akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int n ;
    cin >> n;
    for(int i = 0; i < 8; i++) {
        if(n < pow(2,i+1) ) { 
            cout << pow(2,i) << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define AmrYassen                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 2 * 1e5 + 1;
const int mod = 1e9 + 7;
ll minn = INT_MIN;
int main() {
    AmrYassen ll n, m;
    cin >> n >> m;
    ll summ = 0;
    if (n == 1 && m == 1) {
        return cout << 1000000, 0;
    }
    if (n == 1) {
        summ += 300000;
    }
    if (m == 1) {
        summ += 300000;
    }
    if (n == 2) {
        summ += 200000;
    }
    if (m == 2) {
        summ += 200000;
    }
    if (n == 3) {
        summ += 100000;
    }
    if (m == 3) {
        summ += 100000;
    }
    cout << summ;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    double p1, p2, p3, p4;
    p1 = p2 = p3 = p4 = 0;
    for (int i = 0; i < n; i++) {
        p1 += fabs(x[i] - y[i]);
    }
    for (int i = 0; i < n; i++) {
        p2 += pow(fabs(x[i] - y[i]), 2);
    }
    p2 = sqrt(p2);
    for (int i = 0; i < n; i++) {
        p3 += pow(fabs(x[i] - y[i]), 3);
    }
    p3 = cbrt(p3);
    p4 = fabs(x[0] - y[0]);
    for (int i = 1; i < n; i++) {
        p4 = max(p4, fabs(x[i] - y[i]));
    }
    printf("%.8f\n%.8f\n%.8f\n%.8f\n", p1, p2, p3, p4);
    return 0;
}


Measured memory_bytes: 3460
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	for (long long i = 1;; i++)
	{
		if ((n*i) % 2 == 0)
		{
			cout << n * i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//daydream
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,tmp,sum=0;
string s;
bool b=1;
char r1,r2,op;
int main(){
	ios::sync_with_stdio(0);
	getline(cin,s);
	int i=0;
	while (i<s.length()){
		if (s[i]=='d'){
			if (i+4>=s.length()){
				//cout<<"s1"<<endl;
				cout<<"NO"<<endl;
				exit(0);
			}
			if (s[i+1]=='r' && s[i+2]=='e' && s[i+3]=='a' && s[i+4]=='m'){
				i=i+5;
				if (i>=s.length()) break;
				else if (s[i]=='e' && s[i+1]=='r' && s[i+2]!='a') i+=2;
			}
			else{
				//cout<<s[5]<<endl;
				//cout<<"s2"<<endl;
				cout<<"NO"<<endl;
				exit(0);
			}
		}
		else if (s[i]=='e'){
			if (i+4>=s.length()){
				//cout<<"s3"<<endl;
				cout<<"NO"<<endl;
				exit(0);
			}
			if (s[i+1]=='r' && s[i+2]=='a' && s[i+3]=='s' && s[i+4]=='e'){
				i=i+5;
				if (i>=s.length()) break;
				else if (s[i]=='r') i++;
			}
			else{
				//cout<<s[i]<<endl;
				//cout<<"s4"<<endl;
				cout<<"NO"<<endl;
				exit(0);
			}
		}
		else{
			cout<<"NO"<<endl;
			exit(0);
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int main(){
string S;
string T;
string U;
int A;
int B;

cin >> S >> T;
cin >> A >> B;
cin >> U;

if (U==S){
cout << A-1 << " " << B;
}
else if (U==T){
cout << A << " " << B-1 ;
}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	string s;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='1')
		s[i]='9';
		else if(s[i]=='9')
		s[i]='1';
	}
	cout<<s;
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mx = 1e9+5;
int main()
{
	//freopen("in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int dp[n][3];
	for(int i = 0; i<n; i++){
		for(int j = 0; j<3; j++){
			cin>>dp[i][j];
		}
	}

	for(int i = 1; i<n; i++){
		for(int j = 0; j<3; j++){
			if(j==0){
				dp[i][j]=max(dp[i][j]+dp[i-1][j+1], dp[i][j]+dp[i-1][j+2]);
			}
			else if(j==1){
				dp[i][j]=max(dp[i][j]+dp[i-1][j+1], dp[i][j]+dp[i-1][j-1]);
			}
			else{
				dp[i][j]=max(dp[i][j]+dp[i-1][j-1], dp[i][j]+dp[i-1][j-2]);
			}
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a>b)  System.out.printf("a > b\n");
        else if(a<b) System.out.printf("a < b\n");
        else if(a==b) System.out.printf("a == b\n");
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define N 1000005
//int N;
//# define N 2003
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define INF 100000000
# define A 1000000

int main()
{
	IOS;
	ll n,k;
	cin >> n >> k;
	ll ans=0;
	if(k==0)
	{
		ans=n*n;
		cout << ans;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if((i-k)<=0)
			continue;
		for(int j=i;j<=n;j+=i)
		{
			ans+=(i-k);
		}
		ll rem=(n%i);
		if((rem-k+1)>0)
		ans+=(rem-k+1);
	//trace2(i,ans);
	}
	cout << ans;

}

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

int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(abs(a-b)>=1000000000000000000){cout << "Ubfair" << endl;}
    else{
        if(k%2==0)cout << a-b << endl;
        else cout << b-a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        double A = sc.nextDouble();
        double[] H = new double[N];
        long ans = 0;
        double c = INF;
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextDouble();
            if (c > Math.abs(A - (T - H[i] * 0.006))) {
                ans = i + 1;
                c = Math.abs(A - (T - H[i] * 0.006));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28116
#131b
N,L = map(int, input().split()) #2≦N≦200  , −100≦L≦100
#N 個のリンゴがあります。これらはそれぞれリンゴ 1、リンゴ 2、リンゴ 3、...、リンゴ N 
#リンゴ i の「味」は L+i−1 です。
#N 個のリンゴ全てを材料としてできるアップルパイの「味」と、
#食べていない N−1 個のリンゴを材料としてできるアップルパイの「味」の差の絶対値ができるだけ小さくなるように、
#食べるリンゴを選ぶことにしました。 →絶対値が一番少ないものを除外する
#このようにして選ばれたリンゴを食べた時、食べていない N−1 個のリンゴを材料としてできるアップルパイの「味」を求めてください。

#元のアップルパイ
taste_list = [L+(i+1)-1 for i in range(N)]

#print(min([abs(taste) for taste in taste_list]))　絶対値最小
#print([abs(taste) for taste in taste_list].index(min([abs(taste) for taste in taste_list])))　絶対値最小のインデックス
#print(taste_list[[abs(taste) for taste in taste_list].index(min([abs(taste) for taste in taste_list]))])　#絶対値最小の元の値

print(sum(taste_list)-taste_list[[abs(taste) for taste in taste_list].index(min([abs(taste) for taste in taste_list]))])

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] t = new int[n];
		int[] t2 = new int[n];

		int i = 0;
		int j = 0;
		for (i = 0; i < n; i++) {
			t[i] = scan.nextInt();
		}

		//System.out.println(t[0]);
		//System.out.println(t[1]);
		//System.out.println(t[2]);

		int m = scan.nextInt();
		int[] p = new int[m];
		int[] x = new int[m];

		j = 0;
		for (j = 0; j < m; j++) {
			p[j] = scan.nextInt();
			x[j] = scan.nextInt();
		}
		/*
				System.out.println(p[0]);
				System.out.println(p[1]);
				System.out.println(x[0]);
				System.out.println(x[1]);
		*/

		for (i = 0; i < m; i++) {
			for (j = 0; j < n; j++) {
				t2[j] = t[j];
			}

			t2[p[i] - 1] = x[i];
			int sum = 0;
			for (j = 0; j < n; j++) {
				sum = sum + t2[j];
			}
			System.out.println(sum);
		}

	}

}

Measured memory_bytes: 21588
# Acceptance of input
import sys

file_input = sys.stdin

n = file_input.readline()

EP = []
l = -1000000001
u = 1000000001

for line in file_input:
    x1, y1, x2, y2 = (map(int, line.split()))
    if x1 == x2:
        if y1 < y2:
            EP.append((y1, l, x1))
            EP.append((y2, u, x1))
        else:
            EP.append((y1, u, x1))
            EP.append((y2, l, x1))
    else:
        if x1 < x2:
            EP.append((y1, x1, x2))
        else:
            EP.append((y1, x2, x1))

# Sweep
import bisect

EP.sort()
BT = []
cnt = 0

for p in EP:
    e = p[1]
    if e == l:
        bisect.insort(BT, p[2])
    elif e == u:
        i = bisect.bisect_left(BT, p[2])
        BT.pop(i)
    else:
        cnt += bisect.bisect(BT, p[2]) - bisect.bisect_left(BT, e)

# Output
print(cnt)

Measured memory_bytes: 27096
w,h,n = gets.chomp.split(" ").map(&:to_i)
x = n.times.map{gets.chomp.split(" ").map(&:to_i)}
a,b,c,d = 0,0,w,h
for i in 0..n-1
  if x[i][2] == 1
    a = [a,x[i][0]].max
  elsif x[i][2] == 2
    c = [c,x[i][0]].min
  elsif x[i][2] == 3
    b = [b,x[i][1]].max
  else
    d = [d,x[i][1]].min
  end
end
if c-a > 0 && d-b > 0
  puts (c-a)*(d-b)
else
  puts 0
end

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int a;
    char s[16];

    cin >> a;

    if (a >= 3200) {
        cin >> s;
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
 
int n, s;
int used[10];
int ans = 0;
 
void func( int num, int sum )
{
    if( num == n ){
        if( sum == s ){
            ans++;
        }
        return;
    }
     
    for( int i = used[num]; i <= 9; i++ ){
        used[num+1] = i + 1;
        func( num + 1, sum + i );
        used[num+1] = 0;
    }
}
 
int main()
{
    while( 1 ){
        memset( used, 0, 10 );
        ans = 0;
         
        std::cin >> n >> s;
        if( !n && !s ) break;
         
        func( 0, 0 );
         
        std::cout << ans << std::endl;
    }
 
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include <math.h>
#include <iomanip>

using namespace std;
int main(){
    cout<<fixed<<setprecision(12);
	double x1, y1, x2, y2, dx, dy,ans;
    cin >> x1 >> y1>> x2 >> y2;
    
    dx = x2 - x1;
    dy = y2 - y1;
    ans = sqrt(dx*dx + dy*dy);
    cout << ans <<endl;

	return 0;
}



Measured memory_bytes: 3280
#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>
#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>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;

int main() {
	int n, m,ac=0,wa=0;
	cin >> n >> m;
	map<int, int> acc;
	map<int, int> wac;
	for (int k = 0;k < m;k++) {
		int a;
		string s;
		cin >> a >> s;
		if (s == "AC") {
			if (acc[a] != 123) {
				ac++;
				acc[a] = 123;
			}
		}
		else {
			if (acc[a] != 123) {
				wac[a]++;
			}
		}
	}
	for (int i = 1;i <= n;i++) {
		if (acc[i] == 123) {
			wa += wac[i];
		}
	}
	cout << ac << " " << wa;

}


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

using namespace std;

int main (){
    ios_base::sync_with_stdio(false);
    int n, k, x, y, sum;
    cin >> n >> k >> x >> y;
    if (n>=k) sum=(k*x)+((n-k)*y);
    else sum=n*x;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {

	const L = input.split(" ").map(x => parseInt(x, 10));
	
	console.log(L[0] + L[1] + L[2] + 9 * L.reduce( (a, b) => Math.max(a, b) ));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# B - Bingo
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
s3 = list(map(int, input().split()))

n = (int)(input())
result = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(0, n):
    b = (int)(input())

    if s1[0] == b:
        result[0][0] = True
    elif s1[1] == b:
        result[0][1] = True
    elif s1[2] == b:
        result[0][2] = True

    if s2[0] == b:
        result[1][0] = True
    elif s2[1] == b:
        result[1][1] = True
    elif s2[2] == b:
        result[1][2] = True

    if s3[0] == b:
        result[2][0] = True
    elif s3[1] == b:
        result[2][1] = True
    elif s3[2] == b:
        result[2][2] = True

if result[0][0] & result[0][1] & result[0][2]:
    print('Yes')
elif result[1][0] & result[1][1] & result[1][2]:
    print('Yes')
elif result[2][0] & result[2][1] & result[2][2]:
    print('Yes')
elif result[0][0] & result[1][0] & result[2][0]:
    print('Yes')
elif result[0][1] & result[1][1] & result[2][1]:
    print('Yes')
elif result[0][2] & result[1][2] & result[2][2]:
    print('Yes')
elif result[0][0] & result[1][1] & result[2][2]:
    print('Yes')
elif result[0][2] & result[1][1] & result[2][0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3192
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <ctime>
#include <set>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdio>
#include <bitset>
#include <iomanip>

using namespace std;

long long dp[123456];
long long h[123456];

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

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

    for (int i = 0; i <= n; ++i)
        dp[i] = (1LL<<60);

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }

    cout << dp[n] << endl;

    return 0;
}

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

int main() {
  int n,m,count=0,kijun,sum=0;
  cin >> n >> m;
  m*=4;
  int a[n];
  r(i,n){cin >> a[i];
         sum+=a[i];
        }
  kijun=(sum+m-1)/m;
  r(i,n)if(a[i]>=kijun)count++;
  m/=4;
  if(m<=count)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mo=998244353;
int ans,x,n,a[205],b[205];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",&a[i],&b[i]);
	ans=1; for (int i=1;i<=n;++i) ans=ans*2%mo;
	for (int i=1;i<=n;++i)
	for (int j=i+1;j<=n;++j){
		x=1;
		for (int k=j+1;k<=n;++k)
		if ((a[j]-a[i])*(b[k]-b[i])-(b[j]-b[i])*(a[k]-a[i])==0) x=x*2%mo;
		(ans-=x)%=mo;
	}
	printf("%d",((ans-n-1)%mo+mo)%mo);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
Total = sum(B)
for T in range(0,N-1):
    if A[T+1]-A[T]==1:
        Total += C[A[T]-1]
print(Total)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define int long long
using namespace std;
const long long inf = 1e18;
signed main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	if(a[0] == 0){
		cout << 0 << endl;
		return 0;
	}
	int x = 1;
	for(int i = n - 1; i >= 0; i--){
		double aa = 1.0 * inf / x;
		if(a[i] > aa || x * a[i] > inf){
			cout << -1 << endl;
			return 0;
		}
		x *= a[i];
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 4436
import java.util.Scanner;

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

		if (a == b) {
			System.out.println(c);
		} else if (a == c ) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 21204
#include <stdio.h>

int main(void){

	int m, f, r;
	char result;


	for (;;){
		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1){
			break;
		}
		else if (m == -1 || f == -1){
			result = 'F';
		}
		else if (m + f >= 80)
		{
			result = 'A';
		}
		else if (m + f >= 65 && m + f < 80)
		{
			result = 'B';
		}
		else if (m + f >= 50 && m + f < 65)
		{
			result = 'C';
		}
		else if (m + f >= 30 && m + f < 50)
		{
			if (r >= 50){
				result = 'C';
			}
			else
			{
				result = 'D';
			}
		}
		else if (m + f < 30)
		{
			result = 'F';
		}
		printf("%c\n", result);
	}

	return 0;
}

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

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

int main() {
    int n;cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);
    
    ll ans = 999999999999999;
    for(int  i = max(n/2 - 5,0);i<= min(n/2 + 5,n-1);++i){
        ll ans2 = 0;
        rep(j,n){
            ans2+=abs(a[j]-a[i]);
        }
        ans = min(ans,ans2);
    }
   cout<<ans<<endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	fct[0] = fct[1] = inv[1] = inv[cmx] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	for(ll x=fct[cmx], n=mod-2; n > 0; n >>=1, x = x*x %mod)
		if(n & 1) inv[cmx] = inv[cmx] * x %mod;
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	finit(2*n+1000);
	if(n<=k){
		cout << nCk(n+n-1, n) <<"\n"; return 0;
	}
	ll ans =0;
	rep(i, k+1){
		(ans += nCk(n, i) * nCk(n-1, i)) %=MD;
	}
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

ll a[100000];

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) scanf("%lld", &a[i]);
	sort(a, a + N);
	ll w = 0, h = 0;
	bool flag = false;
	for(int i = N - 1; i > 0; --i) {
		if(!flag && a[i] == a[i - 1]) {
			flag = true;
			h = a[i];
			--i;
		}
		else if(flag && a[i] == a[i - 1]) {
			w = a[i];
			break;
		}
	}
	cout << w * h << endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
h = list(map(int, input().split()))

def calc(left, right, ans):
    minh = min(h[left: right+1])
    ans += minh
    for i in range(left, right+1):
        h[i] -= minh
    return ans

ans = 0

while h!=[0]*N:
    if h[0]>0:left = 0
    
    if N==1:
        ans = h[0]
        break    
    
    for i in range(1, N):
        if h[i]>0 and h[i-1]==0:
            left=i
            if i==N-1:
                right = N-1
                ans = calc(left, right, ans)
        elif h[i]==0 and h[i-1]>0:
            right=i-1
            ans = calc(left, right, ans)
        elif h[i]>0 and h[i-1]>0 and i==N-1:
            right = N-1
            ans = calc(left, right, ans)
        else:continue


print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int s, w;
  cin >> s >> w;
  string ans;
  if(s <= w) {
    ans = "unsafe";
  }
  else {
    ans = "safe";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <math.h>
#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr long long INFLL = 1e18;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  ll ans = 0;
  int temp = 0;

  for (int i = 1; i < n; i++) {
    if (a.at(i - 1) > a.at(i)) {
      temp = a.at(i - 1) - a.at(i);
      a.at(i) += temp;
      ans += temp;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

priority_queue<int> pq;
int main() {
	int N, L; cin >> N;
	for(int i=0; i<N; ++i){
	    cin >> L;
	    pq.push(L);
	}
	int mx=pq.top(), ot=0;
	for(int i=1; i<N; ++i){
	    pq.pop();
	    ot += pq.top();
	}
	if(mx<ot) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main() {
  long long n;
  cin >> n ;
  vector<char> c(n);
  int r=0, ans=0;
  for(int i=0;i<n;i++){
    cin >> c[i];
    if(c[i] =='R') r++;
  }
  
  for(int i=r;i<n;i++){
    if(c[i] == 'R')ans++;
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 3552
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;

ll n, length = 1, a[N], res[N];
vector<ll> v[N], seq, tail(N, INF);

void dfs(ll s, ll p)
{
    ll val, ind=-1, mx = length;
    if(a[s] < tail[0])
    {
        val=tail[0];
        ind=0;
        tail[0] = a[s];
    }
    else if(a[s] > tail[length - 1])
        tail[length++] = a[s];
    else
    {
        ind = lower_bound(tail.begin(), tail.begin()+length, a[s]) - tail.begin();
        // ind = b_search(tail, 0, length, a[s]);
        if(ind==length)
            length++;
        val = tail[ind];
        tail[ind] = a[s];
    }
    res[s] = length;

    for(auto u : v[s])
        if(u!=p)
            dfs(u, s);

    length = mx;
    if(ind!=-1)
        tail[ind] = val;

}
void test_case()
{
    ll i,j;
    cin>>n;
    f(i,1,n+1)
    {
        cin>>a[i];
    }
    f(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        v[x].pu(y);
        v[y].pu(x);
    }
    tail[0] = a[1];
    dfs(1, 0);
    f(i,1,n+1)
    {
        cout<<res[i]<<'\n';
    }
}

int32_t main()
{
    IOS();
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 33120
#include<iostream>
using namespace std;
int main(){
	char s[4];
	cin>>s[0]>>s[1]>>s[2]>>s[3];
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
		cout<<"Bad";
	}else{
		cout<<"Good";
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

double dp[302][302][302];

int main(){
  int N;
  int a = 0;
  int b = 0;
  int c = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    int d;
    cin >> d;
    if(d==1) a++;
    if(d==2) b++;
    if(d==3) c++;
  }

  dp[1][0][0] = 3;
  for(int k=0;k<=300;k++){
    for(int j=0;j<=300;j++){
      for(int i=0;i<=300;i++){
        if(i+j+k == 0) continue;
        //cout << i << " " << j << " " << k << " " << endl;
        dp[i][j][k] = (double)N / (double)(i + j + k);
        if(i>0) dp[i][j][k] += (double)i / (double)(i+j+k) * dp[i-1][j][k];
        if(j>0) dp[i][j][k] += (double)j / (double)(i+j+k) * dp[i+1][j-1][k];
        if(k>0) dp[i][j][k] += (double)k / (double)(i+j+k) * dp[i][j+1][k-1];
      }
    }
  }

  //cout << dp[1][0][0] << endl;
  printf("%.10lf\n",dp[a][b][c]);
  return 0;
}

Measured memory_bytes: 215296
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b; cin >>a >> b;
	cout << a*b <<" " << a*2+b*2<<endl;

}


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

int main() {
    int32_t n, m;
    cin >> n >> m;
    bool r[n + 1];
    int32_t d[n + 1];
    for (int32_t i = 0; i <= n; i++) {
        r[i] = false;
        d[i] = 1;
    }
    r[1] = true;

    for (int32_t i = 0; i < m; i++) {
        int32_t x, y;
        cin >> x >> y;
        d[x] -= 1;
        d[y] += 1;
        r[y] = r[x] || r[y];
        r[x] = d[x] > 0 ? r[x] : false;
    }

    int32_t answer = 0;
    for (int32_t i = 1; i <= n; i++) {
        if (r[i]) {
            answer++;
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    int n, m;
    string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int tt;
  tt = 1;
  while (tt--)
  {
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
      s += 'e';
      s += 's';
    }
    else
    {
      s += 's';
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    int ans[26];
    fill(ans, ans+26, inf);
    rep(i, N){
        string s;
        cin >> s;
        int cnt[26];
        fill(cnt, cnt+26, 0);
        rep(j, s.size()){
            cnt[s[j]-'a']++;
        }
        rep(j, 26){
            ans[j] = min(ans[j], cnt[j]);
        }
    }
    rep(i, 26){
        char res = 'a'+i;
        rep(j, ans[i]){
            cout << res;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val arr: Array[String] = new Array[String](3)
    arr.update(0, io.StdIn.readLine().mkString)
    arr.update(1, io.StdIn.readLine().mkString)
    arr.update(2, io.StdIn.readLine().mkString)

    for (i: Int <- 0 to 2)
     print(arr(i)(i))
    
  }
}


Measured memory_bytes: 25292
#include<cstdio>
int abs(int n){
	if(n<0)n=-n;
	return n;
}
int main(){
	int h,w,d;
	scanf("%d%d%d",&h,&w,&d);
	int a[h*w];
	int b[h*w];
	for(int i=0;i<h*w;i++){
		int x;
		scanf("%d",&x);
		x--;
		a[x]=i/w;
		b[x]=i%w;
	}
	int p[90000]={};
	for(int i=0;i<d;i++){
		for(int j=i+d;j<h*w;j+=d){
			p[j]=p[j-d]+abs(a[j]-a[j-d])+abs(b[j]-b[j-d]);
		}
	}
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		l--;
		r--;
		printf("%d\n",p[r]-p[l]);
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  int X, Y; std::cin >> X >> Y; X--, Y--;

  std::vector<std::vector<int>> G(N);
  rep(i,N-1) {
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);

  std::vector<std::vector<int>> D(N, std::vector<int> (N));
  for(int i=0; i<N; i++) {
    std::queue<int> q; q.push(i);
    std::vector<int> dist(N,-1); dist[i] = 0;
    while(!q.empty()) {
      int cur = q.front(); q.pop();
      for(auto&& g : G[cur]) {
        if ( dist[g] != -1 ) continue;
        dist[g] = dist[cur]+1;
        D[i][dist[g]]++;
        q.push(g);
      }
    }
  }

  for(int k=1; k<=N-1; k++) {
    ll ans = 0;
    rep(i,N) ans += D[i][k];
    std::cout << ans/2 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main() {
  char a, b, c, d;
  int A=0, B=0, C=0, D=0;
  cin >> a >> b >> c >> d;

  // char->intの変換は'0'を引くことでASCII的に変換する
  A = a - '0';
  B = b - '0';
  C = c - '0';
  D = d - '0';

  // forループの中で利用する配列
  vector<char> CHARS = {b, c, d};
  vector<int> INTS = {B, C, D};

  // bit全探索
  // maskが組み合わせを保持するbit
  rep(mask, 1 << 3){
    int ans = A;
    // maskの各bitが1か0かを見ていく
    rep(idx, 3){
      // もし1であれば&を使ってtrueが帰ってくるのでifを使って抽出できる
      if (mask & (1 << idx)) ans += INTS[idx];
      // 0の場合はelseで対応
      else ans -= INTS[idx];
    }

  // もし演算結果が7の場合は出力操作に移行する
  if (ans == 7){
    // とりあえず7を出力
    cout << a;
      rep(idx, 3){
        // 先ほどと同じ要領で演算子と数字を出力
        if (mask & (1 << idx)) cout << '+';
        else cout << '-';
        cout << CHARS[idx];
      }
    // 最後に"=7"を出力
    cout << "=7" << endl;
    // 強制終了
    return 0;
    }
  }
}

Measured memory_bytes: 256
from itertools import combinations

n,k=map(int,input().split())
lst=list(map(int,input().split()))

work=lst[0]
ini=[x-work for x in lst]
ini_seen=[0]
work=0
for i in range(1,n):
    if ini[i]>work:
        work=ini[i]
        ini_seen.append(i)

mn=None
for x in combinations(range(n-len(ini_seen)),k-len(ini_seen)):
    sm=0
    work=0
    xtoken=0
    count=1
    for i in range(1,n):
        if i in ini_seen:
            count+=1
            if work<ini[i] : work=ini[i]
            else:
                work+=1
                sm+=work-ini[i]
        elif xtoken<len(x) and i==x[xtoken]+count:
            work+=1
            sm+=work-ini[i]
            xtoken+=1
    if not mn : mn=sm
    if mn>sm : mn=sm
print(mn)

Measured memory_bytes: 9276
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint K; cin >> K;


    vector<lint> h(N);
    REP(i, N) {
      lint a; cin >> a; h[i] = a;
    }

    vector<lint> dp(N);

    for(int i= max(N-K-1, (lint)0); i < N; i++) {
      dp[i] = abs(h[i] - h[N-1]);
    }
    for(lint i=N-K-2; i >=0;i--) {
      lint res = 10000000000;
      for(lint k=1; k <=K; k++) {
        res = min(abs(h[i] - h[i+k]) + dp[i+k], res);
      }
      dp[i] = res;
    }
    
    PRINT(dp[0]);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int h,w;
char c[52][52];
int cc[52][52];
void dfs(int i,int j){
  if(i!=h||j!=w){
    if(c[i+1][j]=='.'&&cc[i][j]+1<cc[i+1][j]){
      cc[i+1][j]=cc[i][j]+1;
      dfs(i+1,j);
    }
    if(c[i-1][j]=='.'&&cc[i][j]+1<cc[i-1][j]){
      cc[i-1][j]=cc[i][j]+1;
      dfs(i-1,j);
    }
    if(c[i][j+1]=='.'&&cc[i][j]+1<cc[i][j+1]){
      cc[i][j+1]=cc[i][j]+1;
      dfs(i,j+1);
    }
    if(c[i][j-1]=='.'&&cc[i][j]+1<cc[i][j-1]){
      cc[i][j-1]=cc[i][j]+1;
      dfs(i,j-1);
    }
  }
}
int main(){
  int m=0;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c[i][j];
      if(c[i][j]=='#')
        m++;
      cc[i][j]=10000;
    }
  }
  cc[1][1]=1;
  dfs(1,1);
  if(cc[h][w]==10000){
    cout<<-1;
    return 0;
  }
  cout<<h*w-m-cc[h][w];
}
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  char p = s.back();
  if (p == '2' || p == '4' || p == '5' || p == '7' || p == '9') {
    cout << "hon" << endl;
  } else if (p == '0' || p == '1' || p == '6' || p == '8') {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3612
#include <iostream>

typedef long long ll;

int mat[3000][3000];

ll dp[3000][3000][4];
ll dpl[3000];

int main(int argc, char **argv)
{
    int rr, cc, k;

    std::cin >> rr >> cc >> k;
    for (int i = 1; i <= k; i++) {
        int r, c, v;
        std::cin >> r >> c >> v;
        mat[r - 1][c - 1] = v;
    }
    dp[0][0][1] = mat[0][0];
    for (int y = 0; y < rr; y++) {
        for (int x = 0; x < cc; x++) {
            for (int c = 0; c < 4; c++) {
                int v = mat[y][x];
                ll q;
                if (c == 0 || v == 0) {
                    q = (x == 0) ? dpl[x] : std::max(dpl[x], dp[y][x - 1][c]);
                } else {
                    q = (x == 0) ? dpl[x] + v : std::max(dpl[x] + v, std::max(dp[y][x - 1][c], dp[y][x - 1][c - 1] + v));
                }
                dp[y][x][c] = q;
            }
        }
        for (int x = 0; x < cc; x++) {
            dpl[x] = std::max(std::max(dp[y][x][0], dp[y][x][1]), std::max(dp[y][x][2], dp[y][x][3]));
        }
    }
    std::cout << dpl[cc - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 319456
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

typedef  unsigned long long ull;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

struct P {
	string title, auther;
	int y, m, d;
};

void YMD(string s,int& y, int &m, int &d) {
	FOR(i, sz(s)) s[i] -= '0';
	y = s[0] * 1000 + s[1] * 100 + s[2] * 10 + s[3];
	m = s[5] * 10 + s[6];
	d = s[8] * 10 + s[9];
}

bool C(int ly, int lm, int ld, int ry, int rm, int rd) {
	if (ly != ry) return ly < ry;
	if (lm != rm) return lm < rm;
	return ld <= rd;
}

int main() {
	int n; cin >> n;
	vector<P> vp;
	FOR(i, n) {
		P p;
		cin >> p.title >> p.auther;
		string ymd; cin >> ymd;
		YMD(ymd,p.y, p.m, p.d);
		vp.push_back(p);
	}

	int q; cin >> q;
	FOR(_, q) {
		if (_ != 0) cout << endl;
		string ti, au, st, en;
		cin >> ti >> au >> st >> en;
		bool ok[100] = {};
		memset(ok, 1, sizeof(ok));
		if (ti != "*") {
			FOR(i, n) if (vp[i].title.find(ti) == -1) ok[i] = false;
		}
		if (au != "*") {
			FOR(i, n) if (vp[i].auther.find(au) == -1) ok[i] = false;
		}
		if (st != "*") {
			int y, m, d; YMD(st, y, m, d);
			FOR(i, n) if (!C(y, m, d, vp[i].y, vp[i].m, vp[i].d)) ok[i] = false;
		}
		if (en != "*") {
			int y, m, d; YMD(en, y, m, d);
			FOR(i, n) if (!C(vp[i].y, vp[i].m, vp[i].d, y, m, d)) ok[i] = false;
		}
		FOR(i, n) {
			if (ok[i]) cout << vp[i].title << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1240
#!/usr/bin/env python3
if __name__ == '__main__':
  l = list([-1,100])
  for i in range(2,14):
    l.append(i)
  # for i in range(1,14):
  #   print(i, l[i])
  s = str(input()).split(" ")
  a = int(s[0])
  b = int(s[1])
  if l[a] > l[b]:
    print("Alice")
  elif l[a] < l[b]:
    print("Bob")
  else:
    print("Draw")


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

using namespace std;

int main()
{
	int n;cin>>n;
  	vector <int> v(n);
    for(int i=0;i<n;i++)
    {
       cin>>v[i];
    }
    sort(v.begin(),v.end(),greater <int> ());
    long long sum=v[0];
     int c=n-2,i; 
   for(i=1;i<n && c>1 ;i++)
    {	sum = (sum+2*1ll*v[i]);
        c-=2;
    }
    if(c==1)
       {
       	 sum+=v[i];
       }
    	cout<<sum<<'\n';
  	return 0;
}

Measured memory_bytes: 4060
#include <stdio.h>
int main(void) {
	int a,b,c,temp;
	scanf("%d %d %d", &a, &b,&c);
	if (a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c) {
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2728
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
set<int>s;
int main()
{
    int n;
    scanf("%d",&n);
    int x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(s.find(x)==s.end())
            s.insert(x);
        else s.erase(x);
    }
    printf("%d\n",s.size());
    return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

// const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	string s, t;
	cin >> s >> t;

	int count = 0;
	for (size_t i = 0; i < s.size() - t.size() + 1; i++)
	{
		string str = s.substr(i, t.size());
		int matchCount = 0;
		for (size_t j = 0; j < str.size(); j++)
		{
			if (str[j] == t[j])
			{
				matchCount++;
			}
		}
		count = max(count, matchCount);
	}

	cout << (t.size() - count) << endl;
	return 0;
}

Measured memory_bytes: 3160
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int D,M,d,q;
int c[30];
int s[400][30];
int type[400];
int last[29];
ll satis_level[400];

ll calc_score(int d){
  rep(i,d,D+1) satis_level[i] = 0;
  if(d==1)
    rep(j,1,27) last[j]=0;
  else{
    rep(j,1,27) last[j]=0;
    rep(i,1,d) last[type[i]] = i;
  }
  ll down_satis;
  satis_level[d] = satis_level[d-1];
  rep(i,d,D+1){
    down_satis=0;
    last[type[i]] = i;
    satis_level[i] += s[i][type[i]];
    rep(j,1,27) down_satis += c[j]*(i-last[j]);
    satis_level[i] -= down_satis;
    satis_level[i+1] += satis_level[i];
  }
  return satis_level[D];
}

int main(){
  map<int,int, std::greater<int>> mp;
  satis_level[0]=0;
  cin >> D;
  rep(i,1,27){
    cin >> c[i];
    mp[c[i]]=i;
  }
  rep(i,1,D+1){
    rep(j,1,27){
      cin >> s[i][j];
    }
  }
  
  int j=1;
  for(auto i=mp.begin();j<=D;++i,j++) {
    type[j] = mp[i->first];
  }
  
  ll pre_score,new_score;
  int d,q,pq;
  pre_score = calc_score(1);
  random_device rnd; 
  mt19937 mt(rnd());
  uniform_int_distribution<> rand_d(1,D); 
  uniform_int_distribution<> rand_q(1,26); 
  rep(i,1,100000){
    d = rand_d(mt);
    q = rand_q(mt);
    pq = type[d];
    type[d] = q;
    new_score = calc_score(d);
    if(pre_score > new_score) type[d] = pq;
    else pre_score = new_score;
    //if(pre_score > new_score && i%10000==0) type[d] = q;
  }
  
  rep(i,1,D+1) cout << type[i] << '\n';
  return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<vector>
#define PP std::pair<int,int>
#define INF (1<<30)
#define LL long long
int H, W;
int cost[11];
bool d[11];
int c[11][11];
int wall[210][210];
LL ans;


int main() {
	std::cin >> H >> W;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			std::cin >> c[i][j];
		}
	}
	for (int i = 0; i <= 9; i++) {
		cost[i] = c[i][1];
	}
	std::vector<int> fig;
	fig.push_back(1);
	while (fig.size() != 10) {
		for (int i = 0; i < (int)fig.size(); i++) {
			for (int j = 0; j <= 9; j++) {
				cost[j] = std::min(cost[fig[i]] + c[j][fig[i]], cost[j]);
			}
		}
		std::vector<PP> tmp;
		for (int i = 0; i <= 9; i++) {
			if (!d[i])
				tmp.push_back(PP(cost[i], i));
		}
		std::sort(tmp.begin(), tmp.end());
		fig.push_back(tmp[1].second);
		d[tmp[1].second] = true;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			std::cin >> a;
			if(a>=0)
			ans += cost[a];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int froms[100002];
int D, N, M;

int main()
{
 loop:
  cin >> D;
  if(!D)
    return 0;
  cin >> N >> M;
  froms[0] = 0;
  for(int i = 1; i < N; i++)
  {
    int d;
    cin >> d;
    froms[i] = d;
  }
  froms[N] = D;
  sort(froms, froms + N + 1);

  int ans = 0;
  for(int i = 0; i < M; i++)
  {
    int k;
    cin >> k;
    int *p = lower_bound(froms, froms + N + 1, k);
    int *p2 = p - 1;
    ans += min(*p - k, k - *p2);
  }
  cout << ans << endl;
  goto loop;
}

Measured memory_bytes: 1564