akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
int a[100000];
vector <int> t[100000];
int di[100000];
priority_queue <P> que;
void res(int now, int dist){
    if(di[now] != -1)return;
    di[now] = dist; que.push(P(dist, now));
    for(int i = 0;i < t[now].size();i++)res(t[now][i], dist+1);
    return;
}
void cl(int now){
    if(di[now] == 0)return;
    di[now] = 0;
    for(int i = 0;i < t[now].size();i++)cl(t[now][i]);
}
int main(void){
    int n, k; cin >> n >> k; ll ans = 0;
    for(int i = 0;i < n;i++){
        int aa; cin >> aa; aa--; t[aa].push_back(i);
        a[i] = aa;
    }
    fill(di, di+n, -1);
    res(0, 0);
    //for(int i = 0;i < n;i++)cout << di[i] << endl;
    if(k == 1){
        for(int i = 0;i < n;i++)if(a[i] != 0)ans++;
        cout << ans << endl;
        return 0;
    }
    if(a[0] != 0)ans++;
    while(!que.empty()){
        P p = que.top(); que.pop();
        //cout << p.first << " " << p.second << " " <<  ans << endl;
        if(di[p.second] > k){
            ans++;
            int w = p.second;
            for(int i = 0;i < k-1;i++)w = a[w];
            cl(w);
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14448
n = int(input())
w = [w for w in map(int, input().split())]

ans = 1000000000
for i in range(n):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    min_ = abs(s1 - s2)
    if min_ < ans:
        ans = min_
        
print(ans)

Measured memory_bytes: 3060
// Author: πα

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

int main()
{
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    long ans = b-a;
    ans -= (b/c - a/c);
    ans -= (b/d - a/d);
    c = c*d/__gcd(c, d);
    ans += (b/c - a/c);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define N 110
int n;
char a[N],b[N],c[N];
int main()
{
	/*freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);*/
	n=read();
	scanf("%s",a+1);scanf("%s",b+1);scanf("%s",c+1);
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==b[i]&&b[i]==c[i]) ;
		else if (a[i]==b[i]||a[i]==c[i]||b[i]==c[i]) ans++;
		else ans+=2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = [int(x) for x in input().split()]

if (a+b) < c * 2:
    ans = (a * x) + (b * y)
else:
    tmp1 = c * 2 * max(x,y)
    tmp2 = c * 2 * min(x,y)
    if x > y:
        tmp2 += (x - y) * a
    else:
        tmp2 += (y - x) * b
    ans = min(tmp1,tmp2)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int s,m = 0,h = 0;
  scanf("%d",&s);
  while(s>=3600) {
    s -= 3600;
    h++;
  }
  while(s>=60) {
    s -= 60;
    m++;
  }
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}



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

using namespace std;

int main() {
    stack<int> si;
    char s[110];
    while (scanf("%s", s) != EOF) {
        int a, b;
        if (s[0] >= '0' && s[0] <= '9') {
            si.push(atoi(s));
        } else {
            b = si.top(); si.pop();
            a = si.top(); si.pop();

            int p;
            switch (s[0]) {
                case '+': p = a + b; break;
                case '-': p = a - b; break;
                case '*': p = a * b; break;
            }
            si.push(p);
        }
    }

    printf("%d\n", si.top());
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    bool flag = true;
    int i=0, j=s.size()-1;
    while(i<j && s[i]==s[j]){
        i++; j--;
    }
    if(i != j){
        flag = false;
    }
    i=0, j=((s.size()-3)/2);
    while(i<j && s[i]==s[j]){
        i++; j--;
    }
    if( i< j){
        flag = false;
    }
    i=((s.size()+1)/2), j=s.size()-1;
    while(i<j && s[i]==s[j]){
        i++; j--;
    }
    if( i< j){
        flag = false;
    }
    if(flag){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define fi first
#define sc second
#define mp make_pair
pair<int,int> dp[105][50005];
int n,p[105];
void chh(pair<int,int> &a,pair<int,int> &b){
	if(a.fi < b.fi) a = b;
	else if(a.fi == b.fi) a.sc = min(a.sc,b.sc);
}
int main(){
	while(1){
		cin>>n; if(!n) return 0;
		for(int i=1;i<=n;i++) cin>>p[i];
		for(int i=0;i<105;i++) for(int j=0;j<50005;j++) dp[i][j] = mp(-10000,100000000);
		dp[0][0] = mp(0,0);
		for(int i=0;i<n;i++){
			for(int j=0;j<50005;j++){
				if(dp[i][j].fi < 0) continue; //cout <<i << " " <<j<< endl;
				if(dp[i+1][j].fi < dp[i][j].fi) dp[i+1][j] = dp[i][j];
				else if(dp[i+1][j].fi == dp[i][j].fi) dp[i+1][j].sc = min(dp[i+1][j].sc,dp[i][j].sc);
				
				if(p[i+1]%1000 == 0){
					if(j>=500){
						pair<int,int> Q=mp(dp[i][j].fi+1,dp[i][j].sc+p[i+1]) ;
						chh(dp[i+1][j-500],Q);
					}
				}
				else if(p[i+1]%1000 <= 500){
					pair<int,int> Q=mp(dp[i][j].fi+1,dp[i][j].sc+p[i+1]) ;
					chh(dp[i+1][j+500-(p[i+1]%1000)],Q);
				}
				else{
					if(j+500-(p[i+1]%1000)>=0){
						pair<int,int> Q=mp(dp[i][j].fi+1,dp[i][j].sc+p[i+1]) ;
						chh(dp[i+1][j+500-(p[i+1]%1000)],Q);
					}
					pair<int,int> Q=mp(dp[i][j].fi,dp[i][j].sc+p[i+1]) ;
					chh(dp[i+1][j+1000-(p[i+1]%1000)],Q);
				}
			}
		}
		pair<int,int> ans = mp(-10000,100000000);
		for(int i=0;i<=n;i++){
		for(int j=0;j<50005;j++){
			if(ans.fi < dp[i][j].fi) ans = dp[i][j];
			else if(ans.fi == dp[i][j].fi) ans.sc = min(ans.sc,dp[i][j].sc);
		}}
		cout <<ans.fi<<" " << ans.sc << endl;
	}
}

Measured memory_bytes: 44088
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define INF 1e18
#define PI 3.1415926535
using namespace std;

const int mod = mod1;

int power(int a, int n, int p = mod) {
    if (n < 0)
        return 0;
    int ans = 1;
    while (n) {
        if (n & 1)
            ans = (ans * a) % p;
        a = (a * a) % p;
        n >>= 1;
    }
    return ans;
}

int inverse(int x, int p = mod) {
    return power(x, p - 2);
}

void pre(void) {
    //
}
const int maxN = 1e5;
vector<int> adj[maxN];
int visited[maxN];

void dfs(int node) {
    visited[node] = 1;
    for (int i : adj[node]) {
        if (!visited[i]) {
            dfs(i);
        }
    }
}

void solve(void) {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int cc = -1;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            dfs(i);
            cc++;
        }
    }
    cout << cc << '\n';
}

int32_t main(void) {
#ifdef AKSHIT_PC
    cout.setf(ios::unitbuf);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    fastio;
    pre();
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 11124
program prob1
    implicit none
    character :: s
    read(*,*) s
    if(s == 'A') then
        write(*,*) 'T'
    else if(s == 'T') then
        write(*,*) 'A'
    else if(s == 'G') then
        write(*,*) 'C'
    else if(s == 'C') then
        write(*,*) 'G'
    end if
    stop
contains
end program prob1

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

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

	max = a + b;
	if (max < a*b) max = a * b;
	if (max < a - b) max = a - b;

	cout << max << endl;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, c[nax], s[nax], f[nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n - 1; i ++) cin >> c[i] >> s[i] >> f[i];
    int tim = 0;
    for(int idx = 1; idx <= n - 1; idx++)
    {
        tim = 0;
        int cur = idx;
        while(cur < n)
        {
            if(tim < s[cur]) tim = s[cur];
            else
            {
                int val = (tim - s[cur] + f[cur] - 1) / f[cur];
                tim = s[cur] + val * f[cur];
            }
            tim += c[cur];
            cur++;
        }
        cout << tim << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    ll dp[3001][3001][2];
    ll arr[3000];
    ll a=0;
    ll b=0;
    ll solve(int s, int e, int a)
    {
        if(s>e)
        {
            return 0;
        }
        else if(dp[s][e][a]!=-1)
        {
            return dp[s][e][a];
        }
        else
        {
            ll b=0;
            b+=max(arr[s]-solve(s+1,e,!a),arr[e]-solve(s,e-1,!a));
            dp[s][e][a]=b;
            return dp[s][e][a];
        }
    }
    int main() {
    int n;
    cin>>n;

    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            for(int k=0;k<2;k++)
            {
                dp[i][j][k]=-1;
            }
        }
    }
    ll ans=solve(0,n-1,1);/*
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<dp[i][j][0]<<' ';
        }
        cout<<'\n';
    }
    cout<<'\n';
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<dp[i][j][1]<<' ';
        }
        cout<<'\n';
    }*/
    cout<<ans<<'\n';
    return 0;
    }


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define M                 1000000007
#define MM                998244353
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define mem0(x)           memset(x, 0, sizeof (x))
#define mem1(x)           memset(x, -1, sizeof (x))
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

//coded by Avijit Mandal 

int main(){
   IOS;
   ll t,i,j,k,n;
   ll w;
   cin>>n>>w;
   vector <pair<ll,ll>>it;
   ll t1,t2;
   for(i=0;i<n;i++){
      cin>>t1>>t2;
      it.pb(mp(t1,t2));
   }
   ll dp[n+1][w+1];
   for(i=0;i<=n;i++){
      for(j=0;j<=w;j++){
         if(i==0||j==0)dp[i][j]=0;
         else{
            if(j<it[i-1].ff)dp[i][j]=dp[i-1][j];
           else  dp[i][j]=max(dp[i-1][j],it[i-1].ss+dp[i-1][j-it[i-1].ff]);
         }
      }
   }
   cout<<dp[n][w]<<"\n";
      
}


Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,r) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


struct UnionFind {
  vll rank, par, data;

  UnionFind(ll x = MAX) {
	rank.resize(x + 1, 0);
	par.resize(x + 1, 0);
	data.resize(x + 1, 1);
	rep(i, x + 1) par[i] = i;
  }

  ll root(ll x) {
	if (x != par[x]) par[x] = root(par[x]);
	return par[x];
  }

  ll size(ll x) {
	return data[root(x)];
  }

  void unite(ll a, ll b) {
	ll x = root(a);
	ll y = root(b);
	if (x == y) return;
	if (rank[x] > rank[y]) {
	  par[y] = x;
	  data[x] += data[y];
	}
	else {
	  par[x] = y;
	  data[y] += data[x];
	  if (rank[x] == rank[y]) rank[y]++;
	}
  }

  bool same(ll a, ll b) {
	return root(a) == root(b);
  }
};

int main(void) {
  UnionFind u(MAX * 2);
  cin >> n >> m;
  rep(i, n) {
	cin >> cnt;
	rep(j, cnt) {
	  cin >> tmp;
	  u.unite(i, tmp + n);
	}
  }
  tmp = u.root(0);
  ok = true;
  rep(i, n) if (tmp != u.root(i)) ok = false;

  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e4;
const int inf=1e9;
int main(){
	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[2]!=a[0]){
		if(a[0]==a[1]||a[1]==a[2]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n=int(input())

s=list(map(int,input().split()))

cnt=[-1,-1,-1]

result=1

for item in s:

    temp=item-1
    if temp in cnt:
        result=result*cnt.count(temp)
        cnt[cnt.index(temp)]=cnt[cnt.index(temp)]+1
    else:
        print(0)
        exit()

print(result%1000000007)

Measured memory_bytes: 52908
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;

    int L[M], R[M], Lmax = 0, Rmin = 1e+9;
    REP(i, M){
        cin >> L[i] >> R[i];

        Lmax = max(Lmax, L[i]);
        Rmin = min(Rmin, R[i]);
    }

    int ans = 0;
    if (Rmin - Lmax >= 0) ans = Rmin - Lmax + 1;
    else ans = 0;

    cout << ans << endl;
}

Measured memory_bytes: 4368
var n,a,b,s,i,m:Longint;
begin
	read(n,a,b);
	for i:=1 to n do begin
		inc(m);
		if i mod 10000 = 0 then m:=1
		else if i mod 1000 = 0 then dec(m,27)
		else if i mod 100 = 0 then dec(m,18)
		else if i mod 10 = 0 then dec(m,9);
		if (a<=m)and(m<=b)then inc(s,i);
	end;
	writeln(s);
end.


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int r, c, i, j;
    static int s[101][101];

    scanf("%d%d", &r, &c);

    for (i = 0; i <= r; i++)
    {
        for (j = 0; j < c; j++)
        {
            scanf("%d", &s[i][j]);
            printf("%d ", s[i][j]);
            s[i][c] += s[i][j];
            s[r][j] += s[i][j];
        }
        printf("%d\n", s[i][c]);
    }

    return 0;
}



Measured memory_bytes: 2032
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = 1e9+7;
void Main(){
    string s; cin >> s;
    int n = s.size();
    
    // dp0 : 上から i 桁が s と一致
    // dp1 : そうでない
    vll dp0(n+1, 0), dp1(n+1, 0);
    dp0[0] = 1;
    rep(i, n){
        if(s[i] == '0'){
            dp0[i+1] = dp0[i];
            dp1[i+1] = (dp1[i] * 3) % MOD;
        }else{
            dp0[i+1] = (2 * dp0[i]) % MOD;
            dp1[i+1] = (dp0[i] + dp1[i] * 3) % MOD;
        }
    }
    /*
    rep(i, n+1){
        cout << i << " " << dp0[i] << " " << dp1[i] << endl;
    }
    */
    cout << (dp0[n] + dp1[n]) % MOD << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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


def main():
    """Function."""
    s = str(input())

    nums = len(s) - 2
    abs_dum = [0 for _ in range(nums)]
    for i in range(nums):
        dum = int(s[i:i+3])
        abs_dum[i] = abs(dum - 753)
    print(min(abs_dum))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	sort(a+1,a+1+n);
	int sum=0;
	for(int i=1;i<=k;i++){
		sum+=a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

N = int(input())
S = str(input())

west_w = 0
west_e = 0
east_w = S[1:].count("W")
east_e = S[1:].count("E")

min_change = west_w + east_e
for i in range(1, N):
    if S[i-1] == "W":
        west_w += 1
    else:
        west_e += 1
    if S[i] == "W":
        east_w -= 1
    else:
        east_e -= 1
    change = west_w + east_e
    if change < min_change:
        min_change = change

print(min_change)


Measured memory_bytes: 43376
#include <bits/stdc++.h> 
using namespace std; 
#define ll int long long
 int com(ll a)
{
    ll temp;
    if(a>=2)
    temp=a*(a-1)/2;
    else
    temp=0;
    return temp;
}
int main()
{
    ll n,m;cin>>n>>m;
    ll sum=com(n)+com(m);
    cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#define abs(a) ((a) < 0 ? -(a) : (a))

int main(void) {
	long long n, m, ans;
	
	scanf("%lld %lld", &n, &m);
	
	ans = abs((m - 2) * (n - 2));
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        int ans = 0;
        int ab = 100;
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = -100 ; i <= 101 ; i++) {
            boolean flg = true;
            for (int j = 0 ; j < n ; j++) {
                if (i == p[j]) {
                    flg = false;
                }
            }

            if (flg) {
                if (Math.abs(i - x) < ab) {
                    ans = i;
                    ab = Math.abs(i - x);
                }
            }
        }
        System.out.println(ans);
    }

}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<ll> cnt(N+1,0);
    for(int i = 0; i < N; ++i) cnt[A[i]]++;
    
    ll sum = 0;
    for(int i = 0; i <= N; ++i) sum += (cnt[i]*(cnt[i]-1))/2;
    for(int i = 0; i < N; ++i){
        ll ans = sum;
        ans -= (cnt[A[i]]*(cnt[A[i]]-1))/2;
        if(cnt[A[i]]-1>0) ans += ((cnt[A[i]]-1)*(cnt[A[i]]-2))/2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
while 1:
    val = input().split()
    op = val[1]
    int_val = [val[0], val[2]]
    int_val = [int(n) for n in int_val]

    if op == '?':
        break
    else:
        if op == '+':
            ret = int_val[0] + int_val[1]
        elif op == '-':
            ret = int_val[0] - int_val[1]
        elif op == '*':
            ret = int_val[0] * int_val[1]
        elif op == '/':
            ret = int_val[0] // int_val[1]
        print(ret)


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

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  int max1=0;
  int ind;
  for(int i=0;i<N;++i){
    cin>>A.at(i).first;
    A.at(i).second=i;
  }

  sort(A.begin(),A.end(),greater<pair<int,int>>());
  for(int i=0;i<N;++i){
    if(A.at(0).second==i){
      cout<<A.at(1).first<<endl;
    }
    else{
      cout<<A.at(0).first<<endl;
    }
  }
}

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

#define mod 1000000007 //1e9+7(prime number)
#define INF 1e9
#define LLINF (ll)2e18 + 1;
#define SIZE 200010

ll s[SIZE], t[SIZE];

int main(){
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A + 2), t(B + 2);
    s[0] = t[0] = -LLINF;
    s[A + 1] = t[B + 1] = LLINF;
    for (int i = 0; i < A; ++i) {
        cin >> s[i + 1];
    }
    for (int i = 0; i < B; ++i) {
        cin >> t[i + 1];
    }

    for (int i = 0; i < Q; ++i) {
        ll x, ans = LLINF;
        cin >> x;
        auto sIter = lower_bound(s.begin(), s.end(), x);
        auto tIter = lower_bound(t.begin(), t.end(), x);
        ll a = abs(x - *sIter);
        ll b = abs(x - *(sIter - 1));
        ll c = abs(x - *tIter);
        ll d = abs(x - *(tIter - 1));
        ans = min(ans, max(a, c));
        ans = min(ans, max(b, d));
        ans = min(ans, min(a, b) + min(c, d) + min({a, b, c, d}));
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll count = 0;
  string a, b;
  a = "";
  rep(i, sz(s)){
    b = s[i];
    if(a==b){
      if(i==sz(s)-1)count--;
      i++;
      a = "";
    }
    else{
      a = b;
    }
    count++;
  }
  print(count);
}

Measured memory_bytes: 3756
import java.util.*;
import java.util.stream.Collectors;
import static java.lang.System.*;

public class Main extends CodingSupport {
    protected void solve() {
        String inputStr = sc.nextLine();
        StringBuffer sb = new StringBuffer(inputStr);
        print(sb.reverse());
    }
}

abstract class CodingSupport {
    protected Scanner sc;
    protected CodingSupport() {
        sc = new Scanner(in);
    }
    
    public static void main(String[] args) throws Exception {
        new Main().solve();
    }
    
    protected abstract void solve();
    
    protected void print(Object o) {
        out.println(o);
    }
    
    protected Long[] scanLongs() {
        return 
          Arrays
              .stream(scanInts())
              .map(Integer::longValue)
              .toArray(Long[]::new);
    }
    
    protected Double[] scanDoubles() {
        return 
          Arrays
              .stream(scanInts())
              .map(Integer::doubleValue)
              .toArray(Double[]::new);
    }
    
    protected Integer[] scanInts() {
       return strArrayToIntArray(sc.nextLine().split(" "));
    }
    
    protected String[] scanLineToTokens(String delimiter) {
        return sc.nextLine().split(delimiter);
    }
    
    protected int scanInt() {
       return sc.nextInt();
    }

    protected List<Integer> strArrayToIntList(String[] strArray) {
        List<Integer> intList =
          Arrays
            .stream(strArray)
            .map(Integer::valueOf)
            .collect(Collectors.toList());
        return intList;
    }
    
    protected Integer[] strArrayToIntArray(String[] strArray) {
        Integer[] intArray =
        Arrays
            .stream(strArray)
            .map(Integer::valueOf)
            .toArray(Integer[]::new);
        return intArray;
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    typedef pair<string, pll> obj;

    ll N;
    cin >> N;
    vector<obj> res;
    REP(i, N){
    	string s;
    	ll P;
    	cin >> s >> P;
    	res.push_back({s, {-P, i+1}});
    }
    sort(res.begin(), res.end());
    REP(i, N){
    	cout << res[i].second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll mfa[MAX];
ll mrfa[MAX];

ll mPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll fa(ll x) {
    if(x==0) return 1;
    if(mfa[x]!=-1) return mfa[x];
    return mfa[x]=x*fa(x-1)%MOD;
}

ll rfa(ll x) {
    if(x==0) return 1;
    if(mrfa[x]!=-1) return mrfa[x];
    rfa(x-1);
    return mrfa[x]=mPow(fa(x), MOD-2)%MOD;
}

ll C(ll n, ll k) {
    if(n<k) return 0;
    return fa(n)*rfa(k)%MOD*rfa(n-k)%MOD;
}

int main(void) {
    ll N;
    ll a[MAX]={};
    ll cnt[MAX]={};
    ll id=-1;
    ll l=-1, r=-1;
    cin >> N;
    
    for(ll i=0; i<=N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]]==2) id=a[i];
    }
    
    for(ll i=0; i<=N; i++) {
        if(a[i]==id) {
            if(l==-1) l=i;
            else r=i;
        }
    }
    
    memset(mfa, -1, sizeof(mfa));
    memset(mrfa, -1, sizeof(mrfa));
    
    fa(100010);
    rfa(100010);
    
    for(ll k=1; k<=N+1; k++) {
        pr((C(N+1, k)-C(N+l-r, k-1)+MOD)%MOD);
    }
    
}



Measured memory_bytes: 5888
k = int(input())


ansl = []
def dfs(s):
    if len(s) == 12:
        return
    ansl.append(int(s))
    if s[-1] != "0":
        dfs(s + str(int(s[-1]) - 1))
    dfs(s+s[-1])
    if s[-1] != "9":
        dfs(s + str(int(s[-1]) + 1))

for i in range(1,10):
    dfs(str(i))

ansl = sorted(ansl)
print(ansl[k-1])

Measured memory_bytes: 105560
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
foreach($a as $num){
    @$map[$num]++;
}
$array = [];
foreach($map as $num => $count){
    for($i = 2; $i <= $count; $i+=2){
        $array[] = $num;
    }
}
if(count($array) >= 2){
    rsort($array);
    echo $array[0] * $array[1];
}else{
    echo 0;
}

Measured memory_bytes: 19444
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;
int main(void){
    // Your code here!
    char ch;
    while((ch=getchar()) != EOF){
        if(isalpha(ch)){
            if(islower(ch)){ printf("%c",toupper(ch));}
            else{printf("%c",tolower(ch));}
        }
        else{printf("%c",ch);}
        if(ch=='\n'){break;}
        
    }
    return 0;
}



Measured memory_bytes: 2996
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     int n;cin >> n;
     string s;cin >> s;
     vector<int>com;
     int cnt = 0;
     for(int i = 0;i<n;i++) if(s[i]=='R') {cnt++;com.push_back(i+1);}
     int ans = 0;
     for(int i = 0;i<cnt;i++){
        if(com[i]>cnt) ans++;
     }
     cout << ans;
}

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

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


void solve(long long N, std::vector<long long> H){
  ll x = H[0];
  ll ans = 0;
  ll cnt = 0;
  for(int i=1; i<N; i++) {
    if(x < H[i]) {
      ans = max(ans, cnt);
      cnt = 0;
    } else {
      cnt++;
    }
    x = H[i];
  }
  ans = max(ans, cnt);
  std::cout << ans << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 4056
require "bigdecimal"

while line=gets
    cod=line.chomp.split(" ").map{|x| BigDecimal(x)}
    if (cod[0]-cod[2])*(cod[4]-cod[6])+(cod[1]-cod[3])*(cod[5]-cod[7])==BigDecimal("0.0") then
        puts "YES"
    else
        puts "NO"
    end
end

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
typedef set<int>s;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
/*note

*/
int main()
{   int x,y;
cin>>x>>y;
if(y%2==1){cout<<"No"<<endl; return 0;}

if(2*x<=y&&y<=4*x)cout<<"Yes"<<endl;
else cout<<"No"<<endl;








}





Measured memory_bytes: 3620
'use strict';

// 改行で情報を分ける
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

// 最初の情報だけ分離
const info = input.shift().split(' ');
const targetNum = info[1] - 1;

// ソート
input.sort((a,b)=> {return a - b});

// 一通り引き算して配列の中に入れてしまう
let ans;
let ansArr = [];
for(let i = 0; i <= info[0] - info[1]; i++) {
	ansArr.push(input[targetNum + i] - input[i]);
}

// 一番小さな値を出力
console.log(Math.min(...ansArr));

Measured memory_bytes: 30644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int f(int x) {
  if (x % 4 == 0) return x;
  if (x % 4 == 1) return 1;
  if (x % 4 == 2) return x + 1;
  if (x % 4 == 3) return 0;
  return 0;
}
signed main() {
  int a, b;
  cin >> a >> b;
  cout << (f(a - 1) ^ f(b)) << endl;
  return 0;
}


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

int n, a[300], dp[300][300];

int rec(int l, int r){
    if(l >= r) return 0;
    if(~dp[l][r]) return dp[l][r];
    int ret = 0;
    if(abs(a[l]-a[r]) <= 1 && rec(l+1, r-1) == r-l-1) ret = r-l+1;
    for(int k = l; k < r; k++){
        chmax(ret, rec(l, k) + rec(k+1, r));
    }
    return dp[l][r] = ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    while(true){
        cin >> n;
        if(n == 0) break;
        rep(i,n) cin >> a[i];
        memset(dp, -1, sizeof(dp));
        cout << rec(0, n-1) << endl;
    }
    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)



int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    string s;
    cin >> N >> M >> s;
    VI V{N};
    int last = -1;
    FORD(i, N - 1, 0) {
        if (s[i] == '0' && V.back() - i <= M) {
            last = i;
        } else if (V.back() - i > M) {
            if (last == -1) {
                cout << "-1\n";
                return 0;
            }
            V.pb(last);
            last = -1;
            if (s[i] == '0') {
                last = i;
            }
        }
    }
    V.pb(0);
    reverse(all(V));
    FOR(i, 1, SZ(V) - 1) {
        cout << V[i] - V[i - 1] << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


const int MAXN = 100005;
string S;
int RK[MAXN], SA[MAXN], LCP[MAXN], h[MAXN];
int cnt[MAXN], tmp[MAXN];

void getSA() {
	// O(NlogN)っぽいSA構築のコピペ
	// SA[i]が辞書順i番目の接尾辞が何文字目からのものか
	// RK[i]はi文字目からの接尾辞が辞書順何番目か
	// LCP[i]は辞書順i番目と(i-1)番目の接尾辞をみたとき、prefixが何文字一致するか
	// h[i] = LCP[RK[i]]

	int N = S.size();
	int limit = 128;
	rep(i, N) ++cnt[RK[i] = S[i]];
	rep(i, limit - 1) cnt[i + 1] += cnt[i];
	for (int i = N - 1; i >= 0; --i) SA[--cnt[S[i]]] = i;
	for (int k = 1; k <= N; k <<= 1) {
		int j = 0;
		rep(i, k) tmp[j++] = N - k + i;
		rep(i, N) if (SA[i] >= k) tmp[j++] = SA[i] - k;
		rep(i, limit) cnt[i] = 0;
		rep(i, N) ++cnt[RK[i]];
		rep(i, limit - 1) cnt[i + 1] += cnt[i];
		for (int i = N - 1; i >= 0; --i) SA[--cnt[RK[tmp[i]]]] = tmp[i];
		tmp[SA[0]] = 0;
		rep1(i, N - 1) {
			tmp[SA[i]] = tmp[SA[i - 1]] + 1;
			if (SA[i] + k < N && SA[i - 1] + k < N && RK[SA[i]] == RK[SA[i - 1]] && RK[SA[i] + k] == RK[SA[i - 1] + k]) {
				tmp[SA[i]]--;
			}
		}
		rep(i, N) RK[i] = tmp[i];
		limit = RK[SA[N - 1]] + 1;
		if (limit >= N) break;
	}
	rep(i, N) {
		if (!RK[i]) h[i] = 0;
		else {
			if(i && h[i - 1]) h[i] = h[i - 1] - 1;
			while (S[i + h[i]] == S[SA[RK[i] - 1] + h[i]]) h[i]++;
		}
	}
	rep(i, N) LCP[i] = h[SA[i]];
}

const int K = 15;
const int KM = 1 << (K - 1);
int dat[1 << K];

void update(int A) {
	dat[A] = min(dat[A * 2], dat[A * 2 + 1]);
	if (A != 1) update(A / 2);
}

void add(int A, int B) {
	int C = A + KM;
	dat[C] = B;
	update(C / 2);
}

int check(int L, int R, int A, int l, int r) {
	if (L <= l && r <= R) return dat[A];
	if (r <= L || R <= l) return 1e9;
	return min(check(L, R, A * 2, l, (l + r) / 2), check(L, R, A * 2 + 1, (l + r) / 2, r));
}

int query(int L, int R) {
	return check(L, R, 1, 0, KM);
}

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


	int N;
	cin >> N;
	cin >> S;

	getSA();

	int SpT[100000][20];
	rep(i, N) SpT[i][0] = LCP[i];
	rep(i, 19) {
		int k = 1 << i;
		rep(j, N) SpT[j][i + 1] = min(SpT[j][i], SpT[min(N - 1, j + k)][i]);
	}

	int kotae = 0;
	rep(i, N) for(int j = i + 1; j < N; j++) {
		int a = RK[i];
		int b = RK[j];
		if (a > b) swap(a, b);

		int c = 31 - __builtin_clz(b - a);
		int k = min(SpT[a + 1][c], SpT[b + 1 - (1 << c)][c]);

		kotae = max(kotae, min(k, j - i));
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

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

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

	int ans = -INT_MAX;
	range(i,1,1 << 10){
		int sum = 0;
		rep(j,n){
			int cnt = 0;
			rep(k,10){
				if((i >> k) bitand 1 and f[j][k]) cnt++; 
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double pi=3.14159265358979323846;

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	cout<<fixed<<setprecision(10);
	ld a,b,x;
	cin>>a>>b>>x;
	if(((2*x)/(a*b))<=a)
	{
		ld ans=(pi/2)-atanl((2*x)/(a*b*b));
		ans=180*ans/pi;
		cout<<ans<<endl;
	}
	else
	{
		ld ans=(pi/2)-atanl((a*a*a)/(2*a*a*b-2*x));
		ans=180*ans/pi;
		cout<<ans<<endl;
	}
	
	

	return 0;
}

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

public class Main {

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

		while (true) {
			String[] inputNum = br.readLine().split(" ");
			int H = Integer.parseInt(inputNum[0]);
			int W = Integer.parseInt(inputNum[1]);

			if (H == 0 && W == 0) {
				break;
			}

			for (int i = 1; i <= H; i++) {
				for (int j = 1; j <= W; j++) {
					if (i == 1 || i == H || j == 1 || j == W) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				}
				System.out.println("");

			}
			System.out.println("");

		}

	}

}

Measured memory_bytes: 25700
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
   
  // static Scanner sc = new Scanner(System.in);
  
    private final static int mod = (int) (1e9 + 7);
    private final static int N = (int) (1e6);
    public static List<Integer>[] edges ;
    public static long[][] dp;
    
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 char[] s = sc.next().toCharArray();
	 char[] t = sc.next().toCharArray();
	 int[][] dp = new int[s.length+1][t.length+1];
	 for(int i=1;i<=s.length;++i) {
		 for(int j=1;j<=t.length;++j) {
			 if(s[i-1] == t[j-1]) {
				 dp[i][j] = dp[i-1][j-1] + 1;
			 }else {
				 dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
			 }
		 }
	 }
	 StringBuilder sb = new StringBuilder();
	 int i = s.length,j = t.length;
	 while(i > 0 && j > 0) {
		 if(s[i-1] == t[j-1]) {
			 sb.append(s[i-1]);
			 --i; --j;
		 }else if(dp[i-1][j] > dp[i][j-1]){
			 --i;
		 }else --j;
	 }
	 sb.reverse();
	 
	 out.print(sb);
	 out.close();
	 
    
	}
	
	
    
	

	
}

Measured memory_bytes: 80084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> al(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		al[a].push_back(b);
		al[b].push_back(a);
	}

	queue<int> q;
	vector<int> dist(n, INT_MAX);
	vector<int> pre(n, -1);
	dist[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (const auto& u : al[v]) {
			if (dist[u] != INT_MAX) continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	for (int i = 0; i < n; i++) {
		if (i == 0) continue;
		int ans = pre[i] + 1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 10572