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

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

string s;
map<char, int> hm;
int mn[3] = {2, 1, 0};
int ml[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
int pl[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};

typedef string::const_iterator State;
class ParseError{};

template<typename T> class Parsing
{
public:
  static void consume(State& begin, char expected) {
    if (*begin == expected) {
      begin++;
    } else {
      cerr << "Expected '" << expected << "' but got '" << *begin << "'"
           << endl;
      cerr << "Rest string is '";
      while (*begin) {
        cerr << *begin++;
      }
      cerr << "'" << endl;
      throw ParseError();
    }
  }

  static T formula(State& begin){
    T ret;
    if(*begin == '-'){
      consume(begin, '-');
      ret = mn[formula(begin)];
    }
    else if(isalpha(*begin) || isdigit(*begin)){
      ret = hm[*(begin++)];
    }
    else if(*begin == '('){
      consume(begin, '(');
      ret = formula(begin);
      if(*begin == '*'){
        consume(begin, '*');
        ret = ml[ret][formula(begin)];
      }
      else if(*begin == '+'){
        consume(begin, '+');
        ret = pl[ret][formula(begin)];
      }
      consume(begin, ')');
    }
    return ret;
  }
};

int main()
{
  rep(i, 3) hm['0' + i] = i;
  while(cin >> s, s != "."){
    int res = 0;
    rep(P, 3) rep(Q, 3) rep(R, 3){
      hm['P'] = P;
      hm['Q'] = Q;
      hm['R'] = R;
      State begin = s.begin();
      if(Parsing<int>::formula(begin) == 2) res += 1;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
// Author - Sumit 

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

#define INF 1e18L+5

using ll = long long;

const int N=405;
ll dp[N][N];

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int& x:v){
		scanf("%d",&x);
	}
	auto sum = [&](int L,int R){
		ll s=0;
		for(int i=L;i<=R;i++){
			s+=v[i];
		}
		return s;
	};
	for(int L=n-1;L>=0;--L){
		for(int R=L;R<n;++R){
			if(L==R){
				dp[L][R] = 0;
			}else{
				dp[L][R] = INF;
				for(int i=L;i<R;i++){
					dp[L][R] = min(dp[L][R],dp[L][i]+dp[i+1][R] + sum(L,R));
				}
			}
		}
	}
	printf("%lld",dp[0][n-1]);
    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    cout << n * m << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        int n,m;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer in=new StringTokenizer(br.readLine());
        n=Integer.parseInt(in.nextToken());
        m=Integer.parseInt(in.nextToken());
        Union_Find tree=new Union_Find(n);
        for(int i=0;i<m;i++){
            in=null;
            in=new StringTokenizer(br.readLine());
            int a=Integer.parseInt(in.nextToken()),b=Integer.parseInt(in.nextToken());
            tree.Union(a,b);
        }
        System.out.println(tree.get_tree(n));
    }
}
class Union_Find{
    private int[] t,s;
    public Union_Find(int max_length){
        t=new int[max_length+1];
        s=new int[max_length+1];
        for(int i=0;i<=max_length;i++){
            t[i]=i;
            s[i]=1;
        }
    }
    void Union(int x,int y){
        if (same(x, y)) return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        }
        else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        }
        else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        }
        else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }
    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }
    boolean same(int x, int y) {
        return Find(x) == Find(y);
    }
    int get_Size(int a) {
        return s[a];
    }
    int get_tree(int size){
        HashSet<Integer> st=new HashSet<>();
        for(int i=0;i<size;i++){
            st.add(Find(i+1));
        }
        return st.size();
    }
}


Measured memory_bytes: 46444
import math
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
place_list = []
ans = []

for num in h:
  place = t - num*0.006
  place_list.append(place)

for num in place_list:
  i = math.fabs(a - num)
  ans.append(i)
  
print(ans.index(min(ans)) + 1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var V1 = ReadInts();
            var V2 = ReadInts();
            Console.WriteLine(V1[0] == V2[0] ? 0 : 1);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll a[200010];
int main() {
	ll n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0,st=a[0],en=st+t;
	for(int i=1;i<n;i++){
		ll now=a[i];
		if(a[i]>en){
			ans+=en-st;
			st=a[i];
			en=st+t;
		}
		else{
			en=a[i]+t;
		}
	}
	ans+=en-st;
	cout << ans;
	// your code goes here
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        n = Integer.parseInt(sc.next());
        
        int x = n;

        int num = 0;

        while(x > 0){
            num += x % 10;
            x /= 10;
        }
        if(n % num == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        sc.close();
    }
}


Measured memory_bytes: 23764
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(input())

for i in range(n):
    u = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == u:
                bingo[j][k] = 0
b = 0

for l in range(3):
    if (bingo[l][0] == 0) and (bingo[l][1] == 0) and (bingo[l][2] == 0):
        b = 1
for m in range(3):
    if (bingo[0][m] == 0) and (bingo[1][m] == 0) and (bingo[2][m] == 0):
        b = 1
    
if (bingo[0][0] == 0) and (bingo[1][1] == 0) and (bingo[2][2] == 0):
    b = 1

if (bingo[0][2] == 0) and (bingo[1][1] == 0) and (bingo[0][2] == 0):
    b = 1
    
if b == 1:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(void){
  unsigned long long a[100001];
  int i,j,n;
  unsigned long long s=0,t=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%llu",&a[i]);

  sort(a,a+n);

  for(i=n;i>=0;i--){
    for(j=1;j<4;j++){
      if(a[i]!=a[i-j]) break;
    }
    if(j==4){
      if(s==0)s=a[i];
      t=a[i];
      break;
    }
    else if(j>=2){
      if(s==0)
        s=a[i];
      else{
        t=a[i];
        break;
      }
    }
    i-=j-1;
  }

  printf("%llu\n",s*t);

  return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;


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

	int res = n;
	rep(i, n + 1)
	{
		int cc = 0;
		int t = i;
		while ( t > 0 ) cc += t % 6, t /= 6;
		t = n - i;
		while ( t > 0 ) cc += t % 9, t /= 9;
		if ( res > cc ) res = cc;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  unsigned long long X;
  cin >> X;
  unsigned long long a = 100, i = 0;
  while(a < X){
    a+=(a/100);
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    for (int h, m, s; n; scanf("%d", &n))
    {
        vector<int> a(86401, 0);
        for (int i = 0; i < n; i++)
        {
            scanf("%d:%d:%d ", &h, &m, &s);
            a[h * 3600 + m * 60 + s]++;
            scanf("%d:%d:%d ", &h, &m, &s);
            a[h * 3600 + m * 60 + s]--;
        }
        for (int i = 1; i < 86401; i++)
        {
            a[i] += a[i - 1];
        }
        printf("%d\n", *max_element(a.begin(), a.end() - 1));
    }
}


Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
 
namespace {
	using ll = long long;
	using ull = unsigned long long;
	using ld = long double;
	constexpr auto INF = 1000000000000;
	constexpr auto EPS = 1e-9;
	constexpr auto MOD = 1000000007LL;
	constexpr auto PI = 3.1415926535897932384626433832795;
	#define FOR(i, j, k, step) for (int i=j; i<k; i+=step)
	#define RFOR(i, j, k, step) for (int i=j; i>=k; i-=step)
	#define REP(i, k) for(int i = (0); i < (k); i++ ) 
	#define RREP(i, k) for(int i = k; i >= 0; i-- )
	#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
	#define ALL(cont) cont.begin(), cont.end()
	#define RALL(cont) cont.rbegin(), cont.rend()
	#define REV(cont)  reverse(ALL(cont))
	#define SORT(cont) sort(ALL(cont))
	#define RSORT(cont) sort(RALL(cont))
	int ctoi(const char c) { return (('0' <= c && c <= '9' ? c - '0' : -1)); }
	template<typename T, typename U, typename Comp = less<>>
	static inline bool chmax(T& maxv, const U& value, Comp comp = {}) { if (comp(maxv, value)) { maxv = value; return true; } return false; }
	template<typename T, typename U, typename Comp = less<>>
	static inline bool chmin(T& minv, const U& value, Comp comp = {}) { if (comp(value, minv)) { minv = value; return true; } return false; }
	template<typename C>ll SZ(const C& c) { return static_cast<ll>(c.size()); }
	template<typename C = int>C in() { C n; cin >> n; return n; }
	template<typename T>void out(T value) { cout << value << "\n"; }
}
 
struct fast_io {
	static constexpr int IOS_PREC = 15;
	fast_io() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
	}
} fast_io;
 
using VI = vector<int>;
 
 
int fiv_to_dec(int orig, int len) {
	int ans{ 0 };
	REP(i, len) {
		int d = orig % 10;
		orig /= 10;
		ans += (int)(pow(5, i)) * d;
	}
	return ans;
}
 
string get_quin(int dec) {
	if(dec == 0) return "0";
	string ans;
	while (dec != 0) {
		auto d = div(dec, 5);
		dec = d.quot;
		ans += to_string(d.rem);
	}
	REV(ans);
	return ans;
}
 
void solve() {
	vector<bool> ls(101, true);
	int x, n; cin >> x >> n;
	while (n--) { int a; cin >> a; ls[a] = false; }
	int a = x, b = x;
	while (!ls[x]) {
		a++; b--;
		if (ls[a]) x = a;
		if (ls[b]) x = b;
	}
	cout << x;
}
 
signed main()
{
	solve();
	return 0;
}

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

const int mi[] = {1,0,-1,0};
const int mj[] = {0,1,0,-1};

int main() {
    int h,w,ch,cw,dh,dw;
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    for (int k=0; k<h ; k++) cin >> s[k];
    const int INF = 1e6;
    vector<vector<int>> dist(h,vector<int>(w,INF));
    deque<P> deq;
  	dist[ch][cw] = 0; //init
    deq.emplace_front(ch,cw); //init
    while(!deq.empty()) {
        int i0 = deq.front().first;
        int j0 = deq.front().second;
        deq.pop_front();
        int d = dist[i0][j0];
        for (int k=0; k<4 ; k++) {
            int i = i0 + mi[k], j = j0 + mj[k];
          	if (i < 0 || i >= h || j < 0 || j >= w) continue;
            if (s[i][j] == '#') continue;
            if (dist[i][j] <= d) continue;
            dist[i][j] = d;
            deq.emplace_front(i,j);
        }
        for (int l = -2; l <= 2 ; l++) {
            for (int m = -2; m <= 2 ; m++) {
                int i = i0 + l, j = j0 + m;
              	if (i < 0 || i >= h || j < 0 || j >= w) continue;
                if (s[i][j] == '#') continue;
                if (dist[i][j] <= d + 1) continue;
                dist[i][j] = d + 1;
                deq.emplace_back(i,j);
            }
        }
    }
    int ans = dist[dh][dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
const int INF = 0x3f3f3f3f ;
#define PII pair<lli,lli>
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() {
	int n,k;
	si(n);
	si(k);
	int x,ans=0;
	
	for(int i=0;i<n;i++){
	    si(x);
	    
	    ans+=2*min(x,k-x);
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  for(int i=0; i<H; i++){
    cin >> a.at(i);
  }
  string edge = "";
  for(int i=0; i<W+2; i++){
    edge += '#';
  }
  cout << edge << endl;
  for(int i=0; i<H; i++){
    cout << '#' + a.at(i) + '#' << endl;
  }
  cout << edge << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var nk = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = nk[0];
        var K = nk[1];
        var ans = 0L;
        //余り0
        var count = N / K;
        ans += (long)Math.Pow(count,3);
        //余り1/2
        if (K % 2 == 0)
        {
            count = (N + (K / 2)) / K;
            ans += (long)Math.Pow(count,3);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
ans = ''
while(dp[n][m]>0):
  if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1:
    ans = ''.join([s[n-1],ans])
    n -= 1
    m -= 1
  elif dp[n-1][m] > dp[n][m-1]:
    n -= 1
  else:
    m -= 1
print(ans)

Measured memory_bytes: 119772
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> adjlist[n];
    for (int i = 1; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        --a, --b;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    int dist[n]; memset(dist,-1,sizeof(dist));
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while (q.size()){
        int u = q.front(); q.pop();
        for (auto v : adjlist[u]){
            if (dist[v] == -1){
                dist[v] = dist[u]+1;
                q.push(v);
            }
        }
    }
    int s = 0;
    for (int i = 0; i < n; i++){
        if (dist[i] > dist[s]) s = i;
    }
    memset(dist,-1,sizeof(dist));
    q.push(s);
    dist[s] = 0;
    while (q.size()){
        int u = q.front(); q.pop();
        for (auto v : adjlist[u]){
            if (dist[v] == -1){
                dist[v] = dist[u]+1;
                q.push(v);
            }
        }
    }
    int diameter = 0;
    for (int i = 0; i < n; i++){
        diameter = max(diameter,dist[i]);
    }
    //printf("%d",diameter);
    if (diameter%3 == 1){
        printf("Second");
    }
    else printf("First");

}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

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

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if( a >= b  || c >= d){
        if( a >= b  && c >= d) {cout << b + d << endl;}
        else if(  a >= b && c < d){ cout << b + c << endl;}
        else if( a < b &&c >= d){cout << a + d << endl;}
    }
    else{
        cout << a + c << endl;
    }

    return 0;
}


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

using namespace std;

int main(){

    int W,a,b;

    cin >> W >> a >> b;

    if(a < b){

    }else{
       int c = b;
       b = a;
       a = c;
    }

    if(a + W < b){
    	cout << b - (a + W);
    }else{
    	cout << 0;
    }

}


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

int main(){
int A,B;
cin >> A >> B;
if(A==1&&B==3){
    cout << 2 << endl;
}else if(A==1&&B==2){
    cout << 3 << endl;
}else if(A==2&&B==1){
    cout << 3 << endl;
}else if(A==2&&B==3){
    cout << 1 << endl;
}else if(A==3&&B==1){
    cout << 2 << endl;
}else{
    cout << 1 << endl;
}
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	char S[7];
	scanf("%s", &S);
	if (S[2] == S[3] && S[4] == S[5]){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<string> S(N);
    REP(i,N) cin>>S[i];
    map<string,int> mp;
    vector<string> ans;
    int MAX=0;
    REP(i,N){
        mp[S[i]]++;
        if(mp[S[i]]>MAX){
            ans.clear();
            MAX=mp[S[i]];
            ans.push_back(S[i]);
        }
        else if(mp[S[i]]==MAX){
            ans.push_back(S[i]);
        }
    }
    sort(All(ans));
    for(auto s:ans) cout<<s<<endl;
}

Measured memory_bytes: 28272
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll A;
double b;

int main(){
    cin>>A>>b;
    ll B=b*100+0.1;

    ll ans=A*B/100;

    cout<<ans<<endl;
}

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

using namespace std;

int main(void){
   vector<long long> num(3);
   for (int i = 0; i < 3; i++) cin >> num[i];
   
   for (int i = 0; i < 3; i++){
       if (num[i] % 2 == 0){
           cout << 0 << endl;
           return 0;
       }
   }
   
   sort(num.begin(),num.end());
   cout << num[0] * num[1] << endl;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
const int MAX = 500000;

int L[MAX], R[MAX], A[MAX], n;
int num = 0;

void merge(int left, int mid, int right) 
{
	int n1 = mid - left;
	int n2 = right - mid - 1;

	for (int i = 0; i <= n1; i++)
		L[i] = A[left + i];
	for (int i = 0; i <= n2; i++)
		R[i] = A[mid + 1 + i];

	L[n1 + 1] = R[n2 + 1] = (int)2e9;

	int i = 0, j = 0;
	for (int k = left; k <= right; k++)
	{
		num++;
		if (L[i] <= R[j])
			A[k] = L[i++];
		else
			A[k] = R[j++];
	}
}

void MergeSort(int left, int right) 
{
	if (left < right) 
	{
		int mid = (left + right) / 2;
		MergeSort(left, mid);
		MergeSort(mid + 1, right);
		merge(left, mid, right);
	}
}

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

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

	MergeSort(0, n - 1);

	for (int i = 0; i < n - 1; i++)
		cout << A[i] << " ";
	cout << A[n - 1] << endl;

	cout << num << endl;
	return 0;
}


Measured memory_bytes: 7024
l_raw = input().split()
l = [int(n) for n in l_raw]
a_raw = input().split()
a_ = [int(n) for n in a_raw]

study = 0
state = 0
now=0

for a in a_:
    if state==0:
        if l[1]<a-now:
            study+=a-now-l[1]
        now=a
        state=1
    elif state==1:
        if 2*l[1]<a-now:
            study+=a-now-2*l[1]
        now=a

if l[2]-l[1]-a>0:
    study+=l[2]-l[1]-a
    
print(study)


Measured memory_bytes: 5604
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
  string S,T;
  cin >> S;
  REP(i,(S.size())){
    if(S[i]=='b'&&S[S.size()-1-i]!='d'){
      cout << "No" << endl;
      return 0;
    }
    if(S[i]=='d'&&S[S.size()-1-i]!='b'){
      cout << "No" << endl;
      return 0;
    }
    if(S[i]=='p'&&S[S.size()-1-i]!='q'){
      cout << "No" << endl;
      return 0;
    }
    if(S[i]=='q'&&S[S.size()-1-i]!='p'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout <<"Yes" << endl;
  return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl;
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

//文字列分割
VS split(string str, char del) {
	VS re;
	string sub;
	for (char c : str) {
		if (c == del) {
			re.pb(sub);
			sub.clear();
		}
		else {
			sub += c;
		}
	}
	re.pb(sub);
	return re;
}

int main() {
	string line;
	while (getline(cin, line)) {
		VS s = split(line, ' ');

		stack<double> st;

		for (auto t : s) {

			if (!isdigit(t[0]) && t.size() == 1) {
				double x = st.top(); st.pop();
				double y = st.top(); st.pop();

				double ans;
				switch (t[0]) {
				case '+':
					ans = y + x;
					break;
				case '-':
					ans = y - x;
					break;
				case '*':
					ans = y * x;
					break;
				case '/':
					ans = y / x;
					break;
				}

				st.push(ans);
				//cout << x << ", " << y << " = " << ans << endl;
			}
			else {
				int x = stoi(t);
				st.push((double)x);
			}

		}

		printf("%.20f\n", st.top());
	}
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

vector<int> to[100010];
vector<bool> und(1000010,0);
int now;

void dfs(int x){
    for(auto u : to[x]){
        if(und[u]==0){
            now++;
            und[u]=1;
            dfs(u);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int x;
        int y;
        int dumy;
        cin >> x >> y>>dumy;
        x--;y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    int ans = 0;
    while(1){
        rep(i,n){
            if(und[i]==0){
                ans++;
                und[i]=1;
                dfs(i);
            }
        }
        bool ok = 1;
        rep(i,n){
            if(und[i]==0) ok = 0;
        }
        if(ok) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8960
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		for(i=-1500ll;i<=1500ll;i++)
		{
			m=n+(i*i*i*i*i);
			for(j=-1500ll;j<=1500ll;j++)
			{
				if(j*j*j*j*j==m)
				{
					cout<<j<<" "<<i;
					cout<<"\n";
					return 0;
				}
			}
		}
		
	}
	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, m;
	ll ans;

	cin >> n >> m;

	vector<ll> v(m, 0);

	REP(i, m) {
		cin >> v[i];
	}

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

	if (n < m) {
		vector<ll> vv(m - 1, 0);
		REP(i, m - 1) {
			vv[i] = v[i + 1] - v[i];
		}
		sort(vv.begin(), vv.end(), greater<ll>());
		ans = v[m - 1] - v[0];
		REP(i, n - 1) {
			ans -= vv[i];
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    int n = x-1;
    int b[n];
    int i;
    for(i=0;i<n;i++)
      cin>>b[i];
    long long int sum=b[0]+b[n-1];
    for(i=0;i<n-1;i++){
        sum+=min(b[i],b[i+1]);
    }
    cout<<sum<<endl;
}

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

using namespace std;
int mod =1000000007;
#define fr first 
#define sc second 

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<pair<long long,long long> > adj[n+1] ={};
    long long dp[n+1]={};
    int seen[n+1]={};
    int t,k;
    for(int i=1;i<n;i++)
    {
    	long long x,y,w;
    	cin>>x>>y>>w;
    	adj[x].push_back({y,w});
    	adj[y].push_back({x,w});
    }
    
    cin>>t>>k;
    queue<long long> q;
    q.push(k);
    dp[k]=0;
    while(!q.empty())
    {
    	int s =q.front();q.pop();
    	for(auto u:adj[s])
    	{
    		if(seen[u.fr]) continue;
    		seen[u.fr]=1;
    		q.push(u.fr);
    		dp[u.fr] = dp[s] +u.sc;
    	}
    }

    while(t--)
    {
    	int a,b;
    	cin>>a>>b;
    	cout<<dp[a] +dp[b]<<endl;
    }
}

Measured memory_bytes: 10368
N = int(input())
As = list(map(int, input().split()))

sumA = sum(As)
num = N * (N + 1) // 2
if sumA % num:
    print('NO')
else:
    M = sumA // num
    sumK = 0
    for i in range(N):
        k = (M - (As[i] - As[i - 1])) / N
        if k < 0:
            print('NO')
            break
        sumK += k
    else:
        if sumK == M:
            print('YES')
        else:
            print('NO')


Measured memory_bytes: 14260
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 1 / (4 * M)
A = sorted(A, reverse=True)
ans1 = 0
for i in range(M):
    if A[i]/sum(A) >= ans:
        ans1 += 1
if ans1 == M:
    print('Yes')
else:
    print('No')


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

int n, ans;
int a[210];

int main() {

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

	cin >> n;

	for(int i = 0; i < 2 * n; i++) {
		cin >> a[i];
	}

	sort(a, a + 2 * n);

	for(int i = 0; i < 2 * n; i += 2) {
		ans += a[i];
	}

	cout << ans << '\n';
	
	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, double> pdd;
typedef pair<ll, pii> key;

ll facs[1005];
ll ifacs[1005];
const int MOD = 1000000007;

ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}

ll solve(int sz, int num) {
  ll ret = facs[sz*num];
  for(int i = 0; i < num; i++) {
    ret *= ifacs[sz];
    ret %= MOD;
  }
  ret *= ifacs[num];
  ret %= MOD;
  // cout << num << " groups of size " << sz << " is " << ret << endl;
  return ret;
}

ll dp[1005];
ll ndp[1005];

void solve() {
  facs[0] = 1;
  for(int i = 1; i <= 1000; i++) {
    facs[i] = facs[i-1] * i;
    facs[i] %= MOD;
  }
  ifacs[1000] = modpow(facs[1000], MOD-2, MOD);
  for(int i = 999; i >= 0; i--) {
    ifacs[i] = ifacs[i+1] * (i+1);
    ifacs[i] %= MOD;
  }
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  dp[0] = 1;
  for(int x = a; x <= b; x++) {
    memset(ndp, 0, sizeof(ndp));
    for(int y = c; y <= d; y++) {
      for(int i = 0; i + x*y <= n; i++) {
        if(dp[i] == 0) continue;
        ll scale = facs[i+x*y];
        scale *= ifacs[x*y];
        scale %= MOD;
        scale *= ifacs[i];
        scale %= MOD;
        scale *= solve(x, y);
        scale %= MOD;
        ndp[i+x*y] += dp[i] * scale;
        ndp[i+x*y] %= MOD;
      }
    }
    for(int i = 0; i <= n; i++) {
      dp[i] += ndp[i];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
// TEMP:
package main

import (
  "fmt"
  // "os"
)

var S string

func main(){
  // var S string
  fmt.Scan(&S)
  var ans = true
  for i := 0; i < 3; i++ {
    if S[i] == S[i+1] {
      ans = false
      break
    }
  }

  if ans {
    fmt.Println("Good")
  }else{
    fmt.Println("Bad")
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int n;
int a[maxn];
int b[maxn];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int p,q;
        cin>>p>>q;
        a[i]=p+q;
        b[i]=p-q;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    printf("%d\n",max(a[n]-a[1],b[n]-b[1]));
    return 0;
}


Measured memory_bytes: 5268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main (){
	int x, y;

	std::cin >> x >> y;

	int count = 0;

	if (x == 1) {
		count += 300000;
	}

	if (x == 2) {
		count += 200000;
	}

	if (x == 3) {
		count += 100000;
	}

	if (y == 1) {
		count += 300000;
	}

	if (y == 2) {
		count += 200000;
	}

	if (y == 3) {
		count += 100000;
	}


	if (x == 1 && y == 1) {
		count += 400000;
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
struct node {
    int a, b;
    bool operator < (const node &B)const{
        return b < B.b;
    }
}A[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i].a >> A[i].b;
    sort(A + 1, A + n + 1);
    int r = 0, ok = 1;
    for(int i = 1; i <= n; i++) {
        r += A[i].a;
        if(r > A[i].b) ok = 0;
    }
    if(ok) cout << "Yes" ;
    else cout << "No";
    return 0;
}


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

template<typename OperatorMonoid>
struct SegmentTree {
    using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
    const H h;
    const OperatorMonoid OM0;
    int sz, height;
    vector<OperatorMonoid> lazy;
    SegmentTree(int n, const H h, const OperatorMonoid &OM0)
        : h(h), OM0(OM0), sz(1), height(0)
    {
        while (sz < n) sz <<= 1, height++;
        lazy.assign(sz * 2, OM0);
    }
    inline void propagate(int k) {
        if (lazy[k] == OM0) return ;
        lazy[k << 1 | 0] = h(lazy[k << 1 | 0], lazy[k]);
        lazy[k << 1 | 1] = h(lazy[k << 1 | 1], lazy[k]);
        lazy[k] = OM0;
    }
    inline void thrust(int k) {
        for (int i = height; i > 0; i--) propagate(k >> i);
    }
    void update(int a, int b, const OperatorMonoid &x) {
        thrust(a += sz);
        thrust(b += sz - 1);
        for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lazy[l] = h(lazy[l], x), ++l;
            if (r & 1) --r, lazy[r] = h(lazy[r], x);
        }
    }
    void set(int k, const OperatorMonoid &x) { thrust(k += sz); lazy[k] = x; }
    OperatorMonoid get(int k) { thrust(k += sz); return lazy[k]; }
    OperatorMonoid operator[](const int &k) { return get(k); }
};

const int INF = numeric_limits<int>::max();
int main() {
    int n, q; cin >> n >> q;
    SegmentTree<int> seg(n, [](int a, int b) { return b; }, INF);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int s, t, x; cin >> s >> t >> x; t++;
            seg.update(s, t, x);
        } else {
            int i; cin >> i;
            cout << seg[i] << endl;
        }
    }
    return 0;
}


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

using namespace std ; 

const int N = 1e5 + 7 ; 


int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0); 
   // freopen("in.in" ,"r" , stdin) ; 
    int a , b , c, d ; 
    cin>>a>>b>>c>>d ; 
    int trn =0 ; 
    while(a >0 && c >0){
        if(trn){
            a-=d ; 
        }
        else{
            c-=b ; 
        }
        trn = 1 - trn ; 
    }
    if(trn)cout<<"Yes" ; 
    else cout<<"No" ; 
    return 0 ; 
}

Measured memory_bytes: 3652
main :: IO ()
main = do
  n <- readLn
  solve n 0.0

solve :: Int -> Double -> IO ()
solve 0 m = print m
solve n m = do
  [x, u] <- words <$> getLine
  case u of
    "JPY" -> solve (n - 1) (m + toDbl x)
    "BTC" -> solve (n - 1) (m + 380000.0 * toDbl x)
  where
    toDbl :: String -> Double
    toDbl s = read s :: Double


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 35;
int n,m;
int mp[N][N];
int main(){
    cin>>n>>m;
    int ans=  0;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        for(int j=1,l;j<=k;j++){
            scanf("%d",&l);
            mp[i][l]=1;
        }
    }
    for(int j=1;j<=m;j++){
        int f=1;
        for(int i=1;i<=n;i++) if(!mp[i][j]) f=0;
        if(f) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::cout << (N-2)*180 << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    ll n; cin>>n;
    ll g[3][2];
    for(ll i=0; i<2; i++){
        for(ll j=0; j<3; j++) cin>>g[j][i];
    }
    vector<ll> b, a;
    for(ll i=0; i<3; i++){
        if(g[i][0]<g[i][1]) b.push_back(i);
        else if(g[i][0]>g[i][1]) a.push_back(i);
    }
    if(b.size()==1){
        n+=n/g[b[0]][0]*(g[b[0]][1]-g[b[0]][0]);
    }else if(b.size()==2){
        ll mx=0;
        for(ll t=0; t<=n; t++){
            if(g[b[0]][0]*t>n) break;
            ll u=(n-g[b[0]][0]*t)/g[b[1]][0];
            mx=max(t*(g[b[0]][1]-g[b[0]][0])+u*(g[b[1]][1]-g[b[1]][0]), mx);
        }
        n+=mx;
    }else if(b.size()==3){
        ll mx=0;
        for(ll t=0; t<=n; t++){
            if(g[0][0]*t>n) break;
            for(ll u=0; u<=n; u++){
                if(g[0][0]*t+g[1][0]*u>n) break;
                ll v=(n-(g[0][0]*t+g[1][0]*u))/g[2][0];
                mx=max(t*(g[0][1]-g[0][0])+u*(g[1][1]-g[1][0])+v*(g[2][1]-g[2][0]), mx);
            }
        }
        n+=mx;
    }

    if(a.size()==1){
        n+=n/g[a[0]][1]*(g[a[0]][0]-g[a[0]][1]);
    }else if(a.size()==2){
        ll mx=0;
        for(ll t=0; t<=n; t++){
            if(g[a[0]][1]*t>n) break;
            ll u=(n-g[a[0]][1]*t)/g[a[1]][1];
            mx=max(t*(g[a[0]][0]-g[a[0]][1])+u*(g[a[1]][0]-g[a[1]][1]), mx);
        }
        n+=mx;
    }else if(a.size()==3){
        ll mx=0;
        for(ll t=0; t<=n; t++){
            if(g[0][1]*t>n) break;
            for(ll u=0; u<=n; u++){
                if(g[0][1]*t+g[1][1]*u>n) break;
                ll v=(n-(g[0][1]*t+g[1][1]*u))/g[2][1];
                mx=max(t*(g[0][0]-g[0][1])+u*(g[1][0]-g[1][1])+v*(g[2][0]-g[2][1]), mx);
            }
        }
        n+=mx;
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
if 100 <= N <= 111:
    ans = 111
elif 112 <= N <= 222:
    ans = 222
elif 223 <= N <= 333:
    ans = 333
elif 334 <= N <= 444:
    ans = 444
elif 445 <= N <= 555:
    ans = 555
elif 556 <= N <= 666:
    ans = 666
elif 667 <= N <= 777:
    ans = 777
elif 778 <= N <= 888:
    ans = 888
elif 889 <= N <= 999:
    ans = 999
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}

void solve()
{
  ll h,w;
  cin>>h>>w;
  vector<string> a(h);
  vvl dp(h+1, vl(w+1,0));
  loop(i,0,h) cin>>a[i];
  dp[1][1]=1;
  loop(i,1,h+1)
  {
  	loop(j,1,w+1)
  	{
  		if(a[i-1][j-1]=='.')
  		 dp[i][j] = max(dp[i][j], dp[i-1][j]+dp[i][j-1])%mod;
  		else 
  		  dp[i][j]=0;
	}
  }
  cout<<dp[h][w];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 10752
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define INT_MAX std::numeric_limits<int>().max()
#define INT_MIN std::numeric_limits<int>().min()
#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())

#define MAX_M   2010
#define MAX_N   1010
#define INF     std::numeric_limits<ll>().max()

// 頂点from から頂点 to へのコスト cost の辺
struct edge { int from, to, cost; };
int N, M;
edge es[MAX_M];
ll d[MAX_N];
int V, E;

bool updated[MAX_N];

int main()
{
    cin >> N >> M;
    V = N; E = M;
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = -c;
    }

    REP(i, V+1) { d[i] = INF; }

    // 1 番目の頂点から各頂点への最短距離を求める
    d[1] = 0;
    REP(j, V+1) {
        bool update = false;
        REP(i, E) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update){ break; }
    }

    ll ans = -d[N];

    // 本来これ以上更新されないはずだが、更新されるなら閉路あり
    REP(i, V+1) {
        updated[i] = false;
    }
    REP(j, V+2) {
        REP(i, E) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                updated[e.to] = true;
            }
        }
    }

    if(updated[N]){ printf("inf\n"); }
    else { printf("%lld\n", ans); }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
    char a[50],b[50],c[100],m,k,i,s;
    scanf("%s",a);
    scanf("%s",b);
    k=strlen(a);
    m=strlen(b);
    s = k > m ? k : m;
    printf("%c%c",a[0],b[0]);
    for(i=1;i<=s;i++)
    {
        c[2*i-1]=a[i];
        c[2*i]=b[i];
    }
    if(k>m)
    {
        for(i=1;i<=2*(k-1)-1;i++)
           printf("%c",c[i]);
    }
    else
    {
        for(i=1;i<=2*(s-1);i++)
           printf("%c",c[i]);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);


//入力変数
int N=sc.nextInt();
int[] t=new int[N+1];
int[] x=new int[N+1];
int[] y=new int[N+1];
t[0]=0;
x[0]=0;
y[0]=0;
for(int i=1;i<=N;i++){
    t[i]=sc.nextInt();
    x[i]=sc.nextInt();
    y[i]=sc.nextInt();
}

//入力値変換


//出力変数
String ans="Yes";

//計算
for(int i=0;i<N;i++){
    if(t[i+1]-t[i]<Math.abs(x[i]-x[i+1])+Math.abs(y[i]-y[i+1])){
        ans="No";
    }
    if((t[i]+t[i+1]+x[i]+y[i]-x[i+1]-y[i+1])%2!=0){
        ans="No";
    }
}
//出力
System.out.println(ans);

}}

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

int main() {
	int a,b,c,d,n=0,m=0;

	cin >> a >> b >> c >> d;

	if (a >= b)
		n = b;
	else
		n = a;

	if (c >= d)
		m = d;
	else
		m = c;

	cout << n + m;

	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
array = [list(map(int,input().split())) for i in range(b)]
count = [0]*a
for i in range(a):
    for j in range(b):
        if i+1 in array[j]:
            count[i] += 1
for i in range(a):
    print(count[i])

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

int main() {
  char b;cin>>b;

  vector<char> v1 = {'A', 'C'};
  vector<char> v2 = {'T', 'G'};

  for (int i = 0; i <=1; ++i) {
    if (b==v1[i]) cout << v2[i] << endl;
    if (b==v2[i]) cout << v1[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// /*
// power code taken from geeks for geeks
// */

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str{
    ll x, y;
};


void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}
ll gcd(ll a, ll b){
    if(b==0){
        return a;
    }
    return gcd(b, a%b);
}

void solve(){
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll n=a+b+c;
    if(k<=a){
        cout<<k<<endl;
        return;
    }
    else if(k<=b){
        cout<<a<<endl;
        return;
    }
    ll t=k-(a+b);

    // cout<<"t "<<t<<endl;
    
    t=a-t;
    cout<<t<<endl;
    
}


int main(){




    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t=1;

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


Measured memory_bytes: 3644