akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    cin>>a>>b>>c;
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    int ans=0;
    REP(i,n) {
        auto itr1=lower_bound(ALL(a),b[i]);
        auto itr2=upper_bound(ALL(c),b[i]);
        int x=distance(begin(a),itr1);
        int y=distance(itr2,end(c));
        dump(x,b[i],y);
        ans+=x*y;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

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

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll c[501] = {};
ll s[501] = {};
ll f[501] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n-1) cin >> c[i] >> s[i] >> f[i];

	repe(i, 1, n) {
		ll curT = s[i];
		curT += c[i];
		rep(j, i + 1, n) {
			ll cnt = 0;
			while (s[j] + cnt * f[j] < curT) {
				cnt++;
			}
			curT = s[j] + cnt * f[j];
			curT += c[j];
		}
		cout << curT << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 998244353;
ll INF =1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    if(vec[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    V reg(1e5+1);
    rep(i,n)reg[vec[i]]++;
    ll res=1;
    ll prev=1;
    sort(all(vec));
    rep3(i,1,n){
        if(vec[i-1]!=vec[i]&&vec[i-1]!=vec[i]-1){
            cout<<0<<endl;
            return 0;
        }
        if(vec[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep3(i,1,n+1){
      //  cout<<res<<endl;
        if(reg[i]==0)continue;
        
        rep(j,reg[i]){
            res*=prev;
            res%=MOD;
        }
        prev=reg[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.trim().split('\n');
const n = Number(list[0]);
const A = list[1].trim().split(' ');
const q = Number(list[2]);
const mi = list[3].trim().split(' ');

class KeyMap {
  constructor() {
    this.map = {};
  }
  get(...args) {
    let map = this.map;
    args.forEach(arg => {
      map[arg] = map[arg] || {};
      map = map[arg];
    });
    return map;
  }
}

const dp = new Map();
const keyMap = new KeyMap();
const memo = (i, m) => {
  if (dp.has(keyMap.get(i, m))) {
    return dp.get(keyMap.get(i, m));
  }
  if (i === n || m === 0) {
    const result = m === 0;
    dp.set(keyMap.get(i, m),result);
    return result;
  }

  const nI = i + 1;
  const nM = m - A[i];
  const result = memo(nI, m) || memo(nI, nM);
  dp.set(keyMap.get(i, m),result);
  return result;
}
for (let i = 0; i < q; i++) {
  console.log(memo(0, Number(mi[i])) ? 'yes' : 'no');
}
// console.log(dp);


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

int main(){
  string s,t;int n,ans=0;cin>>n>>s>>t;
  REP(i,n) cout<<s.at(i)<<t.at(i);
}

Measured memory_bytes: 256
import math

def main():
    a, b, h, m = input_list()
    ang = get_angle(h, m)
    coss = math.cos((ang/180)*math.pi)
    ans = math.sqrt(a**2 + b**2 - 2*a*b*coss)
    print(ans)


def get_angle(hour, minute):
    h = (hour * 360) / 12 + (minute * 360) / (12 * 60)
    m = (minute * 360) / 60
    angle = abs(h-m)
    return min(angle, 360-angle)

def has(v, l):
    for vl in l:
        if v == vl:
            return True
    return False

def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62724
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, A, B;
    cin >> K >> A >> B;
    ll ans = 1;
    
    ll C = B - A;
    int cnt = max(0LL, min(K, A - ans));
    ans += cnt;
    K -= cnt;
    if (K % 2 == 1) {ans++; K--;}
    if(C >= 2) ans += C * K / 2;
    else ans += K;
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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 T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    string s,t;
    cin>>n>>s>>t;
    REP(i,0,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int work;
      if(c < a) {
         work = a;
         a = c;
         c = work;
      }
      if(c < b) {
         work = b;
         b = c;
         c = work;
      }
      if(b < a) {
         work = a;
         a = b;
         b = work;
      }
      System.out.println(a + " " + b + " " + c);
   }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	ll t;
	for (int i = 0; i <= 1000; i++) {
		if (i * (i + 1) / 2 == n) {
			cout << "Yes" << endl;
			cout << i + 1 << endl;
			t = i;
			break;
		}

		if (n < i * (i + 1) / 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	vector<vector<int>> a(t + 1, vector<int>(t));
	ll last = 0;
	for (int i = 0; i <= t; i++) {
		if (i == 0) {
			for (int j = 0; j  < t; j++) {
				a[i][j] = j + 1;
			}

			last = a[0][t - 1];
		} else {
			int j = 0;
			while (j < i) {
				a[i][j] = a[j][i - 1];
				j++;
			}

			int offset = 1;
			while (j < t) {
				a[i][j] = last + offset;
				j++;
				offset++;
			}
			last = a[i][t - 1];
		}
	}

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


Measured memory_bytes: 2176
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;


int D,G;
int c[12],p[12];
int dp[12][1111];

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

    cin>>D>>G;
    for(int i=1;i<=D;i++) cin>>p[i]>>c[i];

    memset(dp,-1,sizeof dp);
    dp[0][0] = 0;
    for(int i=1;i<=D;i++){
      for(int j=0;j<=1000;j++){
        if(dp[i-1][j]==-1) break;
        for(int k=0;k<p[i];k++) {
          dp[i][j+k] = max(dp[i][j+k], dp[i-1][j] + k*100*i);
        }
        dp[i][j+p[i]] = max(dp[i][j+p[i]], dp[i-1][j] + p[i]*100*i+c[i]);
      }
    }
    for(int j=0;j<=1000;j++) if(dp[D][j]>=G) {
        cout<<j<<endl;
        break;
      }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (int x = a; x < b; x++)

int
main()
{
  int n;

  cin >> n;

  vector<int> a(n, 0);

  rep(i, 0, n) {cin >> a[i]; a[i]--;};

  int ans = 0;

  rep (i, 0, n) ans += (a[a[i]] == i);

  cout << ans / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int k, t; cin >> k >> t;
    int ma = 0;
    REP(i, 0, t){int a; cin >> a; ma = max(a, ma);}
    cout << max(ma - 1 - (k-ma), 0);
}

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


int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    string str;
    int N;
    int count = 0;
    while(getline(cin, str)){
        stringstream ss;
        ss << str;
        break;

        count++;
    }

    for (int i = 0; i < str.size(); ++i) {
        if (str[i] == 'B' && i) {
            str.erase(i - 1, 2);
            i -= 2;
        }
        else if (str[i] == 'B' && i == 0) {
            str.erase(i, 1);
            i--;
        }
    }



    cout << str << endl;
    return 0;
}

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

int main() {
    string N;
    int K,l;
    cin >> N >> K;
    l = N.size();

    dp[0][0][1] = 1;
    rep(i,l) {
        int d=N.at(i)-'0';
        rep(j,2)
            rep(k,K+2)
                rep(m,(j?9:d)+1)
                    dp[i+1][j||m<d][k+(m!=0)] += dp[i][j][k];
    }

    cout << dp[l][0][K+1]+dp[l][1][K+1] << endl;
}

Measured memory_bytes: 256
from math import sqrt
from math import floor
n,p = map(int,input().split())
l = [p]
for i in range(2,floor(sqrt(p))+1):
    if p % i == 0:
        l.append(i)
        l.append(p//i)
l.sort()
s = [1]
i = 0
while p > 1:
    if p % l[i] == 0:
        s.append(l[i])
        p = p // l[i]
    else:
        i += 1
ans = 1
x = s[0]
y = 1
for i in s[1:]:
    if x == i:
        y += 1
    else:
        while y >= n:
            ans *= x
            y -= n
        x = i
        y = 1
while y >= n:
    ans *= x
    y -= n
print(ans)

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b;a <= c; ++a)
#define pb push_back
#define int long long

const int N = 2005;
const int mod = 1e9 + 7;
const int oo = 1e15;

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

int n, k, q, ans;
int a[N], b[N];
bool visit[N];
priority_queue<int, vector<int>, greater<int> > pq;


int solve() {
    while(!pq.empty()) pq.pop();
    int cur = -oo;
    int l = 1, r = l;
    while(l <= n)   {
        while(visit[l]) l ++;
        r = l;
        while(r < n && visit[r + 1] == false) r ++;

        if(r >= l && r - l + 1 >= k && r <= n) {
            vector<int> tmp;
            FOR(i, l, r) tmp.pb(a[i]);
            sort(tmp.begin(), tmp.end());
            for(int i = 0; i < (r - l + 1 - k + 1); ++i) pq.push(tmp[i]);
        }
        l = r + 1;
    }
    FOR(i, 1, q)    {
        if(pq.empty()) return oo;
        cur = max(cur, pq.top());
        pq.pop();
    }
    return cur;
}

signed main()
{
    //freopen("test.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> q;
    FOR(i, 1, n) {
        cin >> a[i];
    }

    //cout << solve() << '\n';
    //return 0;
    // done
    ans = oo;
    FOR(i, 1, n)    {
        memset(visit, false, sizeof visit);
        FOR(j, 1, n) if(a[j] < a[i]) visit[j] = true;
        int cur = solve();
        //cout << a[i] << ' ' << cur << '\n';
        ans = min(ans, cur - a[i]);
    }
    cout << ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e6+5;
ll inf=1e15;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    
    while(t--)
    {
        
        int n,k;
        cin>>n;
        ll ar[n+1][3];
        for(int i=1;i<=n;i++)
            cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
        ll dp[n+1][3];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<3;j++)
                dp[i][j]=0;
        }
            
        // dp[0]=0;
        for(int i=1;i<=n;i++)
        {
            for(int lst=0;lst<3;lst++)
            {
                if(lst==0)
                dp[i][lst]=max(dp[i][lst],max(dp[i-1][1]+ar[i][0],dp[i-1][2]+ar[i][0]));
                if(lst==1)
                dp[i][lst]=max(dp[i][lst],max(dp[i-1][0]+ar[i][1],dp[i-1][2]+ar[i][1]));
                if(lst==2)
                dp[i][lst]=max(dp[i][lst],max(dp[i-1][0]+ar[i][2],dp[i-1][1]+ar[i][2]));
            }
        }

        cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    }

    return 0;
}

Measured memory_bytes: 8272
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 3e5+10;
const int base = 31337;
const llint mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
llint niz[maxn];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
		scanf("%lld", niz+i);
		
	llint sol = 0;
	for (int i = 0; i < 61; i++) {
		llint a = 0, b = 0;
		for (int j = 0; j < n; j++) {
			if (niz[j] & (1LL << i)) a++;
			else b++;
		}
		//printf("debug %d -> %lld %lld\n", i, a, b);
		llint tren = a * b;
		tren %= mod;
		tren *= (1LL << i) % mod; tren %= mod;
		sol += tren;
		sol %= mod;
	}
	printf("%lld", sol);
	return 0;
}



Measured memory_bytes: 6132
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x[30]={},a;
	for(int i=0;i<28;i++){
		cin>>a;
		x[a-1]=1;
	}
	for(int i=0;i<30;i++){
		if(x[i]==0)
		cout<<i+1<<endl;
	}
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string s;
int main(){
    cin >> s;
    s[5] = s[13] = ' ';
    pr(s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define pb push_back
#define F first
#define S second
#define ll long long 
#define ld long double 

#define int long long int

const int mod = 1e9+7;
const ll inf = 1e18; 
 
int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n, int r){ int C[r+1]; memset(C, 0, sizeof(C)); C[0] = 1; for(int i = 1; i <= n; i++) {int t=i;if(r<t)t=r; for (int j = t; j > 0; j--) C[j] = C[j] + C[j-1]; }return C[r];} 
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}

int min(int a , int b){return a < b ? a : b;}
int max(int a , int b){return a > b ? a : b;}

using namespace std;
int a[405];
int dp[405][405] = {} , cost[405][405];

pair<int , int> solve(int l , int r){
	//cout << l << " " << r << endl;
	if(l == r){
		dp[l][r] = a[l];
		cost[l][r] = 0;
		return {dp[l][r] , 0};
	}
	
	if(dp[l][r])
		return {dp[l][r] , cost[l][r]};
	
	int ans = LLONG_MAX;

	for(int i = l ; i < r ; i++){
		int no1 = solve(l , i).F;
		int no2 = solve(i+1 , r).F;
		
		int past_cost = solve(l , i).S + solve(i+1 , r).S;
		
		if(no1 + no2 + past_cost < ans){
			ans = no1 + no2 + past_cost;
			dp[l][r] = no1 + no2;
			cost[l][r] = ans;
		}
	}
	
	return {dp[l][r] , cost[l][r]};
}

signed main(){

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

	int n;
	cin >> n;
	
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	
	cout << solve(0 , n-1).S;
}










Measured memory_bytes: 6144
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(void){
    int i = 0,h,n,sum = 0,a;
 
    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum += a;
    }
 
    if(sum >= h) printf("Yes\n");
    else printf("No\n");
  
  return 0;
}

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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  int ans =0;
  for(int j=0;j<N;j++){
    int point =0;
    for(int k=0;k<M;k++){
      cin >> A.at(k);
      point+=A.at(k)*B.at(k);
    }
    if(point+C>0){
      ans++;
    }
  }
  
  cout << ans << endl;
  

}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if((a + b) % 2 == 0)cout << (a + b) / 2;
    else cout << "IMPOSSIBLE";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	//	freopen("_input.txt", "r", stdin);
	//	freopen("_output.txt", "w", stdout);
	#endif
		int n;
		cin >> n;
		int a[n];
		int b[n];
		int c[n-1];
		forn(i, n) cin >> a[i];
		forn(i, n) cin >> b[i];
		forn(i, n-1) cin >> c[i];
		int last = -10;
		ll ans = 0;
		forn(i, n)
		{
			ans += b[a[i]-1];
			if (a[i] == last+1 and a[i] != 1) ans+= c[a[i]-2];
			last = a[i];
		}
		cout << ans;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N+1];
  int b[N+1];
  int count = 0;
  for(int i = 1;i <= N;i++){
    cin >> a[i];
    b[i]= 0;
  }
  for(int i = N; i > (N/2); i--){
    if(a[i] == 1){
      b[i] = 1;
    }
  }
  for(int i = (N/2); i > 0; i--){
    int multi = 2;
    int total = 0;
    while(i*multi <= N){
      total+= b[i*multi];
      multi++;
    }
    if(a[i] == (total%2)){
      b[i] = 0;
    }
    else{
      b[i]++;
      if(b[i] >= 2){
        cout << -1 << endl;
        return 0;
      }
    }
  }

  for(int i =1;i <= N;i++){
    if(b[i]==1) count++;
  }
  cout << count << endl;
  for(int i=1;i <= N;i++){
    if(b[i]==1) cout << i << " ";
  }
  cout << endl;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
  cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int Xiaobo()
{
	string s;
	cin>>s;
	//s=" "+s;
	reverse(s.begin(),s.end());
	ll res=0;
	int jw=0;
	s+='0';
	for(int i=0;i<(int)s.size();i++) {
		int k=s[i]-'0';
		res+=min(k,10-k);
		if(k>5) s[i+1]++;
		else if(k==5&&s[i+1]>='5') s[i+1]++;
	}
	cout<<res<<'\n';
	return 0;
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  char c;
  set<char> s;

  cin >> c; s.insert(c);
  cin >> c; s.insert(c);
  cin >> c; s.insert(c);

  if (s.size() == 2)  cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  char A, B;
  cin >> A >> B;
  int a = A - 'A', b = B - 'A';
  if (a == b)cout << '=' << endl;
  else if (a > b)cout << '>' << endl;
  else cout << '<' << endl;
  return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;

  vector<tuple<string, int, int>> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> get<0>(p[i]) >> get<1>(p[i]);
    get<2>(p[i]) = i + 1;
  }
  sort(begin(p), end(p), [](const auto &x, const auto &y) {
    return get<0>(x) == get<0>(y) ? get<1>(x) > get<1>(y)
                                  : get<0>(x) < get<0>(y);
  });

  for (int i = 0; i < n; ++i) {
    cout << get<2>(p[i]) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3560
import Control.Monad
import Data.List

toI :: String -> Int
toI s = let nums = dropWhile (== '0') s in
    if null nums then 0
                 else read s
d :: String -> Int
d s = (toI . sortBy (flip compare)) s - (toI . sort) s

main = do
    n <- readLn
    replicateM_ n $ getLine >>= print . d

Measured memory_bytes: 3568
#include <stdio.h>

int max(int a,int b){
  if (a>b)
    return a;
  else
    return b;
}

int main(){
  int i,n,x,maxsofar,maxend;

  while (scanf("%d",&n)){
    int min=-100001;
    if (n==0)
      break;
    maxsofar=0;
    maxend=0;
    for (i=0;i<n;i++){
      scanf("%d",&x);
      if ((x>min))
        min=x;
      maxend=max(maxend+x,0);
      maxsofar=max(maxsofar,maxend);
    }
    if (min<0)
      printf("%d\n",min);
    else
      printf("%d\n",maxsofar);
  }
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=1,a;
  char S[110]={0};
  scanf("%s",S);
  a=strlen(S);
  rep(i,(a-1)/2){
    if(S[i]!=S[(a-1)/2-i-1])ans=0;
    if(S[a-1-i]!=S[(a-1)/2+1+i])ans=0;
  }
  rep(i,a){
    if(S[i]!=S[a-1-i])ans=0;
  }
  YN(ans);

  //printf("%lld\n",ans);
	return 0;
}


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

int main() {
	int k, ans = 0;
	cin>>k;
	for(int i=1;i<=k;i++) {
		for(int j=1;j<=k;j++) {
			for(int l=1;l<=k;l++) {
				ans = ans + __gcd(__gcd(i, j), l);
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
/*
int actioncnt;
string removestring(string s,string target){
  actioncnt=0;
  if(s.size()<target.size()) return s;
  for(int i=0;i<=s.size()-target.size();i++){
    if(i>s.size()-target.size()) break;
    if(s.substr(i,target.size())==target){
      if(s.size()==target.size()){
        return "";
      }
      s.erase(i,target.size());
      actioncnt++;
    }
  }
  return s;
  while(1){
    s=removestring(s,"ST");
    if(s=="") break;
    if(actioncnt==0) break;
  }
}
*/
signed main(){
  string s;
  cin>>s;
  int scnt=0,ans=s.size();
  lp(i,s.size()){
    if(s[i]=='S'){
      scnt++;
    }
    else{
      if(scnt>0){
        ans-=2;
        scnt--;
      }
      else{
        scnt=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    cout<<N*M<<endl;
}





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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

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

    long long a[n];

    rep(i,n){
        cin>>a[i];
    }
    long long now=0;
    for(int i=1;i<n-1;i+=2){
        now^=(a[i]^a[i+1]);
    }
    long long A[n];
    A[0]=now^a[n-1];
    //cout<<A[0]<<endl;

    rep2(i,n-1){
        A[i]=A[i-1]^(a[i]^a[i-1]);
    }
    rep(i,n){
        cout<<A[i]<<" ";
    }
    cout<<endl;
    return 0;

}
/*


*/


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

class Program {
    static void Main (string[] args) {
        string[] nm = Console.ReadLine().Split(' ');
        int a = int.Parse(nm[0]);
        int b = int.Parse(nm[1]);

        int c = b /a;
        int ans = 0;

        for(int i=c;i <= 20;i++ ){
            if((i*a)-(i-1) >= b){
                ans = i;
                break;
            }
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A[3];
    cin >> A[0] >> A[1] >> A[2];
    if(A[0]%2 == 0 || A[1]%2 == 0 || A[2]%2 == 0){
    	cout << 0 << endl;
    	return 0;
    }
    sort(A, A+3);
    cout << A[0]*A[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int l=0,x[h*w];
    for(int i=0;i<n;i++)
    {
        while(a[i]>0)
        {
            if((l/w)%2==0)x[l]=i+1;
            else x[l-l%w+w-l%w-1]=i+1;
            a[i]--;
            l++;
        }
    }
    l=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w-1;j++)
        {
            cout<<x[l]<<" ";
            l++;
        }
        cout<<x[l]<<endl;
        l++;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,s;
	while(cin>>n>>m>>s,n){
		int ans=0;
		for(int i=1;i<2001;i++){
			for(int j=1;j<2001;j++){
				int p1=i*(n+100)/100;
				int p2=j*(n+100)/100;
				if(p1+p2==s){
					int p1=i*(m+100)/100;
					int p2=j*(m+100)/100+p1;
					ans=max(ans,p2);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1220
#include <vector>
#include <stack>
#include <map>
#include <iostream>
#include <sstream>

using namespace std;
struct elem{
    bool isPossible[256];
    elem(){
        fill(isPossible,isPossible+256,false);
    }
    elem(int lb,int ub){
        fill(isPossible,isPossible+256,false);
        for(int i=lb;i<=ub;i++)isPossible[i]=true;
    }
};

int main(){
    int m;
    cin>>m;
    map<string,elem> M;
    for(int i=0;i<m;i++){
        string name;
        int lb,ub;
        cin>>name>>lb>>ub;
        M[name]=elem(lb,ub);
    }
    int n;
    cin>>n;
    stack<elem, vector<elem>> S;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        stringstream ss(str);
        if('0'<=str[0]&&str[0]<='9'){
            int val;
            ss>>val;
            S.emplace(val,val);
            continue;
        }
        if(str[0]=='+'){
            elem B=S.top();S.pop();
            elem A=S.top();S.pop();
            elem C;
            for(int a=0;a<256;a++){
                if(A.isPossible[a]==false) continue;
                for(int b=0;b<256;b++){
                    if(B.isPossible[b])C.isPossible[(a+b)&0b11111111]=true;
                }
            }
            S.push(C);
            continue;
        }
        if(str[0]=='-'){
            elem B=S.top();S.pop();
            elem A=S.top();S.pop();
            elem C;
            for(int a=0;a<256;a++){
                if(A.isPossible[a]==false) continue;
                for(int b=0;b<256;b++){
                    if(B.isPossible[b])C.isPossible[(a-b)&0b11111111]=true;
                }
            }
            S.push(C);
            continue;
        }
        if(str[0]=='*'){
            elem B=S.top();S.pop();
            elem A=S.top();S.pop();
            elem C;
            for(int a=0;a<256;a++){
                if(A.isPossible[a]==false) continue;
                for(int b=0;b<256;b++){
                    if(B.isPossible[b])C.isPossible[(a*b)&0b11111111]=true;
                }
            }
            S.push(C);
            continue;
        }
        if(str[0]=='/'){
            elem B=S.top();S.pop();
            elem A=S.top();S.pop();
            if(B.isPossible[0]){
                cout<<"error"<<endl;
                return 0;
            }
            elem C;
            for(int a=0;a<256;a++){
                if(A.isPossible[a]==false) continue;
                for(int b=1;b<256;b++){
                    if(B.isPossible[b])C.isPossible[a/b]=true;
                }
            }
            S.push(C);
            continue;
        }
        S.push(M[str]);
    }
    cout<<"correct"<<endl;
    return 0;
}

Measured memory_bytes: 3240
N, M = map(int, input().split())
lists = list(map(int, input().split()))
# print(lists)
sigma_A = sum(lists)
val = 1/(4 * M) * sigma_A

count = 0
for i in range(M):
    if max(lists) >= val:
        count += 1
        lists.remove(max(lists))
# print(lists)

if count == M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <stdio.h>

int main (void)
{
  int n = 0;
  long res = 0;

  scanf("%d", &n);

  for(int i = 1; i <= n; i++){
    if (i % 3 != 0 && i % 5 != 0){
      res += i;
    }
  }

  printf("%ld\n", res);

  return 0;
}

Measured memory_bytes: 1732
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;sc.hasNext();){
			String s = sc.next();
			String t = sc.next();
			SuffixArray sa = new SuffixArray(s);
			int left=-1,right=t.length()+1;
			while(left<right-1){
				int len= (left+right)/2;
				boolean f = false;
				for(int i=0;i<t.length();i++){
					if(i+len>t.length())break;
					String sub = t.substring(i,i+len);
					if(sa.contain(sub)){
						f=true;
						break;
					}
				}
				if(f){
					left=len;
				}
				else{
					right=len;
				}
					
			}
			System.out.println(left);			
		}

	}

	static class SuffixArray {
		int n,k=1;
		Integer[] sa,rank,tmp;
		String s;

		SuffixArray(String _s) {
			s=_s;
			n = s.length();
			String[] S = new String[n+1];
			S[n]="";
			for(int i=n-1;i>=0;i--){
				S[i] = s.charAt(i)+S[i+1];
			}
			rank=new Integer[n+1];
			sa=new Integer[n+1];
			tmp=new Integer[n+1];
			for(int i=0;i<n;i++){
				sa[i]=i;
				rank[i]=(int) s.charAt(i);
			}
			sa[n]=n;
			rank[n]=-1;

			for(k=1;k<=n;k<<=1){
				Arrays.sort(sa,new Comparator<Integer>(){
					@Override
					public int compare(Integer o1, Integer o2) {
						int r1=rank[o1];
						int r2=rank[o2];
						if(r1!=r2)return (r1-r2);
						int r11=o1+k <= n ? rank[o1+k] : -1;
						int r22=o2+k <= n ? rank[o2+k] : -1;
						return (r11-r22);
					}
				});
				tmp[sa[0]]=0;
				for(int i=1;i<=n;i++){
					tmp[sa[i]]=tmp[sa[i-1]]+ (compare(sa[i-1],sa[i])!=0?1:0);
				}
				for(int i=0;i<=n;i++){
					rank[i]=tmp[i];
				}
			}
		}
		boolean contain(String t){
			return contain(s,sa,t);
		} 
		private boolean contain(String s,Integer[] sa,String t){
			int a=0,b=s.length();
			while(b-a>1){
				int c = (a+b)/2;
				int com = compare(s,sa[c], Math.min(sa[c]+t.length(), s.length()),t);
				if(com<0){
					a=c;
				}
				else{
					b=c;
				}
			}
			return compare(s,sa[b], Math.min(sa[b]+t.length(), s.length()),t)==0;
		}
		/*
		 * s.substring(i1,i2).compare(t)と同じ。メモリ節約
		 */
		private int compare(String s,int i1,int i2,String t){
			if(true)
			return s.substring(i1,i2).compareTo(t);
					
			for(int i=i1;i<i2;i++){
				if(i-i1>=t.length()){
					return 1;
				}
				if(s.charAt(i)!=t.charAt(i-i1)){
					return s.charAt(i)-t.charAt(i-i1);
				}
			}
			return (i2-i1)-t.length();
		}

		/*
		 * s.substring(i1,i2).compare(t.substring(j1,j2)と同じ。メモリ節約
		 */
		private int compare(String s,int i1,int i2,String t,int j1,int j2){
			int slen=i2-i1;
			int tlen=j2-j1;
			for(int i=0;i<slen;i++){
				if(i>=tlen){
					return 1;
				}
				if(s.charAt(i+i1)!=t.charAt(i+j1)){
					return s.charAt(i+i1)-t.charAt(i+j1);
				}
			}
			return slen-tlen;
		}

		private int compare(Integer o1, Integer o2) {
			int r1=rank[o1];
			int r2=rank[o2];
			if(r1!=r2)return (r1-r2);
			int r11=o1+k <= n ? rank[o1+k] : -1;
			int r22=o2+k <= n ? rank[o2+k] : -1;

			return (r11-r22);
		}

	}

}

Measured memory_bytes: 198668
n = int(input())
c = list(input())

c_sort = sorted(c)

# print(c_sort)

r = 0
w = 0

for cc, ss in zip(c,c_sort):
    if cc == 'W' and ss == 'R':
        r += 1
    elif cc == 'R' and ss == 'W':
        w += 1
    else:
        continue

print(max(r,w))

Measured memory_bytes: 12744
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl

int main() {
  int n;
  cin >> n;
  vector<int> v(n+2);
  v[0] = 0;
  REP(i, n) {
    cin >> v[i+1];
  }
  v[n+1] = 0;
  int all = 0;
  REP(i, n+1) {
    all += abs(v[i]-v[i+1]);
  }
  int x;
  REP(i, n) {
    x = all-abs(v[i]-v[i+1])-abs(v[i+1]-v[i+2])+abs(v[i]-v[i+2]);
    dump(x);
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 100002;
string s,t,ans;
ll n;

int main(){
	cin>>n>>s>>t;
	if(s==t){
		cout<<n<<endl;
		return 0;
	}
	ans=s+t;
	FOR(i,1,n){
		string w;
		w = s.substr(n-i,i);
		w += t.substr(i,n-i);
		if(w==t){
			ans=s+t.substr(i,n-i);
		}
	}
	cout<<ans.size()<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int max_ws=0;
    int max_s=0;
    for(int ai=0; a*ai*100<=f; ++ai){
        for(int bi=0; b*bi*100<=f; ++bi){
            int w=100*(a*ai+b*bi);
            if(w==0) break;
            for(int ci=0; c*ci+w<=f; ++ci){
                for(int di=0; d*di+w<=f; ++di){
                    int s=c*ci+d*di;
                    int ws=w+s;
                    if(ws>f) break;
                    if(100*s>e*w) break;
                    if((max_ws==0 && max_s==0) || (max_s*ws < max_ws*s)){
                        max_ws=ws;
                        max_s=s;
                    }
                }
            }
        }
    }
    cout << max_ws << " " << max_s << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = input()
t = input()
min_count = 1000
for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            count += 1
    min_count = min(count, min_count)
    if min_count == 0:
        break
print(min_count)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int w, h, n;
int x[300005], y[300005];
pii p[300005];
ll ans = 0;

ll st[1200010], lazy[1200010];
void push(int n, int s, int e, ll val){
    st[n] += val;
    if(s != e){
        lazy[n+n] += val;
        lazy[n+n+1] += val;
    }
    lazy[n] = 0;
}
void update(int n, int s, int e, int l, int r, ll v){
    push(n, s, e, lazy[n]);
    if(s > r || l > e) return;
    if(l <= s && e <= r){
        push(n, s, e, v);
        return;
    }
    int mid = (s+e)/2;
    update(n+n, s, mid, l, r, v);
    update(n+n+1, mid+1, e, l, r, v);
    st[n] = max(st[n+n], st[n+n+1]);
}
ll query(int n, int s, int e, int l, int r){
    push(n, s, e, lazy[n]);
    if(s > r || l > e) return 0;
    if(l <= s && e <= r) return st[n];
    int mid = (s+e)/2;
    return max(query(n+n, s, mid, l, r), query(n+n+1, mid+1, e, l, r));
}

void solve(){
    for(int i=1;i<=4*n;i++){
        st[i] = h;
        lazy[i] = 0;
    }

    stack<pii> st1, st2;
    st1.push(mp(0, 0)), st2.push(mp(0, h));
    for(int i=1;i<=n;i++){
        update(1, 0, n, 0, i-1, p[i].fi-p[i-1].fi);
        if(i-1 >= 1) ans = max(ans, query(1, 0, n, 0, i-1));

        if(p[i].se <= h/2){
            int r = i;
            while(!st1.empty() && st1.top().se <= p[i].se){
                int l = st1.top().fi;
                update(1, 0, n, l, r-1, -(p[i].se-st1.top().se));
                r = l;
                st1.pop();
            }
            st1.push(mp(r, p[i].se));
            st1.push(mp(i, 0));
        }
        else{
            int r = i;
            while(!st2.empty() && st2.top().se >= p[i].se){
                int l = st2.top().fi;
                update(1, 0, n, l, r-1, -(st2.top().se-p[i].se));
                r = l;
                st2.pop();
            }
            st2.push(mp(r, p[i].se));
            st2.push(mp(i, h));
        }
    }
}

int main(){
    scanf("%d%d%d", &w, &h, &n);   
    for(int i=1;i<=n;i++){
        scanf("%d%d", &x[i], &y[i]);
        p[i] = mp(x[i], y[i]);
    }
    p[0] = mp(0, 0);
    p[++n] = mp(w, h);
    sort(p+1, p+1+n);
    solve();

    for(int i=1;i<=n;i++) swap(p[i].fi, p[i].se);
    swap(w, h);
    sort(p+1, p+1+n);
    solve();
    printf("%lld\n", ans*2);
}

Measured memory_bytes: 28436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int64_t a,b;
    cin >> a >> b;
    int64_t ans = a/__gcd(a,b)*b;
    cout << ans << endl;
}

Measured memory_bytes: 256
def GCD(a, b):
    if a == 0 and b == 0:
        return 0
    elif a == 0:
        return b
    elif b == 0:
        return a

    while a % b != 0:
        r = a % b
        a, b = b, r
    return b

ans = 0
N = int(input())
A = tuple(map(int,input().split()))

X = [0]*N
Y = [0]*N

for i in range(1,N):
    X[i] = GCD(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i] = GCD(Y[i+1],A[i+1])

for i in range(N):
    ans = max(ans,GCD(X[i],Y[i]))

print(ans)


Measured memory_bytes: 14180
#include <iostream>
#define MAX 1000000
#define INF 1000000000
using namespace std;

int dp1[MAX+1],dp2[MAX+1];

int main(){
    //INFで初期化
    for(int i = 1;i <= MAX;i++){
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n + 2) /6 <= MAX;n++){
        int a = n * (n + 1) * (n + 2) / 6;  //ポロック数の生成
        for(int i = a;i <= MAX;i++){     //正四面体数の個数dp(a以下は必要ない)
            dp1[i] = min(dp1[i],dp1[i-a] + 1);  //更新しないor左側から更新する
        }
        if(a % 2 == 0)continue;     //偶数の時は次のroopへ
        for(int i = a;i <= MAX;i++){     //奇数の正四面体数の個数dp(a以下は必要ない)
            dp2[i] = min(dp2[i],dp2[i-a] + 1);  //更新しないor左側から更新する
        }
    }

    //入出力
    while(true){
        int n;
        cin >> n;
        if(n == 0)break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 10912
eval"N,*A="+`dd`.split*?,
b=A[N,N].reverse
puts N.times{|i|$*[v=A[i]]||=i;v!=b[i]||(N=v;$r=i)}<A.count(N)?:No:[:Yes,$r?(t=[N])*(k=[$*[N],b[..$r].count(N)].min)+(b-t)+t*=b.count(N)-k:b]

Measured memory_bytes: 89420