akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int arr[200009] = {0};
int dp[21][200009] = {0};

long long int fun(int n)
{
    long long int m = n, i, j, k = n + 1;
    m *= k;
    m /= 2;
    m -= n;
    return m;
}
int main()
{
    long long int n, m, i, j, k;
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> m;
        arr[i] = m;
        for(j = 0; j < 21; j++)
        {
            dp[j][i] = m % 2;
            m /= 2;
            dp[j][i] += dp[j][i - 1];
        }
    }
    for(i = 0; i < 21; i++)
    {
        dp[i][n + 1] = INT_MAX;
    }
    int ck,mx=0,mn = INT_MAX;
    long long int ans  = 0ll;
    for(i=1;i<=n;i++)
    {
        mn = 100000000;
        for(j=0;j<21;j++)
        {
            int up = upper_bound(dp[j]+1,dp[j]+n+1,(dp[j][i-1]+1)) - dp[j];
            //cout<<up<<" ";
            //up++;
            if(dp[j][up]-dp[j][i-1]>1)
                up--;
            mn = min(mn,up);
        }
        //cout<<i<<" "<<mn<<" "<<(mn-i)<<endl;
        ans+=(mn-i);

    }

    cout << ans+n << endl;

    return 0;
}


Measured memory_bytes: 17408
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

ll gcd(ll x, ll y) { return (x == 0) ? y : gcd(y % x, x); }

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

  ll curlcm;
  cin >> curlcm;

  for (ll i = 1; i < N; i++) {
    ll tmp;
    cin >> tmp;
    ll x = min(curlcm, tmp);
    ll y = max(curlcm, tmp);
    curlcm = x/gcd(x, y)*y;
  }


  cout << curlcm << endl;

  return 0;
}


Measured memory_bytes: 256
# import io
# import sys

# _INPUT = """\
# 1 4 120
# 100 1 1 1 1 1 1 1 1 1 1
# 80 10 10 10 10
# """
# sys.stdin = io.StringIO(_INPUT)

####################################################################
import sys
def p(*_a):
  return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################

N,M,K = map(int, input().split())
A = [0] + [int(i) for i in input().split()]
B = [0] + [int(i) for i in input().split()]


# 累積和
from itertools import accumulate
C = list(accumulate(A))
D = list(accumulate(B))

p(*C)
p(*D)

ans = 0
d = len(D) - 1
for c in range(len(C)):
  if C[c] > K: break
  while True:
    if C[c] + D[d] <= K: break
    d -= 1

  ans = max(ans , c + d)

print(ans)


Measured memory_bytes: 50460
N,K = map(int,input().split())
A = list(map(int,input().split()))
A += A
d = {}
da = {}
for i in range(2*N):
    a = A[i]
    if a in da:
        d[da[a]] = i
    da[a] = i
        
for i in range(N):
    if d[i] >= N:
        d[i] %= N


s = 0
k = K
while k > 1:
    if d[s]<=s:
        k -= 1
    if d[s] == N-1:
        k = K%(K-k+1)
    s = (d[s]+1)%N

if k == 0:
    print('')
else:
    ans = []
    while s <= N-1:
        if s < d[s]:
            s = d[s]+1
        else:
            ans.append(str(A[s]))
            s += 1
    print(' '.join(ans))

Measured memory_bytes: 124392
/**
*    created: 11.07.2020 21:00:08
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int l, r, d;
    cin >> l >> r >> d;
    if (l == 0) cout << r/d << endl;
    else cout << r/d - (l-1)/d << endl;
    return 0;
}

Measured memory_bytes: 3632
/*
Mangal bhavan amangal haari
Drabahu su Dasharath achar Bihari
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hoi hai wohi jo Raam rachi raakha
Ko kari tarak badhave saakha
Raam Siya Raam Siya Raam jai jai Raam
Ho dheeraj dharam mitra aru naari
Aapad kaal parakhiye chaari
Ho jehike jehi par satya sanehu
So tehi milay na kachhu sandehu
Ho jaaki rahi bhawana jaisi
Prabhu murati dekhi tin taisi
Ho Raghukul reet sada chali aayi
Praan jaaye par vachan na jaayi
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hari anant hari katha ananta
Kahahi sunahi bahuvidhi sab santa
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i
vector<int> sieve(ll n) 
{ 
//cout<<":";
    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = n; 

    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i);  
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a ;//% mod;
		a = 1LL * a * a ;//% mod;
		b >>= 1;
	}
	return res;
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
#define PI 3.141592653589793
ll lcm(ll a,ll b)
{
	return a*b/__gcd(a,b);
	//return t*c/__gcd(t,c);
}
bool isprime(ll n)
{
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		return false;
	}
	return true;
}
ll v(ll n)
{
	if(isprime(n))
	return 1;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return max(i,n/i);
		}
	}
}
void solve()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}
ll ans=1000,s=0,l=1000,cp=INT_MAX,t=1000;
ll m=INT_MAX;
int d=1;
for(int i=0;i<n;i++)
{
	if(d==1)
	{
		if(arr[i]<m)
		{
			m=arr[i];
		}
		if(arr[i]>m)
		{
		s=l/m;
		l%=m;
		m=arr[i]-1;
		d=0;
		}
	}
	if(d==0)
	{
	if(arr[i]>m)
	{
		//cout<<i<<"\\n";
		l=l+(s*arr[i]);
		ans=max(ans,l);
		m=arr[i];
		d=1;
	}
    }
   // cout<<l<<"\n";
}
cout<<ans;
}

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
int mul=0;
if(mul==1)
{
 int t;
    cin>>t;
   while(t--)
    {
    //	cout<<"Case #"<<i<<": ";
		solve();
	cout<<"\n";
    }
}
else
{
	solve();
}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll k,x;
  cin >> k >> x;
  for(ll i = x+1-k; i <= x+k-1; ++i) cout << i << ' ';
  return 0;
}

Measured memory_bytes: 256
f[168],z[]={24,23,25,12,36,11,13,35,37,22,26,48,0},x,y;main(s){for(;~scanf("%d,%d,%d",&x,&y,&s);)for(s*=4;s+1;++f[y*12+x+z[s--]]);for(x=y=0,s=23;++s<144;s%12<10?y=fmax(y,f[s]),f[s]&&++x:0);return!printf("%d\n%d\n",100-x,y);}

Measured memory_bytes: 0
#include<iostream> 
#include<string>

int main(void) {
	int a;
	std::cin >> a;
	int count = 0;
	if (a<10) {
		count = a;
	}
	if (a<100&&a>=10) {
		count = 9;

	}
	if (a >= 100&&a<1000) {
		count = 9 + (a - 99);
	}
	if (a >= 1000 && a < 10000) {
		count = 909;
	}
	if (a >= 10000 && a < 100000) {
		count = 909 + (a - 9999);
	}
	if (a == 100000) {
		count = 90909;
	}
	std::cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    string a,b,c,d; cin>>a>>b;
    c=string(ci(b[0],'0'),a[0]);
    d=string(ci(a[0],'0'),b[0]);
    if(c<d) cout<<c<<'\n';
    else cout<<d<<'\n';
}

signed main() { 
    IO();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)

typedef pair<int, int> pii;
const int NR = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;

#define fi first
#define se second

int f[NR], w[NR], L[NR], R[NR], s[NR], n;
pii a[NR];
vector<int> v[NR];

int main() {
	scanf("%d", &n);
	iter(i, n) scanf("%d%d", &a[i].fi, &a[i].se), w[i] = a[i].se;
	sort(a + 1, a + n + 1);
	sort(w + 1, w + n + 1);
	int wl = unique(w + 1, w + n + 1) - w - 1;
	iter(i, n) a[i].se = lower_bound(w + 1, w + wl + 1, a[i].se) - w;
	iter(i, n) R[i] = max(R[i - 1], a[i].se);
	L[n + 1] = inf;
	iter_r(i, n) L[i] = min(L[i + 1], a[i].se), v[R[i]].push_back(L[i]);
	//iter(i, n) printf("[%d %d]\n", L[i], R[i]);
	f[0] = 1; s[0] = 1;
	iter(i, wl) {
		sort(v[i].begin(), v[i].end(), greater<int>());
		s[i] = s[i - 1];
		int pw = 1;
		for (int l : v[i]) {
			int tmp = 1ll * pw * (s[i - 1] - (l >= 2 ? s[l - 2] : 0) + mod) % mod;
			f[i] = (f[i] + tmp) % mod;
			s[i] = (s[i] + tmp) % mod;
			pw = pw * 2 % mod;
		}
	//	printf("%d ", f[i]);
	}
//	puts("");
	printf("%d\n", f[wl]);
	return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  vector<ll> sum(N+1);
  rep(i, N) sum[i+1] = sum[i] + A[i];

  if(M == N*N) {
    cout << sum[N] * 2 * N << endl;
    return 0;
  }

  ll val = 0;
  int mn = 0;
  ll cnt = 0;
  auto test = [&](ll t) {
    cnt = 0;
    val = 0;
    mn = 0;
    rep(i, N) {
      auto j = lower_bound(all(A), t-A[i]) - begin(A);
      if(j > 0) {
        mn = max(A[i]+A[j-1], mn);
      }
      val += (sum[N]-sum[j]) + A[i] * (N-j);
      cnt += (N-j);
    }
    return cnt <= M;
  };
  auto binary_search = [&]() {
    ll ng = 0, ok = 200005;
    while(abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      if(test(mid)) ok = mid;
      else ng = mid;
    }
    return ok;
  };
  ll mx = binary_search();
  test(mx);
  cout << val+(M-cnt)*mn << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
//int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2320 : Infinity Maze **/
typedef long long int ll;
ll dd[100][100][4];
char board[100][100];
int H, W;
ll L;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

int main()
{
	string label = "NESW";
	
	while (cin>>H>>W>>L, H||W||L) {
		int d, sx, sy;
		memset(dd, -1, sizeof(dd));
		
		rep(y, H) {
			rep(x, W) {
				char c; cin>>c;
				board[x][y] = c;

				if (c!='.' && c!= '#') {
					if (c=='N') {
						d = 0;
					} else if (c=='E') {
						d = 1;
					} else if (c=='S') {
						d = 2;
					} else if (c=='W') {
						d = 3;
					}
					sx = x; sy = y;
				}
			}
		}
		
		dd[sx][sy][d] = 0;
		
		ll t=0; bool find=false; int ansd;
		while (L>0) {
			int nx = sx+dx[d], ny = sy+dy[d];
			
			if (0<=nx && nx<W && 0<=ny && ny<H && board[nx][ny]!='#') {
				if (!find && dd[nx][ny][d]>=0) {
					L %= (t+1 - dd[nx][ny][d]);
					find = true;
				} else {
					sx = nx; sy = ny;
					L--; t++;
					dd[sx][sy][d] = t;
					ansd = d;
				}
			} else {
				d++; d%=4;
			}
		}
		
		cout << sy+1 << " " << sx+1 << " " << label[ansd] << endl;
	}
}

Measured memory_bytes: 1544
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>

const int w_max = 30;
const int h_max = 60;

int stage[w_max][h_max];
int cost[w_max][h_max][2];

int w, h;

typedef std::tuple<int, int> S;
std::tuple<int, int> can[2][9] =
{
	{
		S(-3, 0), S(-2, 1), S(-2, 0), S(-2, -1), S(-1, 2), S(-1, 1), S(-1, 0), S(-1, -1), S(-1, -2)
	}, 
	{
		S(3, 0), S(2, 1), S(2, 0), S(2, -1), S(1, 2), S(1, 1), S(1, 0), S(1, -1), S(1, -2)
	}
};

typedef std::tuple<int, int, int, bool> T;
int search(int x, int y, bool migi)
{
	for ( int k = 0; k < h; ++k ) {
		for ( int l = 0; l < w; ++l ) {
			cost[l][k][0] = 0xffff;
			cost[l][k][1] = 0xffff;
		}
	}
	cost[x][y][migi] = 0;

	int min = 0xffff;
	std::priority_queue<std::tuple<T>, std::vector<T>, std::greater<T>> q;
	q.push(T(0, x, y, migi));
	while(!q.empty()) {
		int c = std::get<0>(q.top());
		int px = std::get<1>(q.top());
		int py = std::get<2>(q.top());
		int pmigi = std::get<3>(q.top());
		q.pop();
		//std::cout << c << " " << px << " " << py << " " << pmigi << std::endl;

		if ( stage[px][py] == 11 ) {
			if ( c < min ) min = c;
		}
		
		for ( int i = 0; i < 9; ++i ) {
			int nx = px + std::get<0>(can[pmigi][i]);
			int ny = py + std::get<1>(can[pmigi][i]);

			if ( nx < 0 || ny < 0 || nx >= w || ny >= h || stage[nx][ny] == 10 ) continue;
			int nc = c;
			if ( stage[nx][ny] < 10 ) {
				 nc += stage[nx][ny];
			}

			if ( cost[nx][ny][1-pmigi] > nc ) {
				cost[nx][ny][1-pmigi] = nc;
				q.push(T(nc, nx, ny, 1-pmigi));
			}
		}
	}
	return min;
}

int main()
{
	while(true){
		std::cin >> w >> h;

		if ( w == 0 && h == 0 ) break;
		for ( int j = 0; j < h; ++j ) {
			for ( int i = 0; i < w; ++i ) {
				char c;
				std::cin >> c;
				if ( isdigit(c) ) {
					stage[i][j] = c - '0';
				} else {
					switch(c) {
						case 'X':
							stage[i][j] = 10;
							break;
						case 'T':
							stage[i][j] = 11;
							break;
						case 'S':
							stage[i][j] = 12;
							break;
					}
				}
			}
		}

		int min = 0xffff;
		for ( int i = 0; i < h; ++i ) {
			for ( int j = 0; j < w; ++j ) {
				if ( stage[j][i] == 12 ) {
					int a = search(j, i, false);
					int b = search(j, i, true);

					if ( a < min ) min = a;
					if ( b < min ) min = b;
				}
			}
		}
		if ( min == 0xffff ) {
			std::cout << -1 << std::endl;
		} else {
			std::cout << min << std::endl;
		}
	}
}

Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	string s; cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}
	return;
}

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

Measured memory_bytes: 3624
import re

def main():
    s = input()
    d = {}
    n = len(re.findall(r'\w', s))
    for i in range(n):
        a, v = input().split()
        v = int(v)
        d[a] = v

    prog = re.compile(r'\[(\w)-(\w)\]')
    m = prog.search(s)
    while m is not None:
        c1, c2 = m.group(1, 2)
        if d[c1] == d[c2]:
            print('No')
            return 0

        if d[c1] < d[c2]:
            d[c2] -= 1
            s = prog.sub(c2, s, 1)
            if d[c1] != 0:
                print('No')
                return 0
        else:
            d[c1] -= 1
            s = prog.sub(c1, s, 1)
            if d[c2] != 0:
                print('No')
                return 0

        m = prog.search(s)

    if len(s) != 1:
        print('No')
    elif [0 for k, v in d.items() if v]:
        print('No')
    else:
        print('Yes')
    return 0

if __name__ == '__main__':
    main()



Measured memory_bytes: 6560
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int b,r,g,c,s,t;
	cin >> b >> r >> g >> c >> s >> t;
	if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)break;
	int coin = 100;
	coin += b*13*5 + b*12;
	coin += r*13*3 + r*12;
	coin += g*4;
	coin += c*(-1);
	coin -= (t-s-b*6-r*4-g-c)*3;
	cout << coin << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 8/18/2018, 9:08:51 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

class BIT
{ // index starts at 1.
public:
  int N;
  ll *data;

  BIT(int n) : N(n)
  {
    data = new ll[N + 1];
    for (auto i = 1; i <= N; ++i)
    {
      data[i] = 0;
    }
  }

  ~BIT()
  {
    delete[] data;
  }

  ll sum(int i)
  { // [1, i]
    ll s = 0;
    while (i > 0)
    {
      s += data[i];
      i -= i & -i;
    }
    return s;
  }

  ll sum(int a, int b)
  { // [a, b)
    return sum(b - 1) - sum(a - 1);
  }

  void add(int i, ll x)
  {
    while (i <= N)
    {
      data[i] += x;
      i += i & -i;
    }
  }

  void add(int i)
  {
    add(i, 1);
  }
};

int N, M, Q;

typedef tuple<int, int> que;

vector<int> seg[510];
vector<que> X[510];
int ans[100010];

int main()
{
  cin >> N >> M >> Q;
  for (auto i = 0; i < M; i++)
  {
    int l, r;
    cin >> l >> r;
    seg[r].push_back(l);
  }
  for (auto i = 0; i < Q; i++)
  {
    int l, r;
    cin >> l >> r;
    X[r].push_back(que(l, i));
  }
  BIT bit(510);
  for (auto r = 1; r <= N; r++)
  {
    for (auto x : seg[r])
    {
      bit.add(x);
    }
    for (auto x : X[r])
    {
      int l = get<0>(x);
      int ind = get<1>(x);
      ans[ind] = bit.sum(l, r + 1);
    }
  }
  for (auto i = 0; i < Q; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3712
<?php
# 整数の入力
fscanf(STDIN, "%d %d", $x, $y);

$grpA = array(1,3,5,7,8,10,12);
$grpB = array(4,6,9,11);
$grpC = array(2);

function sch($ary, $src)
{

    foreach ($ary as $a) {
        if ($a == $src) {
            return true;
        }
    }
    return false;
}

$ret = 'No';
if (sch($grpA, $x) == true) {
    if (sch($grpA, $y) == true) {
        $ret = 'Yes';
    }
} elseif (sch($grpB, $x) == true) {
    if (sch($grpB, $y) == true) {
        $ret = 'Yes';
    }
} elseif (sch($grpC, $x) == true) {
    if (sch($grpC, $y) == true) {
        $ret = 'Yes';
    }
}
echo $ret;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int figure_len(ll n)
{
    int ret = 0;
    while (n != 0)
    {
        ret++;
        n /= 10;
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    int ans = (1 << 30);
    rep(a, 1, n + 1)
    {
        ll b = n / a;
        if (b < a)
        {
            break;
        }
        if (n % a != 0)
            continue;
        ans = min(ans, max(figure_len(a), figure_len(b)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<char, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;
        mp['W'] = mp['E'] = mp['N'] = mp['S'] = 0;
        rep(i, s.length()) mp[s[i]] = 1;
        if (mp['W'] * mp['E'] == 1 && mp['N'] * mp['S'] == 1)cout << "Yes" << endl;
        else {
            if (mp['W'] == 0 && mp['E'] == 0 && mp['N'] * mp['S'] == 1)cout << "Yes" << endl;
            else if (mp['W'] * mp['E'] == 1 && mp['N'] == 0 && mp['S'] == 0)cout << "Yes" << endl;
            else if (mp['N'] * mp['S'] == 1 && mp['W'] == 0 && mp['E'] == 0)cout << "Yes" << endl;
            else if (mp['W'] == 0 && mp['E'] == 0 && mp['N'] == 0 && mp['S'] == 0)
                cout << "Yes" << endl;
            else cout << "No" << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
a = [0] * 5
for i in range(5):
    a[i] = int(input())
ans = 0
tmp = 10
for i in range(5):
    if a[i]%10 == 0:
        ans += a[i]
    else:
        ans += (a[i]//10)*10+10
        tmp = min(tmp,a[i]%10)
if tmp == 10:
    print(ans)
else:
    print(ans+tmp-10)

Measured memory_bytes: 3060
def resolve():
    S = input()
    zero = 0
    one = 0
    for i in range(len(S)):
        if i%2 == 0 and S[i] != "0" or i%2 == 1 and S[i] != "1":
            zero += 1
        elif i%2 == 0 and S[i] != "1" or i%2 == 1 and S[i] != "0":
            one += 1
    print(min(one, zero))
resolve()

Measured memory_bytes: 9136
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=100000000000000000;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
    string s,t;
    cin>>s>>t;
    vector<bool> used(26,false);
    for(int i=0;i<s.size();i++)used.at(s.at(i)-'a')=true;
    for(int i=0;i<t.size();i++){
        if(!used.at(t.at(i)-'a')){
            cout<<-1<<endl;
            return 0;
        }
    }
    vector<vector<ll>> num(26,vector<ll>(0));
    for(int i=0;i<s.size();i++){
        num[s[i]-'a'].push_back(i);
    }
    ll now=-1,ans=0,cnt=0;
    for(int i=0;i<t.size();i++){
        ll ite=upper_bound(num[t[i]-'a'].begin(),num[t[i]-'a'].end(),now)-num[t[i]-'a'].begin();
        if(ite==num[t[i]-'a'].size()){
            cnt++;
            now=num[t[i]-'a'][0];
        }
       else now=num[t[i]-'a'][ite];
    }
    ans=cnt*s.size()+now+1LL;
    cout<<ans<<endl;
}


Measured memory_bytes: 1724
import           Control.Applicative
import           Control.Monad
import           Data.List           hiding (union)
import           Text.Printf

---------------------------------------------------------------------------
primesTME :: [Int]
primesTME = 2 : ([3,5..] `minus` foldt [[p*p,p*p+2*p..] | p <- primes_])
   where
     primes_ = 3 : ([5,7..] `minus` foldt [[p*p,p*p+2*p..] | p <- primes_])
     foldt ((x:xs):t)    = x : union xs (foldt (pairs t))
     pairs ((x:xs):ys:t) = (x : union xs ys) : pairs t               -- (* Treefold Merge Eratosthenes *)
----------------------------------------------------------------------------
primesTMWE :: [Int]
primesTMWE = 2:3:5:7: gaps 11 wheel (fold3t $ roll 11 wheel primes_)
  where
   primes_ = 11: gaps 13 (tail wheel) (fold3t $ roll 11 wheel primes_)     -- separate feed
   fold3t ((x:xs): ~(ys:zs:t)) = x : union xs (union ys zs)
                                      `union` fold3t (pairs t)              -- fold3t: 5% ~ 10% speedup
   pairs ((x:xs):ys:t)         = (x : union xs ys) : pairs t
   wheel = 2:4:2:4:6:2:6:4:2:4:6:6:2:6:4:2:6:4:6:8:4:2:4:2:
           4:8:6:4:6:2:4:6:2:6:6:4:2:4:6:2:6:4:2:4:2:10:2:10:wheel
   gaps k ws@(w:t) cs@ ~(c:u) | k==c  = gaps (k+w) t u              -- (*  better fold, w/ Wheel!   *)
                              | True  = k : gaps (k+w) t cs
   roll k ws@(w:t) ps@ ~(p:u) | k==p  = scanl (\c d->c+p*d) (p*p) ws
                                          : roll (k+w) t u
                              | True  = roll (k+w) t ps
----------------------------------------------------------------------------
minus :: [Int] -> [Int] -> [Int]
minus xs@(x:xt) ys@(y:yt) = case compare x y of
  LT -> x : minus xt ys
  EQ ->     minus xt yt
  GT ->     minus xs yt
minus a         b         = a

union :: [Int] -> [Int] -> [Int]
union xs@(x:xt) ys@(y:yt) = case compare x y of
  LT -> x : union xt ys
  EQ -> x : union xt yt
  GT -> y : union xs yt
union a         []        = a
union []        b         = b


main :: IO ()
main = mapM_ (print . process . read) . lines =<< getContents
  where
    process n = length $ takeWhile (<=n) primesTMWE


Measured memory_bytes: 9716
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;


int main(){
	int a,b;
	cin>>a>>b;
	if(a-(2*b)>0){
	    cout<<a-(2*b);
	}
	else {
	    cout<<0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    int a,b[2000],c=0;
    cin>>a;
    for(int i=0;i<a*2;i++){
        cin>>b[i];
    }
    for(int i=0;i<a*2;i=i+2){
        c=b[i+1]-b[i]+1+c;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0)
		puts("Zero");
	else if (a > 0)
		puts("Positive");
	else {
		b = min(b, -1ll);
		puts(((b-a)&1) ? "Positive" : "Negative");
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, i, cards[128][13]={{0}};
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        char c; int cn;
        scanf("%c", &c);
        scanf("%c %d", &c, &cn);
        cards[c][cn] = 1;
    }
    
    for(i = 1; i <= 13; i++) {
        if(cards['S'][i] == 0) {
            printf("S %d\n", i);
        }
    }
    
    for(i = 1; i <= 13; i++) {
        if(cards['H'][i] == 0) {
            printf("H %d\n", i);
        }
    }
    
    for(i = 1; i <= 13; i++) {
        if(cards['C'][i] == 0) {
            printf("C %d\n", i);
        }
    }
    
    for(i = 1; i <= 13; i++) {
        if(cards['D'][i] == 0) {
            printf("D %d\n", i);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int a, b, c;
int main(){
    scanf("%d %d %d", &a, &b, &c);
    if(a+b+c>=22) cout << "bust\n";
    else cout <<"win\n";
    return 0;
}

Measured memory_bytes: 256
# 2分木探索
# m以下の最大の要素を返す
# 組み込みbsearchはfind-minimam
def bsearch(m, arr)
  j = (0...arr.size).bsearch {|i| arr[i] > m}
  if j.nil?
    arr.last
  elsif j > 0
    arr[j - 1]
  else
    false
  end
end

# 4重ループ O(n^4)
def main1(n,m,a)
  max = 0
  0.upto(n) do |i|
    i.upto(n) do |j|
      j.upto(n) do |k|
        k.upto(n) do |l|
          sum = a[i] + a[j] + a[k] + a[l]
          max = sum if sum <= m && sum > max
        end
      end
    end
  end

  max
end

# 3重ループ O(n^3logn)
# a[l] <= m - (a[i] + a[j] + a[k]) を2分木探索
def main2(n,m,a)
  max = 0
  0.upto(n) do |i|
    i.upto(n) do |j|
      j.upto(n) do |k|
        # k.upto(n) do |l|
        buf = m - (a[i] + a[j] + a[k])
        if buf >= 0
          a4 = bsearch(buf, a)
          sum = a[i] + a[j] + a[k] + a4
          max = sum if max < sum
        end
        # end
      end
    end
  end

  max
end

# 2重ループ O(n^2logn)
# 2要素の和をメモ化する
def main3(n,m,a)
  max = 0
  # 2要素の和を格納する配列
  sum_2 = a.dup
  0.upto(n) do |i|
    i.upto(n) do |j|
      a_2 = a[i] + a[j]
      sum_2 << a_2 if a_2 <= m
    end
  end
  sum_2.sort!

  f = sum_2.size - 1
  0.upto(f) do |i|
    another_sum_2 = bsearch(m - sum_2[i], sum_2)
    sum = sum_2[i] + another_sum_2
    max = sum if max < sum
  end

  max
end

loop do
  # 入力
  n,m = gets.split(" ").map(&:to_i)
  break if n == 0
  a = []
  a[0] = 0
  (1..n).each { |i| a[i] = gets.to_i }
  a.sort!

  # main
  puts main3(n,m,a)
end

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

int main(){
  ll N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  ll g=1,l;
  while(true){
    l=N*g;
    if(l%M==0){
      break;
    }
    g ++;
  }
  g=N*M/l;
  for(ll i=0;i<g;i++){
    if(S[i*l/M]!=T[i*l/N]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n,cnt=0; cin>>n;
	rep(i,n){
		int x; cin>>x;
		if(x%2==1) cnt++;
	}
	if(cnt%2==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input()
    T = input()
    min_count = math.inf
    for start in range(len(S)-len(T)+1):
        end = start+len(T)
        count = sum(c0 != c1 for c0, c1 in zip(S[start:end], T))
        min_count = min(min_count, count)
    return min_count


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


Measured memory_bytes: 67944
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


int main() {
  int h1, m1, h2, m2, k; 
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int time1 = h1*60 + m1 + k;
  int time2 = h2*60 + m2;
  if (time1 > time2) {
		cout<< 0;
	}
	else
		cout<< time2 - time1;
  return 0; 
} 





Measured memory_bytes: 3588
S = input()
N = []
for s in S:
  N.append(int(s))

N.reverse()

ans = 0
for i in range(len(N)):
    if i != len(N)-1:
        ans += 9
        if N[i] != 9:
            N[i+1] -= 1
    else:
        ans += N[i]

print(ans)

Measured memory_bytes: 3060
import sys

def comb(n, r, fact, revfact, mod):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def solve():
    H, W, A, B = map(int, input().split())
    mod = 7 + 10 ** 9
    fact = [1] * (H + W + 4)
    revfact = [1] * (H + W + 4)
    for i in range(1, H + W + 4): fact[i] = (i * fact[i-1]) % mod
    revfact[H + W + 3] = pow(fact[H + W + 3], mod - 2, mod)
    for i in reversed(range(1, H + W + 3)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    ans = 0
    for j in range(B + 1, W + 1):
        up = comb(H - A + j - 2, j - 1, fact, revfact, mod)
        down = comb(A + W - j - 1, A - 1, fact, revfact, mod)
        ans += (up * down) % mod
        ans %= mod
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 44268
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val N = sc.nextInt()
    val A = sc.nextInt()
    val B = sc.nextInt()
    val v = ArrayList<Long>()

    for (i in 0 until N) {
        v.add(sc.nextLong())
    }

    v.sort()
    v.reverse()

    var sum = 0L
    for (i in 0 until A) {
        sum += v[i]
    }

    System.out.printf("%1.10f\n", sum.toDouble() / A)

    val a = v.indexOfFirst { n -> n == v[(A-1)] }
    val b = v.indexOfLast { n -> n == v[(A-1)] }
    val m = b - a + 1;

    val comb = Array(60) { Array<Long>(60) {0L} }

    comb[0][0] = 1
    for (i in 1 until 60) {
        comb[i][0] = 1
        for(j in 1..i) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j]
        }
    }

    var res = 0L
    if (v[0] == v[A - 1]) {
        for (i in A..B) {
            if (v[(i - 1)] != v[(A - 1)]) {
                continue
            }

            res += comb[m][(i - a)]
        }
    } else {
        res += comb[m][A - a]
    }

    println(res)
}

Measured memory_bytes: 31768
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ii pair<int,int>
#define iii pair<ii,int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vvi vector<vector<ll> >
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define nu 100000
#define mod 1000000007
#define inf pow(10,8)
#define h pow(10,-8)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
	fastio;
	
	int n;
	cin >> n;

	vi v(n), count(n+1, 1);
	set<int> s;

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

	for (int i = n-1; i > 0; --i)
	{
		if (s.find(v[i]-1)==s.end())
		{
			count[v[i]-1] += count[v[i]];
		}
		s.insert(v[i]);
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans = max(ans, count[i]);
	}
	cout << n-ans;
}	

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
#define maxn 200009
using namespace std;
const ll INF = 100000000000;
struct edge
{
	ll a,b,cap,flow;
};
ll num,s,t,d[maxn],ptr[maxn],q[maxn];
vector<ll> g[maxn];
vector<edge> e;
inline void add_edge(ll a,ll b,ll cap)
{
	edge e1={a,b,cap,0};
	edge e2={b,a,0,0};
	g[a].pb(e.size());
	e.pb(e1);
	g[b].pb(e.size());
	e.pb(e2);
}
bool bfs()
{
	queue<ll> q;
	for(int i=0;i<=num;i++)
	{
		d[i]=-1;
	}
	d[s]=0;
	q.push(s);
	while(!q.empty())
	{
		if(d[t]!=-1)
		{
			return true;
		}
		ll x=q.front();
		q.pop();
		for(ll i=0;i<g[x].size();i++)
		{
			ll id=g[x][i];
			ll nxt=e[id].b;
			if(e[id].flow<e[id].cap)
			{
				if(d[nxt]==-1)
				{
					d[nxt]=d[x]+1;
					q.push(nxt);
				}
			}
		}
	}
	return false;
} 
ll dfs(ll vv,ll flow)
{
	if(!flow) return 0;
	if(vv==t) return flow;
	for(;ptr[vv]<(ll)g[vv].size();++ptr[vv])
	{
		ll id=g[vv][ptr[vv]],
			to=e[id].b;
		if(d[to]!=d[vv]+1) continue;
		ll pushed=dfs(to,min(flow,e[id].cap-e[id].flow));
		if(pushed)
		{
			e[id].flow+=pushed;
			e[id^1].flow-=pushed;
			return pushed;
		}
	}
	return 0;
}
ll dinic()
{
	ll flow=0;
	while(1)
	{
		if(!bfs())
		{
			break;
		}
		memset(ptr,0,num*sizeof ptr[0]);
		while(1)
		{
			ll pushed=dfs(s,INF);
			if(!pushed)
			{
				break;
			}
			flow+=pushed;
		}
	}
	return flow;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,w;
	cin>>h>>w;
	string str[h+2];
	for(int i=0;i<h;i++)
	{
		cin>>str[i];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(str[i][j]!='.')
			{
				for(int k=0;k<w;k++)
				{
					if(k!=j&&(str[i][k]!='.'))
					{
						add_edge(h*w+(i*w)+j,i*w+k,INF);
					}
				}
				for(int k=0;k<h;k++)
				{
					if(k!=i&&(str[k][j]!='.'))
					{
						add_edge(h*w+(i*w)+j,k*w+j,INF);
					}
				}
			}
		}
	}
	ll ss,tt;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(str[i][j]=='S')
			{
				ss=i*w+j;
				add_edge(i*w+j,(h*w)+(i*w)+j,INF);
			}
			else if(str[i][j]=='T')
			{
				tt=((ll)((h*w)+(i*w)+j));
				add_edge(i*w+j,(h*w)+(i*w)+j,INF);
			}
			else if(str[i][j]!='.')
			{
				add_edge(i*w+j,(h*w)+(i*w)+j,1);
			}
		}
	}
	s=2*h*w;
	t=2*h*w+1;
	num=2*h*w+100;
	add_edge(s,ss,INF);
	add_edge(tt,t,INF);
	ll ans=dinic();
	if(ans>=INF)
	{
		cout<<"-1\n";
	}
	else
	{
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 175136
#include <stdio.h>

int main(void) {
  int i, j, k, a[100], n, l, flag = 1, temp, count = 0;
  char buf[2];
  scanf("%d", &l);
  for (n = 0; n < l && (j = scanf("%d%1[\n]", a+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;

  while (flag) {
    flag = 0;
    for (j = l - 1; j > 0; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        flag = 1;
        count++;
      }
    }
  }

    for (k = 0; k < l; k++) {
      printf("%d", a[k]);
      if (k < n - 1) {
        printf(" ");
      }
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
  }



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

int n, m;

int main()
{
    cin >> n;
    for(int i = 1; i <= 9; i++){
        if(n%i) continue;
        if(n/i >= 1 && n/i <= 9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    puts("No");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int N;
vector<int> t(105, 0);
vector<int> v(105, 0);
vector<double> cum(105, 0);

double f(double time, int id){
    if(id == 0) {
        if (time == 0) return 0;
        else return time;
    } else if (id == N+1) {
        if(time == cum[N]) return 0;
        else return cum[N]-time;
    }

    if (cum[id-1]<=time && time<=cum[id]) return v[id];
    else if(time <= cum[id-1]) return v[id]+cum[id-1]-time;
    else return v[id]+time-cum[id];
}

int main(void){
    cin >> N;
    for(int i=1; i<=N; i++) cin >> t[i];
    for(int i=1; i<=N; i++) cin >> v[i];
    for(int i=1; i<=N; i++) cum[i] = cum[i-1]+t[i];

    double ans = 0.0;
    double prev = 0.0;
    for(double t=0.5; t<=cum[N]; t+=0.5){
        double now = 10000.0;
        for(int id=0; id<=N+1; id++) now = min(now, f(t, id));
        ans += (prev+now)*0.25;
        prev = now;
    }
    //cout << cum[N] << endl;

    printf("%.8lf\n", ans);

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

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

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



int m1, m2, d1, d2;

int main () {
  cin >> m1 >> d1;
  cin >> m2 >> d2;

  if ((m2 == m1 + 1) && (d2 == 1)) {
    cout << 1 << "\n";
  } else {
    cout << 0 << "\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int A, B;
	int a = 8;


  scanf("%d%d", &A , &B);

	if (A <= 8 && B <= 8) {

		printf("Yay!");
	}

  
	else {

		printf(":(");
	}
	
	return 0;



}

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

int main () {
  long long int N;
  vector<long long int> A;
  long long int sum = 0;

  cin >> N;
  for (long long int i = 0; i < N; i++) {
    long long int n;
    cin >> n;
    A.push_back(n);
    sum += n;
  }
  sort(A.begin(), A.end());
  cout << A.front() << ' ' << A.back() << ' ' << sum << endl;
}

Measured memory_bytes: 3272
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,c);
  OUT(min(a*b, c));
}

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

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

	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if x<=y and x*y>=0:
    print(y-x)
elif x>=0 and y>=0:
    print(min(x+y+1,x-y+2))
elif x<0 and y<0:
    print(min(-y-x+1,x-y+2))
elif x>=0 and y<=0 and -y<=x:
    print(x+y+1)
elif x>=0 and y<=0 :
    print(-y-x+1)
elif x<=0 and y>=0 and -x<=y:
    print(min(y-x,x+y+1))
else:
    print(min(y-x,-x-y+1))

Measured memory_bytes: 3064
n=int(input())

a='abcdefghijklmnopqrstuvwxyz'
ans=''

x=0
while True:
    if (26**(x+1)-26)/25>=n:
        break
    x+=1
beam=x

for i in range(beam):
    x=n%26
    if x==0:
      x=26
    n=(n-x)//26
    ans+=a[x-1]
print(ans[::-1])

Measured memory_bytes: 9192
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		String b = scn.next();
		int c = scn.nextInt();
		if(b.equals("+")){
			System.out.println(a + c);
		} else {
			System.out.println(a - c);
		}
	}

}


Measured memory_bytes: 10188
#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>;

const int mod = 1000000007;

ll dp[100005];

int main() {
    ll N, M;
    cin >> N >> M;

    rep(i, N) dp[i + 1] = 0;
    dp[0] = 1;

    rep(i, M) {
        int a;
        cin >> a;
        dp[a] = -1;
    }

    rep(i, N) {
        if (dp[i + 1] == -1) continue;

        if (i == 0) {
            dp[1] = 1;
            continue;
        }

        if (dp[i] != -1) dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
        if (dp[i - 1] != -1) dp[i + 1] = (dp[i + 1] + dp[i - 1]) % mod;
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,N;
  cin >> N>>A>>B;
  int C = A * N; 
  if (C == B) {
    cout << C << endl;
  }
  else if (C > B) {
    cout << B << endl;
  }
  else {
    cout << C << endl;
return 0;
  }
}

Measured memory_bytes: 256