akhauriyash/Code-Regression huggingface dataset:
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 1010101
void build(){
}
int n , dp[ N ] , ps[ N ];
void init(){
  n = getint();
}
void solve(){
  ps[ 0 ] = dp[ 0 ] = 1;
  ps[ 1 ] = dp[ 1 ] = n;
  ps[ 1 ] = add( ps[ 1 ] , ps[ 0 ] );
  for( int i = 2 ; i <= n ; i ++ ){
    dp[ i ] = dp[ i - 1 ];
    dp[ i ] = add( dp[ i ] , mul( n - 1 , n - 1 ) );
    LL lft = i - 3 , rgt = i - 1 - n;
    if( lft >= 0 ){
      dp[ i ] = add( dp[ i ] , ps[ lft ] );
      dp[ i ] = add( dp[ i ] , -rgt );
    }else
      dp[ i ] = add( dp[ i ] , lft - rgt + 1 );
    ps[ i ] = add( ps[ i - 1 ] , dp[ i ] );
  }
  printf( "%d\n" , dp[ n ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 8064
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
#define inf 20021225
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
map<int,int> f; int n,k;
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int calc(int x)
{
	if(f.find(x)!=f.end())	return f[x];
	int tmp=ksm(k,x+1>>1);
	for(int i=1;i*i<=x;i++)	if(x%i==0)
	{
		if(i!=x)	upd(tmp,mdn-calc(i));
		if(i!=x/i&&x/i!=x)	upd(tmp,mdn-calc(x/i));
	}
	return f[x]=tmp;
}
int odd,even;
int main()
{
	n=read(),k=read();
	for(int i=1;i*i<=n;i++)	if(n%i==0)
	{
		int w=i;
		if(w&1)	upd(odd,1ll*w*calc(w)%mdn); else	upd(even,1ll*w*calc(w)%mdn);
		w=n/i; if(w==i)	continue;
		if(w&1)	upd(odd,1ll*w*calc(w)%mdn); else	upd(even,1ll*w*calc(w)%mdn);
	}
	even=500000004ll*even%mdn;
	printf("%d\n",(odd+even)%mdn);
	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict, deque

# 入力・隣接リスト作成
n,m = li()
graph = defaultdict(set)
geta = pow(10,7)

for _ in range(m):
    p,q,c = li()
    
    graph[p + c*geta].add(q + c*geta)
    graph[q + c*geta].add(p + c*geta)
    
    graph[p + c*geta].add(p)
    graph[q + c*geta].add(q)
    
    graph[p].add(p + c*geta)
    graph[q].add(q + c*geta)
    
que = deque()
que.append((0, 1))
visited = set()

ans = -1

while que:
    (cost, node) = que.popleft()
    
    if node in visited:
        continue
    
    elif node % geta == n:
        ans = cost
        break
    
    visited.add(node)
    
    
    for nex in graph[node]:
        if nex in visited:
            continue
        
        elif node <= n and nex > n:
            que.append((cost+1, nex))
            
        else:
            que.appendleft((cost, nex))
    
print(ans)

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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i =0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> dp(n, 99999999999);
    dp[0] = 0;
    for(ll i = 1; i < n; i++){
        for(ll j = 1; j <= k; j++){
            if(i - j >= 0)  dp[i] = min(dp[i], dp[i - j] + abs(a[i - j] - a[i]));
            else break;
        }
        
    }
    cout << dp[n -1] << endl;
}

Measured memory_bytes: 1792
import sys
from collections import Counter

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
l = []
for _ in range(H):
    l.extend(list(rs()))

c = Counter(l)
count = W//2 * H
pair = 0
four = 0
for x in c.values():
    four += x // 4
    pair += x // 2

f = H // 2 * (W // 2)
if f > four:
    print('No')
    exit()

pair -= f * 2 #残りのペア
p = W // 2 if H&1 else 0
p += H // 2 if W&1 else 0
if p > pair:
    print('No')
    exit()

print('Yes')
# 16

Measured memory_bytes: 3444
n = int(input())
a = list(map(int, input().split()))
o = 0
t = 0
f = 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
    else:
        o += 1
if t > 0:
    print("Yes" if f >= o else "No")
else:
    print("Yes" if f >= o - 1 else "No")

Measured memory_bytes: 15020
#include<cctype>
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    string s;
    getline(cin, s);
    
    string out_s = "";
    for (int i = 0; i < s.length(); i++) {
        if(isalpha(s[i]) && islower(s[i])) {
            out_s += toupper(s[i]);
        } else if (isalpha(s[i]) && isupper(s[i])) {
            out_s += tolower(s[i]);
        } else {
            out_s += s[i];
        }
    }
    
    cout << out_s << endl;
    
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#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 SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n, col[MAX_N];
vector<vector<P> > g;

void dfs(int now){
    for(auto e : g[now]){
        int to = e.first, w = e.second, c;
        c = col[now] ^ (w%2);
        if(col[to] == -1){
            col[to] = c;
            dfs(to);
        }
    }
}

int main() {
    cin >> n;
    g.resize(n);
    REP(i,n-1){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    fill(col, col+n, -1);
    col[0] = 0;
    dfs(0);
    REP(i,n){
        cout << col[i] << endl;
    }
    return 0;
}

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


int main()
{
    vector <int> s(13,0);
    vector <int> h(13,0);
    vector <int> c(13,0);
    vector <int> d(13,0);


    int a,k,n,nm,sum=0;
    char g;

    cin >> n;

    for(int i=0; i<n; i++)
    {
        cin >> g >> a;

        if(g=='S')
            s[a-1]=a;
        else if(g=='H')
            h[a-1]=a;
        else if(g=='C')
            c[a-1]=a;
        else if(g=='D')
            d[a-1]=a;



    }




    for(int i=0; i<13; i++)
    {

  if(s[i]==0)
    cout << 'S' << " " << i+1 << endl;

    }

    //cout << endl;

    for(int i=0; i<13; i++)
    {
  if(h[i]==0)
    cout << 'H' << " " << i+1 << endl;
    }

    // cout << endl;

    for(int i=0; i<13; i++)
    {
  if(c[i]==0)
    cout << 'C' << " " << i+1 << endl;
    }

    // cout << endl;

    for(int i=0; i<13; i++)
    {
   if(d[i]==0)
    cout << 'D' << " " << i+1 << endl;
    }



    return 0;
}


Measured memory_bytes: 3088
import unittest
import functools


class TestE(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 3, 4]), 13)

    def test_2(self):
        self.assertEqual(think([12, 12, 12, 12, 12]), 5)

    def test_3(self):
        self.assertEqual(think([1000000, 999999, 999998]), 996989508)

    def test_4(self):
        self.assertEqual(gcd(3, 2), 1)


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    mode = 10 ** 9 + 7

    lcm_of_all_a = functools.reduce(lambda x, y: lcm(x, y), a, 1)
    lcm_of_all_a %= mode

    b = map(lambda x: lcm_of_all_a * inverse(x, mode) % mode, a)
    return sum(b) % mode


def write(result):
    print(result)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def gcd(a, b):
    if a < b:
        return gcd(b, a)

    while True:
        if a % b == 0:
            return b
        a, b = b, a % b


def inverse(x, mode):
    return pow(x, mode - 2, mode)


if __name__ == '__main__':
    # unittest.main()
    solve()

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

string s;
vector< char >q;

void rec(int pos = 1, int cur = s[0] - '0'){
    if(pos == s.size()){
        if(cur==7){
            cout << s[0];
            for(int i = 1; i < s.size(); i++){
                cout << q[i - 1] << s[i];
            }
            cout << "=7";
            exit(0);
        }
        return;
    }
    q.push_back('+');
    rec(pos + 1, cur + (s[pos] - '0'));
    q.pop_back();
    q.push_back('-');
    rec(pos + 1, cur - (s[pos] - '0'));
    q.pop_back();
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s;
    rec();
}


Measured memory_bytes: 256
N = int(input())
lsB = list(map(int,input().split()))

lsA = [0]*N
lsA[0] = lsB[0]
lsA[N-1] = lsB[N-2]
for i in range(1,N-1):
    lsA[i] = min(lsB[i-1],lsB[i])
print(sum(lsA))

Measured memory_bytes: 61868
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(a []int) int {
	min := a[0]
	for _, i := range a {
		if i < min {
			min = i
		}
	}
	return min
}

func main() {
	var a []int

	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}

	var ans = -1

	for i := 0; ; i++ {
		for j := 0; j < len(a); j++ {
			if a[j]%2 == 1 {
				ans = i
				break
			}
			a[j] = a[j] / 2
		}
		if ans != -1 {
			break
		}
		// fmt.Printf("%v %v\n", i, a)
	}
	fmt.Printf("%v\n", ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

map<ll,ll> pfmp; //各素因数の指数を格納
vector<ll> pfv(0); //異なる素因数を列挙

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit() {
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n,int k){
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

void PF(ll N){
  ll n=N;
  if(n%2==0) pfv.push_back(2);
  while(n%2==0){
    n/=2;
    pfmp[2]++;
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0) pfv.push_back(i);
    while(n%i==0){
      n/=i;
      pfmp[i]++;
    }
  }
  if(n!=1){
    pfv.push_back(n);
    pfmp[n]++;
  }
}

int main(){
  COMinit();
  ll N,M;
  cin >> N >> M;
  PF(M);
  ll ans=1;
  rep(i,pfv.size()){
    ans=ans*COM(pfmp[pfv[i]]+N-1,N-1)%MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

const int N=100005;
int n,m,fa[N],cnt[N];
LL sum[N];

struct edge{
    int u,v,w;

    bool operator <(const edge &b) const{
        return w<b.w;
    }
} ed[N];

int Find(int x){
    if(fa[x]==x)return x;
    int y=Find(fa[x]);
    sum[y]+=sum[x];
    cnt[y]+=cnt[x];
    sum[x]=cnt[x]=0;
    return fa[x]=y;
}

int main(){
    cin>>n>>m;
    rep(i,1,n){
        cin>>sum[i];
        fa[i]=i;
        cnt[i]=0;
    }
    rep(i,1,m)
        cin>>ed[i].u>>ed[i].v>>ed[i].w;
    sort(ed+1,ed+m+1);
    int ans=0;
    rep(i,1,m){
        int u=Find(ed[i].u),v=Find(ed[i].v);
        if(u!=v){
            fa[u]=v;
            sum[v]+=sum[u];
            cnt[v]+=cnt[u]+1;
            cnt[u]=sum[u]=0;
            if(sum[v]>=ed[i].w){
                ans+=cnt[v];
                cnt[v]=0;
            }
        }else{
            ++cnt[u];
            if(sum[u]>=ed[i].w){
                ans+=cnt[u];
                cnt[u]=0;
            }
        }
    }
    cout<<m-ans<<endl;
    return 0;
}


Measured memory_bytes: 3072
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int N;
    cin >> N;
    int n2, n4, odd;
    n2 = n4 = odd = 0;
    rep(i, N)
    {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0)
        {
            n4++;
        }
        else if (tmp % 2 == 0)
        {
            n2++;
        }
        else
        {
            odd++;
        }
    }
    if (n2 != 0)
    {
        odd++;
    }
    if (odd - 1 <= n4)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.printf("%d %d %.9f\n", a / b, a % b, 1.0 * a / b);
	}
}

Measured memory_bytes: 26328
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
s = []
for _ in range(m):
    s.append(na()[1:])
p = na()
ans = 0
for switch in itertools.product([0,1], repeat=n):
    flag = True
    for si, pi in zip(s, p):
        c = sum(switch[i-1] for i in si)
        if c % 2 != pi:
            flag = False
            break
    if flag == True:
        ans += 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = map(int, input().split())
B = list(A_i - (i + 1) for i, A_i in enumerate(A))
B_sorted = sorted(B)

ans = []
##中央値のインデックスmを求める
if N % 2 == 1:
    ##Nが奇数: 中央値のインデックスを求める
    m = int((N - 1) / 2 + 1) - 1
    b = B_sorted[m]
    ans += [sum(abs(x - b) for x in B_sorted)]
else:
    ##Nが偶数: 中央値を計算する元になる2数のインデックスを求める
    for m in range(int(N / 2) - 1, int(N / 2) + 1):
        b = B_sorted[m]
        ans += [sum(abs(x - b) for x in B_sorted)]    
print(min(ans))

Measured memory_bytes: 26180
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;

  int c = a * b;
  if(c % 2 == 0){
    cout << "Even" << endl;    
  } else {
    cout << "Odd" << endl;
  }
}

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


class UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    UnionFind(int n){
        init(n);
    }
    void init(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
        rank.assign(n, 0);
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

struct edge{
    int u, v, c;
    edge(int u, int v, int c) : u(u), v(v), c(c) {}
    bool operator<(const edge& right) const {
        return c < right.c;
    }
};

int N, M;
vector<vector<edge>> G;
vector<bool> used;
vector<bool> alive;

void dfs(int v){
    used[v] = true;
    for(edge& e : G[v]){
        if(!used[e.v] && alive[e.v]) dfs(e.v);
    }
}

bool is_connect(){
    used.assign(N, false);
    for(int i=0;i<N;i++){
        if(alive[i]){
            dfs(i);
            break;
        }
    }
    for(int i=0;i<N;i++){
        if(alive[i] && !used[i]){
            return false;
        }
    }
    return true;
}

int main(){
    while(true){
        cin >> N >> M;
        if(N == 0) break;

        vector<P> h(N);
        for(int i=0;i<N;i++){
            cin >> h[i].first;
            h[i].second = i;
        }
        vector<edge> edges;
        G.assign(N, {});
        for(int i=0;i<M;i++){
            int u, v, c;
            cin >> u >> v >> c;
            u--; v--;
            G[u].emplace_back(u, v, c);
            G[v].emplace_back(v, u, c);
            edges.emplace_back(u, v, c);
        }

        sort(h.begin(), h.end());
        alive.assign(N, true);
        if(!is_connect()){
            cout << 0 << endl;
            continue;
        }

        int k = 0;
        for(;k<N;k++){
            alive[h[k].second] = false;
            if(!is_connect()) break;
        }

        alive.assign(N, false);
        for(int i=k+1;i<N;i++){
            alive[h[i].second] = true;
        }

        sort(edges.begin(), edges.end());
        UnionFind uf(N);
        int ans = 0;
        for(int i=min(k, N-1);i>=0;){
            int t = h[i].first;
            while(i >= 0 && h[i].first == t){
                alive[h[i].second] = true;
                i--;
            }
            for(edge& e : edges){
                if(alive[e.u] && alive[e.v] && !uf.same(e.u, e.v)){
                    uf.unite(e.u, e.v);
                    ans += e.c;
                }
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4180
import math

A, B, H, M = map(int, input().split(' '))

long_r = (math.pi * 2 * H / 12) + (math.pi * 2 * M / 720)
short_r = math.pi * 2 * M / 60

sin_l = math.sin(long_r)
cos_l = math.cos(long_r)
sin_s = math.sin(short_r)
cos_s = math.cos(short_r)

yl = sin_l * A
xl = cos_l * A
ys = sin_s * B
xs = cos_s * B

diff = (yl - ys) * (yl - ys) + (xl - xs) * (xl - xs)
print(math.sqrt(diff))


Measured memory_bytes: 9528
#include <iostream>
using namespace std;
int main()
{
	int a[10], i, j;
	for (i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	for (i = 0; i < 5; i++)
	{
		if (a[i] == 0)
		{
			j = i + 1;
			break;
		}
	}
	cout << j << "\n";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
	int a,b[51],cnt=0;
	cin>>a;
	for (int i=0;i<a;i++)
		cin>>b[i];
	for (int i=0;i<a;i++)
		for (int n=i+1;n<a;n++)
			cnt+=b[i]*b[n];
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
//    freopen("f.in","r",stdin);
//    freopen("f.out","w",stdout);
    int d,n,i=0,nr=0;
    scanf("%d%d",&d,&n);
    while(nr<n)
    {
        i++;
        if(!d&&i%100)
            nr++;
        if(d==1&&i%100==0&&i%10000)
            nr++;
        if(d==2&&i%100==0&&i%10000==0&&i%1000000)
            nr++;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int a,b;
int main(){
    read(a),read(b);
    if ((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b+1)/2<<endl;
    return 0;
}*/
string s,t;
int main(){
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));
    if (s<t) puts("Yes");
    else puts("No");
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int allxor = 0;
  rep(i, n) {
    cin >> a[i];
    allxor = allxor ^ a[i];
  }
  rep(i, n) {
    if (i == n - 1) cout << (allxor ^ a[i]) << endl;
    else cout << (allxor ^ a[i]) << " ";
  }

  return 0;
}


Measured memory_bytes: 4020
def into_lan(s,n):
	ch = s[0]
	res = 0
	for i in range(1,n):
		if(s[i] != ch):
			res = res + 1
		ch = s[i]
	return res + 1

n = int(input())
body = input()
print(into_lan(body,n))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string S;
  cin >> S;
  int ans;
  if(S == "SUN"){
    ans = 7;
  }else if(S == "MON"){
    ans = 6;
  }else if(S == "TUE"){
    ans = 5;
  }else if(S == "WED"){
    ans = 4;
  }else if(S == "THU"){
    ans = 3;
  }else if(S == "FRI"){
    ans = 2;
  }else if(S == "SAT"){
    ans = 1;
  }

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


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

ll rec(ll h) {
    if (h == 1) return 1;
    return 2 * rec(h / 2) + 1;
}

void solve() {
    ll H;
    cin >> H;
    cout << rec(H) << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
// 2011/08/09 Tazoe

#include <iostream>
using namespace std;

long long GCD(long long m, long long n)
{
	if(n>m){
		long long tmp = m;
		m = n;
		n = tmp;
	}

	if(n==0)
		return m;

	while(true){
		if(m%n==0)
			return n;

		long long tmp = m%n;
		m = n;
		n = tmp;
	}
}

long long LCM(long long m, long long n)
{
	return (m/GCD(m, n))*n;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

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

		// v/dªüñ^ÔÆÈé

		// ñª
		for(int i=0; i<n; i++){
			long long gcd = GCD(d[i], v[i]);
			d[i] /= gcd;
			v[i] /= gcd;
		}

		// dÌÅ¬ö{
		long long D = LCM(d[0], d[1]);
		for(int i=2; i<n; i++)
			D = LCM(D, d[i]);

		// üñÌ®»
		long long r[10];
		for(int i=0; i<n; i++)
			r[i] = v[i]*(D/d[i]);

		// rÌÅåöñ
		long long R = GCD(r[0], r[1]);
		for(int i=2; i<n; i++)
			R = GCD(R, r[i]);

		for(int i=0; i<n; i++)
			cout << r[i]/R << endl;
	}

	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string S = RString();
        if (S.Last() == 's')
        {
            S.Remove(S.Length - 1);
            S = S + "es";
        }
        else
        {
            S += "s";
        }
        WriteLine(S);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


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

int N, M;

int main() {
	cin >> N >> M;
	int n[N] = {};
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		++n[a - 1], ++n[b - 1];
	}
	for (int i = 0; i < N; ++i)
		cout << n[i] << '\n';
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key) x = x->left;
      else x = x->right;
    }

  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;


}

void inorder(Node u){

  if(u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
  
}

void preorder(Node u){

  if(u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }

 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main(){
  int k;cin>>k;
  cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    string s; cin >> s;
    vector<int> a(4, 0);
    rep(i, s.size()){
        if(s[i] == 'N')a[0]++;
        else if(s[i] == 'S')a[1]++;
        else if(s[i] == 'W')a[2]++;
        else if(s[i] == 'E')a[3]++;
    }
    if(a[0] > 0 && a[1] > 0 && a[2] > 0 && a[3] > 0){
        cout << "Yes" << endl;
    }else if(a[0] > 0 && a[1] > 0 && a[2] == 0 && a[3] == 0){
        cout << "Yes" << endl;
    }else if(a[0] == 0 && a[1] == 0 && a[2] > 0 && a[3] > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);
 
using namespace std;
const int N = 1E5+7;
const long long INF = 1E18;
 
long long f[N][4];
long long a[N], b[N], c[N];
int n;
 
int main()
{
    fastIO;
    cin>>n;
    
    for (int i = 1;i <= n;++i) cin>>a[i]>>b[i]>>c[i];
    

    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= 3;++j)
        {
            if (j == 1) f[i][j] = max(f[i][j],max(f[i-1][j+1]+a[i],f[i-1][j+2]+a[i]));
            if (j == 2) f[i][j] = max(f[i][j],max(f[i-1][j-1]+b[i],f[i-1][j+1]+b[i]));
            if (j == 3) f[i][j] = max(f[i][j],max(f[i-1][j-1]+c[i],f[i-1][j-2]+c[i]));
        }
    
    long long res = -INF;
    for (int i = 1;i <= 3;++i) res = max(res,f[n][i]);
    
    cout<<res;
}

Measured memory_bytes: 9084
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

constexpr int INF = 1e9+1;
struct Graph {
  vector<vector<int>> edge;
  Graph(int n = 0) { resize(n); }
  void resize(int n) {
    edge.resize(n, vector<int>());
  }
  void addEdge(int from, int to) {
    edge[from].push_back(to); edge[to].push_back(from);
  }
  vector<int>& operator[](int from) { return edge[from]; }
};

vi ans, A;
void dfs(Graph &G, vi &lis, int cur, int prev) {
  auto it = all(lower_bound, lis, A[cur]);
  int before = *it;
  *it = A[cur];
  ans[cur] = (int)(all(lower_bound, lis, INF) - lis.begin())-1;
  for (const auto& to:G[cur]) {
    if (to == prev)
      continue;
    dfs(G, lis, to, cur);
  }
  *it = before;
}

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

  A.resize(N);
  ans.resize(N, -1);
  Graph G(N);
  rep(i, N) cin >> A[i];
  rep(i, N-1) {
    int u, v; ins(u, v); --u, --v;
    G.addEdge(u, v);
  }
  vi lis(N+1, INF); lis[0] = -INF;
  dfs(G, lis, 0, -1);
  rep(i, N)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 30852
N,Q = map(int,input().split())
S = list(input())
R = [0]*N
ans = []
temp = 0
for i in range(1,N):
  if S[i-1] == 'A' and S[i] == 'C':
    temp += 1
  R[i] = temp
for k in range(Q):
  l,r = map(int,input().split())
  ans.append(R[r-1]-R[l-1])
for j in range(len(ans)):
  print(ans[j])

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

int n, k;
int v[50];

signed main() {
  cin >> n >> k;
  rep(i,n) cin >> v[i];

  int ans = 0;

  for (int a=0; a<=min(n,k); a++ ) 
    for(int b=0; b<=min(n,k) - a; b++)
      for(int cd=0; cd<=min(a+b, k-a-b); cd++)
      {
        //cerr << a + b + cd << ": " << a << " " << b << " " << cd << endl;
        multiset<int> s;
        int sum = 0;
        for(int i=0; i<a; i++) {
          sum += v[i];
          s.insert(v[i]);
        }
        for(int i=n-1; i>=n-b; i--) {
          sum += v[i];
          s.insert(v[i]);
        }
        rep(i, cd) {
          int m = *s.begin();
          sum -= m;
          s.erase(m);
        }
        ans = max(ans ,sum);
      }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  ll cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  cout << s << '\n';
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

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


ll searchMax(ll c[], ll sd[], ll picked[]){
    ll max = -1;
    REP(i, 26){
        if(picked[i] == 1){
            if(max < sd[i] + c[i]){
                max = i;
            }
        }else{
            if(max < sd[i]){
                max = i;
            }
        }
    }

    return max;
}

int main(){
    // input
    ll D;
    cin >> D;

    ll c[27];
    ll s[D + 1][27];
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }

    // preparation
    ll t[D + 1];
    ll picked[27];

    // main
    REP(i, D){
        t[i] = searchMax(c, s[i], picked);
        picked[t[i]] = 1;
    }

    // output
    REP(i, D){
        cout << t[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>

int main()
{
	char a[4];
	for(int i=0;i<4;i++){
		scanf("%c",&a[i]);
	}
	int c=0;
	for(int i=0;i<4;i++){
		if(a[i]=='+'){
			c++;
		}
		else{
			c--;
		}
	}
	printf("%d",c);


	return 0;
}

Measured memory_bytes: 128
# ABC167 B

def main():
    a, b, c, k = map(int, input().split())
    total = 0

    if a >= k:
        print(k)
    elif a+b >= k:
        print(a)
    else:
        print(a - (k - a - b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 8976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define int long long
 
int n;
vector<pair<int, int>> v;
bool is[55];
 
main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
	int ans = n;
	sort(v.begin(), v.end());
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int p = v[j].first - v[i].first, q = v[j].second - v[i].second;
			for (int z = 0; z < n; ++z) is[z] = 0;
			int cur = 0;
			for (int z = 0; z < n; ++z) {
				cur += !is[z];
				is[z] = 1;
				for (int g = 0; g < n; ++g) {
					if (is[g]) continue;
					if (((v[z].first - v[g].first) == p && (v[z].second - v[g].second) == q) || ((v[z].first - v[g].first) == -p && (v[z].second - v[g].second) == -q)) is[g] = 1;
				}
			}
			ans = min(ans, cur);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
a=[0]*26
w='abcdefghijklmnopqrstuvwxyz'
try:
    while True:
        s=list(input().upper())
        for i in s:
            if i=='A':
                a[0]+=1
            elif i=='B':
                a[1]+=1
            elif i=='C':
                a[2]+=1
            elif i=='D':
                a[3]+=1
            elif i=='E':
                a[4]+=1
            elif i=='F':
                a[5]+=1
            elif i=='G':
                a[6]+=1
            elif i=='H':
                a[7]+=1
            elif i=='I':
                a[8]+=1
            elif i=='J':
                a[9]+=1
            elif i=='K':
                a[10]+=1
            elif i=='L':
                a[11]+=1
            elif i=='M':
                a[12]+=1
            elif i=='N':
                a[13]+=1
            elif i=='O':
                a[14]+=1
            elif i=='P':
                a[15]+=1
            elif i=='Q':
                a[16]+=1
            elif i=='R':
                a[17]+=1
            elif i=='S':
                a[18]+=1
            elif i=='T':
                a[19]+=1
            elif i=='U':
                a[20]+=1
            elif i=='V':
                a[21]+=1
            elif i=='W':
                a[22]+=1
            elif i=='X':
                a[23]+=1
            elif i=='Y':
                a[24]+=1
            elif i=='Z':
                a[25]+=1 

except EOFError:
    pass

for i in range(26):
    print(w[i:i+1], ':', str(a[i]))

Measured memory_bytes: 7560
#include <iostream>
#include <algorithm>
#include <vector>
#define MAX_N 100000
using namespace std;

long long par[MAX_N];
int size[MAX_N];

void init(long long n) {
  for(int i=0;i<n;i++) {
    par[i] = i;
    size[i] = 1;
  }
}

// rootを返す
long long find(long long x) {
  if(par[x] == x) {
    return x;
  }
  long long root = find(par[x]);
  par[x] = root;
  return root;
}

void unite(long long x, long long y) {
  // 親どうし
  long long root_x = find(x);
  long long root_y = find(y);
  if (root_x == root_y) {
    return;
  }
  par[root_y] = root_x;
  size[root_x] += size[root_y];
}

bool same(long long x, long long y) {
  return find(x) == find(y);
}

long long size_tree(long long x) {
  return size[find(x)];
}
/*
 * n 島の数 
 * m 橋の数
 * a[i] - b[i];
 */
vector<long long> decayed_bridges(long long n, long long m, long long a[], long long b[]) {
  init(n);
  vector<long long> answer;
  answer.push_back((n * (n-1)) / 2);
  for(int i=m-1;i>=1;i--) {
    int aa = a[i] - 1;
    int bb = b[i] - 1;
    long long last = answer[answer.size() - 1];
    if(same(aa, bb)) {
      answer.push_back(last);
      continue;
    }
    answer.push_back(last - size_tree(aa) * size_tree(bb));
    unite(aa, bb);
  }
  reverse(answer.begin(), answer.end());
  return answer;
}

int main() {
  long long n, m;
  cin >> n;
  cin >> m;
  long long a[m];
  long long b[m];
  for(int i=0;i<m;i++) {
    cin >> a[i];
    cin >> b[i];
  }
  vector<long long> answer = decayed_bridges(n, m, a, b);
  for(int i=0;i<answer.size();i++) {
    cout << answer[i];
    if(i != answer.size())
      cout << endl;
  }
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> l(n * 2);
    for(int i = 0; i < n * 2; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = n * 2 - 2; i >= 0; i -= 2)
        ans += l[i];
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long long ld;


#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    string s = "";
    int n; cin >> n;
    for(int i = 0; i < 2e6; i++){
        s += '7';
    }
    int res = 0;
    int cnt = 0;
    for(int i = 0; i < 2e6; i++){
        res = (res*10 + (int)s[i] - '0')%n;
        cnt++;
        if(res == 0)break;
    }
    if(cnt == 2e6)cnt = -1;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    reverse(s.begin(), s.end());

    vector<int> ans;

    int itr = 0;
    while(1){
        //cout << itr << endl;
        if ((itr + m) >= n){
            ans.push_back(n - itr);
            break;
        } 
        bool gameover = true;
        for (int i = m; i > 0; i--)
        {
            if (s[itr + i] == '0'){
                ans.push_back(i);
                itr += i;
                gameover = false;
                break;
            }
        }
        
        if (gameover == true){
            cout << "-1" << endl;
            return 0;
        }

    }

    reverse(ans.begin(), ans.end());

    show(ans);
}

Measured memory_bytes: 1144
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	int n = ri();
	
	int mod = 1;
	FOR(i,9)mod*=10;
	mod += 7;
	
	int res = 1;
	FOR(i,n) {
		u64 tmp_ = ((u64)res) * (i+1);
		res = tmp_ % mod;
	}
	
	wi(res);
	
	return 0;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
 	int n, x, t;
 	
 	cin >> n >> x >> t;

 	int ans = 0;
 	int a = 0;
 	while(a < n){
 		a += x;
 		ans += t;
 	}   

 	cout << ans ;
    
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code
int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	VL a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	VL dp(n+1,0);
	if (m > 0) {
		if (a[0] != 0) {
			dp[0] = 1;
		}
		if (!binary_search(ALL(a),1)) {
			dp[1] = 1;
		}
	}
	else {
		dp[0] = 1;
		dp[1] = 1;
	}
	if (n == 1) {
		cout << dp[1] << endl;
		return 0;
	}
	for (int i = 2; i < n+1; i++) {
		if (!binary_search(ALL(a),i)) {
			dp[i] = dp[i-1] + dp[i-2];
			dp[i] %= MOD;
		}
		else {
			dp[i] = 0;
		}
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int max = sc.nextInt();

        for (int i = 0; i < n - 1; i++) {
            int now = sc.nextInt();
            if (max - 1 > now) {
                System.out.println("No");
                return;
            } else if (now > max) {
                max = now;
            }
        }

        System.out.println("Yes");

        sc.close();

    }

}

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  if (A > 8 || B > 8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int i,n,m;
    for(i=0;i<3000;i++){
        std::cin>> n>> m;
        if(n==0&&m==0) break;
        if(n>=m){
            std::cout<< m<< " "<< n<< std::endl;
        }else{
            std::cout<< n<< " "<< m<< std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160