akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
signed main() {
    int n, a, b, c, x;
    while(cin >> n >> a >> b >> c >> x, n || a || b || c || x) {
        vector<int> v(n);
        rep(i,0,n) cin >> v[i];
        
        bool ok = false;
        int cnt = 0;
        rep(i,0,10001) {
            if(x == v[cnt]) cnt++;
            if(cnt == n) {
                cout << i << endl;
                ok = true;
                break;
            }
            x = (x * a + b) % c;
        }
        if(!ok) cout << -1 << endl;
    }
    return 0;
}

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

memo = [0, abs(h[1]-h[0])]
def dp(n):
  for i in range(len(memo), n+1):
    costs = [memo[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, K)+1)]
    memo.append(min(costs))
  return memo[n]
 
print(dp(N-1))

Measured memory_bytes: 58336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector< vector<int> > data(n+1, vector<int>(n+1, 0));

  rep(i, m) {
    int x, y;
    cin >> x >> y;
    data[x][y] += 1;
  }

  vector< vector<int> > sum2(n+1, vector<int>(n+1, 0));

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      sum2[i][j] += sum2[i][j - 1] + data[i][j];
    }
  }

  for (int j = 1; j <= n; ++j) {
    for (int i = 1; i <= n; ++i) {
      sum2[i][j] += sum2[i - 1][j];
    }
  }
/*
  rep(i, n+1) {
    END;
    rep(j, n+1) {
      cout << sum2[i][j] << " ";
    }
  }
  END;
*/
  rep(i, q) {
    int x, y;
    cin >> x >> y;
    cout << sum2[y][y] + sum2[x-1][x-1] - sum2[x-1][y] - sum2[y][x-1] << endl;
  }
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
char s[13];
int n;
int a[13];
int add[13];
ll powt[13];
ll ans;
int main(void)
{
	scanf("%s",&s[1]);
	n=strlen(&s[1]);
	int i, j;
	for(i=1 ; i<=n ; i++)
	{
		a[i]=s[i]-'0';
	}
	powt[0]=1;
	add[0]=1;
	add[1]=1;
	add[2]=2;
	for(i=3 ; i<=12 ; i++)
	{
		add[i]=2*add[i-1];
	}
	for(i=1 ; i<=12 ; i++)
	{
		powt[i]=10*powt[i-1];
	}
	for(i=1 ; i<=n ; i++)
	{
		for(j=1 ; j<=n ; j++)
		{
			if(n-i-j+1>=0)
			{
				ans+=a[i]*(1<<(i-1))*add[n-i-j+1]*powt[j-1];
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 100005

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll t, ans = 0;
	ll now = 1;
	cin >> t;
	while (t) {
		ans += now;
		now <<= 1;
		t >>= 1;
	}

	cout << ans << '\n';





#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int a,b,c,d,e,k;
int main()
{
    cin>>a>>b>>c>>d>>e>>k;
    if (e-a<=k)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> S(3); rep(i, 3) cin >> S[i];
  rep(i, 3) cout << S[i][0];
  cout << endk;
  return 0;
}


Measured memory_bytes: 3648
n = int(input())
h = list(map(int, input().split()))

count = 0
c_max = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
        if c_max < count:
            c_max = count
    else:
        count = 0

print(c_max) 

Measured memory_bytes: 63856
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10
#define MP make_pair

int map[124][124];
bool map_flg[124][124];
int x_move[] = { 0,0,1,-1 };
int y_move[] = { -1,1,0,0 };

int main() {
	int w, h;

	while (cin >> w >> h && w != 0 && h != 0) {
		memset(map, 0, sizeof(map));
		memset(map_flg, true, sizeof(map_flg));
		int xs, ys;
		int xg, yg;
		int n;

		cin >> xs >> ys >> xg >> yg >> n;

		for (int i = 1; i <= n; ++i) {
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			int x_, y_;
			if (d == 0) {
				x_ = 4;
				y_ = 2;
			}
			else {
				x_ = 2;
				y_ = 4;
			}
			for (int j = y; j < y + y_; ++j) {
				for (int j2 = x; j2 < x + x_; ++j2) {
					map[j][j2] = c;
				}
			}
		}

		if (map[ys][xs] != map[yg][xg]) {
			cout << "NG" << endl;
			continue;
		}

		stack<pair<int, int> > st;
		st.push(MP(xs, ys));
		int m_c = map[ys][xs];
		bool flg = false;
		while (!st.empty()) {
			int x = st.top().first, y = st.top().second;
			st.pop();
			map_flg[y][x] = false;
			for (int i = 0; i < 4; ++i) {
				int x_ = x + x_move[i], y_ = y + y_move[i];
				if (map[y_][x_] == m_c && map_flg[y_][x_]) {
					if (y_ == yg && x_ == xg) {
						flg = true;
						break;
					}
					st.push(MP(x_, y_));
				}
			}
			if (flg) { break; }
		}

		if (flg) { cout << "OK" << endl; }
		else { cout << "NG" << endl; }
	}

	return 0;
}

Measured memory_bytes: 3132
/*
* @Author: kabbo
* @Date:   2020-05-11 20:22:01
* @Last Modified by:   kabbo
* @Last Modified time: 2020-05-11 20:40:42
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
const int mx = 3e3;
int dp[mx + 5][mx + 5];
int cnt = 0;
int len_lcs(string& s1, string& s2, int i, int j) {
	cnt++;
	if (i >= s1.length() || j >= s2.length())
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	if (s1[i] == s2[j])
		return dp[i][j] = 1 + len_lcs(s1, s2, i + 1, j + 1);
	else
		return dp[i][j] = max(len_lcs(s1, s2, i + 1, j), len_lcs(s1, s2, i, j + 1));
}
void print_lcs(string& s1, string& s2, int len) {
	string ans;
	int i = 0; int j = 0;
	while (len > 0 && i < s1.length() && j < s2.length()) {
		if (s1[i] == s2[j]) {
			ans += s1[i];
			i++;
			j++;
			len--;
		}
		else {
			if (dp[i + 1][j] > dp[i][j + 1])
				i++;
			else
				j++;
		}
	}
	cout << ans << endl;
	//cout << cnt << endl;
}
void solve() {
	string s1, s2;
	cin >> s1 >> s2;
	memset(dp, -1, sizeof(dp));
	auto len = len_lcs(s1, s2, 0, 0);
	print_lcs(s1, s2, len);
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100010
#define int ll

int N,L,Q;
int A[maxn];
vi adj[maxn];

int twok[maxn][100],depth[maxn];

void twokdecomp(int x,int p){
	twok[x][0] = p;
	for (int i=1;i<=18;i++){ //i <= logmaxn
		if (twok[x][i-1] == -1) break;
		twok[x][i] = twok[twok[x][i-1]][i-1];
	}
	for (auto i: adj[x]){
		if (i != p){
			depth[i] = depth[x] + 1;
			twokdecomp(i,x);
		}
	}
}

int kth_parent(int x,int k){
	
	for (int i=0;i<=18;i++){
		if (k&(1<<i)){
			x = twok[x][i];
		}
		if (x==-1) break;
	}
	return x;

}



int32_t main(){
	fast;
	
	cin>>N;
	FOR(i,1,N) cin>>A[i];
	
	cin>>L>>Q;
	
	FOR(i,1,N-1){
		
		int idx = upper_bound(A+1,A+N+1,A[i] + L) - A;
		
		idx--;
		
		if (i == idx) continue;
		adj[i].pb(idx);
		adj[idx].pb(i);
		
	}
	
	mem(twok,-1);
	
	twokdecomp(N,-1);
		
	FOR(i,0,Q-1){
		int a,b; cin>>a>>b;
		if (a > b) swap(a,b);
		
		int l=0,r=depth[a]+10;
		
		while (l + 1 < r){
			
			int mid = (l+r)/2;
			//cout<<mid<<' '<<kth_parent(a,mid)<<'\n';

			if (kth_parent(a,mid) == -1) r = mid;
			else if (kth_parent(a,mid) > b) r = mid;
			else l = mid;
		}
		
		while (kth_parent(a,l) < b){
			l++;
		}
		cout<<l<<'\n';
		
	}
			
	
	
}


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

int n;
unsigned long long ans;

unsigned long long euclidean(unsigned long long a, unsigned long long b){
    if(b == 0) return a;
    return euclidean(b, a % b);
}

int main(){
    cin >> n;
    vector<unsigned long long> t(n,0);
    for(int i = 0; i < n; i++)cin >> t[i];
    sort(t.begin(), t.end(), greater<unsigned long long>());
    ans = t[0];
    for(int i = 1; i < n; i++){
        ans = (ans / euclidean(ans, t[i]) ) * t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

// #define NDEBUG
#include "atcoder/all"
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int nums;
};

// struct F {
//     mint a, b;
// };
using F = int;

mint pows[int(2e5 + 1)];
S op(S l, S r) { return S{l.a * pows[r.nums] + r.a, l.nums + r.nums}; }
S e() { return S{0, 0}; }
S mapping(F l, S r) { r.a = l == -1 ? r.a : (pows[r.nums] - 1) / 9 * l; return r; }
F composition(F l, F r) { return l == -1 ? r : l; }
F id() { return -1; }

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    pows[0] = 1;
    for(int i = 1; i < n; i++){
        pows[i] = pows[i - 1] * 10;
        // cerr << i << ' ' << pows[i].val() << '\n';
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(n, S{1, 1}));
    // lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
    // for(int i = 0; i < n; i++){
    //     seg.set(i, S{1, n - i - 1});
    // }
    // cerr << seg.all_prod().a.val() << '\n';
    for(int i = 0; i < q; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        // cerr << l << ' ' << r << ' ' << d << '\n';
        // for(int i = 0; i < n; i++){
        //     cerr << seg.get(i).a.val() << ',' << seg.get(i).nums << ' ';
        // }
        // for(int i = 0; i < n; i++){
        //     // cout << seg.prod(i, i + 1).a.val();
        //     cerr << seg.prod(i, i + 1).a.val() << ' ';
        // }
        // // cout << '\n';
        // cerr << '\n';
        cout << seg.all_prod().a.val() << '\n';
    }
}


Measured memory_bytes: 10320
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

char s[105][105];

int main(void) {
  int i,j;
  int a,b;
  cin>>a>>b;
  int h=100,w=100;
 
  rep(i,h)rep(j,w){
    if(i<h/2)s[i][j]='#';
    else s[i][j]='.';
  }
  a--,b--;
  rep(i,h/2)rep(j,w){//.を配置
    if(a==0)goto A;
    if(i%2==0 && j%2==0)s[i][j]='.',a--;
  }
 A:;
  loop(i,h/2+1,h)rep(j,w){//#を配置
    if(b==0) goto B;
    if(i%2==0 && j%2==0)s[i][j]='#',b--;
  }
 B:;
  cout<<h<<" "<<w<<endl;
  rep(i,h){
    rep(j,w)cout<<s[i][j];
    cout<<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)   int x; cin>>x; while(x--)
/*#define all(v)          (v).begin(), (v).end()
#define sortve(v)       sort(all(v))
#define rsrt(v)         sort(v.rbegin(), v.rend())
#define rev(i,n)        for(int i=n-1;i>=0;i--)
#define f0              for(int i=0;i<n;i++)
#define f1              for(int i=1;i<n+1;i++)
#define f2(i,a,b)       for(int i=a;i<b;i++)*/
const double pi=3.14159265359;
const int mod = 1e9 + 6;
//Actual Code Is At The Top
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{   
	very_slow
//	no_of_test(x)
	{
      string s;
	  cin>>s;
	  int k=s.length();
	  if(s[k-1]!='s')
	  {
		  s+="s";
	  }
	  else
	  {
		  s+="es";
	  }
	  cout<<s<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
        ll n, k, ans;
        cin >> n >> k;
        vector<ll> a(n+1);
        for(int i = 1; i <= n; i++) cin >> a[i];
        vector<ll> v;
        vector<bool> b(n+1, false);
        ll i = 1;
        while(!b[i]){
                v.push_back(i);
                b[i] = true;
                i = a[i];
        }
        if(k < (ll)v.size()){
                ans = v[k];
        } else {
                ll j;
                ll m = (ll)v.size();
                for(j = 0; j < m; j++){
                        if(v[j] == a[v.back()]){
                                v.erase(v.begin(), v.begin()+j);
                                break;
                        }
                }
                k -= j;
                ans = v[k%v.size()];
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 6900
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

ans=0
right=0
left=0
array_sum = 0
sum_xor = 0
sum_pls = 0

for left in range(n):

    while right<n and sum_pls+a[right] == sum_xor^a[right]:
        sum_pls += a[right]
        sum_xor ^= a[right]
        right+=1

    ans += right-left
    sum_pls -= a[left]
    sum_xor ^= a[left]

print(ans)


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) cout << setfill('0') << setw(len) << right << a << endl;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    string s;
    cin >> s;
    auto ans = "AC";

    if (s[0] != 'A') ans = "WA";
    if (s[s.size() - 1] == 'C') ans = "WA";

    string sub = s.substr(2, s.size() - 2 - 1);
    int cnt = 0;
    for (auto c : sub) {
        if (c == 'C') cnt++;
    }
    if (cnt != 1) ans = "WA";

    for (int i = 1; i < s.size(); ++i) {
        if (isupper(s[i]) && s[i] != 'C') {
            ans = "WA";
        }
    }

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

Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 10000;/// 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

VI A;
int N, K;

int count(LD x) {
	int ans = 0;
	for (int n = 0; n < N; n++) {
		int t = ceil((LD)A[n] / x);
		ans += t - 1;
	}
	return ans;
}

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> N >> K;
	A.resize(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	//sなら<=K回、eなら>K回
	LD s = 1e9, e = 0;
	for (int t = 0; t < 100; t++) {
		LD m = (e + s) / 2;
		if (count(m) <= K)s = m;
		else e = m;
	}
	cout << (int)ceil(s) << "\n";
	return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    int AN = N/A+1;
    if(N%A==0)AN--;
    int CN = N/C+1;
    if(N%C==0)CN--;
    cout << min(AN*B,CN*D) << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC102();
}

void ABC102(){
    int n,i;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    cout<<vec[n-1]-vec[0]<<endl;
}


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

int32_t main() {
	int n,w;
	cin>>n>>w;
	int c[n],v[n];
	int i;
	for(i=0;i<n;i++)cin>>c[i]>>v[i];
	int j;
	int dp[n+1][w+1];
	for(i=0;i<=n;i++){
	    for(j=0;j<=w;j++){
	        if(i==0 || j==0)dp[i][j] = 0;
	        else if(j < c[i-1])dp[i][j] = dp[i-1][j];
	        else{
	            dp[i][j] = max(dp[i-1][j] , v[i-1] + dp[i-1][j-c[i-1]]);
	        }
	    }
	}
	cout<<dp[n][w]<<endl;
	return 0;
}


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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c  >> x;
    int res = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int total = 500 * i + 100 * j + 50 * k;
                if (total == x) ++res;
            }
        }
    }
    cout << res << endl;
}

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

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

    map<char, int> char_cnt;
    rep(i, 0, s.size()) char_cnt[s[i]]++;

    vector<int> st_map(26, -1);
    vector<int> ts_map(26, -1);
    bool ans = true;
    rep(i, 0, s.size())
    {
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if (st_map[a] != -1 || ts_map[b] != -1)
        {
            if (st_map[a] != b || ts_map[b] != a)
            {
                ans = false;
                break;
            }
        }
        st_map[a] = b;
        ts_map[b] = a;
    }

    if (ans) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#define MAX 100
#define IN 10000


int main(){
int n,i,j,dat[MAX][MAX],min,tmp[MAX],mini=0,a[MAX],flag[MAX],k,sum=0;

scanf("%d",&n);

for ( i = 0; i < n;i++){
for (j = 0;j < n;j++){
scanf("%d",&dat[i][j]);
}
}
for ( i =0 ;i < n; i++){
flag[i]=0;
a[i]=IN;
}
a[0] =0;

for (k = 0 ;k < n-1;k++){
min =IN;
  
for ( i = 0; i < n;i++){
if(a[i] < min && flag[i] ==0){
min = a[i];
mini = i;
}
}
flag[mini]= 1;

for (j = 0;j < n;j++){

if(dat[mini][j] < a[j] && dat[mini][j] != -1 && flag[j]==0){
a[j] = dat[mini][j];
}
     
      
     
}
   
}

for ( i =0 ; i < n; i++){
sum += a[i];
}
printf("%d\n",sum);








return 0;

}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a > b) {
            int d = a;
            a = b;
            b = d;
        }

        if(b > c) {
            int d = b;
            b = c;
            c = d; 
        }

        if(a > b) {
            int d = a;
            a = b;
            b = d;
        }

        System.out.println(a + " " + b + " " + c);
	}
}


Measured memory_bytes: 26228
function main(input) {
  var A = Number(input.split(" ")[0]);
  var B = Number(input.split(" ")[1]);
  var big = A > B ? A : B;
  var small = A > B ? B : A;
  var int1 = big;
  var int2 = big-1 > small ? big-1 : small;
  console.log(Number(int1)+Number(int2));
}

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


Measured memory_bytes: 7372
def examC():
    N = I()
    s = [I() for _ in range(N)]
    is_trueScore = [False]*(max(s)*N+1)
    is_trueScore[0] = True
    ans = 0
    for i in s:
        for j in range(max(s)*N,i-1,-1):
            if is_trueScore[j-i]==True:
                is_trueScore[j]=True
    for i in range(max(s)*N+1):
        if i%10!=0:
            if is_trueScore[i]:
                ans = i
    print(ans)




import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  int ans = 0;
  int a = 0, b = 0, ba = 0;
  rep(i, n) {
    string s;
    cin >> s;
    int m = sz(s);
    rep(j, m - 1) {
      if (s.substr(j, 2) == "AB") ans += 1;
    }
    if (s.front() == 'B' && s.back() == 'A') {
      ba += 1;
    } else if (s.front() == 'B') {
      b += 1;
    } else if (s.back() == 'A') {
      a += 1;
    }
  }
  if (ba > 0) {
    ans += ba - 1;
    if (a > 0) {
      ans += 1;
      a -= 1;
    }
    if (b > 0) {
      ans += 1;
      b -= 1;
    }
  }
  ans += min(a, b);
  cout << ans << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

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

	int N;
	string S;
	vector<BIT> DP;
	cin>>N>>S;
	DP.push_back(BIT(N));
	DP.push_back(BIT(N));

	int tar=1;
	DP[0].add(0,1);

	rep(i,1,N)
	{
		DP[tar]=BIT(N);
		rep(j,0,i+1)
		{
			if(S[i-1]=='<')
			{
				int l=0,r=j-1;
				if(r<l)continue;
				int res=DP[tar^1].sum(r)%MOD;
				DP[tar].add(j,res);
			}
			else
			{
				int l=j,r=i-1;
				if(r<l)continue;
				int res=DP[tar^1].sum(r)%MOD;
				if(0<l)res=(res-(DP[tar^1].sum(l-1)%MOD)+MOD)%MOD;
				DP[tar].add(j,res);
			}
		}
		tar^=1;
	}
	tar^=1;

	cout<<DP[tar].sum(N-1)%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;cin>>a>>b;
	if((a+b)%2)puta("IMPOSSIBLE");
	else puta((a+b)/2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
    int ant[5];
    for (int i = 0; i < 5; i++)
        cin >> ant[i];
    int k;
    cin >> k;

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (ant[j] - ant[i] > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<ll> a(m),b(m,0),dp((1<<n),inf);
	rep(i,m){
		cin>>a[i];
		int x;
		cin>>x;
		rep(j,x){
			int c;
			cin>>c;
			c--;
			b[i]+=(1<<c);
		}
	}
	dp[0]=0;
	rep(S,1<<n){
		rep(i,m){
			ll T=S;
			rep(j,n){
				if(1<<j & b[i]){
					T|=(1<<j);
				}
			}
			chmin(dp[T],dp[S]+a[i]);
		}
	}
	if(dp[(1<<n)-1]==inf) cout<<-1<<endl;
	else cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define lin puts("");
ll n,x,y,a[300000],b[300000],c=0,t=0,sum=0,z=0,i,j,f=0;
char ch[101],cr,ss[101];
string s;
int main()
{
    rep(i,0,2)
    cin>>a[i];
    swap(a[0],a[1]);
    swap(a[0],a[2]);
    rep(i,0,2)
    cout<<a[i]<<" ";
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int N;
int a[200005];
int xorsum;

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> a[i];
	for (int i = 1; i <= N; i++)
		xorsum ^= a[i];
	for (int i = 1; i <= N; i++)
		cout << (xorsum ^ a[i]) << (i == N ? '\n' : ' ');
	return 0;
}

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

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

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n, i;
	cin >> n >> i;

	cout << n - i + 1 << endl;




    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
signed main(){
   int a,b;
   P c[10000];
   while(scanf("%d%d",&a,&b),a|b){
       for(int d=0;d<a;d++){
	   int e,f;
	   scanf("%d%d",&e,&f);
	   c[d]=P(f,e);
	   }
	   sort(c,c+a);
	   reverse(c,c+a);
	   int s=0;
	   for(int g=0;g<a;g++){
	       int l=min(b,c[g].second);
	       b-=l;
	       c[g].second-=l;
	       s+=c[g].first*c[g].second;
	       }
	       printf("%d\n",s);
       }
}

Measured memory_bytes: 3204
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=1e5+5, OO=1e18;
using namespace std;
int arr[100005],ans[100005],n,k;
int solve(int idx)
{
    if (idx >= n) return 2e9;
    if (idx == n-1) return 0;
    //cout << idx << endl;
    if (ans[idx]!=-1) return ans[idx];
    int anss = 2e9;
    for (int i=1; i<=k; ++i)
    {
        anss=min(anss,abs(arr[idx]-arr[idx+i])+solve(idx+i));
    }
    ans[idx]=anss;
    return anss;
}
int main()
{
    ahmocs
    cin>>n>>k;
    for (int i=0; i<n; ++i) ans[i]=-1;
    for (int i=0; i<n; ++i) cin>>arr[i];
    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[1000][1000];
void func(int);
int main(void)
{
	int n,f,p,i,j,inm[100],inn[100][10],x,y,m,k,flg,p2;
	char list[1000][31],buf[31],syu[5000][2][31];
	scanf("%d %d",&n,&f);
	p=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&m);
		inm[i]=m;
		for(j=0;j<m;j++)	{
			scanf("%s",buf);
			flg=0;
			for(k=0;k<p;k++)	{
				if(strcmp(buf,list[k])==0)	{
					flg=1;
					break;
				}
			}
			if(flg==1)	{
				inn[i][j]=k;
			}
			else {
				strcpy(list[p],buf);
				inn[i][j]=p;
				p++;
			}
		}
	}
	for(i=0;i<p;i++)	{
		for(j=0;j<p;j++)	{
			a[i][j]=0;
		}
	}
	for(i=0;i<n;i++)	{
		for(j=0;j<inm[i];j++)	{
			for(k=0;k<inm[i];k++)	{
				x=inn[i][j];
				y=inn[i][k];
				if(x!=y)	{
					a[x][y]++;	a[y][x]++;
				}
			}
		}
	}
/*	for(i=0;i<p;i++)	{
		for(j=0;j<p;j++)	{
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
*/	
	
	p2=0;
	for(i=0;i<p;i++)	{
		for(j=i+1;j<p;j++)	{
			if(a[i][j]>=f*2)	{
				strcpy(syu[p2][0],list[i]);
				strcpy(syu[p2][1],list[j]);
				if(strcmp(syu[p2][0],syu[p2][1])>0)	{
					strcpy(buf,syu[p2][0]);
					strcpy(syu[p2][0],syu[p2][1]);
					strcpy(syu[p2][1],buf);
				}
				p2++;
			}
		}
	}
	for(i=0;i<p2-1;i++)	{
		for(j=i+1;j<p2;j++)	{
			if(strcmp(syu[i][0],syu[j][0])>0 || (strcmp(syu[i][0],syu[j][0])==0 && strcmp(syu[i][1],syu[j][1])>0))	{
				strcpy(buf,syu[i][0]);
				strcpy(syu[i][0],syu[j][0]);
				strcpy(syu[j][0],buf);				
				strcpy(buf,syu[i][1]);
				strcpy(syu[i][1],syu[j][1]);
				strcpy(syu[j][1],buf);		
			}
		}
	}
	printf("%d\n",p2);
	for(i=0;i<p2;i++)	{
		printf("%s %s\n",syu[i][0],syu[i][1]);
	}

	return 0;
}


Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    string s;
    cin >> s;

    stringstream ss;
    ss << s;

    FOR(i, 0, 15){
        ss << 'o';
    }

    s = ss.str();

    ll win = 0;
    FOR(i, 0, 15){
        if(s[i]=='o'){
            win++;
        }
    }

    if(win>=8){
        p_yes();
    }
    else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
// 2011/01/13 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

struct bindex{
	string wrd;
	int pag;
};

int main()
{
	struct bindex ind[100];
	int n=0;

	while(!cin.eof()){
		string str;
		getline(cin, str);

		if(!str.empty()){
			istringstream ist(str);
			ist >> ind[n].wrd >> ind[n].pag;
			n++;
		}
	}

	for(int i=0; i<n-1; i++)
		for(int j=i+1; j<n; j++)
			if((ind[i].wrd>ind[j].wrd)||(ind[i].wrd==ind[j].wrd&&ind[i].pag>ind[j].pag)){
				string wrd_tmp = ind[i].wrd;
				int pag_tmp = ind[i].pag;
				ind[i].wrd = ind[j].wrd;
				ind[i].pag = ind[j].pag;
				ind[j].wrd = wrd_tmp;
				ind[j].pag = pag_tmp;
			}

	cout << ind[0].wrd << endl;
	cout << ind[0].pag;
	for(int i=1; i<n; i++)
		if(ind[i-1].wrd==ind[i].wrd){
			cout << ' ' << ind[i].pag;
		}
		else{
			cout << endl;
			cout << ind[i].wrd << endl;
			cout << ind[i].pag;
		}
	cout << endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = max(a, c);
	int y = min(b, d);
	if (x > y)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << y - x << endl;
	}
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		c, _ := strconv.Atoi(buf[2])
		d, _ := strconv.Atoi(buf[3])
		e, _ := strconv.Atoi(buf[4])
		f, _ := strconv.Atoi(buf[5])
		if a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0 {
			break
		}
		fmt.Println(100-((5*a+3*b)*2)-(f-5*a-3*b-e)*3+15*a+15*b+15*(5*a+3*b)+c*7+d*2)
	}
}


Measured memory_bytes: 1120
N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
S[0] = 0
for i in range(N):
  S[i+1] = S[i] + A[i]

ans = float("INF")
for i in range(1, N+1):
  lsum = S[i]
  rsum = S[N]-S[i]
  ans = min(ans, abs(rsum-lsum))
  
print(ans)

Measured memory_bytes: 26220
#include <stdio.h>

int main(void){
	char c;
    while(1){
        c = getchar();
	if      (c >= 'a' && c <= 'z') c += 'A' - 'a';
	else if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
	printf("%c", c);
	if(c == '\n') return 0;
    }
    return 0;
}


Measured memory_bytes: 2552
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define NMAX 100000
#define MMAX 10000
using namespace std;
vector<int > group[NMAX];
int main(){
	int N,T,A[NMAX] = {},dif[NMAX] = {},most = 0,first,end = 0,num = 0,gr_num = 0;
	cin >> N >> T;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if(i == 0){
			first = A[i];
			group[gr_num].push_back(A[i]);
		}else if(first < A[i]){
			group[gr_num].push_back(A[i]);
			if(i == N-1){
				sort(group[gr_num].begin(), group[gr_num].end());
				dif[gr_num] = group[gr_num][group[gr_num].size()-1]-group[gr_num][0];
				most = max(most,dif[gr_num]);
			}
		}else{
			first = A[i];
			sort(group[gr_num].begin(), group[gr_num].end());
			dif[gr_num] = group[gr_num][group[gr_num].size()-1]-group[gr_num][0];
			most = max(most,dif[gr_num]);
			gr_num++;
			group[gr_num].push_back(A[i]);
		}
	}
	// for (int i = 0; i <= gr_num; ++i)
	// {
	// 	for (int j = 0; j < group[i].size(); ++j)
	// 	{
	// 		cout << group[i][j] << " ";
	// 	}
	// 	cout << dif[i];
	// 	cout << "\n";
	// }
	for (int i = 0; i < N; ++i)
	{
		if(dif[i] == most){
			num += /*dif_num[i]*/1;
			// cout << dif_num[i] << "\n";
		}
	}
	// cout << dif_num[N-1] << "\n";
	cout << num << "\n";
	return 0;
}

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

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t ans;
    int64_t r = n % (a + b);
    ans = n / (a + b) * a;
    ans += min(r, a);
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<unordered_set>

int main(){
    int n;
    std::cin >> n;
    std::unordered_set<std::string> set;
    for(int i = 0; i < n; i++){
        std::string S;
        std::cin >> S;
        set.insert(S);
    }

    std::cout << set.size() << std::endl;
    return 0;
}


Measured memory_bytes: 17704
#include<stdio.h>

int main(){
	int i,t,n,c;
	for(i=0;i<4;i++){
		scanf("%d%d",&t,&n);
		if(t==1)c=6000;
		else if(t==2)c=4000;
		else if(t==3)c=3000;
		else c=2000;
		printf("%d\n",c*n);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << " ";

signed main()
{
	// freopen("in.txt", "r",stdin);
	// freopen("out.txt" ,"w", stdout);
	ios:: sync_with_stdio(false); cin.tie(0);
	
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int red[a], green[b], col_less[c];

	for(int i = 0; i < a; i++) cin >> red[i];
	for(int i = 0; i < b; i++) cin >> green[i];
	for(int i = 0; i < c; i++) cin >> col_less[i];

	sort(red, red+a, greater<int>());
	sort(green, green+b, greater<int>());
	sort(col_less, col_less+c, greater<int>());
	
	int arr[x+y+c];
	for(int i = 0; i < x; i++) arr[i] = red[i];
	for(int i = 0; i < y; i++) arr[x+i] = green[i];
	for(int i = 0; i < c; i++) arr[x+y+i] = col_less[i];

	sort(arr, arr+x+y+c, greater<int>());
	
	cout << accumulate(arr, arr+x+y, 0ll);
}

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

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

int main() {
    string S, T;
    cin >> S >> T;
    if (S[0] == T[2] && S[1] == T[1] && S[2] == T[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256