akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cinttypes>
#include<algorithm>
#include<queue>

using sl = std::int64_t;
int main(){
	int n;

	std::cin >> n;

	std::vector<sl> an( n );
	for( auto&e : an )
		std::cin >> e;
	

	std::sort( std::begin( an ), std::end( an ) );

	std::vector<std::pair<sl, sl>> res;
	sl ans{};
	if( an.front()*an.back() > 0 )
	{
		auto low = an.front();//ex -999 or 10
		auto high = an.back();//ex -10 or 999

		if( low < 0 )
			std::swap( low, high );

		auto t = low;
	
		
		for( int i{ 1 }; i < an.size() - 1; ++i )
		{
			res.emplace_back( t, an[i] );
			t -= an[i];
		}//tはanが負整数列なら大きい正の整数に、anが正の整数列なら大きい負の整数になる。

		auto r = high;
		if( high < 0 )
			std::swap( r, t );// always t < 0 < r

		res.emplace_back(r ,t );
		ans = r - t;
	}
	else
	{
		auto low = an.front();
		auto high = an.back();

		for( int i{ 1 }; i < n - 1; ++i )
		{
			auto ai = an[i];
			if( ai > 0 )
			{
				res.emplace_back( low, ai );
				low -= ai;
			}
			else
			{
				res.emplace_back( high, ai );
				high -= ai;
			}
		}
		res.emplace_back( high, low );
		ans = high - low;
	}

	std::cout << ans << "\n";
	for( const auto&e : res )
		std::cout << e.first << " " << e.second << "\n";


	return 0;
}


Measured memory_bytes: 4336
def main():
    S = input()
    s1, s2 = S[:2], S[2:]
    months = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
    if s1 in months and s2 in months:
        return "AMBIGUOUS"
    elif s1 in months:
        return "MMYY"
    elif s2 in months:
        return "YYMM"
    else:
        return "NA"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(long i=0;i<n;i++)
#define rn(i,n) for(long i=1;i<=n;i++)

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

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

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

  	double mul = 1;
  	double val = 0;
  	for (int i = 0; i < N; i++) {
  		if (i != N - 1)	mul *= 2;
  		val += (v[i] / mul);
      
  	}

  	cout << val;

  return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
ll L[86];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    L[0] = 2;
    L[1] = 1;
    ll sum = 0;
    for(int i = 2; i <= n; i++){
        L[i] = L[i-1] + L[i-2];
        //cout << L[i] << endl;
    }
    cout << L[n]<< endl;

    return 0;
}


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

int main(){
    int n;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    bool flag = false;
    if(std::is_sorted(v.begin(),v.end())){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<v.size();i++){
        int cur = v[i];
        for(int j=i+1;j<v.size();j++){
            swap(v[i],v[j]);
            // for(auto a:v){
            //     cout<<a<<" ";
            // }
            //cout<<endl;
            if(std::is_sorted(v.begin(),v.end())){
                flag = true;
                break;
            }
            swap(v[i],v[j]);
        }
    }
    if(!flag){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

const int MXN=50;
ll d[MXN+1][MXN+1];
vl A(MXN),B(MXN);
vl use;
int N;

void solve(int m){//mを取らないとしてみる
    rep(i,51){
        rep(j,51){
            d[i][j]=INF;//iからj
        }
        d[i][i]=0;
    }
    FOR(i,1,m){
        rep(j,51){
            d[j][j%i]=1;
        }
    }
    rep(i,use.size()){
        rep(j,51){
            d[j][j%use[i]]=1;
        }
    }
    rep(k,51){
        rep(i,51){
            rep(j,51){
                chmin(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    rep(i,N){
        if(d[A[i]][B[i]]==INF){
            use.pb(m);
            if(m==50){
                cout << -1 << endl;
                exit (0);
            }
            break;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    ROF(i,50,1){
        solve(i);
    }
    ll ans=0;
    rep(i,use.size()){
        ans+=(ll)pow(2,use[i]);
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

int main() {
  char data[] = {"aiueo"};
  char c;
  int flag = 0;

  scanf("%c", &c);

  for (int i = 0; i < 5;i++){
    if (c == data[i]) {
      flag = 1;
      break;
    }
  }
  
  if(flag == 0) {
    printf("consonant\n");
  }
  else {
    printf("vowel\n");
  }
   return 0;
}

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

#define INF (1<<31)-1
#define LINF (1LL<<63)-1LL

#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=LINF,sum=0;

    int n,k;
    cin>>n>>k;
    vector<P> po(n);

    vector<int> xl(n);
    vector<int> yl(n);

    rep(i,n){
        int x,y;
        cin>>x>>y;
        po[i] = P(x,y);
        xl[i]  =x;
        yl[i]  =y;
    }

    sort(all(xl));sort(all(yl));

    rep(a,n)rep1(b,a,n)rep(c,n)rep1(d,c,n){
        
        ll x2 = xl[b];
        ll x1 = xl[a];
        ll y2 = yl[d];
        ll y1 = yl[c];

        int cnt=0;
        rep(i,n){
            int x = po[i].fi;
            int y = po[i].se;
            
            if( x1<=x&&x<=x2 && y1<=y&&y<=y2 ){
                ++cnt;
            }
        }

        if(cnt >= k){
            chmin(ans,(x2-x1)*(y2-y1));
        }
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  int a;
  int sum=0;
  for(int i=0;i<10;i++){
    scanf("%d",&a);
    sum+=a;
  }
  
  printf("%d\n",sum);
  
  return (0);
}



Measured memory_bytes: 3212
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int x,n;
    cin>>x>>n;
    set<int>p;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        p.insert(temp);
    }
    int ans = INT_MAX;

    int v;
    for(int i=0;i<=101;i++){
        if(!p.count(i)){

            int k = abs(x-i);
            if(k<ans){
                ans= k;
                v=i;
            }
            else if(k==ans){
                if(i<v){
                    v=i;
                }
            }


        }


    }

    cout<<v;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int H = in.nextInt();
            int W = in.nextInt();
            String[] C = new String[H];
            for (int h = 0; h < H; h++) {
                C[h] = in.next();
            }

            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    char c = C[h].charAt(w);
                    System.out.print(c);
                }
                System.out.println();
                for (int w = 0; w < W; w++) {
                    char c = C[h].charAt(w);
                    System.out.print(c);
                }
                System.out.println();
            }
        }
    }
}


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

typedef struct{
  int *INFO;
  int TOP;
}Stack;

#define top(s) (s).TOP
#define infotop(s) (s).INFO[top(s)]

void push(Stack *s,int x)
{
  top(*s)++;
  infotop(*s) = x;
}

void pop(Stack *s,int *x)
{
  if(!top(*s)){
    (*x) = 0;
    return;
  }
  (*x) = infotop(*s);
  top(*s)--;
}

void init(Stack *s,int sizes)
{
  top(*s) = 0;
  (*s).INFO = calloc(sizes,sizeof(int));
}

int main(){
  int x,y;
  char s[100];
  Stack st;
  init(&st,100);
  while(scanf("%s",s) != EOF ){
    if(s[0] == '\n'){
        while(top(st) > 1){
            pop(&st,&y);
            pop(&st,&x);
            if(s[0] == '+')
                push(&st,x+y);
            else if(s[0] == '-')
                push(&st,x-y);
            else if(s[0] == '*')
                push(&st,x*y);
            else
                push(&st,x/y);
        }
    }
    else if(s[0] == '+' || s[0] == '-' || s[0] == '*' || s[0] == '/'){
        pop(&st,&y);
        pop(&st,&x);
        if(s[0] == '+')
            push(&st,x+y);
        else if(s[0] == '-')
            push(&st,x-y);
        else if(s[0] == '*')
            push(&st,x*y);
        else
            push(&st,x/y);
    }
    else
        push(&st,atoi(s));
  }
  while(top(st) > 0){
      pop(&st,&x);
      printf("%d\n",x);
  }
  return 0;
}



Measured memory_bytes: 1852
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=1e5+11;
const int M=2e6+11;
const int W=1e3+11;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;
const ld EPS=1e-9;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(s==u)a--;
  if(t==u)b--;
  cout<<a<<" "<<b;
}


Measured memory_bytes: 256
n,k = (int(x) for x in input().split())
M = 10**9+7
s = 0

for i in range(n+2-k):
    ad = 1 + (n+1-k-i)*(k+i)
    s += ad
#if s >= M:
#    s -= M
        
print(s%M)

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

//境界値に注意！！！

int main() {
    string s;
    cin >> s;
    for (int i=0;i<s.size();++i){
        if (i%2==0){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			String s = sc.next();
			int k = sc.nextInt() - 1;

			for (char c = 'a'; c <= 'z'; c++) {
				int index = -1;
				TreeSet<String> ts = new TreeSet<>();
				while ((index = s.indexOf(c, index + 1)) >= 0) {
					for (int i = index; i < s.length() && i <= index + 5; i++) {
						ts.add(s.substring(index, i + 1));
					}
				}
				if (k < ts.size()) {
					List<String> list = new ArrayList<>(ts);
					out.println(list.get(k));
					break;
				}
				k -= ts.size();
			}

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.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 byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

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

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte 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();
			}
		}

	}
}



Measured memory_bytes: 22484
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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



int main(void) {
	int a, b, c;

	cin >> a >> b >> c;

	cout << a * b / 2 << endl;


	return 0;
}

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

int main()
{
	long long N;
	cin >> N;

	string ans;
	while( N > 0 ) {
		int n = N % 26;
		if( n == 0 ) {
			ans += 'z';
			N--;
			N /= 26;
		}
		else {
			ans += 'a' + (n - 1);
			N /= 26;
		}
	}
	reverse( ans.begin(), ans.end() );

	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	vector<ll> sum(n + 1, 0LL);
	for(int i = 0; i < n; ++i) {
		sum[i + 1] = sum[i] % MOD_LL + a[i] % MOD_LL;
		sum[i + 1] %= MOD_LL;
	}
	
	ll ans = 0LL;
	for(int i = 0; i < n - 1; ++i) {
		ans += (a[i] % MOD_LL) * ((sum[n] - sum[i + 1]) % MOD_LL);
		ans %= MOD_LL;
	}
	
	if( ans < 0 ) ans += MOD_LL;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6372
n=int(input())
a=[0]+list(map(int, input().split()))+[0]
cost=[abs(a[i+1]-a[i]) for i in range(n+1)]
s=sum(cost)
for i in range(1, n+1):
    print(s-cost[i]-cost[i-1]+abs(a[i-1]-a[i+1]))


Measured memory_bytes: 14040
"""
created 2020-05-11
"""
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*uvw = map(int, read().split())

    E = [[] for _ in range(N+1)]
    for u, v, w in zip(*[iter(uvw)]*3):
        E[u].append((v, w))
        E[v].append((u, w))
    
    color = [-1] * (N+1)
    color[1] = 0
    
    d = [-1] * (N+1)
    d[1] = 0
    def dfs(s):
        stack = [s]

        while stack:
            v = stack.pop()
            for e, w in E[v]:
                if d[e] == -1:
                    d[e] = d[v] + w
                    if d[e] % 2 == 0:
                        color[e] = 0
                    else:
                        color[e] = 1
                    stack.append(e)
    
    dfs(1)

    print(*color[1:], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 47596
import itertools
import math
n = int(input())
x,y = [],[]
for i in range(n):
    x_y_str = input()
    x.append(int(x_y_str.split(" ")[0]))
    y.append(int(x_y_str.split(" ")[1]))
tmp_dist = 0
for i in itertools.permutations(range(n)):  # 0, 1, 2
    tmp = None
    for node in list(i):
        if tmp == None:
            tmp = node
        else:
            tmp_dist += math.sqrt(pow(x[tmp]-x[node],2)+pow(y[tmp]-y[node],2))
            tmp = node
print(tmp_dist/math.factorial(n))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

#define ODD true
#define EVEN false

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

void disp(lli *x, int n)
{
	rep(i, 0, n)cout << x[i] << " ";
}

void back_disp(lli *x, int n)
{
	for(int i=n-1;i>=0;i--)cout << x[i] << " ";
}

int main(void)
{
	int n; cin >> n;
	vector<lli> a(n); rep(i, 0, n)cin >> a[i];

	if (n == 1)cout << a[0] << endl;
	else {
		vector<lli> odd((n + 1) / 2), even(n / 2);
		int j = 0;
		for (int i = 0; i < n; i += 2)odd[j++] = a[i];
		j = 0;
		for (int i = 1; i < n; i += 2)even[j++] = a[i];

		if (n % 2 == 0) {
			back_disp(&even[0], even.size());
			disp(&odd[0], odd.size());
			cout << endl;
		}
		else {
			back_disp(&odd[0], odd.size());
			disp(&even[0], even.size());
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
long long int MOD = 1000000007;
using namespace std;
//g++ -std=c++14
//setprecision(10)
int main(){
	string s;	cin >> s;
	string yuki = "YAKI";
	for(int i = 0; i < 4; i++){
		if(s[i] != yuki[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   int a2=a%10;
   if(a2==0){
       a2=10;
   }
   int b2=b%10;
   if(b2==0){
       b2=10;
   }
   int c2=c%10;
   if(c2==0){
       c2=10;
   }
   int d2=d%10;
   if(d2==0){
       d2=10;
   }
   int e2=e%10;
   if(e2==0){
       e2=10;
   }
   int sum=0;
   sum+=((a-1)/10+1)*10;
   sum+=((b-1)/10+1)*10;
   sum+=((c-1)/10+1)*10;
   sum+=((d-1)/10+1)*10;
   sum+=((e-1)/10+1)*10;
   cout<<sum-10+min({a2,b2,c2,d2,e2})<<endl;
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        
        int A = nextInt();//health 
        int B = nextInt();//strength 
        int C = nextInt();
        int D = nextInt();
 
        int fistround = C;
        int nextround = A;

        while(fistround>0 || nextround>0){
            fistround -=B;
            if(fistround<=0){
                System.out.println("Yes");
                return;
            }
    
            nextround -=D;
            if(nextround<=0){
                System.out.println("No");
                return;
            }
        }
        
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32656
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


int main(){
    ll n,k;
    cin >> n >> k;
    ll h[n];
    for (ll i=0;i<n;i++)cin >> h[i];
    ll dp[n];
    fill(dp,dp+n,INF);
    dp[0]=0;
    for (ll i=1;i<n;i++){
        for (ll j=1;j<=min(k,i);j++){
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 1000000007;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
	COMinit();
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	cout << n - k + 1 << endl;
	for (int i = 1; i < k; i++) {
		ans = COM(2 + (n - k) - 1, (n - k) - i) * COM(k - 1, i) % 1000000007;
		cout << ans << endl;
	}
}


Measured memory_bytes: 8288
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//
var (
	N int
	M int
	R int
	r []int
	d [][]int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func fillInts(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}

func warshallFloyd(n int, d [][]int) {
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}
}

func swap(a []int, i int, j int) {
	x, y := a[i], a[j]
	a[i], a[j] = y, x
}

func permtationsImpl(a []int, i int, f func(a []int)) {
	if i == len(a)-1 {
		f(a)
		return
	}
	permtationsImpl(a, i+1, f)
	for j := i + 1; j < len(a); j++ {
		swap(a, i, j)
		permtationsImpl(a, i+1, f)
		swap(a, i, j)
	}
}

func permtations(a []int, f func(a []int)) {
	permtationsImpl(a, 0, f)
}

func main() {
	defer flush()

	N = readInt()
	M = readInt()
	R = readInt()
	r = make([]int, R)
	for i := 0; i < R; i++ {
		r[i] = readInt()
	}

	d = make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		d[i] = make([]int, N+1)
		fillInts(d[i], math.MaxInt32)
		d[i][i] = 0
	}

	for i := 0; i < M; i++ {
		A := readInt()
		B := readInt()
		C := readInt()
		d[A][B] = C
		d[B][A] = C
	}
	warshallFloyd(N+1, d)

	result := math.MaxInt64
	permtations(r, func(a []int) {
		t := 0
		for i := 0; i < R-1; i++ {
			t += d[a[i]][a[i+1]]
		}
		result = min(result, t)
	})
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500010;
const int MOD = 1000000007;
int N,C[MAXN],sum[MAXN];
int dp[MAXN][2];
int inc(int a,int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int mul(int a,int b) { return 1LL * a * b % MOD; }
int main() {
	scanf("%d",&N);for (int i=1;i<=N;i++)scanf("%d",&C[i]);
    dp[0][0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
        dp[i][0] = inc(dp[i - 1][1],dp[i - 1][0]);
        if(C[i] != C[i - 1]) {
            dp[i][1] = sum[C[i]];
            sum[C[i]] = inc(sum[C[i]],dp[i][0]);
        }
    }
    printf("%d\n",inc(dp[N][0],dp[N][1]));
	return 0;
}

Measured memory_bytes: 6400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#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)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
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;}}

typedef pair<ll, string> IS;

string s;
map<IS, ll>dp;
set<string>S[202020];

int main(){
    cin >> s;
    S[0].insert("");
    rep(i, s.size()){
        for(set<string>::iterator it = S[i].begin(); it != S[i].end(); it++){
            string lst = (*it);
            ll score = dp[IS(i, lst)];
            // cout << i << " : " << lst << " -> " << score << endl;
            string t = "";
            t += s[i];
            if(t != lst){
                S[i + 1].insert(t);
                chmax(dp[IS(i + 1, t)], score + 1);
            }
            if(i + 1 < s.size()){
                t += s[i + 1];
                if(t != lst){
                    S[i + 2].insert(t);
                    chmax(dp[IS(i + 2, t)], score + 1);
                }
            }
        }
    }
    ll ans = -1;
    for(set<string>::iterator it = S[s.size()].begin(); it != S[s.size()].end(); it++){
        string lst = (*it);
        chmax(ans, dp[IS(s.size(), lst)]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 72452
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=2e3+23;
  const int M=2e4;
  
 
 int ct[N];
 void fft()           
 { 
   int n,x,y;  cin>>n>>x>>y;

   for(int i=1;i<=n;++i){

     for(int j=i+1;j<=n;++j){

         int mn=j-i;
         mn=min(mn,abs(x-i)+1+abs(y-j));
         mn=min(mn,abs(y-i)+1+abs(x-j));
         ct[mn]++;
     }
   }

   for(int i=1;i<n;++i) cout<<ct[i]<<nl;
    
 }

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

   
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<tc)
   cout<<nl;
  }
  
 return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 0, x = 0, y = n, f=0, r=0, w=0;
    forn(i, 0, n){
        if(s[i]=='R')r++;
        else w++;
    }
    if(r==0 || w==0){
        cout<<"0"<<endl;
        return 0;
    }

    forn(i, 0, n){
        if(i>=y){
            break;
        }
        if(s[i] == 'W'){
            for(ll j=y-1;j>=0;j--){
                if(s[j] == 'R'){
                    if(j>i){
                        // cout<<i<<" "<<j<<endl;
                        y=j;
                        // swap(s[i], s[j]);
                        ans++;
                        break;

                    }
                    else{
                        f=1;
                        break;
                    }
                }
            }
            if(f){
                break;
            }
        }
    }
    // cout<<s<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

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

int main()
{
	string S, T;
	cin >> S >> T;

	unordered_map<char, char> table1, table2;

	string ans = "Yes";
	rep(i, S.size())
	{
		if (table1.find(S[i]) == table1.end())
		{
			table1[S[i]] = T[i];
		}
		else
		{
			if (table1[S[i]] != T[i])
			{
				ans = "No";
				break;
			}
		}

		if (table2.find(T[i]) == table2.end())
		{
			table2[T[i]] = S[i];
		}
		else
		{
			if (table2[T[i]] != S[i])
			{
				ans = "No";
				break;
			}
		}
	}

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

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

void solve() {
   string s, t;
   cin >> s >> t;
   int n = s.length(), m = t.length();
   int ans = m;
   for (int i = 0; i < n - m + 1; i++) {
      int tm = 0;
      for (int j = 0; j < m; j++) {
         tm += (s[i + j] != t[j]);
      }
      ans = min(ans, tm);
   }
   cout << ans << '\n';
}

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   solve();

   return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.lines()
                .map(line -> Arrays.stream(line.split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray())
                .forEach(tokens -> {
                 int a = tokens[0];
                 int b = tokens[1];
                 int c = tokens[2];
                 
                    if(a+b>=c){
                         System.out.println("Yes");
                    }else{
                        System.out.println("No");
                        }
                 
                });
        

        }
    }
}

Measured memory_bytes: 28628
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[150];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    double ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=1.0/a[i];
    }
    ans=1/ans;
    printf("%.20lf\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<list>
using namespace std;
int main(){
	int n,q,key,t,x;
	cin>>n>>q;
	list<int> Q[1002];
	list<int>::iterator itr;
	for(int i=0;i<q;i++){
		cin>>key>>t;
		if(key==0){
			cin>>x;
			Q[t].push_back(x);
		}else if(key==1){
			for(itr=Q[t].begin();itr!=Q[t].end();++itr){
				if(itr!=Q[t].begin()) cout<<" ";
				cout<<*itr;
			}
			cout<<endl;
		}else{
			cin>>x;
			Q[x].splice(Q[x].end(),Q[t]);
		}
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> arr(n);
    for(int i = 0; i < n; ++i)cin >> arr[i];
    ll ans = 0;
    for(int i = 1; i < n; ++i)ans=__gcd(ans,arr[i]);
    for(ll i = 1; i*i <= arr[0]; ++i){
        if(arr[0]%i == 0){
            int k = 0;
            for(int j = 1; j < n; ++j){
                if(arr[j]%i == 0)k++;
            }
            if(k >= n-2){
                ans = max(ans,i);
            }
            k = 0;
            ll f = arr[0]/i;
            for(int j = 1; j < n; ++j){
                if(arr[j]%f == 0)k++;
            }
            if(k >= n-2){
                ans = max(ans,f);
            }
        }
    }
    cout << ans;
   return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;cin>>N>>M;
vector<int> a;int x;
for(int i=0;i<M;i++){
cin>>x; a.push_back(x);}
int sum=0;
for(auto y:a){sum+=y;
}
if(sum>N){cout<<-1;

} else cout<<N-sum;






}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll N, K;
    cin >> N >> K;
    vll x(N);
    for(auto &a:x) cin >> a;
    ll ans = 0;
    REP(i, N) {
        ans += 2 * min(x[i], abs(K - x[i]));
    }
    out(ans);
}

int main() {
    fast_io;
    solve();
    return 0;
}


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

int main()
{

  int n, k;
  cin >> n >> k;
  int x = k - n + 1;
  int cnt = 0;
  n = n * 2 - 1;
  while (cnt < n){
    cout << x << " ";
    cnt++;
    x++;
  }
  cout << endl;
  return 0;
}

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

using namespace std;
#define sc(x) scanf("%lld", &x);
#define pr(x) printf("%lld\n", x);
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[1005], maxx;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
            maxx = max(maxx, abs(x[i] - x[j]));
    }
    cout<<maxx<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
ll N,M;


//解法
void solve() {

	if (N >= 2 && M >= 2) {
		cout << (N - 2)*(M - 2);
		return;
	}
	if (N == 1 && M == 1) {
		cout << 1;
		return;
	}
	if (N == 1) {
		cout << M - 2;
		return;
	}
	if (M == 1) {
		cout << N - 2;
		return;
	}

	return;
}

int main() {
	//入力
	cin >> N >> M;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import math
n,d=map(int,input().split())
L=[]
for i in range(n):
   L.append(list(map(int,input().split())))
c=0
for j in range(n):
    for k in range(j+1,n):
        s=pow(sum([(L[j][m]-L[k][m])**2 for m in range(d)]),0.5)
        if math.ceil(s)==math.floor(s):
            c+=1
print(c)

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(void)
{
   int i, a, b, k;
  
   scanf("%d", &a);
   scanf("%d", &b);
 
   if( a%2 != b%2 ) printf("IMPOSSIBLE");
   else             printf("%d", (a+b)/2) ;
  
   return 0;
}

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

		long n = sc.nextLong();
		long d = sc.nextLong();

		long d2 = d*d;

		long g = 0;
		for ( int i=0; i<n; i++ ) {
			long x = sc.nextLong();
			long y = sc.nextLong();

			long x2 = x*x;
			long y2 = y*y;
			if ( d2 >= x2+y2 ) g++;
		}
		System.out.println(g);
	}
}

Measured memory_bytes: 60520
# 問題文

# 英大文字のみからなる長さ Nの文字列 Sがあります。
# Sの連続する部分列 (入出力例をご覧ください) として 
# ABC がいくつ含まれるかを求めてください。

# 制約
# 3 ≤ N ≤ 50
# Sは英大文字のみからなる。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S

# 出力
# Sが連続する部分列として含む ABC の個数を出力せよ。

N = int(input())
S = input()

count = 0
for i in range(N - 2):
    if S[i] + S[i + 1] + S[i + 2] == 'ABC':
        count += 1

print(count)

Measured memory_bytes: 2940
//Sum of Large Numbers

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()
const int inf = 1000000000;

int main (){
    ll N, K; cin >> N >> K;
    ll x=0,y=0,c=0;
    rep(i,0,N){
        x+=i;
        y+=N-i;
        c+=y-x+1;
    }
    c++;//すべてを使う組み合わせ
    ll p=0,q=0,r=0;
    rep(j,0,K-1){
        p+=j;
        q+=N-j;
        r+=q-p+1;
    }
    cout << (c-r)%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 3636
function Main(input) {
    var D = input.split("\n")[0] - 0;
    var str;
    switch (D) {
    case 7: 
    case 5:
    case 3:
        str = 'YES';
        break;
    default:
        str = 'NO';
    }

    console.log(str);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
h,w=map(int,input().split())
disp=['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']
for i in range(h):
  arr=list(map(str,input().split()))
  for j in range(w):
    if arr[j]=='snuke':
      print(disp[j]+str(i+1))

Measured memory_bytes: 3064
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <string.h>
typedef long long ll;
const int INF = 1e9+7;

char str[1024];
char p[1024];

void cmd_p(int a, int b) {
	int i;
	for (i = a; i <= b; i++) {
		putchar(str[i]);
	}
	putchar('\n');
}

void cmd_rev(int a, int b) {
	int i;
	char c;
	for (i = a; i <= (a+b)/2; i++) {
		c = str[i];
		str[i] = str[b - i + a];
		str[b - i + a] = c;
	}
}

void cmd_rplc(int a, int b) {
	int i;

	scanf("%s", p);
	for (i = a; i <= b; i++) {
		str[i] = p[i - a];
	}
}

int main(int argc, char **argv)
{
	int q, a, b;
	char cmd[32];

	scanf("%s %d", str, &q);
	while (q--) {
		scanf("%s %d %d", cmd, &a, &b);
		if (strcmp(cmd, "print") == 0) {
			cmd_p(a, b);
		} else if (strcmp(cmd, "reverse") == 0) {
			cmd_rev(a, b);
		} else {
			cmd_rplc(a, b);
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <math.h>

int main(void) {
	_Bool flag[60000];
	int i, j;
	int n;
	memset(flag, 0, sizeof(flag));
	for (i = 2; i <= 3 || i <= sqrt(60000); i++) {
		for (j = 2; i*j <= 60000; j++) {
			flag[i*j-1] = 1;
		}
	}
	while (scanf("%d", &n) != EOF) {
		for (i = n-1; i >= 2 ;i--) {
			if (!flag[i-1]) {
				printf("%d ", i);
				break;
			}
		}
		for (i = n+1; i <= 60000; i++) {
			if (!flag[i-1]) {
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 660
#include<iostream>
using namespace std;
int h,w;
char s[55][55];
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cin>>s[i][j];
    }
    for(int i=0;i<h;++i){
        
        for(int k=0;k<w;k++){
            int cnt=0;
          	if(s[i][k]=='#')continue;
            for(int j=0;j<8;++j){
                int a=i+dx[j];
                int b=k+dy[j];
                if(0>a || a>=h || 0>b || b>=w)continue;
                if(s[a][b]=='#')cnt++;
            }
            s[i][k]=cnt+'0';
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cout<<s[i][j];
      	cout<<endl;
    }
}

Measured memory_bytes: 256
public class Main {

    public static void main(String[] args) {
        final String line = readLine();
        System.out.println(calc(line));
    }

    protected static String calc(String input) {
        final int[] ia = split(input);

        final int a = ia[0];
        final int b = ia[1];
        final int c = ia[2];

        int count = 0;
        for (int i = a; i <= b; i++) {
            if ((c % i) == 0) {
                count++;
            }
        }

        return String.valueOf(count);
    }

    private static int[] split(String s) {
        final String[] s0 = s.split(" ");
        int[] ia = new int[s0.length];

        for (int i = 0; i < s0.length; i++) {
            ia[i] = Integer.parseInt(s0[i]);
        }

        return ia;
    }

    private static String readLine() {
        java.util.Scanner s = null;
        try {
            s = new java.util.Scanner(System.in);
            return s.nextLine();
        } finally {
            if (s != null) {
                s.close();
            }
        }
    }
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll c(int a, int b){
  ll ans=1;
  ll m=1;
  if(a==0) return 1;
  for(int i=0; i<b; i++){
    ans *=a;
    a--;
    m *=(i+1);
  }
  ans /=m;
  return ans;
}
int main(){
  string s;
  int k;
  cin>>s>>k;
  int n=s.size();
  ll ans=0;
  int a=s.at(0) - '0';
  int nin=1;
  for(int i=0 ; i<k ; i++){
    nin *= 9;
  }
  if(n<k){
    cout<<0<<endl;
    return 0;
  }
  else{
    int count=0;
    int keta=0;//ketaは左からk桁のときk-1
    while(count<k&&keta<n){
      int tmp=s.at(keta)-'0';
      if(tmp==0){
        keta++;
        continue;
      }
      else if(tmp==1){
        ans +=nin*c(n-keta-1,k-count);
        count++;
        nin/=9;
        keta++;
      }
      else{
        ans += (tmp-1)*(nin/9)*c(n-keta-1,k-count-1)//1~b-1
          +nin*c(n-keta-1,k-count)*min(1,n-keta-1);//0
        count++;
        nin/=9;
        keta++;
      }
      
    }
    if(count==k) ans++;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String n = scan.nextLine();
		String m = scan.nextLine();

		char[] a = n.toCharArray();
		char[] b = m.toCharArray();

		int total = 0;

		for(int i=0;i<3;i++) {
			if(a[i]==b[i]) {
				total+=1;
			}
		}

		System.out.println(total);

	}

}

Measured memory_bytes: 21844