akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
int n;
void input(vector<char>&, vector<int>&);
void babble(vector<char>, vector<int>, vector<char>, vector<int>);
void selection(vector<char>, vector<int>, vector<char>, vector<int>);
bool check(vector<char>, vector<int>, vector<char>, vector<int>);
int main() {
	bool judge;
	int flag, cnt = 0, at;
	vector<char> ch(37);
	vector<int> num(37);
	
	cin >> n;
	input(ch, num);
	babble(ch, num, ch, num);
	selection(ch, num, ch, num);

	return 0;
}
void input(vector<char> &ch, vector<int> &num) {
	int k=0;
	for (int i = 0; i < n; ++i) {
		cin >> ch[i] >> num[i];
	}
}
void babble(vector<char> ch, vector<int>num, vector<char> a, vector<int>b) {
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; j >= 1; --j) {
			if (num[j] < num[j - 1]) {
				swap(num[j], num[j - 1]);
				swap(ch[j], ch[j - 1]);
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		if (i == n - 1)cout << ch[i] << num[i] << endl;
		else cout << ch[i] << num[i] << " ";
	}
	if (check(ch, num, a, b))cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	return;
}
void selection(vector<char> ch, vector<int>num, vector<char>a, vector<int>b) {
	int min;
	for (int i = 0; i < n; ++i) {
		min = i;
		for (int j = i; j < n; ++j) {
			if (num[j] < num[min])min = j;
		}
		swap(num[i], num[min]);
		swap(ch[i], ch[min]);
	}
	for (int i = 0; i < n; ++i) {
		if (i == n - 1)cout << ch[i] << num[i] << endl;
		else cout << ch[i] << num[i] << " ";
	}
	if (check(ch, num, a, b))cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	return;
}
bool check(vector<char>ch, vector<int>num, vector<char>sc, vector<int>sn) {
	int k,at=0,cnt=0;
     int  br;
	 char u[5];
	for (int i = 1; i <= 13; ++i) {
		k = 0;
		br = 0;
		for (int j = 0; j < n; ++j) {
			if (num[j] == i) {
				if (k == 0) {
					at = j;
				}
				k++;
				br = 1;
			}
			else if (br == 1) break;
		}
		if (k > 1) {
			cnt = 0;
			for (int j =at; j <at+k ; j++) {
				u[cnt] = ch[j];
				cnt++;
			}
			cnt = 0;
			for (int j = 0; j < n; ++j) {
				if (sn[j] == i) {
					if (sc[j] != u[cnt])return false;
					else cnt++;
				}
			}
		}
	}
	return true;
}


Measured memory_bytes: 3140
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i32 = itr.next().unwrap().parse().unwrap();
    let x: i32 = itr.next().unwrap().parse::<i32>().unwrap() - 1;
    let y: i32 = itr.next().unwrap().parse::<i32>().unwrap() - 1;

    let mut ans = vec![0; n as usize];
    for i in 0..n {
        for j in i + 1..n {
            let mut tmp = j - i;
            tmp = std::cmp::min(tmp, (x - i).abs() + 1 + (y - j).abs());
            ans[tmp as usize] += 1;
        }
    }
    let mut out = Vec::new();
    for i in 1..n {
        writeln!(out, "{}", ans[i as usize]).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

void reverse(char s[],int n){
    char ch[101];
    ch[0]=s[n-1];
    for(int i=0;i<n-1;i++)
        ch[i+1]=s[i];
    for(int i=0;i<n;i++)
        s[i] = ch[i] ;
}

int main()
{
    char s[101],t[101];
    int m=0,n=0;
    while((s[m]=getchar())!='\n')
        m++;
    while((t[n]=getchar())!='\n')
        n++;
    int flag=0;
    for(int i=0;i<m;i++){
        int flag1=1;
        reverse(s,m);
        for(int j=0;j<m;j++){
            if(s[j]!=t[j]){
                flag1=0;
                break;
            }
        }
        if(flag1==1){
            flag=1;
            break;
        }
    }
    if(flag==0)
        printf("No");
    if(flag==1)
        printf("Yes");
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb; 

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


int main() {
    ll A,B;
    string S;
    cin >> A >> B >> S;

    if(S[A] != '-'){
        cout << "No" << endl;
        return 0;
    }

    rep(i,A){
        if(S[i] == '-'){
            cout << "No" << endl; 
            return 0;
        }
    }

    for(ll i=A+1;i<S.size();i++){
        if(S[i] == '-'){
            cout << "No" << endl; 
            return 0;
        }
    }

    cout << "Yes" << endl; 


}


Measured memory_bytes: 256
def main():
    n = int(input())
    array = list(map(int, input().split()))
    sum_value = array[-1] + array[0]
    for i in range(n-2):
        sum_value += min(array[i], array[i+1])
        # print(array[i])
    print(sum_value)

if __name__ == "__main__":
    main()


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class ModuloOperator {
 public:
  ll modulo;

  ModuloOperator(ll modulo) {
    this->modulo = modulo;
  }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0)
      ret += modulo;
    else
      ret %= modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= modulo;
    return ret;
  }

  ll div(ll a, ll b) { return mul(a, pow(b, modulo - 2)); }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1LL;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0LL;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

int n;
ll a, b, c;

ll a_div_apb_arr[MAX_N];
ll b_div_apb_arr[MAX_N];

ll ans;

ModuloOperator mo(MOD);

int main(void) {
  // Here your code !
  scanf("%d %lld %lld %lld", &n, &a, &b, &c);

  CombinationModulo cm(n + n + 3);

  ll a_div_apb = mo.div(a, mo.add(a, b));
  ll b_div_apb = mo.div(b, mo.add(a, b));

  ll hund_div_hund_sub_c = mo.div(100LL, mo.sub(100LL, c));

  a_div_apb_arr[0] = 1LL;
  b_div_apb_arr[0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    a_div_apb_arr[i] = mo.mul(a_div_apb_arr[i - 1], a_div_apb);
    b_div_apb_arr[i] = mo.mul(b_div_apb_arr[i - 1], b_div_apb);
  }

  ans = 0;

  for (int i = 0; i <= n - 1; ++i) {
    ll combination = cm.comb(n - 1 + i, n - 1);

    ll after_fst = mo.mul(a_div_apb_arr[n], b_div_apb_arr[i]);
    ll after_snd = mo.mul(b_div_apb_arr[n], a_div_apb_arr[i]);
    ll after = mo.add(after_fst, after_snd);

    ll expect_fst = mo.mul(n + i, mo.mul(combination, after));

    ans = mo.add(ans, expect_fst);
  }

  ans = mo.mul(ans, hund_div_hund_sub_c);

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <fstream>
#include <memory.h>
#include <iomanip>
#include <omp.h>
#include <bitset>
#include <string>
#include <list>

using namespace std;

#define right asfdsg
#define left asfdsvs
#define MAXN 1000000000
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define x1 asicvlid
#define y1 ascnsdkn

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n;
int a[101];
multiset < int > s;
int mx = 0;

bool del(int x) {
    if (s.find(x) == s.end()) return false;
    s.erase(s.find(x));
    return true;
}

bool bld () {
    int rast = mx;
    int i = rast;
    while ( i > (rast + 1) / 2 ) {
        for (int k = 0; k < 2; k ++)
            if (!del(i)) return false;
        i --;
    }
    for (int j = 0; j < 1 + (rast & 1); j ++)
        if (!del(i)) return false;
    int mn = (rast + 1) / 2;
    if (s.find(mn) != s.end()) return false;
    return true;
}

int main() {
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
        scanf ("%d", &a[i]),
        mx = max (a[i], mx),
        s.insert (a[i]);
    if (bld ()) cout << "Possible";
    else cout << "Impossible";
    return 0;
}


Measured memory_bytes: 384
N = 8
def readdata():
    x = ""
    while x=="":
        try: x = raw_input()
        except: return []
    for i in range(N-1):
        x += raw_input()
    return x

while True:
    dt = readdata()
    if dt==[]: break
    dt = [i for i,c in enumerate(dt) if c=="1"]
    ptn = [18, 48, 6, 30, 20, 34, 16]
    try: print "ABCDEFG"[ptn.index(sum(dt)-dt[0]*4)]
    except: break

Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge
{
    int v,w,nxt;
}e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w)
{
    e[++ecnt].v = v;
    e[ecnt].w = w;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
int dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st)
{
    que.push(st);
    inq[st] = true;
    dist[st] = 0;
    int curmax = 0,curmin = 0;
    while(!que.empty())
    {
        int u = que.front();
        que.pop();
        for(int i = head[u];i;i = e[i].nxt)
        {
            int v = e[i].v;
            if(dist[v] == 0x3f3f3f3f)
            {
                dist[v] = dist[u] + e[i].w;
                curmax = max(curmax,dist[v]);
                curmin = min(curmin,dist[v]);
                if(curmax - curmin > 1e9)
                    return false;
                vis[v] = 1;
                if(!inq[v])
                    que.push(v);
            }
            else if(dist[v] != dist[u] + e[i].w)
                return false;
        }
        inq[u] = false;
    }
    return true;
}

int main()
{
    memset(dist,0x3f,sizeof(dist));
    scanf("%d%d",&N,&M);
    for(int i = 1;i <= M; ++ i)
    {
        scanf("%d%d%d",&l[i],&r[i],&d[i]);
        adde(l[i],r[i],d[i]);
        adde(r[i],l[i],-d[i]);
    }
    for(int i = 1;i <= N; ++ i)
    {
        if(!vis[i])
        {
            vis[i] = 1;
            if(!spfa(i))
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 8704
#include <stdio.h>
int main()
{
    int a, b;
    b = 1;
    
    while(1){
        scanf("%d", &a);
        if (a == 0){
            break;
        }
    printf("Case %d: %d\n",b,a);
    b++;
    }
    return 0;
}


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

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

int N;
int A[100010];
int Sum[200010];

bool check(int i, int x)
{
    int idx = lower_bound(all(Sum), Sum[i] + x) - begin(Sum);

    if (idx >= i + N) return false;

    int idx2 = lower_bound(all(Sum), Sum[idx] + x) - begin(Sum);

    if (idx2 >= i + N) return false;

    return Sum[i + N] - Sum[idx2] >= x;
}

signed main()
{
    cin >> N;

    rep(i, N) cin >> A[i];

    fill_n(Sum, 200010, 1e16);
    Sum[0] = 0;
    for (int i = 0; i < N; ++i) Sum[i + 1] = A[i] + Sum[i];
    for (int i = 0; i < N; ++i) Sum[N + i + 1] = A[i] + Sum[N + i];

    int ans = 0;

    rep(i, N) {
        int l = 0, r = 1e15+2;

        rep(_, 50) {
            int mid = (l+r)/2;
            if (check(i, mid)) l = mid;
            else r = mid;
        }

        ans = max(ans, l);
    }

    cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,Q;
int C[505050];
int L[505050],R[505050];
const int DI=800;
vector<pair<int,int>> ev[DI];
int ret[505050];
int num[505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) cin>>C[i];
	FOR(i,Q) {
		cin>>L[i]>>R[i];
		L[i]--;
		ev[L[i]/DI].push_back({R[i],i});
	}
	
	FOR(i,DI) {
		ZERO(num);
		int c=0;
		sort(ALL(ev[i]));
		int CL=0,CR=0;
		FORR(e,ev[i]) {
			x=e.second;
			while(CR<R[x]) {
				if(num[C[CR]]==0) c++;
				num[C[CR]]++;
				CR++;
			}
			while(CL<L[x]) {
				num[C[CL]]--;
				if(num[C[CL]]==0) c--;
				CL++;
			}
			while(L[x]<CL) {
				CL--;
				if(num[C[CL]]==0) c++;
				num[C[CL]]++;
			}
			ret[x]=c;
		}
		
	}
	FOR(i,Q) cout<<ret[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 19952
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

    cout << min(a * n, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9+7;
ll binaryExp(ll a, ll b)
{
	ll ans = 1, x = a;
	while(b>0)
	{
		if(b&1)
			ans = (ans*x)%mod;
		x = (x*x)%mod;
		b>>=1;
	}
	return ans;
}
ll invfac(ll n)
{
	return binaryExp(n,mod-2);
}
ll nCr(ll n, ll r)
{
	vector<ll> fact(n+1,1);
	for(ll i = 2; i<=n; i++)
		fact[i] = (i*fact[i-1])%mod;
	return (((fact[n]*invfac(fact[n-r]))%mod)*invfac(fact[r]))%mod;
}

int main()
{
	ll x,y; cin>>x>>y;
	if((x+y)%3!=0)
		cout<<0<<endl;
	else
	{
		
		ll k = (x+y)/3;
		if(k>y||y>2*k)
		{
			cout<<0<<endl;
			return 0;
		}
		ll m = y - k;
		ll n = 2*k - y;
		cout<<nCr(m+n,min(m,n))<<endl;
	}
	return 0;
}


Measured memory_bytes: 5504
x=int(input())
hon=[2,4,5,7,9]
pon=[0,1,6,8]
bon=[3]
if x>99:
  ones=(x%100)%10
elif (x>9) and (x<99):
  ones=x%10
else :
  ones=x

if ones in hon:
  print("hon")
elif ones in pon:
  print("pon")
elif ones in bon:
  print("bon")

Measured memory_bytes: 9080
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = max(max(a + b, a - b), a * b);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {

    while (1){
        int x;
        int static i = 1;
        cin >> x;
        
        if (x == 0){
            break;
        }else{
        cout << "Case " << i << ": " << x << endl;
        }
        
        i++;
    }
    
    
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
char F(char c,int d){return (c-'a'+d)%26+'a';}
int main()
{
	int N,i,a[100],b[100],d,p,q;
	char s[256],t;
	while(scanf("%d%s",&N,s),N)
	{
		for(i=0;i<N;++i)scanf("%d%d",a+i,b+i);
		for(;--i>=0;)
		{
			p=a[i]-1;
			q=b[i]-1;
			d=q-p;
			t=F(s[p],d);
			s[p]=F(s[q],d);
			s[q]=t;
		}
		printf("%s\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
a,b,c = gets.split.map(&:to_i)
d = gets.to_i
for i in 0...d do
  if a>=b
    b *= 2
  elsif b>=c
    c *= 2
  else
    break
  end
end

if a<b&&b<c then
  puts "Yes"
else
  puts "No"
end

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(const T x, const S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

const int MAX_N = 111;
const int MAX_C = 22;
int c, n, m, s, d;
int t, u, f;
struct Edge{int from, to, cost;};
vector<Edge> g[MAX_N];
int l[MAX_N][MAX_C];

int main()
{
  while(cin >> c >> n >> m >> s >> d, c){
    rep(i, n) g[i].clear();
    rep(i, MAX_N) rep(j, MAX_C) l[i][j] = INF;

    rep(i, m){
      cin >> t >> u >> f;
      g[t - 1].pb((Edge){t - 1, u - 1, f});
      g[u - 1].pb((Edge){u - 1, t - 1, f});
    }

    priority_queue<vi, vector<vi>, greater<vi> > que;
    vi tmp(3);
    tmp[0] = 0;      // ?????¢
    tmp[1] = -c;     // ?????°
    tmp[2] = s - 1;  // ??´???
    l[s - 1][c] = 0;
    que.push(tmp);
    while(!que.empty()){
      vi p = que.top();  que.pop();
      int ti = -p[1];
      int v = p[2];
      if(l[v][ti] < p[0]) continue;

      vrep(w, g[v]){
        Edge& e = *w;
        if(l[e.to][ti] > l[v][ti] + e.cost){
          l[e.to][ti] = l[v][ti] + e.cost;
          tmp[0] = l[e.to][ti];
          tmp[1] = -ti;
          tmp[2] = e.to;
          que.push(tmp);
        }
      }

      if(ti > 0) vrep(w, g[v]){
          Edge& e = *w;
          if(l[e.to][ti - 1] > l[v][ti] + e.cost / 2){
            l[e.to][ti - 1] = l[v][ti] + e.cost / 2;
            tmp[0] = l[e.to][ti - 1];
            tmp[1] = -(ti - 1);
            tmp[2] = e.to;
            que.push(tmp);
          }
        }
    }

    int res = INF;
    rep(i, c+1) minup(res, l[d - 1][i]);
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  int k = b - a;
  int right_h = (k * (k+1)) / 2;

  cout << right_h - b << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  double N;
  cin >> N;
  
    int num = int(N / 1.08);
    int num2 = num + 1;
    int num3 = num * 1.08;
    int num4 = num2 * 1.08;
  
    if(num3 == (int)N){
      cout << num << endl;
    }
    else if(num4 == (int)N){
      cout << num2 << endl;
    }
    else{
      cout <<":(" << endl;
    }

  
  
    
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

map<char, int> mp;

int main(void) {
  // Here your code !
  cin >> s;

  for (auto e: s) {
    mp[e] += 1;
  }

  if (mp.size() == 2) {
    bool flg = true;
    for (auto e: mp) {
      flg &= (e.second == 2);
    }

    if (flg) {
      printf("Yes\n");
      return 0;
    }
  
  } 

  printf("No\n");

  return 0;
}


Measured memory_bytes: 256
from collections import deque
it = lambda: list(map(int, input().strip().split()))


def maximise(L, R, cycle):
    cur = 0
    ans = max(cycle)
    queue = deque([0])
    dp = [0] * (2 * L + 1)
    for i, num in enumerate(cycle + cycle):
        j = i + 1
        cur += num
        while queue and j - queue[0] > R:
            queue.popleft()
        if queue:
            ans = max(ans, cur - dp[queue[0]])
        while queue and dp[queue[-1]] >= cur:
            queue.pop()
        queue.append(j)
        dp[j] = cur
    return ans


def get(K, cycle):
    L = len(cycle)
    T = sum(cycle)

    if K > L:
        B = (K - 1) // L
        R = K - B * L
    else:
        B = 0
        R = K
    return max(maximise(L, K, cycle), maximise(L, R, cycle) + max(0, B * T))


def solve():
    # square labelled from 1 to N
    N, K = it()
    P = it()
    C = it()

    for i in range(N):
        P[i] -= 1

    cycles = []
    seen = [False] * N
    for i in range(N):
        if not seen[i]:
            cycle = []
            first = curr = i
            while True:
                seen[curr] = True
                cycle.append(C[curr])
                curr = P[curr]
                if curr == first:
                    break
            cycles.append(cycle)
    
    # print(cycles)
    ans = float('-inf')
    for cycle in cycles:
        ans = max(ans, get(K, cycle))
    return ans


if __name__ == '__main__':
    ans = solve()
    print(ans)

Measured memory_bytes: 10792
import numpy as np
N = input()
As = np.array(input().split(), dtype=int)

# 集計
from collections import defaultdict
d = defaultdict(int)
for a in As:
    d[a] += 1
    
# 全組み合わせ計算
patterns = sum([v * (v - 1) // 2 for v in d.values()])

# 出力
for num in As:
    times = d[num]
    print(patterns - times + 1)

Measured memory_bytes: 33844
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let x: usize = sc.read();

    let mut top = x;
    let mut side = n - x;
    let mut ans = top + side;
    loop {
        if top > side {
            let t = top / side;
            ans += 2 * t * side;
            top %= side;
            if top == 0 {
                ans -= side;
                break;
            }
        } else {
            let t = side / top;
            ans += 2 * t * top;
            side %= top;
            if side == 0 {
                ans -= top;
                break;
            }
        }
    }

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;
	static long INF = Long.MAX_VALUE;

	static long chmin(long a, long b) {
		return Math.min(a, b);
	}

	static long chmax(long a, long b) {
		return Math.max(a, b);
	}

	public static void main(String[] args) {
		// AtCoder_C
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N];

		long DPA[] = new long[N];
		long DPB[] = new long[N];
		long DPC[] = new long[N];

		Arrays.fill(DPA, 0);
		Arrays.fill(DPB, 0);
		Arrays.fill(DPC, 0);

		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			C[i] = sc.nextInt();
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();

		DPA[0] = A[0];
		DPB[0] = B[0];
		DPC[0] = C[0];

		for(int now=1; now<N; now++) {
			DPA[now] = chmax(DPB[now-1]+A[now], DPC[now-1]+A[now]);
			DPB[now] = chmax(DPA[now-1]+B[now], DPC[now-1]+B[now]);
			DPC[now] = chmax(DPA[now-1]+C[now], DPB[now-1]+C[now]);
		}

		// 出力
		System.out.println(chmax(chmax(DPA[N-1],DPB[N-1]),DPC[N-1]));
	}
}

Measured memory_bytes: 63388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string S;
    cin >> S;
    int ans = 0;
    
    for(int i = 0; i < S.size()/2; i++){
        //cout << S[i] << " " << S[S.size() - 1 - i] << "\n";
        if(S[i] != S[S.size() - 1 - i])
            ans++;
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  b = list(int(i) for i in input().split())
  ans = 0
  for i in range(n):
   if a[i]<b[i]:
    ans += a[i]
    b[i] -=a[i]
    ans += min(a[i+1],b[i])
    a[i+1] -= min(a[i+1],b[i])
   else:
    ans += min(a[i],b[i])
    
  print(ans)
solve()

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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n;

  for (n = nil->next; n != nil; n = n->next) {
    if (n->key == key) return n;
  }
  return nil;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  deleteNode(t);
}

void deleteLast(){
  NodePointer n;
  n = nil->prev;
  deleteNode(n);
}

void delete(int key){
  NodePointer n;

  n = listSearch(key);
  if (n != nil) {
    deleteNode(n);
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->prev = nil;
  x->next->prev = x;
  nil->next = x;

}

int main(){
  int n, i;
  int key;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32956
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>

#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int main()
{
        string moji;
        cin >> moji;
        map<char, int> mp;

        for (int i = 0; i < moji.size(); i++)
        {
                mp[moji[i]]++;
        }

        map<char, int>::iterator itr;
        for (itr = mp.begin(); itr != mp.end(); itr++)
        {
                int a = itr->second;
                if (a % 2 != 0)
                {
                        cout << "No" << endl;
                        return 0;
                }
        }

        cout << "Yes" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << ((a+b)%2 == 0 ? "Alice" : "Borys") << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
	int n, color = 0, cool = 0, num;
	cin >> n;
	vector <int> seen(8);
	for (int i = 0; i < n; i++) {
		cin >> num;
		if (num < 3200) {
			seen[num / 400]++;
		}
		else {
			cool++;
		}
	}
	for (int k = 0; k < seen.size(); k++) {
		if (seen[k] !=  0) {
			color++;
		}
	}
	cout << max(color, 1) << " " << color + cool << endl;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c - '0';}


// TODO: write
int main() { 
  int h,n;cin>>h>>n;
  int tmp = 0;
  rep(i,n){
    int a;
    cin>>a;
    tmp += a;
  }
  if(h <= tmp)print("Yes");
  else print("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N, K; //家族の人数と血液型の種類数
    int S[200]; //冷蔵庫にある血液型の血液量
    int B[200][200]; //吸血鬼が使う血液型の血液量

    while(true){
        cin >> N >> K;
        if(N + K == 0) break;

        for(int i = 1; i <= K; i++){
            cin >> S[i];
        }
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= K; j++){
                cin >> B[i][j];
            }
        }
        int cnt = 0;
        for(int i = 1; i <= K; i++){
            int sum = 0;
            for(int j = 1; j <= N; j++){
                sum += B[j][i];
            }
            if(sum <= S[i]) cnt++;
        }
        if(cnt == K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

int n, m, ans;
vector<vector<int>> ver;

void DFS(int node, set<int> Set){
    
    Set.erase(node);

    loop(ver[node].size()){
        int cur = ver[node][i];
        
        if(Set.count(cur)){
            DFS(cur, Set);
        }
    }

    if(Set.size() == 0)
        ans++;
}

int main(){
    MrN;
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    ver.resize(n+1);
    loop(m){
        int a, b;
        cin >> a >> b;
        ver[a].pb(b);
        ver[b].pb(a);
    }

    set<int> s;
    loop(n){
        s.insert(i+1);
    }

    DFS(1, s);
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
from itertools import product

n = int(input())
F = [tuple(map(int,input().split())) for _ in range(n)]
P = [tuple(map(int,input().split())) for _ in range(n)]
ans = -float("inf")

for ptn in product((0, 1), repeat=10):
    if ptn == (0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    tmp = 0
    for i in range(n):
        now = sum([ptn[x] * F[i][x] for x in range(10)])
        tmp += P[i][now]
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 42204
//confirm 0LL and 1LL
//confirm cornercases such as 0
//confirm times of cin < 1^6
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(T n){cout << n << endl;}
template <typename T>
void cosp(T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	string s;
	cin >> s;
	ll lenS = s.length();
	unordered_map<char, ll> ump;
	rep(i, lenS) ump[s[i]]++;

	ll ans = lenS*(lenS-1)/2+1;
	char c = 'a';
	rep(i, 26){
		ll a = ump[c++];
		ans -= a*(a-1)/2;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	_, m := sc.getInt2()
	type city struct {
		p, y, i int
		id      string
	}
	cs := make([]city, m)
	for i := range cs {
		cs[i].p = sc.getInt()
		cs[i].y = sc.getInt()
		cs[i].i = i
	}

	sort.Slice(cs, func(i, j int) bool {
		if cs[i].p == cs[j].p {
			return cs[i].y < cs[j].y
		}
		return cs[i].p < cs[j].p
	})

	prevP := -1
	cnt := 0
	for i, c := range cs {
		cs[i].id = fmt.Sprintf("%06d", c.p)

		if prevP != c.p {
			cnt = 0
		}
		cnt++
		prevP = c.p
		cs[i].id += fmt.Sprintf("%06d", cnt)
	}

	sort.Slice(cs, func(i, j int) bool {
		return cs[i].i < cs[j].i
	})

	for _, c := range cs {
		fmt.Fprintln(wr, c.id)
	}
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
const int x4[] = {1,0,-1,0}, y4[] = {0,-1,0,1};
const int x8[] = {1,1,1,0,-1,-1,-1,0}, y8[] = {1,0,-1,-1,-1,0,1,1};

int main()
{
	int h,w; //�����A��
	cin >> h >> w;
	char c[h][w]; //'#'= �ǁA'.'= ���H 
	int cnt = 0;
	rep(i,h) rep(j,w){
		cin >> c[i][j];
		if(c[i][j] == '#') cnt++;
	}
	int sx = 0,sy = 0,gx = w-1,gy = h-1; //�X�^�[�g�ƃS�[����x�Ay���W

	////////////////////////////////////////////////////////////////////
	int d[h][w]; //�X�^�[�g����̍ŒZ����
	for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) d[i][j] = INF;
	queue<P> que; que.push(P(sx,sy)); d[sy][sx] = 1;
	while(que.size()){
		P p = que.front(); que.pop();
		for(int i = 0; i < 4/*4,8*/; i++){
			int nx = p.first + x4[i]/*4,8*/,ny = p.second + y4[i]/*4,8*/;
			if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
			if(d[ny][nx] != INF || c[ny][nx] == '#') continue;
			que.push(P(nx,ny)); d[ny][nx] = d[p.second][p.first]+1;
		}
	}
	////////////////////////////////////////////////////////////////////

	cout << (d[gy][gx] == INF ? -1 : h*w-cnt-d[gy][gx]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    string ans;
    bool flag=false;
    reverse(all(s));
    for(int i=0; i<s.size();i++){
        ans+=s[i];
        if(ans=="maerd"||ans=="esare"||ans=="resare"||ans=="remaerd"){
            ans.clear();
            flag=true;
        }
    }
    if(ans.size())cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", gcd(a, b));

	return 0;
}


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

#define mod  1000000007
int main()
{
	
   int n; cin>>n;
   long long a[n];
   long long pre[n+2]; long long pre2[n+2],pre3[n+2];
   
   for( int i=0;i<n;i++) cin>>a[i];
   long long sum=0;
   
   for ( int i=0;i<=n;i++) pre[i]=0,pre2[i]=0,pre3[i]=0;
   
    for ( int i=1;i<=n;i++)
    {
    	pre[i]= pre[i-1]+ a[i-1];
    	
    	
	}
	

	
	for( int i=1;i<=n;i++)
	{
		pre2[i]= pre[n]-pre[i];

		
	
		pre2[i]=pre2[i]%mod; 
		a[i-1]= a[i-1]%mod ;
		
	     pre2[i]= pre2[i]*a[i-1];
		 
	    	pre2[i]= pre2[i]%mod;
	}
	
	for( int i=1;i<=n;i++)
	{
		sum= sum + pre2[i];
		sum= sum%mod ;
	}
	
	
   
   
   cout<<sum<<endl;
   
   
			
		

	
	
	
}

Measured memory_bytes: 9864
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
VI vp,e[N],s[N];
int vis[N],cyc[N],inc[N],a[N],pre[N],n,cycnt[N];
ll ret,f[N];
void dfs(int u) {
	vp.pb(u); vis[u]=1;
	for (auto v:e[u]) if (!vis[v]) dfs(v);
}
bool check(VI &v) {
	int c=v[0];
	for (auto u:v) vis[u]=0;
	int m=0;
	while (1) {
		vis[c]=1;
		c=a[c];
		if (vis[c]==1) break;
	}
	int d=c;
	while (1) {
		cyc[m++]=c;
		inc[c]=1;
		c=a[c];
		if (c==d) break;
	}
	for (auto u:v) vis[u]=1;
	if (m==SZ(v)) {
		cycnt[m]++;
		return 1;
	}
	for (auto u:v) {
		if (SZ(s[u])>2) return 0;
		if (SZ(s[u])==2&&!inc[u]) return 0;
	}
	rep(i,0,m) pre[cyc[i]]=cyc[(i+m-1)%m];
	rep(i,0,m) {
		int u=cyc[i];
		if (SZ(s[u])==1) continue;
		int nbr=(s[u][0]==pre[u])?s[u][1]:s[u][0];
		VI chain; chain.pb(nbr);
		while (1) {
			if (SZ(s[nbr])==0) break;
			assert(SZ(s[nbr])==1);
			nbr=s[nbr][0];
			chain.pb(nbr);
		}
		bool v1=1,v2=1; nbr=pre[u];
		rep(j,0,SZ(chain)-1) {
			if (SZ(s[nbr])==2) v1=0,v2=0;
			nbr=pre[nbr];
		}
		if (SZ(s[nbr])==2) v2=0;
		if (v1==0) return 0;
		if (v2==1) ret=ret*2%mod;
	}
	return 1;
}

ll fac[N],fnv[N];
ll comb(int x,int y) {
	return fac[x]*fnv[y]%mod*fnv[x-y]%mod;
}
int main() {
	ret=1;
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%d",a+i);
	fac[0]=fnv[0]=1;
	rep(i,1,n+1) fac[i]=fac[i-1]*i%mod,fnv[i]=powmod(fac[i],mod-2);
	rep(i,1,n+1) {
		e[i].pb(a[i]); e[a[i]].pb(i);
		s[a[i]].pb(i);
	}
	rep(i,1,n+1) if (!vis[i]) {
		vp.clear();
		dfs(i);
		if (!check(vp)) {
			puts("0");
			return 0;
		}
	}
	// deal with cycle
	f[0]=1;
	rep(i,1,n+1) f[i]=f[i-1]*(2*i-1)%mod;
	rep(i,1,n+1) if (cycnt[i]!=0) {
		ll r=0;
		for (int j=0;2*j<=cycnt[i];j++) {
			r=(r+comb(cycnt[i],2*j)*f[j]%mod*powmod(i,j)%mod*powmod((i%2==1&&i!=1)?2:1,cycnt[i]-2*j))%mod;
		}
		ret=ret*r%mod;
	}
	printf("%lld\n",ret);
}



Measured memory_bytes: 20732
a,b = (int(i) for i in input().split())
print(100,100)
x,y = a-1,b-1
for i in range(50):
	if i%2==0:
		if x>=50:
			print("#."*50)
			x -= 50
		else:
			print("#."*x+"#"*(100-2*x))
			x = 0
	else: print("#"*100)
for i in range(50):
	if i%2==1:
		if y>=50:
			print(".#"*50)
			y -= 50
		else:
			print(".#"*y+"."*(100-2*y))
			y = 0
	else: print("."*100)

Measured memory_bytes: 3064