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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int a, b, c;

int main() {
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d;cin >> a >> b >> c >> d;
	if(a+b>c+d) cout << "Left" << endl;
	else if(a+b==c+d) cout << "Balanced" << endl;
	else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char a[505][505],b[505][505];
int n,m;
void calc(int op){
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			b[i][p]=a[i][p];
		}
	}
	for(int i=1;i<=n;i++){
		if(!op) b[i][m]='#';
		else b[i][1]='#';
		if((i&1)==op){
			for(int p=1;p<=m;p++) b[i][p]='#';
			if(!op) b[i][1]='.';
			else b[i][m]='.';
		}
	}
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++) putchar(b[i][p]);
		puts("");
	}
	puts("");
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	calc(0);
	calc(1);
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int n;
vector<P> v;
vector<P> w;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int len = s.length();
    int cnt = 0, plus, minus = 0;
    for (int j = 0; j < len; j++) {
      if (s[j] == '(') cnt++;
      plus = cnt - (j + 1 - cnt);
      minus = min(minus, plus);
    }
    if (plus > 0) {
      v.push_back(P(minus, plus));
    } else {
      plus = -plus;
      minus += plus;
      w.push_back(P(minus, plus));
    }
  }
  
  sort(v.begin(), v.end(), greater<P>());
  sort(w.begin(), w.end(), greater<P>());
  
  long long height1 = 0;
  for (P p: v) {
    int minus = p.first;
    int plus = p.second;
    if (height1 + minus < 0) {
      cout << "No" << endl;
      return 0;
    }
    height1 += plus;
  }
  long long height2 = 0;
  for (P p: w) {
    int minus = p.first;
    int plus = p.second;
    if (height2 + minus < 0) {
      cout << "No" << endl;
      return 0;
    }
    height2 += plus;
  }
  
  if (height1 == height2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 11084
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, A, B = in_nn()
    X = list(in_nn())

    ans = 0
    for i in range(N - 1):
        if (X[i + 1] - X[i]) * A < B:
            ans += (X[i + 1] - X[i]) * A
        else:
            ans += B

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18424
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int alength=200000;

int main() {
	int n;
    cin>>n;
    if(n%10==3){
        cout<<"bon";
    }else if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout<<"pon";
    }else{
        cout<<"hon";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std; 
#define maxn 100005
int main()
{
	int max1,max2,cm1,cm2;
	max1=max2=-123123;
	int n;
	scanf("%d",&n);
	unsigned a[maxn];
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	//for (int i=1;i<=n;i++)  cout<<a[i]<<endl;
	//int cnt,a2,a2,a3; 
   unsigned	long long	a2=1;
//	int max1=-23423;
	unsigned long long cc=0;
	for (int i=n-1;i>=1;i--)
	{
		if (i+3<=n && a[i]==a[i+1] && a[i+1]==a[i+2] && a[i+2]==a[i+3]) {
			cout<<(long long)a[i]*a[i];
			return 0;
		}
		if (i==n-1) if (a[i]==a[i+1]){
		cc++;
		//if (cc==2) cout<<(long long) a2*a[i];
		a2*=a[i];
		}
		if (a[i]==a[i+1] && a[i]!=a[i+2] && i+2<=n)
		{
			cc++;
			a2*=a[i];
		}
	if (cc==2) {cout<<(long long)a2<<endl;return 0;}
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc117/tasks/abc117_d
=begin
3 7
1 6 3

14

4 9
7 4 0 3

46

1 0
1000000000000

1000000000000
=end
N, upper_bit = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
beki_ary = (1..39).to_a.each_with_object([1]) { |i, obj| obj << (obj.last * 2)}
already_min = false

ans = 0
39.step(0, -1) do |digest|
  mask = 1 << digest
  ones = A.count { |str| (str & mask) > 0 }
  if ones * 2 >= N
    already_min = true if upper_bit[digest] == 1
    ans += mask * ones
  else
    if already_min || (upper_bit[digest] == 1)
      ans += mask * (N - ones)
    else
      ans += mask * ones
    end
  end
end
p ans


Measured memory_bytes: 10764
#include<iostream>
#include<vector>

using namespace std;

int main(){
	string a, b;
	cin >> a >> b;

	for(int i=0; i<min(a.length(), b.length()); i++){
		cout << a[i] << b[i];
	}
	if(b.length() != a.length()) cout << a[a.length() -1 ] << endl;
	else cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

vector<int> v[N];

int solve(){
    int n; cin>>n;
    for(int i=2; i<=n; i++){
        int t; cin>>t;
        v[t].push_back(i);
    }
    for (int i = 0; i < n; ++i)
    {
        cout<<v[i+1].size()<<"\n";
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

int main(){
	int H, M, h, m, K;
	cin >> H >> M >> h >> m >> K;
	int ans;
	ans = h * 60 + m - (H * 60 + M) - K;
	cout << ans << endl;
}

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

using namespace std;

typedef pair< int ,int > pr;
typedef long long int ll;
typedef unsigned long long int ull;
typedef map<int ,int > mi;
typedef map<string ,int > ms;
typedef map<string ,string > mss;
typedef vector<int > vi;
typedef vector<string > vs;

int main()
{
    stringstream ss;
    string s,r;
   long long   int a,b,m,n,c,x,y,p,q;
//    while(1){
//    long long     int cont=0;
//
//      cin>>a>>b>>c;
//        cin>>n;
//        for(int i=0;i<n;i++){
//           cin>>p;
//        if(p>b&&p<c)
//            cont++;
//        }

//    int c;

    int ar[10000]={0},mx=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        ar[a]++;ar[b]++;
    }
    for(int i=1;i<=n;i++)
        cout<<ar[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>

inline long long gcd(long long a, long long b) {
    return b == 0 ? a : gcd(b, a % b); 
}

int main() {
    int T; 
    scanf("%d", &T); 

    while (T--) {
        long long a, b, c, d; 
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d); 
        
        if (a < b) {
            puts("No"); 
            continue; 
        }
        if (d < b) {
            puts("No"); 
            continue; 
        }   
        if (c + 1 >= b) {
            puts("Yes"); 
            continue; 
        }

        if ( (a - c - 1) / gcd(b, d) - (a - b) / gcd(b, d) > 0) {
            puts("No"); 
            continue; 
        }
        else {
            puts("Yes"); 
        }
    }

    return 0; 
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

enum {migi, hidari, mae, ushiro, ccw, cw};
int dx[] = {0,0,1,-1,0,0};
int dy[] = {1,-1,0,0,0,0};
int op[6][6] = {
    {4,1,0,3,5,2},
    {2,1,5,3,0,4},
    {3,0,2,5,4,1},
    {1,5,2,0,4,3},
    {0,4,1,2,3,5},
    {0,2,3,4,1,5},
};
void roll(vector<int> &v, int dir){
  vector<int> temp = v;
  for(int i = 0; i < 6; i++){
      temp[i] = v[op[dir][i]];
  }
  v = temp;
}
vector<int> dice[24];

void init_dice(){
  for(int i=1; i < 24; i++){
      dice[i] = dice[i-1];
      roll(dice[i], ccw);
      if( i % 8 == 0 ) roll(dice[i], hidari);
      else if(i % 4 == 0) roll(dice[i], mae);
  }
}


int main() {
  for (int N; cin >> N, N; ) {
      vector<int> v;
      v.push_back(1);
      v.push_back(2);
      v.push_back(3);
      v.push_back(5);
      v.push_back(4);
      v.push_back(6);

      int ans = 1;
      REP(i, N) {
          string op; cin >> op;
          int dir = 0;
          switch (op[0]) {
          case 'N': dir = ushiro; break;
          case 'S': dir = mae; break;
          case 'E': dir = migi; break;
          case 'W': dir = hidari; break;
          case 'R': dir = cw; break;
          case 'L': dir = ccw; break;
          }
          roll(v, dir);
          ans += v[0];
      }
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool func(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

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

	return 0;
}

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

const int N = 3e5 + 10;
char s[N];
int n, Q, ff;
vector<char> a, b;

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    cin >> Q;
    while (Q--) {
        int t; scanf("%d", &t);
        if (t == 1) ff ^= 1;
        else {
            int x; char ch; cin >> x >> ch;
            if (ff) {
                if (x == 1) x = 2; else x = 1;
            }
            if (x == 1) a.push_back(ch);
            else b.push_back(ch);
        }
    }
    if (ff) {
        int sz = b.size();
        for (int i = sz - 1; i >= 0; i--) printf("%c", b[i]);
        // printf("%s", s + 1);
        for (int i = n; i >= 1; i--) printf("%c", s[i]);
        for (int i = 0; i < a.size(); i++) printf("%c", a[i]);
        puts("");
    } else {
        int sz = a.size();
        for (int i = sz - 1; i >= 0; i--) printf("%c", a[i]);
        printf("%s", s + 1);
        for (int i = 0; i < b.size(); i++) printf("%c", b[i]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
map<string,int> mp;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
	re 0;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            string[] count = new string[0];

            int k = int.Parse(input[1].ToString());
            int n = int.Parse(input[0].ToString());
            int sunuke = 0;

            for (int i = 0; i < k; i++)
            {
                int d = int.Parse(Console.ReadLine());
                string[] a = Console.ReadLine().Split();
                for(int j = 0; j < d; j++)
                {
                    Array.Resize(ref count, count.Length + 1);
                    count[count.Length - 1] = a[j];
                }
            }

            for (int i = 1; i <= n; i++)
            {
                string g = i.ToString();
                if (count.Contains(g))
                {
                    sunuke++;
                }
            }
            Console.WriteLine();
            Console.WriteLine(n - sunuke);
            Console.Read();
        }
    }
}


Measured memory_bytes: 41792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector <pii> pj[100004];
string ans[100004];
string kop(int t){
	string res="";
	int zz=t;
	while (zz>0){
		res+=char(zz%10+'0');
		zz/=10;
	}
	reverse (res.begin(),res.end());
	for (int i=0;res.size()<6;i++)
		res="0"+res;
	return res;
}
int main(){
	int n,m;
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int p,z;
		cin>>p>>z;
		ans[i]+=kop(p);
		pj[p].push_back(pii(z,i)); 
	}
	for (int i=1;i<=n;i++) sort (pj[i].begin(),pj[i].end());
	for (int i=1;i<=n;i++)
		for (int j=0;j<pj[i].size();j++){
			ans[pj[i][j].second]+=kop(j+1);
		}
	for (int i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VVII = vector<VII>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
// struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N = in();
  VVI G(N);
  REP (i, N - 1) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  VVII dist(N); // {len, v}
  VI far(N);
  function<void (int, int)> dfs1 = [&](int v, int prev) {
    for (int u: G[v]) if (u != prev) {
      dfs1(u, v);
      dist[v].push_back({far[u] + 1, u});
      chmax(far[v], far[u] + 1);
    }
  };
  dfs1(0, -1);

  sort(RALL(dist[0]));
  function<void (int, int)> dfs2 = [&](int v, int prev) {
    for (int u: G[v]) if (u != prev) {
      int tmp;
      if (dist[v][0].se == u) {
        tmp = dist[v].size() == 1 ? 0 : dist[v][1].fi;
      } else {
        tmp = dist[v][0].fi;
      }
      dist[u].pb({tmp + 1, v});
      sort(RALL(dist[u]));
      dfs2(u, v);
    }
  };
  dfs2(0, -1);

  REP (i, N) {
    cout << 2 * (N - 1) - dist[i][0].fi << endl;
  }
}



Measured memory_bytes: 30132
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

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

return 0;
}

Measured memory_bytes: 3632
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-04-04 21:14:15
 * @LastEditTime: 2020-04-04 21:18:04
 * @FilePath: \VSCode\C++\Practice\AC abc161 C.cpp
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n,k;
signed main(){
    scanf("%lld%lld",&n,&k);
    
    int ans=n/k;
    printf("%lld\n",min(n-ans*k,(ans+1)*k-n));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = 1;
	FOR(i,0,n){
		ll k;
		cin >> k;
		ans = lcm(ans,k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    int n,m; cin>>n>>m;
    vector<pair<ll, ll>> vec;
    for(int i=0; i<n; i++){
        ll a,b; cin>>a>>b;
        vec.push_back(make_pair(a,b));
    }
    sort(ALL(vec), greater<pair<ll,ll>>());
    priority_queue<ll> pq;
    ll ans = 0;
    int t = 1;
    while(t <= m){
        while(vec.size()>0 && vec.back().first <= t){
            pq.push(vec.back().second);
            vec.pop_back();
        }
        if(pq.size()>0){
            ans += pq.top();
            pq.pop();
        }
        t++;
    }
    OUT(ans);
}


Measured memory_bytes: 3696
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

s = 0
for c in S:
    s += c.count('.')

que = deque()
dist = [[-1 for j in range(W)] for i in range(H)]
dist[0][0] = 0
st = (0, 0)
que.append(st)
dydx = [(1, 0), (0, 1), (-1, 0), (0, -1)]

while que:
    p, q = que.popleft()

    for dy, dx in dydx:
        if 0 <= p+dy and p+dy < H and 0 <= q+dx and q+dx < W:
            if dist[p+dy][q+dx] != -1 or S[p+dy][q+dx] != '.':
                continue

            dist[p+dy][q+dx] = dist[p][q] + 1
            que.append((p+dy, q+dx))

if dist[H-1][W-1] == -1:
    print(-1)
else:
    print(s-dist[H-1][W-1]-1)

Measured memory_bytes: 9284
#include <iostream>
#include <algorithm>
#include <iterator>

int main() {
	size_t len;
	std::cin >> len;

	size_t count = 1;
	bool inc;
	bool undecided = true;
	int32_t prev;
	int32_t cur;
	std::cin >> cur;
	for (size_t i = 1; i < len; ++i) {
		prev = cur;
		std::cin >> cur;
		if (prev == cur) {
			continue;
		}
		if (undecided) {
			inc = cur > prev;
			undecided = false;
		} else if (inc != (cur > prev)) {
			undecided = true;
			++count;
		}
		
	}

	std::cout << count << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N,M,Q;
	ll res=0;
	string sres;
	cin>>N>>M>>Q;
	VI a(Q),b(Q),c(Q),d(Q);
	REP(i, Q) {
		cin >> a[i]>>b[i]>>c[i]>>d[i];
		a[i]--,b[i]--;
	}
	for (ll i0 = 1 ; i0<=M; ++i0) {
	for (ll i1 = i0; i1<=M; ++i1) {
	for (ll i2 = i1; i2<=M; ++i2) {
	for (ll i3 = i2; i3<=M; ++i3) {
	for (ll i4 = i3; i4<=M; ++i4) {
	for (ll i5 = i4; i5<=M; ++i5) {
	for (ll i6 = i5; i6<=M; ++i6) {
	for (ll i7 = i6; i7<=M; ++i7) {
	for (ll i8 = i7; i8<=M; ++i8) {
	for (ll i9 = i8; i9<=M; ++i9) {
	ll tmp=0;
	VI arr={i0,i1,i2,i3,i4,i5,i6,i7,i8,i9};
	REP(i,Q) {
		if(arr[b[i]]-arr[a[i]]==c[i]){
			tmp+=d[i];
		}
	}
	res=max(res,tmp);
	}
	}
	}
	}
	}
	}
	}
	}
	}
	}

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

		int N = sc.nextInt();
		int L = sc.nextInt();

		int sum1 = 0;
		for (int i = 0; i < N; i++) {
			sum1 += L + (i + 1) - 1;
		}
		//System.out.println(sum1);

		int sa = 100000;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int sum2 = 0;
			for (int j = 0; j < N; j++) {
				if (i == j) {
					continue;
				}
				sum2 += L + (j + 1) - 1;
			}

			sa = Math.min(sa, Math.abs(sum1 - sum2));
		}

		if(L > 0) {
			ans = sum1 - sa;
		} else {
			ans = sum1 + sa;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

set<ll> primes;

void factorize(ll n) {
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) { primes.insert(i); primes.insert(n / i); }
    }
}

ll factor(ll a, ll k) {
    return 5 * powl(a, 4)
         - 10 * powl(a, 3) * k
         + 10 * powl(a, 2) * powl(k, 2)
         - 5 * a * powl(k, 3)
         + powl(k, 4);
}

int main()
{
    ll x; cin >> x;
    factorize(x);
    vll target;
    for (auto elem : primes) {
        target.push_back(elem); target.push_back(-elem);
    }

    sort(ALL(target));

    for (auto k : target) {
        reprr(a, -1e3, 1e3) {
            if (factor(a, k) == x / k) {
                cout << a << " " << a - k << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3648
import sys
from functools import reduce
def b():
    p = [r.split(' ') for r in sys.stdin.read().split('\n') if r != '']
    SP = p[1:]
    sp = sorted(enumerate(SP), key=lambda x: -int(x[1][1]))
    sc = sorted(sp, key=lambda x: x[1][0])
    for i, t in sc:
        print(i + 1)
b()


Measured memory_bytes: 3828
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>

using namespace std;

int n,k;
vector<int> f[110000];
int v[110000];
struct node
{
	int id,x;
	friend bool operator < (node a,node b)
	{
		return a.x>b.x;
	}
};
priority_queue<node> q;
int main()
{
	scanf("%d",&n);
	memset(v,-1,sizeof(v));
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		f[x].push_back(y);
		f[y].push_back(x);
	}
	scanf("%d",&k);
	for (int i=1;i<=k;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		v[x]=y;
		q.push({x,y});
	}
	while (!q.empty())
	{
		node p=q.top();q.pop();
		for (int i=0;i<f[p.id].size();i++)
		{
			int y=f[p.id][i];
			if (v[y]==-1)
			{
				v[y]=v[p.id]+1;
				q.push({y,v[y]});
			}
			else
			{
				if (abs(v[y]-p.x)!=1)
				{
					printf("No\n");
					return 0;
				}
			}
		}
	}
	printf("Yes\n");
	for (int i=1;i<=n;i++)
		printf("%d\n",v[i]);
	return 0;
}

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


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(n);
        Console.WriteLine(n[n.Length-1] - n[0]);
	} 
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a[3]; REP(i,3) cin >> a[i];
  int ans = 0;

  sort(a, a+3);
  auto same = [&](){ return a[0] == a[1] && a[0] == a[2]; };
  while(1) {
    if (same()) break;
    int add = (a[2] - a[0]) / 2;
    if (add > 0) {
      a[0] += add*2;
      ans+=add;
    } else {
      a[2]--;
      ans++;
    }
    sort(a, a+3);
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
inline void read(int &x)
{
    int s=0,w=1;
    char c=getchar();
    while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
    while(isdigit(c)){s=(s<<3)+(s<<1)+c-'0',c=getchar();}
    x=s*w;
}
const int N=100010;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define rg register int
int seed=2333;
inline int rnd(){return seed=seed*seed+23*seed+3;}
struct Treap
{
    int ls[N],rs[N],rt,val[N],size[N],key[N],tot;
    ll s[N];
    inline void push_up(int x)
    {
        size[x]=size[ls[x]]+size[rs[x]]+1;
        s[x]=s[ls[x]]+s[rs[x]]+val[x];
    }
    inline int merge(int x,int y)
    {
        if(!x||!y)return x+y;
        if(key[x]<key[y])
        {
            rs[x]=merge(rs[x],y);
            push_up(x);
            return x;
        }
        else
        {
            ls[y]=merge(x,ls[y]);
            push_up(y);
            return y;
        }
    }
    inline pii split(int x,int k)
    {
        if(!x)return mp(0,0);
        pii p(0,0);
        if(k<=size[ls[x]])
        {
            p=split(ls[x],k);
            ls[x]=p.se,push_up(x),p.se=x;
            return p;
        }
        else
        {
            p=split(rs[x],k-size[ls[x]]-1);
            rs[x]=p.fi,push_up(x),p.fi=x;
            return p;
        }
    }
    inline int rnk(int x)
    {
        int res=0,now=rt;
        while(now)
        {
            if(x<=val[now])now=ls[now];
            else res+=size[ls[now]]+1,now=rs[now];
        }
        return res;
    }
    inline void ins(int x)
    {
        size[++tot]=1,val[tot]=s[tot]=x,key[tot]=rnd();
        pii a=split(rt,rnk(x));
        rt=merge(merge(a.fi,tot),a.se);
    }
    inline void del(int x)
    {
        pii a=split(rt,rnk(x)),b=split(a.se,1);
        rt=merge(a.fi,b.se);
    }
    inline ll get(int x)
    {
        int now=rt;
        ll res=0;
        while(now)
        {
            if(x<=size[ls[now]])now=ls[now];
            else if(x==size[ls[now]]+1)
            {
                res+=s[ls[now]]+val[now];
                break;
            }
            else res+=s[ls[now]]+val[now],x-=size[ls[now]]+1,now=rs[now];
        }
        return res;
    }
}A,B;
ll s1,s2;
int n,X,Y,Z;
struct data
{
    int a,b,c;
}p[N];
inline bool cmp(data x,data y){return x.a-x.b>y.a-y.b;}
ll ans;
int main()
{
    read(X),read(Y),read(Z),n=X+Y+Z;
    for(rg i=1;i<=n;i++)
        read(p[i].a),read(p[i].b),read(p[i].c);
    sort(p+1,p+n+1,cmp);
    for(rg i=1;i<=X;i++)
        s1+=p[i].c,A.ins(p[i].c-p[i].a);
    for(rg i=X+1;i<=n;i++)
        s2+=p[i].c,B.ins(p[i].c-p[i].b);
    ans=s1+s2-A.get(X)-B.get(Y);
    for(rg i=X+1;i<=n-Y;i++)
    {
        s2-=p[i].c,B.del(p[i].c-p[i].b),
        s1+=p[i].c,A.ins(p[i].c-p[i].a);
        ans=max(ans,s1+s2-A.get(X)-B.get(Y));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,q,i,t,x;
   cin>>n>>q;
   stack<int>a[n];
   while(q){
   	q--;
   	cin>>i;
   	if(i==0){
   		cin>>t>>x;
   		a[t].push(x);
	   }
	if(i==1){
		cin>>t;
		 if(a[t].size()!=0)
		cout<<a[t].top()<<endl;
   }
   if(i==2){
   	cin>>t;
   	 if(a[t].size()!=0)
   	a[t].pop();
   }
}
}



Measured memory_bytes: 4336
n, k, q = map(int, input().split())
point = [0 for i in range(n)]
for i in range(q):
    winner = int(input())
    point[winner - 1] += 1
for i in range(n):
    if k - q + point[i] > 0:
        print("Yes")
    else:
        print("No")

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

int main(){
    string A, B;
    cin >> A >> B;
    sort(A.begin(),A.end());
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    if (A<B) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 10'000;

int P[MAX];
int R[MAX];

//
int parent(int x) {
    if (P[x] == x) {
        return x;
    } else {
        return P[x] = parent(P[x]);
    }
}

void unite(int x, int y) {
    int a, b;
    a = parent(x);
    b = parent(y);
    if (R[a] > R[b]) {
        P[b] = a;
    } else if (R[a] < R[b]) {
        P[a] = b;
    } else {
        P[b] = a;
        R[a]++;
    }
}

bool same(int x, int y) {
    return parent(x) == parent(y);
}

//
int main() {

    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        P[i] = i;
        R[i] = 0;
    }

    int com, x, y;
    for (int i = 0; i < q; i++) {
        cin >> com >> x >> y;
        if (com == 0) {
            unite(x, y);
        } else {
            cout << (same(x, y) ? 1 : 0) << endl;
        }
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

int mod;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n;
	cin >> n;
	if (n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

const ll sqrtN = 64;
const ll INF = (1ll << 60ll);

ll n, x;
ll a[4096];
ll bucket[65];

void init(void);
ll range_min(int s, int t);//[s, t)
void update(int k, ll dat);

int main()
{
    // comment out
    
    ll ans = INF;
    ll m;

    init();

    scanf("%lld %lld", &n, &x);
    m = n;
    n += n;
    for (ll i = 1; i <= m; i++) {
        scanf("%lld", &a[i]);
        update(i, a[i]);
        update(i + m, a[i]);
    }

    for (ll i = 0; i < m; i++) {

        ll a_sum = 0;
        for (ll j = 1; j <= m; j++) {
            ll k = j + m;

            a_sum += range_min(k - i, k + 1);
        }

        ans = min(ans, i * x + a_sum);
    }
    
    printf("%lld\n", ans);

    return 0;
}

void init(void)
{
    for (int i = 0; i < 4096; i++) {
        a[i] = INF;
    }

    for (int i = 0; i < 65; i++) {
        bucket[i] = INF;
    }

    return;
}

//[s, t)
ll range_min(int s, int t)
{
    ll minv = INF;
    ll K = (n + sqrtN - 1) / sqrtN;
    ll l, r;
    
    for (int k = 0; k < K; k++) {
        l = k * sqrtN;
        r = (k + 1) * sqrtN;

        // out range
        if (t <= l) {
            break;
        }
        else if (r <= s) {
            continue;
        }

        // in range
        if (s <= l && r <= t) {
            minv = min(minv, bucket[k]);
        }
        else {
            for (ll i = max(l, s); i < min(r, t); i++) {
                minv = min(minv, a[i]);
            }
        }
        
    }

    return minv;
}

void update(int k, ll dat)
{
    ll minv = INF;
    a[k] = dat;

    k /= sqrtN;
    for (ll i = k * sqrtN; i < (k + 1) * sqrtN; i++) {
        minv = min(minv, a[i]);
    }

    bucket[k] = minv;

    return;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
int main(void) {
	//B
	int n, m, k, x;
	std::cin >> n;
	std::cin >> m;
	int table[31] = { 0 };
	for (int i = 0; i < n; i++) {
		std::cin >> k;
		for (int j = 0; j < k; j++) {
			std::cin >> x;
			table[x]++;
		}
	}
	int result = 0;
	for (int i = 0; i < m+1; i++) {
		if (table[i] == n)result++;
	}
	std::cout << result << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  char prev = s[0];
  for (int i=0;i<s.length();i++) {
    if (prev != s[i])
      count++;
    prev = s[i];
  }
  cout << count << endl;
  return(0);
}


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

int top, S[1000];

void push(int x){
	/* top ?????????????????????
	   ????????????????????\ */
	S[++top] = x;
}

int pop(){
	top--;
/* top ??????????????????????´?????????? */
	return S[top+1];
}

int main(){
	int a, b;
	top = 0;
	char s[100];

	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a-b);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}

	printf("%d\n",pop());

	return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct pro{
  string s;
  int d;
};
vector<pro> res;

bool mycomp(pro qwe, pro rty){
  if(qwe.s.size() != rty.s.size())return qwe.s.size() < rty.s.size();
  return qwe.s < rty.s;
};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    string x;
    int y;
    res.pb((pro){"ZZZZZZZZ", 0});
    for(;n--;){
      cin >> x >> y;
      res.pb((pro){x, y});
    }
    sort(all(res), mycomp);

    string l = "a";
    int r = 0;
    rep(i, res.size()){
      if(l == res[i].s){
        r += res[i].d;
      }else{
        if(l != "a")cout << l << " " << r << endl;
        l = res[i].s;
        r = res[i].d;
      }
    }

/*/

//*/ break;
  }
  return 0;
}

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

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

    switch (b)
    {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
        default:
            break;
    }
}

Measured memory_bytes: 256
//選択ソート
//2018-12-11
//Ebitani Akira

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

#define N 100

int ss(int *, int);

int main(){
  int array[N];
  int i,count;
  int n;

  scanf("%d",&n);

  if( n<1 || n>N ){
    printf("要素数が適当ではありません。\n");
    exit(1);
  }

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&array[i]);
  }

 
  count = ss(array,n);
    
  for( i=0 ; i<n ; i++ ){
    printf("%d",array[i]);

    if( i<n-1 )printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

int ss( int array[], int n){
  int i, j, temp;
  int count=0;
  int min;

  for( i=0 ; i<n ; i++ ){
    min=i;
    for( j=i ; j<n ; j++ ){
      if( array[j] < array[min] ){
	min = j;
      }
    }
    temp = array[i];
    array[i] = array[min];
    array[min] = temp;

    if( i!=min ){
      count = count + 1;
    }
  }
  return count;
}



Measured memory_bytes: 2108
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) Counts(26, 100011);
    FOR(i, 0, N) {
        string s;
        cin >> s;

        VEC(int) Counts2(26, 0);
        for (char c : s)
            Counts2[c - 'a']++;
        FOR(j, 0, 26)
            Counts[j] = min(Counts[j], Counts2[j]);
    }

    FOR(i, 0, 26)
        while (Counts[i]--)
            cout << (char)('a' + i);
    cout << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

typedef long long ll;
const int Maxn=2e5;

int N;
ll A[Maxn+5];
bool used[Maxn+5];

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%lld",&A[i]);
	sort(A+1,A+N+1);
	ll ans=0;
	for(ll num=1<<30;num;num>>=1) {
		int j=N;
		for(int i=1;i<=N;i++)
			if(!used[i]) {
				while(j>i&&(num-A[i]<A[j]||used[j]))
					j--;
				if(j<=i)break;
				if(num!=A[i]+A[j])
					continue;
				used[i]=used[j]=true;
				ans++;
			}
	}
	printf("%lld\n",ans);
	return 0;
}
/*6
1 1 2 2 7 9
*/

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int X[m];
  int i;
  for(i=0;i<m;i++){
    cin >> X[i];
  }
  sort(X,X+m);
  int distance[2000000];
  for(i=1;i<m;i++){
    distance[X[i]-X[i-1]]++;
  }

  int ans = 0;
  int num = m-n;
  i=1;
  while(num>0){
    if(distance[i]>0){
      distance[i]--;
      num-=1;
      ans += i;
    }else{
      i++;
    }
  }
  cout << ans;
  
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)%3==0||a%3==0||b%3==0){
    cout<<"Possible"<<endl;
  }
  else{
    cout<<"Impossible"<<endl;
  }
}

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  vector<long> t(N);
  vector<long> S(N);
  vector<long> A(N);
  vector<long> T(N);
  for(long j=0;j<N;j++){
    cin>>t[j]>>a[j];
  }

  A[0]=a[0];
  T[0]=t[0];
  S[0] = A[0]+T[0];
  for(long i=1;i<N;i++){
    //long r = max(ceil(double(A[i-1])/double(a[i])),ceil(double(T[i-1])/double(t[i])));
    long r = max((T[i-1]-1)/t[i], (A[i-1]-1)/a[i])+1;
    //cout<<r<<endl;
    A[i]= r*a[i];
    T[i]= r*t[i];
    S[i] = A[i]+T[i];
  }

cout<<S[N-1]<<endl;
}


Measured memory_bytes: 256