akhauriyash/Code-Regression huggingface dataset:
import sys

N, K = map(int, input().strip().split(' '))
S = input().strip()
prev = ''
l = 0
lst = []
for s in S:
    if s == prev:
        l += 1
    else:
        lst += [l]
        l = 1
    prev = s
lst += [l]
lst = lst[1:]
# print(lst)

flip = S[0] == '1'
res = sum(lst[0:2*K+flip])
cur = res
# print(cur)
flip ^ - 1
for i in range(1, len(lst)):
    cur -= lst[i-1]
    if not flip:
        cur += sum(lst[i+2*K-1:i+2*K+1])
        res = max(cur, res)
        # print(lst[i+2*K:i+2*K+2])
    # res = max(res, sum(lst[i:i+2*K+flip]))
    # print(cur)
    flip ^= 1

# print(N, K)
# print(S)
print(res)

Measured memory_bytes: 4860
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
pair<int,int> el;
map< pair<int,int> ,int > m[20];
char a[30],b[30];
int n,i,j,nr;
string s;
long long h1,h2,base=30,mod=1000*1000*1000+7;
long long tot;
int main()
{
  //  freopen("data.in","r",stdin);
    cin>>n;
    cin>>s;
    for(i=0;i<n;i++)
        a[i]=s[i];
    for(i=2*n-1;i>=n;i--)
        b[nr++]=s[i];
    for(i=0;i<(1<<n);i++)
    {
        h1=0;h2=0;nr=0;
        for(j=0;j<n;j++)
        {
            if(((1<<j)&i))
           {
               h1=(1LL*h1*base+(a[j]-'a'+1))%mod;
               ++nr;
           }
           else h2=(1LL*h2*base+(a[j]-'a'+1))%mod;
        }
        el.first=h1;el.second=h2;
        m[nr][el]++;
    }
    for(i=0;i<(1<<n);i++)
    {
        h1=0;h2=0;nr=0;
        for(j=0;j<n;j++)
        {
            if(((1<<j)&i))
           {
               h1=(1LL*h1*base+1LL*(b[j]-'a'+1))%mod;
               ++nr;
           }
           else h2=(1LL*h2*base+1LL*(b[j]-'a'+1))%mod;
        }
        el.first=h2;el.second=h1;
        tot+=1LL*m[n-nr][el];
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 33024
using System;
using System.Collections.Generic;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int count = int.Parse(Console.ReadLine()); count > 0; --count){
                Console.WriteLine(Judge(Console.ReadLine().Split().Select(p => int.Parse(p))) ? "YES" : "NO");
            }
        }
        static bool Judge(IEnumerable<int> input)
        {
            int right = 0;
            int left = 0;
            foreach(var item in input){
                if (left < item) left = item;
                else if(right < item) right = item;
                else return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 5572
class A:

    def solve(self):
        [a, b, c] = sorted([int(x) for x in input().split(" ")])
        if a == 5 and b == 5 and c == 7:
            print("YES")
        else:
            print("NO")

class B:

    def solve(self):
        [n, l] = [int(x) for x in input().split(" ")]

        strings = []
        for r in range(n):
            strings.append(input())

        sorted_strings = sorted(strings)

        print("".join(sorted_strings))

class C:

    def fix(self, final_amount, likes):
        i = 0
        import bisect as b
        changed = False
        for i,x in enumerate(reversed(final_amount)):
            real_index = len(final_amount) - i - 1
            ind = b.bisect_right(likes, int(x))
            if ind != len(likes):
                final_amount[real_index] = str(likes[ind])
                changed = True
                break

        if not changed:
            ind = b.bisect_right(likes, 0)
            final_amount = [str(likes[ind])] + final_amount
            i = 1
        else:
            i = len(final_amount) - i - 1

        while i < len(final_amount):
            final_amount[i] = str(likes[0])
            i += 1

        return final_amount

    def solve(self):
        [n, k] = [int(x) for x in input().split(" ")]
        dislikes = [int(x) for x in input().split(" ")]

        likes = []
        for r in range(10):
            if r not in dislikes:
                likes.append(r)

        import bisect as b

        final_amount = []
        sn = str(n)
        for ind in range(len(sn)):
            c = sn[ind]
            i = b.bisect_left(likes, int(c))
            if i == len(likes):
                prev_len = len(final_amount)
                final_amount = self.fix(final_amount, likes)
                final_amount += [str(likes[0]) for r in range(len(sn) - prev_len)]
                break

            if str(c) != str(likes[i]):
                final_amount.append(str(likes[i]))
                final_amount += [str(likes[0]) for r in range(len(sn) - len(final_amount))]
                break

            final_amount.append(str(likes[i]))

        print("".join(final_amount))

C().solve()


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

void run(void){
  char *a=(char *)malloc(sizeof(char)*(200000+1));
  scanf("%s",a);
  const int n=strlen(a);
  int *stack=(int *)calloc(n/26+2,sizeof(int));
  int top=0;
  stack[top++]=n;
  int i,j;
  i=n-1;
  while(i>=0){
    int elem[26]={0};
    int cnt=0;
    j=i;
    while(j>=0 && cnt<26){
      int k=a[j]-'a';
      if(!elem[k]) cnt++;
      elem[k]=1;
      j--;
    }
    if(cnt<26) break;
    stack[top++]=j+1;
    i=j;
  }
  char *ans=(char *)calloc(top+1,sizeof(char));
  int len=0;
  int from=0;
  while(top>0){
    int up=stack[--top];
    int elem[26]={0};
    for(i=from;i<up;i++) elem[a[i]-'a']=1;
    for(i=0;elem[i];i++);
    ans[len++]='a'+i;
    for(from=up;from<n && a[from]!=ans[len-1];from++);
    from++;
  }
  printf("%s\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 384
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
MOD = 10 ** 9 + 7

N = int(input())
T = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int1, input().split())
    T[a].append(b)
    T[b].append(a)


def dfs(x, parent):
    b, w = 1, 1
    for n in T[x]:
        if n == parent:
            continue
        nb, nw = dfs(n, x)
        b *= nw
        w *= (nw + nb)
    b %= MOD
    w %= MOD
    return b, w


b, w = dfs(0, 0)
print((b + w) % MOD)


Measured memory_bytes: 99820
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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

vector<mint> frac, ifrac;
void finit(ll X) {
	frac.assign(X + 1, 1);
	ifrac.assign(X + 1, 1);

	repn(i, X) {
		frac[i] = frac[i - 1] * i;
		ifrac[i] = ifrac[i - 1] / i;
	}

}

mint com(ll n, ll m) {
	if (n < 0 || m < 0 || n < m) { return 0; }
	return frac[n] * ifrac[m] * ifrac[n - m];
}

int main() {

	ll N;
	cin >> N;

	finit(N);
	ll M = N / 2;

	vector<mint> t(N + 1, 1);
	repn(i, N) t[i] = t[i - 1] * 2 - com(i-1, i-1 - M) - com(i-1, M);

	//rep(i, N + 1) cout << t[i] << endl;

	mint ans = 0;
	rep(i, N + 1) ans += com(N, i)*t[i];
	cout << ans;
	
	
	system("PAUSE");
}


Measured memory_bytes: 234872
def comb_mod(n,r,m):
    ans = 1
    for i in range(1,r+1):
        ans *= (n-i+1) % m
        ans *= pow(i,m-2,m) % m
        ans = ans % m
    return ans
n,a,b = map(int,input().split())
m = 10**9 + 7
ans = pow(2,n,m) - comb_mod(n,a,m) - comb_mod(n,b,m) - 1
print(int(ans) % m)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll N,M,Q;
ll sum = 0,ans = 0;
vector<ll> a(50);
vector<ll> b(50);
vector<ll> c(50);
vector<ll> d(50);
vector<ll> A(11,1);

void dfs(ll NN){
    if(N == NN){
        sum = 0;
        for(ll i = 0;i < Q;++i){
            if(A[b[i]-1]-A[a[i]-1] == c[i]){
                sum = sum + d[i];
            }
        }
        if(ans < sum) ans = sum;
    }
    else{
        for(ll i = 1;i <= M;++i){

            A[NN] = i;
            if(A[NN-1] <= A[NN])    dfs(NN+1);
            
        }
    }
}

int main(){
cin >> N >> M >> Q;
for(ll i = 0;i < Q;++i)    cin >> a[i] >> b[i] >> c[i] >> d[i];
dfs(1); 
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3560
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll N;
ll P;

ll getPower(ll value,ll shisu,ll MODV){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % MODV;
        }
        value = value * value % MODV;
        cnt = cnt/2;
    }
    return ans;
}
int getIntSubstr(string s,int start_index,int length){
    return atoi(s.substr(start_index,length).c_str());
}
int main(){

    cin >> N;
    cin >> P;

    string S;
    
    cin >> S;

    int index_str;
    int index_end;
    index_str = 0;
    index_end = N-1;

    ll l_cnt[10010]={};
    ll shisu=1;
    ll cnt=0;
    ll value=0;
    l_cnt[0]++;
    if (P == 2 or P == 5) {
        for (int index = 0; index < N; index++) {
            if ((getIntSubstr(S,index,1)) % P == 0) {
                cnt += index + 1;
            }
        }
    } else {
        for( int index = index_end ; index >= index_str ; index-- ){
            //cout << getIntSubstr(S,index,1)  << endl;
            value = value + getIntSubstr(S,index,1) * shisu;
            value = value % P;
            cnt+=l_cnt[value];
            l_cnt[value]++;
            //l_cnt[value % P]++;
            shisu=(shisu*10)%P;
        }
    }
    /*
    ll tmp;
    tmp = l_cnt[0];
    //cout << tmp << endl;
    cnt+=tmp*(tmp+1)/2;
    for( int ni = 1 ; ni <P+1 ; ni++ ){
        tmp = l_cnt[ni];
        //cout << tmp << endl;
        tmp--;
        cnt+=tmp*(tmp+1)/2;
    }
    */
    cout << cnt << endl;
}

Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>

#include <cfloat>
#include <cmath>

using namespace std;

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	double deg = DBL_MAX;
	int ans;
	for (int i = 0; i < n; i++)
	{
		double temp = fabs(a - (t - h[i] * 0.006));
		if (temp < deg) {
			deg = temp;
			ans = i + 1;
		}
	}

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

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for c in [input() for i in range(n)]:
	d[c[0]]+=1
tar = [d["M"],d["A"],d["R"],d["C"],d["H"]]
ans = 0
for a in itertools.combinations(tar,3):
	ans+=a[0]*a[1]*a[2]

print(ans)

Measured memory_bytes: 16492
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K
{
	static int[] G => ReadLine().Split().Select(i => int.Parse(i) - 1).ToArray();
	static int N;
	static void Main()
	{
		var I = G;
		N = I[0] + 1;
		WriteLine(string.Join(" ", C(G, G, I[1]).Select(i => i + 1)));
	}
	static int[] C(int[] p, int[] q, int K)
	{
		int[] P = I(p), Q = I(q), x = E(M(q, P, Q, p), K / 6), y = I(x);
		switch (K % 6)
		{
			case 0: return M(x, p, y);
			case 1: return M(x, q, y);
			case 2: return M(x, q, P, y);
			case 3: return M(x, q, P, Q, y);
			case 4: return M(x, q, P, Q, p, Q, y);
			default: return M(x, q, P, Q, p, p, Q, y);
		}
	}
	static int[] I(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	static int[] M(int[] a, int[] b) { var p = new int[N]; for (var i = 0; i < N; i++) p[i] = a[b[i]]; return p; }
	static int[] M(params int[][] a) => a.Aggregate(M);
	static int[] E(int[] a, int b)
	{
		if (b < 0) return I(E(a, -b));
		var p = new int[N];
		var f = new bool[N];
		for (var i = 0; i < N; i++)
			if (!f[i])
			{
				var l = new List<int>();
				var x = i;
				while (!f[x]) { l.Add(x); f[x] = true; x = a[x]; }
				var C = l.Count;
				for (var j = 0; j < C; j++) p[l[j]] = l[(j + b) % C];
			}
		return p;
	}
}


Measured memory_bytes: 38264
import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
import java.util.*;

/**
 * Created by takaesumizuki on 2018/06/22.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Integer q = sc.nextInt();
        PrimitiveUnionFind uni = new PrimitiveUnionFind(n);

        while (q-- > 0) {
            Integer com, x, y;
            com = sc.nextInt();
            x = sc.nextInt();
            y = sc.nextInt();

            if (com == 0) {
                uni.merge(x, y);
            } else {
                if (uni.same(x, y)) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
            }


        }

    }


    public class PrimitiveUnionFind {
        int[] unions;

        /**
         * 0 ~ size - 1までの集合を
         *
         * @param size 集合のサイズ
         */
        PrimitiveUnionFind(Integer size) {
            this.unions = new int[size];
            for (Integer i = 0; i < size; i++) {
                this.unions[i] = i;
            }
        }

        int find(int v) {
            if (unions[v] == v) {
                return v;
            } else {
                int ret = find(this.unions[v]);
                this.unions[v] = ret;
                return ret;
            }
        }

        /**
         * v1の集合 を v2の集合にする
         *
         * @param v1
         * @param v2
         */
        void merge(int v1, int v2) {
            int v1Root = find(v1);
            int v2Root = find(v2);

            this.unions[v1Root] = v2Root;
        }

        Boolean same(int v1, int v2) {
            return find(v1) == (find(v2));
        }
    }
}



Measured memory_bytes: 98896
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: f32,
        x: f32,
        t: isize,
    }


    print!("{}", (n/x).ceil() as isize * t );
}

Measured memory_bytes: 2696
def position_zip(a,flag):
  j=0
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
class BinaryIndexedTree:
  def __init__(self,n):
    self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_sub(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_sub(j+1)
    if i!=0:a-=self.sum_sub(i-1)
    return a
xx=1<<20
n,q=map(int,input().split())
a=list(map(int,input().split()))
a=position_zip(a,0)
k=max(a)+1
ans=[0]*q
queries=[]
for i in range(q):
  l,r=list(map(int,input().split()))
  l-=1
  r-=1
  queries.append(r<<40|l<<20|i)
queries.sort()
for i in range(q):
  ind=queries[i]%xx
  queries[i]>>=20
  l=queries[i]%xx
  queries[i]>>=20
  r=queries[i]
  queries[i]=(r,l,ind)
queries.append((10*20,0,0))
lastAppeared=[-1]*k
bitt=BinaryIndexedTree(n)
j=0
for i in range(n):
  if lastAppeared[a[i]]!=-1:
    bitt.add(lastAppeared[a[i]],-1)
    bitt.add(i,1)
    lastAppeared[a[i]]=i
  else:
    bitt.add(i,1)
    lastAppeared[a[i]]=i
  while queries[j][0]==i:
    r,l,ind=queries[j]
    j+=1
    ans[ind]=bitt.sum(l,r-1)
print(*ans)


Measured memory_bytes: 255632
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main() {
  ll N, K;
  cin >> N >> K;
  ll i, j;
  ll a[MAX];
  ll f[50]={};
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    
    for(j=0; j<44; j++) {
      if(1&(a[i]>>j)) f[j]--;
      else f[j]++;
    }
  }
  
  for(i=0; i<44; i++) {
    if(f[i]>0) f[i]=1;
    else f[i]=0;
  }
  
  ll ans=0;
  for(i=0; i<N; i++) {
    ans+=K^a[i];
  }
  
  for(i=0; i<44; i++) {
    if((1&(K>>i))==0) continue;
    ll mask=(K>>(i+1))<<(i+1);
    for(j=0; j<i; j++) {
      if(f[j])
        mask+=1LL<<j;
    }
    
    ll t=0;
    for(j=0; j<N; j++) {
      t+=mask^a[j];
    }
    
    chmax(ans, t);
  }
  
  pt(ans);
  
}





Measured memory_bytes: 1024
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int n,a;
    cin>>n>>a;
    
    int amari;
    amari=n%500;
    
    if(amari<=a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
   
    
    return 0;
   
}






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

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

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

const ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	int a[100];
	for(int i = 0; i < n; i++){
	scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
	printf("%d", a[n-1-i]);
	if(i !=n-1){
	printf(" ");
	}
	}
	printf("\n");
	return 0;
}

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

template <typename T>
bool isRight_Triangle ( T a, T b, T c )
{
	return (a * a + b * b == c * c) || (a * a + c * c == b * b) || (b * b + c * c == a * a);
}

int main() {
	int n;
	while (cin >> n) {
		for (int i = 0; i < n; ++i) {
			int a, b, c;
			cin >> a >> b >> c;

			if (isRight_Triangle(a, b, c)) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int w, h, ans;
int d[4][2] = { { 1, 0 }, { -1, 0 }, {0, 1}, {0, -1} };
char map[20][20];

void search_dfs(int x, int y){
	if( x < 0 || x >= w || y < 0 || y >= h ) return;
	if( map[y][x] != '.' ) return;
	ans ++;
	map[y][x] = '*';
	for(int i = 0; i < 4; i++)
		search_dfs( x + d[i][0], y + d[i][1] );
}

int main(void){

	while( 1 ) {
		cin >> w >> h;
		if( w == 0 && h == 0 ) break;
		ans = 0;

		for(int i = 0; i < h; i++)
			cin >> map[i];

		for(int i = 0; i < h; i++)
			for(int j = 0; j < w; j++)
				if( map[i][j] == '@' ) {
					map[i][j] = '.';
					search_dfs(j, i);
				}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string s;
	cin >> s;
	cout << s;
	if (s[s.size() - 1] == 's') {
		cout << "e";
	}
	cout << "s" << endl;
	
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+2);
    int ALL = 0;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    rep(i,n+1) ALL += abs(a[i]-a[i+1]);
    for(int i = 1; i <= n; ++i) {
        cout << ALL - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]) << endl;
    }
    return 0;
}

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

using namespace std;

bool isPrime[100'001];
bool like2017[100'001];
int a[100'002];

int main()
{
    const int n = 100'001;

    fill(isPrime, isPrime + n, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < n; i++) {
        if (isPrime[i]) {
            for (int j = i * 2; j < n; j += i) {
                isPrime[j] = false;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        like2017[i] = isPrime[i] && isPrime[(i + 1) / 2];
    }

    for (int i = 0; i <= n; i++) {
        if (i == 0) {
            a[i] = 0;
        } else {
            a[i] = a[i - 1] + (like2017[i - 1] ? 1 : 0);
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << a[r + 1] - a[l] << endl;
    }
    return 0;
}

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

int main(){
    char b[2];
    scanf("%s",b);
    if(b[0]=='A'){
printf("T");
}else if(b[0]=='T'){
printf("A");
}else if(b[0]=='G'){
printf("C");
}else{
printf("G");
}
    return 0;
}

Measured memory_bytes: 128
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
p.sort()
p_non=[]


for i in range(102):
    if i not in p:
        p_non.append(i)
p_non.sort()

zettaiti=1000000
ans=None
for i in p_non:
    if abs(i-x)<zettaiti:
        ans=i
        zettaiti=abs(i-x)

print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int a[N],b[N];
int main(){
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=n-1;i>=0;i--){
		if((a[i]+ans)%b[i]) ans+=b[i]-(a[i]+ans)%b[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
ans = float('inf')
for i in (-1, 1):
    cnt, now = 0, 0
    for aa in a:
        now += aa
        if now * i <= 0:
            cnt += abs(now - i)
            now = i
        i *= -1
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 12460
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int n,a,b;
  cin >> n >> a >> b;
  
  if(n == 1 && a != b || a > b) cout << 0 << endl;
  else cout << b*(n-1)+a - (a*(n-1)+b) + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c,i,n;
	cin>>a>>b>>c;
	n=0;
	for(i=a;i<=b;i++){
		if(c%i==0){
			n++;
		}
	}
	cout<<n<<endl;//ここで出力！
  return 0;
}

Measured memory_bytes: 1164
n_k = list(map(int, input().split()))
R_S_P = list(map(int, input().split()))
"""
グーで勝った場合、 R点
チョキで勝った場合、 S点
パーで勝った場合、P点

r :グー
s :チョキ
p :パー
"""
n = input()
j = 0
a = ""
res = 0
dasita = []


for i in n:
    if j >= n_k[1]:
        a = dasita[j - n_k[1]]

    if i == "r":  # グーを出された場合
        if a == "p":
            dasita.append("N")
        else:
            res += R_S_P[2]
            dasita.append("p")
    elif i == "s":
        if a == "r":
            dasita.append("N")
        else:
            res += R_S_P[0]
            dasita.append("r")
    elif i == "p":
        if a == "s":
            dasita.append("N")
        else:
            res += R_S_P[1]
            dasita.append("s")
    j += 1
print(res)

Measured memory_bytes: 4212
using System;
using System.Linq;

class Amondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var gedoku = A + B+1;
        var doku = gedoku < C ? gedoku : C;
        Console.WriteLine(doku+B);
    }
}

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

namespace my {
template <typename T>
void input_vec(vector<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_vec" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_set" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(a) )

bool isPrime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////////////////////////////

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (t >= (ld)d / s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{    
    ll n;
    cin >> n;
    vll a(n);
    
    ll d0 = 0, d1 = 0, d2 = 0;
    
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 4 == 0) {
            d2++;
        } else  if (a[i] % 2 == 0) {
            d1++;
        } else d0++;
    }
    
    if(d0 > d2+1) {
        mes("No");
        re0;
    }
    if(d0 == d2+1) {
        if (d1 > 0) {
            mes("No");
            re0;
        }
        
    }
    
    mes("Yes");
    
    
    
    
    
}

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

public class Main {

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

        final String s = sc.next();
        final char[] c = s.toCharArray();

        Arrays.sort(c);

        System.out.println(c[0] == c[1] && c[1] != c[2] && c[2] == c[3] ? "Yes" : "No");
    }
}


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

int a[200005];

int main()
{
	int n;
	scanf("%d",&n);
	int mx=0,sx=0;
	for(int i=1;i<=n;++i) {
		scanf("%d",&a[i]);
		if(mx<a[i]) sx=mx,mx=a[i];
		else if(sx<a[i]) sx=a[i];
	}
	for(int i=1;i<=n;++i) {
		if(a[i]==mx) printf("%d\n",sx);
		else printf("%d\n",mx);
	}
}

Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String str = sc.next();

        int cntA=0, cntB=0, passed=0, rankB=0;
        for (char c : str.toCharArray()) {
            if (c == 'a') { cntA++; }
            if (c == 'b') { cntB++; }        
            if (c == 'c') {
                System.out.println("No");
                continue;
            }
            if (c == 'a') {
                if (passed < a+b) {
                    System.out.println("Yes");
                    passed++;
                } else {
                    System.out.println("No");
                }
            }
            if (c == 'b') {
                rankB++;
                if (passed < a+b && rankB <= b) {
                    System.out.println("Yes");
                    passed++;
                } else {
                    System.out.println("No");
                }
            }
        }
    }
}


Measured memory_bytes: 34920
#include<stdio.h>
double area(double,double);
double len(double,double);
int main(void)
{
  double r,S,l,p;
  p=3.141592653589;
  scanf("%lf",&r);
  S=area(r,p);
  l=len(r,p);
  printf("%f %f\n",S,l);
  return 0;
}
double area(double x,double y)
{
  double num1;
  num1=x*x*y;
  return num1;
}
double len(double x,double y)
{
  double num2;
  num2=2*x*y;
  return num2;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> L(M), R(M);
	rep(i,M) cin >> L[i] >> R[i];
	vector<int> p(Q), q(Q);
	rep(i,Q) cin >> p[i] >> q[i];
	vector<vector<int>> T(N+1);
	rep(i,M) T[R[i]].emplace_back(L[i]);
	int num[510][510]={0};
	for(int i=1; i<=N; i++){
		for(int j=i; j<=N; j++){
			num[i][j]=num[i][j-1];
			rep(k,T[j].size()){
				if(T[j][k]>=i) num[i][j]++;
			}
		}
	}
	rep(i,Q) cout << num[p[i]][q[i]] << endl;

	return 0;
}

Measured memory_bytes: 5504
/**/
#include<bits/stdc++.h>
using namespace std;
int ans=1,n,k;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ans+=min(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	vector<int> l(n);
  	rep(i, n) cin >> l[i];
  
  	sort(l.begin(), l.end());
  	int ans = 0;
  	rep(b, n){
    	rep(a, b){
          	int ab = l[a] + l[b];
			for(int c = b+1;c < n; c++){
            	if(ab > l[c]) ans++; 
            }
        }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF (1e9)
#define M 1005
#define N 205
using namespace std;
typedef long long ll;

ll n,m,r,z[M],sld[2][N][N];

void init(){
  rep(i,2)
    rep(j,n)
      rep(k,n)
        sld[i][j][k]=INF;  
}

void add_edge(ll sl,ll x,ll y,ll t){
  sld[sl][x][y]=sld[sl][y][x]=min(sld[sl][x][y],t);
}

void warshall_floyd(){
  rep(sl,2) rep(k,n) rep(i,n) rep(j,n)
    sld[sl][i][j]=min(sld[sl][i][j],sld[sl][i][k]+sld[sl][k][j]);
  rep(sl,2)
    rep(i,n)sld[sl][i][i]=0;
}

ll dp[M][N];

void solve(){
  rep(i,r)
    rep(j,n)dp[i][j]=INF;
  dp[0][z[0]]=0;
  
  rep(i,r-1)
    rep(j,n){
      if(dp[i][j]==INF)continue;
      ll cost=dp[i][j]+sld[0][z[i]][z[i+1]];
      dp[i+1][j]=min(dp[i+1][j],cost);
      rep(k,n){
	ll cost2=dp[i][j]+sld[0][z[i]][j];
	cost2+=sld[1][j][k]+sld[0][k][z[i+1]];
	dp[i+1][k]=min(dp[i+1][k],cost2);
      }
    }
  ll ans=INF;
  rep(i,n)ans=min(ans,dp[r-1][i]);
  cout<<ans<<endl;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    ll x,y,t;
    char sl;
    
    init();
    
    rep(i,m){
      cin>>x>>y>>t>>sl;
      x--,y--;
      if(sl=='L')add_edge(0,x,y,t);
      else add_edge(1,x,y,t);
    }
    
    warshall_floyd();
 
    cin>>r;
    rep(i,r)cin>>z[i],z[i]--;
    
    solve();
  }
  return 0;
}

Measured memory_bytes: 5328
#include<bits/stdc++.h>
#define LL long long
#define cbn(u,y) ((LL)fac[u]*inv[y]%mod*inv[(u)-(y)]%mod)

const int mod=1e9+7;
struct Combin{
	#define N 400005
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;

#define N 200005
using namespace std;
struct edge{
    int d,t,next;//d=x+y
}e[N*2];int ecnt,head[N];
void addedge(int dp,int t,int d){
    e[++ecnt]=(edge){d,t,head[dp]};head[dp]=ecnt;
    e[++ecnt]=(edge){d,dp,head[t]};head[t]=ecnt;
}

int medge,sta[N],top,vis[N],vise[N];
void dfsc(int u,int fr_edge){//染色
	vis[u]=1;sta[++top]=u;
	for(int i=head[u],y;i;i=e[i].next) 
        if((i^1)!=fr_edge){
            if (vise[i>>1]==0) vise[i>>1]=1,medge++;
            if (vis[e[i].t]==0) dfsc(e[i].t,i);
	    }
}

int fre[N],mxp;//mxp 连通块中最右上角的点
void dfsp(int u,int fr_edge){//找到环上权值最大的边
	vis[u]=2;
	for(int i=head[u];i;i=e[i].next)
        if((i^1)!=fr_edge){
            if (vis[e[i].t]!=2){
                fre[e[i].t]=i;
                dfsp(e[i].t,i);
            }else if(mxp==0){//找到环了
                mxp=i;
                for (int t=u;t!=e[i].t;t=e[fre[t]^1].t)
                    if (e[fre[t]].d>e[mxp].d) mxp=fre[t];
            }
	    }
}

int n,m,ans;
int dp[N],sz[N];
void calc(int u,int fr_edge){
	sz[u]=dp[u]=1;
	for(int i=head[u];i;i=e[i].next)
        if(((i^1)!=fr_edge)&&(i>>1)!=(mxp>>1)){
            calc(e[i].t,i);
            if(e[i].d>e[fr_edge].d){
                ans=(LL)ans*dp[e[i].t]%mod*C.facrv[sz[e[i].t]]%mod;
            }else{
                sz[u]+=sz[e[i].t];
                dp[u]=(LL)dp[u]*dp[e[i].t]%mod*C.C(sz[e[i].t],sz[u]-1)%mod;
            }
    	}
}

int main(){
	scanf("%d",&n);ecnt=1;
	for(int i=1,x,y;i<=n*2;i++){
		scanf("%d%d",&x,&y);
		addedge(x,y+n,x+y);
	}

	int sum=C.fac[n*2],tot;
	for(int i=1,v;i<=n*2;i++)
        if(vis[i]==0){
            mxp=medge=top=tot=0;
            dfsc(i,0);
            if(medge!=top) return puts("0"),0;
            dfsp(i,0);

            v=e[mxp].t,ans=1,calc(v,mxp);
            ans=(LL)ans*dp[v]%mod*C.facrv[sz[v]]%mod;
            tot+=ans;

            v=e[mxp^1].t,ans=1,calc(v,mxp);
            ans=(LL)ans*dp[v]%mod*C.facrv[sz[v]]%mod;
            tot+=ans;

            sum=(LL)sum*tot%mod;
    	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 18432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void putNo() {
	cout << "No" << endl;
}
void  TakahashisInformation() {

	int c[3][3];
	for (size_t i = 0; i < 3; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			cin >> c[i][j];
		}
	}

	for (size_t i = 0; i < 3; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			if (c[i][i] + c[j][j] != c[i][j] + c[j][i]) {
				cout << "No" << endl;
				return;
			}
		}
	}
	cout << "Yes" << endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
		float o,m,n,i;
		m=0;
		n=10000000;
	while(scanf("%f",&o)!=EOF){
		if(m<o){
			m=o;
		}
		if(n>o){
			n=o;
		}
	}	
		printf("%.2f\n",m-n);
	return 0;
}

Measured memory_bytes: 1076
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long N = stdIn.nextInt();
		long K = stdIn.nextInt();
		long S = stdIn.nextInt();
		
		long len = N-(K-1);
		if(S >= len) {
			long a = S/(len);
			long b = S-a*(len-1);
			
			for(int i = 0; i < N; i++) {
				if((i+1)%len == 0) {
					System.out.println(b);
				}
				else {
					System.out.println(a);
				}
			}
		}
		else {
			for(int i = 0; i < N; i++) {
				if(i < S+K-1) {
					System.out.println(1);
				}
				else {
					System.out.println(S+1);
				}
			}
		}
		

	}

}

Measured memory_bytes: 42360
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m, a, b;
int dist[2100];

vint graph[2100];

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        
        memset(dist, -1, sizeof(dist));
        for (int i = 0; i < 2100; ++i) graph[i].clear();
        for (int i = 0; i < m; ++i) {
            cin >> a >> b;
            --a; --b;
            graph[a].PB(b); 
            graph[b].PB(a);
        }
        
        dist[0] = 0;
        queue<int> que; que.push(0);
        while (!que.empty()) {
            int q = que.front(); que.pop();
            
            for (int i = 0; i < graph[q].size(); ++i) {
                int to = graph[q][i];
                if (dist[to] == -1) {
                    dist[to] = dist[q] + 1;
                    que.push(to);
                }
            }
        }
        
        int res = 0;
        for (int i = 0; i < n; ++i) if (dist[i] == 1 || dist[i] == 2) ++res;
            
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, d, m, t;
    vector<long> ds, ts;
    cin >> n;
    REP(i,n) {
        cin >> d;
        ds.push_back(d);
    }
    cin >> m;
    REP(i,m) {
        cin >> t;
        ts.push_back(t);
    }
    
    sort(ds.begin(), ds.end());
    sort(ts.begin(), ts.end());
    
    map<int,int> ma;
    
    bool flag = true;
    REP(i,m) {
        if (upper_bound(ds.begin(), ds.end(), ts[i]) - lower_bound(ds.begin(), ds.end(), ts[i]) - ma[ts[i]]) {
            ma[ts[i]]++;
        } else {
            flag = false;
        }
    }
    if (flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 12784
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    deque<char> deq;
    string s;
    int q;
    cin >> s >> q;
    bool inv = 0;
    rep(i,s.size()) deq.push_back(s[i]);
    rep(i,q){
        int n;
        cin >> n;
        if(n==1){
            if(inv) inv = 0;
            else inv = 1;
        }else{
            int f;
            char ss;
            cin >> f >> ss;
            if(inv==0){
                if(f==1) deq.push_front(ss);
                else deq.push_back(ss); 
            }else{
                if(f==1) deq.push_back(ss);
                else deq.push_front(ss);
            }
        }
    }
    //cout << deq.size() << endl;
    //cout << inv << endl;
    if(inv) {
        for(int i = deq.size()-1;i>=0;i--){
            cout << deq[i];
        }
    }
    else{ 
        for(int i=0;i<deq.size();i++) cout << deq[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    if (A%2 == 0 || B%2 == 0 || C%2 ==0) {
      System.out.println(0);
      return;
    }
    long ans;
    if (A >= B && A>= C){
      ans = (long) B*C;
    } else if (B >= A && B >= C) {
      ans = (long) C*A;
    } else {
      ans = (long) A*B;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cctype>
#include <sstream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
	string a;
	cin>>a;
	cout<<a[0]<<a.size()-2<<a[a.size()-1];
	return 0;
}

Measured memory_bytes: 256