akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
queue<P<int,int>> q;
int a[1005][1005],n,lst[1005],b[1005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int x,t;
	FOR(i,1,n)rep(j,1,n)cin>>a[i][j];
	FOR(i,1,n)b[i]=1;
	rep(i,1,n){
		FOR(j,i+1,n){
			if(a[i][1]==j&&a[j][1]==i){
				q.emplace(MP(i,1));
				q.emplace(MP(j,1));
				b[i]++;b[j]++;
				lst[i]=1;lst[j]=1;
			}
		}
	}
	int ans=0,nxt,d;
	P<int,int> cur;
	while(!q.empty()){
		cur=q.front();q.pop();
		gmax(ans,cur.S);
		nxt=a[cur.F][b[cur.F]];
		if(a[nxt][b[nxt]]==cur.F){
			d=max(lst[cur.F],lst[nxt])+1;
			q.emplace(MP(cur.F,d));
			q.emplace(MP(nxt,d));
			b[nxt]++;b[cur.F]++;
			lst[cur.F]=lst[nxt]=d;
		}
	}
	FOR(i,1,n){
		if(b[i]!=n){
			cout<<-1;RE 0;
		}
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

bool in[5][5];

int check(int x1,int y1,int x2,int y2){
  int cnt = 0;
  loop(i,x1,x2+1)
    loop(j,y1,y2+1)
    if(in[i][j])cnt++;
    else return 0;
  return cnt;
}
int main(void){
  int n;
  cin>>n;
  while(n--){
    rep(i,5)rep(j,5)cin>>in[i][j];
    
    int ans = 0;
    rep(i,5)rep(j,5)
      if(in[i][j])
	loop(k,i,5)
	  loop(l,j,5)
	  ans = max(check(i,j,k,l),ans);
    
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int countDivisors(int n) {
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
        	if (n / i == i) cnt++;
        	else cnt = cnt + 2;
        }
    }
    return cnt;
}
 
int main()
{
    int n, cnt = 0; cin >> n;
    for(int i = 1; i <= n; i++) {
    	if(i % 2 != 0) {
    		if(countDivisors(i) == 8) cnt++;
    	}
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n = read_line().trim().parse().unwrap();
    let A: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut min = A[0].abs();
    let mut sum = 0;
    let mut count = 0;

    for i in 0..n {
        min = cmp::min(A[i].abs(), min);
        sum += A[i].abs();
        if A[i] < 0 {
            count += 1;
        }
    }
    let ans = if count %2 > 0 {
        sum - 2 * min
    } else {
        sum
    };

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  
  bool fin1=false, fin2=false;
  for (int i=X;i>0;i--) {
    for (int b=1;b<=31;b++) {
      for (int p=2;p<=9;p++) {
        if (i == pow(b,p)) {
          cout << i << endl;
          fin1 = true;
          break;
        }
      }
      if (fin1) {
        fin2 = true;
        break;
      }
    }
    if (fin2) {
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve(){
	int n,m,a,b;
	cin>>n>>m;
	vector<VI> grid(n+1);
	vector<int> mn(n+1,n+1); 
	rep(i,0,m){
		cin>>a>>b;
		mn[a] = min(mn[a],b);
		grid[a].pb(b);
	}
	int board=n+1,ans=0;
	for(int i=n-1;i;i--){
		if(mn[i]<board){
			board = i+1;
			ans++;
		}
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 3e3 + 10;

int n;
ll a[maxN];

ll dp[maxN][maxN][2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
        dp[i][i][0] = a[i];
        dp[i][i][1] = -a[i];
    }
    fore(d, 2, n)
    {
        for1(i, n - d + 1)
        {
            int j = i + d - 1;
            dp[i][j][0] = max(a[i] + dp[i + 1][j][1], a[j] + dp[i][j - 1][1]);
            dp[i][j][1] = min(dp[i + 1][j][0] - a[i], dp[i][j - 1][0] - a[j]);
        }
    }
    cout << dp[1][n][0];
    return 0;
}


Measured memory_bytes: 141568
unittest
{
	assert( [ "yx", "axy" ].parse.expand.solve == "Yes" );
	assert( [ "ratcode", "atlas" ].parse.expand.solve == "Yes" );
	assert( [ "cd", "abc" ].parse.expand.solve == "No" );
	assert( [ "w", "ww" ].parse.expand.solve == "Yes" );
	assert( [ "zzz", "zzz" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip;
	input.popFront;
	auto t = input.front.strip;
	return tuple( s, t );
}

auto solve( string s, string t )
{
	auto ss = s.to!( dchar[] ).sort();
	auto tt = t.to!( dchar[] ).sort!( ( a, b ) => b < a )();
	
	return ( ss.cmp( tt ) < 0 ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int n;
	cin >> n;
	while (n > 0) {
		if (n % 10 == 7) {
			cout << "Yes";
			return 0;
		}
		n /= 10;
	}
	cout << "No";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll l,r;

int main(){
  cin >> l >> r;
  if(r-l+1>=2019){
    cout << 0 << endl;  return 0;
  }
  ll mi = 2018;
  for(ll i=l ; i<r ; i++){
    for(ll j=i+1 ; j<=r ; j++){
      mi = min(mi, i * j % 2019);
    }
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,m,d=map(int,input().split())

if n>=2*d:
    expe=(n-2*d)*2+2*d if d!=0 else n
elif n>=d:
    expe=2*(n-d)
else:
    expe=0
#print(expe)
print((expe/n**2)*(m-1))


Measured memory_bytes: 2940
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp;
  writeln("ABC" ~ n);
}


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

int main(){
uint64_t H,W,ans;
cin >> H >> W;
if(H==1 || W==1){
    cout << 1 <<endl;
}
else if(H%2!=0 && W%2!=0){
    ans=(H*W)/2+1;
    cout << ans <<endl;
}
else{
    ans=(H*W)/2;
    cout << ans <<endl;
    }
    
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
A = int(input())
B = int(input())
C = int(input())
X = int(input())

y = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            x = a * 500 + b * 100 + c * 50
            
            if x == X:
                y += 1
                
            else:
                pass
            
print(y)

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; ++i) {
        cin >> b[i];
        b[i]--;
    }

    vector<int> ans;
    for (int i = 0; i < N; i++) {
        int p = -1;
        for (int j = 0; j < sz(b); j++) {
            if (b[j] == j) {
                p = j;
            }
        }

        if (p == -1) {
            cout << -1 << endl;
            return 0;
        } else {
            ans.push_back(b[p] + 1);
            b.erase(b.begin()+p);
        }
    }

    reverse(all(ans));
    for (int x : ans)cout << x << endl;

    return 0;
}

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

    void solve() {
	    ll n, k;
	    cin >> n >> k;
	    ll a[n], sum = 0;
	    for(ll i = 0; i < n; i++) cin >> a[i];
	    sort(a, a+n);
	    for(ll i = 0; i < n-k; i++) sum+= a[i];
	    cout << sum << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


Measured memory_bytes: 1792
def run():
  N = int(input())
  di = {}
  for n in range(N):
    S = input()
    di.setdefault(S, 0)
    di[S] += 1
  count_max = max(di.items(), key=lambda x: x[1])[1]
  sorted_li = [k[0]  for k in sorted(di.items(), key=lambda x: x[0]) if k[1] == count_max]
  for s in sorted_li:
    print(s)

if __name__ == '__main__':
  run()


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    for(int i = k; i < n; i++){
        if(a[i] > a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
struct unionfind{
    vector<int> par, sz;
	int cnt;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1), cnt(n){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
		cnt--;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[200020], invf[200020];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
ll dp[5050][5050];
int main()
{
	int n; cin>>n;
	int p[5050];
	int k=0;
	for(int i=0; i<n; i++){
		cin>>p[i]; p[i]--;
		if(p[i]<0) k++;
	}
	unionfind uf(n);
	for(int i=0; i<n; i++){
		if(p[i]>=0) uf.unite(i, p[i]);
	}
	vector<int> x;
	for(int i=0; i<n; i++){
		if(p[i]<0){
			x.push_back(uf.size(i));
		}
	}
	int m=uf.cnt-k;
	dp[0][0]=1;
	for(int i=0; i<k; i++){
		for(int j=0; j<=i; j++){
			(dp[i+1][j]+=dp[i][j])%=MOD;
			(dp[i+1][j+1]+=dp[i][j]*x[i])%=MOD;
		}
	}
	(dp[k][1]+=MOD-k)%=MOD;
	fac(n);
	ll ans=0;
	for(int i=1; i<=k; i++){
		(ans+=f[i-1]*dp[k][i]%MOD*powmod(n-1, k-i))%=MOD;
	}
	(ans+=powmod(n-1, k)*m)%=MOD;
	ans=(powmod(n-1, k)*n+MOD-ans)%MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 120548
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	string s;
	string max_length_string = "";
	map<string, int> m;

	while (cin >> s) {
		m[s]++;
		if (s.size() > max_length_string.size() ) {
			max_length_string = s;
		}
	}

	// 最頻値を求める
	int max = 0;
	string mode = "";
#if 0
	for ( auto x : m ) {
		if (x.second > max) {
			mode = x.first;
			max = x.second;
		}
	}
#else
	for (map<string,int>::iterator it = m.begin(); it != m.end(); it++) {
		if (it->second > max) {
			mode = it->first;
			max = it->second;
		}
	}
#endif
	cout << mode << " " << max_length_string << endl;

	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

class UF {

  vector<int> par; // 親
  vector<int> rank; // 深さ

public:

  void init(int n) { // n個で初期化
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  UF(int n) {
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  int find(int x) { // 木の中のxの深さを返す
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y) { // xとyを統合する
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) { // xとyが等しいかどうか判定する
    return find(x) == find(y);
  }
};

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  vi p(n);
  REP(i, n) {
    cin >> p[i];
    p[i]--;
  }

  UF uf(n);

  REP(i, m) {
    int x, y; cin >> x >> y;
    x--; y--;
    uf.unite(p[x], p[y]);
  }

  int ans = 0;
  REP(i, n) {
    if(uf.same(i, p[i]) || i == p[i]) ans++;
  }
  cout << ans << endl;

  
}


Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000007
#define ll long long
#define mp make_pair
int main()
{
	std::ios::sync_with_stdio(false);
	int n,a[3005],ans=0,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	ans-=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	double f[50],m=0;
	int n=0;
	while(scanf("%lf",&f[n])!=EOF){
		n++;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(f[i]-f[j]>m){
				m=f[i]-f[j];
			}
		}
	}
	printf("%.2lf\n",m);
	return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int a[200010];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    int res[200010] = {0};
    for(int i = 0; i < N; i++){
        res[a[i] - 1]++;
    
    }

    sort(res, res + N, greater<int>());

    int ans = 0;

    for(int i = 0; i < N; i++){
        if(res[i] > 0) ans++;
    }


    ans = ans - K;
    if(ans <= 0){
        cout << 0 << endl;
        return 0;
    }

    int ans2 = 0;
    for(int i = K; i < N; i++){
        ans2 += res[i];
    }

    cout << ans2 << endl;



}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(void){
    char A[201],buf[201];
    int n,i,h;
    while(1){
        scanf("%s",A);
        if(strcmp(A,"-")==0) break;
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d",&h);
            strcpy(buf,A+h);
            strncat(buf,A,h);
            strcpy(A,buf);
        }
        printf("%s\n",A);
    }
    return 0;
}
 

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

using namespace std;

int ans[110][110];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int idx = 0, cnt = a[0];
  for (int i = 0; i < h; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j++) {
        ans[i][j] = idx + 1;
        cnt--;
        if (idx < n - 1 && cnt == 0) {
          idx++;
          cnt = a[idx];
        } 
      }
    } else {
      for (int j = w - 1; j >= 0; j--) {
        ans[i][j] = idx + 1;
        cnt--;
        if (idx < n - 1 && cnt == 0) {
          idx++;
          cnt = a[idx];
        } 
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      cout << ans[i][j] << " ";
    }
    cout << ans[i][w - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    char s;
    std::cin >> s;
    if('A'<=s&&s<='Z'){
        std::cout << "A" << std::endl;
    }else{
        std::cout << "a" << std::endl;
    }
}


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

deque<string> ans(1,"");

inline deque<string> stf(){
    for(int i=0; i<ans.size(); i++){
        if(ans.back().size()>=10) break;
        ans.ph(ans.at(i)+'3');
        ans.ph(ans.at(i)+'5');
        ans.ph(ans.at(i)+'7');
    }
    ans.pop_front();
    for(int i=0; i<3; i++)
        ans.pop_back();
    return ans;
}

bool isstf(string s, int t){
    if(stoi(s)>t) return false;
    vector<bool> n(3,false);
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='3') n.at(0)=true;
        if(s.at(i)=='5') n.at(1)=true;
        if(s.at(i)=='7') n.at(2)=true;
    }
    return n.at(0) and n.at(1) and n.at(2);
}

signed main(){
    int n; cin>>n;
    int num=0;
    stf();
    for(int i=0; i<ans.size(); i++){
        if(!isstf(ans.at(i), n)) ans.at(i)="";
        if(ans.at(i) != "") num++;
    }
    cout<<num<<endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#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;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const int MOD = 1000000007,MAX_N = 500000;
vector<ll> an(MAX_N), bn(MAX_N), bunbo(MAX_N), comb(MAX_N);

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

void makevec(ll a,ll n, vector<ll> &vec){
    ll temp = 1;
    rep(i,n*2+10){
        vec.at(i) = temp;
        (temp *= a)%=MOD;
    }
    return;
}
void makecomb(ll n, vector<ll> &vec){
    ll temp = 1;
    //comb.at(i)が(i-1)C(N-1)になるので、iはNから2N-1
    //つまりi=M
    reps(i,n,n*2){
        vec.at(i) = temp;
        (temp *= i)%=MOD;
        (temp *= fastpow(i-n+1,MOD-2))%=MOD;
    }
    return;
}
int main() {
    cin>>N>>A>>B>>M;
    makevec(A,N,an);
    makevec(B,N,bn);
    makevec(100-M,N,bunbo);
    makecomb(N,comb);
    ll p, q, ans = 0;
    reps(i,N,N*2){
        p = 100*i;
        (p *= comb.at(i))%=MOD;
        ll ab=0;
        (ab += an.at(N)*bn.at(i-N))%=MOD;
        (ab += bn.at(N)*an.at(i-N))%=MOD;
        (p *= ab)%=MOD;
        q = bunbo.at(i+1);
        ll temp = fastpow(q,MOD-2);
        temp %=MOD;
        (temp *= p)%=MOD;
        (ans += temp)%=MOD;
    }
    cout<<ans<<endl;

}

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

ll selfadd(ll a,ll b)
{
	if(a<b)
	return a;
	else return a%b;
}
void solve()
{

	ll	 n;
	
	cin>>n;
	double x=(double)n;
	
	if(n%2==0)cout<<0.5;
	else
	cout<<setprecision(12)<<((n/2)+1)/x;
		
		
	
	
	
	
	}
		
		


int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

/*int memo[3010][3010], n; // pos, ok 
string s;

int dp(int pos, int less) {
	if(pos == n) return 1;
	int& p = memo[pos][less];
	if(p != -1) return p;

	int ret = 0;
	if(s[pos] == '=') {
		for(int i=0; i<n; i++) 
			ret = (ret + dp(pos+1, i)) % MOD;	
	}
	else if(s[pos] == '>') {
		for(int i=0; i < less; i++) {
			ret = (ret + dp(pos+1, i)) % MOD;
		}
	}
	else {
		for(int i=0; i<n-pos-less; i++) {
			ret = (ret + dp(pos+1, less+i)) % MOD;	
		}
	}

	return p = ret;
}*/

int main(){ _

	string s;
	int n; cin >> n >> s;
	s = "=" + s;

	vector<int> memo(n+1), pref(n+1);
	memo[0] = 1;

	function<int(int,int)> sum = [&] (int l, int r) {
		if(r < l) return 0;
		return (((pref[r] - (l ? pref[l-1] : 0)) % MOD) + MOD) % MOD;	
	};

	for(int i=n-1; i>=0; i--) {
		pref[0] = memo[0];

		for(int j=1; j<=n; j++) pref[j] = (pref[j-1] + memo[j]) % MOD;

		for(int j=0; j <= n-i; j++) {
			if(s[i] == '=') {
				memo[j] = sum(0, j-1);
			}
			else if(s[i] == '>') {
				memo[j] = sum(0, j-1);
			}
			else {
				memo[j] = sum(j, n-i-1);
			}
		}
	}	

	cout << memo[n] << endl;

	return 0;
}


Measured memory_bytes: 3692
import collections

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

s = sum(A)
c = collections.Counter(A)

for _ in range(Q):
    B, C = map(int, input().split())
    s += (C-B)*c[B]
    c[C] += c[B]
    c[B] = 0
    print(s)

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

vector <long long> edges[200010];
long long num[200010];

void dfs(int i,int p){
  for(int j:edges[i]) if (j!=p){
    num[j]+=num[i];
    dfs(j,i);
  }
}

int main(){
long long N;
  long long Q;
  cin>>N>>Q;
  for(int i=0; i<N-1; i++){
int a,b;
    cin>>a>>b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }
  for(int i=0; i<Q; i++){
int p,x;
    cin>>p>>x;
    num[p-1]+=x;
  }
  
  dfs(0,-1);
  for(int i=0; i<N; i++){
    cout<<num[i]<<" \n"[i==N-1];
      cout<<endl;
  }
}
  
  


Measured memory_bytes: 24448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main(){
    int n,k,d,can = 0,ans = 0;
    int A[110] = {0};
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> can;
            //cout << can << endl;
            A[can - 1] = A[can - 1] + 1;
        }
    }
    for(int i = 0; i < n; i++){
        //cout << A[i] << endl;
        if(A[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

int main(){
    int const INF = 1000000000;
    int h, n;
    cin >> h >> n;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    int dp[n+1][h+1];
    rep(i, n + 1)rep(j, h + 1) dp[i][j] = INF; 
    rep(i, n + 1) dp[i][0] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= h; j++){
            if (j >= a[i-1]){
                dp[i][j] = min(dp[i-1][j], dp[i][j - a[i-1]] + b[i-1]);    
            }else{
                dp[i][j] = min(dp[i-1][j], dp[i][0] + b[i-1]);
            }
        }
    }
    // rep(i, n + 1){
    //     rep(j, h + 1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][h] << endl;
}


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

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

    vector<bool> check(4, false);
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] == 'N') check[0] = true;
        if (S[i] == 'W') check[1] = true;
        if (S[i] == 'S') check[2] = true;
        if (S[i] == 'E') check[3] = true;
    }

    if (check[0] == check[2] && check[1] == check[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	if (a > 9 || b > 9) { cout << -1 << endl; }
	else { cout << a * b << endl; }
	return 0;
}


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

using namespace std;

int arr[105];
int mem[100005];
int n,k;

int go(int x)
{
	if(x<0) return 1;
	if(x==0) return 0;
	if(mem[x]!=-1) return mem[x];
	for(int i=0;i<n;i++)
		if(!go(x-arr[i])) return mem[x]=1;
	return mem[x]=0;
}

int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> arr[i];
	memset(mem,-1,sizeof mem);
	cout << (go(k)?"First":"Second") << endl;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int64_t *a1, int *a2) {
  scanf("%lld %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int64_t *a2, int *a3) {
  scanf("%d %lld %d", a1, a2, a3);
  return 0;
}

struct monster {
    int64_t pos;
    int hp;
};

int asc_by_pos(const void *a1, const void *a2) {
    struct monster *ma1 = (struct monster*)a1;
    struct monster *ma2 = (struct monster*)a2;
    return ma1->pos - ma2->pos;
}

#define NUM_MAX 200000
#define NUM2_MAX (1<<18)
#define ROOT_NODE 1
#define INF ((int64_t)(3e+9)+1)

struct range {
    int start;
    int end;
};

int64_t get_val(int64_t* seg, int num, int idx) {
    int node = num+idx;
    int64_t ans = 0;
    while(node) {
        ans += seg[node];
        node /= 2;
    }
    return ans;
}

int is_contain(struct range this, struct range box) {
    return box.start <= this.start && box.end >= this.end;
}

int is_overlap(struct range r1, struct range r2) {
    return r1.end >= r2.start && r2.end >= r1.start;
}

void add_range(int64_t *seg, int64_t val, struct range r, int node, struct range nr) {
#ifdef DEBUG
    printf("add_range(seg, %lld, r, %d)\n", val, node);
#endif
    if(is_contain(nr, r)) {seg[node] += val; return;}
    if(!is_overlap(r, nr)) return;
    struct range left = {nr.start, (nr.start+nr.end)/2};
    struct range right = {left.end+1, nr.end};
    add_range(seg, val, r, node*2, left);
    add_range(seg, val, r, node*2+1, right);
    return;
}

#define ROOT_NODE 1
int main(void) {
    int num, attack;
    int64_t range;
    static struct monster mons[NUM_MAX+1];
    get_int3(&num, &range, &attack);
    range *= 2;
    int num2 = 1;
    while(num > num2) num2 *= 2;

    int i;
    for(i = 0; i < num; i++) {
        get_int2(&mons[i].pos, &mons[i].hp);
    }
    mons[num] = (struct monster){INF, 0}; // guard
    qsort(mons, num, sizeof(struct monster), asc_by_pos);

    static int64_t seg[NUM2_MAX*2];
    for(i = 0; i < num; i++) {
        seg[i+num2] = mons[i].hp;
    }

    int left;
    int right = 0;
    int64_t ans = 0;

    struct range whole = {0, num2-1};
    for(left = 0; left < num+1; left++) {
        if(left == right) { right++; }
        int64_t rem = get_val(seg, num2, left);
        if(rem <= 0) continue; // if no hit point, break;
        // ensure that mons[left] should be attacked
        for(;right < num+1; right++) {
            if(mons[left].pos + range < mons[right].pos) break;
        }
#ifdef DEBUG
        printf("[%d, %d)\n", left, right);
#endif
        // attack
        int64_t cnt = (rem-1)/attack + 1;
        int64_t damage = (int64_t)attack * cnt;
        struct range r = {left, right-1};
        add_range(seg, -damage, r, ROOT_NODE, whole);
        ans += cnt;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
const int N = 1e6;
ll ar[N];
ll dp[N];
int main(){
	Fast;
    ll n;
    cin >> n;
    n=2*n;
    fn{
        cin >> ar[i];
    }
    sort(ar,ar+n);
    ll ans=0;
    for(int i =0;i<n-1;i+=2){
        ans+=min(ar[i],ar[i+1]);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#define ll long long
#define int ll
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define gcd(A,B) (__gcd(A,B))
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;
vector <pii> work;
int curt = 0;
int32_t main()
{
    usecppio
    int n;
    cin >> n;
    for (int i = 0; i<n; i++)
    {
        ll a, b;
        cin >> a >> b;
        work.push_back({b,a});
    }
    sort(all(work));
    for (auto it:work)
    {
        curt += it.second;
        if (curt > it.first)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 6128
#include <iostream>
using namespace std;
string s;
int main()
{
    cin >> s;
    int res = 0;
    int len = s.size();
    for(int i = 0; i < len/2; i ++){
        if(s[i] != s[len-1-i]) res ++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
S = [input() for i in range(N)]

c = Counter(S)

counts = ["AC", "WA", "TLE", "RE"]

for i in counts:
    print(i + " x " + str(c[i]))

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

using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int head[maxn];
vector<int> v[maxn];
int n;
int vis[maxn];
int flag,cnt;
void dfs(int x)
{
    if(x==n)
    {
        flag=1;
        return;
    }
    for(int i=0;i<v[x].size();i++)
    {
        if(!vis[v[x][i]])
        {
            vis[v[x][i]]=1;
            head[v[x][i]]=x;
            dfs(v[x][i]);
        }
        if(flag)
            break;
    }
}

void dfs1(int x)
{
    for(int i=0;i<v[x].size();i++)
    {
        if(vis[v[x][i]])
            continue;
        vis[v[x][i]]=1;
        cnt++;
        dfs1(v[x][i]);
    }
}

int main()
{
    memset(head,-1,sizeof(head));
    cin >> n;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1);
    int num=0;
    int ans=n;
    memset(vis,0,sizeof(vis));
    while(head[ans]!=1)
    {
        num++;
        ans=head[ans];
    }
    num/=2;
    ans=head[n];
    vis[n]=1;
    vis[1]=1;
    for(int i=0;i<num;i++)
    {
        cnt++;
        vis[ans]=1;
        for(int j=0;j<v[ans].size();j++)
        {
            if(v[ans][j]==head[ans])
                continue;
            if(!vis[v[ans][j]])
            {
                cnt++;
                vis[v[ans][j]]=1;
                dfs1(v[ans][j]);
            }
        }
        ans=head[ans];
    }
    for(int i=0;i<v[n].size();i++)
    {
        if(v[n][i]==head[n])
            continue;
        if(!vis[v[n][i]])
        {
            cnt++;
            vis[v[n][i]]=1;
            dfs1(v[n][i]);
        }
    }
    int cn=n-2-cnt;
 //   cout << cn << endl;
  //  cout << cnt << endl;
    if(cn>cnt)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
    return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    string a;cin>>a;
    for(int bit=0;bit<(1<<3);bit++){
        vector<int>S = bitSearch(bit,3);
        if(S.size() == 0)continue;
        int sum = a[0]-'0';
        REP(i,1,3){
            if(i-1 == *lower_bound(ALL(S),i-1))sum += a[i]-'0';
            else sum -= a[i]-'0';
        }
        //cout<<sum<<" ";
        if(sum == 7){
            cout<<a[0];
            REP(i,1,3){
                if(i-1 == *lower_bound(ALL(S),i-1))cout<<'+'<<a[i];
                else cout<<'-'<<a[i];
            }
            cout<<'='<<7;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	char a[10000];
	int n,i,j,len,num;
	scanf("%d",&n);
	scanf("%s",a);
	len=strlen(a);
	for(i=0;i<len;i++){
		a[i]+=n;
		if(a[i]>'Z'){
			a[i]-=26;
		}
	}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 128
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	d, n := nextInt(), nextInt()

	c := n
	if n == 100 {
		c = 101
	}
	for i := 0; i < d; i++ {
		c *= 100
	}
	fmt.Println(c)
}


Measured memory_bytes: 640
import math

a, b, x = map(int, input().split())
if (a*a*b)/2 >= x:
    print(90 - math.atan((2*x)/(a*b*b)) * 180 / math.pi)
else:
    print(math.atan((2*b - 2*x/(a*a)) / a) * 180 / math.pi)


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

int main() {
  int n,l; cin>>n>>l;
  vector<string>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<n;i++){
  	cout<<vec[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007

int main() {
	int n, k;
	cin >> n >> k;
	VI x(n);
	for (int i = 0; i < n; i++) cin >> x[i];

	int sum = 0,memo;
	for (int i = 0; i < n; i++) {
		memo = abs(x[i] - k);
		sum += min(memo, x[i]);
	}
	cout << sum*2 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

lines = sys.stdin.readlines()
N = int(lines[0])

stdin = list(map(int,lines[1].split(' ')))

lst = []
S1, S2 = 0, sum(stdin)
for i, a in enumerate(stdin):
    S1 += a
    S2 -= a
    lst.append(abs(S1-S2))

print(min(lst))

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,C;
int D[33][33];
int col[555][555];

int cost[1111][33];

signed main(){
    cin>>N>>C;
    rep(i,C)rep(j,C)cin>>D[i][j];

    rep(i,N)rep(j,N)cin>>col[i][j],col[i][j]--;

    rep(i,N)rep(j,N){
        rep(k,C){
            cost[i+j][k]+=D[col[i][j]][k];
        }
    }

    int ans=LLONG_MAX;
    rep(i,C)rep(j,C)rep(k,C){
        if(i==j||j==k||k==i)continue;
        int val=0;
        rep(l,2*N-1){
            if(l%3==0)val+=cost[l][i];
            else if(l%3==1)val+=cost[l][j];
            else val+=cost[l][k];
        }
        chmin(ans,val);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
int data[n];
for(i=0;i<n;i++){
scanf("%d",&data[i]);
}
for(i=n-1;i>0;i--){
printf("%d ",data[i]);
}
printf("%d\n",data[0]);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n){
    if((i+1) % 3 == 0 || (i+1) % 5 == 0){
      continue;
    }
    ans += i+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
int main(void)
{
	int a,c;
	char  b[11];
	int i;

	scanf("%d", &a);
	scanf("%s", &b);
	scanf("%d", &c);

	
	int target;

	target = b[c-1];
	for (i = 0; i < a; i++) {
		if (b[i] != target) {
			b[i] = '*';
		}
	}

	for (i = 0; b[i] != '\0'; i++) {
		printf("%c", b[i]);
	}
	printf("\n");
/**
	printf("%c\n", target);
	for (i = 0; i < 10; i++) {
		
	}*/
	

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long sum=0;
	cin>>n;
	int a[n],b[n];
	cin>>a[1];
	b[0]=a[1];
	for(int i=2;i<n;i++){
		cin>>a[i];
		if(a[i]>=a[i-1]){
			b[i-1]=a[i-1];
		}
		else{
			b[i-1]=a[i];
		}
	}
	b[n-1]=a[n-1];
	for(int i=0;i<n;i++){
		sum+=b[i];
	}
	cout<<sum;
}


Measured memory_bytes: 3596
(defmacro alambda (parms &body body)
  `(labels ((self ,parms ,@body))
     #'self))

(let ((str1 (read-line))
      (str2 (read-line)))
  (labels ((string-rotate (str)
             (concatenate 'string (subseq str 1) (subseq str 0 1))))
    (if (funcall (alambda (str1 str2 n)
                       (if (string= str1 str2)
                           t
                           (if (zerop n)
                               nil
                               (self (string-rotate str1) str2 (1- n)))))
                 str1 str2 (length str1))
        (princ "Yes")
        (princ "No"))))

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

int main(){
	string s,t; cin>>s>>t;
	if(s==t) {cout<<"Yes"<<endl; return 0;}
	
	int k=s.size();
	rep(i,k){
		string r=s.substr(k-1,1);
		s.erase(k-1,1);
		r+=s.substr(0,k);
		s=r;
		if(s==t) {cout<<"Yes"<<endl; return 0;}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3600
import java.util.*;
import java.lang.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++)
        {
            a[i] = s.nextInt();
            sum+=a[i];
        }
        int p = sum/n;
        int ans1=0;
        int ans2=0;
        for(int i=0; i<n; i++)
        {
            ans1+=Math.pow((a[i]-p),2);
            ans2+=Math.pow((a[i]-p-1),2);
        }
        if(ans1<ans2)
        System.out.println(ans1);
        else System.out.println(ans2);
    }
}

Measured memory_bytes: 21332
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    string S; cin >> S;
    REP(i, 1, S.size() + 1)
    {
        char c = S[i - 1];
        if (c == 'U' || c == 'D') continue;
        if (i % 2 == 0 && c != 'L' || i % 2 != 0 && c != 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main(){
  int A, B, max=-200;
  cin >> A >> B;
  if(A+B > max) max = A+B;
  if(A-B > max) max = A-B;
  if(A*B > max) max = A*B;
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using Graph=vector<vector<int>>;
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; }
const long long INF=1LL<<60;
const long long MOD=1e9+7;

int n;
double p[3010];
double dp[3010][3010];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i) cin>>p[i];
    for(int i=0;i<=n;++i){
        for(int j=0;j<=n;++j){
            dp[i][j]=0.0;
        }
    }
    dp[0][0]=1.0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
        }
    }

    double ans=0.0;
    for(int j=n/2+1;j<=n;++j) ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

int N,a[100010],K,res,d[100010]; vector<int> g[100010];

void dfs(int nod){
    int i;
    for (i=0; i<g[nod].size(); i++){
        dfs(g[nod][i]);
        if (d[g[nod][i]]==K-1) res++;
        else d[nod]=max(d[nod],d[g[nod][i]]+1);
    }
}

int main(){
    cin >> N >> K;

    int i;
    for (i=1; i<=N; i++) cin >> a[i];

    if (a[1]!=1) a[1]=1,res++;
    for (i=2; i<=N; i++)
        g[a[i]].push_back(i);

    for (i=0; i<g[1].size(); i++)
        dfs(g[1][i]);


    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 11136
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; 
    cin>>n; 
    int ans=0,i=1;
    while (n>0){
        ans += i; i *= 2; n /= 2; 
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

void f(int n) {
    if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7) cout << "Yes" <<endl;
    else cout << "No" << endl;
}
int main() {
    int R;
    cin >> R;
    cout << 2.0 * M_PI * R <<endl;
    return 0;
}

Measured memory_bytes: 3776