akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int n; ll m; cin >> n >> m;
    vector<ll> yakusu = enum_divisors(m);
    sort(all(yakusu));
    ll mx = m / n, res;
    for(ll num: yakusu){
        if(num <= mx) res = num;
        else break;
    }
    cout << res << ln;
}

Measured memory_bytes: 256
/*Remember: The Struggle Is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast() 	     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,MOD=1e9+7;

int n;
vector<int> v;

void solve()
{
 cin>>n;

 vector<int> v(n),a(n),b(n);

 for(int i=0;i<n;++i)
 cin>>v[i];

 int g;

 g=a[0]=v[0];
 for(int i=1;i<n;++i)
 g=gcd(g,v[i]),a[i]=g;

 g=b[n-1]=v[n-1];
 for(int i=n-2;i>=0;--i)
 g=gcd(g,v[i]),b[i]=g;

 int ans=0;
 for(int i=0;i<n;++i)
 {
  if(i==0)
  ans=max(ans,b[i+1]);
  else if(i==n-1)
  ans=max(ans,a[i-1]);
  else
  ans=max(ans,gcd(a[i-1],b[i+1]));
 }

 cout<<ans;
}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


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

for idx, num in enumerate(numbers):
    if num == 0:
        print(idx + 1)


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

int main(){
  int n; cin>>n;
  vector<int> b(n-1);
  for(int i=0; i<n-1; ++i)cin>>b[i];

  int ans=0;
  for(int i=1; i<n-1; ++i)ans+=min(b[i], b[i-1]);
  ans+=b[0]+b[n-2];

  cout<<ans<<endl;
}


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

int main(){
  int n,k,a[8888],dp[8888];

  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)dp[j] = 1e8;
    for(int j=i;j<a[i];j++){
      if(a[i]<a[j])*lower_bound(dp,dp+n+1,a[j]) = a[j];
    }
    ans = max(ans, (int)(lower_bound(dp,dp+n+1,1e8) - dp));
  }
  printf("%d\n",min(ans+1+k,n/2));
}

Measured memory_bytes: 1260
H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]

for k in range(10):
	for i in range(10):
		for j in range(10):
			c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for _ in range(H):
	ans += sum([c[x][1] for x in map(int,input().split()) if x != -1])

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;


int main() {
	//解説AC
	int N, K;
	cin >> N >> K;
	vector<int>X(N);
	rep(i, N) {
		cin >> X[i];
	}
	int ans = INT_MAX;
	rep(i, N - K+1) {
		ans = min(ans, abs(X[i]) + abs(X[i] - X[i + K - 1]));
		ans = min(ans, abs(X[i + K - 1]) + abs(X[i] - X[i + K - 1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
//
// Created by Hideaki Imamura on 2020-03-21.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll comb(ll N, ll R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    if (R == 2) return N * (N-1) / 2;
    return N * (N - 1) * (N - 2) / 6;
}

ll pow(ll N, ll k) {
    ll res = 1;
    for (int i = 0; i < k; ++k) res *= N;
    return res;
}

string S;
int N, K;

// solve(i, k, smaller) = i桁目以降についてみる。0以外の値を残りk回使用できる。i桁目までの値がSと等しいなら
// smaller = trueで、strictに小さいならsmaller = falseである。この時の場合の数。
ll solve(int i, int k, bool smaller) {
    if (i == N) return k == 0 ? 1 : 0;
    if (k == 0) return 1;
    if (smaller) return comb(N - i, k) * pow(9, k);
    if (S[i] == '0') return solve(i + 1, k, false);
    ll zero = solve(i + 1, k, true);
    ll aida = solve(i + 1, k - 1, true) * (S[i] - '1');
    ll ichi = solve(i + 1, k - 1, false);
    return zero + aida + ichi;
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
xl = list(map(int, input().split()))

if n>=m:
    print(0)
    exit()
if n==1:
    print(max(xl)-min(xl))
    exit()


xl.sort()
l = []
for i in range(m-1):
    l.append(xl[i+1]-xl[i])
l.sort(reverse=True)

res = sum(l) - sum(l[0:n-1])
print(res)


Measured memory_bytes: 13968
#include<iostream>
#include<string>
#include<map>


int main()
{
    int N;
    long long sum=0;
    std::cin >> N;
    std::string str, l="MARCH";
    std::map<char, int> c;
    c['M']=0;
    c['A']=0;
    c['R']=0;
    c['C']=0;
    c['H']=0;
    
    for(int i=0; i<N; i++)
    {
        std::cin >> str;
        c[str[0]]++;
    }
    
    for(int i=0; i<3; i++)
    {
        for(int j=i+1; j<5; j++)
        {
            for(int k=j+1; k<5; k++)
            {
                sum += c[l[i]]*c[l[j]]*c[l[k]];
            }
        }
    }
    std::cout << sum << std::endl;
    
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N;cin >> N;
    vector<ll> V(N);
    REP(i,N){
        cin >> V[i];
        if(i > 0) V[i] += V[i-1];
    }
	V.pb(0);
    sort ALL(V);
    ll ans = 0,cnt = 1;
    REP(i,N){
        if(V[i] == V[i+1]) cnt++;
        else{
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
        if(i == N - 1 && cnt > 1) ans += cnt * (cnt - 1) / 2; 
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  int n;
  cin >> n >> s;
  for(int i = 0; i < s.size(); i++){
    s[i] += n;
    if(s[i] > 'Z') s[i] -= 'Z' - 'A' + 1;
  }
  cout << s << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  
  long long tmp = max(max(a*c,a*d),max(b*c,b*d));
  
  cout << tmp <<endl;

  return 0;  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl "\n"
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fb(i, a, b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector <int>
#define vl vector <long long>
#define pi pair <int, int>
#define sz(x) (int) x.size()
#define M 100005
#define mod 1000000007
using namespace std;

void solve()
{
	double x, y = 100, ans = 0;
	cin>>x;
	while(y < x)
	{
		ans++;
		y = floor(y*1.01);
	}
	cout<<ans;
}

int main()
{
    IOS
    int t = 1;
    //cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

#define ransum(mat, i1, i2, j1, j2) (mat[i2][j2] + mat[i1][j1] - mat[i1][j2] - mat[i2][j1])

int B[2020][2020], W[2020][2020];
int psumBr[2020][2020], psumWr[2020][2020];
int psumB[2020][2020], psumW[2020][2020];

int main() {
  ios::sync_with_stdio(false);

  int N, K;

  cin >> N >> K;
  int L = K * 2;

  REP(i, N) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    x %= L;
    y %= L;

    if (c == 'W') W[y][x] += 1;
    else B[y][x] += 1;
  }

  REP(i, L) {
    REP(j, L) {
        psumBr[i][j+1] = psumBr[i][j] + B[i][j];
        psumWr[i][j+1] = psumWr[i][j] + W[i][j];
    }
  }

  REP(i, L) {
    REP(j, L) {
        psumB[i+1][j+1] = psumB[i][j+1] + psumBr[i][j+1];
        psumW[i+1][j+1] = psumW[i][j+1] + psumWr[i][j+1];
    }
  }

  int result = 0;

  REP(i, K+1) {
    REP(j, K+1) {
        int result2 = ransum(psumB, 0, i, 0, j) + ransum(psumB, i+K, L, 0, j) + ransum(psumB, i, i+K, j, j+K)
                    + ransum(psumB, 0, i, j+K, L) + ransum(psumB, i+K, L, j+K, L)
                    + ransum(psumW, i, i+K, 0, j) + ransum(psumW, 0, i, j, j+K)
                    + ransum(psumW, i+K, L, j, j+K) + ransum(psumW, i, i+K, j+K, L);
        result = max(result2, result);
    }
  }

  REP(i, K+1) {
    REP(j, K+1) {
        int result2 = ransum(psumW, 0, i, 0, j) + ransum(psumW, i+K, L, 0, j) + ransum(psumW, i, i+K, j, j+K)
                    + ransum(psumW, 0, i, j+K, L) + ransum(psumW, i+K, L, j+K, L)
                    + ransum(psumB, i, i+K, 0, j) + ransum(psumB, 0, i, j, j+K)
                    + ransum(psumB, i+K, L, j, j+K) + ransum(psumB, i, i+K, j+K, L);
        result = max(result2, result);
    }
  }


  cout << result << endl;
}


Measured memory_bytes: 95744
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;


struct mint{
    ll x;
    mint(ll x = 0):x((x%mod+mod)%mod){};
    mint operator-() const{
        return mint(-x);
    }
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const{
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const{
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const{
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const{
        //愚直にt回書けるとO(t)かかるが，
        //以下の方法でやるとO(log(t))
        //二進数で考えて，一番上の桁から再帰的に計算
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};

struct combination{
    vector<mint> fact, ifact;
    combination(int n):fact(n+1), ifact(n+1){
        //n < mod という条件を想定しているのだぞ！という主張
        assert(n < mod);
        fact[0] = 1;
        for(int i=1; i<= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i=n; i>=1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k){
        if(k<0 || k>n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int x, y;
    cin >> x >> y;
    int n = x + y;
    if(n%3!=0){
        cout << 0 << endl;
        return 0;
    }
    n /= 3;
    x -= n;
    y -= n;
    if(x<0 || y<0){
        cout << 0 << endl;
        return 0;
    }

    combination c(n);
    mint ans = c(n, x);

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 10624
#include<stdio.h>
  
#define M 2000001
#define INFTY (1<<30)
  
int H, A[M];
  
void maxHeapify(int i){
    int l, r, biggest, tmp;
     
    l = 2 * i;
    r = 2 * i + 1;
 
    if(l <= H && A[l] > A[i]) biggest=l;
    else biggest=i;
     
    if(r <= H && A[r] > A[biggest]) biggest=r;
    if(biggest != i){
        tmp = A[i];
        A[i] = A[biggest];
        A[biggest] = tmp;
        maxHeapify(biggest);
    }
}
  
int extract(){
    int maxv;
    if(H < 1)return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}
  
void increKey(int i, int key){
    int tmp;
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        tmp = A[i];
        A[i] = A[i/2];
        A[i/2] = tmp;
        i = i/2;
    }
}
  
void insert(int key){
    H++;
    A[H] = -INFTY;
    increKey(H,key);
}
  
int main(){
    int key;
    char com[10];
    while(1){
        scanf("%s", com);
        if(com[0]=='e' && com[1]=='n'){
            break;
        }
        if(com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }
        else printf("%d\n", extract());
    }
     
    return 0;
}

Measured memory_bytes: 4696
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
#define N 5000100
char a[N];
char b[N];
ll k=0;
int deal()
{
    for (ll i=0,j=k-1;i<k/2;i++,j--)
            if (b[i]!=b[j])
          return 0;
    return 1;
}

int main()
{
    int flag=0;
    scanf("%s",a);
   ll len=strlen(a);
    int i=0,j=len-1,num=0;
    while (i<j)
    {
        if (a[i]==a[j])
            i++,j--;
        else if (a[i]=='x')
            i++,num++;
        else if (a[j]=='x')
            j--,num++;
        else
        {
            flag=1;
            break;
        }
    }
    if (!flag)
        cout << num << endl;
    else
        cout << "-1" << endl;
   /*ll num=0;
   for (ll i=0;i<len;i++)
      if (a[i]!='x')
         b[k++]=a[i];
   if (!deal())
    {
        cout << "-1" << endl;
        return 0;
    }
   else
   {
       int j=len-1;
       for (ll i=0;i!=j;)
       {
           if (a[i]==a[j])
            i++,j--;
           else if (a[i]=='x')
             i++,num++;
           else if (a[j]=='x')
              j--,num++;
       }
   }
   cout << num << endl;
   */
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 1e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;


char s[maxN];
char t[maxN];

int a[maxN];
int b[maxN];
int c[maxN];
void clear(int n)
{
	for(int i=1;i<=n;i++)
	{
		a[i] = b[i] = c[i] = 0;
	}
}
int main()
{
	string s;
	cin>>s;
	int cnt = 0;
	int tmp = 0;
	for(int i=0;i<3;i++)
	{
		if(s[i] == 'S')
		{
			cnt = max(cnt,tmp);
			tmp = 0;
			continue;
		}
		tmp++;
	} 
	cnt = max(cnt,tmp);
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=16,maxm=20;
const int MOD=1e9+7;
int n,m;
int a[maxm];
int dp[maxm][1<<maxn];
int fac[1<<maxn],invf[1<<maxn];
int pw[maxn];

bool cmp(int &a,int &b)
{
	return a>b;
}

void inc(int &a,int b)
{
	a+=b;
	if(a>=MOD) a-=MOD;
	if(a<0) a+=MOD;
}

void init()
{
	pw[0]=fac[0]=invf[0]=invf[1]=1;
	for(int i=1;i<(1<<maxn);i++)
		fac[i]=1ll*fac[i-1]*i%MOD;
	for(int i=2;i<(1<<maxn);i++)
		invf[i]=1ll*(MOD-MOD/i)*invf[MOD%i]%MOD;
	for(int i=2;i<(1<<maxn);i++)
		invf[i]=1ll*invf[i-1]*invf[i]%MOD;
	for(int i=1;i<maxn;i++)
		pw[i]=1ll*pw[i-1]*2%MOD;
}

int C(int n,int m)
{
	if(n<m) return 0;
	else return 1ll*fac[n]*invf[m]%MOD*invf[n-m]%MOD;
}

int P(int n,int m)
{
	if(n<m) return 0;
	else return 1ll*fac[n]*invf[n-m]%MOD;
}

int solve()
{
	sort(a+1,a+m+1,cmp);
	dp[0][0]=1;
	int N=1<<n;
	for(int i=1;i<=m;i++)
	{
		for(int S=0;S<N;S++)
			dp[i][S]=dp[i-1][S];
		for(int S=0;S<N;S++)
		{
			int cnt=0;
			for(int j=0;j<n;j++)
				if((S>>j)&1)
					cnt+=pw[j];
			for(int j=0;j<n;j++)
			{
				if((S>>j)&1) continue;
				if(!dp[i-1][S]) continue;
				int newS=S|(1<<j);
				inc(dp[i][newS],1ll*dp[i-1][S]*C(N-a[i]-cnt,pw[j]-1)%MOD*P(pw[j],pw[j])%MOD);
			}
		}
	}
	int ans=0;
	for(int S=0;S<N;S++)
	{
		int c=1;
		int res=dp[m][S];
		int cnt=0;
		for(int j=0;j<n;j++)
		{
			if((S>>j)&1)
			{
				cnt+=pw[j];
				c=-c;
			}
		}
		res=1ll*res*P(N-cnt-1,N-cnt-1)%MOD;
		inc(ans,res*c);
	}
	ans=1ll*ans*N%MOD;
	return ans;
}

int main()
{
	//freopen("093F.txt","r",stdin);
	init();
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	printf("%d\n",solve());
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
struct node
{
	int l,r;
}g[maxn];
string s[maxn];
std::vector<node> v1;
std::vector<node> v2;
bool cmp1(node a,node b){
	return a.r<b.r;
}
bool cmp2(node a,node b){
	return a.l<b.l;
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i = 1; i <=n; ++i)
	{
		cin>>s[i];
		int l = 0,r = 0;
		for (int j = 0; j <s[i].length(); ++j)
		{
			if(s[i][j] == '(') l++;
			else {
				if(l) l--;
				else r++;
			}
		/* code */
		}
			/* code */
		if(l>=r) v1.push_back({l,r});
		else v2.push_back({l,r});
		/* code */
	}

	sort(v1.begin(),v1.end(),cmp1);
	sort(v2.begin(),v2.end(),cmp2);
	int sum1 = 0, sum2 = 0, ok = 0;
	for (int i = 0; i <v1.size(); ++i)
	{
		sum1-=v1[i].r;

		if(sum1<0){
			ok = 1;
			break;
		}

		sum1+=v1[i].l;
		/* code */
	}
	for (int i = 0; i <v2.size(); ++i)
	{
		sum2-=v2[i].l;
		if(sum2<0){
			ok = 1;
			break;
		}
		sum2+=v2[i].r;
		/* code */
	}
	if(sum1 != sum2) ok = 1;
	if(ok){
		printf("No\n");
	}
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 42532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, x, a;
bool in[105];

void ac(int x) {
	cout << x;
	exit(0);
}

int main() {
	fastio; cin >> x >> n;
	FOR(i, 1, n) {
		cin >> a;
		in[a] = 1;
	}
	FOR(i, 0, 100) {
		if (x - i <= 0 or !in[x-i]) ac(x-i);
		if (x + i > 100 or !in[x+i]) ac(x+i);
	}
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int n, m, l;
    int a, b, c;
    int q;
    vector<int> s(100010), t(100010);
    ll d[500][500], count[500][500];
    int i, j, k;

    cin >> n >> m >> l;

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            if (i == j)
            {
                d[i][j] = 0;
            }
            else
            {
                d[i][j] = INF;
            }
        }
    }

    rep(i, 0, m)
    {
        cin >> a >> b >> c;

        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
    }

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            rep(k, 0, n)
            {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

                if (j == k)
                {
                    count[j][k] = 0;
                }
                else if (d[j][k] <= l)
                {
                    count[j][k] = 1;
                }
                else
                {
                    count[j][k] = INF;
                }
            }
        }
    }

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            rep(k, 0, n)
            {
                count[j][k] = min(count[j][k], count[j][i] + count[i][k]);
            }
        }
    }

    cin >> q;

    rep(i, 0, q)
    {
        cin >> s[i] >> t[i];
    }

    rep(i, 0, q)
    {
        if (count[s[i] - 1][t[i] - 1] == INF)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << count[s[i] - 1][t[i] - 1] - 1 << endl;
        }
    }
}

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

int main() {
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

//const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,c;
  std::cin>>n>>c;

  std::vector<ll> x(n),v(n);
  rep(i,0,n)std::cin>>x[i]>>v[i];

  auto solve=[&n,&c](std::vector<ll>& x,std::vector<ll>& v)->ll{
    std::vector<ll> max_right(n+1,0);
    ll sum=0;
    rep(i,0,n){
      sum+=v[i];
      max_right[i+1]=std::max(max_right[i],sum-x[i]);
    }
    sum=0;
    ll ret=max_right[n];
    rep(i,0,n){
      sum+=v[n-1-i];
      chmax(ret,max_right[n-1-i]+sum-2*(c-x[n-1-i]));
    }
    return ret;
  };

  ll ans=solve(x,v);

  rep(i,0,n){
    x[i]=c-x[i];
  }

  std::reverse(all(x));
  std::reverse(all(v));

  chmax(ans,solve(x,v));

  std::cout<<ans<<"\n";

  return 0;
}


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

int main(){
 int n,b[200010];
 set<int> p;
 cin>>n;
 for(int i=1;i<=n;i++){
  int a;
  cin>>a;
  b[a]=i;
 }
 p.insert(0);
 p.insert(n+1);
 ll ans=0;
 for(int i=1;i<=n;i++){
  int l=*(--p.lower_bound(b[i])),r=*p.upper_bound(b[i]);
  ans+=(ll)i*(b[i]-l)*(r-b[i]);  
  p.insert(b[i]);
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	int s,w;
	cin>>s>>w;
	if( w >= s){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;;
#define llong long long
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int n,m;
vector<int> graph[9];
bool used[9];
int dfs(int now, int cnt){
    int ans = 0;
    if(cnt == n){
        ans = 1;
    }else{
        for(int i=0; i<graph[now].size(); i++){
            if(used[graph[now][i]] == false){
                used[graph[now][i]] = true;
                ans += dfs(graph[now][i], cnt+1);
                //cout << graph[now].size() << endl;
                used[graph[now][i]] = false;
            }
        }
    }

    return ans;

}
int main(){
    cin >> n >> m;
    for(int i = 0; i<m; i++){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for(int i = 1 ; i<9; i++){
        used[i]  = false;
    }
    used[1] = true;
    int ans = dfs(1, 1);

cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
//辗转相除法求解a,b的最大公约数，使用前a、b请自行取绝对值
int gcd(long long a,long long b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    long long a,b;
    while(cin>>a>>b) {
        cout<<gcd(a,b)<<" "<<a*b/gcd(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long f[101010];
long long a[101010];
int main()
{
	int n,e,t,now=1;
	long long mi=21474836478ll;
	scanf("%d%d%d",&n,&e,&t);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	f[0]=0;
	f[1]=t;
	for(int i=2;i<=n;i++)
	{
		while((a[i]-a[now])*2>t)
		{
			mi=min(mi,f[now-1]-2*a[now]);
			now++;
		}
		f[i]=f[now-1]+t;
		f[i]=min(f[i],mi+2*a[i]);
	}
	printf("%lld",(long long)e+f[n]);
	return 0;
}

Measured memory_bytes: 1792
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int N;
string S;
set<int> st;
vector<vvb> dp;

void dfs(int n, int l, int p) {
  if (l>=3) {
    st.insert(p);
    return;
  }
  if (n>N) return;

  if (dp[n][l][p]) return;

  dfs(n+1, l, p);
  if (l<3 && p*10+(S[n]-'0') < 1000) dfs(n+1, l+1, p*10+(S[n]-'0'));

  dp[n][l][p] = true;
}

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


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

  S = " "  + S;
  dp = vector<vvb>(N+1, vvb(4, vb(1008, false)));
  // [1,i] で j 文字を選んで、パスを k にできるか
  dp[0][0][0] = true;
  dfs(1, 0, 0);

  int ans = st.size();
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 25472
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int a[15][15],p[15];
int main(){
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			splay(a[i][j]);
		}
	}
	int ans=0;
	for(int k=0;k<=9999;k++){
		int x=k;
		for(int i=4;i>=1;i--)p[i]=x%10,x/=10;
		x=0;
		for(int i=1;i<=4;i++)x=a[x][p[i]];
		p[5]=x;x=0;
		for(int i=1;i<=5;i++)x=a[x][p[i]];
		if(x==0){
			bool f=1;
			for(int i=1;i<=5;i++){
				for(int j=0;j<=9;j++){
					if(j==p[i])continue;
					swap(p[i],j);
					int o=0;
					for(int ff=1;ff<=5;ff++)o=a[o][p[ff]];
					if(o==0)f=0;
					swap(p[i],j);
				}
			}
			for(int i=1;i<=4;i++){
				if(p[i]==p[i+1])continue;
				swap(p[i],p[i+1]);
				int o=0;
				for(int ff=1;ff<=5;ff++)o=a[o][p[ff]];
				if(o==0)f=0;
				swap(p[i],p[i+1]);
			}
			if(!f){
				ans++;
				//cerr<<k<<endl;
				//return 0;
			}
		}
	}
	cout<<ans<<endl;
}

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

    int main() {
      int n;
      cin >>n;
      long cnt = 0;
      for (int i = 1; i <= n; i++) {
      	for (int j = 1; j <= n; j++) {
      		for (int k = 1; k <= n; k++) {
			  int temp;	
              temp = gcd(i, j);
              temp = gcd(temp,k);
              cnt = cnt + temp;
      		}
      	}
      }
      cout << cnt;
      return 0;
    }

Measured memory_bytes: 3636
"use strict";
const combi = function(n){
    return n*(n-1)/2
}

const main = arg => {
    const input = arg.trim().split("\n");

    const N = parseInt(input[0].split(" ")[0]);
    const A = input[1].split(" ").map(n => parseInt(n));

    let m = {}
    for(let i = 0; i<A.length; i++){
        if(!m[A[i]]) m[A[i]] = 1
        else m[A[i]]++
    }
    let orgCnt = 0
    let keys = Object.keys(m)
    for(let i = 0; i<keys.length; i++){
        let tmp = m[keys[i]]
        orgCnt = orgCnt + tmp * (tmp-1)/2
    }

    let out = ""
    for(let i = 0; i<A.length; i++){
        let num = m[A[i]]
        const diff = num*(num-1)/2 - (num-1)*(num-2)/2

        out = out + String(orgCnt-diff)+"\n"
    }
    console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 75972
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($A,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

printf("%d\n",$A*$B);


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

int main(int argc, char **argv){
  int iN;
  int iNgroup;
  cin >> iN;
  // cout << "input: " << iN << endl;
  iNgroup = (iN-(iN%3))/3;
  cout << iNgroup << endl;
  return 0;
}

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy
# sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def main():
    n, x = map(int, input().split())
    print(3 * (n - gcd(n, x)))

main()


Measured memory_bytes: 3444
#include <iostream>

using namespace std;
int main(){
	int i,n,c[100],v[100],x = 0;
	cin >> n;
	for(i=0;i<n;i++) cin >> v[i];
	for(i=0;i<n;i++) cin >> c[i];
	for(i=0;i<n;i++){
		x += max(0,v[i] - c[i]);
	}
	cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner a = new Scanner(System.in);

		int H = a.nextInt();
		int W = a.nextInt();
int h = a.nextInt();
		int w = a.nextInt();
		int ans = (H - h) * (W - w);
		System.out.println(ans);

	}

}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n, q; cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    for (int i = 0; i < q; i++) {
        ll x; cin >> x;

        ll res = 0, sum = 0;
        int l = 0, r = 0;
        for (; l < n; l++) {
            while (r < n && sum + a[r] <= x) sum += a[r++];
            res += r - l;
            sum -= a[l];
        }
        cout << res << endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<string>> s;
    char prefix[] = {'M', 'A', 'R', 'C', 'H'};
    string tmp;
    ll ans = 0;
    
    rep(i, 5) {
        vector<string> t;
        s.push_back(t);
    }
    
    rep(i, n) {
        cin >> tmp;
        
        rep(ii, 5) {
            if (tmp[0] == prefix[ii]) {
                s[ii].push_back(tmp);
            }
        }
    }
    
    for (int i = 0; i < (1 << 5); i++) {
        bitset<5> bs(i);
        int cnt = 0;
        ll ptn = -1;
        
        rep(ii, 5) {
            if (bs[ii]) cnt++;
        }
        
        if (cnt != 3) {
            continue;
        }
        
        rep(ii, 5) {
            if (bs[ii]) {
                ptn = ((ptn == -1) ? 1 : ptn) * s[ii].size();
            }
        }
        
        ans += ptn;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5748
import java.util.Scanner;

class Main {

	public void ci(){

		Scanner sc = new Scanner(System.in);

		double r,S,O;

		r = sc.nextDouble();

		S = r * r * 3.141592653589;

		O = 2 * r * 3.141592653589;

		System.out.printf("%2.6f %2.6f\n",S,O);

	}

	public static void main(String[] args){

		new Main().ci();

	}

}

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

using ll = long long;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<bool> check(N+1, false);
    vector<int> count(N+1, 0);
    ll ans = 0;
    ll correct = 0;
    for(int i = 0; i< M; i++){
        int buf;
        string bb;
        cin >> buf >> bb;
        if(check.at(buf) == false){
            if(bb.compare("WA") == 0){
                count.at(buf) += 1;
            }else{
                check.at(buf) =true;
                correct += 1;
                ans += count.at(buf);
            }
        }
    }

    cout <<correct << " " <<  ans << endl;


}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vs s(n); vll t(n);
  rep(i,n){
    cin>>s[i]>>t[i];
  }
  string x; cin>>x;
  bool flg=false;
  ll ans=0;
  rep(i,n){
    if(flg) ans+=t[i];
    if(s[i]==x) flg=true;
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
	int a[4], b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		int hit=0, blow=0;
		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(a[i]==b[j]){
					if(i==j)
						hit++;
					else
						blow++;
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int outlet=1,ans=0;
    while(outlet<b)
    {
        outlet--;
        outlet+=a;
        ans++;
    }
    cout<<ans<<endl;

}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll m = min(b-1,n);
    cout << (a*m)/b-a*(m/b);
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)

int N, k, i1, i2;
ll a[100010];

int main() {
    while (cin >> N >> k) {
        if (N == 0) break;
        REP(i,N) cin >> a[i];

        ll S[100010];
        S[0] = 0;
        REP(i,N) {
            S[i+1] = S[i] + a[i];
        }

        int ans = 0;
        REP(i,N+1-k) {
            if (S[i+k] - S[i] > ans) ans = S[i+k] - S[i];
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 4548
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;


public class Main {
	  static int mod=1000000007;
      public static void main(String[] args) {
    	  Scanner in=new Scanner( new BufferedReader(new InputStreamReader(System.in)))	;
    	  String string=in.next();
    	  int n=string.length();
    	  TreeMap<Character, Integer> map=new TreeMap<Character, Integer>(); 
    	  int l=0,r=0;
    	  long num=0;
    	  for(int i=0;i<n-1;i++)
    	  {
    		 for(int j=i+1;j<n&&j<=i+2;j++)
    		 {
    			 if(string.charAt(j)==string.charAt(i))
    			 {
    				 i++;j++;
    				 System.out.println(i+" "+j);
    				 return ;
    			 }
    		 }
    	  }
    	  System.out.println("-1 -1");
    	  
      }
}


Measured memory_bytes: 24164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int isconnected(int *a, int *b, int N, int M, int without){

	int isvisited[N];
	memset(isvisited, 0, sizeof(int) * N);

	isvisited[0] = 1;

	for(int i = 0; i < M; i++){
		for(int j = 0; j < M; j++){
			if(j == without) continue;
			if(isvisited[a[j]]) isvisited[b[j]] = 1;
			if(isvisited[b[j]]) isvisited[a[j]] = 1;
		}
	}

	for(int i = 0; i < N; i++){
		if(!isvisited[i]){
			return 0;
		}
	}
	return 1;

}

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

	int N, M;
	int *a, *b;

	scanf("%d %d", &N, &M);

	a = malloc(sizeof(int) * M);
	b = malloc(sizeof(int) * M);

	for (int i = 0; i < M; i++){
		scanf("%d %d", a + i, b + i);
		a[i]--; b[i]--;
	}

	int ret = 0;
	for (int i = 0; i < M; i++){
		if(!isconnected(a, b, N, M, i)) ret++;
	}

	printf("%d\n", ret);
	
	free(a);
	free(b);
	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N;
  string S;
  cin >> N >> S;
  vector< int > g[2000];
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  int64 ret = infll;
  for(int i = 0; i < N; i++) {
    vector< int64 > small(N), large(N), cnt(N);
    function< void(int, int) > dfs = [&](int idx, int par) {
      cnt[idx] = S[idx] == '1';
      int64 x = -1, y = -1;
      for(auto &to : g[idx]) {
        if(to == par) continue;
        dfs(to, idx);
        large[idx] += large[to] + cnt[to];
        cnt[idx] += cnt[to];
        if(chmax(x, large[to] + cnt[to])) y = small[to] + cnt[to];
      }
      small[idx] = large[idx];
      int64 other = large[idx] - x;
      int64 base = y;
      if(base <= other) {
        chmin(small[idx], large[idx] % 2);
      } else {
        chmin(small[idx], base - other);
      }
    };
    dfs(i, -1);
    if(small[i] == 0) {
      chmin(ret, large[i] / 2);
    }
  }
  if(ret == infll) cout << -1 << endl;
  else cout << ret << endl;
}







Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include <cmath>


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

using namespace std;

int main(){
    long long N,M,Lmax,Rmin;
    cin >> N >> M;
    vector<long long> L(M),R(M);
    rep(i,M){
        cin >> L[i] >> R[i];
    }
    Lmax = 1;
    Rmin = N;
    rep(i,M){
        if(L[i]>Lmax)Lmax = L[i];
        if(R[i]<Rmin)Rmin = R[i];
    }
    int num;
    if((num = Rmin - Lmax + 1)<0)num =0;
    cout << num << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
int n;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int dp[N],s[N],ans;
void DP(int u,int pre)
{
	int p=0;
	for(int v:E[u])if(v^pre)
	{
		DP(v,u);
		p|=s[u]&s[v];
		s[u]|=s[v];
	}
	while((1<<dp[u])<=p||((1<<dp[u])&s[u]))dp[u]++;
	cmax(ans,dp[u]);
	//cerr<<u<<' '<<s[u]<<endl;
	s[u]=(s[u]>>dp[u]<<dp[u])|(1<<dp[u]);
}
void work()
{
	DP(1,0);
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 12160
//Swapping two number

#include<stdio.h>

int main(void)
{
    int x,y,tmp;

    while(1)
    {
        scanf("%d%d",&x,&y);
        if(x>y)
        {
            tmp=x; x=y; y=tmp;
        }
        if(x==0&&y==0) break;

        printf("%d %d\n",x,y);
    }

    return 0;
}


Measured memory_bytes: 1920
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>
using namespace std;



int main()
{



     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

     
ll a,b;
cin>>a>>b;
if(a>=10||b>=10)
{
	cout<<-1<<endl;
}
else
{
	cout<<a*b<<endl;
}





    ///////////////////////////////////////////////////////////////////////////////////////

     return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    rep(i,n) {
        if (i+1 < n) dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
        if (i+2 < n) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

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


void solve(std::string S, std::string T, long long A, long long B, std::string U){
    if(S == U) A -= 1;
    else B -= 1;
    cout << A << " " << B << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 3696