akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

tmp = []
tmp.append(a % 10)
tmp.append(b % 10)
tmp.append(c % 10)
tmp.append(d % 10)
tmp.append(e % 10)

for id, item in enumerate(tmp):
    if item == 0:
        tmp[id] = 10

tmp.sort()
ans = 0

if a % 10 == 0:
    ans += a
else:
    a = (a // 10 + 1) * 10
    ans += a

if b % 10 == 0:
    ans +=  b
else:
    b = (b // 10 + 1) * 10
    ans += b

if c % 10 == 0:
    ans +=  c
else:
    c = (c // 10 + 1) * 10
    ans += c 

if d % 10 == 0:
    ans +=  d
else:
    d = (d // 10 + 1) * 10
    ans += d

if e % 10 == 0:
    ans += e
else:
    e = (e // 10 + 1) * 10
    ans += e
ans -= 10
ans += tmp[0]

print(ans)


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

int main(){
    string s;
    int blue=0,red=0;
    cin>>s;
    int sum=s.size();
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            red++;
        }
        else if(s[i]=='1'){
            blue++;
        }
    }
    cout<<sum-(max(blue,red)-min(blue,red))<<endl;
}

 

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    string str;
    cin >> str;

    if (str == string(3, 'A') || str == string(3, 'B'))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define pb push_back
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18

/*ll power(int a, int b){
    return (ll)(pow(a,b)+0.5);
}*/

vector<int> gV(int n){
    vector<int> v;
    int input;
    fo { cin>>input; v.pb(input); }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void secondThreadApproach(){
    int H,W,K;
    cin>>H>>W>>K;
    char** arr= new char*[H];
    for(int i=0;i<H;i++){
        arr[i]=new char[W];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>arr[i][j];
        }
    }

    int range = (1<<(H+W))- 1;                //2^(H+W)-1
    int ans=0;                              //int as ans can be at max 2^(H+W) and H,W<=6

    for(int mask=0;mask<=range;mask++){
        int count=0;
//        cout<<"--------------------------"<<endl;
        for(int i=0;i<W;i++){
            for(int j=0;j<H;j++){
                if(arr[j][i]!='#') continue;
//                cout<<mask<<"\t"<<(1<<i)<<"|"<<(1<<(W+j))<<" = "<<((1<<i)| (1<<(W+j)))<<endl;
                if((mask&((1<<i)| (1<<(W+j))))!=0) continue;
                count++;
            }
        }
//        cout<<"Count was "<<count<<endl;
//        cout<<"--------------------------"<<endl;
        if(count==K)
            ans++;
    }

    cout<<ans<<endl;
}

//https://atcoder.jp/contests/abc173/tasks/abc173_c
void solve(){
    int H,W,K;
    cin>>H>>W>>K;
    char** arr= new char*[H];
    for(int i=0;i<H;i++){
        arr[i]=new char[W];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>arr[i][j];
        }
    }

    int range = (1<<H+W)- 1;                //2^(H+W)-1
    ll ans=0;
    for(int i=0;i<=range;i++){
        int t=i,count=0;
        map<int,bool> row;
        map<int,bool>col;
        while(t>0){
            if(t&1==1){
                if(count<W) col[count]=true;
                else row[count-W]=true;
            }
            t=t>>1;
            count++;
        }

        ll temp=0;
        for(int p=0;p<H;p++){
            if(row[p]) continue;
            for(int q=0;q<W;q++){
                if(col[q]) continue;
                if(arr[p][q]=='#') temp++;
            }
        }
        if(temp==K) ans++;

    }

    cout<<ans<<endl;




}




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

    secondThreadApproach();
    //solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3540
n=int(input())
a=list(map(int,input().split()))
d={}
l=[]
for i in range(n):
    try:
        d[a[i]]+=1
    except:
        d[a[i]]=1
        l.append(a[i])

ans=0
for i in range(len(l)):
    if d[l[i]]>l[i]:
        ans+=d[l[i]]-l[i]
    elif d[l[i]]<l[i]:
        ans+=d[l[i]]
print(ans)


Measured memory_bytes: 17780
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	string s;
	cin >> s;
	map<string, string>m;
	m["Sunny"] = "Cloudy";
	m["Cloudy"] = "Rainy";
	m["Rainy"] = "Sunny";
	cout << m[s];
}
	

Measured memory_bytes: 3020
n,k,q = map(int,input().split())
ok = [ 0 for i in range(n) ]
init= [ k for i in range(n) ]
for i in range(q):
    x = int(input())
    x -= 1
    ok[x] += 1

for i in range(n):
    init[i] = init[i] - (q) + ok[i]
    if init[i] > 0:
        print("Yes")
    else:
        print("No")
            


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

using namespace std;

int gcd(int x,int y){
    //xを大
    if(x<y){
        int tmp=y;
        y=x;
        x=tmp;
    } 

    if(x%y==0) return y;
    return gcd(y,x%y);
}

int Agcd(int *A,int i){
    if(i==2) return gcd(*(A+1),*(A+2));
    return gcd(*(A+i),Agcd(A,i-1));
}

int main(){
    int N; cin>>N;
    int A[100001];

    for(int i=1;i<=N;i++) scanf("%d",&A[i]);

    printf("%d",Agcd(A,N));

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;



int main(){
	char c[3][3];
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < 3; i++){
		cout << c[i][i];
	}
	cout << endl;
	return 0;
}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long seisu = scan.nextLong();
		long syou = 0;
		long a = 0,b = 0;
		long re = Long.MAX_VALUE;

		for(int i=1;i<=Math.sqrt(seisu);i++) {

			if(seisu%i==0) {
				a = i;
			b = seisu/i;
			}
		re = Math.min(re,a+b-2);
		}
		System.out.println(re);
		scan.close();

	}

}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 110;



map<pair<int,string>,ll> mp;
int n;
string s;

bool good(string buf) {
    if (buf.find("agc")!=string::npos) return false;
    for (int i=0; i<3; i++) {
	swap(buf[i],buf[i+1]);
	if (buf.find("agc")!=string::npos) return false;
	swap(buf[i],buf[i+1]);
    }
    return true;
}


ll dfs(int i, string last3) {
    if (i==n) return 1;
    if (mp.count({i,last3})) return mp[{i,last3}];

    ll res=0;
    string lets="actg";
    for (char c: lets) {
	string buf=last3+string(1,c);
	if (good(buf)) {
	    res += dfs(i+1,buf.substr(1));
	    res %= mod;
	}
    }
    res %= mod;
    return mp[{i,last3}]=res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    ll ans=dfs(0,"ttt");
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout<<ans<<endl;
    return 0;
}


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

int dp[17][17];
int road[17][17];

int main()
{
    int a, b;
    int n;
    while(cin >> a >> b && a && b) {

        for(int i = 0; i <= b; i++) 
            for(int j = 0; j <= a; j++) 
                dp[i][j] = road[i][j] = 0;

        cin >> n;
        int x, y;
        for(int i = 0; i < n; i++) {
            cin >> x >> y;
            road[y][x] = 1;
        }
        
        for(int i = 1; i <= b; i++) {
            for(int j = 1; j <= a; j++) {
                if(i == 1 && j == 1) {
                    dp[i][j] = 1;
                } else {
                    dp[i][j] = (road[i][j]) ? 0 : dp[i-1][j] + dp[i][j-1];
                }
            }
        }

        cout << dp[b][a] << endl;

    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll pow(ll n){
	ll ans = 1;
	while(n > 0){
		ans *= 10;
		n--;
	}
	return ans;
}

int main(){
	string S;
	cin >> S;
	ll N = 0; 
	ll sum = 0;
	for (ll i = 0;i < S.size();i++){
		N += (pow(i) * (S[S.size() - 1 - i] - '0'));
		sum += (S[i] - '0');
	}

	if (N % sum == 0){
		cout << "Yes" <<endl;
	}
	else{
		cout <<"No" <<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		int r = 0, l;
		int[] a = new int[s.length];
		for (int i = 0; i < s.length - 1; i++) {
			if (s[i] == 'R' && s[i + 1] == 'L') {
				a[i]++;
				a[i + 1]++;

				for (int j = r; j < i; j++) {
					if ((i - j) % 2 == 0) {
						a[i]++;
					} else {
						a[i + 1]++;
					}
				}

				for (int j = i + 2; j < s.length; j++) {
					if (s[j] == 'L') {
						if ((j - i) % 2 == 0) {
							a[i]++;
						} else {
							a[i + 1]++;
						}
					} else {
						i = j - 1;
						r = i + 1;
						break;
					}
				}
			}
		}
		sb.append(a[0]);
		for (int i = 1; i < s.length; i++) {
			sb.append(" " + a[i]);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 44496
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

int const mod = 1e9 + 7;
namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b){
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 2e5 + 5;


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b; cin >> a >> b;
	vector<ll>v = { a + b, a - b, a * b };
	cout << *max_element(all(v));
	return 0;
}
/*

*/


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		long[][] ab = new long[n][2];
		long[][] cd = new long[m][2];
		
		for (int i = 0; i < n; i++) {
			ab[i][0] = sc.nextLong();
			ab[i][1] = sc.nextLong(); 
		}
		
		for (int i = 0; i < m; i++) {
			cd[i][0] = sc.nextLong();
			cd[i][1] = sc.nextLong();
		}
		
		int[] result = new int[n];
		
		for (int i = 0; i < n; i++) {
			long length = 0;
			long min = 200000000;
			for (int j = 0; j < m; j++) {
				length = Math.abs(ab[i][0]-cd[j][0]) + Math.abs(ab[i][1] - cd[j][1]);
				if (length < min ) {
					min = length;
					result[i] = j;
				}
				
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(result[i]+1);
		}

	}

}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main(void){
	
	int n;
	
	cin>>n;
	
	for(int i=1;i<=n;i++){
		int x=i;
		if(x%3==0)
			cout<<" "<<i;
		else{
			while(x!=0){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				x/=10;
			}
		}
		
	}
	cout<<endl;
	
}

Measured memory_bytes: 2984
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

ll a[300010];
priority_queue<ll> bque;
priority_queue<ll, vector<ll>, greater<ll> > aque;
int main(){
    int N;
    cin >> N;
    FOR(i,0,3*N) cin >> a[i];
    ll asum[N+1];
    ll bsum[N+1];
    asum[0] = 0;
    bsum[0] = 0;
    FOR(i,0,N){
        aque.push(a[i]);
        bque.push(a[3*N-1-i]);
        asum[0] += a[i];
        bsum[0] += a[3*N-1-i];
    }
    FOR(i,0,N){
        // 左側について
        aque.push(a[N+i]);
        asum[i+1] = asum[i] + a[N+i];
        asum[i+1] -= aque.top();
        aque.pop();

        //右側について
        bque.push(a[2*N-1-i]);
        bsum[i+1] = bsum[i] + a[2*N-1-i];
        bsum[i+1] -= bque.top();
        bque.pop();
    }
    ll ans = -1e14;
    FOR(i,0,N+1){
        ans = max(ans, asum[i] - bsum[N-i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool cmp(pair<int,int> a, pair<int,int> b) {
  return a.first*a.second<b.first*b.second;
}

int main(){
  int n,w,d;
  while(cin >> n >> w >> d, w) {
    vector<pair<int,int> > cakes;
    cakes.push_back(make_pair(w,d));
    while(n--) {
      int p,s; cin >> p >> s; --p;
      int nw=cakes[p].first,nd=cakes[p].second;
      cakes.erase(cakes.begin()+p);
      s%=nw+nd;
      pair<int,int> p1,p2;
      if(s<nw) {
	p1=make_pair(s,nd);
	p2=make_pair(nw-s,nd);
      } else {
	p1=make_pair(nw,s-nw);
	p2=make_pair(nw,nd-(s-nw));
      }
      if(p1.first*p1.second<p2.first*p2.second) {
	cakes.push_back(p1); cakes.push_back(p2);
      } else {	
	cakes.push_back(p2); cakes.push_back(p1);
      }
    }
    sort(cakes.begin(),cakes.end(),cmp);
    for(int i=0;i<cakes.size();++i) {
      if(i) cout << " ";
      cout << cakes[i].first*cakes[i].second;
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
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); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
ll n,m; 
inline void _Sol_()
{
	read(n);read(m);
	if(n==1||m==1)priE(1);else
	priE((n*m+1)/2); 
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> ret(m, 0);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            ret[a - 1]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < m; ++i) {
        if (ret[i] == n)
            cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int N;
int L[102];
int mask[102];
ll dp[102][1<<16];

ll dfs(int a,int b) {
    if(a==N) return 0;
    if(dp[a][b]!=-1) return dp[a][b];

    ll res=0;
    res=max(res,dfs(a+1,b));
    if((b&mask[a])==0)
        res=max(res,dfs(a+1,b|mask[a])+L[a]);

    return dp[a][b]=res;
}

void solve() {
    rep(i,102) mask[i]=0;
    memset(dp,-1,sizeof(dp));
    rep(i,N) {
        int m;
        cin>>m>>L[i];
        rep(j,m) {
            int s,e;
            cin>>s>>e;
            s-=6;
            e-=6;
            for(int k=s;k<e;k++) mask[i] |= 1<<k;
        }
    }
    cout<<dfs(0,0)<<endl;


}

int main() {
    while(cin>>N) {
        if(!N) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 53388
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    vector<string> S(3);
    for(int i = 0; i < 3; i++){
        cin >> S[i];
    }
    
    int A_now = 0, B_now = 0, C_now = 0;
    int now = S[0][0] - 'a';
    if(now == 0){
        now = S[0][A_now++] - 'a';
    }
    else if(now == 1){
        now = S[1][B_now++] - 'a';
    }
    else{
        now = S[2][C_now++] - 'a';
    }
    
    
    while(A_now <= S[0].length() && B_now <= S[1].length() && C_now <= S[2].length()){
        if(now == 0){
            if(A_now == S[0].length()){
                cout << "A\n";
                return 0;
            }
            now = S[0][A_now++] - 'a';
        }
        else if(now == 1){
            if(B_now == S[1].length()){
                cout << "B\n";
                return 0;
            }
            now = S[1][B_now++] - 'a';
        }
        else{
            if(C_now == S[2].length()){
                cout << "C\n";
                return 0;
            }
            now = S[2][C_now++] - 'a';
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int main()
{
    int a, b; cin >> a >> b;
    float ave = (a + b) / 2.0;
    int ans = ceil(ave);
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=[0]*(10**5+1)
for i in a:
  ans[i]+=1
res=sum(a)
for _ in range(q):
  b,c=map(int,input().split())
  ans[c]+=ans[b]
  res-=ans[b]*b
  res+=ans[b]*c
  ans[b]=0
  print(res)

Measured memory_bytes: 84176
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        long sum = 0;
        Map<Long, Long> map = new HashMap<>();
        map.put(0L, 1L);
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (map.containsKey(sum)) {
                cnt += map.get(sum);
            }
            map.put(sum, map.getOrDefault(sum, 0L) + 1);
        }
        System.out.println(cnt);
    }

}


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

int main() {
	int A, B, N, P1, P2;
	cin >> N >> A >> B;
	P1 = A * N;
	P2 = B;
	if (P1 < P2) {
		cout << P1 << endl;
	}
	else {
		cout << P2 << endl;
	}
}

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

int main() {
  int n; cin >> n;
  string s,t; cin >> s >> t;
  rep(i,n){
   cout << s[i] << t[i]; 
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll  long long int
#define mod 1000000007
using namespace std;

main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	ll suff[n];
	suff[n-1]=0;
	for(ll i=n-2;i>=0;i--)
	{
		suff[i]=suff[i+1]+a[i+1];
		suff[i]=suff[i]%mod;
	}
	for(ll i=0;i<n;i++)
	{
		ll is = suff[i]*a[i];
		is%=mod;
		ans+=is;
		ans%=mod;
	}
	while(ans<0)
	{
		ans+=mod;
	}
	ans = (ans%mod);
	cout<<ans<<endl;
		
}

Measured memory_bytes: 6668
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;
ll A[10010];
ll ans;

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
  {
    scanf( "%lld", A+i );
  
    while( A[i] % 2 == 0 )
      A[i] /= 2, ++ans;
  }

  printf( "%lld\n", ans );
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string A;
  cin>>A;
  if(A.size()%2==1) cout<<"No\n";
  else{
    bool c=true;
    for(int i=0; i<A.size()-1; i+=2){
      if(A[i]=='h' && A[i+1]=='i') continue;
      else {cout<<"No\n"; c=false; break;}
    }
    if(c) cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=c&&a-c<=d)cout<<"Yes"<<endl;
  else if(a<c&&c-a<=d)cout<<"Yes"<<endl;
  else if(a>b&&b>c&&a-b<=d&&b-c<=d)cout<<"Yes"<<endl;
  else if(c>b&&b>a&&c-b<=d&&b-a<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<list>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// vector 型
template<class T>
std::ostream& operator<<(std::ostream& os, const vector<T>& v){
  // ここでストリームに obj を書き込みます。
  for(const T& t:v) cout << t << " ";
  return os;
}
// vector 型
template<class T>
std::ostream& operator<<(std::ostream& os, const list<T>& v){
  // ここでストリームに obj を書き込みます。
  for(const T& t:v) cout << t << " ";
  return os;
}

int find(int a,vector<int>& uf){
  if(uf[a]<0) return a;
  return uf[a]=find(uf[a],uf);
}

void unite(int a,int b,vector<int>& uf){
  a=find(a,uf),b=find(b,uf);
  if(a==b) return ;
  if(uf[a]>uf[b]) swap(a,b);
  uf[a]+=uf[b]; uf[b]=a;
}


int main(){
  int n,m; cin >>n >>m;
  vector<vector<pair<int,int>>> adj(n);
  vector<int> ideg(n,0);
  rep(i,m){
    int a,b,d; cin >>a >>b >>d; a--;b--;
    adj[a].push_back({b,d});
    ideg[b]++;
  }
  list<int> que;
  vector<int> pos(n,-1);
  int cnt=0;
  rep(i,n){
    if(ideg[i]==0) {que.push_back(i); pos[i]=1;cnt++;}
  }
  while(!que.empty()){
    if(df)print("que:",que);
    int u=que.front(); que.pop_front();
    for(pair<int,int> x:adj[u]){
      int v=x.first,d=x.second;
      if(df) print(u,pos[u],d,v,pos[v]);
      if(pos[v]>0 and (pos[u]+d)!=pos[v]){
        print("No");
        return 0;
      }
      pos[v]=pos[u]+d;
      if((--ideg[v])==0){cnt++;que.push_back(v);}
    }
  }
  print(cnt==n?"Yes":"No");
  if(df)print(pos);
  
}


Measured memory_bytes: 7540
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[100001];
ll b[100001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
	}
	ll res=0;
	for(int i=n-1;i>=0;i--){
		if((a[i]+res)%b[i]!=0){
			ll rest=(a[i]+res)%b[i];
			rest=b[i]-rest;
			res+=rest;
		}
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int mx = -1; 
	int ans = -1; 
	for(int i = 0; i < N; i++){
		int a, b; 
		cin >> a >> b; 
		if(a > mx){
			mx = a, ans = a + b; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  std::cout << A * B << std::endl;

  return 0;
}


Measured memory_bytes: 3648
n = input().split()
a = input().split()
N = int(n[0])
A = list(map(int, a))
Flag = 0
i = 0

while True:
    for j in range(N):
        if A[j] % 2 == 1:
            Flag = 1
            break
        A[j] = A[j] / 2
    if Flag == 1:
        print(i)
        break
    i += 1

Measured memory_bytes: 3064
Scanf.scanf "%d %d %d %d" (fun x y z k ->
    let a = Array.init x (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
    let b = Array.init y (fun _ -> Scanf.scanf " %d" (fun y -> y)) in
    let c = Array.init z (fun _ -> Scanf.scanf " %d" (fun z -> z)) in
    Array.sort (fun a b -> compare b a) a;
    Array.sort (fun a b -> compare b a) b;
    Array.sort (fun a b -> compare b a) c;
    let buf1 = Array.make (x * y) 0 in
    for i = 0 to x - 1 do
        for j = 0 to y - 1 do
            buf1.(i * y + j) <- a.(i) + b.(j)
        done
    done;
    Array.sort (fun a b -> compare b a) buf1;
    let xy = min 3000 (x * y) in
    let buf2 = Array.make (xy * z) 0 in
    for i = 0 to xy - 1 do
        for j = 0 to z - 1 do
            buf2.(i * z + j) <- buf1.(i) + c.(j)
        done
    done;
    Array.sort (fun a b -> compare b a) buf2;
    for i = 0 to k - 1 do
        Printf.printf "%d\n" buf2.(i)
    done
)

Measured memory_bytes: 37372
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
using namespace std;

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

    int N;
    cin >> N;

    vector<tuple<string, int, int>> rest;
    rest.reserve(N);
    for (int i = 0; i < N; ++i) {
        string s;
        int point;
        int id = i + 1;
        cin >> s >> point;
        rest.emplace_back(s, -point, id);
    }

    sort(rest.begin(), rest.end());
    for (int i = 0; i < N; ++i) {
        cout << get<2>(rest[i]) << endl;
    }

    return 0;
}


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

int main() {
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;

    cout << arr[K-1];
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
typedef long long ll;
using namespace std;

int main(void){
  string s, t;
  cin >> s >> t;
  rep(i, s.length()){
    string tmp;
    FOR(j, s.length()-i-1, s.length())  {
      tmp += s[j];
    }
    FOR(j, 0, s.length()-i-1){
      tmp += s[j];
    }
    if(tmp == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]
arr = list(map(int,input().split()))

m = sum(arr[0:k])
sump = m

for i in range(1, n-k+1):
    sump = sump - arr[i-1] + arr[i+k-1]
    if m < sump:
        m = sump

ans = (m + k) / 2

print(ans)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int r, g, b,n;
string s;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    f(i,0,n){
        if(s[i] == 'R'){
            r++;
        }
        else if(s[i] == 'G'){
            g++;
        }
        else
            b++;
    }
    int ans = r*g*b;
    f(i,0,n){
        f(j,1,n){
            int l = i-j;
            int rr = i+j;
            if(l >= 0 and l < n and rr >= 0 and rr < n and s[l] != s[i] and s[rr] != s[i] and s[l] != s[rr]){
                ans --;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
 


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  
  vector<int> a(A), b(B);
  
  for (int i = 0; i < A; i++) cin >> a.at(i);

//  int minA = *min_element(a.begin(), a.end());
  int minA = a.at(0);
  for (int i = 0; i < A; i++) {
    if (a.at(i) < minA) {
      minA = a.at(i);
    }
  }
    
  for (int j = 0; j <B; j++) cin >> b.at(j);

  int minB = *min_element(b.begin(), b.end());  
//  int minB = b.at(0);
//  for (int j = 0; j < B; j++) {
//    if (j < minB) {
//      minB = b.at(j);
//    }
//  }
  
  int minAB = minA + minB; 
  
  vector<int> x(M), y(M), c(M);
  
  for (int k = 0; k < M; k++) {  
  cin >> x.at(k) >> y.at(k) >> c.at(k);
  }
  
  int minm = a.at(x.at(0) - 1) + b.at(y.at(0) - 1) - c.at(0);

  for (int k = 0; k < M; k++) {
    if (a.at(x.at(k) - 1) + b.at(y.at(k) - 1) - c.at(k) < minm) {
      minm = a.at(x.at(k) - 1) + b.at(y.at(k) - 1) - c.at(k);
    }  
  }

  cout << min(minAB, minm) << endl;
}


Measured memory_bytes: 2176
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)
mod=10**9+7

fib=[1]*(N+1)
for i in range(2,N+1):
    fib[i]=fib[i-1]+fib[i-2]
fib.append(0)

ans=fib[a[0]-1]
for i in range(M):
    ans*=fib[a[i+1]-a[i]-2]
    ans%=mod
print(ans%mod)

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

int main()
{
  string s;
  int k;
  cin>>s>>k;
  for(int i=0;i<k;i++){
    if(s.at(i)!='1') {
      cout<<s.at(i)<<endl;
      return 0;
    }
  }
  cout<<1<<endl;
  return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;
        cout << fixed << setprecision(9);
        cout << acos(-1) * 2 * n;
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define int long long
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int INF = 2e18;

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

inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}

int exp(int a, int b, int m){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,m);
 
        b >>= 1;
        a = mod(a*a,m);
    }
    return result;
}
void solve(){
    int n,m; cin>>n>>m;
    vector<int>vet(n);
    int sum = 0;
    for(int &i : vet){
        cin>>i;
        sum+=i;
    }
    double pode = sum/(4.0*m);
    int res = 0;
    for(int &i : vet){
        if(i>=pode){
            res++;
        }
    }
    cout<<(res>=m ? "Yes" : "No")<<endl;
}
main(){
    fastio;
    // int q; cin>>q;
    // while(q--)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int l1, b1;
	cin >> l1 >> b1;

	int l2, b2;
	cin >> l2 >> b2;


	cout << max(l1 * b1, l2 * b2) << endl;




	return 0;
}

Measured memory_bytes: 3528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>

using namespace std;

int main(){
   string S;
   cin >> S;
   int ans =0;
   for( int i = 0 ; i+1 < (int)S.size(); i++ ){
      if( S[i] != S[i+1] ) ans++;
   }
   cout << ans << endl;
   return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b;
	cin >> a >> b;
	if (a / 10 == 0 && b / 10 == 0)
	{
		cout << a*b << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A, B := make([][]int, N), make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)
		B[i] = make([]int, N)
		for j := 0; j < N; j++ {
			A[i][j] = scanInt()
			B[i][j] = A[i][j]
		}
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				B[i][j] = intMin(B[i][j], B[i][k]+B[k][j])
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := i; j < N; j++ {
			if B[i][j] < A[i][j] {
				fmt.Println(-1)
				return
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := 0; k < N; k++ {
				if (i-k)*(j-k) == 0 {
					continue
				}
				if A[i][k]+A[k][j] == A[i][j] {
					B[i][j] = -1
					B[j][i] = -1
					break
				}
			}
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if B[i][j] != -1 {
				ans += B[i][j]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4876
#include <iostream>

using namespace std;

int main()
{
 int X,Y,a,b,c ;
 cin >> X>>Y ;
 b= X+Y ;
 a= X-Y ;
 c= X*Y ;
 if (a>=b && a>=c)
    cout << a<< endl ;
 else if (b>=a && b>=c)
    cout << b<<endl ;
 else
    cout << c <<endl;
  return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long n, ans = 0, mod = 1000000007;
    cin >> n;
    vector<long long> a(n);
    long long sum = 0; 
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        sum += a.at(i);
        sum %= mod;
    }
    for(int i = 0; i < n; ++i){
        sum -= a.at(i);
        if(sum < 0) sum += mod;
        ans += a.at(i) * sum % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
#define _CRT_SECURE_NO_WARNINGS
 
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
 
typedef long long ll;
 
using namespace std;
 
int get_gcd(int a, int b)
{
	while (b)
	{
		int temp = b;
		b = a % b;
		a = temp;
	}
	return a;
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	int K;
	ll sum = 0;
 
	scanf("%d", &K);
	
	for (int i = 1; i <= K; ++i)
	{
		for (int j = 1; j <= K; ++j)
		{
			for (int k = 1; k <= K; ++k) sum += get_gcd(get_gcd(i, j), k);
		}
	}
 
	printf("%lld\n", sum);
 
	return 0;
}

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

using namespace std;

int main()
{
    int i,c=0,j;

    string s;

    cin>>s;

    for(i=0;i<3;++i)if(s[i]=='S')++c;

    if(c==0)cout<<3<<endl;

    else if(c==3)cout<<0<<endl;

    else if(c==1){

        if(s[1]=='S')cout<<1<<endl;

        else cout<<2<<endl;

    }

    else cout<<1<<endl;

    return 0;

}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

//?????§????????¢
void largest_rectangle() {
	int H, W; cin >> H >> W;
	vector<vector<int>> v(H, vector<int>(W));
	rep(i, 0, H) rep(j, 0, W) {
		int x; cin >> x;
		v[i][j] = !x;
	}
	rep(i, 0, H - 1)rep(j, 0, W) {
		if (v[i + 1][j] == 0)continue;
		v[i + 1][j] += v[i][j];
	}
	using P = pair<int, int>;
	int ans = 0;
	rep(i, 0, H) {
		stack<P> st;
		st.emplace(0, 0);
		rep(j, 0, W) {
			dump(i, v[i], j, st);
			if (st.top().first == v[i][j])
				continue;
			int pos = j;
			while (st.top().first > v[i][j]) {
				chmax(ans, st.top().first*(j - st.top().second));
				pos = st.top().second;
				st.pop();
			}
			st.emplace(v[i][j], pos);
			dump(ans);
		}
		while (st.size()) {
			chmax(ans, st.top().first*(W - st.top().second));
			st.pop();
		}
		dump(ans);
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	largest_rectangle();
	return 0;
}

Measured memory_bytes: 10504
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  string w;
  cin >> w;
  int len = w.size();
  int n_w[50] = {};

  FOR(itr, 0, len){
    FOR(i, 97, 123){
      int itmp = w[itr];
      if(itmp == i){
	n_w[i-97]++;
      }
    }
  }
  
  
  FOR(i, 97, 123){
    //cout << n_w[i-97] << endl;
    if(n_w[i-97]%2 != 0) {cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;

  
  
  return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))

cc=collections.Counter(A)
L=list(cc.values())

total=0
for i in range(len(L)):
    total+=L[i]*(L[i]-1)//2

ans=0
for a in A:
    temp=cc[a]*(cc[a]-1)//2
    ttemp=(cc[a]-1)*(cc[a]-2)//2
    ans=total-temp+ttemp
    print(ans)

Measured memory_bytes: 110316
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,count=0,coun=0,cou=0;
  int ans=0;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    int d;
    cin>>d;
    if(b>=d)
      count++;
    else if(b+1<=d&&c>=d)
      coun++;
    else if(c<=d)
      cou++;
  }
  ans=min({count,coun,cou});
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
vint group(8,0);
int n;
vint abc(3);
vint l(8,0);

int solve(int id){
    int ret = INF;
    if(id==n){
        vvint bamboo(4);
        REP(i,n){
            bamboo[group[i]].pb(l[i]);
        }
        if(bamboo[0].empty()||bamboo[1].empty()||bamboo[2].empty()){
            return INF;
        }
        ret = 0;
        REP(i,3){
            int lx = 0;
            for(int li : bamboo[i]){
                lx+=li;
                ret+=10;
            }
            ret-=10;
            ret+=abs(abc[i]-lx);
        }
        return ret;
    }
    REP(i,4){
        group[id]=i;
        ret = min(ret,solve(id+1));
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> abc[0] >> abc[1] >> abc[2];
    REP(i,n){
        cin >> l[i];
    }
    int ans = solve(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
err = False
ans = list('*' * n)

for _ in range(m):
    si, ci = map(int, input().split())
    if ans[si - 1] == '*' or ans[si - 1] == str(ci):
        ans[si - 1] = str(ci)
    else:
        err = True

if ans[0] == '0' and n != 1:
    err = True

if ans[0] == '*':
    if n == 1:
        ans[0] = '0'
    else:
        ans[0] = '1'

if err:
    print(-1)
else:
    print(''.join(ai if ai != '*' else '0' for ai in ans))


Measured memory_bytes: 9188