akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

int const N = 400000, md = 998244353;
int dp[N + 1], n, n2, p2[N + 1];
bool ok[N + 1];
char s[N], z[N];

void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
void sb(int &x, int y) { if ((x -= y) <  0 )x += md; }

bool fl(int x){
	f(i, x, n)z[i] = z[i - x] ^ 1;
	f(i, 0, n)if (z[i] < s[i])return true;
	else if (z[i] > s[i])return false;
	return true;
}

void go(int x){
	x >>= 1;
	f(i, 0, x){
		if (s[i] == '1')ad(dp[x << 1], p2[x - i - 1]);
		z[i] = s[i];
	}
	if (fl(x))ad(dp[x << 1], 1);
}

int main(){
	scanf("%d%s", &n, s);
	n2 = n << 1;
	p2[0] = 1;
	f(i, 1, n2 + 1)ad(p2[i] = p2[i - 1], p2[i - 1]);
	f(i, 1, n2 + 1)if (n % i && n2 % i == 0)ok[i] = true;
	f(i, 1, n2 + 1)if (ok[i])go(i);
	f(i, 1, n2 + 1)if (ok[i])for (int j = i << 1; j <= n2; j += i)sb(dp[j], dp[i]);
	int an = 0;
	f(i, 1, n2 + 1)if (ok[i])ad(an, (ll)i * dp[i] % md);
	printf("%d\n", an);
}

Measured memory_bytes: 3840
#include<iostream>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9) {
		cout << -1 << endl;
	}
	else {
		cout << A * B << 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;

map<char, int>notal{
	{ ' ',26 },{ '\'',27 },{ ',',28 },{ '-',29 },{ '.',30 },{ '?',31 }
};
map<int, char>mp{
	{ 26,' ' },{ 27,'.' },{ 28,',' },{ 29,'-' },{ 30,'\'' },{ 31,'?' },
};
string code[]{ "100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000","101","000000","000011","10010001","010001","000001" };
int bin(string s) {
	reverse(s.begin(), s.end());
	int i = 1;
	int res = 0;
	for (char c : s) {
		res += i*(c - '0');
		i <<= 1;
	}
	return res;
}
int main() {
	string s;
	while (getline(cin, s)) {
		string ss;
		for (char c : s) {
			if (isalpha(c))ss += code[c - 'A'];
			else ss += code[notal[c]];
		}
		while (ss.size() % 5)ss += '0';
		string ans;
		for (int i = 0; i <= ss.size() - 5; i += 5) {
			int d = bin(ss.substr(i, 5));
			if (d < 26)ans += 'A' + d;
			else ans += mp[d];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3216
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int n,F,x[101],y[101],h[101];
inline bool check(int X,int Y,int H){
	for(register int i=1;i<=n;i++)if((((H-abs(X-x[i])-abs(Y-y[i]))<0)?0:H-abs(X-x[i])-abs(Y-y[i]))!=h[i])return false;
	return true;
}
int main() {
	scanf("%d",&n);
	for(register int i=1; i<=n; i++) {
		scanf("%d%d%d",&x[i],&y[i],&h[i]);
		if(h[i]!=0)F=i;
	}
	for(register int i=0; i<=100; i++) {
		for(register int j=0; j<=100; j++) {
			if(check(i,j,abs(i-x[F])+abs(j-y[F])+h[F])){
				cout<<i<<" "<<j<<" "<<(int)abs(i-x[F])+abs(j-y[F])+h[F]<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN


int main() {
	ll a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,b,a[li],k,flag;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	if(n==25){printf("Christmas\n");return 0;}
	if(n==24){printf("Christmas Eve\n");return 0;}
	if(n==23){printf("Christmas Eve Eve\n");return 0;}
	if(n==22){printf("Christmas Eve Eve Eve\n");return 0;}
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
str = gets.split
a = []
answer = 0

for x in 0...n
  a[x] = str[x].to_i
end

f = 0
loop do
  for x in 0...n
    if a[x] % 2 != 0
    f = 1
    end
  end
  if f == 1
    break
  end
  for x in 0...n
    a[x] /= 2
  end
  answer += 1
end

puts (answer)

Measured memory_bytes: 3836
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
#これを消すとなぜかWAになる呪い
for i in range(m-1):
    if a[i]+1 == a[i+1]:
        print(0)
        exit(0)
if n == 1:
    print(1)
else:
    p = 0
    dp = [0 for i in range(n+1)]
    dp[1]  = 1
    dp[2] = 2
    for i in range(3,n+1):
        dp[i] = dp[i-1]+dp[i-2]
    left = [i+1 for i in a]
    right = [i-1 for i in a]
    left.insert(0,0)
    right.append(n)
    s = 1
    for i in range(len(right)):
        if right[i] != left[i] :s*=dp[right[i]-left[i]]
        s%=rem
    print(s)

Measured memory_bytes: 468312
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			long max=Long.MIN_VALUE;
			long[] a=new long[n];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt();
				if(max<a[i]){
					max=a[i];
				}
			}
			for(int i=0;i<n-1;i++){
				long sum=a[i];
				for(int j=i;j<n-1;j++){
					sum=sum+a[j+1];
					if(max<sum){
						max=sum;
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 26340
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll a[N];
map<ll,int> mp;

void solve () {
    int n;cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    ll ans = 0;
    for (int i=1;i<=n;i++) {
        ans += mp[i-a[i]];
        mp[i+a[i]]++;
    }
    cout<<ans<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 27888
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N, Q;
vector<vector<int>> g;
vector<ll> c;

void dfs(int x, int y) {
    for (auto child: g[x]) {
        if (child == y) continue;
        c[child] += c[x];
        dfs(child, x);
    }
}

int main() {
    cin >> N >> Q;
    g.resize(N);
    c.resize(N);

    rep(i, N-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    rep(i, Q) {
        int p, x; cin >> p >> x;
        p--;
        c[p] += x;
    }

    dfs(0, -1);
    rep(i, N) cout << c[i] << (i < N-1 ? ' ' : '\n');
}


Measured memory_bytes: 24320
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,M;
	cin >> N >> M;
	vector<bool> red(N+1,false);
	red[1] = true;
	vector<int> A(N+1,1);
	A[0] = 0;
	for(int i=0;i<M;++i){
		int X,Y;//X->Y
		cin >> X >> Y;
		//ボールを移動
		A[X]--;
		A[Y]++;
		if( red[X] ){//赤入ってた
			if( A[X] == 0 ) red[X] = false;
			red[Y] = true;
		}
	}
	int ans = 0;
	for(int i=1;i<=N;++i){
		ans += red[i];
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
n,m=map(int,input().split())
ab,cd=[],[]
ans_dis=[1000000000 for i in range(n)] 
ans=[0 for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    ab.append([a,b])
for i in range(m):
    c,d=map(int,input().split())
    cd.append([c,d])
for i in range(n):
    for j in range(m):
        dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if dis<ans_dis[i]:
            ans[i]=(j+1)
            ans_dis[i]=dis
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
N = int(input())
SP = []
for i in range(N):
    S, P = input().split()
    SP.append((S, int(P), i + 1))

SP = sorted(SP, key=lambda x: x[1], reverse=True)
SP = sorted(SP, key=lambda x: x[0])
for i in range(N):
    print(SP[i][2])


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
//  ll mod(ll val) {
//      ll res = val % MOD;
//      if (res < 0) res += MOD;
//      return res;
//  }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     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;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }


int main() {
    ld A, B, H, M;
    cin >> A >> B >> H >> M;
    ld t1 = 2 * M_PI / (12 * 60) * (H * 60 + M);
    ld t2 = 2 * M_PI / 60 * M;
    ld t = abs(t1 - t2);
    ld ans = sqrt(A * A + B * B - 2 * A * B * cos(t));
    // std::cout << t1 << std::endl;
    // std::cout << t2 << std::endl;
    // std::cout << t << std::endl;
    // std::cout << cos(t) << std::endl;
    cout << setprecision(11);
    cout << ans << endl;
    return 0;
}


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

int main() {
	int W, H, r, x, y;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	int l = x - r;
	int r1 = x + r;
	int u = y + r;
	int d = y - r;
	if (l >= 0 && r1 <= W && d >= 0 && u <= H)
		printf("Yes\n");
	else
		printf("No\n");
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main(){
  int n, k;
  cin >> n >> k;
  if(k==1)
    cout << 0;
  else
    cout << n-k;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return(t*t);
    else
        return(t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
    }
    return true;
}

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

ll lcm(ll a,ll b){
    return ( a*b/__gcd(a,b));
}



int main()
{
    weewoo;
    ll a,b;
    cin >> a >> b;
    if(a>9||b>9)
        cout << -1 << endl;
    else
        cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
// bool cmp()
// {
//     return 
// }
int32_t main()
{
  // int t;cin>>t;
  // while(t--)
  // {
    int n;cin >> n;
    map<string,int>m;
    m["AC"]=0;
    m["WA"]=0;
    m["TLE"]=0;
    m["RE"]=0;
    while(n--)
    {
      string s;cin >> s;
      m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;


  // }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;
	int n,m;
	cin>>n>>m;
	int correct=0,pen=0;
	vector<bool> v(n,false);
	vector<int> cnt(n,0);
	while(m--)
	{
		int a;string b;
		cin>>a>>b;
		
		a--;
		if(v[a]==false)
		{
			if(b=="AC")
			{
				correct++;
				v[a]=true;
				pen+=cnt[a];
			}
			else
			cnt[a]++;
		}
		
	}
	cout<<correct<<" "<<pen;
}




Measured memory_bytes: 3656
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto a = readln.split.to!(int[]);
  auto ch = ['A', 'B', 'C'];

  auto mx = a.reduce!(max);
  foreach (i; 0 .. 3) {
    if (a[i] == mx) {
      writeln(ch[i]);
      return;
    }
  }
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}



Measured memory_bytes: 2452
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int dp[N+1][411][411];
	rep(i,N+1){
		rep(j,411){
			rep(k,411){
				if(j==0 && k==0) dp[i][j][k] = 0;
				else dp[i][j][k] = INF;
			}
		}
	}
	int A[N], B[N], C[N];
	rep(i,N){
		cin >> A[i] >> B[i] >> C[i];
	}

	rep(i,N){
		rep(j,401){
			rep(k,401){
				chmin(dp[i+1][j][k], dp[i][j][k]);
				chmin(dp[i+1][j+A[i]][k+B[i]], dp[i][j][k]+C[i]);
			}
		}
	}
	int ans = INF;
	rep(i,500){
		if(Ma*(i+1) > 400 || Mb*(i+1) > 400) break;
		chmin(ans, dp[N][Ma*(i+1)][Mb*(i+1)]);
	}
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 54400
import java.util.*

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val n = readLine()!!.toInt()
    val aQueue = ArrayDeque<Int>(readLine()!!.split(' ').map(String::toInt))

    val map = Array(h) { IntArray(w) { 0 } }
    var curNum = 1
    var count = aQueue.pollFirst()!!
    var reverse = false
    for (r in 0 until h) {
        for (tc in 0 until w) {
            if (reverse) {
                map[r][w - tc - 1] = curNum
            } else {
                map[r][tc] = curNum
            }
            count--
            if (count == 0) {
                curNum++
                count = aQueue.pollFirst()?:0
            }
        }
        reverse = !reverse
    }
    map.forEach { println(it.joinToString(" ")) }
}

Measured memory_bytes: 39528
def main():
    n = input()
    aa = raw_input().strip()
    bb = raw_input().strip()
    cc = raw_input().strip()
    count = 0
    for a, b, c in zip(aa, bb, cc):
        s = {a, b, c}
        if len(s) == 3:
            count += 2
        elif len(s) == 2:
            count += 1
    print count


if __name__ == '__main__':
    main()


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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m;
   cin >> n >> m;
   vector <pii> vec;
   for(int i = 0 ; i < n ; i++){
      int x;
      cin >> x;
      vec.push_back({x , i});
   }
   sort(vec.begin() , vec.end());
   int mn[n];
   memset(mn , 63 , sizeof(mn));
   vector <pii> g[n];
   for(int i = 0 ; i < m ; i++){
      int u , v;
      cin >> u >> v;
      u--; v--;
      g[u].push_back({v , i});
      g[v].push_back({u , i});
   }
   int ans[m];
   bool mark[n];
   memset(mark , 0 , sizeof(mark));
   int col[n];
   memset(col , 0 , sizeof(col));
   for(pii x : vec){
      int v = x.second;
      for(pii y : g[v]){
         int u = y.first;
         if(mark[u]){
            if(mn[v] < mod){
               if(mn[u] > mod)
                  col[u] = 1 - col[v];
            }
            else{
               col[v] = 1 - col[u];
            }
            mn[u] = min(mn[u] , x.first);
            mn[v] = min(mn[v] , x.first);
            ans[y.second] = x.first;
         }
      }
      mark[x.second] = true;
   }
   for(pii x : vec)
      if(mn[x.second] != x.first)
         return cout << -1 , 0;
   for(int i = 0 ; i < n ; i++)
      cout << ((col[i] == 0) ? "B" : "W");
   cout << "\n";
   for(int i = 0 ; i < m ; i++)
      cout << ans[i] << "\n";
   return 0;
}


Measured memory_bytes: 13756
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

string S;
void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  int ans = 0;
  string prev = "```";
  int i = 0;
  while (i < S.size()) {
    string st = {S[i]};
    debug(st);
    if (prev != st) {
      ans++;
      ++i;
      prev = st;
    } else {
      if (i == S.size() - 1) {
        break;
      }
      ans++;
      prev = S.substr(i, 2);
      i += 2;
    }
    debug(prev);
  };
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
            C[i] = cin.nextInt();
        }

        int[][] dp = new int[N][3]; //dp[i][j] = i+1日目で最後にjを選んだときの最大幸福度
        // 1日目の幸福度は初期値として入れる
        dp[0][0] = A[0];
        dp[0][1] = B[0];
        dp[0][2] = C[0];
        //2日目以降は、前の最大幸福度から計算する
        for (int i = 1; i < N; i++) {
            //行動Aを選ぶのは、前に行動B,Cを選んだ場合なので、そのどちらかの最大値から足し算する
            dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + A[i];
            //行動Bも同様に、直前の行動がA,Cのものから選ぶ
            dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + B[i];
            //行動Cも同様に選ぶ
            dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + C[i];
        }
        // 答えは、最後に行動A,B,Cそれぞれを選んだものの最大値となる
        int ans = Math.max(dp[N - 1][0], Math.max(dp[N - 1][1], dp[N - 1][2]));
        System.out.println(ans);
    }
}


Measured memory_bytes: 94412
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
from itertools import accumulate
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def floor(a, b): return -(-a // b)


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


x = z()
if (x == 0):
    print(1)
else:
    print(0)


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

int main(){
	int m, d;
	scanf("%d%d", &m, &d);
	int ans = 0;
	for (int i = 1; i <= m; i++){
		for (int j = 1; j <= d; j++){
			int x1 = j % 10, x2 = j / 10 % 10;
			if (x1 >= 2 && x2 >= 2 && x1 * x2 == i) ans++;
		}
	}
	printf("%d", ans);
	return 0;
}


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

int main(){
	int N, answer = 0;
	vector<int> d;
	cin >> N;
	for(int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			answer += d[i]*d[j];
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    abc = [0] * N
    for i in range(N):
        abc[i] = list(map(int, input().split()))

    dp = [[0] * 3 for _ in range(N)]
    dp[0] = abc[0]
    for i, (a, b, c) in enumerate(abc[1:], start=1):
        dp_im = dp[i - 1]
        dp[i][0] = max(dp_im[1], dp_im[2]) + a
        dp[i][1] = max(dp_im[0], dp_im[2]) + b
        dp[i][2] = max(dp_im[0], dp_im[1]) + c

    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50880
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i = 1;
		while (true) {
			int num1 = scanner.nextInt();
			if (num1 == 0)
				break;
			else {
				System.out.println(String.format("Case %s: %s", i, num1));
				i++;
			}
		}
	}
}



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

const ll INF = 1LL << 60;

ll A, B, C;
int main() {
    cin >> A >> B >> C;
    ll even = 0;

    if (A % 2 == 0) even++;
    if (B % 2 == 0) even++;
    if (C % 2 == 0) even++;

    if (even >= 1) {
        cout << 0 << endl;
        return 0;
    }

    // 全部奇数の時
    // ll max_v = A;
    // max_v = max(max_v, B);
    // max_v = max(max_v, C);
    vector<ll> v = {A, B, C};
    sort(v.begin(), v.end());

    ll red = v[0] * v[1] * (v[2] / 2);
    ll blue = v[0] * v[1] * (v[2] / 2 + 1);
    // cout << red <<  " " << blue << endl;
    cout << blue - red << endl;
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")  # 第１条件の全事象
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+j-i
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]: # 第1条件 かつ not第２条件
            ans-=1
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
vector<long long int> a;
void Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		a.push_back(num);
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	
}
int main() {
	double a;
	while (cin >> a) {
		double ans[10];
		ans[0] = a;
		double sum = a;
		for (int i = 1;i < 10;i++) {
			if (i % 2 == 0) ans[i] = ans[i - 1] / 3;
			else ans[i] = 2 * ans[i - 1];
			sum += ans[i];
		}
		cout <<setprecision(9) <<sum << endl;
	}
	
	}

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

#define ll long long int
#define ld long double
#define u128 __int128 
#define ff first
#define ss second
#define pb push_back
#define PI 3.141592653589793

#define MOD 1000000007
#define N 100100
#define M 1000010

int n, m;
int a[N];

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);
	
	string s;
	cin >> s;

	n = s.size();

	int a[n] = {};

	for(int i = 0; i < n;)
	{
		int k1 = 0, k2 = 0;
		while(s[i] == 'R')
			k1++, i++;
		int pos = i - 1;
		while(s[i] == 'L')
			k2++, i++;

		a[pos] = 1, a[pos + 1] = 1;
		a[pos] += k1 / 2;
		a[pos + 1] += (k1 - 1)/2;

 		a[pos] += (k2 - 1) /2;
 		a[pos + 1] += k2 / 2;
 		swap(a[pos], a[pos + 1]);
	}

	for (int i = 0; i < n; ++i)
	{
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1104
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N, M, ans;   cin >> N >> M;
    ans = pow(2,M)*(M*1900+(N-M)*100);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4000
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(int,input().split()))

seg_el=1<<(N.bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(N): # Aを対応する箇所へupdate. Aは0-indexedなことに注意. 
    SEG[i+seg_el]=A[i]

for i in range(seg_el-1,0,-1): # 親の部分もupdate
    SEG[i]=max(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el): # A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1 # 子ノードへ
    
    while i!=0:
        SEG[i]=max(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r): # 区間[l,r)に関するmaxを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=0

    while L<R:
        if L & 1:
            ANS=max(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=max(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

def bisect_on_SEG(l,x):  
    L=l+seg_el
    R=seg_el*2-1
    while L<R:
        if SEG[L]>=x:
            break
        if L & 1:
            L+=1
        L>>=1
        R>>=1

    if SEG[L]<x:
        return N

    while L<seg_el:
        if SEG[L*2]>=x:
            L=L*2
        else:
            L=L*2+1

    return L-seg_el

for queries in range(Q):
    T,X,V=map(int,input().split())
    if T==1:
        update(X-1,V,seg_el)
    elif T==2:
        print(getvalues(X-1,V))
    else:
        print(1+bisect_on_SEG(X-1,V))

Measured memory_bytes: 94640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int i,j,k,s,x,y,z;
    int counter = 0;
    

    cin >> k >> s;

    for(x = 0; x <= k;x++) {
        for(y = 0;y <= k; y++){
            z = s - x - y;
            if(z >= 0 && z <= k) {
                counter++;
            }
        }
    }
   
    cout << counter << endl;
       
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll H, W;
  cin >> H >> W;

  vector<vll> C(10, vll(10));
  rep(i, 10) rep(j, 10) cin >> C[i][j];

  vll to(10);

  rep(i, 10) {
    to[i] = C[i][1];
    queue<P> q;
    rep(j, 10) {
      if (i == j) continue;
      if (C[i][j] > to[i]) continue;
      q.push({j, C[i][j]});
    }

    while (!q.empty()) {
      P p = q.front();
      q.pop();

      if (p.first == 1) {
        to[i] = min(to[i], p.second);
        continue;
      }

      rep(j, 10) {
        if (i == j) continue;
        if (p.first == j) continue;
        if (p.second + C[p.first][j] > to[i]) continue;
        q.push({j, p.second + C[p.first][j]});
      }
    }
  }

  ll ans = 0;
  rep(i, H) rep(i, W) {
    ll a;
    cin >> a;
    if (a == -1 || a == 1) continue;
    ans += to[a];
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, maxv, ans = 0;
    cin >> n;
    int L[n];
    REP(i,n) cin >> L[i];

    sort(L, L+n);

    REP(i,n) {
        for (int j = i+1; j < n; j++) {
            for (int f = j+1; f < n; f++) {
                if (L[f] < L[i]+L[j]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define ll long long

ll sum(ll n)
{
    if(n == 1)
        return 1;
    else
        return (pow(n, n) + sum(n-1));
}
void printFun(int test)
{
    if(test < 1)
        return;
    else
    {
        cout << test << " ";
        printFun(test - 1);
        cout << test << " ";
        return;
    }
}
int baseToDecimal(string x, int base)
{
    int res = 0, coef = 1, len = x.length();
    for(int i = len-1; i >= 0; i--)
    {
        res += (x[i] - '0')*coef;
        coef *= base;
    }
    return res;
}
int baseToDecimalAlternate(string x, int base)
{
    int res = 0;
    int len = x.length();
    for(int i = 0; i < len; i++)
    {
        res = (res*base) + (x[i] - '0');
    }
    return res;
}

int main()
{
    int a, b, c, d, i = 2;
    cin >> a >> b >> c >> d;
    while(1)
    {
        if(a <= 0)
        {
            cout << "No" << endl;
            break;
        }
        else if(c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        if(i%2 == 0)
        {
            c -= b;
        }
        else if(i%2 != 0)
        {
            a -= d;
        }
        i++;
    }

    //cout << baseToDecimalAlternate(x, base) << endl;
    //cout << baseToDecimal(x, base) << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
#define N 100010
#define lowbit(x) x&-x
int c[N*10];
int n,a[N],s[N*10];
ll query(int x){
    ll sum=0;
    while(x){
        sum+=c[x];
        x-=x&(-x);
    }
    return sum;
}
void add(int x){
    while(x<(N<<1)){
        c[x]++;
        x+=(x)&(-x);
    }
}
bool check(int x){
    memset(c,0,sizeof(c));
    s[0]=0;
    for(int i=1;i<=n;i++)
    s[i]=s[i-1]+(a[i]<x?-1:1);
    ll sum=0;
    for(int i=0;i<=n;i++){
        sum+=query(s[i]+N);
        add(s[i]+N);
    }
    return sum>=1ll*n*(n+1)/4;
}
int main(){
    scanf("%d",&n);
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        r=max(r,a[i]);
    }
    int ans=0;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid))l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",r);
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin, a, b, c, k;
    ll sum = 0;
    ll m = min(a, k);
    sum += m;
    k -= m;
    m = min(b, k);
    k -= m;
    m = min(c, k);
    sum -= m;
    print(sum);
    return 0;
}


Measured memory_bytes: 3648
N = int(input())

judge = N%10

if judge == 2 or judge == 4 or judge == 5 or judge == 7 or judge == 9:
    print('hon')
elif judge == 0 or judge == 1 or judge == 6 or judge == 8:
    print('pon')
elif judge == 3:
    print('bon')


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



void solve(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i,3){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

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

    char ans;
    if(a+b == 15){
        ans = '+';
    }else if(a*b == 15){
        ans = '*';
    }else{
        ans = 'x';
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int a[50], b[50], c[50], d[50];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int j = 0; j < m; j++) {
        cin >> c[j] >> d[j];
    }

    for (int i = 0; i < n; i++) {
        int j1 = 0, t1 = 1 << 30;
        for (int j = 0; j < m; j++) {
            int t = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (t < t1) {
                t1 = t;
                j1 = j;
            }
        }
        cout << j1 + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
ans = 0
flag = 0
for i in range(N):
  while(h[i] > 0):
    ans += 1
    for j in range(i, N):
      if(h[j] > 0):
        h[j] -= 1
      else:
        break
print(ans)

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

int gcd(int p,int q) {
    
  if (p % q == 0)
    return q;
  else 
    return gcd(q,p % q);
}

int main() {
  int K,ans = 0;
  cin >> K;
  for (int a = 1; a < K + 1; a++) {
    for (int b = 1; b < K + 1; b++) {
      for (int c = 1; c < K + 1; c++) 
        ans += gcd(gcd(a,b),c);
    }
  }
  cout << ans << endl;
}


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

template<typename T> T GCD(T a, T b) {
    if (a % b == 0) {
        return b;
    }
    return (GCD(b, a % b));
}

template<typename T> T LCM(T a, T b) {
    return (a / GCD(a, b) * b);
}

int main() {
    long long a, b;
    cin >> a >> b;
    cout << LCM(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793

int main(void){
    // Your code here!
   double a,b,c,C,s;
   double S,L,h;
   
   scanf("%lf %lf %lf", &a, &b, &C);
   
   c=sqrt(a*a+b*b-2*a*b*cos(C*PI/180));
   L=a+b+c;
   s=L/2;
   S=sqrt(s*(s-a)*(s-b)*(s-c));
   h=2*S/a;
   
   printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);
   
   return 0;
    
}



Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n; i++){
			String str1 = br.readLine();
			String str2 = br.readLine();
			
			if(str1.length() > 80 || str2.length() > 80){
				System.out.println("overflow");
				continue;
			}
			
			//?¨????????\????????????????????????????????????¢??????
			char[] str1Rev = reverseString(str1);
			char[] str2Rev = reverseString(str2);
			
			//??????????¶????????????????
			int[] result = new int[101];
			Arrays.fill(result, 0);
			
			int a, b, c = 0;
			boolean of = false;
			for(int j = 0; j < str1.length() || j < str2.length() || c != 0; j++){
				if(j < str1.length()){
					a = Character.digit(str1Rev[j], 10);
				}
				else {
					a = 0;
				}
				
				if(j < str2.length()){
					b = Character.digit(str2Rev[j], 10);
				}
				else {
					b = 0;
				}	
				
				if(j >= 80 && a+b+c != 0){
					of = true;
					break;
				}
				result[j] = (a+b+c)%10;
				c = (a+b+c)/10;
			}
			if(of){
				System.out.println("overflow");
				continue;
			}
			
			//???????????????
			boolean printable = false;
			for(int j = result.length - 1; j >= 0; j--){
				if(printable == false && result[j] != 0){
					printable = true;
				}
				
				if(printable){
					System.out.print(result[j]);
				}
			}
			
			if(printable == false){
				System.out.print(0);
			}
			System.out.println();
		}
	}
	
	static char[] reverseString(String str){
		char[] result = new char[str.length()];
		for(int i = 0; i < str.length(); i++){
			result[i] = str.charAt(str.length() - 1 - i);
		}
		
		return result;
	}

}

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

int main() {
  string S; cin >> S;
  long long K; cin >> K;

  rep(i, S.size()) {
    if(S[i] == '1') {
      if(i == K-1) {
        cout << 1 << endl;
        return 0;
      }
    } else {
      cout << S[i] << endl;
      return 0;
    }
  }
  

}


Measured memory_bytes: 256
///not today

#include <bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front
#define accept_sho ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int32_t main(){
    string s;
    cin >>s;
    int n = SZ(s), ans = n;
    for(char k = 'a'; k <= 'z'; k ++){
        int pt = n, mx = 0;
        for(int j = n - 1; j >= 0; j --){
            if(s[j] == k)
                pt = j;
            xmax(mx, pt - j);
        }
        xmin(ans, mx);
    }
    cout <<ans <<endl;
    return false;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
typedef long long ll;

/*
ll mod(ll n, ll m) {
n -= (n / m)*m;
return n;
}
ll loop(ll n, ll m, ll k) {
if (k == 1) {
return n % m;
}
else if (k % 2 == 0) {
ll t = loop(n, m, k / 2);
return t * t%m;
}
else {
return loop(n, m, k - 1)*n%m;
}
}
*/
int main() {
	int n;
	cin >> n;
	string s[110];
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	//cout << s[2] << endl;
	int m;
	cin >> m;
	string t[110];
	for (int i = 0; i < m; ++i) {
		cin >> t[i];
	}
	int x[110] = {};
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (s[i] == s[j]) {
				x[i]++;
			}
		}
		for (int j = 0; j < m; ++j) {
			if (s[i] == t[j]) {
				x[i]--;
			}
		}
	}
	sort(x, x + n, greater<int>());
	if (x[0] >= 0) {
		cout << x[0] << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;

}


Measured memory_bytes: 256