akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void CountTriangles(int A[],int n){  
    sort(A, A+n);  
    int count = 0; 
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
                count += r - l ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    cout<<count; 
} 
void solve()
{
	//Enter your code here Tanmay:)
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	CountTriangles(arr,n);
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
 
 
void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M);
    vector<vector<int>> data(N + 1);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        data[P[i]].push_back(Y[i]);
    }
 
    for (int i = 0; i < N + 1; i++) {
        sort(all(data[i]));
    }
 
    for (int i = 0; i < M; i++) {
        vector<int> &d = data[P[i]];
        int k = lower_bound(all(d), Y[i]) - d.begin();
        
        printf("%06d%06d\n", P[i], k + 1);
    }
 
}
 
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char const *argv[])
{
    short a[3];
    short d;

    for(int i = 0; i < 3; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i = 2; i > 0; i--)
    {
        for(int j = 0; j < i; j++)
        {
            if (a[j] > a[j+1])
            {
                d = a[j+1];
                a[j+1] = a[j];
                a[j] = d;
            }
            
        }
        
    }
    printf("%d %d %d\n", a[0], a[1], a[2]);
    return 0;
}



Measured memory_bytes: 3204
N, H = map(int, input().split())
A, B = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(N):
  A[i], B[i] = map(int, input().split())
m = max(A)
B.sort(reverse=True)
cnt = N - 1
while B[cnt] < m:
  cnt -= 1
ccnt = 0
for i in range(cnt+1):
  H -= B[i]
  ccnt += 1
  if H <= 0:
    break
if H > 0:
  ccnt += -(-H//m)
print(ccnt)

Measured memory_bytes: 11360
#include <iostream>

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

    const int BASE_COST = 700;
    const int OPTION_COST = 100;

    std::string S;
    std::cin >> S;

    int count = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == 'o') count++;
    }
    std::cout << (count * OPTION_COST + BASE_COST) << std::endl;
}


Measured memory_bytes: 256
from collections import defaultdict as d

n = int(input())
dico = d(int)
for i in range(n):
	s = input()
	dico[s] += 1
x = 0
tab = []
for k in dico.keys():
	if dico[k] > x:
		tab = [k]
		x = dico[k]
	elif dico[k] == x:
		tab.append(k)
tab.sort()
for i in tab:
	print(i)

Measured memory_bytes: 32472
///  author:Kissheart  ///
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
vector<int>a,b;
char s[MAX],t[MAX];
int n1,n2,n;
int ans;
int main()
{
    ans=INF;
    scanf("%d",&n);
    scanf("%s%s",s+1,t+1);
    for(int i=1;i<n;i++) //处理红蓝线
    {
        if(s[i]!=s[i+1]) a.push_back(i);
        if(t[i]!=t[i+1]) b.push_back(i);
    }
    n1=a.size();
    n2=b.size();
    for(int i=-n1-1;i<=n2+1;i++) //枚举长度
    {
        if((i+(s[1]==t[1]))&1)
        {
            int sum=0;
            for(int j=min(-i,0);j<max(n1,n2-i);j++)
            {
                int p=i+j;
                int t1=j<0?0:(j>=n1?n:a[j]);
                int t2=p<0?0:(p>=n2?n:b[p]);
                sum+=abs(t1-t2);
            }
            ans=min(ans,sum);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
<?php

//$_input = explode(
//    "\n",
//    '4
//20 18 2 18
//'
//);

function getNext() {
    return trim(
        isset($GLOBALS['_input'])
            ? array_shift($GLOBALS['_input'])
            : fgets(STDIN)
    );
}


$n = (int) getNext();
$a = array_map(function ($i) {
    return (int) $i;
}, explode(' ', getNext()));

rsort($a, SORT_NUMERIC);

$alice = 0;
$bob = 0;
foreach ($a as $key => $value) {
    if ($key % 2 === 0) {
        $alice += $value;
    } else {
        $bob += $value;
    }
}

printf("%d\n", $alice - $bob);


Measured memory_bytes: 4604
X,Y = map(int,input().split())
ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000

if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000

if X == 1 and Y == 1:
    ans += 400000
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


long long N;
int main() {
    while (cin >> N) {
        auto pf = prime_factorize(N);
        auto div = calc_divisor(N);
        cout << pf.size() << " " << (int)div.size()-1 << endl;
    }
}



Measured memory_bytes: 3152
N = gets.to_i
A = gets.split.map(&:to_i)

stock = 0
ans = 1000

(N-1).times do |i|
  if (A[i] < A[i+1] && stock == 0)
    stock = ans / A[i]
    ans %= A[i]
  elsif (A[i] > A[i+1])
    ans += stock * A[i]
    stock = 0
  end
end

puts (ans + stock * A.last)

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

void solve(long long A, long long B, long long N)
{
    ll ans = 0;
    if (N / B >= 1) {
        ans = A * (B - 1) / B;
    } else {
        ans = A * N / B;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
ll fre[11];
int main( )
{
    ll N, i,k, mx = -1,sum=0,A,B;
    cin>>A>>B>>k;
    vector<ll>v;
    vector<ll>vv;

    ll x=abs(A-B);
    if(x/2>=k)
    {
        for(i=A; i<A+k; i++)
            cout<<i<<endl;
        for(i=B-k+1; i<=B; i++)
            cout<<i<<endl;
    }
    else
    {
        for(i=A; i<=B; i++)
            cout<<i<<endl;
    }

return 0;
}




Measured memory_bytes: 256
a1, a2, a3 = map(int, input().split())
if (a1 <= a2 and a2 <= a3) or (a3 <= a2 and a2 <= a1):
    print(abs(a2 - a1) + abs(a3 - a2))
elif (a2 <= a1 and a1 <= a3) or (a3 <= a1 and a1 <= a2):
    print(abs(a1 - a2) + abs(a3 - a1))
else:
    print(abs(a3 - a1) + abs(a2 - a3))

Measured memory_bytes: 9184
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto ab = readln.chomp.split().to!(long[]);
    long a = ab[0];
    long b = ab[1];
    writeln(a * b - (a + b - 1));
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll h, w, cnt;
char s[25][25];
ll a[25][25];
ll d[4][2] = { 1,0,0,1,-1,0,0,-1 };
ll f[505][505];
int MAP[SIZE];

void Floyd(int n) {
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
			}
		}
	}
}

bool chk(int x, int y) {
	return x >= 1 && x <= h && y >= 1 && y <= w && a[x][y] != -1;
}

void build() {
	rep(i, 1, h) {
		rep(j, 1, w) {
			MAP[100ll * i + j] = ++cnt;
		}
	}
	rep(i, 1, 500) {
		rep(j, 1, 500) {
			if (i == j) f[i][j] = 0;
			else f[i][j] = 2e5;
		}
	}
	rep(i, 1, h) {
		rep(j, 1, w) {
			if (a[i][j] == -1) continue;
			rep(k, 0, 3) {
				if (!chk(i + d[k][0], j + d[k][1])) continue;
				f[MAP[100ll * i + j]][MAP[100ll * (i + d[k][0]) + j + d[k][1]]] = 1ll;
			}
		}
	}
}

int main() {
	io(); cin >> h >> w;
	rep(i, 1, h) cin >> (s[i] + 1);
	rep(i, 1, h) {
		rep(j, 1, w) {
			if (s[i][j] == '#') a[i][j] = -1;
		}
	}
	build();
	Floyd(cnt);
	ll maxd = 0;
	rep(i, 1, cnt) {
		rep(j, 1, cnt) {
			//cout << f[i][j] << ' ';
			if (f[i][j] >= 2e5) continue;
			maxd = max(maxd, f[i][j]);
		}
		//cout << '\n';
	}
	cout << maxd;
}
/*
3 3
...
...
...
5 7
#######
#.....#
#.###.#
#..#..#
#######
3 5
...#.
.#.#.
.#...
4 5
...#.
.###.
.###.
####.
*/

Measured memory_bytes: 2304
fn main() {
    // input
    let one = read_vec::<usize>();
    // N
    let n = one[0];
    // K
    let k = one[1] as i32;
    // Q
    let q = one[2];

    // A
    let a = (0..q)
        .map(|_| read_line::<usize>() - 1)
        .collect::<Vec<usize>>();

    let mut wins = vec![0; n];

    for &win in a.iter() {
        wins[win] += 1;
    }

    for &win in wins.iter() {
        let point = k - (q as i32) + win;
        // println!("{}", point);
        if point > 0 {
            println!("{}", "Yes");
        } else {
            println!("{}", "No");
        }
    }
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(26);
  char a;
  for(int i = 0; i < N; i++){
    cin >> a;
    data.at(a - 'a')++;
  }
  long ans = 1;
  for(int i = 0; i < 26; i++){
    ans *= data.at(i) + 1;
    ans %= 1000000007;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
string s = "aiueo" ;
int main(void)
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0)
			break;
		string b;
		vector<string> a(n);
		for (int i = 0; i < n; i++)
		{
			cin >> b;
			a[i] += b[0];
			for (int j = 1; j < b.size(); j++)
			{
				for (int k = 0; k < 5; k++)
				{
					if (b[j - 1] == s[k])
					{
						a[i] += b[j];
					}
				}
			}
		}
		sort(a.begin(), a.end());
		int c, d;
		//c = a.size();
		//unique(a.begin(), a.end());
		//d = a.size();
		//cout<<c<<" "<<d<<endl;
		if (unique(a.begin(),a.end()) != a.end())
		{
			cout << -1 << endl;
		}
		else
		{
			int ans = 0;
			for (int i = 1; i < a.size(); i++)
			{
				for (int j = 0; a[i - 1][j] == a[i][j]; j++)
				{
					if (ans < j + 1)
						ans = j + 1;
				}
			}
			cout << ans+1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>

int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(k<=a){
      printf("%d",k);
   }else if(k<=a+b){
      printf("%d",a);
   } else{
      printf("%d",a-(k-a-b));
   }
	return 0;
} 


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#ifdef SIR
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define err(...) 42
#endif

typedef long long ll;

using namespace std;

ll solve(vector<int> &a, vector<int> &b) {
    int n = (int)a.size();
    vector<pair<int, int>> c(n);
    for (int i = 0; i < n; i++) c[i] = { a[i] + b[i], i };
    sort(c.rbegin(), c.rend());

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) sum += a[c[i].second];
        else sum -= b[c[i].second];
    }
    return sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef SIR
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n; cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    cout << solve(a, b);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    string s;cin>>s;
    lli szs=sz(s);
    if(s[szs-1]=='s')
    {
    	s.pb('e');
    	s.pb('s');
    }
    else s.pb('s');
    cout<<s;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)     array<x,y>
#define p(x,y)      pair<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
/* template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; */

template<typename T>
T gcd(T a,T b){
    return b ? gcd(b, a%b) : a;
}

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int power(int x,int y){
    int res = 1;
    while(y > 0){
         if(y & 1) res *= x;
         y >>= 1;
         x *= x;
    }
    return res;
}

int power(int x,int y,int mod){
     int res = 1;
     x %= mod;
     while(y > 0){
          if(y & 1) res = (res * x) % mod;
          y >>= 1;
          x = (x * x) % mod;
     }
     return res;
}

class Template {
    int* readArray(int n){
        int *res = new int[n];
        for(int i = 0; i<n; i++){
            cin >> res[i];
        }
        return res;
    }
    void destroy(int *x){
        delete[] x;
    }
    v(int) readVector(int n){
        v(int) res(n);
        for(int i = 0; i<n; i++){
            cin >> res[i];
        }
        return res;
    }
    public:
    void solveOne(istream &in, ostream &out) {
        int x;
        in >> x;
        out << (x == 0) << "\n";
    }
    
    void solve(istream &in, ostream &out) {
        int nt = 1;
        //in >> nt;
        for (int it = 0; it < nt; ++it) {
            solveOne(in, out);
        }
    }
};
 
signed main() {
  fastio();
  Template solver;
  istream& in(cin);
  ostream& out(cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3644
while True:
    try:
        h=0
        b=0
        a1,a2,a3,a4=map(int,input().split())
        b1,b2,b3,b4=map(int,input().split())
        if a1==b1:
            h+=1
        if a2==b2:
            h+=1
        if a3==b3:
            h+=1
        if a4==b4:
            h+=1
        if a1==b2 or a1==b3 or a1==b4:
            b+=1
        if a2==b1 or a2==b3 or a2==b4:
            b+=1
        if a3==b1 or a3==b2 or a3==b4:
            b+=1
        if a4==b1 or a4==b2 or a4==b3:
            b+=1
        print(h,b)
    except:
        break


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string input;
	cin >> input;
	int num[4];
	rep(i, 0, 4) num[i] = input[i] - '0';

	for(int bit = 0; bit < 1 << 3; bit++) {
		int tmp = num[0];
		string res = "";
		for(int i = 0; i < 3; i++) {
			if(bit & 1 << i) {
				res += '+';
				tmp += num[i + 1];
			} else {
				res += '-';
				tmp -= num[i + 1];
			}
		}
		if(tmp == 7) {
			cout << num[0];
			rep(i, 1, 4) {
				cout << res[i - 1] << num[i];
			}
			cout << "=7" << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

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

// clang-format off
#ifdef _DEBUG_
#define dump(...) cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl
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(...)
#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...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    while (cin >> s >> t) {
        int n = s.size(), m = t.size();
        auto dp = make_v(n + 1, m + 1, 0);
        int ans = 0;
        REP(i, 0, n) {
            REP(j, 0, m) {
                if (s[i] == t[j]) {
                    dp[i + 1][j + 1] += dp[i][j] + 1;
                    ans = max(ans, dp[i + 1][j + 1]);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 65624
a,b,n=map(int,input().split(" "))

x=b-1
if x<=n:
  c=int(a*x/b)
  d=4*int(x/b)
  print(c-d)
else:
  c=int(a*n/b)
  d=4*int(n/b)
  print(c-d)
  

Measured memory_bytes: 9180
s=0
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in range(N):
  if A[i]>=B[i]:
    s+=B[i]
  else:
    s+=A[i]
    B[i]=B[i]-A[i]
    if B[i]>=A[i+1]:
      s+=A[i+1]
      A[i+1]=0
    else:
      s+=B[i]
      A[i+1]-=B[i]
print(s)

Measured memory_bytes: 24176
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
#define CO(a, b, c) ((a) ? (b) : (c))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main(void)
{

    vector<int> n(5);
    for (auto &&i : n)
    {
        cin >> i;
    }
    int x = 0;
    for (auto &&i : n)
    {
        ++x;
        if (i == 0)
        {
            cout << x << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int sum=0,ma=INT_MIN;
  for(unsigned long int i=0;i<s.length();i++)
  {
  if(s[i]=='R')
    sum++;
    else
      sum=0;
  ma=max(ma,sum);
  }
cout<<ma;
  return 0;
}


Measured memory_bytes: 3616
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String str = sc.next();
			
			String str3 = str.substring(2, 3);
			String str4 = str.substring(3, 4);
			String str5 = str.substring(4, 5);
			String str6 = str.substring(5, 6);
				
			if(str3.equals(str4) && str5.equals(str6)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
				}
			}
		
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)

Measured memory_bytes: 31704
import sys
read = sys.stdin.read

N, *D = map(int, read().split())

D_1 = [D.count(i) for i in range(13)]

if D_1[0] or D_1[-1] > 1:
    print(0)
    exit()

for i in D_1:
    if i > 2:
        print(0)
        exit()


d = [False] * (12 + 1 + 12)

# 高橋君
d[12] = True

rl = True
for i in range(13):
    for _ in range(D_1[i]):
        if rl:
            d[12 + i] = True
            rl = False
        else:
            d[12 - i] = True
            rl = True

a = [i for i, j in enumerate(d) if j]
a.append(24 + a[0])
s = 24
for i, j in zip(a, a[1:]):
    if j - i < s:
        s = j - i

print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)   for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
    if(a.first==b.first)return a.second<b.second;
    else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
    for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
    for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
    int sum=0;
    // for(auto x: v)sum+=x;
    fr(i,0,v.size())sum+=v[i];
    return sum;
}





 void solve()
{
    int n;
    cin>>n;
    int a=0;
    fr(i,1,n)
    {
        a= a+ floor((n-1)/i);

    }
    cout<<a;

    
}

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

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

int main( void )
{
    int a,b,h;
    cin >> a >> b >> h;
    
    int ans = (a + b) * h / 2;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
 
ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
 
INF = 1 << 60
dp = [INF for _ in range(h+10001)]
 
dp[0] = 0
 
for i in range(1, h+10001):
    for j in range(n):
        if(i<ab[j][0]): continue
        dp[i] = min(dp[i-ab[j][0]] + ab[j][1], dp[i])
 
res = INF
for i in range(h, h+10001):
    res = min(res, dp[i])
print(res)

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


X=[1]+[6**i for i in range(1,7)]+[9**i for i in range(1,6)]
X.sort()
X.reverse()

ANS=1000000



i=5



for i_0 in range(max(N//X[0]-i,0),N//X[0]+1):
    N_0=N-X[0]*i_0
    for i_1 in range(max(N_0//X[1]-i,0),N_0//X[1]+1):
        N_1=N_0-X[1]*i_1
        for i_2 in range(max(N_1//X[2]-i,0),N_1//X[2]+1):
            N_2=N_1-X[2]*i_2
            for i_3 in range(max(N_2//X[3]-i,0),N_2//X[3]+1):
                N_3=N_2-X[3]*i_3
                for i_4 in range(max(N_3//X[4]-i,0),N_3//X[4]+1):
                    N_4=N_3-X[4]*i_4
                    for i_5 in range(max(N_4//X[5]-i,0),N_4//X[5]+1):
                        N_5=N_4-X[5]*i_5
                        for i_6 in range(max(N_5//X[6]-i,0),N_5//X[6]+1):
                            N_6=N_5-X[6]*i_6
                            for i_7 in range(max(N_6//X[7]-i,0),N_6//X[7]+1):
                                N_7=N_6-X[7]*i_7
                                for i_8 in range(max(N_7//X[8]-i,0),N_7//X[8]+1):
                                    N_8=N_7-X[8]*i_8
                                    for i_9 in range(max(N_8//X[9]-i,0),N_8//X[9]+1):
                                        N_9=N_8-X[9]*i_9
                                        i_10=N_9//6
                                        N_10=N_9-X[10]*i_10
                                        if ANS>i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10:
                                            ANS=i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10


                                            




print(ANS)
        
    


Measured memory_bytes: 3192
n = int(input())
xy = []

for i in range(n):
    a = int(input())
    temp = {}
    for j in range(a):
        x, y = map(int, input().split())
        temp[x] = y
    xy.append(temp)

ans = 0

for i in range(0, 2**n):
    # print('\n', i, bin(i))
    isValid = True
    temp = 0

    for k in range(len(xy)):
        hMap = xy[k]
        kBit = (i >> k) & 1
        # print('k:', k, 'kBit:', kBit)
        if kBit == 1:
            # print('hMap is correct:', hMap)
            for key, value in hMap.items():
                # print(key, value, (i >> (key-1)) & 1, 'must be same')
                if not (i >> (key-1)) & 1 == value:
                    # print('paradox!')
                    isValid = False
                    break
        # else:
        #     # print('hMap is NOT correct:', hMap)
        #     for key, value in hMap.items():
        #         # print(key, value, (i >> (key-1)) & 1, 'must be different')
        #         if not (i >> (key-1)) & 1 != value:
        #             # print('paradox!')
        #             isValid = False
        #             break
    if isValid:
        for j in range(n):
            # print('Check digit:', j)
            jBit = (i >> j) & 1
            # print('bit:', jBit)
            if jBit == 1:
                temp += 1
        ans = max(ans, temp)

print(ans)

Measured memory_bytes: 43228
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int mx1 = 0, mx2 = 0;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
		if(mx1 < a[i]){
			mx2 = mx1;
			mx1 = a[i];
		}
		else if(mx2 < a[i]){
			mx2 = a[i];
		}
	}
	rep(i,n){
		if(a[i] == mx1) cout << mx2 << endl;
		else cout << mx1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * One-Dimensional Cellular Automaton
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int N, M, A, B, C, T;
			N = parseInt(st.nextToken());
			M = parseInt(st.nextToken());
			A = parseInt(st.nextToken());
			B = parseInt(st.nextToken());
			C = parseInt(st.nextToken());
			T = parseInt(st.nextToken());
			if ((N | M | A | B | C | T) == 0) break;

			//
			int[][] mat = new int[N][N];

			for (int i = 0; i < N; i++) {
				if (i - 1 >= 0) mat[i][i - 1] = A;
				mat[i][i] = B;
				if (i + 1 < N) mat[i][i + 1] = C;
			}

			int[][] aa = pow(mat, T, M);

			//
			st = new StringTokenizer(br.readLine());

			int[] S = new int[N];

			for (int i = 0; i < N; i++) {
				S[i] = parseInt(st.nextToken());
			}

			String[] SS = new String[N];

			for (int i = 0; i < N; i++) {
				int _ss = 0;
				for (int j = 0; j < N; j++) {
					_ss = (_ss + aa[i][j] * S[j]) % M;
				}
				SS[i] = String.valueOf(_ss);
			}

			System.out.println(String.join(" ", SS));
		}
	}

	static int[][] mul(int[][] a, int[][] b, int mod) {

		int[][] t = new int[a.length][b[0].length];

		for (int i = 0; i < a.length; i++) {
			for (int k = 0; k < b.length; k++) {
				for (int j = 0; j < b[0].length; j++) {
					t[i][j] = (t[i][j] + a[i][k] * b[k][j]) % mod;
				}
			}
		}

		return t;
	}

	static int[][] pow(int[][] a, int e, int mod) {

		if (e == 0) {
			int[][] t = new int[a.length][a[0].length];
			for (int i = 0; i < a.length; i++) {
				t[i][i] = 1;
			}
			return t;
		}

		if (e == 1) return a;

		int[][] t = {};

		t = pow(mul(a, a, mod), e / 2, mod);
		if (e % 2 == 1) t = mul(t, a, mod);

		return t;
	}
}

Measured memory_bytes: 50852
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	ans := 0
	for i := 1; i < N; i++ {
		l := S[0:i]
		r := S[i:N]

		m := make(map[rune]bool)
		for _, s := range l {
			m[s] = true
		}

		c := make(map[rune]bool)
		for _, s := range r {
			if _, ok := m[s]; ok {
				c[s] = true
			}
		}

		if ans < len(c) {
			ans = len(c)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
  int N,K,M=0;
  cin>>N>>K;
  vector<int> length(N);
  	for(int i=0;i<N;i++){
      cin>>length.at(i);
    }
  sort(length.begin(),length.end());
  reverse(length.begin(),length.end());
    for(int i=0;i<K;i++){
      M+=length.at(i);
    }
  cout<<M<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    if(n >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
a, b = map(int, input().split())

a_str, b_str = [], []
for i in range(0,b):
  a_str.append(a)
for i in range(0,a):
  b_str.append(b)

if a > b :
  print(''.join(map(str,b_str)))
else :
  print(''.join(map(str,a_str)))

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

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

  int judge = 0;
  rep(i, N.size()) judge += (int)(N[i] - '0');

  if (judge % 9 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3744
A,B,M = gets.chop.split.map(&:to_i)
a = gets.split(' ').map(&:to_i)
b = gets.split(' ').map(&:to_i)
xyz = []
M.times do
    xyz << gets.chomp.split(' ').map(&:to_i)
end

ans = a.min + b.min
for i in 0..M-1 do
    value = a[xyz[i][0] - 1] + b[xyz[i][1] - 1] - xyz[i][2]
    ans = [ans, value].min
end

puts ans

Measured memory_bytes: 28412
from numpy import*
h,w=map(int,input().split())
a=array([[0 if i!="." else 1 for i in input()]for j in range(h)])
e=zeros((4,h,w))
for i in range(h):
    e[0,i]=(e[0,i-1]+1)*a[i]
    e[1,-i-1]=(e[1,-i]+1)*a[-i-1]  
for i in range(w):
    e[2,:,i]=(e[2,:,i-1]+1)*a[:,i]
    e[3,:,-i-1]=(e[3,:,-i]+1)*a[:,-i-1] 
print(int(amax(sum(e, axis=0))-3))

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

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z')
        cout << 'A';
    else
        cout << 'a';
    return 0;
}

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

int isKaibun(int n){
    string s;
    s=to_string(n);
    int size;
    size = s.size();
    for(int i=0;i<size/2;i++){
        if(s[i]!=s[size-1-i]){return 0;}
    }
    return 1;
}

int main(){
    int a,b,ans=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(isKaibun(i)){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

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

N = map(int,input().split())
A = [int(x) for x in input().split()]

low,high = 2,2

for a in A[::-1]:
    low += (-low)%a
    high -= high%a
    high += (a-1)

if low > high:
    print(-1)
else:
    print(low,high)

Measured memory_bytes: 14168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=2e9;
int main(){
	int n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	rep(i,n-1){
		ll s,t;
		cin>>s>>t;
		if((double)a/s<(double)b/t){
//			ll q=ceil<ll>((double)b/t);
			ll q=(b-1)/t+1;
			a=s*q;b=t*q;
		}else{
//			ll q=ceil<ll>((double)a/s);
			ll q=(a-1)/s+1;
			a=s*q;b=t*q;		
		}
	}
	cout<<a+b<<endl;
}










Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// ランレングス圧縮 O(N)
template <class RandomAccessIterator>
vector<ll> run_length(RandomAccessIterator first, RandomAccessIterator last) {
    vector<ll> rl;
    for (RandomAccessIterator itr = first; itr != last; ) {
        RandomAccessIterator jtr = itr++;
        while ((itr != last && *itr == *(itr-1))) itr++;
        rl.push_back(itr - jtr);
    }
    return rl;
}

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    ll ans = 0;
    for (ll i : run_length(ALL_OF(a))) {
        ans += i / 2;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k=0,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++)
    {
        if(a[i]!=(i+1))k++;
    }
    if(k==2||k==0)cout<<"YES";
    else {cout<<"NO";}
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 5050;
int n,mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
struct yzr{
	int cnt,f[N][N],dp[2][N][N];//lim,sum
	void ini(){
		dp[0][cnt][0]=1;
		rep(t,1,n+1){//t-1 --> t
			int p=t&1,q=p^1;//q-->p
			rep(i,0,n/t)rep(j,0,n)dp[p][i][j]=0;
			static int g[N];rep(j,0,n)g[j]=0;
			for(int j=t>1?n/(t-1):n;j>=0;j--){
				rep(k,0,n){
					add(g[k],dp[q][j][k]);
					if(k+j<=n)dp[p][j][k+j]=g[k];
				}
			}
			rep(i,0,n)f[t-1][i]=dp[p][0][i];
		}
	}
}a,b;
int main() {
	read(n);read(mo);
	a.cnt=n/2;b.cnt=n/2-1;
	a.ini();if(n%2==0)b.ini();
	if(n%2){
		int res=0;
		rep(x,1,n){
			static int f[N],g[N];
			rep(i,0,x)f[i]=a.f[x-1][i];
			rep(i,0,x)g[i]=a.f[n-x][i];
			rep(i,1,x)add(g[i],g[i-1]);
			rep(i,0,x-1)add(res,1ll*f[i]*g[x-1-i]%mo);
		}
		cout<<res;
	}
	else{
		int res=0;
		rep(x,1,n){
			static int f[N],g[N];
			rep(i,0,x)f[i]=a.f[x-1][i];
			rep(i,0,x)g[i]=b.f[n-x][i];
			rep(i,1,x)add(g[i],g[i-1]);
			rep(i,0,x-1)add(res,1ll*f[i]*g[x-1-i]%mo);
		}
		cout<<res;
	}
	return 0;
}


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


long tmp[10];

int main(){
	int X,Y;
	int x[10];
		scanf("%d%d",&X,&Y);
	/*
	a+b=X
	2a+4b=Y

	b=X-a
	
	2a+4X-4a=Y
	
	4X-2a=Y
	4X-Y=2a
	*/
	if(Y%2==0){
		int a = (4*X-Y)/2;
		
		if(a<0 || (X-a)<0){
			printf("No\n");
			return 0;
		}
		else printf("Yes\n");
	}
	else {
		
		printf("No\n");	
	}
	return 0;
}


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

N = int(input())
S = input().rstrip()
# X, Y = map(int,input().split())
# Z, W = map(int,input().split())
# vA = list(map(int, input().split()))

dpA = [1,] + [0,]*10
dpB = [0,] * 100
dpC = [0,] * 1000

# dp = [[[1,]+[0,]*10 for _i in range(11)]
#       for _j in range(11)]

for s in S:
    d = int(s)
    for i in range(10):
        for j in range(10):
            if dpB[i*10 + j]:
                dpC[i*100 + j*10 + d] = 1
    for i in range(10):
        if dpA[i+1]:
            dpB[i*10 + d] = 1
    dpA[d+1] = 1
    # print(dpA)##
# print(":(")

# res = 0
# for i in range(10):
#     for j in range(10):
#         res += sum(a>0 for a in dp[i][j][1:])

res = sum(dpC)
print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.nextLine();
        char[] S = sc.nextLine().toCharArray();
        int cnt = 0;
        for (int i=0; i+2<S.length; i++) {
            if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cnt++;
        }
        System.out.println(cnt);
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n,m;
    while(cin>>n>>m, n || m){
        int res = 0;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[i] + a[j] > m) continue;
                res = max(res, a[i] + a[j]);
            }
        }
        if(res==0){
            cout<<"NONE"<<endl;
        }
        else{
            cout<<res<<endl;
        }
    }
}



Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int dist1[100000];
int dist2[100000];
vector<int> g[100000];
vector<int> v[100000];
int a[200000];
int b[200000];

int main() {
  int n,m;
  while(cin >> n >> m) {
    REP(i,n) {
      v[i].clear();
      g[i].clear();
    }
    REP(i,m) {
      scanf("%d%d",a+i,b+i);
      a[i]--;b[i]--;
      g[a[i]].push_back(b[i]);
    }
    memset(dist1,0,sizeof(dist1));
    memset(dist2,0,sizeof(dist2));
    int maxLen = 0;
    REP(i,n) {
      FOR(it, g[i]) {
        chmax(dist1[*it],dist1[i] + 1);
      }
      chmax(maxLen, dist1[i]);
    }
    for (int i=n-1; i>=0; --i) {
      FOR(it, g[i]) {
        chmax(dist2[i],dist2[*it] + 1);
      }
    }
    REP(i,m) {
      if (maxLen == dist1[a[i]] + 1 + dist2[b[i]]) {
        v[dist1[a[i]]].push_back(i);
      }
    }
    vector<int> ans;
    REP(i,n) if (v[i].size() == 1) ans.push_back(v[i][0]);
    if(ans.size() == 0) cout << -1 << endl;
    else {
      sort(ALL(ans));
      FOR(it, ans) cout << *it + 1 << endl;
    }
  }
}

Measured memory_bytes: 14232