akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
l = [list(map(str, input().split())) for i in range(h)]
l = [["#"] + l[i] + ["#"] for i in range(h)]
l = [["#" for i in range(w+2)]] + l + [["#" for i in range(w+2)]]
for i in range(h+2):
    print("".join(l[i]))

Measured memory_bytes: 9152
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] s=sc.next().split(""),ops={"+","+","+"};
  	int[] n=new int[4];
    int sum=0;
    for(int i=0;i<4;i++){
      n[i]=Integer.parseInt(s[i]);
      
    }
    if(n[0]+n[1]+n[2]+n[3]==7){
      System.out.println(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7");
    }else if(n[0]+n[1]+n[2]-n[3]==7){
      System.out.println(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"=7");
    }else if(n[0]+n[1]-n[2]+n[3]==7){
      System.out.println(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"=7");
    }else if(n[0]+n[1]-n[2]-n[3]==7){
      System.out.println(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7");
    }else if(n[0]-n[1]-n[2]-n[3]==7){
      System.out.println(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7");
    }else if(n[0]-n[1]-n[2]+n[3]==7){
      System.out.println(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"=7");
    }else if(n[0]-n[1]+n[2]-n[3]==7){
      System.out.println(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]+"=7");
    }else{
      System.out.println(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"=7");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define maxn 105
using namespace std;
typedef long long ll;
ll w[maxn]={0};
ll v[maxn]={0};
ll cnt[5]={0};
ll f[maxn][maxn]={0};
struct nodes
{
    ll val=0;
    ll wei=0;
}node[105];
bool cmp(nodes a,nodes b)
{
    return a.val>b.val;
}
int n;
void init()
{   ll c[5]={0},i,j;
        for(i=1;i<=n;i++)
        {
            f[node[i].wei-w[1]][c[node[i].wei-w[1]]+1]=f[node[i].wei-w[1]][c[node[i].wei-w[1]]]+node[i].val;
            c[node[i].wei-w[1]]++;
        }
}
int main()
{
   ll m,i,j,k,l;
   cin>>n>>m;
   for(i=1;i<=n;i++)
   {
       scanf("%lld%lld",&w[i],&v[i]);
       cnt[w[i]-w[1]]++;
       node[i].val=v[i];
       node[i].wei=w[i];
   }
   sort(node+1,node+1+n,cmp);
   ll ans=0;
   init();
//   for(i=0;i<4;i++)
//   {
//       printf("%d ",cnt[i]);
//   }
   for(i=0;i<=cnt[0];i++)
   {
        for(j=0;j<=cnt[1];j++)
        {
            for(k=0;k<=cnt[2];k++)
            {
                for(l=0;l<=cnt[3];l++)
                {
                    if((i*w[1])+j*(w[1]+1)+k*(w[1]+2)+l*(w[1]+3)<=m)
                    {
                        ans=max(f[0][i]+f[1][j]+f[2][k]+f[3][l],ans);
                    }
                }
            }
        }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())
#define mod 1000000007
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
void solve()
{
    ll n,m,c;
    cin >> n >> m >> c;
    ll b[m];
    for(int i=0;i<m;i++) cin >> b[i];
    ll a[m];
    ll co = 0;
    for(int i=1;i<=n;i++)
    {
        ll res = 0;
        for(int i=0;i<m;i++) {cin >> a[i];res+=b[i]*a[i];}
        if(res+c>0) co++;
    }
    cout << co << endl;
}
int main()
{
  fast();
  solve();

return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define MAX 1000000
#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define ll long long
using namespace std;

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

    string s;
    cin>>s;
    // cout<<s.substr(2,2)<<endl;
    // cout<<s.substr(4,2)<<endl;
    if(s[2]==s[3] and s[4]==s[5]){
        cout<<"Yes\n";
    }
    else cout<<"No\n";

    return 0;
}

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

int main() {
  
  int N; cin >> N;
  if(N/100 == 7 || N%10 == 7 || (N%100)/10 == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

int main (){
  int i;
  int n;
  cin>>n;
  n%=10;
  if(n==2||n==4||n==5||n==7||n==9){
    cout<<"hon"<<endl;
  }
  else if(n==3){
    cout<<"bon"<<endl;
  }
  else {
    cout<<"pon"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3564
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort(reverse=True)
    print(ab[0][0] + ab[0][1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 56412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    string s;cin>>s;
    vector<string >v;
    int a[4]={0,4,6,8};
    rep(i,0,(1<<4)-1){
        string t="AKIHABARA";
        vector<int>eras;
        rep(j,0,3){
            if((i>>j)&1){
                eras.pb(a[j]);
            }
        }
        reverse(eras.begin(),eras.end());
        for(auto x:eras)t.erase(t.begin()+x);
        v.pb(t);
    }
    for(auto x:v)if(x==s){cout<<"YES"<<endl;return 0;}
    cout<<"NO"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, w, h, X, Y;
	cin >> W >> H >> w >> h >> X >> Y;
	int l = max(-(int)(W / 2), X - (w / 2));
	int r = min((int)(W / 2), X + (w / 2));
	int u = max(-(int)(H / 2), Y - (h / 2));
	int d = min((int)(H / 2), Y + (h / 2));
	//cerr << r << " " << l << endl;
	//cerr << u << " " << d << endl;
	cout << fixed << setprecision(15) << ((double)(d + u) / (r + l)) << endl;
}


Measured memory_bytes: 3264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int d = Integer.parseInt(str[3]);

		while (true) {
			c -= b;
			if (c <= 0) {
				System.out.println("Yes");
				return;
			}
			a -= d;
			if (a <= 0) {
				System.out.println("No");
				return;
			}
		}
	}
}


Measured memory_bytes: 32708
"use strict"
let input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split('\n');
let N = input.shift();
let A = input[0].split(' ');
let B = input[1].split(' ');
let C = input[2].split(' ');
//let Ccount = 0;
let ans = 0;
for(let i = 0; i < N*1; i++){
  ans += B[A[i]-1]*1;
  // Cの方の計算
  if(A[i+1]-A[i] == 1){
    ans += C[A[i] -1]*1;
  }
}

console.log(ans)

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

int main(){

	double q;
	while(~scanf("%lf",&q)){
		if(q==-1) break;
		double x=q/2;
		for(;;){
			x = x - (pow(x,3.0)-q)/(3*x*x);
			if(abs(pow(x,3.0)-q) < 0.00001*q) break;
		}

		printf("%.6f\n",x);
	}
}

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

class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	public void solve() {
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] S = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Arrays.stream(S).sorted()
		.forEach(s -> out.print(s));
		out.println();
	}




	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
}

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

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 25812
import java.util.Scanner
import java.math.BigDecimal
object Main{
    def main(args:Array[String]):Unit={
        val scan = new Scanner(System.in)
        var x_list = List[Double]()
        var y_list = List[Double]()
        var count = 0
        while(scan.hasNextDouble()){
            val list = for(i <- 1 to 6) yield scan.nextDouble()
            val d = det(list(0),list(1),list(3),list(4))
            val x = det(list(2),list(1),list(5),list(4))/d
            val y = det(list(0),list(2),list(3),list(5))/d
            x_list :+= x
            y_list :+= y
            count+=1
        }
        for(i <- 0 to count-1){
            val x = new BigDecimal(x_list(i))
            val y = new BigDecimal(y_list(i))

            val res_x = x.setScale(3,BigDecimal.ROUND_HALF_UP)
            val res_y = y.setScale(3,BigDecimal.ROUND_HALF_UP)
            println(s"${res_x} ${res_y}")
        }
    }

    def det(a:Double,b:Double,c:Double,d:Double):Double 
        = a*d-b*c
}

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

int check(int n,int* a){
    for(int i=0;i<n;i++){
        if(a[i]%10) return i;
    }
    return -1;
}
void solve(int n,int* a){
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    if(ans%10){
        cout<<ans<<endl; return;
    }
    sort(a,a+n);
    int k=check(n,a);
    if(k!=-1){
        cout<<ans-a[k]<<endl;
        return;
    }
    cout<<0<<endl;
}
int main(){
    int a[128],n;
    while(cin>>n){
        for(int i=0;i<n;i++) cin>>a[i];
        solve(n,a);
    }
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    if((int)S.size()%2){
        cout << "No" << endl;
        return 0;
    }
    
    for(int i=0; i<(int)S.size(); i++){
        if(i%2==0 && S[i]=='h'){
            continue;
        }else if(i%2 && S[i]=='i'){
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
from math import floor


def f(a, b, x):
    return floor(a * x / b) - a * floor(x / b)


def solve(a, b, n):
    return f(a, b, min(b-1, n))


if __name__ == "__main__":
    a, b, n = map(int, input().split())
    print(solve(a, b, n))


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
  
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  UnionFind tree(n+1);
  vector<int> fr(n+1,1);
  vector<vector<int>> bl(n+1,vector<int>(0));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    fr[a]++;
    fr[b]++;
    tree.unite(a,b);
  }
  rep(i,k){
    int a,b;
    cin >> a >> b;
    bl[a].push_back(b);
    bl[b].push_back(a);
  }
  map<int,int> size;
  rep1(i,n) size[tree.root(i)]++;
  vector<int> ans(n+1,0);
  rep1(i,n) ans[i] = size[tree.root(i)] - fr[i];
  rep1(i,n){
    for(int j : bl[i]){
      if(tree.same(i,j)) ans[i]--;
    }
  }
  rep1(i,n) cout << ans[i] << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int g[m][2];
    map<vector<int>, int> mp;
    rep(i,m) {
        vector<int> t(2);
        rep(j,2) cin >> t[j];
        mp[t] = -1;
    }
    vector<int> a(n-1);
    rep(i,n-1) a[i] = i+2;
    int ans = 0;
    do {
        bool ok = true;
        vector<int> b(2);
        b[0] = 1; b[1] = a[0];
        if (mp.find(b) == mp.end()) ok = false;
        for (int i = 0; i < n-2; i++) {
            vector<int> t(2);
            for (int j = i; j < i+2; j++) {
                t[j-i] = a[j];
            }
            sort(t.begin(), t.end());
            if (mp.find(t) == mp.end()) ok = false;
        }
        if (ok) ans++;
    } while (next_permutation(a.begin(), a.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int col[705], w, b; 
bool dp[705][705], app[705][705]; 
std::pair<int, int> arr[705]; 
std::vector<int> adj[705]; 
void dfs(int u, int c)
{
	if (~col[u])
	{
		if (col[u] != c)
		{
			puts("-1"); 
			exit(0); 
		}
		return; 
	}
	col[u] = c; 
	(c ? w : b)++; 
	for (int v : adj[u])
		dfs(v, c ^ 1); 
}
int main()
{
	// freopen("ARC099-E.in", "r", stdin); 
	memset(col, -1, sizeof(col)); 
	int n, m, len = 0; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		u--; 
		v--;
		app[u][v] = app[v][u] = true; 
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (!app[i][j] && i != j)
				adj[i].pb(j); 
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (~col[i])
			continue; 
		w = 0;
		b = 0; 
		dfs(i, 0); 
		arr[len++] = {w, b}; 
	}
	dp[0][0] = true; 
	for (int i = 0; i < len; i++)
	{
		for (int x = 0; x <= n; x++)
		{
			if (dp[i][x])
			{
				dp[i + 1][x + arr[i].first] = true; 
				dp[i + 1][x + arr[i].second] = true; 
			}
		}
	}
	int ans = 1e9; 
	for (int i = 0; i <= n; i++)
	{
		if (dp[len][i])
			ans = std::min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2); 
	}
	printf("%d\n", ans >= 1e9 ? -1 : ans);
	return 0; 
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int n, a[100001], t, A, B, C;
bool b[100001];
vector<int>v;
ll c[100001], d[100001];

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1)a = a * x%mod;
		x = x * x%mod;
		y >>= 1;
	}
	return a;
}

ll modinv(int x) {
	return pw(x, mod - 2);
}

ll Comb(int x, int y) {
	if (x < 0 || y < 0 || x - y < 0)return 0;
	return c[x] * d[y] % mod * d[x - y] % mod;
}

int main() {
	cin >> n;
	for (int i = 0; i != n + 1; ++i) {
		cin >> a[i];
		if (b[a[i]]) {
			t = a[i];
		}
		b[a[i]] = true;
	}
	for (int i = 0; i != n + 1; ++i)
		if (a[i] == t)v.push_back(i);
	A = v[0];
	B = v[1] - v[0] - 1;
	C = n - v[1];
	c[0] = 1;
	for (int i = 1; i != n + 1; ++i)
		c[i] = (c[i - 1] * i) % mod;
	for (int i = 0; i != n + 1; ++i)
		d[i] = modinv(c[i]);
	for (int i = 1; i != n + 2; ++i) 
		cout << (Comb(n - 1, i) + Comb(n - 1, i - 1) * 2 - Comb(A + C, i - 1) + Comb(n - 1, i - 2) + mod) % mod << endl;
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		string s, t;
		cin >> s >> t;
		if(s.size() < t.size())
		{
			string temp = s;
			s = t;
			t = temp;
		}
		reverse(s.begin(), s.end());
		reverse(t.begin(), t.end());
		string ans = "";
		string buf = "0";
		for(int i = 0; i < t.size(); ++i)
		{
			int a = s[i] - '0' + t[i] - '0' + buf[0] - '0';
			if(a >= 10)
			{
				buf = "1";
			}
			else
			{
				buf = "0";
			}
			ans += (char)(a % 10 + '0');
		}
		for(int i = t.size(); i < s.size(); ++i)
		{
			int a = s[i] - '0' + buf[0] - '0';
			if(a >= 10)
			{
				buf = "1";
			}
			else
			{
				buf = "0";
			}
			ans += (char)(a % 10 + '0');
		}
		if(buf != "0")
		{
			ans += buf[0];
		}
		if(ans.size() >	80)
		{
			cout << "overflow" << endl;
		}
		else
		{
			reverse(ans.begin(), ans.end());
			cout << ans << endl;
		}
	}
}

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

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

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


int main(void){
	int n;	
	while(cin>>n,n){
		int cnt=0;
		while(n!=1){
			cnt ++;
			if(n%2==1){n=n*3+1;}
			else n/=2;
			
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1160
# 差が小さければ嬉しい
# -> という考えで１WA
# 頭から愚直にやればいいかもしれない
n = int(input())
arr = sorted(list(map(int, input().split())))

while len(arr) > 1:
  x = (arr[0] + arr[1])/2.0
  arr = [x] + arr[2:]
  arr = list(sorted(arr))

print(arr[0])

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

using namespace std;

int main(){
    const double dTolerance = 1.0e-10;
    double x1, x2, y1, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    int q;
    scanf("%d", &q);
    
    for (int i = 0; i < q; i++){
        double x, y;
        scanf("%lf %lf", &x, &y);
        if (fabs(x1 - x2) < dTolerance) {
            printf("%.10lf %.10lf\n", x1, y);
        } else if (fabs(y1 - y2) < dTolerance){
            printf("%.10lf %.10lf\n", x, y1);
        } else {
            double dt = ((x2 - x1) * (x2 - x) + (y2 - y1) * (y2 - y)) / ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
            double ds = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1)) / ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
            printf("%.10lf %.10lf\n", dt * x1 + ds * x2, dt * y1 + ds * y2);
        }
    }
    return 0;
}


Measured memory_bytes: 2748
#include<stdio.h>
int main()
{
    int k,a;
    scanf("%d",&k);
    if(k%2==0)
    {
        a=k/2;
        printf("%d",a*a);
    }
    else {
        a=(k+1)/2;
        printf("%d",(a*a)-a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

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

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }

void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

// ==========Start Here==============

// 138 - 142
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 	
 	int n ; 
 	cin >> n ; 
 	vt<int> a(n) ; 
 	read(a) ; 
 	int ans = 0 , cnt = 0 ;
 	rep(i,1,n) {
 		int d = a[i] - a[i-1] ; 
 		if(d <= 0) {
 			++cnt ; 
 		} else {
 			umax(ans,cnt) ; 
 			cnt = 0 ; 
 		}
 	}
 	umax(ans,cnt) ; 
 	cout << ans ; 
	return 0 ; 
 	
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int plug = 1;
  int answer = 0;
  while(plug < B) {
    plug += A - 1;
    answer++;
  }
  
  cout << answer << endl;
  return 0;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5, mod = 1e9 + 7, dsz = 4;
int n, m, d[nsz + 5];

struct matrix {
	int n, m, d[dsz + 5][dsz + 5];
	
	matrix(int n = 0, int m = 0, bool e = 0) {
		this->n = n, this->m = m;
		loop (i, n) {
			loop (j, m) {
				d[i][j] = (i == j) & e;
			}
		}
	}
	
	matrix(vector< vector<int> > a) {
		n = a.size(), m = a[0].size();
		loop (i, n) {
			loop (j, m) {
				d[i][j] = a[i][j];
			}
		}
	}
	
	int* operator [] (int id) {
		return d[id];
	}
};
matrix a = matrix({
	{1, 0, 1},
	{2, 1, 2},
	{1, 1, 2},
}),
b = matrix({
	{1, 0, 0},
	{2, 1, 0},
	{1, 1, 1},
}),
res = matrix(3, 1);

matrix inline operator * (matrix a, matrix b) {
	matrix res(a.n, b.m);
	loop (i, a.n) {
		loop (j, b.m) {
			loop (k, a.m) {
				res[i][j] = (res[i][j] + (num) a[i][k] * b[k][j] % mod) % mod;
			}
		}
	}
	return res;
}

matrix inline qpow(matrix a, int p) {
	matrix res(a.n, a.m, 1);
	for (; p; p >>= 1) {
		if (p & 1) {
			res = res * a;
		}
		a = a * a;
	}
	return res;
}

int main() {
	scanf("%d%d", &n, &m);
	cont (i, m) {
		scanf("%d", &d[i]);
		++d[i];
	}
	res[0][0] = 1;
	cont (i, m) {
		res = qpow(a, d[i] - d[i - 1] - 1) * res;
		res = b * res;
	}
	res = qpow(a, n - d[m]) * res;
	printf("%d\n", res[2][0]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

int main() {
    int n, q;
    cin >> n >> q;

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    CumulativeSum cs(n), cs_even(n), cs_odd(n);
    rep(i, n) cs.set(i, v[i]);
    rep(i, n) if (i % 2 == 0) cs_even.set(i, v[i]);
    rep(i, n) if (i % 2 == 1) cs_odd.set(i, v[i]);

    cs.build();
    cs_even.build();
    cs_odd.build();

    map<ll, ll> m;

    auto get_l_score = [&](int r) -> ll {
        if (r == -1) return 0;
        if (r % 2 == 0) return cs_even.getSum(r);
        return cs_odd.getSum(r);
    };

    for (int i = 1; i * 2 < n; i++) {
        int b_r = n - 1;
        int b_l = b_r - i + 1;
        int a_r = b_l - 1;
        int a_l = a_r - i + 1;

        ll d = v[a_l - 1];
        ll u = v[a_r];

        ll x = (u + d) / 2 + 1;
//        printf("%d %d %d %d %lld\n", a_l, a_r, b_l, b_r, x);
//
        ll a_r_score = cs.getSectionSum(b_l, b_r);
        ll b_r_score = cs.getSectionSum(a_l, a_r);

        ll a_l_score = get_l_score(a_l - 1);

        ll score = a_r_score + a_l_score;

        m[x] = score;
    }

    m[0] = cs.getSectionSum(n / 2, n);
    m[INF] = get_l_score(n - 1);

    rep(_, q) {
        ll x;
        cin >> x;
        auto it = m.upper_bound(x);
        it--;
        cout << (*it).second << endl;

    }


}


Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    iota(ALL(a), 1);
    do {
        printv(a);
    } while(next_permutation(ALL(a)));
}



Measured memory_bytes: 3208
// Problem : B - Strings with the Same Length
// Contest : AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int n;
  cin >> n;
  
  string s;
  string t;
  cin >> s >> t;
  
  for (int i = 0; i < n; ++i) {
    cout << s[i] << t[i];
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            Console.WriteLine(a-b+1);
            Console.Read();
        }
    }
}



Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main(){
    int N, D, a;
    cin >> N >> D;

    if (N % (D*2+1) == 0) {
        a = N / (D*2+1);
    } 
    else {
        a = N / (D*2+1) + 1;
    }

    cout << a << endl;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp.chars

ans = Array.new(N)
[
  ['S', 'S'],
  ['S', 'W'],
  ['W', 'S'],
  ['W', 'W']
].each do |(a0, a1)|
  ans[0] = a0
  ans[1] = a1
  (1...(N - 1)).each do |i|
    a = ans[i]
    if a == 'S'
      ans[i + 1] = if S[i] == 'o'
        ans[i - 1]
      else
        ans[i - 1] == 'S' ? 'W' : 'S'
      end
    else # W
      ans[i + 1] = if S[i] == 'o'
        ans[i - 1] == 'S' ? 'W' : 'S'
      else
        ans[i - 1]
      end
    end
  end
  is_ok = true
  is_ok = false if ans[-1] == 'S' && S[-1] == 'o' && ans[-2] != ans[0]
  is_ok = false if ans[-1] == 'S' && S[-1] == 'x' && ans[-2] == ans[0]
  is_ok = false if ans[-1] == 'W' && S[-1] == 'o' && ans[-2] == ans[0]
  is_ok = false if ans[-1] == 'W' && S[-1] == 'x' && ans[-2] != ans[0]
  is_ok = false if ans[0] == 'S' && S[0] == 'o' && ans[-1] != ans[1]
  is_ok = false if ans[0] == 'S' && S[0] == 'x' && ans[-1] == ans[1]
  is_ok = false if ans[0] == 'W' && S[0] == 'o' && ans[-1] == ans[1]
  is_ok = false if ans[0] == 'W' && S[0] == 'x' && ans[-1] != ans[1]
  if is_ok
    puts ans.join('')
    exit 0
  end
end

puts '-1'


Measured memory_bytes: 25852
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import sys


def solve(values, nb, max_jump_size):
    max_jump_size = min(nb, max_jump_size)
    cost_to = [0]
    for i in range(1, nb):
        j = max(0, i - max_jump_size)
        value_i = values[i]
        new_cost = min(
            prev_cost + abs(value_i - prev_value)
            for prev_cost, prev_value in zip(cost_to[j:i], values[j:i])
        )
        cost_to.append(new_cost)
    return new_cost


def do_job():
    "Do the work"
    # first line is number of test cases
    N, K = map(int, input().split())
    values = list(map(int, input().split()))
    result = solve(values, N, K)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


Measured memory_bytes: 18120
"use strict"
let input = require('fs').readFileSync('/dev/stdin','utf8');
let arr = input.split('\n')
let n = arr[0];
if (n !== 0) {
	let list = arr[1].split(' ');
	let min = parseInt(list[0]);
	let max = parseInt(list[0]);
	let sum = 0;
	for (let i in list) {
		let v = parseInt(list[i]);
		min = Math.min(min, v);
		max = Math.max(max, v);
		sum += v;
	}
	console.log(min + ' ' + max + ' ' + sum);	
}



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    map<int, lint> mp;
    REP(i, 2, n + 1){
        int tmp = i;
        for(int j = 2 ; j * j <= tmp ; ++j){
            lint cnt = 0;
            while(tmp % j == 0){
                tmp /= j;
                ++cnt;
            }
            mp[j] += cnt;
        }
        if(tmp > 1){
            ++mp[tmp];
        }
    }
    lint ans = 0;
    for(auto x : mp){
        if(x.second >= 74){
            ++ans;
        }
        for(auto y : mp){
            if(x.first == y.first){
                continue;
            }
            if(x.second >= 2 && y.second >= 24){
                ++ans;
            }
            if(x.second >= 4 && y.second >= 14){
                ++ans;
            }
            for(auto z : mp){
                if(x.first == z.first || y.first >= z.first){
                    continue;
                }
                if(x.second >= 2 && y.second >= 4 && z.second >= 4){
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-} 
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.Text as T
import qualified Data.Map.Strict as Map
import Data.Maybe


createACMap :: T.Text -> Int -> Map.Map Int Int
createACMap t len =  Map.fromList $ snd indexAndCount  where
    indexAndCount = mapAccumL (\(acc, str) i -> if isIndexPrefixOfAC i str 
                                         then ((acc+1, T.drop 1 str), ((i+1),acc+1)) 
                                         else ((acc, T.drop 1 str) ,((1+i), acc))) 
                    (0, t) [1..len] 
    isIndexPrefixOfAC i str = T.isPrefixOf "AC" $ T.take 2 str


solve :: Map.Map Int Int -> Int -> Int -> Int
solve acMap from to = findVal to - findVal from
    where
        findVal i = fromMaybe 0 $ Map.lookup i acMap

main = do
    (len, lines) <- readTuple :: IO (Int, Int)
    s <- T.pack <$> getLine 
    let acMap = createACMap s len
    lrlist <- replicateM lines readTuple
    forM_ lrlist $ \(l, r) ->
        print $ solve acMap l r


readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)

Measured memory_bytes: 73212
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a%b) : a;
}

map<ll, ll> prime_factorization(ll n){
    map<ll,ll> ret;
    for(ll i=2;i*i<=n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    //start = chrono::system_clock::now();
        ll A, B;
        cin >> A >> B;
        ll div = gcd(A,B);
        auto divs = prime_factorization(div);
        cout << divs.size()+1 << endl;
    //end = chrono::system_clock::now();
    //cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int a[2000001];
int n;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];	
	}
	int l=1,r=1,x=0,sum=0;
	long long ans;
	for(int l=1;l<=n;l++){
		if(r==l){
			x=0;
			sum=0;
		}
		else if(r<l){
			r=l;
			x=0;
			sum=0;
		}
		else r++;
//		cout<<"x="<<x << " " << "sum="<<sum<<endl;
		while(r<=n){
			if((x^a[r])==(sum+a[r])){
//				cout<<l<<" "<<r<<endl;
				x^=a[r];
				sum+=a[r];
				r++;
			}
			else{
//				cout<<"wrong:"<<l<<" "<<r<<endl;
				r--;
				break;
			}
		}
		if(r>n)r--;
		ans+=r-l+1;
		sum-=a[l];
		x^=a[l];
//		cout<<l<<" "<<r<<endl;
//		cout<<ans<<endl;
	}		
	cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
    
    #define ll long long
    #define ld long double
    using namespace std;
    
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        string s;
        cin >> s;
        ll p[200001];
        p[0] = 0;
        for (ll i = 1; i <= 200000; i++){
            p[i] = p[i-1] + i;
        }
        ll answ = 1;
        ll n = s.size();
        for (ll i = 1; i <= n; i++){
            answ += i;
        }
        map<char,ll> mal;
        for (ll i = 0 ; i < s.size(); i++){
            mal[s[i]]++;
        }
        for (auto i = mal.begin(); i != mal.end(); i++){
            answ -= p[i->second];
        }
        cout << answ << endl;
        return 0;
    }

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

	

int main() {
	
	int N;
	cin >>N;
	
	vector<pair<double,string>> A(N);
	for(int i=0; i<N; i++){
		
		cin >>A.at(i).first >>A.at(i).second;
		
	}
	
	vector<double> B(N);
	
	for(int i=0; i<N; i++){
		
		if(A.at(i).second=="JPY"){
			
			B.at(i)=A.at(i).first;
			
		}
		else{
			
			B.at(i)=A.at(i).first*380000;
			
		}
		
	}
	
	double ans=0;
	
	for(double x: B){
		
		ans+=x;
		
	}
	
	cout <<ans <<endl;
	
}


Measured memory_bytes: 256
/**
*    created: 21.06.2020 23:43:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    long double t, a;
    cin >> t >> a;
    long double tm = 100000000000000;
    int ans;
    rep(i,n) {
        int h;
        cin >> h;
        if (abs((t - h * 0.006)- a) < tm) {
            ans = i + 1;
            tm = abs((t - h * 0.006)- a);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
def bit_add(arr, n, i, x):
    while i <= n:
        arr[i] += x
        i += i & -i

def bit_sum(arr, i):
    result = 0
    while i > 0:
        result += arr[i]
        i ^= i & -i
    return result

n, q = map(int, input().split())
color = [int(i) for i in input().split()]
query = []
rli = [0] * q
for i in range(q):
    l, r = map(int, input().split())
    query.append((l, r))
    rli[i] = (r << 40) + (l << 20) + i
rli.sort()
mask = (1 << 20) - 1
bn = n + 2
bit = [0] * (bn + 1)
ans = [0] * q
appeared = [-1] * (n + 1)
p = 0

for j in range(q):
    k = rli[j]
    r = k >> 40
    l = (k >> 20) & mask
    i = k & mask
    while p < r:
        c = color[p]
        before_appeared = appeared[c]
        if before_appeared != -1:
            bit_add(bit, bn, before_appeared + 2, -1)
        bit_add(bit, bn, p + 2, 1)
        appeared[c] = p
        p += 1
    ans[i] = bit_sum(bit, r + 1) - bit_sum(bit, l)
print('\n'.join(map(str, ans)))    

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

int main(){
  string S; cin >> S;
  int d[10];
  int slen=S.size();
  for(int i=0; i<slen; i++){
    d[i]=(int)(S[i]-'0');
  }
  
  long long result=0;
  long long now=0;
  for(int i=0; i<(1<<(slen-1)); i++){
    now=d[0];
    for(int j=0; j<slen-1; j++){
      if(i&(1<<j)){
        result+=now;
        now=d[j+1];
      }else{
        now=now*10+d[j+1];
      }
      if(j==slen-2){
        result+=now;
      }
    }
  }
  if(S.size()==1) result=d[0]; //ここきたない
  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;

#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

  cin >> n;


  mint ans = 0;
  FOR(i, 1, n + 1) {
    ll t = n - (3 * i);
    if(t < 0) break;
    ans += c(t + i - 1, i - 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6192
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    double R1, R2; cin >> R1 >> R2;
    double R3 = R1 * R2 / (R1 + R2);
    cout << setprecision(15) << R3 << endl;
    
    return 0;
}

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

using namespace std;

int main(){

	int n;
	double tmp;
	double mi = 999999999999.0;
	double ha;
	long long int ans;
	vector<double> v;

	cin>> n;
	v.resize(n+1);
	v[0] = 0;
	for (int i = 1;i <= n;i++) {
		cin >> tmp;
		v[i] += tmp+v[i-1];
	}

	ha = v[n] / 2.0;
	//cout << ha << endl;

	for (int i = 1;i < v.size();i++) {
		mi = min(mi, abs(ha - v[i]));
		//cout << mi << endl;
	}

	ans = round(mi * 2);

	cout<< ans << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
//#define MAXN 1001000
using namespace std;
typedef vector<int> vi;
typedef set<int> se;
typedef pair<int,int> pii;
inline int mod(int n, int m){
int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int check(int x){
	int dig=0;
	while(x>0){
		dig++;
		x=x/10;
	}
	if(dig&1)return true;
	return false;
}

int32_t main(){
	fastio;
 	int n;
 	cin>>n;
 	vector<int> v(n);
 	for(int i=0;i<n;i++)cin>>v[i];
 	int last = 0;
 	 for(int i=0;i<n;i++){
		  if(v[i]>last)v[i]--;
		  last = v[i];
	  }
	   last = v[0];
	for(int i=1;i<n;i++){
		if(v[i]<last){
			cout<<"No"<<endl;
			return 0;
		}
		last = v[i];
	}  
	cout<<"Yes"<<endl;
	return 0;
}

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

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

    int n;cin>>n;

    vector<int> s(n);
    int sum=0;

    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        sum+=s[i];
    }

    sort(s.begin(),s.end());

    int ans=sum;

    int i=0;

    if(ans%10==0)for(;i<n;i++)
    {
        if(s[i]%10)
        {
            ans-=s[i];
            break;
        }
    }

    if(i==n)ans=0;

    cout<<ans<<"\n";

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int n;
  while(cin>>n){
    if(n==0)return 0;
    vector<int>s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    sort(rng(s));
    int ans=0;
    for(int i=1;i<n-1;i++)ans+=s[i];
    cout<<ans/(n-2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3004