akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;


void weather_predicition()
{
  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy\n";
  else if (s == "Cloudy") cout << "Rainy\n";
  else if (s == "Rainy") cout << "Sunny\n";
}


void odds_of_oddness()
{
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 2 != 0) ++cnt;
  }

  cout << (float)cnt / (float)n << "\n";
}


void curtain()
{
  int a, b;
  cin >> a >> b;

  if (a - 2 * b > 0) cout << a - 2 * b << "\n";
  else cout << 0 << "\n";
}


void cant_wait_for_holiday()
{
  string s;
  cin >> s;

  vector<string> S{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  int cnt = 7;
  for (int i = 0; i < 7; ++i)
  {
    if (s == S[i]) cout << cnt << "\n"; 
    --cnt;
  }

}


void blackjack()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  if (accumulate(a.begin(), a.end(), 0) >= 22) cout << "bust\n";
  else cout << "win\n";
}


void round_one()
{
  int a, b;
  cin >> a >> b;

  cout << 6 - a - b;
}


void strings()
{
  string s, t;
  cin >> s >> t;

  cout << t + s << "\n";
}


void yen_conins()
{
  int k, x;
  cin >> k >> x;

  if (k * 500 - x >= 0) cout << "Yes\n";
  else cout << "No\n";
}


void tap_dance() 
{
  string s;
  cin >> s;

  int flag = 1;
  for (int i = 1; i <= s.size(); ++i)
  {
    if (i % 2 == 0)
    {
      if (s[i] == 'L') flag = 0;
    }
    else
    {
      if (s[i] == 'R' ) flag = 0;
    }
  }
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}


void roller_coaster()
{
  int n, k;
  cin >> n >> k;

  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    int h;
    cin >> h;
    if (h >= k) ++cnt;
  }
  cout << cnt << "\n";
}


void takoyaki_festival2019()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];

  int v_sum = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      v_sum += d[i] * d[j];
    }
  }
  cout << v_sum << "\n";
}


void echo()
{
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 != 0)
  {
    cout << "No\n";
    return;
  }

  for (int i = 0; i < n / 2; ++i)
  {
    if (s[i] != s[i + n / 2])
    {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}


void rot_n()
{
  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < s.size(); ++i)
  {
    s[i] = 'A' + (s[i] - 'A' + n) % 26;
  }
  cout << s << "\n";
}



int main()
{
  //weather_predicition();
  //odds_of_oddness();
  //curtain();
  //cant_wait_for_holiday();
  //blackjack();
  //round_one();
  //strings();
  //yen_conins();

  //tap_dance();
  //roller_coaster();
  //takoyaki_festival2019();
  //echo();
  rot_n();
}

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


int main() {
  string s;
  cin >> s;
  int n = s.length();
  cout << s[0] << n -2 << s[n-1] <<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	int H[100000];
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> H[i];
	}
	int count = 0;
	int max = 0;
	for (int i = 0;i < N-1;i++) {
		if (H[i] >= H[i + 1]) {
			count++;
			/*cout << count << "#"<<max<<"$"<< i <<"%"<<H[i]<< endl;*/
		}
		else {
			if (count > max) {
				max = count;
				/*cout << count << "#"<<max<<"$"<< i <<"%"<<H[i]<< endl;*/
			}
			count = 0;
		}
	}
	if (count > max) {
		max = count;
		count = 0;
		/*cout << count << "#" << max << endl;*/
	}
	cout << max << endl;
	return 0;
	/*12
	5 8 3 8 3 0 4 2 6 3 8 3*/
}

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

int main()
{
	int n;
	cin >> n;
	vector<int>p(n);
	int i = 0;
	int exm = 0;
	int exn = 0;
	int sum = 0;
	while (i<n)
	{
		cin >> p[i];
		if (exm<p[i])
		{
			exm = p[i];
			exn = i;
		}
		sum += p[i];
		i++;
	}
	cout << (sum - exm / 2) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#define inf 100100100
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define pb push_back
#define INF (1<<31)
#include<iostream>
#include<string>
using namespace std;
vector<vector<int>> G(200100);
int U[200100] = {};
int dfs(int s,int d){
    U[s] = d;
    int t = s;
    for(int o:G[s]){
        if(U[o]==-1) t = dfs(o,d+1);
    }
    return t;
}

int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "First" << endl;
        return 0;
    }
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,200100) U[i]=-1;
    int t = 0;
    int ma = 0;
    dfs(0,0);
    rep(i,n){
        if(ma < U[i]){
            ma = U[i];
            t = i;
        }
    }
    rep(i,200100) U[i]=-1;
    dfs(t,0);
    rep(i,n){
        ma = max(U[i],ma);
    }
    if(ma%3==1){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
    return 0;
}


Measured memory_bytes: 18176
A, B = map(int,input().split())
ans_cou = 0
for i in range(A, B + 1):
    str_i = str(i)
    reverse_str_i = ''.join(list(reversed(str_i)))
    reverse_int_i = int(reverse_str_i)
    if i == reverse_int_i:
        ans_cou += 1
print(ans_cou)

Measured memory_bytes: 8948
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void)
{
	ll A, B;
	cin >> A >> B;

	int N = 20;

	mat grundy(N*2, vec(N*2, 0));

	rep(N, l) rep(l, i)
	{
		int j = l - i;
		set<int> s;
		for (int k = i/2; k > 0; k--)
		{
			s.emplace(grundy[i-2*k][j+k]);
		}
		for (int k = j/2; k > 0; k--)
		{
			s.emplace(grundy[i+k][j-2*k]);
		}
		rep(100, n)
		{
			if (s.find(n) == s.end())
			{
				grundy[i][j] = grundy[j][i] = n;
				break;
			}
		}
	}

	/*
	rep(N, i)
	{
		rep(N, j) printf("%3d", grundy[i][j]);
		printf("\n");
	}*/

	cout << (abs(A-B)>1 ? "Alice" : "Brown") << endl;


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    for(int i = 0; i < n; ++i){
        ll xi;
        cin >> xi;
        x = max(x, xi);
    }
    for(int i = 0; i < m; ++i){
        ll yi;
        cin >> yi;
        y = min(y, yi);
    }
    if(x < y){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    return 0;
}


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

const long long inf = (long long) 1e18 + 7;
int n, w;
vector<int> wgt;
vector<int> val;
vector<vector<long long>> DP;

int main()
{
	cin >> n >> w;
	wgt.resize(n + 1); val.resize(n + 1);
	for (int i = 1; i < n + 1; i++)
		cin >> wgt[i] >> val[i];

/*	// knapsack 1
	// once an item is taken, you need to remove from available list
	// DP[j][i] is the max value achievable, i is allowable weight, j is min index of object can be used
	// i 0...W, j 1...n
	DP.resize(n + 1);
	for (int i = 0; i < n + 1; i++)
		DP[i].resize(w + 1, 0);
	for (int i = 1; i < w + 1; i++) //using only the last object
	{
		if (i >= wgt[n])
			DP[n][i] = val[n];
	}
	for (int j = n - 1; j >= 1; j--)
	{
		for (int i = 1; i < w + 1; i++)
		{
			// calculate DP[j][i] 
			if (i < wgt[j]) //can't put in this item
			{
				DP[j][i] = DP[j + 1][i];
				continue;
			}
			DP[j][i] = max(DP[j + 1][i], DP[j + 1][i - wgt[j]] + val[j]);
		}
	}

	cout << DP[1][w] << endl;
	*/
	// knapsack 2: weight is ranging from 1 to 10^9
	// no longer affordable to allocated w*n for DP array
	// instead should use v*n for DP array
	// minimum weight required to achieve value of i using objects from j
	int v=0;
	for (int i = 1; i < n + 1; i++)
		v += val[i];

	DP.resize(n + 1);
	for (int i = 1; i < n + 1; i++)
		DP[i].resize(v + 1,inf);
	//using only the last object, 1 ... val[n] is achieveable, the rest are inf
	for(int i =1; i<=val[n]; i++)
		DP[n][i] = wgt[n];
	// using other objects
	for (int j = n - 1; j >= 1; j--)
	{
		for (int i = 1; i < v + 1; i++)
		{
			if (i <= val[j])
				DP[j][i] = min(DP[j + 1][i], (long long)wgt[j]);
			else
				DP[j][i] = min(DP[j + 1][i], DP[j + 1][i - val[j]] + wgt[j]);
		}
	}

	long long result=-1;
	for (int i = 1; i < v + 1; i++)
	{
		if (DP[1][i] <= w)
			result = max(result, (long long)i);
	}
	cout << result << endl;
}

Measured memory_bytes: 81540
n,m,l=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
c=[[0]*l for i in range(n)]

for i in range(n):
    for j in range(m):
        for k in range(l):
            c[i][k]+=a[i][j]*b[j][k]
for i in range(len(c)):
    print(*c[i])


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

int main()
{
	for (int a[4],b[4]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];) {
		int hit=0,blow=0;
		for (int i=0; i<4; i++) {
			if (a[i]==b[i]) {
				hit++;
				a[i]=b[i]=-1;
			}
		}
		for (int i=0; i<4; i++) {
			if (a[i]==-1) {
				continue;
			}
			for (int j=0; j<4; j++) {
				if (a[i]==b[j]) {
					blow++;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

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

#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
    unsigned ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if (n == 1 && 2 < m)
    {
        cout << m - 2 << endl;
        return 0;
    }
    if (m == 1 && 2 < n)
    {
        cout << n - 2 << endl;
        return 0;
    }
    if (3 > n || 3 > m)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << (n - 2) * (m - 2) << endl;

    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3564
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  270005
#define M  100005

int n;

int val[N], cost[N];

vector<pair<int,int>> a[N];

int ans[M];

int dp[22][M];

void dfs(int node,int h)
{
	if(h<=9)
	{
		for(int i=0;i<M;i++)
		{
			dp[h][i]=dp[h-1][i];
			if(i-cost[node]>=0) dp[h][i]=max(dp[h][i],dp[h-1][i-cost[node]]+val[node]);
		}
		for(auto it:a[node])
		{
			ans[it.S]=dp[h][it.F];
		}
	}
	else
	{
		if(a[node].size()!=0)
		{
			vector<pair<int,int>> v;
			int hh=h,tmp_node=node;
			while(hh>9)
			{
				// debug() << fuck(tmp_node) << fuck(hh) ;
				v.pb({val[tmp_node],cost[tmp_node]});
				hh--;
				tmp_node/=2;
			}
			int nn=1<<(v.size());
			for(int mask=0;mask<nn;mask++)
			{
				int vsum=0,csum=0;
				for(int i=0;i<v.size();i++)
				{
					if((mask>>i)&1)
					{
						vsum+=v[i].F;
						csum+=v[i].S;
					}
				}
				for(auto it:a[node])
				{
					if(csum<=it.F)
					{
						ans[it.S]=max(ans[it.S],vsum+dp[9][it.F-csum]);
					}
				}
			}
		} 
	}
	if(node*2<=n) dfs(node*2,h+1);
	if(node*2+1<=n) dfs(node*2+1,h+1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>val[i]>>cost[i];
		}	
		int q;
		cin>>q;
		for(int i=1;i<=q;i++)
		{
			int v,l;
			cin>>v>>l;
			a[v].pb({l,i});
		}
		dp[0][0]=0;
		dfs(1,1);
		for(int i=1;i<=q;i++)
		{
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 18988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int max=0;
		int a= stdin.nextInt();
		int b= stdin.nextInt();
		int c= stdin.nextInt();
		int d= stdin.nextInt();
		if(a>b){
			max=max+ b;
		}else{
			max=max+ a;
		}
		if(c>d){
			max=max+d;
		}else{
			max=max+ c;
		}
		System.out.println(max);

	}

}


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

int main (){
  int b=0;
  string a;
  cin >> a;
  if(a.at(0) == '1') ++b;
  if(a.at(1) == '1') ++b;
  if(a.at(2) == '1') ++b;
  
  cout << b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a;
	int n;
	int x, y, z;
	int c, d;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end());

	x = a[(n - 1)];
	c = -1;
	d = x + 2;
	for (int i = 0; i < (n-1); i++){
		z = x - (2*a[i]);
		if (z < 0)z = -z;
		if (z < d){
			d = z;
			c = a[i];
		}
	}
	printf("%d %d\n", x, c);


	return 0;
}

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

int main()
{
    int n, sum{}, a, b;
    scanf("%d%d%d", &n, &a, &b);
    for (int i = 1; i <= n; i++)
    {
        int tmp = i, tmp_sum{};
        for (int i = 0; i < 5; i++)
        {
            tmp_sum += tmp % 10;
            tmp /= 10;
        }
        if (tmp_sum >= a && tmp_sum <= b)
            sum += i;
    }
    printf("%d\n", sum);

    return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;

void imp() {
    cout << 0 << endl;
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n, m;
    cin >> n >> m;
    V<int> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; a[i]--;
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i]; b[i]--;
    }
    sort(a.begin(), a.end(), greater<>());
    sort(b.begin(), b.end(), greater<>());

    int ap = 0, bp = 0;
    Mint ans = 1;

    for (int ph = n * m - 1; ph >= 0; ph--) {
        int us = n * m - ph;
        bool fa = ap < n && a[ap] == ph;
        bool fb = bp < m && b[bp] == ph;
        if (fa) ap++;
        if (fb) bp++;
        if (fa && fb) {
            continue;
        }
        if (!fa && !fb) {
            if (ap * bp < us) imp();
            ans *= ap * bp - us + 1;
            continue;
        }
        if (fa) {
            ans *= bp;
            continue;
        }
        if (fb) {
            ans *= ap;
            continue;
        }
        assert(false);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s: String = read().unwrap();
    let odd_string: String = s.chars()
        .enumerate()
        .filter(|&(index, _)| index % 2 == 0)
        .map(|tuple| tuple.1)
        .collect();
    println!("{}", odd_string);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define ALL(V) (V).begin(),(V).end()
using namespace std;

int dfs(int n, int k, vector<int> &v ){
    vector<int> pick;
    int answer = 0;
    int sum=0;
    for (int l=0;l<=k && l<=n;l++) {
        if (l>0) {
            sum+= v[l-1];
            pick.push_back(v[l-1]);
        }

        int sum3=sum;
        vector<int> pic3 = pick; 
        for (int r=0; l+r <= k && l+r <= n; r++) {
        if (r>0) {
            sum3+= v[n-1-(r-1)];
            pic3.push_back(v[n-1-(r-1)]);
        }

        vector<int> pic2 = pic3;
        sort(ALL(pic2));
        int sum2 = sum3;
        for (int i=0;i< k-(l+r)&& i<pic2.size();i++) {
            if (pic2[i] < 0) {
                sum2 -= pic2[i];
            }
        }
        if (answer < sum2) {
            // cerr << "l:"<<l<<" r:"<<r<<" sum:"<<sum<<" sum4:"<<sum3<<" sum2:" << sum2<<endl;
        }
        answer = max(answer, sum2);
            
        }
    }
    return answer;
}

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

    cout << dfs(n,k,v) << endl;
        

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 2000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

int cnt[1000010];
int dp[1000010][2];
void solve() {
	string S; cin >> S;
	//S += "0";
	int N = S.size();
	vector<int>v;
	REP(i, N) {
		int num = S[i] - '0';
		v.push_back(num);
	}

	//ll ans = 0;
	VREVERSE(v);
	v.push_back(0); v.push_back(0);
	REP(i, 1000010)REP(j, 2)dp[i][j] = 1e9;
	dp[0][0] = 0;
	REP(i, N + 1) {
		REP(j, 2) {
			if (j == 0) {
				chmin(dp[i + 1][0] , dp[i][j] + v[i]);
				chmin(dp[i + 1][1] , dp[i][j] + 10 - v[i]);
			}
			else {
				chmin(dp[i + 1][0], dp[i][j] + v[i] + 1);
				chmin(dp[i + 1][1], dp[i][j] + 10 - v[i] - 1);
			}
		}
	}
	ll ans = min(dp[N + 1][0], dp[N + 1][1]);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 26512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
 public static void main(String[] args) throws IOException {
   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
   String S = reader.readLine();
   String T = reader.readLine();
   int count = 0;
   for (int i = 0; i < S.length(); i++) {
     if (S.charAt(i) != T.charAt(i)) count += 1;
   }
   System.out.println(count);
 }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int x,y;cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        if (cin[0].CompareTo(cin[1]) < 0) Console.WriteLine("<");
        else if (cin[0].CompareTo(cin[1]) > 0) Console.WriteLine(">");
        else Console.WriteLine("=");
    }
}

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

int main(void) {
  int N;
  cin >> N;
  int A[N];
  bool flag=true;
  
  for(int i=0; i<N; i++) cin >> A[i];
  
  for(int i=0; i<N; i++){
    if(A[i] % 2 == 0){
      if(A[i] % 3 !=0 && A[i] % 5 != 0){
        flag=false;
        break;
      }
    }
  }
  
  if(flag==true) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node {
	int a, b, c, d;
};
node qry[50];
int n, m, q, arr[11], ans;
void dfs(int t, int mn) {
	if(t == n+1) {
		int p = 0;
		for(int i=0; i<q; i++) {
			if(arr[qry[i].b] - arr[qry[i].a] == qry[i].c)
				p += qry[i].d;
		}
		ans = max(p, ans);
		return;
	}
	for(int i=mn; i<=m; i++) {
		arr[t] = i;
		dfs(t+1, i);
	}
}
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m >> q;
	for(int i=0; i<q; i++)
		cin >> qry[i].a >> qry[i].b >> qry[i].c >> qry[i].d;
	dfs(1, 1);
	cout << ans;
}

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

int main() {
    int s,w;
    cin>>s>>w;
    cout << (s<=w? "unsafe":"safe") <<endl;
}

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

int descending_compare(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int ascending_compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}




int main(void){
    int a,b;

    scanf("%d %d", &a, &b);
    printf("%d\n", ((a+2-1)+b)/2);
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main() {
	cin>>a>>b>>c>>d;
	if(b>=c&&a<=c&&b<=d)
		cout<<b-c<<endl;
	else if(d>=a&&c<=a&&d<=b)
		cout<<d-a<<endl;
	else if(a<=c&&b>=d)
		cout<<d-c<<endl;
	else if(c<=a&&d>=b)
		cout<<b-a<<endl;
	else
		cout<<0<<endl;
	return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()

# 循環の1周に何がどう含まれるかを予め作っておく
grid=[[0]*5 for i in range(11)]
for i in range(11):
    num=81+i*63
    for j in range(5):
        grid[i][j]=num%11
        num+=9

# 1循環中の要素数確認 → 全部5つずつ
# C=Counter()
# for i in range(11):
#     C.update(grid[i])

# 循環している回数*5
# 最後の2行は3*3の正方形を作れないので除く
ans=(N-2)//11*5
# 最後の1回は必要なところまでを数える
mod=(N-2)%11
for i in range(mod):
    for j in range(5):
        if grid[i][j]==K:
            ans+=1
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

// 1-indexed
template <class X>
class FenwickTree {
    int n;
    vector<X> a;
public:
    FenwickTree(int n) : n(n), a(n+1, 0) {}
    X get(int i) {
        int sm = 0;
        for(; i > 0; i -= i&-i) sm += a[i];
        return sm;
    }
    void set(int i, X x) {
        for(; i <= n; i += i&-i) a[i] += x;
    }
};

long long inversion(const vector<long long> &a){
    int N = a.size();
    long long ans = 0;
    FenwickTree<long long> ft(N);
    for(int i=0; i<N; i++){
        ans += i - ft.get(a[i]);
        ft.set(a[i], 1);
    }
    return ans;
}

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

    string S;
    cin >> S;
    int N = S.size();
    map<char, long long> mp;
    for(char c : S) mp[c]++;

    int od = 0;
    for(int i=0; i<26; i++){
        char c = 'a' + i;
        if(mp[c] % 2 == 1) od++;
    }
    if(od >= 2){
        cout << -1 << endl;
        return 0;
    }
    char c0 = ' ';
    if(N % 2 == 1){
        for(int i=0; i<26; i++){
            char c = 'a' + i;
            if(mp[c] % 2 == 1)
                c0 = c;
        }
    }

    vector<long long> pos(N, 0);
    map<char, long long> mp2;
    for(int i=0; i<N; i++){
        char c = S[i];
        if(mp2[c] < mp[c] / 2) pos[i] = -1;
        else pos[i] = 1;
        if(c == c0){
            if(mp2[c0] == mp[c0] / 2)
                pos[i] = 0;
        }
        mp2[c]++;
    }

    int cnt1 = 0, cnt2 = N/2, cnt3 = (N+1)/2;
    vector<long long> pos2(N);
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            pos2[i] = cnt1;
            cnt1++;
        }else if(pos[i] == 0){
            pos2[i] = cnt2;
        }else{
            pos2[i] = cnt3;
            cnt3++;
        }
    }
    for(int i=0; i<N; i++) pos2[i]++;

    long long ans = inversion(pos2);

    int M = N / 2;
    vector<char> le(M), ri(M);
    cnt1 = 0; cnt2 = 0;
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            le[cnt1] = S[i];
            cnt1++;
        }
        else if(pos[i] == 1){
            ri[cnt2] = S[i];
            cnt2++;
        }
    }
    reverse(ri.begin(), ri.end());

    map<pair<char, int>, long long> mp3;
    map<char, long long> mp4;
    int cnt = 1;
    for(int i=0; i<M; i++){
        char c = ri[i];
        int num = mp4[c];
        mp3[make_pair(c, num)] = cnt;
        mp4[c]++;
        cnt++;
    }
    map<char, long long> mp5;
    vector<long long> le2(M);
    for(int i=0; i<M; i++){
        char c = le[i];
        le2[i] = mp3[make_pair(c, mp5[c])];
        mp5[c]++;
    }
    ans += inversion(le2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11640
using static System.Math;
using System;

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var L = int.Parse(line[1]);
		var absmin = int.MaxValue;
		var min = 0;
		for (int i = 1; i <= n; i++)
		{
			var t = Abs(L + i - 1);
			if (t < absmin) { absmin = t; min = L + i - 1; }
		}
		var s = n * (n + 2 * L - 1) / 2;
		Console.WriteLine(s - min);
	}
}

Measured memory_bytes: 11092
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:
    k = j+1
    _+=P[j][0]*P[k][1]-P[j][1]*P[k][0]
print(_*0.5)

Measured memory_bytes: 7728
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int powing(int a, int b) {
	int ans = 1;
	while (b) {
		if (b % 2) {
			ans *= a;
			ans %= MAX_MOD;
		}
		b /= 2;
		a *= a;
		a %= MAX_MOD;
	}
	return ans;
}
int inv(int now) {
	return powing(now, MAX_MOD - 2LL);
}
ll combination(int a, int b) {
	ll ans = 1;
	for (int i = 1; i <= b; ++i) {
		ans *= inv(i);
		ans %= MAX_MOD;
		ans *= (a - i + 1LL);
		ans %= MAX_MOD;
	}
	return ans;
}
void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = powing(2LL, n) + MAX_MOD - 1LL;
	ans += MAX_MOD - combination(n, a);
	ans += MAX_MOD - combination(n, b);
	cout << ans % MAX_MOD << endl;
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Scanner.Scan<string>();
            Console.WriteLine(S == "ABC" ? "ARC" : "ABC");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 26492
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_len=(n); i<i##_len; ++i)
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
using ll = long long;
using namespace std;

int main()
{
    int K, S;
    cin >> K >> S;

    int ret = 0;
    REP(i, K+1) REP(j, K+1)
    {
        int k = S - (i+j);
        if (0 <= k && k <= K) ++ret;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
int main(){
  int sum=10,ans=0;
  vector<int> A(5);
  rep(i,0,5){cin>>A[i];
             sum=min(sum,(A[i]-1)%10);
             ans+=(A[i]+9)/10*10;
            }
  ans-=9-sum;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
#ifdef _75108D01685041AA959399A981476AD7
  std::freopen("input.txt", "r", stdin);
#endif

  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> z;
  vector<int> o;
  char ch = '\0';

  for (int i = 0; i < n; i++) {
    if (s[i] != ch) {
      if (s[i] == '0') z.push_back(i);
      else o.push_back(i);
    }
    ch = s[i];
  }

  if (k >= z.size()) {
    cout << n << endl;
    return 0;
  }

  if (o.empty()) {
    cout << (k > 0 ? n : 0) << endl;
    return 0;
  }

  /*cout << s << endl;
  for (int i = 0; i < o.size(); i++) {
    cout << o[i] << " ";
  }
  cout << endl;
  for (int i = 0; i < z.size(); i++) {
    cout << z[i] << " ";
  }
  cout << endl;*/

  int m = 0;
  int sh = z.front() < o.front();
  for (int i = 0; i < o.size(); i++) {
    if (i+k+sh >= z.size()) {
      m = max(m, n - o[i]);
      break;
    }
    m = max(m, z[i+k+sh] - o[i]);
  }
  m = max(m, z[k]);

  cout << m << endl;

  return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#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 mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    int A, B;
    cin >> A >> B;
    const int h = 100;
    const int w = 100;
    int c[h][w];
    cout << h << " " << w << endl;
    REP(i, h) REP(j, 50) {
        c[i][j] = 0;
        c[i][j + 50] = 1;
    }
    A--;
    B--;
    int i = 1;
    int j = 1;
    while (A > 0) {
        c[i][j] = 1;
        A--;
        if (j + 2 <= 48) {
            j += 2;
        } else {
            i += 2;
            j = 1;
        }
    }
    i = 1;
    j = 51;
    while (B > 0) {
        c[i][j] = 0;
        B--;
        if (j + 2 <= 98) {
            j += 2;
        } else {
            i += 2;
            j = 51;
        }
    }
    REP(i, h) {
        REP(j, w) {
            if (c[i][j] == 0) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << 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;
typedef long long ll;
typedef pair<int,int> P;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long Per(int n, int k)
{
	if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}


int main()
{
	COMinit();
	int N,M;
	cin >> N >> M;
	ll tmp = 0;
	for (int i = 0; i <= N; ++i)
	{
		if (i % 2 == 0) tmp = (tmp + COM(N,i) * Per(M,i) % MOD * (Per(M-i,N-i) * Per(M-i,N-i) % MOD) % MOD) % MOD;
		else tmp = (tmp + MOD - COM(N,i) * Per(M,i) % MOD * (Per(M-i,N-i) * Per(M-i,N-i) % MOD) % MOD) % MOD;
	}
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 15592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    vector<ll> x(n);
    rep(i, n) {
        cin >> x[i];
    }

    ll ans=0;
    rep(i, n-1) {
        if((x[i+1]-x[i])*a > b) {
            ans += b;
        } else {
            ans += a*(x[i+1]-x[i]);
        }
    }

    cout << ans << endl;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, k;
    cin >> n >> k;

    vector<int> s(n, 0);

    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            a--;
            s[a] = 1;
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"YES":"NO")<<endl;}
int main(){
	string s;
	cin >>s;
	bool ans=true;
	string list[4]={"dream","dreamer","erase","eraser"};
	reverse(s.begin(),s.end());
	for(int i=0;i<4;i++){
		reverse(list[i].begin(),list[i].end());
	}
	auto at=s.begin();
	int terget=0;
	while(at !=s.end()){
		terget=0;
		if(equal(list[0].begin(),list[0].end(),at)){
			at+=list[0].size();
		}
		else if (equal(list[1].begin(), list[1].end(), at))
		{
			at += list[1].size();
		}
		else if(equal(list[2].begin(), list[2].end(), at))
		{
			at += list[2].size();
		}
		else if (equal(list[3].begin(), list[3].end(), at))
		{
			at += list[3].size();
		}
		else{
			ans=false;
			break;
		}
	}
	solve(ans);
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Your code here!
    int N, A[100], B[99];
    long sum = 0;
    scanf("%d",&N);
    
    for(int i = 0; i < N-1; i++)
    {
        scanf("%d",&B[i]);
    }
    
    for(int i = 0; i < N-1; i = i + 2)
    {
        A[i] = B[i];
        A[i+1] = B[i];
    }
    if((N-2)%2 == 1)
        A[N-1] = B[N-2];
        
    for(int i = 1; i < N-1; i = i + 2)
    {
        if(A[i] > B[i])
            A[i] = B[i];
            
        if(A[i+1] > B[i])
            A[i+1] = B[i];
    }
    
    for(int i = 0; i < N; i++)
    {
        //printf("%d ", A[i]);
        sum += A[i];
    }
    //printf("\n");
    
    
    printf("%ld\n",sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;
   

signed main()
 {

  int n;
  cin>>n;
  vector<long double> v;
  loop(i,0,n)
   {
    long double x;
    cin>>x;
    v.pb(x);
   }
   long double dp[n+1][n+1];
   loop(i,0,n+1)
     dp[0][i] = 0.0;
   dp[0][0] = 1.0;
   loop(i,1,n+1)
    {
      loop(j,0,n+1)
       {
        if(i>=j)
        {
        if(j==0)
           dp[i][j] = dp[i-1][j] * (1-v[i-1]);
         else 
           dp[i][j] = dp[i-1][j-1]*v[i-1] + dp[i-1][j]*(1-v[i-1]);
       }
     
     else
       dp[i][j] = 0.0;
   }
    }
    
    long double answer = 0;
    loop(i,(n+1)/2,n+1)
     answer += dp[n][i];
     cout<<fixed<<setprecision(10)<<answer;

    return 0; 
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << "\n";
    if (s == "Rainy") cout << "Sunny\n";
    if (s == "Cloudy") cout << "Rainy\n";
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n, time;
	cin >> n >> time;
	int c[150], t[150];
	int tmp=1001;
	rep(i, n) {
		cin >> c[i] >> t[i];
		if (time >= t[i] && tmp > c[i]) tmp = c[i];
	}
	if (tmp == 1001) cout << "TLE" << endl;
	else cout << tmp << endl;
	return 0;
}

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

namespace AtCoder.Beginner162
{
    public class ABC162C
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            long sum = 0;
            for (int a=1; a<=N; a++)
            {
                for (int b = 1; b <= N; b++)
                {
                    for (int c = 1; c <= N; c++)
                    {
                        var ab = gcd(a, b);
                        var abc = gcd(ab, c);
                        sum += abc;
                    }
                }
            }
            Console.WriteLine(sum);
        }

        public static int gcd(int a, int b)
        {
            if (b == 0) return a;
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 27476
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    vector<ll> a(3); cin >> a[0] >> a[1] >> a[2];
    if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
        cout << 0 << endl;
    }
    else{
        sort(a.begin(), a.end());
        cout << a[0] * a[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int A=0;int B=0;int C=0;
   scanf("%d%d%d",&A,&B,&C);
   if(A+B>=C)
    printf("%d",B+C);
   if(A+B<C)
    printf("%d",A+2*B+1);
}


Measured memory_bytes: 128