akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC110_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("War");}else{puts("No War");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int m;
    scanf("%d",&m);
    int X;
    scanf("%d",&X);
    int Y;
    scanf("%d",&Y);
    int maxx = -100;
    int miny = 100;
    ll x[n] = {};
    rep(i,n){
        scanf("%lld",&x[i]);
        if(maxx<x[i]){
            maxx=x[i];
        }
    }
    ll y[m] = {};
    rep(i,m){
        scanf("%lld",&y[i]);
        if(miny>y[i]){
            miny=y[i];
        }
    }
    int flag = 0;

    if(maxx>=miny)flag=1;
    if(maxx>=Y)flag=1;
    if(miny<=X)flag=1;
    

    if(flag==1)yn;

    return 0;
}



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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();
    let mut cnt = 0;
    for i in a..b+1 {
        if c % i == 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 5024
#include<stdio.h>

int main(void){
    int n, l;
    int sum, ave, taste;
    scanf("%d %d", &n, &l);

    sum = n*(l-1) + n*(n+1)/2;

    if(l >= 0) taste = sum - l;
    else if(n-1 > -l) taste = sum;
    else taste = sum - (l+n-1);

    printf("%d\n", taste);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [input().split() for l in range(3)]
mnpk = 0
fl = 0
for i in range(n):
  b = int(a[0][i]) - 1
  mnpk = mnpk + int(a[1][b])
  if fl == 1:
    if int(a[0][i-1]) == b:
      mnpk = mnpk + int(a[2][b-1])
  else:
    fl = 1

print(mnpk)
    

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i = m; i < (n); ++i)

int main()
{
	char right[] = { 'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm' };
	string str;
	
	while(cin >> str && str != "#")
	{
		int ans = 0;
		bool r = false;
		rep(i, 11) if(str[0] == right[i]) r = true;
		
		rep2(i, 1, str.size())
		{
			bool rr = false;
			rep(j, 11) if(str[i] == right[j]) rr = true;
			if(r != rr)
				r = rr, ++ans;
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    auto start_time = clock();
    cerr << setprecision(3) << fixed;
#endif
    ll n;
    cin>>n;
    ll a[n][3],i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
            cin>>a[i][j];
    }
    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            for(ll k=0;k<3;k++)
            {
                if(j!=k)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
#ifdef LOCAL
    auto end_time = clock();
    cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 8308
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	ll a,b,n;
	cin>>a>>b>>n;
	ll mn = min(b-1,n);
	cout<<a*mn/b - mn/b*a<<endl;
	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 3564
a=[]
c=[]
while True:
    try:
        a.append(int(input()))
    except:
        break
x=len(a)
for i in range(x):
    b=a.count(i)
    c.append(b)
r=max(c)
e=len([i for i,x in enumerate(c) if x==r])
d=[i for i,x in enumerate(c) if x==r]
for i in range(e):
    print(d[i])


Measured memory_bytes: 5600
from fractions import gcd

a,b,c,d = map(int, input().split())
n=0
j=0

figs = b-a + 1
L = (c*d) // gcd(c,d)


Cdiv = b // c - (a-1) //c
Ddiv = b // d - (a-1) //d
CDdiv =  b // L - (a-1) // L

ans = figs - Cdiv - Ddiv + CDdiv

print (ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int N, M, Q;

vector<vi> vects;

void dfs(vector<int> vec, int n) {
  vec.push_back(n);
  if (vec.size() == N) {
    vects.push_back(vec);
    return;
  }
  for (int i = vec.at(vec.size() - 1); i <= M; i++) {
    dfs(vec, i);
  }
  return;
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  cin >> N >> M >> Q;
  vi vec;
  ll ans = 0;
  dfs(vec, 1);
  /*  for (auto x : vects) {
      for (auto y : x) {
        cout << y << " ";
      }
      cout << endl;
    }*/
  vector<vi> Query;
  REP(i, Q) {
    vi q(4);
    cin >> q.at(0) >> q.at(1) >> q.at(2) >> q.at(3);
    Query.push_back(q);
  }
  for (auto x : vects) {
    ll tmp = 0;
    for (auto q : Query) {
      if (x.at(q[1] - 1) - x.at(q[0] - 1) == q[2]) tmp += q[3];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6732
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 2000;

ll dp[MAX_N][MAX_N];
ll N;
P A[MAX_N];
void rec(ll i){
	REP(l, i+1){
		ll r = N - 1 - (i - l);
		ll tmp = A[i].first*abs(A[i].second-l);
		ll tmp2 = A[i].first*abs(N-1-(i-l)-A[i].second);
		// printf("i: %lld, l: %lld, r: %lld, tmp: %lld, %lld\n", i, l, r, tmp, tmp2);
		if (i-l-1>=0){
			dp[l+1][i-l] = max(dp[l][i-l]+A[i].first*abs(A[i].second-l), 
							   dp[l+1][i-l-1]+A[i].first*abs(N-1-(i-l-1)-A[i].second));
		}
		else dp[l+1][i-l] = dp[l][i-l]+A[i].first*abs(A[i].second-l);
		if (l-1>=0){
			dp[l][i-l+1] = max(dp[l-1][i-l+1]+A[i].first*abs(A[i].second-(l-1)),  
							dp[l][i-l]+A[i].first*abs(N-1-(i-l)-A[i].second));
		}
		else dp[l][i-l+1] = dp[l][i-l]+A[i].first*abs(N-1-(i-l)-A[i].second);
	}
}
/**/
int main() {
	// 入力
	cin>>N;
    REP(i,N){
		ll a_tmp;cin>>a_tmp;
		A[i] = make_pair(a_tmp, i); // (活発度, 座標)
	}
    
	// 解法
	ll ans = 0;
	sort(A, A + N, greater<P>());
	REP(l,N){
		REP(r, N-l){
			dp[l][r] = 0;
		}
	}
	REP(i,N)rec(i);

	REP(l,N+1){
		REP(r,N-l+1){
			// printf("l: %lld, r: %lld, dp: %lld\n", l, r, dp[l][r]);
			if (ans<dp[l][r]) ans = dp[l][r];
		}
	}
	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 26440
n = int(input())
a = [int(i) for i in list(input().split())]
same_flag = False
cnt = 0
for i, color in enumerate(a):
    if i == 0:
        tmp = color
    else:
        if same_flag:
            cnt += 1
            same_flag = False
            tmp = color
        else:            
            if color == tmp:
                same_flag = True
                tmp = color
            else:
                tmp = color
if same_flag:
    cnt += 1
print(cnt)

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

int main(void)
{
	int n;

	while (cin >> n)
	{
		if (n == 0) break;
		int k = 5, d = 0;
		while (n >= k)
		{
			d += n / k;
			k *= 5;
		}
		cout << d << endl;
	}
	return 0;
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b,t; cin >> a >> b >> t;
    cout << b*(t/a) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr long INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

long a, b;
vector<long> d;


int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> a >> b;
  
  for(long i = 1; i * i <= a; ++i) {
    if(a % i == 0) {
      if(b % i == 0) d.push_back(i);
      if(a / i != i) if(b % (a / i) == 0) d.push_back(a/i);
    }
  }

  long ans = 0;
  for(long n : d) {
    bool ok = true;
    for(long i = 2; i * i <= n; ++i) {
      if(n % i == 0) ok = false;;
    }
    if(ok) ++ans;
  }

  cout << ans << endl;

  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double t = abs(0.5*(60*h - 11*m)) * acos(-1) / 180.0;
  double ans = sqrt(a*a+b*b-2*a*b*cos(t));
  cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 4208
N, M = map(int, input().split())
A = []
for i in range(N):
    A_i = list(map(int, input().split()))
    A.append(A_i[1:])

sum = [0]*M
for i in range(N):
    for j in range(len(A[i])):
        sum[A[i][j]-1] += 1

print(sum.count(N))


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	unsigned long long a, b;
	cin >> a >> b;
	int ans = 0;
	while(a <= b){
		b /= 2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
function main(input){
  input = input.split('\n');
  const [N, D] = input[0].split(' ').map(Number);
  const points = input.slice(1, N+1).map(s=> {let v = s.split(' ').map(Number); return {x:v[0], y:v[1]}});

  let D2 = D*D;
  let count = 0;
  points.forEach(p=>{
    if((p.x*p.x + p.y*p.y) <= D2) count++;
  });

  console.log(count);
}


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


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A)); vector<PII> step;
        if (A[n-1] > 0) {
            int j = 1;
            while (j < n-1 && A[j] < 0)
                j++;
            FOR(k,j,n-1) {
                const int x = A[0];
                const int y = A[k];
                A[0] = x-y;
                step.push_back(PII(x,y));
            }
            FOR(i,0,j) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        else {
            FOR(i,0,n-1) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        cout << A[n-1] << endl;
        FOR_ALL(x,step)
            cout << x->first << ' ' << x->second << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>

int main(){
  int r, g, b, n;
  int cnt = 0;
  scanf("%d %d %d %d\n", &r, &g, &b, &n);
  int x = n / r;
  for(int i=x;i>=0;i--){
    int y = (n - (i * r)) / g;
    for(int j=y;j>=0;j--){
      int z = n - (i * r) - (j * g);
      if(z % b == 0){
        cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String array = "";
        Deque<Character> left = new ArrayDeque<>();
        Deque<Character> right = new ArrayDeque<>();
        array = sc.nextLine();
        boolean isClear = true;

        while(!array.equals(".")){
            for( int i = 0; i < array.length(); i++) {
                if(array.charAt(i) == '(' || array.charAt(i) == '['){
                    left.push(array.charAt(i));
                }else if(array.charAt(i) == ')' || array.charAt(i) == ']'){
                    right.push(array.charAt(i));
                    if(!left.isEmpty()){
                        if((right.peek() == ')' && left.peek() == '(') ||
                            (right.peek() == ']' && left.peek() == '[')){
                            right.pop();
                            left.pop();
                        }else{
                            isClear = false;
                            break;
                        }
                    }
                }
            }
            if(left.isEmpty() && right.isEmpty() && isClear){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }

            right.clear();
            left.clear();
            isClear = true;
            array = sc.nextLine();
        }
        
        sc.close();
    }
}


Measured memory_bytes: 45668
def main()
  n = gets.chomp.to_i
  x = gets.chomp.split(' ').map(&:to_i)
  dic = Hash.new(0)
  for i in 0..n-1 do
    dic[x[i]] = dic[x[i]] + 1
    dic[x[i]-1] = dic[x[i]-1] + 1
    dic[x[i]+1] = dic[x[i]+1] + 1
  end
  ans_k,ans_v = dic.max_by{|k,v| v}
  puts ans_v
end

main()

Measured memory_bytes: 17412
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	auto S = readln.split[0].to!(dchar[]);
	auto K = readln.split[0].to!int;
	
	string ans = "";
	auto c = S[K-1];
	foreach (d; S) {
		if (d == c) ans ~= d;
		else ans ~= '*';
	}
	writeln(ans);
}



Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Data.Semigroup

solve :: T.Text -> T.Text -> T.Text -> T.Text
solve temp in1 in2
 | T.null in1  = temp
 | otherwise = solve (T.snoc (T.snoc temp (T.head in1)) (T.head in2)) (T.tail in1) (T.tail in2)

main = do
 _ <- TIO.getLine
 [in1, in2] <- (T.words) <$> TIO.getLine 
 TIO.putStr $ solve T.empty in1 in2 

Measured memory_bytes: 3808
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <array>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <tuple>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;

  size_t n = s.length();
  std::vector<std::vector<size_t>> idx(26);
  for (size_t i = 0; i < n; ++i)
    idx[s[i]-'a'].push_back(i);

  size_t res = 1;
  size_t cur = n;
  for (char c: t) {
    if (idx[c-'a'].empty()) return puts("-1"), 0;

    auto it = std::upper_bound(idx[c-'a'].begin(), idx[c-'a'].end(), cur);
    if (it == idx[c-'a'].end()) {
      res += n-cur;
      it = idx[c-'a'].begin();
      cur = *it;
      res += *it;
    } else {
      res += (*it - cur);
      cur = *it;
    }
    // fprintf(stderr, "res: %zu\n", res);
  }
  printf("%zu\n", res);
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

class UnionFindTree
{
  public:
	int treeCnt; //ツリーの数
	vi rank, p;  //rank => 根の高さ, p => 親
	vi num;		 //木の要素数
	vi diff_weight;
	UnionFindTree() {}
	UnionFindTree(int size)
	{
		rank.resize(size, 0);
		p.resize(size, 0);
		num.assign(size, 1);
		treeCnt = 0;
		REP(i, size)
		{
			makeset(i);
		}
	}

	void makeset(int x)
	{
		p[x] = x;
		rank[x] = 0;
		treeCnt++;
	}

	//同じ木に属しているか判定
	bool isSame(int x, int y)
	{
		return root(x) == root(y);
	}

	//xとyが属している木をつなぐ
	void unite(int x, int y)
	{
		link(root(x), root(y));
	}

	//木と木を繋ぐ処理をする。
	void link(int x, int y)
	{
		if (!isSame(x, y))
		{
			if (rank[x] > rank[y])
			{
				p[y] = x;
				num[x] += num[y];
			}
			else
			{
				p[x] = y;
				if (rank[x] == rank[y])
				{
					rank[y]++;
				}
				num[y] += num[x];
			}
			treeCnt--;
		}
	}

	//xが属している木の根を探る
	int root(int x)
	{
		if (p[x] == x)
			return x;
		else
			return p[x] = root(p[x]);
	}

	int countTree()
	{
		return treeCnt;
	}

	int getNum(int a)
	{
		return num[root(a)];
	}
};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, M;
	cin >> N >> M;
	vi A(M), B(M);
	REP(i, M)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	rev(A);
	rev(B);
	UnionFindTree utf(N);
	vll ans;
	ll cur = (N * (N - 1)) / 2;
	REP(i, M)
	{
		ans.push_back(cur);

		if (!utf.isSame(A[i], B[i]))
		{
			cur -= utf.getNum(A[i]) * utf.getNum(B[i]);
			utf.unite(A[i], B[i]);
		}
	}
	rev(ans);
	REP(i, SZ(ans))
	{
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4212
N = int(input())
S = input()

ans = 0
c = 0
for s in S:
    if s == 'A':
        c = 1
    elif s == 'B' and c == 1:
        c = 2
    elif s == 'C' and c == 2:
        c = 0
        ans += 1
    else:
        c = 0
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/
int main() {
    int n, sum;
    sum = 0;

    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    vector<int> s;
    for(int p = x[0]; p <= x[n - 1]; p++) {
        for(int i : x) {
            sum += (i - p) * (i - p);
        }
        s.push_back(sum);
        sum = 0;
    }
    sort(s.begin(), s.end());

    cout << s[0] << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Lunch
 */
public class Main {

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

		short p1, p2, p3, j1, j2;
		while ((line = br.readLine()) != null && !line.isEmpty()) {

			p1 = Short.parseShort(line);
			p2 = Short.parseShort(br.readLine());
			p3 = Short.parseShort(br.readLine());
			j1 = Short.parseShort(br.readLine());
			j2 = Short.parseShort(br.readLine());

			System.out.println((int) Math.min(Math.min(p1, p2), p3)
					+ (int) Math.min(j1, j2) - 50);
		}
	}
}

Measured memory_bytes: 17056
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int N;
  cin>>N;
  vector<ll> luca(N+1);
  luca[0]=2;
  luca[1]=1;
  for(int i=2;i<N+1;i++){
    luca[i]=luca[i-1]+luca[i-2];
  }
  cout<<luca[N]<<"\n";


  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};




int main(){

  string s;
  cin >> s;
  int ff = (s[0] - '0')*10 + s[1] - '0';
  int bb = (s[2] - '0')*10 + s[3] - '0';
  if(ff > 0 && ff <= 12 && bb > 0 && bb <= 12){
    cout  << "AMBIGUOUS" << endl;
  }else if((ff < 1 || ff > 12) && bb > 0 && bb <= 12){
    cout << "YYMM" << endl;
  }else if((bb < 1 || bb > 12) && ff > 0 && ff <= 12){
    cout << "MMYY" << endl;
  }else{
    cout << "NA" << endl;
  }
  


  return 0;
}


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

const int MAX_NM = 1e5 + 10;
int main()
{
	int n, m;
	int l[MAX_NM], r[MAX_NM];
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> l[i] >> r[i];
	}

	int x = 0, y = MAX_NM;
	for (int i = 0; i < m; ++i)
	{
		if (x < l[i])
			x = l[i];

		if (y > r[i])
			y = r[i];
	}

	if (y - x >= 0)
	{
		cout << y - x + 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
from collections import defaultdict
N = int(input())
dic = defaultdict()
for i in range(1, N+1):
  k, v = input().split()
  dic[i] = [k, int(v)]
  
sorted_dic = sorted(dic.items(), key=lambda x:(x[1][0], -x[1][1]))
for k, *v in sorted_dic:
  print(k)
    

Measured memory_bytes: 3316
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, i, z, f = 0;
    cin >> n;
    vector<int> a(0);
    for(i = 0; i < n; i++){
        cin >> z;
        a.push_back(z);
    }
    for(i = 0; i < n; i++){
        if(a[i]%2 == 1) break;
        if(i == n-1){
            f++;
            i = 0;
        }
        a[i] /= 2;
    }
    cout << f << endl;
    return 0;
}

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

int main()
{
	char a[11]={'\0'},T[1002]={'\n'},P[1002]="END_OF_TEXT";
	int i,t,n,s=0,y=1;
	
	scanf("%s",a);
	for(i=0;a[i]!='\0';i++);
	
	
	for(t=0;a[t]!='\0';t++){//????????§??§??????????°????????????????
		
		a[t]=tolower(a[t]);
	}
	//printf("%s\n",a);
	
	for(;y!=0;){
		y=0;
		for(int m=0;m<1001;m++){
			T[m]='\0';
		}
		
		scanf("%s",T);
		
		for(int x=0;T[x]!='\0';x++){//END_OF_TEXT?????????????????????
			if(T[x]!=P[x]){
			y++;
			}
		}
		
		for(t=0;T[t]!='\0';t++){//????????§??§??????????°????????????????
			
			T[t]=tolower(T[t]);
		}
		
		
		if(y!=0){
			//printf("%s\n",a);
			n=0;
			if(a[0]==T[0]&&i==t){
				
				for(n=1;n<i;n++){
					
					if(a[n]!=T[n]){
						break;
					}
				}
			}
			if(n==i){
				s=s+1;
				//printf("%s %d %d\n\n",T,i,n);
				
			}
		}
		//printf("%s %d\n\n",T,s);
	}
	printf("%d\n",s);
	
	return 0;
}

Measured memory_bytes: 2720
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[100005];
vector<int>a;
int dfs(int x){
    //show(x);
    if(x < a[0])return dp[x] = 0;
    if(dp[x] != -1) return dp[x];
    for(int b:a){
        if(x-b >= 0 and dfs(x-b) ==0)return dp[x] = 1;
    }
    return 0;
}
int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    rep(i,k+1)dp[i] = -1;
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    if(dfs(k)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}

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

void dfs(int i,int p,vector<vector<int> > &e,vector<vector<long long> > &c,vector<int> &S,long long &ans,int &n)
{
  S[i]=1;
  int F=0;
  for(int x=0;x<e[i].size();x++){
    int j=e[i][x];
    if(j==p)continue;
    dfs(j,i,e,c,S,ans,n);
    ans+=c[i][x]*2ll*min(n-S[j],S[j]);
    if(2*S[j]==n){
      F=1;
      ans-=c[i][x];
    }
    else if(2*S[j]>n){
      F=1;
    }
    S[i]+=S[j];
  }
  if(!F&&2*(n-S[i])<n){
    long long mn=1000000000ll;
    for(int x=0;x<e[i].size();x++){
      mn=min(mn,c[i][x]);
    }
    ans-=mn;
  }
}

int main()
{
  int n;
  scanf("%d",&n);
  vector<vector<int> > e(n);
  vector<vector<long long> > c(n);
  for(int t=0;t<n-1;t++){
    int A,B;
    long long C;
    scanf("%d%d%lld",&A,&B,&C);A--,B--;
    e[A].push_back(B);
    c[A].push_back(C);
    e[B].push_back(A);
    c[B].push_back(C);
  }
  vector<int> S(n);
  long long ans=0ll;
  dfs(0,-1,e,c,S,ans,n);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 22272
# Your code here!
def del(i,j)
  return if $t[i][j] == "."
  $t[i][j] = "."
  del(i-1,j) if(i > 0)
  del(i,j-1) if(j > 0)
  del(i+1,j) if(i < $h-1)
  del(i,j+1) if(j < $w-1)
end
def jud(i,j)
  return if(i > 0 and $t[i-1][j] == "#")
  return if(j > 0 and $t[i][j-1] == "#")
  return if(i < $h-1 and $t[i+1][j] == "#")
  return if (j < $w-1 and $t[i][j+1] == "#")
  puts "No"
  exit
end
h,w = gets.chomp.split.map &:to_i
$h,$w = h,w
$t = []
h.times do
  $t << gets.chomp.split("")
end
h.times do |i|
  w.times do |j|
    if($t[i][j] == "#")
      jud(i,j)
      del(i,j)
    end
  end
end
puts "Yes"

Measured memory_bytes: 2428
puts gets.to_i.times.map { gets.split.map(&:to_i) }.inject([1, 1]) { |(ma, mb), (a, b)| (a * mb > b * ma) ? [(mb + b - 1) / b * a, (mb + b - 1) / b * b] : [(ma + a - 1) / a * a, (ma + a - 1) / a * b] }.inject(&:+)
# arr = gets.to_i.times.map { gets.split.map(&:to_i) }
# ma = mb = 1
# arr.each do |a, b|
#   if a * mb > b * ma
#     mb = (mb + b - 1) / b * b
#     ma = mb / b * a
#   else
#     ma = (ma + a - 1) / a * a
#     mb = ma / a * b
#   end
#   p [ma, mb]
# end
# puts ma + mb


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
const int N=105;
const int M=1e5+5;

int n,m;
int a[N];
bool dp[M];

int main()
{
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	sort(a+1,a+n+1);
	for(int i=0;i<=m;i++)
	for(int j=1;j<=n;j++)
	{
		if(dp[i]) break;
		if(a[j]>i) break;
		if(dp[i-a[j]]) continue;
		dp[i]=1;
	}
	printf("%s\n",dp[m]?"First":"Second");
	
	return 0;
}

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

signed main() {

  vector<int> x(5);
  for(int i = 0; i < 5; i++){
    cin >> x[i];
    if(x[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;

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

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

class DVariousSushi {
public:
        int N, K;
        vii G;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>N>>K;
        G = vii(N, vi());
        REP(i, N){
            int t, d;
            in>>t>>d;
            t--;
            G[t].pb(d);
        }
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        vector<pll> D;
        priority_queue<pll> pq;
        REP(i, N){
            if(G[i].empty()) continue;
            sort(RALL(G[i]));
            D.eb(pll(G[i][0], i));
            FOR(j, 1, LEN(G[i])) pq.push(pll(G[i][j], i));
        }

        sort(RALL(D));
        map<lint, lint> mp;
        lint ans = 0, sum = 0, cur = 0;
        FOR(i, 0, min(K, LEN(D))){
            sum += D[i].first;
            mp[D[i].second]++;
        }
        lint x = min(K, LEN(D)), cnt = x;
        for(int i=x-1;0<=i;i--){
            while(cnt<K){
                assert(not pq.empty());
                cur += pq.top().first;
                mp[pq.top().second]++;
                pq.pop();
                cnt++;
            }
            lint sz = LEN(mp);
            ans = max(ans, sz*sz+sum+cur);
            cnt--;
            sum -= D[i].first;
            mp[D[i].second]--;
            pq.push(D[i]);
            if(not mp[D[i].second]) mp.erase(D[i].second);
        }
        out<<ans<<'\n';
    }
};


int main() {
	DVariousSushi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10480
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<P> ab(m);
    rep(i,m)
    {
        cin>>ab[i].first>>ab[i].second;
        ab[i].first--;
        ab[i].second--;
    }
    sort(ab.begin(),ab.end());
    P prev=ab[0];
    int ans=1;
    for(int i=1;i<m;i++)
    {
        //cout<<ab[i].first<<" "<<ab[i].second<<endl;
        if(prev.second<=ab[i].first)
        {
            ans++;
            prev=ab[i];
        }
        else
        {
            prev.first=ab[i].first;
            prev.second=min(prev.second,ab[i].second);
        }
        
    }
    cout<<ans;

}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String input = br.readLine();

		for(int i = 0; i < input.length(); i++){

			char token = input.charAt(i);

			if(Character.isUpperCase(token)){
				sb.append(Character.toLowerCase(token));
			}else{
				sb.append(Character.toUpperCase(token));
			}

		}

		System.out.println(sb);

	}
}

Measured memory_bytes: 24084
#include<iostream>
#include<cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int vp[2*300*300+1],vl[300*300+1],answer[100000];
int h,w,d,q,d2;

int inline dist(int i2){
    return abs(vp[i2]-vp[i2-d2]) + abs(vp[i2+1]-vp[i2-d2+1]);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> h >> w >> d;
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            int a;
            cin >> a;
            vp[2*a] = i;
            vp[2*a+1] = j;
        }
    }

    cin >> q;
    d2 = 2*d;
    FOR(i,1,d+1) vl[i] = 0;
    FOR(i,d+1,h*w+1) vl[i] = vl[i-d] + dist(2*i);

    REP(i,q){
        int l,r;
        cin >> l >> r;
        answer[i] = vl[r] - vl[l];
    }
    REP(i,q) cout << answer[i] << "\n";
    return 0;
}


Measured memory_bytes: 2560
import sys

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n=int(input())
al=input().split()
al_i = [int(s) for s in al]

if (n == 2):
   print(max(al_i[0],al_i[1]))
   sys.exit()

fg = [0] * n
bg = [0] * n

for x in range(n):
   if (x == 0):
       fg[0] = al_i[0]
       y = 1
   else:
      while y <= x:
         fg[y] = gcd(fg[y-1], al_i[y])
         y += 1

for x in range(n):
   if (x == 0):
      bg[0] = al_i[n-1]
      y = 1
   else:
      while y <= x:
         bg[y] = gcd(bg[y-1], al_i[n-1-y])
         y += 1

m = 0
gm = 0

for x in range(n):
   if (x == 0):
      g = bg[n-2]
   elif (x == n-1):
      g = fg[n-2]
   else:
      g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)


Measured memory_bytes: 15688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc174_d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadInt();
            var c = CIn.Read();
            var red = 0;
            var ans = 0;
            for (var i = 0; i < N; i++)
            {
                if (c[i] == 'R')
                {
                    red += 1;
                }
            }
            for(var j = red; j < N; j++)
            {
                if(c[j] == 'R')
                {
                    ans += 1;
                }
            }
            Console.WriteLine(ans);
        }   
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 28540
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	int X;
    cin>>X;
    if(X>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int h,w,i,j,t=0;
	for(;;){
		scanf("%d%d",&h,&w);
		if(h<1&&w<1)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf(t==0?"#":".");
				t=~t;
			}
			if(!(w%2))t=~t;
			puts("");
		}
		puts("");
		t=0;
	}
	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
 
int main(){
    int a, b;
    char buf[16];
 
    while(scanf("%d %d", &a, &b) != EOF) {
        sprintf(buf, "%d", a+b);
        printf("%d\n", strlen(buf));
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200) {
    cout << s;
  } else {
    cout << "red";
  }
  cout << '\n';
}


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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int n;
    scanf("%d", &n);
    int ans = 1;
    int m;
    scanf("%d", &m);
    for(int i = 0; i < n-1; i++){
        int p; scanf("%d", &p);
        if(p >= m){
            m = p;
            ans++;
        }
    }
    printf("%d\n", ans);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] h = new int[n];
		int[] hDiff = new int[n];
		int hDiffTotal = 0;
		
		for (int i = 0; i < n; i++) {
			h[i] = stdIn.nextInt();
		}
		
		hDiff[0] = h[0];
		
		for (int i = 1; i < n; i++) {
			hDiff[i] = h[i] - h[i - 1];
			
			if (hDiff[i] < 0) {
				hDiff[i] = 0;
			}
			
		}
		
		for (int i = 0; i < n; i++) {
			hDiffTotal += hDiff[i];
		}
		
		System.out.println(hDiffTotal);
	
	}
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int n,Q, arr[500005];
int fenwick[500005] = {0};
int ans[500005];
int flag[500005];
struct asdf
{
	int l, r, idx;
};

asdf q[500005];

void reset()
{
	UU(i,0,500000)
	{
		flag[i] = -1;
	}
}


bool Compare(asdf a, asdf b)
{
	return a.r < b.r;
}

void update(int idx, int v)
{
	while(idx <= n)
	{
		fenwick[idx] += v;
		idx += (idx & (-idx));
	}
}

int query(int idx)
{
	int total = 0;
	while(idx > 0)
	{
		total += fenwick[idx];
		idx -= (idx & (-idx));
	}
	return total;
}

int main() 
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	cin>>n>>Q;
	
	UP(i,0,n)
	{
		cin>>arr[i];
	}
	
	UP(i,0,Q)
	{
		cin>>q[i].l>>q[i].r;
		q[i].l--;
		q[i].r--;
		q[i].idx = i;
	}
	
	reset();
	
	sort(q, q + Q, Compare);
	
	int cnt = 0; 
	UP(i,0,n)
	{
		if(flag[arr[i]] != -1)
		{
			update(flag[arr[i]] + 1, -1);
		}
		flag[arr[i]] = i;
		
		update(i + 1, 1);
		
		while(cnt < Q && q[cnt].r == i)
		{
			ans[q[cnt].idx] = query(q[cnt].r + 1) - query(q[cnt].l);
			cnt++;
		}
	} 
	
	UP(i,0,Q)
	{
		cout<<ans[i]<<endl;
	}
	
	return 0; 
} 


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	printf("%d\n", (n - 2) * 180);
	return 0;
}

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

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

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//niwango-B

int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
    ll n,ans=0;
    cin>>n;

    vl cost(n-1);
    ll posi,reposi;
    cin>>reposi;
    for(ll i=0;i<n-1;i++){//costを格納
        cin>>posi;
        cost[i]=posi-reposi;
        reposi=posi;
    }
    
    ll left=1;
    for(ll i=1;i<n;i++){
        left=(left*i)%MOD;
    }
    vl mul(n-1);
    mul[0]=left;
    for(ll i=1;i<n-1;i++){
        mul[i]=(mul[i-1]+left*modinv(i+1,MOD))%MOD;
    }
    rep(i,n-1){
        ans=(ans+(cost[i]*mul[i])%MOD)%MOD;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792