akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; long long Y;
    cin >> N >> Y;
    bool flag=false;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(i*10000+j*5000+(N-i-j)*1000 == Y){
                cout << i <<' '<< j <<' '<< N-i-j << endl;
                flag=true; break;
            }
            if(flag) break;
        }
        if(flag) break;
    }
    if(!flag)cout << "-1 -1 -1" << endl;
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> A(N);
    rep(i, N)cin >> A[i];
    sort(ALL(A));
    int ans = 0;
    rep(i, K)ans += A[i];
    cout << ans;
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001deployed
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long x[1111], y[1111], r[1111], n;
long double dis[1111][1111], ans[1111], vst[1111];
set<pair<long double, int> > q;

int main() {
  ios::sync_with_stdio(false);
  long long xx, yy;
  cin >> x[0] >> y[0] >> xx >> yy >> n;
  x[n + 1] = xx;
  y[n + 1] = yy;
  FOR (i, 1, n) cin >> x[i] >> y[i] >> r[i];
  FOR (i, 0, n + 1) FOR (j, i + 1, n + 1) {
    if (sqr(x[i] - x[j]) + sqr(y[i] - y[j]) <= sqr(r[i] + r[j])) dis[i][j] = dis[j][i] = 0;
    else dis[i][j] = dis[j][i] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])) - r[i] - r[j];
  }
  // BUG(dis[0][2]);
  // BUG(dis[2][1]);
  // BUG(dis[1][3]);
  // BUG(dis[3][4]);
  FOR (i, 1, n + 1) ans[i] = -1;
  q.insert({0, 0});
  while (!q.empty()) {
    auto p = q.begin();
    long double cur = p->_1;
    int z = p->_2;
    q.erase(p);
    if (vst[z]) continue;
    vst[z] = 1;
    // BUG(p->_1);
    // BUG(p->_2);
    if (z == n + 1) {
      cout << setprecision(11) << cur;
      return 0;
    }
    FOR (i, 1, n + 1) if (ans[i] == -1 || ans[i] > cur + dis[i][z]) {
      // BUG(i);
      ans[i] = cur + dis[i][z];
      // BUG(ans[i]);
      // BUG(dis[i][z]);
      q.insert({ans[i], i});
    }
  }
}


Measured memory_bytes: 37376
#include <iostream>

using namespace std;

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

    int ans = 0;
    int lh;
    cin >> lh;
    int cl = 0;
    for (int i = 1; i < n; i++) {
        int h;
        cin >> h;
        if (h <= lh) {
            cl++;
            ans = max(ans, cl);
        } else {
            cl = 0;
        }
        lh = h;
    }

    cout << ans << endl;

    return 0;
}


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

typedef struct position {
    int x = 0;
    int y = 0;
    void print(){
        cout << "x: " << x << ", y: " << y << endl;
    }
} Position;

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> m(h);
    vector<vector<int>> d(h, vector<int>(w, -1));
    queue<Position> q;
    for (auto i = 0; i < h; i++) {
        cin >> m[i];
        for (auto j = 0; j < w; j++) {
            if(m[i][j] == '#') {
                q.push({i, j});
                d[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while(not q.empty()){
        Position p = q.front();
        q.pop();

        for (auto i = 0; i < 4; i++) {
            Position tmp = p;
            tmp.x += dx[i]; tmp.y += dy[i];
            if(tmp.x < 0 or tmp.x > h - 1 or tmp.y < 0 or tmp.y > w - 1) continue;
            if(d[tmp.x][tmp.y] >= 0) continue;
            d[tmp.x][tmp.y] = d[p.x][p.y] + 1;
            q.push(tmp);
            ans = max(ans, d[tmp.x][tmp.y]);
        }
    }

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

Measured memory_bytes: 13456
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<int> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis));
    ll ans = 0;
    int left = lis[0], right = lis[0];
    int lidx = 1, ridx = n-1;
    ll sum = 0;
    REP(i, 0, n-1){
        if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(left-lis[lidx])){
            sum += abs(left-lis[lidx]);
            left = lis[lidx];
            lidx++;
        }else if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(left-lis[ridx])){
            sum += abs(left-lis[ridx]);
            left = lis[ridx];
            ridx--;
        }else if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(right-lis[lidx])){
            sum += abs(right-lis[lidx]);
            right = lis[lidx];
            lidx++;
        }else{
            sum += abs(right-lis[ridx]);
            right = lis[ridx];
            ridx--;
        }
        //cout << right << left << endl;
    }
    ans = sum;
    left = lis[n-1]; right = lis[n-1];
    lidx = 0; ridx = n-2;
    sum = 0;
    REP(i, 0, n-1){
        if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(left-lis[lidx])){
            sum += abs(left-lis[lidx]);
            left = lis[lidx];
            lidx++;
        }else if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(left-lis[ridx])){
            sum += abs(left-lis[ridx]);
            left = lis[ridx];
            ridx--;
        }else if(max({abs(left-lis[lidx]), abs(left-lis[ridx]), abs(right-lis[lidx]), abs(right-lis[ridx])}) == abs(right-lis[lidx])){
            sum += abs(right-lis[lidx]);
            right = lis[lidx];
            lidx++;
        }else{
            sum += abs(right-lis[ridx]);
            right = lis[ridx];
            ridx--;
        }
        //cout << right << left << endl;
    }
    chmax(ans, sum);
    cout << ans << endl;
}

Measured memory_bytes: 3768
import java.io.IOException;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		int n, m;

		n = scan.nextInt();
		m = scan.nextInt();

		int n_ans = 0;
		int m_ans = 0;

		if (n <= 1) {
			n_ans = 0;

		} else {
			n_ans = n * (n - 1) / 2;
		}

		if (m <= 1) {
			m_ans = 0;
		} else {
			m_ans = m * (m - 1) / 2;
		}

		System.out.println(n_ans + m_ans);
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,q;
bool s[2005][2005];
int p[2005][2005];
int e1[2005][2005];
int e2[2005][2005];
int sump,sume;
int x_1,x_2,y_1,y_2;
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	char c=getchar();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			while(c!='1'&&c!='0') c=getchar();
			if(c=='1') s[i][j]=1;
			else s[i][j]=0;
			c=getchar();//
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			p[i][j]=p[i-1][j]+p[i][j-1]-p[i-1][j-1]+s[i][j];
			e1[i][j]=e1[i-1][j]+e1[i][j-1]-e1[i-1][j-1];
			e2[i][j]=e2[i-1][j]+e2[i][j-1]-e2[i-1][j-1];
			//if(s[i-1][j-1]&&s[i-1][j]) e[i][j]++;
			//if(s[i-1][j-1]&&s[i][j-1]) e[i][j]++;
			if(s[i][j]&&s[i][j-1]) e1[i][j]++;
			if(s[i][j]&&s[i-1][j]) e2[i][j]++;
		}
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d%d",&x_1,&y_1,&x_2,&y_2);
		sump=p[x_2][y_2]-p[x_2][y_1-1]-p[x_1-1][y_2]+p[x_1-1][y_1-1];
		sume=e1[x_2][y_2]-e1[x_1-1][y_2]-e1[x_2][y_1]+e1[x_1-1][y_1];
		sume+=e2[x_2][y_2]-e2[x_1][y_2]-e2[x_2][y_1-1]+e2[x_1][y_1-1];
		//sume=e1[x_2][y_2]+e2[x_2][y_2]-e1[x_2][y_1]-e2[x_2][y_1-1]-e1[x_1-1][y_2]-e2[x_1][y_2]+e1[x_1-1][y_1-1]+e2[x_1-1][y_1-1];
		printf("%d\n",sump-sume);
	}
	return 0;
}

Measured memory_bytes: 52864
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long

LL r, x, D;

int main() {
	cin >> r >> D >> x;
	for (int i = 0; i < 10; i++) {
		cout << x * r - D << endl;
		x = x * r - D;
	}

	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut sushi = std::collections::BinaryHeap::new();
    for _ in 0..n {
        let v = read_vec::<u64>();
        let t = v[0] as usize;
        sushi.push((v[1], t));
    }

    let mut eated_count = vec![0u64; n + 1];
    let mut ans = 0u64;
    let mut cur_kinds = 0;
    let mut poppable = Vec::new();

    for _ in 0..k {
        let (d, t) = sushi.pop().unwrap();
        eated_count[t] += 1;
        if eated_count[t] == 1 {
            cur_kinds += 1;
        } else {
            poppable.push(d);
        }
        ans += d;
    }
    ans += cur_kinds * cur_kinds;

    let mut temp_ans = ans;
    while let Some((d, t)) = sushi.pop() {
        if eated_count[t] != 0 {
            continue;
        }
        eated_count[t] += 1;
        if let Some(no_use_d) = poppable.pop() {
            temp_ans += d - no_use_d;
            temp_ans -= cur_kinds * cur_kinds;
            cur_kinds += 1;
            temp_ans += cur_kinds * cur_kinds;
            ans = std::cmp::max(ans, temp_ans);
        } else {
            break;
        }
    }
    println!("{0}", ans);
}


Measured memory_bytes: 6396
n = int(input())
a = list()
for i in range(n):
    a.append(tuple(map(int, input().split())))
count = 0
for i in range(n-2):
    
    if a[i][0] == a[i][1]:
        if  a[i+1][0] == a[i+1][1]:
            if a[i+2][0] == a[i+2][1]:
                count = count + 1

if count == 0:
    print("No")
else: print("Yes")

Measured memory_bytes: 62300
#include <cstdio>

int main()
{
    int N;
    int i = 2;

    int now;
    int l1 = 1;
    int l2 = 1;

    scanf("%d", &N);
    if(N < 2){
        printf("%d\n", 1);
        return 0;
    }

    for (;;)
    {
        now = l1 + l2;
        if(i == N){ break; }
        l1 = l2;
        l2 = now;
        i++;
    }

    printf("%d\n", now);
    return 0;
}


Measured memory_bytes: 2764
import java.util.*;
import java.lang.*;

class Town{
    int id;
    long x, y;
    public Town(int id, long x, long y){
        this.id = id;
        this.x = x;
        this.y = y;
    }
    long distanceTo(Town another){
        return Math.min(Math.abs(this.x-another.x), Math.abs(this.y-another.y));
    }

    static Comparator<Town> longitude(){
        return Comparator.comparingLong(A -> A.x);
    }
    static Comparator<Town> latitude(){
        return Comparator.comparingLong(A -> A.y);
    }
}
class Edge{
    int from, to;
    long length;
    public Edge(int from, int to, long length){
        this.from = from;
        this.to = to;
        this.length = length;
    }

    static Comparator<Edge> longer(){
        return Comparator.comparingLong(A -> A.length);
    }
}

class UnionFind{
    private int size;
    private int[] parent;
    private int[] blockSize;
    public UnionFind(int size){
        this.size = size;
        parent = new int[size];
        blockSize = new int[size];
        for(int i=0;i<size;i++){
            parent[i]=i;
            blockSize[i]=1;
        }
    }
    boolean isRoot(int node){
        return node==parent[node];
    }
    int getRoot(int node){
        if(isRoot(node)) return node;
        else{
            parent[node] = getRoot(parent[node]);
            return parent[node];
        }
    }
    public void union(int node1, int node2){
        if(find(node1, node2)) return;
        if(blockSize[node1]>blockSize[node2]){
            blockSize[getRoot(node1)] = blockSize[getRoot(node1)]+blockSize[getRoot(node2)];
            parent[getRoot(node2)] = getRoot(node1);
        } else{
            blockSize[getRoot(node2)] = blockSize[getRoot(node2)]+blockSize[getRoot(node1)];
            parent[getRoot(node1)] = getRoot(node2);
        }
    }
    public boolean find(int node1, int node2){
        return getRoot(node1)==getRoot(node2);
    }
    public int countGroup(){
        int ans = 0;
        for(int i=0;i<size;i++) if(isRoot(i)) ans++;
        return ans;
    }
    public int blockSize(int node){
        return blockSize[getRoot(node)];
    }
}

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

        Town[] town = new Town[N];
        for(int n=0; n<N; n++) town[n] = new Town(n, sc.nextLong(), sc.nextLong());
        List<Edge> edge = new ArrayList<>(2*N);

        Arrays.sort(town, Town.latitude());
        for(int n=0; n<N-1; n++) edge.add(new Edge(town[n].id, town[n+1].id, town[n].distanceTo(town[n+1])));
        Arrays.sort(town, Town.longitude());
        for(int n=0; n<N-1; n++) edge.add(new Edge(town[n].id, town[n+1].id, town[n].distanceTo(town[n+1])));

        Collections.sort(edge, Edge.longer());

        long cost = 0;
        UnionFind connect = new UnionFind(N);

        for(Edge e: edge){
            if(!connect.find(e.from, e.to)){
                connect.union(e.from, e.to);
                cost += e.length;
            }
        }
        System.out.println(cost);
    }
}


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

using namespace std;

typedef long long int lli;

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

    int n;
    long double p[3000];
    vector<vector<long double>> dp(3000, vector<long double>(3000, 0));

    cin >> n;
    for (int i=0; i<n; i++) cin >> p[i+1];

    dp[1][0] = 1-p[1]; dp[1][1] = p[1];
    for (int coin=2; coin<=n; coin++) {
        dp[coin][0] = dp[coin-1][0] * (1-p[coin]);
        for (int omt=1; omt<=coin; omt++) {
            dp[coin][omt] = dp[coin-1][omt-1]*p[coin] + dp[coin-1][omt]*(1-p[coin]);
        }
    }
/*
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/
    long double ans = 0;
    for (int i=(n/2)+1; i<=n; i++) {
        ans += dp[n][i];
    }

    printf("%.10Lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 141184
P[];M(int*a){return*1[&a]-*a;}main(n,i,p,d){for(;~scanf("%d",&n);printf("%d\n",p)){for(i=n;p=d=i--;)scanf("%d",P+i);for(qsort(P,i=n,4,M);i--;)p+=d+=P[i];}}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
using namespace std;

#define INF 1000000000

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

    int r[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &r[i]);
    }

    int max = r[0];
    int min = r[0];
    int diff = -INF;
    for (int i = 1; i < n; i++)
    {
        //printf("%d, %d, %d\n",diff, max, min);
        if (r[i] > max)
        {
            max = r[i];
            if (diff < max - min)
                diff = max - min;
        }
        else if (r[i] <= min)
        {
            min = r[i];
            max = min;
            if (diff < r[i] - r[i - 1])
                diff = r[i] - r[i - 1];
        }
    }

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

    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

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

    int a,b,c;
    cin >> a;
    string ans = "NO";
    if(a == 3 || a == 5 || a == 7){
        ans = "YES";
    }

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var k int
	var s string
	con.Scan(&k, &s)
	n := len(s)
	a := 0
	p25 := make([]int, k+1)
	p26 := make([]int, k+1)
	p25[0] = 1
	p26[0] = 1
	for i := 1; i <= k; i++ {
		p25[i] = p25[i-1] * 25
		p25[i] %= mod
		p26[i] = p26[i-1] * 26
		p26[i] %= mod
	}
	c := 1
	for i := 0; i <= k; i++ {
		x := c
		x *= p26[k-i]
		x %= mod
		x *= p25[i]
		x %= mod
		a += x
		a %= mod
		c *= n + i
		c %= mod
		c *= powmod(i+1, mod-2)
		c %= mod
	}
	fmt.Println(a)
	return nil
}

const mod = 1e9 + 7

func powmod(a, m int) int {
	b := 1
	for m > 0 {
		if m&1 != 0 {
			b = b * a % mod
		}
		a = a * a % mod
		m >>= 1
	}
	return b
}

func combmod(n, r int) int {
	c := 1
	for i := 0; i < r; i++ {
		c *= n - i
		c %= mod
		c *= powmod(i+1, mod-2)
		c %= mod
	}
	return c
}


Measured memory_bytes: 22016
#include <iostream>
using namespace std;
using L = long long int;
L fast_pow(L,L);
int main(){
	L h;
	int n;
	cin >> h;
	for(n = 1;h >= fast_pow(2,n);n++){}
	cout << fast_pow(2,n) - 1;
	return 0;
}


L fast_pow(L x,L y){
	if(y == 1){
		return x;
	}
	if(y % 2){
		return x * fast_pow(x,y - 1);
	}
	L buf = fast_pow(x ,y / 2);
	return buf * buf;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int s, t;
  VVI edge(3 * n);
  VI d(3 * n, INF);
  REP(i, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    edge[u].push_back(v + n);
    edge[u + n].push_back(v + 2 * n);
    edge[u + 2 * n].push_back(v);
  }
  cin >> s >> t;
  s--; t--;
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front(); q.pop();
    if(u == t) break;
    for(auto v : edge[u]){
      if(d[v] == INF) {
        q.push(v);
        d[v] = d[u] + 1;
      }
    }
  }
  d[t] == INF ? out(-1) : out(d[t] / 3);
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int r = 1e9;
  for (int i = 0; i < s.size() - 2; i++) {
    r = min(r, abs(100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + (s[i + 2] - '0') - 753));
  }
  cout << r << endl;
}


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

void solv(
	double a,
	double b,
	double c,
	double d,
	double e,
	double f,
	double & x,
	double & y){
	y = (f - (d*c)/a)/(e - (b*d)/a);
	x = (c - b*y)/a;
}

int main(){
	std::vector<std::pair<double, double>> ans;

	double a,b,c,d,e,f;
	std::pair<double, double> tmp;

	while(true){
		std::cin >> a >> b >> c >> d >> e >> f;
		if(std::cin.eof() == true) break;
		solv(a,b,c,d,e,f,
			tmp.first, tmp.second);
		ans.push_back(tmp);
	}

	for(auto && a : ans){
		printf("%0.3f %0.3f\n", a.first, a.second);
	}
}

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

int main(void)
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    double den = 0;
    double num = 1.0;
    for (auto x : A) {
        den += 1.0 / static_cast<double>(x);
    }

    std::cout << num / den << std::endl;

    return 0;
}

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

using namespace std;

int main() {
  long long  n;
  cin>>n;
  long long sum=0;
  vector<long long> vec(100000,0);
  for(long long i=0; i<n;i++){
    int a;
    cin>>a;
    sum+=a;
    a--;
    vec.at(a)++;
    
  }
  long long q;
  cin>>q;
  for(long long i=0;i<q;i++){
    long long b,c;
    cin>>b>>c;
    b--;
    c--;
    sum+=(c-b)*vec.at(b);
    cout<<sum<<endl;
    vec.at(c)+=vec.at(b);
    vec.at(b)=0;      
  }
  
  
  
}

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

using namespace std;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b; cin>>a>>b;
    
    //1262
    
    for(int i=min(a,b);i<=1262;i++) {
        if(i*8/100==a and i*10/100==b) {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

int main(){
  char a;
  cin >> a;
  char b = a + 1;
  cout << b<< endl;
  

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lld n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2==0)
		cout << (b-a)/2;
	else
	{
		lld sum = min(a-1,n-b);
		if(a-1<n-b)
		{
			b-=(a-1);
			a=1;
			if(b&1)
			{
				sum+=(b-1)/2;
			}
			else
			{
				b--;
				sum++;
				sum+=(b-1)/2;
			}
		}
		else
		{
			a+=(n-b);
			b=n;
			if((n-a)%2==0)
			{
				sum+=(n-a)/2;
			}
			else
			{
				a++;
				sum++;
				sum+=(n-a)/2;
			}
		}
		cout << sum;
	}
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    putStrLn $ if even (a+b) then show ((a + b) `div` 2) else "IMPOSSIBLE"

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
#define ll long long
char t[maxn];
int main()
{
	scanf("%s",t+1);
	int len=strlen(t+1);
	int cnt=0;
	ll ans=0;
	for(int i=len;i>=1;i--)
	{
		if(t[i]=='W')
			cnt++;
		else
			ans+=cnt;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
main(){
    while(cin>>M>>N,N){
        vector<int>s(M);
        int ans=0;
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                int a;cin>>a;ans=max(ans,s[j]+=a);
            }
        }cout<<ans<<endl;
    }
}


Measured memory_bytes: 3016
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a[555];
int k;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>n>>k;
	int sum=0;
	FOR(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	for(int ii=1;ii*ii<=sum;++ii){
		if(sum%ii)continue;
		int i=sum/ii;
		vi b;
		int cur=0;
		FOR(j,0,n){
			b.push_back(a[j]%i);
			cur+=a[j]%i;
		}
		if(cur%i)continue;
		int num=cur/i;
		SORT(b);
		cur=0;
		FOR(j,0,n-num){
			cur+=b[j];
		}
		if(cur<=k){
			cout<<i<<endl;
			return 0; 
		}
	}
	for(int i=sqrt(sum)+100;i>=2;--i){
		if(sum%i)continue;
		vi b;
		int cur=0;
		FOR(j,0,n){
			b.push_back(a[j]%i);
			cur+=a[j]%i;
		}
		if(cur%i)continue;
		int num=cur/i;
		SORT(b);
		cur=0;
		FOR(j,0,n-num){
			cur+=b[j];
		}
		if(cur<=k){
			cout<<i<<endl;
			return 0; 
		}
	}
	cout<<1<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String num = sc.next();
    int n = num.length();
    
    if(num.substring(n-1,n).equals("0") || num.substring(n-1,n).equals("1") || num.substring(n-1,n).equals("6") || num.substring(n-1,n).equals("8") ) {
      System.out.println("pon");
      return ;
    } else if(num.substring(n-1,n).equals("3")) {
      System.out.println("bon");
      return ;
    } else {
      System.out.println("hon");
    }
  }
}

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


const int mod = 1e9+7;
int fact[2020];

int power(int a, int b){
    int ans = 1;
    while(b){
        if (b&1){
            ans = (ans*a)%mod;
        }
        a = (a*a)%mod;
        b>>=1;
    }
    return ans;
}

int inv(int a){
    return power(a, mod-2);
}

int ncr(int n, int r){
    int denom = fact[r] * fact[n-r] %mod;
    denom = inv(denom);
    return (fact[n]*denom)%mod;
}


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;

    if(n==3){
        cout<<1<<endl;
        return 0;
    }

    fact[0] = 1;
    for (int i=1; i<=n; i++){
        fact[i] = (i*fact[i-1])%mod;
    }

    //n-1cr-1
    //n-1-2*icri-1

    int ans = 0;
    for (int i=1; (n-1-2*i)>0; i++){
        if (n-1-2*i<i-1) break;
        ans = (ans + ncr(n-1-2*i, i-1))%mod;
    }
    cout<<ans<<endl;



    return 0;
}






Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

struct UnionFind {
    int n, cnt;
    vector<ll> par, rank, sz;

    UnionFind(ll n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) { iota(par.begin(), par.end(), 0); }

    ll find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(ll x, ll y) { return find(x) == find(y); }

    ll size(ll x) { return sz[find(x)]; }

    void unite(ll x, ll y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

int main() {
    int N; cin >> N;
    double ans=0;
    vector<int>X(N),Y(N);
    int all=1;
    rep(i,N){
        cin >> X[i] >> Y[i];
    }
    for(int i=N; i>0; i--){
        all*=i;
    }

    int cnt=2;
    for(int i=N-1; i>0; i--){
        cnt *= i;
    }

    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            int diffX = X[i]-X[j], diffY = Y[i]-Y[j];
            ans+=cnt*sqrt(diffX*diffX+diffY*diffY)/all;
        }
    }


    cout << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 1'000'000'007LL
#define N 212345
ll fct[N] = {1}, fctinv[N];
ll pw(ll a, ll b){
	ll c = 1;
	do {
		if(b&1) c = c * a % MOD;
		a = a * a % MOD;
	} while(b /= 2);
	return c;
}
ll inv(ll a){
	return pw(a, MOD-2);
}
ll cmb(ll a, ll b){
	ll ans = 1;
	FOR(i, 1, b+1){
		ans = ans * (a-b + i) % MOD;
		ans = ans * inv(i) % MOD;
	}
	return ans;
}

int main(){
	FOR(i, 1, N) fct[i] = fct[i-1] * i % MOD;
	REP(i, N) fctinv[i] = inv(fct[i]);

	ll n, a, b; scanf("%lld%lld%lld", &n, &a, &b);
	ll ans = pw(2, n);
	ans += MOD - 1;
	ans += MOD - cmb(n, a);
	ans += MOD - cmb(n, b);
	ans %= MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int ls1[Max], ls2[Max];
int n;


int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	ll sum = 0;
	for (int i = 1; i <= n; i++)
	{
		int t = i;
		int s = 0;
		while (t > 0)
		{
			s += t % 10;
			t /= 10;
		}
		if (s <= b && s >= a) sum += i;
	}
	cout << sum;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;

void printv(vvi v){
	for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < v.size(); j++){
			cout << v[i][j] << " ";
		}cout << endl;
	}
		return ;
		}


signed main() {
	
	cin1(n);

	vi cake(n,0);
	rep(i,0,n) {
		cin1(cake[i]);	
	}

	vvi dp(n,vi(n,0));
	rep(i,0,n) {
		dp[i][i] = cake[i];
	}

	for (int i = 0; i < n; i++) { //??????
		for (int l = 0; l < n; l++) {
			int r = (l + i) % n;
			if ((n - i) % 2 == 0) { //????????????
				if (cake[l] > cake[r]) {
					dp[l][r] = dp[(l+1)%n][r];
				}else {
					dp[l][r] = dp[l][(r-1+n)%n];
				}
			}else { //????????????
				dp[l][r] = max(dp[(l+1)%n][r] + cake[l],dp[l][(r-1+n)%n] + cake[r]);
			}
		}
	}

	int ans = 0;
	rep(i,0,n) {
		ans = max(ans,dp[i][(i+n-1)%n]);
	}
	cout(ans);

	return 0;
}

Measured memory_bytes: 34268
# -*- coding: utf-8 -*-
N = int(input())
S = list()
words = {}
for i in range(N):
  s = input()
  S.append(s)
  if s in words:
    words[s] += 1
  else:
    words[s] = 1

max_value = max(words.values())
max_list = list()
for k,v in words.items():
  if v == max_value:
    max_list.append(k)
ans_list = sorted(max_list)
for ans in ans_list:
  print(ans)

Measured memory_bytes: 156976
# -*- coding: utf-8 -*-
# B - Comparing Strings
import  sys

def solve152B(a, b):
	minI, maxI = a, b
	if a > b:
		maxI, minI = a, b
	
	st = ""
	for i in range(maxI):
		st += str(minI)
	
	print(st)


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

	solve152B(a, b)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

vector<ll> parent;
vector<ll> cardinality;
vector<ll> height;
ll N,M;

void init(ll n) {
    for (int i=0; i<n; i++) {
        parent.push_back(i);
        cardinality.push_back(1);
        height.push_back(0);
    }
}

ll find(ll x) {
    if (parent[x] == x) {
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}

void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }
    if (height[x] < height[y]) {
        parent[x] = y;
        cardinality[y] += cardinality[x];
    } else {
        parent[y] = x;
        cardinality[x] += cardinality[y];
        if (height[x] == height[y]) {
            height[x]++;
        }
    }
}

ll size(ll x) {
    x = find(x);
    return cardinality[x];
}

int main() {
    cin >> N >> M;
    
    ll a,b;
    vector<pair<ll,ll> > edges;    
    for (int i=0; i<M; i++) {
        cin >> a >> b;
        edges.push_back(make_pair(a,b));
    }

    init(N+1);
    vector<ll> answer(M+1);
    answer[M] = (N * (N-1))/2;
    
    for (int i=M-1; 0<=i; i--) {
        pair<ll,ll> edge = edges[i];
        
        if (find(edge.first) ==  find(edge.second)) {
            answer[i] = answer[i+1];
        } else {
            answer[i] = answer[i+1] - size(edge.first) * size(edge.second);
        }
        unite(edge.first, edge.second);
    }

    for (int i=1; i<=M; i++) {
        cout << answer[i] << endl;
    }
}


Measured memory_bytes: 6512
#include <iostream>

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if (b == 0)
		return a;
	
	return gcd(b, a % b);
}

unsigned long long int T[100];
unsigned long long int ans = 1;

int main()
{
	int N;
	double a;
	a = 10e18;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> T[i];
	}

	for (int i = 0; i < N; i++)
	{
		ans = (unsigned long long int)(ans / gcd(ans, T[i])) * T[i];
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}

int main(){
  int N, K; cin >> N >> K;
  vector<int> a(N); rep(i, N) cin >> a[i];

  int g = a[0];
  for (int i = 1; i < N; ++i){
    g = gcd(g, a[i]);
  }
  int m = 0;
  for (int i = 0; i < N; ++i){
    m = max(m, a[i]);
  }
  if (gcd(K, g) == g && K <= m) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int in;
  while(cin>>in,in){
    double mini=1e9;
    rep(i,in/500+1){
      if(in-i*500>=0)rep(j,(in-i*500)/300+1){
	  if(in-i*500-j*300>=0)rep(k,(in-i*500-j*300)/200+1){
	      if(in!=i*500+j*300+k*200)continue;
	      //	      cout<<i<<" "<<j<<" "<<k<<endl;
	      double sum=850*(i%3)+850*(i/3)*3*0.88;
	      sum+=550*(j%4)+550*(j/4)*4*0.85;
	      sum+=380*(k%5)+380*(k/5)*5*0.80;
	      mini=min(mini,sum);
	      //	      cout<<i<<" "<<j<<" "<<k<<" "<<sum<<endl;
	    }
	}
    }
    cout<<(int)mini<<endl;
  }

}

Measured memory_bytes: 1160
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        
        String[][] img = new String[N][N];
        for(int i=0; i<N; i++){
            String[] a = sc.next().split("");
            for(int j=0; j<N; j++){
                img[i][j] = a[j];
            }
        }
        
        String[][] tmp_B = new String[M][M];
        for(int i=0; i<M; i++){
            String[] a = sc.next().split("");
            for(int j=0; j<M; j++){
                tmp_B[i][j] = a[j];
            }
        }
        
        for(int y=0; y<N; y++){
            for(int x=0; x<N; x++){
                int count = 0;
                for(int i=0; i<M; i++){
                    for(int j=0; j<M; j++){
                        if(y+i<N  && x+j <N){
                            if(img[y+i][x+j].equals(tmp_B[i][j])){
                                count++;
                            }
                        }
                    }
                }
                
                if(count == M*M){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        
        System.out.println("No");
    }
}

Measured memory_bytes: 23764
import java.io.IOException;
import java.math.BigInteger;

public class Main {
    private static StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int x = readInt();
        int y = readInt();

        int b2 = y - 2 * x;

        if (b2 < 0 || 200 < b2) {
            System.out.print("No");
            return;
        }

        if (b2 % 2 == 1) {
            System.out.print("No");
            return;
        }

        int b = (y - 2 * x) / 2;
        if (x - b < 0 || 100 < x - b) {
            System.out.print("No");
            return;
        }

        System.out.print("Yes");
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


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

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


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            long[] a = readLongArray(reader);
            long A = a[0];
            long B = a[1];
            long C = a[2];
            long D = a[3];

            long lcm = lcm(C, D);

            long x = (B - B / C) - (A - 1 - (A - 1) / C);
            long y = (B - B / D) - (A - 1 - (A - 1) / D);
            long z = (B - B / lcm) - (A - 1 - (A - 1) / lcm);

            System.out.println(x + y - z);
        }
    }

    public static long gcd(long M, long N) {
        long a;

        if (M < N) {
            a = N;
            N = M;
            M = a;
        }

        while (M % N != 0) {
            a = N;
            N = M % N;
            M = a;
        }

        return N;
    }

    public static long lcm(long M, long N) {
        return M * N / gcd(M, N);
    }

    public static long[] readLongArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        long[] array = new long[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Long.parseLong(str[i]);
        }
        return array;
    }

}


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

int main()
{
    ll A, B, C; cin >> A >> B >> C;
    ll K; cin >> K;
    ll sum = A + B + C;
    ll maxv = max(A, B);
    maxv = max(maxv, C);
    sum -= maxv;
    rep(i,K) {
        maxv *= 2;
    }
    cout << sum + maxv << endl;

 
    




}


Measured memory_bytes: 3568
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    use std::cmp::min;
    use std::cmp::max;
    println!("{}",
        max(min(b,d) - max(a,c),0));
}


Measured memory_bytes: 4352