akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define pb push_back 
#define gc getchar 
#define mp make_pair
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define vi vector<int>
#define vc vector<char>
#define pdd pair<double,double>
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define vvi vector<vector<int> >
#define vvli vector<vector<long long int> >
#define vli vector<long long int> 
#define pq priority_queue 
#define lli long long int
#define li long int
#define ff first
#define len length
#define ss second
#define take(n,inp) rep(i,n){int x;cin>>x;inp.pb(x);}
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define M 1000000007
#define PI 3.14159265358979323
using namespace std;
     /*ios_base::sync_with_stdio(false);
         cin.tie(NULL);*/
template <typename T>
void printvec(vector<T>& vec){
   rep(i,vec.size()){
       cout<<vec[i]<<" ";
   }
   cout<<endl;
}

lli arr[3][101]={0};
lli dp[3][101]={0};
int main() {


	lli n;
	cin>>n;


	repi(i,1,2)
	{
		repi(j,1,n)
		{
			cin>>arr[i][j];
		}
	}


	repi(i,1,n)
	{

		//cout<<dp[1][i]<<" "<<dp[2][i]<<"\n";
		dp[1][i] = dp[1][i-1] + arr[1][i];  

		dp[2][i] = max(dp[1][i],dp[2][i-1]) + arr[2][i];

		//cout<<dp[1][i]<<" "<<dp[2][i]<<"\n";
	}

	cout<<dp[2][n]<<"\n";





   
   
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int t = 1;
  for(int i = 0; i < N; ++i){
    if(A[i] != t) continue;
    ++t;
  }
  if(t == 1){
    cout << -1 << endl;
    return 0;
  }
  cout << N-t+1 << endl;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>

using namespace std;

int n,m;
int c[30],dp[50004];
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)
    scanf("%d",&c[i]);


  for(int i=1;i<=n;i++){
    dp[i]=i;
    for(int j=0;j<m;j++){
      if(i==c[j]){
        dp[i]=1;
        break;
      }else{
        if(i>c[j])
        dp[i]=min(dp[i],dp[i-c[j]]+dp[c[j]]);
        //cout << "i: " << i << "   c[j]: " << c[j] << endl;
      }
    }
    //cout << i<< " :" <<dp[i] << endl;
  }


  printf("%d\n",dp[n]);

  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll N, A, B; cin >> N >> A >> B;
    if (abs(A - B) % 2 == 0) {
        cout << abs(A - B) / 2 << endl;
        return 0;
    }
    ll ans = min(min(A, B), min(N-A, N-B)+1);
    if (min(A, B) < min(N-A, N-B)+1) {
        if (A < B) {
            ans = ans + max(0LL, (B-ans) / 2);
        } else {
            ans = ans + max(0LL, (A-ans) / 2);
        }
    } else {
        if (A < B) {
            ans = ans + max(0LL, (N-A - ans) / 2);
        } else {
            ans = ans + max(0LL, (N - B - ans) / 2);
        }
    }
    cout << ans << endl;
    // else cout << min(min(max(A, B) - 1, abs(A - B) / 2 + 1), max(N - A, N - B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_NUM_BOXES 200000

int main()
{
  int N;
  int M;
  int a[MAX_NUM_BOXES + 1];

  /* input */
  scanf("%d", &N);
  for (int i=1; i<=N; i++) scanf("%d", &a[i]);

  /* compute */
  M = 0;
  for (int i=N; i>=1; i--) {
    for (int j=i+i; j<=N; j+=i) {
      a[i] += a[j];
    }
    a[i] %= 2;
    if (a[i] == 1) M++;
  }

  /* output */
  printf("%d\n", M);
  for (int i=1; i<=N; i++) {
    if (a[i] == 1) printf("%d ", i);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

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

    switch((a-1)%4) {
        case 0:
            a = a-1;
            break;
        case 1:
            a = 1;
            break;
        case 2:
            a = (a-1)^1;
            break;
        case 3:
            a = 0;
            break;
    }

    switch(b%4) {
        case 0:
            break;
        case 1:
            b = 1;
            break;
        case 2:
            b = b^1;
            break;
        case 3:
            b = 0;
            break;
    }

    cout << (a^b) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    long long int n = a.size();
    long long int m = b.size();
    long long int dp[n+1][m+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else if(a[i-1]==b[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i=n,j=m;
    string ans="";
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            ans = a[i-1]+ans;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else j--;
    }
    cout<<ans<<endl;
 
}

Measured memory_bytes: 73940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

/**
 * The Code A Doctor Loved
 */
public class Main {

	static final HashMap<Character, String> c1 = new HashMap<Character, String>() {
		{
			put(' ', "101");
			put('\'', "000000");
			put(',', "000011");
			put('-', "10010001");
			put('.', "010001");
			put('?', "000001");
			put('A', "100101");
			put('B', "10011010");
			put('C', "0101");
			put('D', "0001");
			put('E', "110");
			put('F', "01001");
			put('G', "10011011");
			put('H', "010000");
			put('I', "0111");
			put('J', "10011000");
			put('K', "0110");
			put('L', "00100");
			put('M', "10011001");
			put('N', "10011110");
			put('O', "00101");
			put('P', "111");
			put('Q', "10011111");
			put('R', "1000");
			put('S', "00110");
			put('T', "00111");
			put('U', "10011100");
			put('V', "10011101");
			put('W', "000010");
			put('X', "10010010");
			put('Y', "10010011");
			put('Z', "10010000");
		}
	};

	static final HashMap<String, Character> c2 = new HashMap<String, Character>() {
		{
			put("00000", 'A');
			put("00001", 'B');
			put("00010", 'C');
			put("00011", 'D');
			put("00100", 'E');
			put("00101", 'F');
			put("00110", 'G');
			put("00111", 'H');
			put("01000", 'I');
			put("01001", 'J');
			put("01010", 'K');
			put("01011", 'L');
			put("01100", 'M');
			put("01101", 'N');
			put("01110", 'O');
			put("01111", 'P');
			put("10000", 'Q');
			put("10001", 'R');
			put("10010", 'S');
			put("10011", 'T');
			put("10100", 'U');
			put("10101", 'V');
			put("10110", 'W');
			put("10111", 'X');
			put("11000", 'Y');
			put("11001", 'Z');
			put("11010", ' ');
			put("11011", '.');
			put("11100", ',');
			put("11101", '-');
			put("11110", '\'');
			put("11111", '?');
		}
	};

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			//
			StringBuilder sb1, sb2;
			sb1 = new StringBuilder();
			sb2 = new StringBuilder();
			for (char c : line.toCharArray()) {
				sb1.append(c1.get(c));
			}
			//
			sb1.append("00000");
			//
			String line2 = sb1.toString();
			for (int i = 0; i < line2.length() - 5; i += 5) {
				sb2.append(c2.get(line2.substring(i, i + 5)));
			}
			System.out.println(sb2.toString());
		}
	}
}

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

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

    if(k * 3 == s){
        cout << 1 << endl;
        return 0;
    }
    
    int count = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int p = s - i - j;
            //cout << p << endl;
            if(p >= 0 && p <= k){
                count++;
            }
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());		
		int i=0;
		int j=0;
		while(h!=0 && w!=0){
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					if(i==0||j==0||i==h-1||j==w-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println("");
			}	
			h = Integer.parseInt(scan.next());
			w = Integer.parseInt(scan.next());
                        System.out.println("");	
		}
	}
}

Measured memory_bytes: 25752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << endl
#define _ << ", " <<

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e3 + 3;
const ll INF = 1e9 + 37;

ll n, d, a[N][N], res;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> d;
	for (ll i = 1; i <= n; ++i) {
		for (ll j = 1; j <= d; ++j) cin >> a[i][j];
	}
	
	res = 0;
	for (ll i = 1; i <= n; ++i) {
		for (ll j = i + 1; j <= n; ++j) {
			ll sum = 0;
			for (ll k = 1; k <= d; ++k) {
				sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			if (sqrt(sum) == (ll)sqrt(sum)) ++res;
		}
	}
	cout << res;
	
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

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

  vector<ll> A(N), F(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];
  sort(ALL(A));
  sort(ALL(F), greater<ll>());

  ll l = -1, r = 10e12;
  while (l + 1 < r)
  {
    ll mid = (l + r) / 2, sum = 0;
    rep(i, N)
    {
      sum += max(A[i] - mid / F[i], 0ll);
    }
    if (K < sum)
      l = mid;
    else
      r = mid;
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class Main {
	static boolean debug = false;

	public static void main(String[] args) throws IOException {

		UserScanner scan = new UserScanner();
		PrintWriter pwriter = new PrintWriter(System.out);

		String s1 = scan.next();
		String s2 = scan.next();

		pwriter.println(StringDef.getDistance(s1, s2));

		pwriter.flush();
		scan.close();
		System.exit(0);
	}
}

class StringDef {
	static int[][] hist;

	public static int getDistance(String s1, String s2) {
		hist = new int[s1.length() + 1][s2.length() + 1];
		for (int p1 = 0; p1 < hist.length; p1++)
			for (int p2 = 0; p2 < hist[0].length; p2++)
				hist[p1][p2] = -1;
		return minDist(s1, s2, 0, 0);

	}

	private static int minDist(String s1, String s2, int p1, int p2) {
	//	System.out.println(p1 + " " + p2);
		if (p1 == s1.length() && p2 == s2.length())
			return 0;
		if (hist[p1][p2] >= 0)
			return hist[p1][p2];
		int ret = Integer.MAX_VALUE;
		if (p1 < s1.length() && p2 < s2.length())
			if (s1.charAt(p1) == s2.charAt(p2))
				ret = minDist(s1, s2, p1 + 1, p2 + 1);
			else // institution
				ret = 1 + minDist(s1, s2, p1 + 1, p2 + 1);
		// insertion
		if (p2 < s2.length())
			ret = Math.min(ret, 1 + minDist(s1, s2, p1, p2 + 1));
		// deletion
		if (p1 < s1.length())
			ret = Math.min(ret, 1 + minDist(s1, s2, p1 + 1, p2));

		hist[p1][p2] = ret;
		return ret;
	}

}

class UserScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean read() throws IOException {
		ptr = 0;
		buflen = in.read(buffer);
		if (buflen <= 0)
			return false;
		else
			return true;
	}

	private byte getByte() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			return -1;
		} else
			return buffer[ptr++];
	}

	private void skipCtlSpace() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			ptr++;
			skipCtlSpace();
		}
	}

	private boolean isCtlSpace(byte b) {
		if (b <= ' ' || b > '~')
			return true;
		else
			return false;
	}

	public void close() throws IOException {
		in.close();
	}

	public String next() throws IOException {
		skipCtlSpace();
		StringBuilder sb = new StringBuilder();
		byte b;
		while ((b = getByte()) != -1) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() throws IOException {
		skipCtlSpace();
		int n = 0;
		boolean minus = false;
		byte b;
		while ((b = getByte()) != -1) {
			if (b == '-')
				minus = true;
			else {
				n *= 10;
				n += (b - '0');
			}
		}
		if (minus)
			return n * -1;
		else
			return n;
	}
}

Measured memory_bytes: 31128
m=10**9+7
f=max
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()));s=-1;i=j=1
	while j<=x and i+j<=y:i,j,s=j,i+j,s+1
	if x<2 or y<3:print(1,x*y%m);continue
	a=f(0,(y-j)//i+1)+f(0,(x-j)//i+1);i=j=1
	for c in r(s):
		k,l=j,i+j*2
		for _ in r(s-c):k,l=l,k+l
		a+=(y>=k)*f(0,(x-l)//k+1)+(x>=k)*f(0,(y-l)//k+1)
		i,j=j,i+j
	print(s+1,a%m)

Measured memory_bytes: 82808
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int p[100];
    cin >> n;
    imfor(i, n) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i <= n - 2; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            ans++;
        }
        else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int ,int );

int main(){

  int x,y,n;
  
  scanf("%d %d",&x,&y);
  n=gcd(x,y);

  printf("%d\n",n);

  return 0;
}

int gcd(x,y){
  int n,x1,y1;

  if(x>y){
    y1=y;
    x1=x;
  }else if(x<y){
    y1=x;
    x1=y;
  }

  while(y1>0){
    n=x1%y1;
    x1=y1;
    y1=n;
  }

  return x1;

}



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

using namespace std;
int n,subtree[100005], parent[100005];
vector<int> G[100005],sub;

void dfs(int v, int p){
    subtree[v] = 1;
    parent[v] = p;
    for( int i = 0; i < G[v].size(); i ++){
        if(G[v][i]==p)continue;
        dfs(G[v][i],v);
        subtree[v] += subtree[G[v][i]];
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i = 0; i < n-1; i ++){
        int a, b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1, -1);

    int sum = 0,now = n;
    while(1){
        if(parent[now] == 1)break;
      // cout<<now<<endl;
        sub.push_back(subtree[parent[now]] - subtree[now]);
        sum +=subtree[parent[now]] - subtree[now];
        now = parent[now];
    }
    int fi=0,se=0;
    int mid = sub.size()/2;
    if(sub.size()%2==1)mid++;
    for(int i = 0 ; i < sub.size(); i++){
        if(i<mid)fi+=sub[sub.size()-1-i];
        else se+=sub[sub.size()-1-i];
    }
//cout<<fi<<' '<<se;
    fi+=(n-subtree[now]-1);
    se+=subtree[n]-1;

    if(fi>se)cout<<"Fennec";
    else cout<<"Snuke";

    return 0;
}


Measured memory_bytes: 13436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0){
        cout << 1;
    }else if(b==0){
        cout << 2;
    }else if(c==0){
        cout << 3;
    }else if(d==0){
        cout << 4;
    }else if(e==0){
        cout << 5;
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int MAX_V = 100;
std::vector<int> G[MAX_V], rG[MAX_V];
int used[MAX_V];
std::vector<int> postOrder;

void dfs(int v){
    used[v] = 1;
    REP(i, G[v].size()){
        int u = G[v][i];
        if(!used[u]){
            dfs(u);
        }
    }

    postOrder.push_back(v);
}

void rdfs(int v){
    used[v] = 1;
    REP(i, rG[v].size()){
        int u = rG[v][i];
        if(!used[u]){
            rdfs(u);
        }
    }
}

int main(){
    int V, E;
    std::cin >> V >> E;

    REP(i, E){
        int u, v;
        std::cin >> u >> v;
        G[u].push_back(v);
        rG[v].push_back(u);
    }

    REP(v, V){
        if(!used[v]){
            dfs(v);
        }
    }

    std::fill(used, used+V, 0);
    int n = 0;
    for(int i=V-1;i>=0;i--){
        int v = postOrder[i];
        if(!used[v]){
            n++;
            rdfs(v);
        }
    }

    if(n != V){puts("1");}
    else{puts("0");}
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		geta = new long[14];
		for(int i = 0; i < geta.length; i++){
			geta[i] = (long)Math.pow(26, i);
			if(i >= 1){
				geta[i] += geta[i - 1];
			}
//			System.out.println(geta[i]);
		}
		int len = 0;
		for(int i = geta.length - 1; i >= 0; i--){
			if(n >= geta[i]){
				len = i + 1;
				break;
			}
		}

		n -= geta[len - 1];

		String result = "";
		while(true){
			result = (char)(n % 26 + 'a') + result;
			n /= 26;

			if(n == 0){
				break;
			}
		}

		while(result.length() < len){
			result = "a" + result;
		}
		System.out.println(result);
//		geta = new long[14];
//		for(int i = 0; i < geta.length; i++){
//			geta[i] = (long)Math.pow(26, i);
//			if(i >= 1){
//				geta[i] += geta[i - 1];
//			}
//			System.out.println(geta[i]);
//		}
//
//
//		System.out.println(solve(n));

//		if(n == 0){
//			System.out.println('a');
//			return;
//		}
//
//		String name = "";
//		while(n > 0){
//			char tmp = (char)(n%26 + 'a' - 1);
//			if(n%26 == 0){
//				tmp = 'z';
//			}
//			name = tmp + name;
//
//			n /= 26;
//		}
//
//		System.out.println(name);
	}

	static long[] geta;
	static String solve(long num){
		if(num <= 26){
			return (char)(num + 'a' - 1) + "";
		}

		int len = 0;
		for(int i = geta.length - 1; i >= 0; i--){
			if(num >= geta[i]){
				len = i + 1;
				break;
			}
		}
		System.out.println(len);

		String result = (char)(num / (geta[len - 1] - 1) + 'a')+"";// + solve(num % geta[len - 1] - 1);

		return result;
	}
}

Measured memory_bytes: 26904
#include<bits/stdc++.h>
// #include<chrono>
using namespace std;
// using namespace std:chrono;
#define ll long long
#define pb push_back
#define mk make_pair
#define fori0 for(ll i=0;i<n;i++)
#define fori1 for(ll i=1;i<=n;i++)
#define modu 1000000007
ll mod_power(ll n,ll x,ll mod)
{
	ll res = 1; 
	n=n%mod;
	if(n==0)
	{
		return 0;
	}  
    while(x>0) 
    {   
        if(x&1)
        { 
            res=(res*n)%mod; 
        }   
        x=x>>1; 
        n=(n*n)%mod;
    } 
    return res; 
}
ll power(ll n,ll x)
{
	ll res = 1;   
    while(x>0) 
    {   
        if(x&1)
        { 
            res=res*n; 
        }   
        x=x>>1; 
        n=n*n;
    } 
    return res; 
}
ll countDigit(ll n) 
{ 
    if (n == 0) 
        return 0; 
    return 1 + countDigit(n / 10); 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w", stdout);
	ll t;
	// cin>>t;
	t=1;
    ll z=t;
    while(t--)
    {
        string n;
        cin>>n;
        ll sum=0;
        for(ll i=0;i<n.size();i++)
        {
            sum+=n[i]-'0';
        }
        if(sum%9==0)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
	return 0;
}

Measured memory_bytes: 3728
#!/usr/bin/env python3
import sys


def solve(r: int):
    print(3 * r ** 2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N,M=map(int,input().split())

x=[-1]*N
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if ((s==c==0 and N>1) or
       x[s]!=-1 and x[s]!=c):
        print(-1)
        exit()
    x[s]=c

if x[0]==-1:
    x[0]=0+(N>1)
for i in range(N):
    if x[i]==-1: x[i]=0

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


Measured memory_bytes: 61892
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
	int n;
	cin>>n;
		if(n<1200)
	 		cout<<"ABC"<<endl;
	 	else if(n<2800)
	 		cout<<"ARC"<<endl;
		else
			cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
H, W = STDIN.gets.split(' ').map{|s| s.to_i}
S = []
while line = STDIN.gets
  S << line.chomp.split('')
end

INF = -1
DI  = [-1, 0, 1, 0]
DJ  = [0, -1, 0, 1]

ans = 0
queue = []
0.upto(H-1) do |si|
  0.upto(W-1) do |sj|
    # puts "--- si:#{si} sj:#{sj} ---"
    next if S[si][sj] == '#'
    dist = Array.new(H).map{|a| Array.new(W, INF)}

    dist[si][sj] = 0
    queue << [si, sj]
    while(!queue.empty?) do
      i,j = queue.shift
      # puts "i:#{i},j:#{j}"
      0.upto(3) do |n|
        # 隣接マスの距離を求める
        ni = i + DI[n]
        nj = j + DJ[n]
        # puts "ni:#{ni} nj:#{nj}"
        # マップからはみ出てる
        next if ni < 0 or ni >= H or nj < 0 or nj >= W
        # 壁
        next if S[ni][nj] == '#'
        # すでに訪れた
        next if dist[ni][nj] != INF

        # はじめてだから距離を求める
        dist[ni][nj] = dist[i][j] + 1
        queue << [ni, nj]
      end
    end
    # si, sjがスタート地点での最大経路
    ans = [ans, dist.map{|w| w.max}.max].max
  end
end

puts ans



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

int main(){

	int A, B;
	cin >> A >> B;
	int ans = 0;
	for(int i = A; i <= B; i++)
	{
		vector<int> a(10);
		int k = i;
		for(int j = 0; j < 5; j++)
		{
			a[j] = k%10;
			k /= 10;
		}
		if(a[0] == a[4] && a[1] == a[3]) ans++;
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};
/*_________________________________________________________*/

const long long MOD=1e9+7,N=1e5+5;
int solve()
{
	int s,ans=0;
	cin>>s;
	int dp[s+1];
	fill(dp,0);
	dp[0]=1;
	for(int i=3;i<=s;i++){
		for(int j=0;j<=i;j++){
			if(i-j>=3)
			dp[i]+=dp[j];
			dp[i]%=MOD;
		}
	}
	return dp[s];
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--)
	cout<<solve()<<endl;
}

Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

type kakko struct {
	str string
	min int
	max int
}

func main() {
	N := getStdinInt()
	F := make([]kakko, 0, N)
	L := make([]kakko, 0, N)
	for i := 0; i < N; i++ {
		s := getStdin()
		min, max := minmaxKakko(s)
		if min >= 0 {
			F = append(F, kakko{s, min, max})
		} else {
			L = append(L, kakko{s, min, max})
		}
	}
	sort.Slice(F, func(i, j int) bool { return F[i].min < F[j].min })
	sort.Slice(L, func(i, j int) bool { return L[i].max > L[j].max })

	K := make([]kakko, N)
	for i := 0; i < len(F); i++ {
		K[i] = F[i]
	}
	for i := 0; i < len(L); i++ {
		K[i+len(F)] = L[i]
	}

	first := -1
	last := -1
	for i := 0; i < len(K); i++ {
		if K[i].str[0] == '(' {
			first = i
			break
		}
	}
	for i := len(K) - 1; i >= 0; i-- {
		if first != i && K[i].str[len(K[i].str)-1] == ')' {
			last = i
			break
		}
	}

	if first == -1 || last == -1 {
		fmt.Printf("No\n")
		return
	}

	stack := 0
	stack = okKakko(K[first].str, stack)
	if stack < 0 {
		fmt.Printf("No\n")
		return
	}
	for i := 0; i < len(K); i++ {
		if first == i || last == i {
			continue
		}
		stack = okKakko(K[i].str, stack)
		if stack < 0 {
			fmt.Printf("No\n")
			return
		}
	}
	stack = okKakko(K[last].str, stack)
	if stack < 0 {
		fmt.Printf("No\n")
		return
	}

	if stack == 0 {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}

func minmaxKakko(s string) (int, int) {
	stack := 0
	max := math.MinInt32
	min := math.MaxInt32
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			stack++
			if stack > max {
				max = stack
			}
		}
		if s[i] == ')' {
			stack--
			if stack < min {
				min = stack
			}
		}
	}
	return min, max
}

func okKakko(s string, stack int) int {
	for i := 0; i < len(s); i++ {
		if s[i] == '(' {
			stack++
		}
		if s[i] == ')' {
			stack--
		}
		if stack < 0 {
			return -1
		}
	}
	return stack
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 67376
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, k);
	init(ntype, a);
	init(ntype, b);

	ntype f;
	for (f = 0; f + k <= b; f += k);

	outl(f >= a ? "OK" : "NG");

	return 0;
}

Measured memory_bytes: 3632
//Date: 23/10/19
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n;

    cin>>n;

    for(int i = 1; i <= 9; i++){
    	for(int j = 1; j <= 9; j++){
    		if(i * j == n){
    			cout<<"Yes"<<endl;
    			return 0;
    		}
    	}
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;


  while(1){
    i=0;
    while(1){
      
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
	break;
      }
      
      i++;
    }
   
    if ( i == 1 && ch[0] == '-' ) break;

    //  printf("%d",i);
    
    scanf("%d",&m);
    
    for(j=0;j<m;j++){
      scanf("%d", &h );
      
      for(k=0;k<i-h;k++) {
	a[k] = ch[h+k];
	//    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
	a[i-h+k] = ch[k];
	//   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
	ch[k] = a[k];
	// printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
  
  
  return 0;
  
}

Measured memory_bytes: 564
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
void hack(ll n)
{
    if(n==124)
    cout<<"hacked";   
}
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
ll mod=998244353;
ll mod1=1e9+6;
#define int ll
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod,b/2);
    else return a*power(a*a%mod,b/2)%mod;
}
ll power1(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod1,b/2);
    else return a*power(a*a%mod1,b/2)%mod1;
}
void show(vector <pair<int,int>> v)
{
    for(int i=0;i<v.size();++i) cout<<v[i].first<<" "<<v[i].second<<" ";
        cout<<endl;
}
#define endl '\n'


int32_t main()
{
    IOS
 
    int k,x;
    cin>>k>>x;
    set<int> s;
    for(int i=x;i<x+k;++i)
        s.insert(i);
    for(int i=x;i>x-k;--i)
        s.insert(i);
    for(auto i:s)
    {
        if(i>=-1000000 and i<=1000000)
            cout<<i<<" ";
    }
}


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

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef vector<int> Vi;

int n;
Vi desc, asc;

int main()
{
	cin >> n;
	desc.resize(n);
	REP(i, n) cin >> desc[i];
	sort(ALL(desc), greater<>());
	asc = desc;
	reverse(ALL(asc));

	ll ans = 0;
	REP(i_c, n - 2)
	{
		int c = desc[i_c];
		for (int i_b = i_c + 1; i_b < n - 1; ++i_b)
		{
			int b = desc[i_b];
			int hi = b;
			int lo = c + 1 - b;

			if (lo > hi)
				break;

			ll cnt = upper_bound(asc.begin(), asc.end() - 1- i_b, hi)\
				- lower_bound(asc.begin(), asc.end() - 1- i_b, lo);
			
			ans += cnt;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve() {

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll n;
    cin >> n;
    vll a(n, 0);
    map<ll, ll> s;
    forn(i, n) {
        cin >> a[i];
        ++s[a[i]];
    }
    //sort(all(s));
    forn(i, n) {
        for (auto it = s.rbegin(); it != s.rend(); it++) {
            if (a[i] != it->fi || (a[i] == it->fi && it->se > 1)) {
                cout << it->fi << '\n';
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n;
LL a[N],cnt[N],b[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    cnt[a[i]]++;
  }
  LL ans=0;
  for(int i=1;i<=n;i++){
    ans+=1ll*cnt[i]*(cnt[i]-1)/2;
    b[i]=1ll*cnt[i]*(cnt[i]-1)/2;
  }
  for(int i=1;i<=n;i++){
    LL res=ans;
    res-=b[a[i]];
    res+=1ll*(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
    cout<<res<<'\n';
  }
  return 0;
}

Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		HashMap<Long, Long> map = new HashMap<Long, Long>();
		String[] sa = br.readLine().split(" ");
		long[] a = new long[n];
		int count = 0;
		for (int i = 0; i < n; i++) 
		{
			a[i] = Long.parseLong(sa[i]);
			map.put(a[i], map.getOrDefault(a[i], (long)0)+ 1);
//			System.out.println(map);
		}
		for(Long l: map.keySet())
		{
			if(map.get(l)<l)
				count += map.get(l);
			else
				count += Math.abs(map.get(l)-l);
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 60956
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
ll mod(ll a,ll m){
    while(a<0)a+=m;
    a%=m;
    return a;
}
//code begins
ll foo(ll n){
    ll ans=0;
    while(n>0)
        ans++,n%=__builtin_popcount(n);
    return ans;
}
void solve(){
    ll n;cin>>n;
    string s;cin>>s;
    ll no1=0;
    for(const auto &it:s)
        if(it=='1')no1++;
    vector<ll> ans(n);
    if(!no1)
    {
        for(ll i=0;i<n;i++)
            cout<<1<<endl;
        return;
    }
    ll m1=no1+1,m2=no1-1;
    if(no1==1)m2=1;
    vector<ll> pow1(n,1);
    vector<ll> pow2(n,1);
    for(ll i=1;i<n;i++){
        pow1[i]=mod(2*pow1[i-1],m1);//mod m1
        pow2[i]=mod(2*pow2[i-1],m2);//mod m2
    }
    ll x1=0;// for m1
    ll x2=0;// for m2
    for(ll i=0;i<n;i++)
    {
        x1+=(s[n-i-1]-'0')*pow1[i];
        x2+=(s[n-i-1]-'0')*pow2[i];
    }
    for(ll i=0;i<n;i++)
    {
        if(s[n-i-1]=='0')
            ans[n-i-1]=1+foo(mod(x1+pow1[i],m1));
        else
        {
            if(no1==1)
                ans[n-i-1]=0;
            else
                ans[n-i-1]=1+foo(mod(x2-pow2[i],m2));
        }
    }
    for(ll i=0;i<n;i++)
        cout<<ans[i]<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


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

long long solve(string S) {
	long long cnt = 0, ret = 0;
	for (int i = 0; i < S.size(); i++) {
		cnt++;
		if (i == (int)S.size() - 1 || S[i] != S[i + 1]) {
			ret += cnt / 2;
			cnt = 0;
		}
	}
	return ret;
}

int main() {
	string T; cin >> T;
	long long K; cin >> K;

	bool flag = true;
	for (int i = 0; i < (int)T.size() - 1; i++) {
		if (T[i] != T[i + 1]) flag = false;
	}

	if (flag == true) {
		long long len = 1LL * (long long)(T.size()) * K;
		cout << len / 2LL << endl;
	}
	else {
		string V1 = T;
		string V2 = T + T;
		long long R1 = solve(V1);
		long long R2 = solve(V2);
		cout << R1 + (R2 - R1) * (K - 1LL) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int v[100000];

int main()
{
    int n, k, i, maxx, poz1, poz2;
    std::cin >> n >> k >> v[0] ;
    maxx = 0;
    for( i = 1; i < n; i++ )
    {
        std::cin >> v[i];
        if( v[i - 1] + v[i] > maxx )
        {
            maxx = v[i - 1] + v[i];
            poz1 = i - 1;
            poz2 = i;
        }
    }
    if (maxx < k)
    {
        std::cout <<"Impossible";
        return 0 ;
    }
    std::cout << "Possible\n" ;
    for( i = 1; i <= poz1; i++ )
    {
        std::cout << i << '\n' ;
    }
    for( i = n - 1; i > poz2; i-- )
    {
        std::cout << i << '\n' ;
    }
    std::cout << poz2 ;
    return 0;
}


Measured memory_bytes: 1152
/* **********************************************

  File Name: main.cpp

  Auther: zhengdongjian@tju.edu.cn

  Created Time: 2015??´08???29??\ ????????? 10??¶18???38?§?

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

const double EPS = 1e-8;

int k;
double p, e, t;
double dfs(double l, double r, double pre, int dep) {
	//printf("dfs %f, %f, %f, %d\n", l, r, pre, dep);
	if (dep == k) {
		return fabs(t - (l + r) * 0.5) < e ? 0.0 : pre;
	}
	if (fabs(pre) < EPS) {
		return 0.0;
	}
	if (l > t + e || r < t - e) return pre;

	double h = (l + r) * 0.5;
	if (h > t) {
		//cout << "p = " << p << endl;
		return dfs(h, r, pre * p, dep + 1) + dfs(l, h, pre * (1.0 - p), dep + 1);
	} else {
		return dfs(l, h, pre * p, dep + 1) + dfs(h, r, pre * (1.0 - p), dep + 1);
	}
}

int main() {
	double r, l;
	while (cin >> k >> l >> r) {
		cin >> p >> e >> t;
		double ans = 1.0 - dfs(l, r, 1.0, 0);
		cout << fixed << setprecision(6) << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
# Problem C - Traveling Salesman around Lake

K, N = map(int, input().split())
a_list = list(map(int, input().split()))

# initialization
min_cost = 10**8
a_len = len(a_list)

for i in range(len(a_list)):
    a = a_list[i]
    ushiro_i = 0
    mae_i = 0
    # 1つ後ろを取る
    if i-1<0:
        ushiro_i = a_len - 1
    else:
        ushiro_i = i - 1

    # 1つ前を取る
    if i+1>=a_len:
        mae_i = 0
    else:
        mae_i = i + 1

    # update
    kouho_1 = 0
    kouho_2 = 0
    if a_list[mae_i]-a_list[i]<0:
        kouho_1 = K - (a_list[mae_i] - a_list[i] + K)
    else:
        kouho_1 = K - (a_list[mae_i] - a_list[i])
    if a_list[i]-a_list[ushiro_i]<0:
        kouho_2 = K - (a_list[i] - a_list[ushiro_i] + K)
    else:
        kouho_2 = K - (a_list[i] - a_list[ushiro_i])
        
    min_cost = min(min_cost, kouho_1, kouho_2)

# output
print(min_cost)


Measured memory_bytes: 78796
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String res = "";
		if ( A>B ) {
			if (B==1) System.out.println("Bob");
			else System.out.println("Alice");
		}else if ( A<B ) {
			if (A==1) System.out.println("Alice");
			else System.out.println("Bob");
		}else System.out.println("Draw");
	}
}


Measured memory_bytes: 21076
function Main(input) {
    input = input.trim();
    input = input.split(" ")

    var a = parseInt(input[0])
    var b = parseInt(input[1])
    var c = parseInt(input[2])
    var d = parseInt(input[3])

    if (d <= a) {
        console.log(d)
    } else {
        if (d <= a + b) {
            console.log(a)
        } else {
            console.log(a - (d - (a + b)))
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29868
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int n;cin >> n;
	int h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];



	return 0;
}

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

using namespace std;

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

	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < K; ++i) { ans += p[i]; }
	cout << ans << endl;

	return 0;
}


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

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

        int n = cin.nextInt();
        cout.println((int)Math.pow(n, 3));
        
        cout.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  ll A, B, N;
  cin >> N >> A >> B;
  ll mul = N / (A + B);
  ll mod = N % (A + B);
  ll blue = mul * A;
  blue += min(mod, A);
  cout << blue << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
	double n,k;
	cin>>n>>k;
	double sum=0;
	int i,j,jilu=0;
	for(i=1;i<=n;i++)
	{
		jilu=0,j=i;
		while(1)
		{
		if(j>=k)
	 	break;
			j*=2;
			jilu++;
		}
		sum+=(double(1/n))*pow(0.5,jilu);
	}
	cout<<fixed<<setprecision(9)<<sum; 
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int bit_num(int bit) {
  int num = 0;
  while(bit > 0) {
    if(bit % 2 == 1) {
      num++;
    }
    bit /= 2;
  }
  return num;
} 

int main() {
  int N; cin >> N;
  vector<vector<int>> a(N, vector<int>(N,0));
  rep(i, N)rep(j, N) cin >> a[i][j];
  vector<ll> dp(1 << (N + 1), 0);
  dp[0] = 1;
  rep(i, 1 << N) {
    rep(j, N) {
      //      cout << i << " " << j << endl;
      if(((i >> j) & 1) == 0) continue;
      int pre = i - (1 << j);
      dp[i] = (dp[i] + dp[pre] * a[bit_num(i) - 1][j]) % MOD;
    }
  }
  cout << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 35916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <vector>
#include <queue>
#define PB push_back
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1010,M=1003;
bitset<M> G[N],A[N],B;
int n,m;
int vis[N][2];
int inq[N];
queue<int> que;
void push(int u,int t) {
	if(!vis[u][0]) vis[u][0]=t;
	else if(!vis[u][1]&&vis[u][0]!=t) vis[u][1]=t,B[u]=0;
	else return;
	A[t][u]=0;
	if(!inq[u]) que.push(u),inq[u]=1;
}
int mp[N][N],p1[N][N],p2[N][N];
void sol(int s) {
//	cout<<"Solve"<<s<<':';
	B[s]=0;
	for(int i=1;i<=n;++i) if(mp[s][i]) push(i,i);
	while(!que.empty()) {
		int u=que.front(); que.pop(),inq[u]=0;
		while(1) {
			int v=((A[vis[u][0]]|A[vis[u][1]])&G[u]&B)._Find_first();
			if(v==M) break;
			if(vis[u][0]&&A[vis[u][0]][v]) push(v,vis[u][0]);
			if(vis[u][1]&&A[vis[u][1]][v]) push(v,vis[u][1]);
		}
	}
//	cout<<endl;
	for(int i=1;i<=n;++i) if(s!=i) {
		p1[s][i]=vis[i][0]||vis[i][1]||mp[s][i];
		p2[s][i]=(vis[i][0]&&vis[i][0]!=i)||(vis[i][1]&&vis[i][1]!=i);
	}
//	for(int i=1;i<=n;++i) printf("(%d,%d) ",vis[i][0],vis[i][1]); puts("");
	for(int i=1;i<=n;++i) {
		if(vis[i][0]) A[vis[i][0]][i]=1,vis[i][0]=0;
		if(vis[i][1]) A[vis[i][1]][i]=1,vis[i][1]=0;
		B[i]=1;
	}
}
vector<PII> E;
int main() {
	rd(n),rd(m);
	for(int i=1,x,y;i<=m;++i) rd(x),rd(y),G[x][y]=mp[x][y]=1,E.PB(MP(x,y));
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) A[i][j]=1;
	for(int i=1;i<=n;++i) B[i]=1;
	for(int i=1;i<=n;++i) sol(i);
//	cout<<"Check:"<<p1[3][9]<<' '<<p2[9][3]<<endl;
	for(int i=0;i<E.size();++i) { 
		int x=E[i].fir,y=E[i].sec,flg;
		if(p1[y][x]) flg=(p2[x][y]==1);
		else flg=(p2[x][y]==0);
		if(flg) printf("same\n");
		else printf("diff\n");
	}
	return 0;
}
	

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

int main() {
  ll n,m;
  cin >> n >> m;
  if(n == 1 && m == 1) cout << 1 << endl;
  else if(min(n,m) == 1){
    if(max(n,m) < 0) cout << 0 << endl;
    else cout << max(n,m)-2 << endl;
  }
  else if((n-2)*(m-2) < 0) cout << 0 << endl;
  else cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[3],t[3];
ll ans;

int main()
{
    
    cin>>s[0]>>s[1]>>s[2];
	cin>>t[0]>>t[1]>>t[2];
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i]) ans++;
    }
 
    
        cout<<ans;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

max1=max(A)
if A.count(max(A))>1:
    for i in range(N):
        print(max1)
else:
    max2=sorted(A)[-2]
    for a in A:
        if a==max1:
            print(max2)
        else:
            print(max1)


Measured memory_bytes: 13384