akhauriyash/Code-Regression huggingface dataset:
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n;
    cin>>n;
    ll arr[n];
    ll x=0;
    loop(n,i,0)
        cin>>arr[i],x^=arr[i];
    loop(n,i,0)
        cout<<(x^arr[i])<<' ';
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;

    //cout << S.length() << endl;
    bool flag = true;
    for (int i=0; i< (int)(S.length()); i++){
      // 奇数
      if (i%2 == 0 && (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')) {
	  flag = false;
	  break;
      }
      // 偶数
      if (i%2 != 0 && (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')) {
	flag = false;
	break;
      }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

# input = stdin.readline

def solve(h,w,n,a):
  acc = []
  for i in range(n):
    acc.extend([i+1]*a[i])
  res = []
  k = 0
  for i in range(h):
    res.append(acc[k:k+w] if i%2==0 else acc[k:k+w][::-1])
    k += w
  return res


def main():
  H,W = map(int,input().split())
  N = int(input())
  a = list(map(int,input().split()))
  ans = solve(H,W,N,a)
  for i in range(H):
    print(*ans[i])
  




if __name__ == '__main__':
  main()


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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

ll f[hell];

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z = 0, k, n;
	cin >> n;
	ll a[n];
	rep(i, 0, n, 1) {
		cin >> a[i];
		f[a[i]]++;
	}

	rep(i, 0, n, 1) {
		x = a[i];
		if (f[x] > 1 || (x != 1 && f[1]))	continue;

		bool br = true;

		for (j = 2; j * j <= x; j++) {
			if (x % j == 0) {
				t = x / j;
				if (f[j] || f[t]) {
					br = false;
				}
			}
		}
		z += br;
	}
	ce(z)
}


Measured memory_bytes: 12896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    int a[n+1] = {};
    srep(i,1,n+1){
        cin >> a[i];
    }

    int m = 0;

    int flag[n+1] = {};
    int count[n+1] = {};
    for(int i = n; i>0; i--){
        if(count[i]%2==a[i]){
            flag[i] = 0;
        }else{
            flag[i] = 1;
            m++;
        }
        srep(j,1,n+1){
            if(flag[i]==0)break;
            if(j*j>i){
                break;
            }else{
                if(i%j==0){
                    //cout << i << ' ' << j << endl;
                    count[j]++;
                    if(i/j!=j){
                        count[i/j]++;
                    }
                    
                }
            }
        }
    }

    if(m==0){
        cout << m << endl;
        return 0;
    }

    cout << m << endl;
    srep(i,1,n+1){
        if(flag[i]==1){
            cout << i << ' ';
        }
    }
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, m, k;
		cin >> n >> m >> k;
		ll a[n + 1], b[m + 1];
		a[0] = b[0] = 0;
		for (int i = 1; i <= n; i++) cin >> a[i];
		for (int i = 1; i <= m; i++) cin >> b[i];
		for (int i = 0; i < n; i++) a[i + 1] += a[i];
		for (int i = 0; i < m; i++) b[i + 1] += b[i];
		int ans = 0, j = m;
		for (int i = 0; i <= n; i++) {
			if (a[i] > k) break;
			while (j >= 0 && b[j] > k - a[i]) j--;
			ans = max(ans, i + j);
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 6724
#include<cstdio>
const int MaxK=500010,mod=998244353;
int fac[MaxK],ifac[MaxK];
long long inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
int C(int n,int m){return m<0||m>n?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int calc(int N,int K){
	if(K<N)return 0;
	unsigned s=0;
	for(int i=K&1;i<=K;i+=2){
		int m=K-2*N+i;
		if(m<0)continue;
		m=m/2+1;
		if(i)s=(s+C(K,(K+i)/2)+mod-C(K,(K+i)/2+m))%mod;
		else s=(s+C(K-1,K/2)+mod-C(K-1,K/2+m))%mod;
	}
	return s;
}
int main(){
	int N,K;scanf("%d%d",&N,&K);
	for(int i=*fac=1;i<=K;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[K]=inv(fac[K]);
	for(int i=K;i;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	printf("%d\n",calc(N,K));
}

Measured memory_bytes: 4096
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
ans = 0
for c in range(n):
    a=0
    b=c-1
    while a<b:
        if l[a]+l[b]>l[c]:
            ans+=b-a
            b-=1
        else:
            a+=1
print(ans)

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

# 整数の入力
# 整数の入力
antena = []
ans = "Yay!"

for i in range(5):
    antena.append(int(input()))

k = int(input())

for i in range(len(antena)):
    for j in range(i+1, len(antena)):
        dist = abs(antena[j] - antena[i])
        if dist > k:
            print(":(")
            exit()

# 出力
print("Yay!")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];
stack<int>st;
int main(){
    int n,m,T;
    string s;
    cin>>s;
    int cnt=0;
    rep(i,0,SZ(s)){
        if(SZ(st)==0){
            st.push(s[i]-'0');
        }else{
            int temp=s[i]-'0';
            if(st.top()^temp==1){
                st.pop();
                cnt+=2;
            }else{
                st.push(temp);
            }
        }
    }
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 768
while(n=gets.to_i)>0
a=[x=0]*n*2+[0]
n.times{*l,_=a
a=[w=0]
l.each_slice(2){|i,j|s=STDIN.getc<?.?h=w=0:[h=j+1,w+=1,i+1].min;a<<h;a<<s;x<s&&x=s}
gets}
p x
end

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

string s , last , now;
int k;

int main()
{
	cin >> s;
	for(int i = 0 ; i < s.size() ; i ++)
	{
		now += s[i];
		if(now != last) last = now , now.clear() , k ++;
	}
	cout << k << endl;
} 

Measured memory_bytes: 640
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn calculate_digit(x: i64) -> u32 {
    let mut i = 1;
    while x >= 10_i64.pow(i) {
        i += 1;
    }
    i
}


fn f(a: i64, b: i64) -> u32 {
    let a_digit = calculate_digit(a);
    let b_digit = calculate_digit(b);
    if a_digit > b_digit { a_digit } else { b_digit }
}


fn main() {
    let n = input!(i64);

    let mut min_digit = u32::max_value();
    let mut a = 1;
    while a * a <= n {
        if n % a == 0 {
            let digit = f(a, n / a);
            if min_digit > digit {
                min_digit = digit;
            }
        }
        a += 1;
    }
    println!("{}", min_digit);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    ll n;
    cin >> n;
    vector<ll> d(n + 1);
    ll sm = 0;
    for (int i = 0; i < n + 1; ++i) {
        cin >> d[i];
        sm += d[i];
    }
    sm *= (n + 1);
    sm += 100;
    ll x = 1;
    vector<ll> up;
    for (int i = 0; i < n + 1; ++i) {
        x = min(x, sm);
        up.push_back(x);
        x -= d[i];
        if (x < 0) {
            cout << -1 << endl;
            return;
        }
        x *= 2;
    }
    x = 0;
    ll res = 0;
    for (int i = n; i >= 0; --i) {
        x += d[i];
        x = min(x, up[i]);
        res += x;
    }
    cout << res << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 4696
#include<iostream>
using namespace std;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
int t[200][200],vd[200][200];
int W,H,sx,sy,gx,gy,n,key;

bool inField(int y,int x){
  if(y<0||y>=H)return false;
  if(x<0||x>=W)return false;
  return true;
}

bool solve(int y,int x){
  if(y==gy&&x==gx)return true;
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(!inField(ny,nx))continue;
    if(t[ny][nx]!=key)continue;
    if(vd[ny][nx]==1)continue;
    vd[ny][nx]=1;
    if( solve(ny,nx) ) return true;
  }
  return false;
}

void init(){
  for(int i=0;i<200;i++)
    for(int j=0;j<200;j++)
      t[i][j]=vd[i][j]=-1;
}

int main(){
  int a,b,x,y;
  while(cin>>W>>H){
    if(W==0&&H==0)break;
    init();
    cin>>sx>>sy>>gx>>gy>>n;
    sx--,sy--,gx--,gy--;
    for(int k=0;k<n;k++){
      cin>>a>>b>>x>>y;
      x--,y--;
      for(int i=0;i<(b==0?2:4);i++)
	for(int j=0;j<(b==0?4:2);j++)
	  t[y+i][x+j]=a;
    }
    key=t[sy][sx];
    cout<<(key!=-1&&solve(sy,sx)?"OK":"NG")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1464
def hantei(current):
    #print(current)
    if current == n-1:
        up = True
        return up
    for i in range(current, n):
        if a[i+1] != a[i]:
            if a[i+1] > a[i]:
                up = True
            else:
                up = False
            break
    return up
    #print(up)

n = int(input())
a = [int(x) for x in input().split()]

ans = 0
ans_list = [[]]

up = hantei(0)

for i in range(n):
    #print(up, i, a[i-1], a[i])
    if i == 0:
        ans_list[ans].append(a[i])
        continue
    if ((up == True and a[i-1] < a[i]) or (up == False and a[i-1] > a[i]) or (a[i-1] == a[i])):
        #print('thru', i, a[i-1], a[i])
        #print(ans_list, ans)
        ans_list[ans].append(a[i])
    elif up == False and a[i-1] < a[i]:
        #print('down .. stop', i, a[i-1], a[i])
        ans += 1
        ans_list.append([])
        #print(ans_list, ans)
        ans_list[ans].append(a[i])
        up = hantei(i)
    elif up == True and a[i-1] > a[i]:
        #print('up .. stop', i, a[i-1], a[i])
        ans += 1
        ans_list.append([])
        #print(ans_list, ans)
        ans_list[ans].append(a[i])
        up = hantei(i)
print(len(ans_list))

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

int bubuleSort(vector<int> &A,int N){
  int flag = 1,count=0;
  for(int i=0; flag; i++){
    flag = 0;
    for(int j = N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
        count++;
      }
    }
  }

  return count;
}

int main(){
  int n,num;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  num = bubuleSort(a,n);
  rep(i,n-1){
     cout << a[i] << " " ;
   }

   cout << a[n-1] << endl;
   cout << num << endl;

   return 0;
}



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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    int X[M];
    for(int i = 0; i < M; i++)
        cin >> X[i];
    if(N >= M) {
        cout << 0 << endl;
        return 0;
    }
    sort(X, X + M);
    int difX[M - 1];
    for(int i = 0; i + 1 < M; i++) {
        difX[i] = X[i + 1] - X[i];
    }
    sort(difX, difX + M - 1, greater<int>());
    int ans = X[M - 1] - X[0];
    for(int i = 0; i < N - 1; i++) {
        ans -= difX[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
if (N*100)%108 == 0 :
    print(int(N/1.08))
else :
    for i in range(1,100) :
        if (N*100+i) % 108 == 0 :
            print(int((N*100+i)/108))
            break
    else :
        print(":(")


Measured memory_bytes: 9136
#include <cstdio>

typedef struct{
    int father;
}data;

data d[100001];

bool check(int x, int y){
    int tmpx = x;
    int tmpy = y;
    bool bx=false,by=false;
    while(true){
        if(d[x].father==0)break;
        bx = true;
        x = d[x].father;
    }
    while(true){
        if(d[y].father==0)break;
        by = true;
        y = d[y].father;
    }
    if(x==y)return false;
    d[x].father = y;
    if(bx)d[tmpx].father = y;
    if(by)d[tmpy].father = y;
    return true;
}

int main(void){
    int n,m,x,y,z;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        d[i].father = 0;
    }
    int ans = n;
    for(int i=0;i<m;i++){
        scanf("%d %d %d",&x,&y,&z);
        if(check(x,y))ans--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, ans=0;

    cin >> N;

    for(i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define MAX 200000
#define True 1
#define False 0

int main() {
	int N;
	cin >> N;
	vector<int> A(MAX);
	for (int i = 0; i < N; i++) {
		cin >> A[i];	
	}
	sort(A.begin(), A.begin() + N);
	bool flag = True;
	for (int  i = 0; i < N; i++) {
		if (A[i] == A[i+1])  flag = False;
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1024
H,W,K=map(int,input().split())
M=[input()for i in range(H)]
ans=0

for i in range(2**(H+W)):
    h=i%(2**H)
    w=i//(2**H)
    count=0
    for x in range(H):
        if (2**x) & h == 0:
            continue
        for y in range(W):
            if (2**y) & w == 0:
                continue
            if M[x][y]=='#':
                count+=1
    if count==K:
        ans+=1
print(ans)

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

int main(){
  int N;
  cin>>N;
  
  int sum;
  for(int i=0; i<N; i++){
    int l,r;
    cin>>l>>r;
    
    sum+=r-l+1;
  }
  
  cout<<sum<<endl;
}

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i= min(a,b);i>0;i--){
        if((a%i==0)&&(b%i==0)) {
            k--;
            if(k==0){
                cout << i;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
const int maxn = 2e5+5;
int col[maxn],sub[maxn],sz[maxn];
ll cnt[maxn];
vector<int> g[maxn];
int n,dfn;

void dfs(int u,int f)
{
    sz[u] = 1;
    int pre = sub[col[u]];
    for(int v:g[u])if(v!=f){
        int t = sub[col[u]];
        dfs(v,u);
        int dt = sub[col[u]] - t;
        int tmp = sz[v] - dt;
        cnt[col[u]] -= (ll)tmp*(tmp-1)/2;
        sz[u] += sz[v];
    }
    sub[col[u]] = pre+sz[u];
}

int main()
{
    fastio();
    cin>>n;
    for(int i=1;i<=n;i++) cnt[i] = (ll)n*(n-1)/2;
    for(int i=1;i<=n;i++) {cin>>col[i];cnt[col[i]]++;}
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);g[v].pb(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++)
    {
        int t = n-sub[i];
        cnt[i] -= (ll) t*(t-1)/2;
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 37128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, x;
    cin >> k >> x;
    for(int i=x-k+1; i<k+x; ++i)
      cout << i << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
use std::collections::BTreeMap;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,m) = {
        let t = read_vec::<usize>();
        (t[0],t[1])
    };
    let s:Vec<char> = read::<String>().chars().collect();
    let t:Vec<char>  = read::<String>().chars().collect();
    let lcmv = lcm(n,m);
    let mut mm = BTreeMap::new();
    for (i,c) in s.into_iter().enumerate(){
        mm.insert(lcmv/n*i,c);
    }
    let mut check_flag = true;
    for (i,c) in t.into_iter().enumerate(){
        if let Some(x) = mm.get(&(lcmv/m * i)){
            if c != *x {
                check_flag = false;
            }
        }
    }
    let ans = if check_flag {lcmv as i64} else { -1 };
    println!("{}",ans);
}

fn gcd(x:usize,y:usize)-> usize{
    if x % y == 0{
        y
    } else{
        gcd(y,x%y)
    }
}
fn lcm(x:usize,y:usize)->usize{
    x*y/gcd(x,y)
}


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

int main() {
    int n, X;
    cin >> n >> X;
    int x[n + 1];
    rep(i, n) cin >> x[i];
    x[n] = X;
    sort(x, x + n + 1);

    int ans = x[1] - x[0];
    for (int i = 1; i < n; i++) {
        ans = __gcd(ans, x[i + 1] - x[i]);
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	int n,m;
	sd(n);
	sd(m);
	if(n%3==0||m%3==0)
	{
		printf("0\n");
		return 0;
	}
	ll ans=min(n,m);
	for(int i=1;i<=n;i++)
	{
		ll area1=1ll*i*m;
		ll area2=1ll*(m/2)*(n-i);
		ll area3=1ll*(m-m/2)*(n-i);
		ans=min(ans,max(max(area3,area2),area1)-min(min(area3,area2),area1));
	}
	for(int i=1;i<=m;i++)
	{
		ll area1=1ll*i*n;
		ll area2=1ll*(n/2)*(m-i);
		ll area3=1ll*(n-n/2)*(m-i);
		ans=min(ans,max(max(area3,area2),area1)-min(min(area3,area2),area1));
	}
	printf("%lld\n",ans );
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    from bisect import bisect_left
    N, Q = map(int, input().split())
    ret = (N - 2) ** 2
    xs = [-N]
    xvals = [N - 2]
    ys = [-N]
    yvals = [N - 2]
    for _q in range(Q):
        q, x = map(int, input().split())
        if q == 1:
            i = bisect_left(xs, -x)
            ret -= xvals[i - 1]
            if i == len(xs) and yvals[-1] > x - 2:
                ys.append(-xvals[i - 1] - 2)
                yvals.append(x - 2)
        else:
            y = x
            i = bisect_left(ys, -y)
            ret -= yvals[i - 1]
            if i == len(ys) and xvals[-1] > y - 2:
                xs.append(-yvals[i - 1] - 2)
                xvals.append(y - 2)

    print(ret)


# tests
T1 = """
5 5
1 3
2 3
1 4
2 2
1 2
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
200000 0
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
39999200004
"""

T3 = """
176527 15
1 81279
2 22308
2 133061
1 80744
2 44603
1 170938
2 139754
2 15220
1 172794
1 159290
2 156968
1 56426
2 77429
1 97459
2 71282
"""
_TEST_T3 = """
>>> as_input(T3)
>>> main()
31159505795
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 94988
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

void comdiv(map<int, s64>& x, s64 y)
{
    map<int, s64> vy;
    for (int i = 2; i * i <= y; ++i)
    {
        s64 temp = 0;
        while (y % i == 0)
        {
            temp++;
            y /= i;
        }
        x[i] = MAX(x[i], temp);
    }
    x[y] = MAX(x[y], 1);
}

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

    s64 N;
    s64 a;
    vs64 ainv;
    cin >> N;
    ainv.resize(N);
    map<int, s64> com;
    com[1] = 0;
    rep (i, N)
    {
        cin >> a;
        comdiv(com, a);
        ainv[i] = modinv(a, MOD);
    }

    s64 g = 1;
    for (auto mcom : com)
    {
        rep (i, mcom.second)
        {
            g *= mcom.first;
            g %= MOD;
        }
    }

    s64 ans = 0;
    rep (i, N)
    {
        ans += (g * ainv[i]) % MOD;
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]--;
    }
    vi s(n);
    for(ll i=0;i<n;i++)
    {
        cin>>s[i];
        sum+=s[i];
    }
    vi k(n-1);
    for(ll i=0;i<n-1;i++)
        cin>>k[i];
    for(ll i=0;i<n-1;i++)
    {
        if(a[i+1]==a[i]+1)
        {
            sum+=k[a[i]];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


fizzBuzz = let fb k s n = guard (n`mod`k==0) $> s in fromMaybe <$> show <*> fb 3 "Fizz" <> fb 5 "Buzz"

f m ss = f' [1..m] $ zipWith (==) ss $ map fizzBuzz [1..]
  where
    f' [p] _ = [p]
    f' ps [] = sort ps
    f' (p:ps) (b:subs) = f' (if b then ps ++ [p] else ps) subs

main = do
    [m,n] <- getInts
    unless (n==0 && m==0) $ replicateM n getLine >>= putStrLn . sjoin . f m >> main


Measured memory_bytes: 9224
import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

h,w,k = LI()
cnt = 0
c = [0]*h
for i in range(h):
    c[i] = input()

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == k:
            cnt += 1
print(cnt)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = 0;
    while(ans*x < n) ans++;
    cout << ans*t;
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int n = inp.nextInt();
        int a[] = new int[n];
        Set<Integer> sa = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            a[i] = inp.nextInt();
            sa.add(a[i]);
        }
        String ans = (sa.size() == a.length ? "YES" : "NO");
        System.out.println(ans);
    }
}

Measured memory_bytes: 104188
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let ab = Array.init (n - 1) @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)
let c = List.sort (fun a b -> b - a) @@ List.map int_of_string @@ split_string @@ read_line ()

let rec sum = function | [] -> 0 | x :: xs -> x + sum xs
let sum = sum c - List.hd c

let rec find_index i arr f = 
  if Array.length arr = i then -1
  else if f arr.(i) then i
  else find_index (i + 1) arr f
let find_index = find_index 0 ab

let s = Array.make n false
let ans = Array.make n 0

let rec loop = function
  | [] -> ()
  | x :: xs ->
    let idx = find_index (fun (a, b) -> a + b > 0 && (s.(a) || s.(b))) in
    let (a, b) = ab.(idx) in
    ab.(idx) <- (-1, -1);
    if s.(a) then begin
      s.(b) <- true; ans.(b) <- x
    end
    else begin
      s.(a) <- true; ans.(a) <- x
    end;
    loop xs

let () =
  match c with
    | x :: [] -> print_endline "0"
    | x :: y :: xs ->
      let (a, b) = ab.(0) in
      ab.(0) <- (-1, -1);
      ans.(a) <- x; s.(a) <- true;
      ans.(b) <- y; s.(b) <- true;
      loop xs;
      Printf.printf "%d\n" sum;
      print_endline @@ String.concat " " @@ Array.to_list @@ Array.map string_of_int ans;
    | _ -> failwith ""

Measured memory_bytes: 6656
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define N 100005

const double pi=acos(-1.0);
const double eps=1e-9;
int dcmp(double x)
{
    if (x<=eps&&x>=-eps) return 0;
    return (x>0)?1:-1;
}
struct Vector
{
    double x,y;
    Vector(double X=0,double Y=0)
    {
        x=X,y=Y;
    }
};
typedef Vector Point;
Vector operator + (Vector a,Vector b) {return Vector(a.x+b.x,a.y+b.y);}
Vector operator - (Vector a,Vector b) {return Vector(a.x-b.x,a.y-b.y);}
Vector operator * (Vector a,double b) {return Vector(a.x*b,a.y*b);}
Vector operator / (Vector a,double b) {return Vector(a.x/b,a.y/b);}

int n;
double r;
Point c,p[N];

double Dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}
double Cross(Vector a,Vector b)
{
    return a.x*b.y-a.y*b.x;
}
double Len(Vector a)
{
    return sqrt(Dot(a,a));
}
Vector rotate(Vector a,double rad)
{
    return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
}
Point GLI(Point P,Vector v,Point Q,Vector w)
{
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}
Point TC(Point A,Point B,Point C)
{
    Point P=(A+B)/2,Q=(A+C)/2;
    Vector v=rotate(B-A,pi/2),w=rotate(C-A,pi/2);
    if (dcmp(Len(Cross(v,w)))==0)
    {
        if (dcmp(Len(A-B)+Len(B-C)-Len(A-C))==0)
            return (A+C)/2;
        if (dcmp(Len(A-C)+Len(B-C)+Len(A-B))==0)
            return (A+B)/2;
        if (dcmp(Len(A-B)+Len(A-C)-Len(B-C))==0)
            return (B+C)/2;
    }
    return GLI(P,v,Q,w);
}
void mcc()
{
    random_shuffle(p+1,p+n+1);
    c=p[1],r=0;
    for (int i=2;i<=n;++i)
        if (dcmp(Len(c-p[i])-r)>0)
        {
            c=p[i],r=0;
            for (int j=1;j<i;++j)
                if (dcmp(Len(c-p[j])-r)>0)
                {
                    c=(p[i]+p[j])/2,r=Len(c-p[i]);
                    for (int k=1;k<j;++k)
                        if (dcmp(Len(c-p[k])-r)>0)
                        {
                            c=TC(p[i],p[j],p[k]);
                            r=Len(c-p[i]);
                        }
                }
        }
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%lf%lf",&p[i].x,&p[i].y);
    mcc();
    printf("%lf\n",r);
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	int x = 0, max = 0;
	for (int i = 0; i < n; i++) {
		a[i] = ri();
		if (max < a[i]) max = a[i], x = 1;
		else if (max == a[i]) x++;
	}
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x > 1 || a[i] != max) printf("%d\n", max);
		else printf("%d\n", max2);
	}
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s, t;
vector<int> cnt[30];
int ta;
int ans;

signed main() {
	cin >> s >> t;
	for (int i = 0; i < (int)s.size(); i++)cnt[s[i] - 'a'].push_back(i + 1);
	ta = 0;
	for (int i = 0; i < (int)t.size(); i++) {
		int x = t[i] - 'a';
		if ((int)cnt[x].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
		if (cnt[x][cnt[x].size() - 1] <= ta) {
			ans += cnt[x][0] + (int)s.size() - ta;
			ta = cnt[x][0];
		}
		else {
			int y = *upper_bound(all(cnt[x]), ta);
			ans += y - ta;
			ta = y;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll gcd(ll x, ll y) {

    if(y == 0) {
        return x;
    }
    
    return gcd(y, x%y);
}

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

    rep(i, T) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;

        if(b > a || b > d) {
            cout << "No" << "\n";
            continue;
        }

        if(c >= b) {
            cout << "Yes" << "\n";
            continue;
        }

        ll g = gcd(b, d);
        ll e = b - g + a%g;

        if(e > c) {
            cout << "No";
        }
        else {
            cout << "Yes";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2])
    cout << "No" << endl;
    else  if (S[0] == S[2]) 
    cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
a = list(raw_input())
b = a[2:-1]
if a[0] == "A" and b.count("C") == 1:
  c = b.index("C")
  a.pop(0)
  a.pop(c+1)
  d = ""
  for i in range(len(a)):
     d += a[i] 
  if d.islower():
     print "AC"
  else:
     print "WA"
else:
  print "WA"

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
const int M=300000;
int n;
string s;
int a[M];
int main()
{
	cin>>n>>s;
	s=s+s;
	for(int i1=0;i1<2;i1++)
		for(int i2=0;i2<2;i2++)
	{
		a[0]=i1;
		a[1]=i2;
		for(int j=2;j<=n+1;j++)
		{
			if ((s[j-1]=='o'&&a[j-1]==0)||(s[j-1]=='x'&&a[j-1]==1))
				a[j]=a[j-2];
			if ((s[j-1]=='o'&&a[j-1]==1)||(s[j-1]=='x'&&a[j-1]==0))
				a[j]=1-a[j-2];
		}
		if (a[n]==a[0]&&a[n+1]==a[1])
		{
			for(int j=0;j<n;j++)
				cout<<(a[j]?"W":"S");
			return 0;
		}
	}
	cout<<-1;
	return 0;	
} 

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

int f(int N, int K) {
  if (N == 1) return K;
  return (K - 1) * f(N - 1, K);
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << f(N, K) << endl;
}

Measured memory_bytes: 3600
#include<iostream>
int main()
{
	long long n,s,k;
	while(std::cin>>n,n>=0)
	{
		for(s=0,k=1;n;) s+=n%4*k,n/=4,k*=10;
		std::cout<<s<<'\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	for (int i = 0; i < (int)s.length() - 1; ++i) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < (int)s.length() - 2; ++i) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

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

Measured memory_bytes: 592
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W, K = map(int, input().split())
a = []
s = 0
for _ in range(H): a += list(input())[: -1]
for i in range(H * W):
  if a[i] == "S":
    s = i
    break
Q = dq([s])
d = [-1, 0, 1, 0]
dp = [float("inf")] * (H * W)
dp[s] = 0
while len(Q):
  p = Q.popleft()
  for k in range(4):
    q = p + d[k] + d[-1 - k] * W
    if q in range(H * W):
      if a[q] == "#": continue
      if dp[p] + 1 < dp[q]:
        dp[q] = dp[p] + 1
        Q.append(q)
res = float("inf")
for i in range(H * W):
  if dp[i] > K: continue
  n = i // W
  s = H - (i // W) - 1
  e = W - (i % W) - 1
  w = i % W
  res = min(res, -(-min(n, s, e, w) // K))
print(res + 1)

Measured memory_bytes: 125632
import math
f=math.factorial
n,m=map(int,input().split())
if abs(n-m)>1:
    print("0")
elif abs(n-m)==1:
    ans=f(n)*f(m)
    ans%=1000000007
    print(ans)
else:
    ans=f(n)*f(m)
    ans*=2;
    ans%=1000000007
    print(ans)
    

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

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		if(A!=1&&B!=1) {
			if(A>B) {
				System.out.println("Alice");
			}else if(B>A){
				System.out.println("Bob");
			}else {
				System.out.println("Draw");
			}
		}else {
			if(A==1&&B!=1) {
				System.out.println("Alice");
			}else if(A!=1&&B==1) {
				System.out.println("Bob");
			}else {
				System.out.println("Draw");
			}
		}
		
			
		
	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 200000;
const int N = 100;

int c[MAX+1];

int main() {
	int n,k;cin>>n>>k;
	rep(i,n) c[i]=0;
	rep(i,n) {int a;cin>>a;c[a-1]++;}
	sort(c,c+n);
	int ans=0;
	rep(i,n-k) ans+=c[i];
	cout<<ans<<endl;
}


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

using namespace std;

bool check(string& s)
{
    while (s != "ABC") {
        int N = s.size(), p = 0;
        string ns;
        for (int i = 0; i < N; i++) {
            if (i < N - 2 && s.substr(i, 3) == "ABC") {
                i += 2;
                ns += "#";
                p++;
            } else {
                ns += s[i];
            }
        }

        if (p == 0) return 0;
        vector<bool> exist(3);
        for (int i = 0; i < (int)ns.size(); i++) {
            if (ns[i] == '#') continue;
            exist[ns[i] - 'A'] = 1;                
        }

        if (exist[0] + exist[1] + exist[2] != 2) return 0;
        char c = (exist[0] == 0 ? 'A' : exist[1] == 0 ? 'B' : 'C');
        for (int i = 0; i < (int)ns.size(); i++) {
            if (ns[i] == '#') {
                ns[i] = c;
            }
        }
        s = ns;
    }
    return 1;
}

int main()
{
    string s;
    cin >> s;
    cout << (check(s) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    sum+=s[i];
  }
  if(sum%10!=0){
    cout << sum << endl;
  }
  else{
    int t=sum;
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
      if(s[i]%10!=0){
        t=s[i];
        break;
      }
    }
    cout << sum-t << endl;
  }
}

Measured memory_bytes: 256