akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

t,x,y = 0,0,0
ans = 'Yes'
for t1,x1,y1 in A:
    dt,dx,dy = t1-t, abs(x1-x), abs(y1-y)
    if dt>=dx+dy:
        if (dt%2==0)&((dx+dy)%2==0):
            pass
        elif (dt%2==1)&((dx+dy)%2==1):
            pass
        else:
            ans = 'No'
            break
    else:
        ans = 'No'
        break
    t,x,y = t1,x1,y1
print(ans)

Measured memory_bytes: 60408
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {
	 
	long N; cin >> N;
	long A[10000]; for (int i = 1; i <= N; i++) cin >> A[i];
	long res = 0;

	sort(A + 1, A + N + 1);

	res = abs(A[1] - A[N]);

	cout << res << endl;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  int m = 0, a;
  ll sum = 0;
  loop(n) {
    cin >> a;
    sum += max(0, m - a);
    m = max(m, a);
  }
  cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3604
from operator import mul
from functools import reduce
import collections

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    N = int(input())
    A = list(map(lambda x:x-1 ,map(int, input().split())))

    coll = collections.Counter(A[1:])
    counter = [0]*N
    comb = [0]*N
    sum1 = 0
    for i in range(N):
        c=coll.get(i,0)
        counter[i] = c
        if c>1:
            comb[i] = combinations_count(c,2)
            sum1 += comb[i]
    print(sum1)

    for i in range(1,N):
        # ボールA[i-1]を復活させて、ボールA[i]を除外
        n = counter[A[i-1]]
        if n>=1:
            sum1 += n
        counter[A[i-1]] += 1
        n = counter[A[i]]
        if n>=2:
            sum1 -= n-1
        counter[A[i]] -= 1
        print(sum1)

main()


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int p=k;p<=n;p++) {
        ans = (ans+p*(n-p+1)+1)%mod;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T):
    count = 0
    for x, y in zip(S, T):
        if x != y:
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
typedef long long ll;
const int MAXN = -1;

ll Q, H, S, D, N;

int main() {
  scanf("%lld %lld %lld %lld %lld", &Q, &H, &S, &D, &N);
  
  if(H > Q*2) H = Q*2;
  if(S > H*2) S = H*2;
  if(D > S*2) D = S*2;
  
  Q *= 4;
  H *= 4;
  S *= 4;
  D *= 4;
  
  N *= 4;
  
  ll d1 = N / 8; N %= 8;
  ll s1 = N / 4; N %= 4;
  ll h1 = N / 2; N %= 2;
  ll q1 = N;
  
  //~ printf("%lld %lld %lld %lld\n", Q/4, H/4, S/4, D/4);
  //~ printf("%lld %lld %lld %lld\n", q1, h1, s1, d1);
  
  printf("%lld\n", (d1*D + s1*S + h1*H + q1*Q) / 4);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m;
  cin >> n >> m;
  vecint a(n);
  for (auto& e : a) cin >> e;
  sort(all(a));
  vector<pair<int, int>> b(m);
  for (auto& e : b) {
    cin >> e.second >> e.first;
  }
  sort(all(b), greater<pair<int, int>>());
  // for (auto& e : a) cout << setw(4) << e;
  // cout << endl;
  int r = 0;
  REP(i, m) {
    // cout << "r = " << r << endl;
    if(a[r] >= b[i].first)break;
    for (int j = 0; j < b[i].second; j++) {
      if (r + j >= n || a[r + j] >= b[i].first) break;
      a[r + j] = b[i].first;
    }
    r += b[i].second;
    if (r >= n) break;
  }
  ll ans = 0;
  // sort(all(a));
  // for (auto& e : a) cout << setw(4) << e;
  // cout << endl;
  REP(i, n) {
    // cout << a[i] << endl;
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	cout << "2018";
	rep(i, 10) {
		if (i >= 4) {
			cout << S[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int i = 1;
		while (X >= i * Y + (i + 1) * Z) {
			i++;
		}
		System.out.println(i - 1);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

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

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

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

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

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

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

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


Measured memory_bytes: 21332
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

signed main() {
	int a, b, c, x[100000], z = 1;
	cin >> a >> b >> c;
	f(i, a) cin >> x[i];
	sort(x, x + a);
	P p = {x[0],0};
	f(i, a) {
		if (i >= p.second + b || x[i] > p.first + c) {
			z++;
			p = { x[i],i };
		}
	}
	cout << z << endl;
	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int h,w;cin>>h>>w;
  vector<vector<int>> a(h,vector<int>(w));
  int i,j;
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<vector<bool>> mov(h,vector<bool>(w));
  int nowi=0;
  int nowj=0;
  while(nowi<h&&nowj<w)
  {
    int nexi;
    int nexj;
    if(nowi%2==0)
    {
      if(nowj==w-1)
      {
        nexi=nowi+1;
        nexj=nowj;
      }
      else
      {
        nexi=nowi;
        nexj=nowj+1;
      }
    }
    else
    {
      if(nowj==0)
      {
        nexi=nowi+1;
        nexj=nowj;
      }
      else
      {
        nexi=nowi;
        nexj=nowj-1;
      }
    }
    if(nexi>=h)break;
    if(a[nowi][nowj]%2!=0)
    {
      mov[nowi][nowj]=true;
      a[nowi][nowj]--;
      a[nexi][nexj]++;
    }
    nowi=nexi;
    nowj=nexj;
  }
  int count=0;
  rep(i,h)rep(j,w)if(mov[i][j])count++;
  cout<<count<<endl;
  nowi=0;
  nowj=0;
  while(nowi<h&&nowj<w)
  {
    int nexi;
    int nexj;
    if(nowi%2==0)
    {
      if(nowj==w-1)
      {
        nexi=nowi+1;
        nexj=nowj;
      }
      else
      {
        nexi=nowi;
        nexj=nowj+1;
      }
    }
    else
    {
      if(nowj==0)
      {
        nexi=nowi+1;
        nexj=nowj;
      }
      else
      {
        nexi=nowi;
        nexj=nowj-1;
      }
    }
    if(nexi>=h)break;
    if(mov[nowi][nowj])cout<<nowi+1<<' '<<nowj+1<<' '<<nexi+1<<' '<<nexj+1<<endl;
    nowi=nexi;
    nowj=nexj;
  }
}


Measured memory_bytes: 3200
// --------------
// Tejas Pandey  |
// 11 - 07 - 20  |
// AIsing ABC    |
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll l,r,d;
  cin >> l >> r >> d;
  ll ans = r/d - l/d + (!(l%d));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


int counter(int x){
    if(x==0) return 0;
    return counter(x >> 1) + (x & 1);
}

ll nC2(ll n){
    if(n<2) return 0;
    return n*(n-1)/2;
}


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    map<string,ll> anag;
    rep(i,n){
        string s; cin >> s;
        sort(ALL(s));
        if(anag.count(s)){
            anag[s]++;
        }else{
            anag.emplace(s,1);
        }
    }
    
    ll ans = 0;
    for (auto itr = anag.begin(); itr != anag.end(); itr++){
        ans += nC2(itr->second);
    }
        
    cout << ans << endl;
 
}



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



Measured memory_bytes: 11264
using System;
using System.Linq;

namespace AtCoderContestScheduling
{
    class Program
    {
        static void Main(string[] args)
        {
            const int n_contest = 26;
            int D = GetInt();
            var c = GetIntArray();
            var s = new int[D][];
            for(int i = 0; i < D; i++)
            {
                s[i] = GetIntArray();
            }

            var decrement = new int[n_contest];
            int max_eval = int.MinValue;
            int[] contest = new int[D];
            //int score = 0;
            for(int i = 0; i < D; i++)
            {
                for (int j = 0; j < n_contest; j++)
                {
                    decrement[j] += c[j];
                    if (max_eval < decrement[j] + s[i][j])
                    {
                        max_eval = decrement[j] + s[i][j];
                        contest[i] = j;
                        decrement[j] = 0;
                    }
                }
                
            }
            //Console.WriteLine(score);
            foreach (var item in contest)
            {
                Console.WriteLine(item + 1);
            }

        }
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 28916
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int first, second, tgt;

	cin >> first >> second;

	tgt = first * second;
	if(tgt % 2 == 0){
		cout << "Even" << endl;
	}else{
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();

			if ((H == 0) && (W == 0)) {
				break;
			} 
			else {

				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {

						if ((0 < i && i < H - 1) && (0 < j && j < W - 1)) {
							System.out.print(".");
						} 
						else {
							System.out.print("#");
						}
						
					}
					System.out.println();
				}
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 34352
#include<iostream>
#include<vector>
#include<cstdint>
#include<algorithm>

template<class T>
void chmax(T &l, const T &r) {
  l = std::max(l, r);
}

int main() {
  using i64 = std::int_fast64_t;

  int n;
  std::cin >> n;
  std::vector<i64> s(n);
  for (auto &e : s) std::cin >> e;
  n -= 1;

  i64 ans = 0;
  
  for (int d = 1; d != n; d += 1) {
    i64 pre = 0;
    i64 suf = 0;
    for (int i = 0;; i += 1) {
      if (i * d > n || n - i * d <= d) break;
      if (n % d == 0 && i * d >= n - i * d) break;
      pre += s[i * d];
      suf += s[n - i * d];
      chmax(ans, pre + suf);
    }
  }

  std::cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n,count=1;
  cin >> n;
  long long int a[n];
  int zouka=0;
  cin >> a[0];
  cin >> a[1];
  if (a[1]>a[0])zouka=1;
  if (a[1]<a[0])zouka=-1; 
  for (int i=2;i<n;i++){
    cin >> a[i];
    if (a[i]>a[i-1]){
      if (zouka==0)zouka=1;
      if (zouka==-1)count++,zouka=0;
    }
    if (a[i]<a[i-1]){
      if (zouka==0)zouka=-1;
      if (zouka==1)count++,zouka=0;
    }
   }
   cout << count <<endl; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int N;
int a[200000];
int b[200000];

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  rep(i, N) {
    b[i] = a[i];
  }
  sort(b, b + N);
  int m = b[N-1];
  int key;
  key = lower_bound(b, b+N, m)- b;
  int m2;
  if(key != N-1) m2 = m;
  else m2 = b[key-1];

  rep(i, N) {
    if(a[i] != m) cout << m << endl;
    else cout << m2 << endl;
  }



  return 0;
}

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

const int N = 1e5 + 5;
vector< pair< int, int> > conn[N];

int dist[N];
bool seen[N];

int main() {
    int a, b;
    cin >> a >> b;
    if((a * b) & 1) puts("Odd");
    else puts("Even");
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        
        
        int[] a = new int[200];
        
        while(sc.hasNext()){ 
            
        String as = sc.nextLine();
        String s = as.toLowerCase();
        
        for(int i=0;i<s.length();i++){
        	char ch = s.charAt(i);
            a[ch]+=1;
       	 }
        }
        char d=97;
        for(int j=97;j<123;j++){
            
            System.out.print(d+" : ");
            System.out.println(a[j]);
            d++;
        }
    }
}


Measured memory_bytes: 26116
N, M, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))

if max(xlist) < min(ylist):
    check = 0
    for z in range(max(xlist)+1, min(ylist)+1):
        if z > X and z <= Y:
            check = 1
            break
    if check == 1:
        print('No War')
    else:
        print('War')

else:
    print('War')


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] NK=cin.ArrayInt(2,0);
        int N=NK[0];
        int K=NK[1];
        double ans=0;
        for(int i=1;i<=N;i++)
        {
            int x=i;
            int count=0;
            for(int j=1;j<20;j++)
            {
                if(x<K)count++;
                else break;
                x*=2;
            }
            count*=(-1); 
           // Console.WriteLine(Math.Pow(2,count));
            ans+=Math.Pow(2,count);
        }
        Console.WriteLine(ans/N);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
        return b;        
    }
}


Measured memory_bytes: 11092
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B,K;
    cin>>A>>B>>K;

    for(int i=A;i<=min(B,A+K-1);i++){
        cout<<i<<endl;
    }
    for(int i=max(B-K+1,A+K);i<=B;i++){
        cout<<i<<endl;
    }


}




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

using namespace std;
int main()
{
int n;
cin>>n;
int k;
cin>>k;
vector<int>a(n);
for(int i=0;i<n;i++)
{
    cin>>a[i];
}

vector<int>dp(k+1);
for(int i=0;i<a[0];i++)
{
    dp[i]=2;
}
dp[a[0]]=1;
for(int i=a[0]+1;i<=k;i++)
{
    int ans=2;
    for(int j=0;j<=n-1;j++)
    {
      
        if(i-a[j]>=0)
        {
            if(dp[i-a[j]]==2)
            {
                ans=1;
                break;
            }
        }
        else
        {
            break;
        }
        
    }
    dp[i]=ans;
}
if(dp[k]==1)
    cout<<"First";
else
{
    cout<<"Second";
}

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define fast ios_base::sync_with_stdio(false)
#define cintie cin.tie(NULL)
int main()
{
	ll n,i,x;
   cin>>n;
   vvi v(200010);
   for(i=2;i<=n;i++)
   {
   	  cin>>x;
   	  v[i].pb(x);
   	  v[x].pb(i);
   }
   for(i=1;i<=n;i++)
   {
   	  if(i==1)
   	  cout<<v[i].size()<<endl;
   	  else
   	  {
   	  	cout<<v[i].size()-1<<endl;
		 }
   }
}


Measured memory_bytes: 16288
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = sc.nextInt();
		int a = sc.nextInt() - 1;
		int b = sc.nextInt() - 1;
		int c = sc.nextInt() - 1;
		int d = sc.nextInt() - 1;
		String str = sc.next();
		boolean ok = true;
		ok &= str.substring(a, c + 1).indexOf("##") == -1;
		ok &= str.substring(b, d + 1).indexOf("##") == -1;
		if(c > d) {
			ok &= str.substring(Math.max(0, b - 1), Math.min(len, d + 2)).indexOf("...") != -1;
		}
		System.out.println(ok ? "Yes" : "No");
	}
}

Measured memory_bytes: 26812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * What is the Most Popular Shop in Tokaichi?
 */
public class Main {

	static char[] names = { 'A', 'B', 'C', 'D', 'E' };

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

		short[] sales = null;
		short sale, idx, max;
		while (!(line = br.readLine()).equals("0 0")) {
			sales = new short[5];
			
			sale = Short.parseShort(line.substring(0, line.indexOf(' ')));
			sale += Short.parseShort(line.substring(line.indexOf(' ') + 1));
			sales[0] = sale;
			idx = 0;
			max = sales[0];

			for (short i = 1; i < 5; i++) {
				line = br.readLine();
				sale = Short.parseShort(line.substring(0, line.indexOf(' ')));
				sale += Short.parseShort(line.substring(line.indexOf(' ') + 1));
				sales[i] = sale;
				if (sale > max) {
					max = sale;
					idx = i;
				}
			}
			System.out.println(names[idx] + " " + sales[idx]);
		}

	}

}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int x,y;cin>>x>>y;
  	long long int countA=0,countB=0;
	
  	if(x>y && x!=0){countB++; x*=-1;}
  	countA=abs(abs(x)-abs(y));
  	if((x>=0 && y<0) || (y>0 && x<0)) countB++;
  	cout<<countA+countB<<endl;
}


Measured memory_bytes: 256
function main(input){
  let [s, t] = input.split('\n').map(v=>v.split(''));
  let count = 0
  for(let i=0; i< s.length; i++){
    if(s[i] !== t[i]) count++;
  }

  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 36516
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    int n, k;
    vector<int> p;
    cin >> n >> k;
    rep(i, 0, n) {
        int x;
        cin >> x;
        p.pb(x);
    }
    sort(all(p));
    rep(i, 0, k) ans += p[i];


  
    cout << ans << "\n";
    return 0;
}



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

int main(){
  int N,K;
  cin>> N>>K;
  int H[N];
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  sort(H,H+N);
  if(K>=N){
    cout<<0<<endl;
    return 0;
  }
  long long count=0;
  for(int i=0;i<N-K;i++){
    count=count+H[i];
  }
  cout<<count<<endl;

  return 0;

}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int  l, m, n,sum;
	map<long long int, long long int>b,a;
	int i, j, k;
	bool flag = true;
	cin >> n;
	m = 0;
	for (i = 0; i < n; i++) {
		cin >> l;
		a[l + i]++;
		b[i - l]++;
		if (m < i - l)m = i - l;
	}
	sum = 0;
	for (i = 1; i <= m; i++) {
		sum += a[i] * b[i];
	}
	cout << sum << endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 46340
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	
	public void copy (int i, int j, int game[][], int result[][]) {
		result[i][j] = game[i][j];
	}
	
	public void decisionmain (int n, int game[][], int result[][]) {
		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < n; k++) {
					decisionsub(i, j, k, game, result);
				}
			}
		}	
	}
	
	public void decisionsub (int i, int j, int k, int game[][], int result[][]) {
		if (k != i) {
			if (game[i][j] == game[k][j]) {
				result[i][j] = 0;
			}
		}
	}
	
	public void scoresum (int n, int result[][]) {
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < 3; j++) {
				sum += result[i][j];
			}
			System.out.println(sum);
		}
	}
	
	void doIt () {
		
		Scanner sc = new Scanner (System.in);

		int n = sc.nextInt();

		int [][] game = new int [n][3];
		int [][] result = new int [n][3];

		int i, j;
		
		for (i = 0; i < n; i++) {
			for (j = 0; j < 3; j++) {
				game[i][j] = sc.nextInt();
				copy(i, j, game, result);
			}
		}
		
		decisionmain(n, game, result);
		scoresum(n, result);
		
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		new Main(). doIt();
		
	}

}

Measured memory_bytes: 20828
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
using namespace std;

int main(void){
  long x;
  cin >> x;
  long neko = x / 11;
  long amari = x % 11;
  cout << neko*2 + ((amari == 0) ? 0 :((amari > 6)? 2 : 1 ))<< endl;
  return 0;
}

Measured memory_bytes: 3640
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

# 5秒後に存在できるのは距離が5, 3, 1のときだけ

for a in A:
	t, x, y = a
	d = x+y
	if t < d or d%2 != t%2:
		print('No')
		sys.exit()
print('Yes')

Measured memory_bytes: 56412
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;

using namespace std;

int main()
{
    int n;
    int len[] = {5,7,5,7,7};
    while (cin >> n, n) {
        int w[n];
        rep (i, n) {
            string s;
            cin >> s;
            w[i] = s.length();
        }
        int i = 0, count = 0;
        frep (s, 0, n) {
            frep(c, s, n) {
                count += w[c];
                if (count == len[i]) {
                    if (i == 4) {
                        cout << s + 1 << endl;
                        s = n;
                        break;
                    }
                    count = 0;
                    ++i;
                } else if (count > len[i]) {
                    i = 0;
                    count = 0;
                    break;
                }
            }
        }
    }
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3148
// AOJ 	0601 Sugar Glider
// 2018.1.16 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 350000
typedef struct { long long t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void max_heapify(int i)
{
	int l, r, max;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t > que[i].t) max = l; else max = i;
	if (r < qsize && que[r].t > que[max].t) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

void deq()
{
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(int s, long long t)
{
	int i, max;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[max = PARENT(i)].t < que[i].t) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}

typedef struct { int a, b, t; } T;
T tbl[300002];

int h[100002];
int *to[100002], *dt[100002], hi[100002];
char used[100002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long dijkstra(int start, int goal, int val)
{
	int i, s, e, c;
	long long d, x;

	qsize = 0;
	enq(start, val);
	while (qsize) {
		s = que[0].s, d = que[0].t, deq();
		if (s == goal) return val + h[goal] - d*2;
		if (used[s]) continue;
		used[s] = 1;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], c = dt[s][i];
			if (used[e] || c > h[s]) continue;
			x = d - c; if (x > h[e]) x = h[e];
			enq(e, x);
		}
	}
	return -1;
}

int main()
{
	int n, m, x, a, b, t;
	int i, k;

	n = in(), m = in(), x = in();
	for (i = 0; i < n; i++) h[i] = in();
	for (i = 0; i < m; i++) {
		tbl[i].a = a =in()-1, tbl[i].b = b = in()-1, tbl[i].t = in();
		hi[a]++, hi[b]++;
	}
	for (i = 0; i < n; i++) {
		to[i] = malloc(hi[i] << 2);
		dt[i] = malloc(hi[i] << 2);
	}
	memset(hi, 0, sizeof(hi));
	for (i = 0; i < m; i++) {
		a = tbl[i].a, b = tbl[i].b, t = tbl[i].t;
		k = hi[a]++, to[a][k] = b, dt[a][k] = t;
		k = hi[b]++, to[b][k] = a, dt[b][k] = t;
	}
	printf("%lld\n", dijkstra(0, n-1, x));
	return 0;
}


Measured memory_bytes: 17476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;ll a[n];ll c=0;ll sum=0;
  for(ll i=0;i<n;i++){
    ll k=sum;
    cin>>a[i];
    sum+=a[i];
    if(i>0){
      if(sum*k>=0)c=1;
    }
  }
  if(c==0){
    cout<<0<<endl;
    return 0;
  }
  ll sum1=0;
  ll sum2=0;
  ll s1=0,s2=0;
  for(ll i=0;i<n;i++){
    if(i%2==0){
      if(s1+a[i]<1){
    sum1+=abs(a[i]-1+s1);
      s1=1;
      }
      else s1+=a[i];
    }
    else{
      if(s1+a[i]>-1){
        sum1+=abs(a[i]+1+s1);
      s1=-1;
      }
      else s1+=a[i];
    }
  }
  
  for(ll i=0;i<n;i++){
    if(i%2==0){
      if(s2+a[i]>-1){
    sum2+=abs(a[i]+1+s2);
      s2=-1;
      }
      else s2+=a[i];
    }
    else{
      if(s2+a[i]<1){
        sum2+=abs(a[i]-1+s2);
      s2=1;
      }
      else s2+=a[i];
    }
    //cout<<s2<<" "<<sum2<<endl;
  }
  
  cout<<min(sum1,sum2)<<endl;
  //cout<<sum1<<sum2<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, t;
    ll mx = 0, cnt = 0, mn = INF;
    cin >> N >> t;
    rep(i, N){
        ll x;
        cin >> x;
        chmin(mn, x);
        if(mx < x - mn){
            mx = x - mn;
            cnt = 1;
        }
        else if(mx == x - mn)cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d", &N);
    
    int array[N+1];
    
    for(int i = 0; i < N; i++){
        scanf("%d", &array[i]);
    }
    int top1 = 0;
    int top2 = 0;
    
    for(int i = 0; i < N; i++){
        if(i == 0){
            top1 = array[i];
        }else if(top1 < array[i]){
            // top2 = top1;
            top1 = array[i];
        }else if(top2 < array[i]){
            top2 = array[i];
        }
    }
    
    for(int i = 0; i < N; i++){
        if(top1 == array[i]){
            printf("%d\n", top2);
        }else{
            printf("%d\n", top1);
        }
    }
    
}


Measured memory_bytes: 2304
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >

const ll
inf = LONG_LONG_MAX/ 2,
maxn = 5005;

ll
dp[maxn][maxn],
h[maxn],
p[maxn];
pll s[maxn];


main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>h[i] >>p[i];
        s[i].F = h[i] + p[i];
        s[i].S = i;
    }
    sort(s, s + n);
    for(int i = 0; i < n; i ++){
        for(int j = 1; j <= n; j ++)
            dp[i][j] = inf;
    }
    dp[0][1] = p[s[0].S];
    for(int i = 1; i < n; i ++){
        for(int j = 1; j <= i + 1; j ++){
            dp[i][j] = dp[i - 1][j];
            int x = s[i].S;
            if(dp[i - 1][j - 1] <= h[x])
                xmin(dp[i][j], dp[i - 1][j - 1] + p[x]);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i ++){
        if(dp[n - 1][i] <= 2000* 1000* 1000)
            ans = i;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 195968
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	long long a;
	char b[10000];
	cin >> a >> b;
	if (b[0] == '0' && strlen(b) == 1) {
		cout << 0;
	}
	else {
		int r = -1;
		for (int i = 0; i < strlen(b); i++) {
			if (b[i] == '.')
				r = i;
		}
		long long b1 = 0, b2 = 0;
		if (r == -1) {
			for (int i = 0; i < strlen(b); i++) {
				b1 = b1 * 10 + (b[i] - '0');
			}
			cout << a * b1;
		}
		else {
			for (int i = 0; i < r; i++) {
				b1 = b1 * 10 + (b[i] - '0');
			}
			for (int i = r + 1; i < strlen(b); i++) {
				b2 = b2 * 10 + (b[i] - '0');
			}
			long long temp = a * b2;
			for (int i = 1; i < strlen(b) - r; i++) {
				temp /= 10;
			}
			cout << a * b1 + temp;
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
    int a,b,c,d,e,f;
    while(1){
            f=0;
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    for(c=0;c<a;c++){
        for(d=0;d<a;d++){
            for(e=0;e<a;e++){
                if(c!=d&&d!=e&&c!=e){
                    if(c+d+e+3==b){
                        f=f+1;
                    }
                }
            }
        }
    }printf("%d\n",f/6);
    }
return 0;
}

Measured memory_bytes: 600
module ch
  implicit none
  type char
     character(10)      :: chara
  end type char
  type(char),allocatable :: namec(:)
  type(char),allocatable :: namecmax(:)
end module ch
program main
   
  use ch, only : namec, namecmax

  implicit none
  integer :: n
  integer, allocatable :: s(:)
  integer :: i,j,k, maxvals
  
  read(*,*) n

  allocate( s(n) )
  allocate( namec(n) )

  do i = 1, n
    read(*,*) namec(i)%chara
  end do

  call quicksort1( 1, n ) 

  j = 1 
  do i = 1, n-1
    if( namec(i)%chara == namec(i+1)%chara ) then
      j = j + 1
      s(i) = j
    else
      j = 1 
      s(i) = j
    end if 
  end do
  s(n) = 1
  maxvals = maxval( s )
  do i = 1, n
    if( s(i) == maxvals ) then
      print*,namec(i)%chara
    end if
  end do

end program main
recursive subroutine quicksort1( first, last )

  use ch, only : namec, namecmax

  implicit none
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  character(100)::x,t
  integer::i,j

  x = namec((first+last)/2)%chara
  i = first
  j = last
  do
     do while ( LGT( x, namec(i)%chara ) )
        i=i+1
     end do
     do while ( LGT( namec(j)%chara, x ) )
        j=j-1
     end do
     if (i >= j) exit
     t = namec(i)%chara
     namec(i)%chara = namec(j)%chara
     namec(j)%chara = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1( first, i-1  )
  if (j+1 < last)  call quicksort1( j+1  , last )

  return

end subroutine quicksort1
recursive subroutine quicksort2( first, last )

  use ch, only : namecmax 

  implicit none
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  character(10)::x,t
  integer::i,j

  x = namecmax((first+last)/2)%chara
  i = first
  j = last
  do
     do while ( LGT( x, namecmax(i)%chara ) )
        i=i+1
     end do
     do while ( LGT( namecmax(j)%chara, x ) )
        j=j-1
     end do
     if (i >= j) exit
     t = namecmax(i)%chara
     namecmax(i)%chara = namecmax(j)%chara
     namecmax(j)%chara = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort2( first, i-1  )
  if (j+1 < last)  call quicksort2( j+1  , last )

  return

end subroutine quicksort2


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


int main()
{
	int a[100][100];
	int b[100][100];
	long c[100][100]={0};
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=0;i < n; i++){
		for(int j=0 ; j < m; j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i < m; i++){
		for(int j=0 ; j < l; j++){
			cin>>b[i][j];
		}
	}
	for(int i=0;i < n; i++){
		for(int j=0 ; j < l; j++){
			for(int k =0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for(int i=0;i < n; i++){
		for(int j=0 ; j < l; j++){
			if( j != l-1){
				cout<<c[i][j]<<" ";
			}else{
				cout<<c[i][j]<<endl;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define endl "\n"

vector<ll> cost(123450),degree(123450,0);
vector<vector<int> > adj(123450);

int func(int cur,int pre){
	int i;
	ll b=0;
	ll max=-1;
	for(i=0;i<adj[cur].size();i++){
		if(adj[cur][i]==pre) continue;
		func(adj[cur][i],cur);
		b+=cost[adj[cur][i]];
		if(max<cost[adj[cur][i]]) max=cost[adj[cur][i]];
	}
	ll a=cost[cur];
	ll x1=b-a;
	ll x2=2*a-b;
	if(degree[cur]!=1){
		cost[cur]=x2;
		if(pre==-1){
			if(x2!=0){
				cout<<"NO";
				exit(0);	
			}
		}
		if(x2<0||x1<0||(max>a)){
			cout<<"NO";
			exit(0);
		}
	}
	return 0;
}

int main(){
	std::ios::sync_with_stdio(false); 
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++){
		cin>>cost[i];
	}
	for(i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a-1].pb(b-1);
		adj[b-1].pb(a-1);
		degree[a-1]++;
		degree[b-1]++;
	}
	if(n==2){
		if(cost[0]!=cost[1]){
			cout<<"NO";
			return 0;
		}
		else{
			cout<<"YES";
			return 0;	
		}
	}
	for(i=0;i<n;i++){
		if(degree[i]!=1){
			func(i,-1);
			break;
		} 
	}
	cout<<"YES";
	return 0;
}


Measured memory_bytes: 14848