akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

int main(){
  string s,t;
  cin >> s >> t;
  int N = s.size();
  int ans = 0;
  rep(i,N) {
	if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3452
N = int(input())
T = [int(input()) for _ in range(N)]
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(T))

Measured memory_bytes: 5228
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K) = Slice2<long>();
            if (N % K == 0)
                WriteLine("0");
            else
                WriteLine("1");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27456
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;



    ll ans = 0;
    int r = 0;
    int b = 0;
    rep(i,s.size()){
        if(s[i]=='0'){
            r++;
        }else{
            b++;
        }
        if(r>0&&b>0){
            ans+=2;
            r--;
            b--;
        }
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<char> L = new List<char>();
		List<int> Lidx = new List<int>();
		for(int i=0;i<N;i++) if(S[i] != 'x'){
			L.Add(S[i]);
			Lidx.Add(i);
		}
		
		if(L.Count == 0){
			Console.WriteLine(0);
			return;
		}
		
		if(!IsPalindromic(L)){
			Console.WriteLine(-1);
			return;
		}
		
		int NN = L.Count;
		int l = NN/2;
		int r = NN/2;
		if(NN % 2 == 0) l--;
//		Console.WriteLine("{0} {1}",l,r);
		int ans = 0;
		while(l > 0){
			int cl = Lidx[l] - Lidx[l-1] - 1;
			int cr = Lidx[r+1] - Lidx[r] - 1;
			ans += Math.Abs(cl - cr);
			l--;
			r++;
		}
		int cl0 = Lidx[l];
		int cr0 = N - Lidx[r] - 1;
		ans += Math.Abs(cl0 - cr0);
		Console.WriteLine(ans);
	}
	
	bool IsPalindromic(List<char> L){
		int NN = L.Count;
		int l = NN/2;
		int r = NN/2;
		if(NN % 2 == 0) l--;
		while(l >= 0){
			if(L[l] != L[r]) return false;
			l--; r++;
		}
		return true;
	}
	
	int N;
	String S;
	public Sol(){
		S = rs();
		N = S.Length;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
import java.util.*;

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

		while(n-- > 0){
			String order = sc.next(), m = sc.next();
			int len = m.length();

			for(int i=order.length()-1;i>=0;i--){
				switch(order.charAt(i)){
				case 'J':
					m = m.substring(len-1) + m.substring(0,len-1);
					break;
				case 'C':
					m = m.substring(1) + m.substring(0,1);
					break;
				case 'E':
					if(len%2==0) m = m.substring(len/2) + m.substring(0,len/2);
					else m = m.substring(len/2+1) + m.substring(len/2,len/2+1) + m.substring(0,len/2);
					break;
				case 'A':
					m = new StringBuilder(m).reverse().toString();
					break;
				case 'P':
					String s = "";
					for(int j=0;j<len;j++){
						char c = m.charAt(j);
						if('0'<=c && c<='9'){
							if(c == '0') c = '9';
							else c--;
						}
						s += c;
					}
					m = s;
					break;
				case 'M':
					s = "";
					for(int j=0;j<len;j++){
						char c = m.charAt(j);
						if('0'<=c && c<='9'){
							if(c == '9') c = '0';
							else c++;
						}
						s += c;
					}
					m = s;
					break;
				}
			}
			System.out.println(m);
		}
	}
}

Measured memory_bytes: 12000
from itertools import permutations as p


INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x:int(x) - 1, input().split()))

# 隣接行列
dist = [[INF] * N for _ in range(N)]

# 初期化、対角成分は0、それ以外はINF
for i in range(N):
    dist[i][i] = 0

# 繋がっている街への距離を記録
for _ in range(M):
    A, B, C = map(int, input().split())
    A, B = A - 1, B - 1
    dist[A][B] = dist[B][A] = C


# Warshall-Floyd
def main():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = INF
    # rの全ての並び替えに対して、スタートからゴールまでのdistを足し合わせて最小を求める
    for combi in p(r, R):
        temp = 0
        for i in range(R - 1):
            cost = dist[combi[i]][combi[i + 1]]
            if cost < INF:
                temp += cost
            # 繋がってない場合はbreak
            else:
                break
        else:
            ans = min(ans, temp)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 74688
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int n,num[200005],ans[200005];
vector<int> g[200005],dp(200005,2147483647);
void DFS(int v,int p){
	auto x=lower_bound(dp.begin(),dp.begin()+n,num[v]);
	int y=*x;
	*x=num[v];
	ans[v]=lower_bound(dp.begin(),dp.begin()+n,2147483647)-dp.begin();
	for(auto z:g[v])
		if(z!=p)
			DFS(z,v);
	*x=y;
}
int main(){
	int i,from,to;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&num[i]);
	for(i=0;i<n-1;i++){
		scanf("%d%d",&from,&to);
		g[from].emplace_back(to);
		g[to].emplace_back(from); 
	}
	DFS(1,-1);
	for(i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 27388
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[1000030] = {};
long long int kazu[100030] = {};
int main() {
	long long int n;
	cin >> n;
	dp[1] = 1;
	for (long long int i = 2; i*i <= n; i++) {
		if (dp[i] == 0) {
			for (long long int j = i+i; j * j <= n; j = j + i) {
				dp[j] = 1;
			}
		}
	}
	long long int ans = 0;
	long long int k = n;
	for (long long int i = 2; i * i <= n; i++) {
		if (dp[i] == 0) {
			long long int a = i;
			while (k % a == 0) {
				k = k / a;
			}
			while (n % a == 0) {
				ans++;
				n = n / a;
				a = a * i;
			}
		}
	}
	if (k != 1) {
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll inf=1e16+1000;
ll k,n,a[N];
int main()
{
	while(cin>>k)
	{
	
		n=50;
		ll num=k/n,re=k%n;
		for(int i=1;i<=n;i++)
			a[i]=num+i-1;
		for(int p=1;p<=re;p++)
		{
			for(int i=1;i<=n;i++)
			{
				if(i==p)
					a[i]+=n;
				else
					a[i]--;
			}
		}
		printf("%lld\n",n);
		for(ll i=1;i<=n;i++)
			printf("%lld%c",a[i],i==n?'\n':' ');
	}
	return 0;
}
//25720164523
//154320986863
//500000000000000000

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(500000)
# N < 10^5, A, B, C < 10^9
# s = ('AB', 'AC', 'BC')
# A >= 0, B >= 0, C >= 0
# N回操作できるか？できるなら道筋を
# 各ステップで2通りのどちらかしか選択できない。
# DPだと思う
# (A, B, C, i, '')

def f(x, dic):
    if x[4] == '':
        return 1
    else:
        if f(dic[x], dic):
            print(x[4])
            return 1

N, A, B, C = [int(i) for i in input().split()]
S = [input() for _ in range(N)]
i = 0
dic = {}
que = deque([(A, B, C, i, '')])
while len(que) != 0:
    x = que.pop()
    i = x[3]
    if x[3] == N:
        print('Yes')
        f(x, dic)
        exit()
    if S[i] == 'AB':
        if x[1] > 0:
            newx = (x[0]+1, x[1]-1, x[2], x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1]+1, x[2], x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'BC':
        if x[2] > 0:
            newx = (x[0], x[1]+1, x[2]-1, x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
        if x[1] > 0:
            newx = (x[0], x[1]-1, x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'AC':
        if x[2] > 0:
            newx = (x[0]+1, x[1], x[2]-1, x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1], x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    else:
        print('error')
print('No')



Measured memory_bytes: 210676
def e_flatten(MOD=10**9 + 7):
    from fractions import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    lcm = reduce(lambda x, y: y // gcd(x, y) * x, A) % MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten())


Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string S;
    cin >> S;

    int i;
    int ans = 0;

    for(i = 0; i < S.size(); i++)
    {
        if(S.at(i) == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
from itertools import product
H,W,K = map(int, input().split())
C = []
for _ in range(H):
  C.append(input())
  
ans = 0
for hp in product([0,1], repeat=H):
  for wp in product([0,1], repeat=W):
    wk = 0
    for i in range(H):
      for j in range(W):
        if C[i][j] == '#' and hp[i] == 0 and wp[j] == 0:
          wk += 1
    #print(hp, wp, wk)
    if wk == K:
      ans += 1
      
print(ans)

Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n; cin >> n;
	if (n == 3 || n == 5 || n == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 3564
using System;
class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        long result = 1;
        long[] array = new long[n];
        string[] input = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++){
            array[i] = long.Parse(input[i]);
            if(array[i] == 0) {
              Console.WriteLine(0);
              return;
            }
        }
        for(int i=0; i<n; i++){
            result *= array[i];
            //Console.WriteLine(result);
            if(result > 1000000000000000000 || result <= 0) {
              Console.WriteLine(-1);
              return;
            }
        }
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 36136
#include <algorithm>
#include <array>
#include <iostream>

int main(void)
{
    int p, q, r;
    std::cin >> p >> q >> r;
    int result = std::min({p + q, q + r, p + r, r + q, r + p, q + p});
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 888
import math

def main():
	N = int(input())
	f = prime_factorize(N)
	cnt = 0
	if N == 1:
		print(cnt)
		return 0

	for p in f:
		prime = p[0]
		power = p[1]
		tmp = math.floor((math.sqrt(1 + 8 * power) - 1) / 2)
		cnt += tmp
	print(cnt)


def prime_factorize(n):
	ret = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			cnt = 0
			while n % i == 0:
				cnt += 1
				n = n // i
			ret.append([i, cnt])
	if n != 1:
		ret.append([n, 1])
	if len(ret) == 0:
		ret.append([n, 1])

	return ret

main()

Measured memory_bytes: 9472
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int L=sc.nextInt(),R=sc.nextInt(),d=sc.nextInt();
		int a=0;
		for(int i=L;i<=R;i++) {
			if(i%d==0) a++;
		}
		System.out.println(a);
	}

}


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

ll po(ll p, ll n){
    ll ans = 1;
    for(int i=0; i<n; ++i){ans *= p;}
    return ans;
}

int main(){
    ll h; cin >> h;
    if(h==1){cout << 1 << endl; return 0;}
    ll sum = 2, cnt = 0;
    while(1){
        if(h>=sum){sum *= 2; cnt++;}
        else{break;}
    }
    ll res = 1;
    for(ll i=1; i<=cnt; ++i){
        ll pp = 2;
        res += po(pp, i);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int num(int x){
    int n=0;
    while(x>=10){
        x=x/10;
        n++;
    }
    return n+1;
}

int digit[100010]={0};
int main(void){
    digit[0]=0;
    for(int i=1;i<=100000;i++){
        if(num(i)%2==1)digit[i]=digit[i-1]+1;
        else digit[i]=digit[i-1];
    }
    int n;
    cin>>n;
    cout<<digit[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N -1
typedef struct{
  int p,left,right;
}node;
void pre(node *u,int total){
  if(total == N) return;
  printf(" %d",total);
  pre(u,u[total].left); pre(u,u[total].right);
}
void in(node *u,int total){
  if(total == N) return;  in(u,u[total].left);
  printf(" %d",total);
  in(u,u[total].right);
}
void post(node *u,int total){
  if(total == N) return;
  post(u,u[total].left); post(u,u[total].right);
  printf(" %d",total);
}
int main(){
  node u[30];
  int total,id,left,right,i;
    scanf("%d",&total);
  for(i=0;i<total;i++) u[i].p = u[i].left = u[i].right = N;
  for(i=0;i<total;i++){
    scanf("%d%d%d",&id,&left,&right);
    u[id].left = left; u[id].right = right; u[left].p = u[right].p = id;
  }
  id = 0;
  while(u[id].p != N) id = u[id].p;
  printf("Preorder\n");
  pre(u,id);
  printf("\n");
  printf("Inorder\n");
  in(u,id);
  printf("\n");
  printf("Postorder\n");
  post(u,id);
  printf("\n");
return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string a = "AKIHABARA", s; cin >> s;
	int pos = 0;
	for(char c : s){
		if(pos < a.size() && c != a[pos]){
			while(pos < a.size() && a[pos] == 'A') pos++;
		}
		if(pos >= a.size() || c != a[pos]){
			cout << "NO" << endl;
			return 0;
		}
		pos++;
	}
	cout << (pos >= a.size() - 1 ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] h = new int[n];

        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }

        int count = 0;
        int max = 0;

        for(int i = n - 1; i > 0; i--){
            if(h[i - 1] >= h[i]){
                count++;
            } else {
                if(count > max) {
                    max = count;
                }
                count = 0;
            }
        }

        if(count > max) {
            max = count;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 49304
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		String[] strAry = str.split(" ");

	    int a = Integer.parseInt(strAry[0]);
	    int b = Integer.parseInt(strAry[1]);
        String ans = "";

        if(a == b) {

        	ans = "a == b";

        } else if (a < b) {

        	ans = "a < b";

        } else if(a > b) {

        	ans = "a > b";

        }

        System.out.println(ans);

	}
}

Measured memory_bytes: 24292
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
namespace { using std::cin, std::cout, std::endl, std::string, std::vector; }

int main()
{
	std::unordered_map<int, int> map;
	int N;
	cin >> N;
	long long count = 0;
	for (int i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
		if (i + A < N)
			map[i + A]++;
		if (i - A >= 0)
			count += map[i - A];
	}
	cout << count << endl;
}

Measured memory_bytes: 10604
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<int> pos;
	int loc = 0;
	auto pos_v = S.find("AC", loc);

	while (string::npos != pos_v) {
		pos.push_back(pos_v);
		pos_v = S.find("AC", pos_v + 1);
	}

	vector<int> l(Q, 0);
	vector<int> r(Q, 0);
	for (int i = 0; i < Q; i++) {
		cin >> l[i] >> r[i];
	}

	for (int i = 0; i < Q; i++) {
		cout << distance(lower_bound(pos.begin(), pos.end(), l[i] - 1), upper_bound(pos.begin(), pos.end(), r[i] - 2)) << endl;
	}
	return 0;
}



Measured memory_bytes: 2172
N = int(input())
s = input()

def SorW(i, now, pre):
    if s[i] == "o":
        if now == "S":
            return pre
        elif now == "W":
            return ("S" if pre == "W" else "W")
    elif s[i] == "x":
        if now == "S":
            return ("S" if pre == "W" else "W")
        elif now == "W":
            return pre

if s[0] == "o":
    Ini = ["SSS", "WSW", "SWW", "WWS"]
else:
    Ini = ["SSW", "WSS", "SWS", "WWW"]

for start in Ini:
    pre, now = start[1], start[2]
    ans, i = pre + now, 1
    while i <= N-1:
        next = SorW(i, now, pre)
        now, pre = next, now
        i += 1
        ans += next
    if start[1] == now and start[0] == pre:
        print(ans[:-1])
        break
else:
    print(-1)

Measured memory_bytes: 3572
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int h, w;
  cin >> h >> w;
  vector<char> c(200, 0);
  for(int i = 0; i < h; i++) {
    string tmp;
    cin >> tmp;
    for(int j = 0; j < w; j++) {
      c[tmp[j]]++;
    }
  }
  if(h % 2 == 0 && w % 2 == 0) {
    for(int i = 0; i < 200; i++) {
      if(c[i] % 4 != 0) {
        cout << "No\n";
        return 0;
      }
    }
    cout << "Yes\n";
  } else if(h % 2 != w % 2) {
    for(int i = 0; i < 200; i++) {
      if(c[i] % 2 != 0) {
        cout << "No\n";
        return 0;
      }
    }
    int cnt = 0;
    for(int i = 0; i < 200; i++) {
      if(c[i] % 4 != 0) {
        cnt += 2;
      }
    }
    if(h % 2 == 0) {
      if(cnt > h) {
        cout << "No\n";
        return 0;
      }
    } else {
      if(cnt > w) {
        cout << "No\n";
        return 0;
      }
    }
    cout << "Yes\n";
  } else {
    int one = 0;
    for(int i = 0; i < 200; i++) {
      if(c[i] % 2 != 0) {
        one++;
      }
    }
    if(one != 1) {
      cout << "No\n";
      return 0;
    }
    int cnt = 0;
    for(int i = 0; i < 200; i++) {
      if(c[i] % 2 != 0) {
        continue;
      } else if(c[i] % 4 != 0) {
        cnt += 2;
      }
    }
    if(cnt > h + w - 2) {
      cout << "No\n";
      return 0;
    }
    cout << "Yes\n";
  }
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; ll k; cin >> n >> k;
	vi a(n);
	rep(i,n){
		cin >> a[i];
		a[i]--;
	}
	vi b(n,-1);
	int now=0;
	b[now]=0;
	int mod;
	ll cnt;
	rep(i,k){
		now = a[now];
		k--;
//		cout << now << " ";
		if(b[now]!=-1){
			mod = i+1-b[now];
			break;
		}
		b[now]=i+1;
	}
//	cout  << endl;
//	cout << k << " " << now << " " << mod << endl;	
	k %= mod;
	rep(i,k){
		now = a[now];
	}	
//	cout << k << " " << now << " " << mod << endl;
		cout << now+1 << endl;
}


Measured memory_bytes: 4852
#include <cstdio>
 
int main()
{
    int n;
 
    while (scanf("%d", &n), n) {
	int p, d1, d2;
	int ans = 0, num;
 
	while (n--) {
	    scanf("%d %d %d", &p, &d1, &d2);
	    if (ans < d1+d2) {
		ans = d1+d2;
		num = p;
	    }
	}
	printf("%d %d\n", num, ans);
    }
    return 0;
}

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

struct Time{
	public: 
	int hour, minute;
	Time(){}
	Time(int h, int m){
		hour = h;
		minute = m;
	}
	void Show(){
		cout << hour << ':' << setw(2) << setfill('0') << minute;
	}
};

bool CompareTime(Time& t1, Time& t2){
	if(t1.hour < t2.hour){
		return true;
	}else if(t1.hour == t2.hour){
		if(t1.minute < t2.minute){
			return true;
		}else{
			return false;
		}
	}else{
		return false;
	}
}

bool EqualTime(Time& t1, Time&t2){
	if(t1.hour == t2.hour && t1.minute == t2.minute){
		return true;
	}
	return false;
}

int main(){
	int n = 0;
	cin >> n;
	Time iimori[n];
	for(int i = 0; i < n; i++){
		int h, m;
		cin >> h >> m;
		iimori[i] = Time(h, m);
	}
	int m = 0;
	cin >> m;
	Time tsuruga[m];
	for(int i = 0; i < m; i++){
		int g, k;
		cin >> g >> k;
		tsuruga[i] = Time(g, k);
	}
	int iimoriIndex = 0;
	int tsurugaIndex = 0;
	Time all[n + m];
	int allIndex = 0;
	while(iimoriIndex != n && tsurugaIndex != m){
		if(CompareTime(iimori[iimoriIndex], tsuruga[tsurugaIndex])){
			all[allIndex] = iimori[iimoriIndex];
			allIndex++;
			//iimori[iimoriIndex].Show();
			iimoriIndex++;
		}else{
			all[allIndex] = tsuruga[tsurugaIndex];
			allIndex++;
			//tsuruga[tsurugaIndex].Show();
			tsurugaIndex++;
		}
		//cout << ' ';
	}
	if(iimoriIndex != n){
		for(int i = iimoriIndex; i < n; i++){
			/*iimori[i].Show();
			if(i != n - 1){
				cout << ' ';
			}*/
			all[allIndex] = iimori[i];
			allIndex++;
		}
	}else{
		for(int i = tsurugaIndex; i < m; i++){
			/*tsuruga[i].Show();
			if(i != m - 1){
				cout << ' ';
			}*/
			all[allIndex] = tsuruga[i];
			allIndex++;
		}
	}
	for(int i = 0; i < allIndex; i++){
		if(i != 0){
			if(EqualTime(all[i], all[i - 1])){
				continue;
			}
			cout << ' ';
		}
		all[i].Show();
	}
	cout << endl;
	return 0;
}

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

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

int main(){
	int n,x;
	int a,b,c;
	int i,j,k;
	cin>>n>>x;
	for(i=0;i<n;i++){
		cin>>a;
		if(i==0)b=x-a;
		else b=gcd(x-a,b);
	}
	if(b<0)b=-b;
	cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 21:58:18 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  W, H, x, y = list(map(int, input().split()))

  cx, cy = W/2, H/2
  epsilon = 1e-9
  is_multi = 1 if abs(x-cx) < epsilon and abs(y-cy) < epsilon else 0
  print(W*H/2, is_multi)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 61336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll n;
     cin>>n;
     ll a[n];
     for(int i=0;i<n;i++){
         cin>>a[i];
     }
     ll m=INT_MAX;
     for(int i=0;i<=100;i++){
         ll stam=0;
         for(int j=0;j<n;j++){
             stam+=(a[j]-i)*(a[j]-i);
         }
         m=min(m,stam);
     }
     cout<<m<<endl;
}
     

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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	string a, b, c;
	cin >> a >> b >> c;
	int l1 = a.length();
	int l2 = b.length();
	if (a[l1 - 1] == b[0] && b[l2 - 1] == c[0]) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let pp = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun d -> d - 1 in
  let changed = ref 0 in
  for i = 0 to n - 1 do
    if pp.(i) <> i then changed := !changed + 1
  done;
  Printf.printf "%s\n" @@
    if !changed <= 2 then "YES" else "NO"


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

typedef long long LL;
typedef pair<int, int> II;

const int N = (int) 1e5 + 10;
int n, t, a[N], R[N];
bool rec[N];
map<int, int> pos;

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

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

    R[n] = a[n];
    for (int i = n - 1; i >= 1; --i) R[i] = max(R[i + 1], a[i]);
    for (int i = 1; i <= n; ++i) pos[a[i]] = i;

    int sum = 0, ans = 0;
    for (int i = 1; i <= n; ++i) sum = max(sum, R[i] - a[i]);
    for (int i = n; i >= 1; --i) if (R[i] - a[i] == sum) {
        int k = pos[R[i]];
        if (rec[k] == false) rec[k] = true, ans++;
    }

    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const int T = 120*60;

int main()
{
	ll h, s, m;
	ll t;

	while (cin >> h >> m >> s && h != -1 ){
		t = (ll)T - (h*60*60 + m*60 + s );
		printf ("%02lld:%02lld:%02lld\n", t/3600, t%3600/60, t%3600%60 );
		t *= 3L;
		printf ("%02lld:%02lld:%02lld\n", t/3600, t%3600/60, t%3600%60 );
	} // end loop

	return 0;
}

Measured memory_bytes: 0
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-A
int solve(int a)
{
	int ans=0;
	while(a>=0)
	{
		if(a%2==0)
			ans++;
		else
			break;
		a/=2;
	}
	return ans;
}
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n;
		cin>>n;
		if(n==1)
		{
			cout<<1<<endl;
			continue;
		}
		int max1=0;
		int ans=0;
		for(i=1;i<=n;i++)
		{
			int q=solve(i);
			if(max1<q)
			{
				max1=q;
				ans=i;
			}
		}
		cout<<ans<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=20005;
int n,m,tot,fa[N],dep[N],son[N],q[N],tl,a[N],b[N],rev[N],del[N],c[N],ans;
vector<int>E[N],vec,G[N];
void dfs(int u,int f){
	fa[u]=f;dep[u]=dep[f]+1;
	for(int v:E[u])if(v!=f)dfs(v,u),++son[u];
}
void add(int u,int v){
	while(u!=v)
		if(dep[u]>dep[v])++c[u],u=fa[u];
		else ++c[v],v=fa[v];
}
void dfs2(int u){
	swap(a[u],b[u]);
	for(int v:G[u])dfs2(v);
}
int main(){
	scanf("%d%d",&n,&m);tot=m;
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	dfs(1,0);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&a[i],&b[i]);
		add(a[i],b[i]);vec.push_back(i);
	}
	for(int i=1;i<=n;++i)if(!son[i])q[++tl]=i;
	for(int i=1;i<=n;++i){
		int u=q[i];vector<int>tmp;
		for(int j=0;j<vec.size();++j)
			if(a[vec[j]]==u||b[vec[j]]==u)
				tmp.push_back(vec[j]),vec.erase(vec.begin()+j),--j;
		while(tmp.size()>=2){
			int p=tmp.back();tmp.pop_back();
			int q=tmp.back();tmp.pop_back();
			if(a[p]!=u)dfs2(p);
			if(b[q]!=u)dfs2(q);
			if(a[q]!=b[p]){
				a[++tot]=a[q];b[tot]=b[p];
				vec.push_back(tot);
				G[tot].push_back(p);G[tot].push_back(q);
				del[p]=del[q]=1;
			}
		}
		if(tmp.size()){
			int p=tmp.back();tmp.pop_back();
			if(a[p]!=u)dfs2(p);
			if(fa[u]!=b[p]){
				a[++tot]=fa[u];b[tot]=b[p];
				vec.push_back(tot);
				G[tot].push_back(p);del[p]=1;
			}
		}
		ans+=min(2,c[u]);
		if(!--son[fa[u]])q[++tl]=fa[u];
	}
	printf("%d\n",ans);
	for(int i=1;i<=m;++i){
		if(rev[i])swap(a[i],b[i]);
		printf("%d %d\n",a[i],b[i]);
	}
	return 0;
}


Measured memory_bytes: 1536
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,mn=100000,mx=0; cin>>n; 
    while (n--){
        int a; cin>>a;
        mn = min(mn,a);
        mx = max(mx,a);
    }
    cout << (mx-mn) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3520
#include<stdio.h>
char f[6][6],i,j,a,y,x,p;
int main()
{
	for(;i<9;++i){
		scanf("%s",f[5]);
		for(j=0;j<4+i%2;++j){
			a=f[5][j]-48;
			f[i/2][j]|=a<<(1+i%2);
			f[i/2+i%2][j+!(i%2)]|=a<<3-i%2*3;
		}
	}
	do{
		while(!((f[y][x]>>(p=(p+1)%4))&1));
		putchar("URDL"[p]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
		p=(p+2)%4;
	}while(y!=0||x!=0||f[0][0]==6&&p==3);
	return !puts(""); 
}

Measured memory_bytes: 0
def main():
    N = int(input())
    S = input()
    R = 0
    B = 0
    for i in range(0,N):
        if S[i] == "R":
            R = R + 1
        else:
            B = B + 1
        if R > N/2:
            print("Yes")
            return
        elif B > N/2:
            print("No")
            return
    print("No")
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

int getnum(vector<int>&used, const vector<vector<int>>&walls, vector<vector<int>>&decided,int now) {
	int sum = 0;
	if (now == 10)return 1;
	else 	if (now < 5) {
		const int y = now;
		for (int i = 0; i < 10; ++i) {
			if (used[i])continue;
			else {
				used[i] = true;
				for (int rev = 0; rev < 2; ++rev) {
					if (rev&&walls[i][0] == walls[i][4] && walls[i][1] == walls[i][3])continue;
					for (int x = 0; x < 5; ++x) {
						decided[y][rev?4-x:x] = walls[i][x];
					}
					sum += getnum(used, walls, decided, now + 1);
					for (int x = 0; x < 5; ++x) {
						decided[y][rev ? 4 - x : x] = -1;
					}
				}
				used[i] = false;
				
			}
		}
		
	}
	else {
		const int x = now-5;
		for (int i = 0; i < 10; ++i) {
			if (used[i])continue;
			else {
				used[i] = true;
				for (int rev = 0; rev < 2; ++rev) {
					if (rev&&walls[i][0] == walls[i][4] && walls[i][1] == walls[i][3])continue;

					bool ok = true;
					for (int y = 0; y < 5; ++y) {
						if (decided[rev ? 4 - y : y][x] == walls[i][y])ok = false;
					}
					if (!ok)continue;
					
					sum += getnum(used, walls, decided, now + 1);

				}
				used[i] = false;

			}
		}

	}
	return sum;
}

int main() {
	while (1) {
		vector<vector<int>>walls (10);
		for (int i = 0; i < 10; ++i) {
			string st; cin >> st;
			if (st == "END")return 0;
			else {
				for (int j = 0; j< 5; ++j) {
					walls[i].push_back(st[j] == '1');
				}
			}
		}
		vector<int>used(10, false);
		vector<vector<int>>decided(5, vector<int>(5, -1));
		int ans = getnum(used, walls, decided, 0);
		cout << ans/8<< endl;
	}
	return 0;
}

Measured memory_bytes: 3120
N = int(input())
A = list(map(int, input().split(" ")))

num,pt,n_pt,count = 1,-1,0,0
while n_pt < len(A):
    if A[n_pt] == num:
        count += n_pt - pt -1
        pt = n_pt
        num += 1
    n_pt += 1
if pt != -1:
    count += len(A) - pt -1
    print(count)
else:
    print(-1)


Measured memory_bytes: 24744
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, 0, n) {
		cin >> c[i];
		rep(i2, 0, m) {
			cin >> a[i][i2];
		}
	}
	ll M = 1ll << 60, t;
	bool f = 1;
	rep(i, 0ll, 1 << n) {
		vector<int> s(n);
		t = 0;
		rep(i2, 0, n) {
			if (i >> i2 & 1) {
				rep(i3, 0, m) {
					s[i3] += a[i2][i3];
				}
				t += c[i2];
			}
		}
		f = 1;
		rep(i2, 0, m) {
			if (s[i2] < x) {
				f = 0; break;
			}
		}
		if (f)M = min(M, t);
	}
	if (M == 1ll << 60)puts("-1");
	else printf("%lld\n", M);
	return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>

int main()
{
    long long int n, m, ans=0;
    scanf("%lld %lld", &n, &m);
    if(n<2)
        n = 3;
    if(m<2)
        m = 3;
    ans = (n-2) * (m-2);
    printf("%lld", ans);
    return 0;
}

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

int main() {
  double n; cin >> n;
  int t = ceil(n / 1.08);
  if (int(t * 1.08) == n) cout << t << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
int main(){
  long N;
  long PRIME = (long)1e9+7;
  cin >> N;
  vector<vector<long>> dp(N + 1, vector<long>(4, 0));
  // 0 none
  // 1 only 0
  // 2 only 9
  // 3 both

  dp[0][0] = 1;
  dp[0][1] = 0;
  dp[0][2] = 0;
  dp[0][3] = 0;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < 4; j++){
      for(int x = 0; x <= 9; x++){
        if(j == 0){
          if(x == 0){
            dp[i + 1][1] += dp[i][0];
          }
          else if(x == 9){
            dp[i + 1][2] += dp[i][0];
          }
          else{
            dp[i + 1][0] += dp[i][0];
          }
        }
        else if(j == 1){
          if(x == 9){
            dp[i + 1][3] += dp[i][1];
          }
          else{
            dp[i + 1][1] += dp[i][1];
          }
        }
        else if(j == 2){
          if(x == 0){
            dp[i + 1][3] += dp[i][2];
          }
          else{
            dp[i + 1][2] += dp[i][2];
          }
        }
        else{
          dp[i + 1][3] += dp[i][3];
        }
        dp[i + 1][j] %= PRIME;
      }
    }
  }
  cout << dp[N][3] << "\n";
  return 0;
}

Measured memory_bytes: 73396
n, t = map(int, input().split())
a = list(map(int, input().split()))

mina = a[0]
minac = 1
maxd = 0
maxdc = 1
for i in range(1, n):
    if a[i] < mina:
        mina = a[i]
        minac = 1
    elif a[i] == mina:
        minac += 1
    elif a[i] - mina > maxd:
        maxd = a[i] - mina
        maxdc = 1
    elif a[i] - mina == maxd:
        maxdc += 1
print(maxdc)


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

int main(){
  vector<int> v(26, 0);
  for(int i = 0; i < 1200; i++){
    string s;
    cin >> s;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == 'a' || s[j] == 'A'){ v[0]++; }
      else if(s[j] == 'c' || s[j] == 'C'){ v[2]++; }
      else if(s[j] == 'd' || s[j] == 'D'){ v[3]++; }
      else if(s[j] == 'e' || s[j] == 'E'){ v[4]++; }
      else if(s[j] == 'f' || s[j] == 'F'){ v[5]++; }
      else if(s[j] == 'g' || s[j] == 'G'){ v[6]++; }
      else if(s[j] == 'h' || s[j] == 'H'){ v[7]++; }
      else if(s[j] == 'i' || s[j] == 'I'){ v[8]++; }
      else if(s[j] == 'j' || s[j] == 'J'){ v[9]++; }
      else if(s[j] == 'k' || s[j] == 'K'){ v[10]++; }
      else if(s[j] == 'l' || s[j] == 'L'){ v[11]++; }
      else if(s[j] == 'm' || s[j] == 'M'){ v[12]++; }
      else if(s[j] == 'n' || s[j] == 'N'){ v[13]++; }
      else if(s[j] == 'o' || s[j] == 'O'){ v[14]++; }
      else if(s[j] == 'p' || s[j] == 'P'){ v[15]++; }
      else if(s[j] == 'q' || s[j] == 'Q'){ v[16]++; }
      else if(s[j] == 'r' || s[j] == 'R'){ v[17]++; }
      else if(s[j] == 's' || s[j] == 'S'){ v[18]++; }
      else if(s[j] == 't' || s[j] == 'T'){ v[19]++; }
      else if(s[j] == 'u' || s[j] == 'U'){ v[20]++; }
      else if(s[j] == 'v' || s[j] == 'V'){ v[21]++; }
      else if(s[j] == 'w' || s[j] == 'W'){ v[22]++; }
      else if(s[j] == 'x' || s[j] == 'X'){ v[23]++; }
      else if(s[j] == 'y' || s[j] == 'Y'){ v[24]++; }
      else if(s[j] == 'z' || s[j] == 'Z'){ v[25]++; }
      else if(s[j] == 'b' || s[j] == 'B'){ v[1]++; }
    }
  }
  
  cout << "a : " << v[0] << endl;
  cout << "b : " << v[1] << endl;
  cout << "c : " << v[2] << endl;
  cout << "d : " << v[3] << endl;
  cout << "e : " << v[4] << endl;
  cout << "f : " << v[5] << endl;
  cout << "g : " << v[6] << endl;
  cout << "h : " << v[7] << endl;
  cout << "i : " << v[8] << endl;
  cout << "j : " << v[9] << endl;
  cout << "k : " << v[10] << endl;
  cout << "l : " << v[11] << endl;
  cout << "m : " << v[12] << endl;
  cout << "n : " << v[13] << endl;
  cout << "o : " << v[14] << endl;
  cout << "p : " << v[15] << endl;
  cout << "q : " << v[16] << endl;
  cout << "r : " << v[17] << endl;
  cout << "s : " << v[18] << endl;
  cout << "t : " << v[19] << endl;
  cout << "u : " << v[20] << endl;
  cout << "v : " << v[21] << endl;
  cout << "w : " << v[22] << endl;
  cout << "x : " << v[23] << endl;
  cout << "y : " << v[24] << endl;
  cout << "z : " << v[25] << endl;
}


Measured memory_bytes: 3144
n = int(input())
s = list(input())
cnt = 0
for i in range(1,n-1):
    if s[i] == 'R':
        cnt += (s[:i].count('G'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('G'))
    if s[i] == 'G':
        cnt += (s[:i].count('R'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('R'))
    if s[i] == 'B':
        cnt += (s[:i].count('G'))*(s[i+1:].count('R')) + (s[:i].count('R'))*(s[i+1:].count('G'))
for i in range(1,n-1):
    if s[i] == 'R':
        for j in range(1,min(i,n-i-1)+1):
            if s[i-j] == 'G' and s[i+j]=='B':
                cnt -=1
            if s[i-j] == 'B' and s[i+j]=='G':
                cnt -=1
    if s[i] == 'G':
        for j in range(1,min(i,n-i-1)+1):
            if s[i-j] == 'R' and s[i+j]=='B':
                cnt -=1
            if s[i-j] == 'B' and s[i+j]=='R':
                cnt -=1
    if s[i] == 'B':
        for j in range(1,min(i,n-i-1)+1):
            if s[i-j] == 'G' and s[i+j]=='R':
                cnt -=1
            if s[i-j] == 'R' and s[i+j]=='G':
                cnt -=1
print(cnt)

Measured memory_bytes: 9388