akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-6
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) afor(inct (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int r,n;
double R;
const int geta = 30;
int h[100];
bool in_circle(double c,double x,double y){
	if(sq(abs(y-c))+sq(abs(x))<sq(R-eps))return true;
	else return false;
}
bool out_circle(double c,double x,double y){
	if(sq(abs(y-c))+sq(abs(x))>sq(R+eps))return true;
	else return false;
}
bool inter_vert(double c,double x,double y1,double y2){
	if(x>R-eps)return false;
	if(x<-R+eps)return false;
	if(y1<c&&c<y2){
		if(out_circle(c,x,y1)||out_circle(c,x,y2))return true;
		else return false;
	}else{
		if(in_circle(c,x,y1)!=in_circle(c,x,y2))return true;
		else return false;
	}
}
bool inter_hori(double c,double y,double x1,double x2){
	if(y>c+R-eps)return false;
	if(y<c-R+eps)return false;
	if(x1<0.0&&0.0<x2){
		if(out_circle(c,x1,y)||out_circle(c,x2,y))return true;
		else return false;
	}else{
		if(in_circle(c,x1,y)!=in_circle(c,x2,y))return true;
		else return false;
	}
}
bool check(double t){
	if(t-2.0*R>h[geta])return true;
	for(int i=-20;i<20;i++){
		if(inter_hori(t-R,(double)h[i+geta],(double)i+eps,(double)(i+1)-eps)){
			//cout << h[i+geta] << ' '  << i << ' ' << i+1 << endl;
			return true;
		}
		if(h[i+geta]!=h[i+1+geta]){
			int y1 = min(h[i+geta],h[i+1+geta]);
			int y2 = max(h[i+geta],h[i+1+geta]);
			if(inter_vert(t-R,(double)(i+1),(double)y1+eps,(double)y2-eps)){
				//cout << i+1 << ' ' << y1 << ' ' << y2 << endl;
				return true;
			}
		}
	}
	return false;
}
int cnt = 0;
bool solve(){
	cnt++;
	cin >> r >> n;
	R = r;
	memset(h,0,sizeof(h));
	if(r==0&&n==0)return false;
	int l,r,hi;
	int highest = 0;
	if(cnt==48){
		//cerr << r << ' ' << n << endl;
		//cout << "***************************" << endl;
	}
	for(int i=0;i<n;i++){
		cin >> l >> r >> hi;
		//if(cnt==48)cerr << l << ' ' << r << ' ' << hi << endl;
		for(int j=l;j<r;j++){
			highest = max(highest,hi);
			h[j+geta]=max(h[j+geta],hi);
		}
	}

	double low = 0.0, high = highest;
	for(int i=0;i<100;i++){
		//printf("%.5f %.5f\n",low,high);
		double mid = (low+high)/2.0;
		if(check(mid))high = mid;
		else low = mid;
	}
	printf("%.12f\n",low);
	return true;
}
int main (){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#define NUM 100
using namespace std;

int result[NUM][NUM];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            result[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int tmp;
            cin >> tmp;
            result[u - 1][tmp - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (j)
                cout << ' ';
            cout << result[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();

		if(A.length > B.length) {
			System.out.println("GREATER");
			return;
		}else if(A.length < B.length) {
			System.out.println("LESS");
			return;
		}else {
			int i = 0;
			while(i < A.length) {
				if(A[i] > B[i]) {
					System.out.println("GREATER");
					return;
				}else if(A[i] < B[i]) {
					System.out.println("LESS");
					return;
				}
				i++;
			}
			System.out.println("EQUAL");
		}
	}
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {

    static final String[] NUMS = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        char[] array = s.toCharArray();
        int[] count = new int[100];
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                int num = ((int) array[i] - 48) * 10 + ((int) array[j] - 48);
                if (0 < count[num]) {
                    continue;
                }

                int index = j + 1;
                count[num] = calcCount(new StringBuilder(s).substring(index).toString());
            }
        }
        int sum = Arrays.stream(count).sum();
        int result = sum;

        // 出力
        System.out.println(result);
    }

    public static int calcCount(String s) {
        int count = 0;
        for (String num : NUMS) {
            if (s.contains(num)) {
                count++;
            }
        }
        return count;
    }
}


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



int main(){
    ll n,m;
    cin >> n >> m;
    vector<bool> flag(n,false);
    vector<ll> memo(n,1);
    flag[0]=true;
    for(ll i=0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        if(flag[x]&&memo[x]>1){
            flag[y]=true;
            memo[x]--;
            memo[y]++;
        }
        else if(flag[x]&&memo[x]==1){
            flag[y]=true;
            flag[x]=false;
            memo[x]--;
            memo[y]++;
        }
        else if(!flag[x]){
            memo[x]--;
            memo[y]++;
        }
    }
    ll res=0;
    for(ll i=0;i<n;i++){
        if(flag[i]) res++;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 4048
s=input()
alp="".join([chr(i) for i in range(97,97+26)])
if len(s)<26:
    for i in alp:
        if i not in s:
            print(s+i)
            exit()
else:
    if s=="".join([chr(i) for i in range(97,97+26)][::-1]):
        print(-1)
        exit()
    else:
        for i in range(25)[::-1]:
            for j in range(i+1,26)[::-1]:
                if s[i]<s[j]:
                    print(s[:i]+s[j])
                    exit()

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static char[][] field;
	static int h;
	static int w;

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		field = new char[h][];
		for (int i = 0; i < h; i++) {
			field[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] == '#') {
					continue;
				}
				int count = 0;
				for (int x = -1; x <= 1; x++) {
					for (int y = -1; y <= 1; y++) {
						if (x * x + y * y != 0) {
							count += countMine(j + x, i + y);
						}
					}
				}
				field[i][j] = (char)('0' + count);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < h; i++) {
			sb.append(field[i]).append("\n");
		}
		System.out.print(sb);
	}
	
	static int countMine(int x, int y) {
		if (x < 0 || x >= w || y < 0 || y >= h) {
			return 0;
		}
		if (field[y][x] == '#') {
			return 1;
		} else {
			return 0;
		}
	}
	
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
  	// 奇数文字目がすべて R, U, D のいずれか
	// 偶数文字目がすべて L, U, D のいずれか
 	rep(i,s.size()){
    	if(i%2==0 && s[i] == 'L') {
  			cout << "No" << endl;
          	return;
        }else if(i%2==1 && s[i] == 'R') {
  			cout << "No" << endl;
          	return;
        }		
    }
	cout << "Yes" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size(), m=t.size();
    if(n<m)
    {
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=n-m;i>=0;i--)
        {
        bool flag=true;
        for (int j=0; j<m; j++)
        {
            if(s[i+j]!=t[j]&&s[i+j]!='?')
            flag=false;
        }
        if(flag)
        {
        for (int j=0; j<i; j++)
        {
            if(s[j]=='?')cout<<'a';
            else cout<<s[j];
        }
        cout<<t;
        for(int j=i+m; j<n; j++)
        {
            if(s[j]=='?')cout<<'a';
            else cout<<s[j];
        }
        cout<<endl;
        return 0;
        }
        }
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }


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

const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
pair < int , int > dst[803][803];
char Map[803][803]; int H , W , K;
struct data{
	pair < int , int > val; pair < int , int > pos;
	friend bool operator <(data p , data q){return p.val > q.val;}
}; priority_queue < data > q;

int main(){
	memset(dst , 0x3f , sizeof(dst));
	cin >> H >> W >> K;
	for(int i = 1 ; i <= H ; ++i)
		for(int j = 1 ; j <= W ; ++j){
			cin >> Map[i][j];
			if(Map[i][j] == 'S'){
				dst[i][j] = make_pair(0 , 0);
				q.push((data){make_pair(0 , 0) , make_pair(i , j)});
			}
		}
	while(!q.empty()){
		pair < int , int > t = q.top().pos;
		int x = t.first , y = t.second;
		if(x == 1 || y == 1 || x == H || y == W){cout << dst[x][y].first + 1; return 0;}
		q.pop();
		for(int i = 0 ; i < 4 ; ++i){
			int X = x + dir[i][0] , Y = y + dir[i][1];
			pair < int , int > ndst = dst[x][y].first || Map[X][Y] != '#' ? (dst[x][y].second == K ? make_pair(dst[x][y].first + 1 , 1) : make_pair(dst[x][y].first , dst[x][y].second + 1)) : make_pair(1 , 1);
			if(dst[X][Y] > ndst){dst[X][Y] = ndst; q.push((data){dst[X][Y] , make_pair(X , Y)});}
		}
	}
	return 0;
}


Measured memory_bytes: 6524
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int gcd(int x, int y){
    int r;
    while((r=x%y)!=0){
        x = y;
        y = r;
    }
    return y;
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for (int i=0; i<N; i++) cin >> x[i];
    int x_gcd = max(X-x[0], x[0]-X);
    for (int i=1; i<N; i++) x_gcd = gcd(x_gcd, max(X-x[i], x[i]-X));
    cout << x_gcd << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
class UnionFind
{
public:
    vector<T> par;
    vector<T> rank;
    T index;
    UnionFind(T n) : par(n, 0), index(n), rank(n, 0)
    {
    }
    void init(T n)
    {
        for (ll i = 0; i < n; i++)
        {
            par[i] = i;
        }
    }
    int find(T x)
    {
        if (par[x] == x)
        {
            return x;
        }
        else
            return par[x] = find(par[x]);
    }
    void unite(T x, T y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
            par[x] = y;
        else
            par[y] = x;
        if (rank[x] == rank[y])
            rank[x]++;
    }
    bool same(T x, T y)
    {
        return find(x) == find(y);
    }
};
int main()
{
    ll n, q;
    cin >> n >> q;
    UnionFind<ll> uf(n);
    uf.init(n);
    for(int i = 0; i < q; i++){
        ll com,x,y;
        cin >> com >> x >> y;
        if(!com)
        uf.unite(x,y);
        else
        cout << (uf.same(x,y) ? "1" : "0") << endl;
    }
}


Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
ll a[maxn] = { 0 };
int main() {
	ll n, i;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll sum1 = 0;  ll sum2 = 0;
	ll ans1 = 0; ll ans2 = 0;
	for (int i = 1;i <= n; ++i) {
		sum1 += a[i];
		if (i % 2 == 0 && sum1 >= 0) {
			ans1 += sum1 + 1;
			sum1 = -1;
		}
		else if (i % 2 != 0 && sum1 <= 0) {
			ans1 += abs(sum1) + 1;
			sum1 = 1;
		}
	}
	for (int i = 1; i <= n; ++i) {
		sum2 += a[i];
		if (i % 2 == 0 && sum2 <= 0) {
			ans2 += abs(sum2) + 1;
			sum2 = 1;
		}
		else if (i % 2 != 0 && sum2 >= 0) {
			ans2 += abs(sum2) + 1;
			sum2 = -1;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int n; cin >> n;
    vector<int> HA;
    char hina;
    bool flag = true;
    REP(i, n)  {
        cin >> hina;
        if (hina == 'Y') {
            flag = false;
            break;
        }
    }

    if (flag) cout << "Three" << endl;
    else cout << "Four" << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

long[] dijkstra(long from, long to, long[][] edges)
{
	long[] path;
	auto cost = new long[](edges.length); fill(cost, long.max); cost[from] = 0;
	long[][] open = [[from]];
	while (!open.empty)
	{
		auto n = open.front; open.popFront;
		auto p = n[0];
		foreach (i; 0..edges.length)
		{
			if (edges[p][i] == -1) continue;
			auto c = cost[p] + edges[p][i];
			if (c < cost[to] && c < cost[i]) { cost[i] = c; if (i == to) path = i ~ n; else open ~= i ~ n; }
		}
	}
	return cost[to] ~ path;
}

void main()
{
	auto H = RD!long;
	auto W = RD!long;
	auto N = RD!long;
	auto a = RDR.ARR!long;

	auto ans = new long[][](H, W);
	long pos;
	foreach (i; 0..H)
	{
		foreach (j; 0..W)
		{
			auto x = i % 2 == 1 ? W - j - 1 : j;
			ans[i][x] = pos + 1;
			--a[pos];
			if (a[pos] == 0) ++pos;
		}
	}

	foreach (i; 0..H)
	{
		write(ans[i][0]);
		foreach (j; 1..W)
		{
			write(" ", ans[i][j]);
		}
		writeln();
	}
	stdout.flush();
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    string S;
    string a = "AAA";
    string b = "BBB";
    cin >> S;
    if(S == a || S == b){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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(){
    ll X, K, D; cin >> X >> K >> D;
    ll ans;
    if (X < 0) X = - X;

    if( X / D >= K){
        ans = X - K * D;
    }else{
        ll shou = X / D;
        ll amari = X % D;
        if((K - shou)%2 == 0){
            ans = amari;
        }else{
            ans = abs(amari - D);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3648
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << 180*(n - 2);

	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let mut b :i32= read();
    let mut c :i32= read();
    let mut r = 0;
    while c != 0 && b >= a {
        b = b - a;
        c = c - 1;
        r = r + 1;
    }
    println!("{}", r);
}


Measured memory_bytes: 4352
console.log((args=>{
  const [[A,B,C],[K]] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  for ( let i = 0; i < K; i++ ) {
    for ( let j = 0; i+j < K; j++ ) {
      if ( A<<i < B<<j && B<<j < C<<(K-i-j) ) return 'Yes';
    }
  }
  return 'No';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;

int main()
{
    ll a;
    ld b;
    cin >> a >> b;
    a*=b;
    cout << a<< endl;

}

Measured memory_bytes: 3736
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] goods = new int[n];
        int max = 0;
        int max_index = 0;
        
        for (int i = 0; i < n; i++) {
            int price = Integer.parseInt(br.readLine());
            goods[i] = price;
            if (price > max) {
                max = price;
                max_index = i;
            }
        }
        
        goods[max_index] /= 2;
        
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += goods[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
int main(){
	int A,B,C,D;
	scanf("%d",&A);
	scanf("%d",&B);	
	scanf("%d",&C);
	scanf("%d",&D);
	if( A < B){
		B = A;
	}
	if( C < D){
		D = C;
	}
	printf("%d",B+D);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main(){
	int k;
	for(int i=0;i<3;i++)cin>>a[i];
	cin>>k;
	sort(a,a+3);
	cout<<a[0]+a[1]+a[2]*pow(2,k)<<'\n';
	return 0;
}


Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
X, Y = map(int, readline().split())
x = 2*X
if x > Y:
  print('No')
  sys.exit()
for i in range(X+1):
  if (x + 2*i) == Y:
    print('Yes')
    sys.exit()
print('No')

Measured memory_bytes: 9248
n, m = gets.chomp.split(" ").map(&:to_i)
s = []
n.times do
    s << gets.chomp.split(" ").map(&:to_i)
end
c = []
m.times do
    c << gets.chomp.split(" ").map(&:to_i)
end

s.each do |ss|
    d_min = 10 ** 10
    c_min = 0
    c.each_with_index do |cc, i|
        d = (cc[0]-ss[0]).abs + (cc[1]-ss[1]).abs
        if d < d_min
            d_min = d
            c_min = i + 1
        end
    end
    puts c_min
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <queue>


using namespace std;

class Player{
private:
  int  base;

public:
  Player(int i){
    base=1;
  }


  void SetBase(int a){
    this->base =a;
  }

  int GetBase(){
    return this->base;
  }
};

class Baseball{
private:
  int score;
  int out;
  queue<Player> que;

public:
  Baseball(){
      score = out=0;
  }

  void add_hit(int num){
    Player one(1);
    this->que.push(one);
    int length=this->que.size();

    for(int i= 0;i<length;i++){
      Player tmp = this->que.front();
      this->que.pop();
      int tmp_base=tmp.GetBase();
      if((tmp_base+num)>4){
        score++;
      }else{
        tmp.SetBase(tmp_base+num);
        this->que.push(tmp);
      }
    }
  }

  void add_out(){
    this->out++;
  }

  void add_score(){
    this->score++;
  }

  int GetOut(){
    return this->out;
  }

  int GetScore(){
    return this->score;
  }

  void show_score(){
    cout<<this->score<<endl;
  }

};

int main(void){
  int time;
  cin >> time;

  for(int i=0;i<time;i++){
    Baseball baseball;
    while(baseball.GetOut()!=3){
      string judge;
      cin>>judge;
      if(judge == "HIT"){
        baseball.add_hit(1);
      }else if(judge=="OUT"){
        baseball.add_out();
      }else if(judge=="HOMERUN"){
        baseball.add_hit(4);
      }

    }

    cout<<baseball.GetScore()<<endl;
  }

  return 0;
}



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

using namespace std;

bool issquare(vector<string> m, vector<char> &c, int k){
	if(k >= c.size()){
		return true;
	}
	int n = (int)c.size();
	int h = (int)m.size();
	int w = (int)m[0].size();
	int r = 0, l = w, u = h, d = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(m[i][j] == c[k]){
				r = max(r, j);
				l = min(l, j);
				u = min(u, i);
				d = max(d, i);
			}
		}
	}
	//printf("(%d, %d), (%d, %d)\n",r,l,u,d);
	bool flag = true;
	for(int i = u; i <= d; i++){
		for(int j = l; j <= r; j++){
			if(m[i][j] != '?' && m[i][j] != c[k]){
				flag = false;
				i = j = (int)1e9;
			}
		}
	}
	if(!flag)return false;
	for(int i = u; i <= d; i++){
		for(int j = l; j <= r; j++){
			if(m[i][j] == c[k]){
				m[i][j] = '?';
			}
		}
	}
	return issquare(m, c, k+1);
}




int main(){
	int nn; cin >> nn;
	for(int z = 0; z < nn; z++){
		int h,w; cin >> h >> w;
		vector<string> m(h);
		vector<char> c;
		for(int i = 0; i < h; i++){
			cin >> m[i];
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(m[i][j] == '.')continue;
				bool flag1 = true;
				for(int k = 0; k < c.size(); k++){
					if(m[i][j] == c[k]){
						flag1 = false;
						break;
					}
				}
				if(flag1)c.push_back(m[i][j]);
			}
		}
		sort(c.begin(), c.end());/*
		for(int i = 0; i < c.size(); i++){
			cout << c[i] << " ";
		}
		cout << endl;*/
		bool flag = false;
		do{
			if(issquare(m, c, 0)){
				flag = true;
				break;
			}
		}while(next_permutation(c.begin(), c.end()));
		if(flag){
			cout << "SAFE" << endl;
		}
		else{
			cout << "SUSPICIOUS" << endl;
		}
	}
	return 0;
}





Measured memory_bytes: 3316
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int window[10000];
int main() {
	int N, H, W;
	cin >> N >> H >> W;
	for (int i = 1; i <= N; i++) {
		int dx;
		cin >> dx;
		int X = (i - 1)*W;
		if (i % 2 == 1) X += dx;
		else X -= dx;
		for (int j = 0; j < W; j++) window[X + j] = 1;
	}
	int ans = 0;
	for (int i = 0; i < N*W; i++) {
		if (!window[i]) ans += H;
	}
	cout << ans << endl;
}


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

set<string> S;

int main(){
	long long N;
	cin >> N;
	for(long long i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		S.insert(tmp);
	}
	cout << S.size() << endl;

}


Measured memory_bytes: 19180
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: u8,
        b: u8
    };
    let vecs = [vec![1, 3, 5, 7, 8, 10, 12], vec![4, 6, 9, 11], vec![2]];
    let tf = vecs.iter().any(|v| v.contains(&a) && v.contains(&b));
    println!("{}", ["No", "Yes"][tf as usize]);
}


Measured memory_bytes: 2100
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	x, y, a, b, c := io.NextInt(), io.NextInt(), io.NextInt(), io.NextInt(), io.NextInt()
	p, q, r := io.NextInts(a), io.NextInts(b), io.NextInts(c)
	sort.Ints(p)
	sort.Ints(q)
	sort.Ints(r)
	h := &IntHeap{}
	for i := 0; i < x; i++ {
		heap.Push(h, p[a-1-i])
	}
	for i := 0; i < y; i++ {
		heap.Push(h, q[b-1-i])
	}
	for i := range r {
		heap.Push(h, r[c-1-i])
		heap.Pop(h)
	}
	ans := 0
	for h.Len() > 0 {
		ans += heap.Pop(h).(int)
	}
	io.Println(ans)
}

// IntHeap is heap for interger

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

// Push adds an element to heap
func (h *IntHeap) Push(x interface{}) {

	*h = append(*h, x.(int))
}

// Pop returns the minimum element of the heap and remove it
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;

int main() {
    cin >> n;
    int a = 800 * n;
    int b = n / 15 * 200;
    cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int n, m;
	cin >> n >> m;
	int l_edge = 0;
	int r_edge = n - 1;
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		l_edge = max(l_edge, l);
		r_edge = min(r_edge, r);
	}
	if (l_edge > r_edge) {
		cout << 0 << endl;
	} else {
		cout << r_edge - l_edge + 1 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

signed main() {
	int a,b,c;
	cin >> a >> b >> c;
	int tmp=a-b;
	if(tmp>=c){
		cout << 0 << endl;
	}
	else{
		cout << c-tmp << endl;
	}
}

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

int main(){
	int N, M, a, b;
	bool j = true;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		a--;b--;
		A[a]++;A[b]++;
	}
	for (int i = 0;i < N;i++)
		if (A[i] % 2) j = false;
	if (j) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main()
{
 //freopen("t.txt","r",stdin);
 int r,g,b;
 cin>>r>>g>>b;
 int res= g*10+b;
// cout<<res;
	if (res%4==0) printf ("YES");
	else printf("NO");
	
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, a, b; cin >> N >> a >> b;

    int ans = 0;
    FOR( i, 1, N + 1 ){
        string s = to_string( i );
        int d = 0;
        REP( j, s.size() ){
            d += s[j] - '0';
        }
        if( a <= d && d <= b ){
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e15;
ll power(ll a,ll b){a%=MOD;if(!a) return 0;ll p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}
int main()
{
    speed();
    ll x,k,d; cin >> x >> k >> d;
	x = abs(x);
	if(x / k >= d){
		cout << x - k * d << endl;
	}else{
		ll t = x / d;
		k -= t;
		x -= t * d;
		if(k % 2){
			cout <<  d - x << endl;
		}else{
			cout << x << endl;
		}
	}

}


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	bool ans = false;
	for (int k = 0; k <= N; k++) {
		for (int l = 0; l <= M; l++) {
			if (k * (M - l) + l * (N - k) == K)
				ans = true;
		}
	}

	Yn(ans);
	
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 l,r,d;
  cin >> l >> r >> d;
  ANS(r/d - (l-1)/d);
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
void  dfs(vector<int>adj[],int i,int visit[],int dp[])
{
    visit[i]=1;
    for(int j=0;j<adj[i].size();j++)
    {
        if(visit[adj[i][j]]==0)
        {
            dfs(adj,adj[i][j],visit,dp);
        }
        dp[i]=max(dp[i],1+dp[adj[i][j]]);
    }
    
}
int maxp(vector<int>adj[],int n)
{
    int visit[n+1];
    memset(visit,0,sizeof(visit));
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {   if(visit[i]==0)
       {
        dfs(adj,i,visit,dp);
       }
      
    }
    int max1=0;
    for(int i=0;i<=n;i++)
    {
        max1=max(max1,dp[i]);
    }
    return max1;
}
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    vector<int>adj[n+1];
    while(m--)
    {
        cin>>a>>b;
        adj[a].push_back(b);
    }
    cout<<maxp(adj,n)<<"\n";
}


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

#define ll long long

const ll MOD = 1000000007;

vector<ll> v_prime;

vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  
  for (ll a = 2; a*a <= n; a++) {
    if (n % a) continue;
    ll ex = 0;
    
    while (n % a == 0) {
      ex++;
      n /= a;
    }
    
    res.push_back({a, ex});
  }
  
  if (n != 1) res.push_back({n,1});
  
  return res;
}
  
  
int main() {
  int N;
  cin >> N;
  
  vector<ll> prime_v(1000, 0);
  
  for (ll i = 2; i <= N; i++) {
    vector<pair<ll, ll>> temp_factorize = prime_factorize(i);
    
    int t = temp_factorize.size();
    for (int j = 0; j < t; j++) {
      pair<ll, ll> p = temp_factorize[j];
      
      prime_v[p.first] += p.second; 
    }  
  }
  
  ll ans = 1;
  for (int i = 1; i < 1000; i++) {
    ans *= (prime_v[i] + 1);
    ans %= MOD;
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
const int mx = 1e5+100;
int father[mx],n,m,p[mx];
int fi(int a)
{
    int x=a,j;
    while(father[x]!=x)
        x=father[x];
    while(a!=x){
        j=father[a];
        father[a]=x;
        a=j;
    }
    return x;
}
void join(int a,int b)
{
    int fa=fi(a);
    int fb=fi(b);
    father[fa]=father[b];
}
void init()
{
    for(int i=1;i<=n;i++)
        father[i]=i;
}
int main()
{
    while(~scanf("%d%d",&n,&m)){
        init();
        for(int i=1;i<=n;i++)
            scanf("%d",&p[i]);
        for(int i=0;i<m;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            join(x,y);
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(fi(i)==fi(p[i]))
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

int main(){
  int n;
  char s[105];
  int x = 0;
  int mx = 0;
  
  scanf("%d %s", &n, s);

  int i;
  for(i = 0;i < n;i++){
    if(s[i] == 'D') x--;
    else x++;

    if(mx < x) mx = x;
  }

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

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Possible")  # type: str


def no():
    print("Impossible")  # type: str


def main():
    H, W = map(int, input().split())
    A = [None]*H
    for i in range(H):
        A[i] = list(input())

    # 個数がH+W-1でなければ、条件を満たすさない。
    if H+W-1 != sum([A[i].count("#") for i in range(H)]):
        no()
        return

    # 連結しているか
    yes()

    pass


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;typedef long long int ll;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(int arr[], int n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    double x;
    multiset<double>s;
    for(int i=0;i<n;i++)
    {
        double xx;
        cin>>xx;
        s.insert(xx);
    }
    while(1)
    {
        x=*s.begin();
        s.erase(s.begin());
        if(s.empty()){
        break;}
        double y=*s.begin();
        s.erase(s.begin());
       // cout<<x<<" "<<y<<'\n';
        s.insert((x+y)/2.0000000);
    }
    cout<<fixed<<setprecision(10)<<x;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  ll ans = INF;
  REP(i, n){
    ll a; cin >> a;
    ll d = 0;
    while(a%2 == 0){
      a /= 2;
      d++;
    }
    ans = min(ans,d);
  }
  cout << ans << endl;
}

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

using namespace std;

const int maxn = 3e3+10;
const int mod = 1e9+7;

int n;
long long int dp[maxn], psum[maxn];
string s;

int main(){
	cin >> n;
	cin >> s;
	for (int i = 1; i <= n; i++){
		psum[i] = 1;
	}

	for (int i = 2; i <= n; i++){
		for (int j = 1; j <= i; j++){
			if (s[i-2] == '>')
				dp[j] = (psum[n] - psum[j-1]) % mod;
			else 
				dp[j] = psum[j-1];
		}

		for (int j = 1; j <= n; j++)
			psum[j] = (psum[j-1] + dp[j]) % mod;
	}

	cout << ((psum[n] % mod) + mod) % mod << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = n;
      int s = 0;
      while(n>=1){
      	s += n%10;
        n = n/10;
      }
      if(x%s==0&&s!=0)System.out.println("Yes");
      else System.out.println("No");
    }
}


Measured memory_bytes: 21972
A,B,C,X,Y=map(int,input().split())
Xo=A*X+B*Y
if X>=Y:
 X1=A*(X-Y)+2*C*Y
else:
 X1=B*(Y-X)+2*C*X
X2=2*C*max(X,Y)
print(min(Xo,X1,X2))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> d[101];
int r[101];
int p[101][101];
int main(){
	string a;
	int q,t;
	t=0;
	while(cin>>a>>q){
		bool news=true;
		for(int i=0;i<t;i++){
			if(d[i].first==a){
				p[i][r[i]]=q;
				r[i]++;
				news=false;
			}
		}
		if(news){
			d[t].first=a;
			d[t].second=t;
			r[t]=1;
			p[t][0]=q;
			t++;
		}
	}
	sort(d,d+t);
	for(int i=0;i<t;i++)sort(p[i],p[i]+r[i]);
	for(int i=0;i<t;i++){
		int y=d[i].second;
		cout<<d[i].first<<endl<<p[y][0];
		for(int j=1;j<r[y];j++)cout<<" "<<p[y][j];
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

#define x first
#define y second

int n, d, a;

int main() {
    cin >> n >> d >> a;
    vector<pair<int, int> > monster(n);
    for (int i = 0; i < n; i++) {
        cin >> monster[i].x >> monster[i].y;
    }
    sort(monster.begin(), monster.end());

    vector<pair<int, int> > tmp;
    long long ans = 0, cs = 0;
    int ii = 0;
    for (auto m : monster) {
        int xx = m.x, hh = m.y;
        while (ii < (int) tmp.size() && tmp[ii].x < xx - d) {
            cs -= (long long) tmp[ii].y * a;
            ii++;
        }
        hh -= cs;
        if (hh >= 0) {
            int k = (hh + a - 1) / a;
            ans += 1ll * k;
            tmp.push_back({xx + d, k});
            cs += (long long) k * a;
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3956
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#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)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n, k;
    cin >> n >> k;

    int ans = 1;
    rep(i, n) {
        if (ans+k < ans*2) {
            ans += k;
        }
        else {
            ans *= 2;
        }
    }

    cout << ans;


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define MOD (ll) (1e9+7)
int main()
{
	ll k;
	cin>>k;
	if(k%2==0)
	{
		cout<<-1<<"\n";
	}
	else
	{
	     ll ans = -1;
	     set<ll> se;
	     ll ff = 7,cnt=1;
	     while(1)
	     {
	     	if(ff%k==0)
	     	{
	     		ans = cnt;
	     		break;
	     	}
	     	if(se.find(ff%k)!=se.end())
	     	{
	     		ans = -1;
	     		break;
	     	}
	     	se.insert(ff%k);
	     	ff = (ff%k)*10+7;
	     	cnt++;
	     }
	     if(ans==-1)
	     {
	     	cout<<-1<<"\n";
	     }
	     else
	     {
	     	cout<<cnt<<"\n";
	     }
	}
}

Measured memory_bytes: 50416