akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int a,b,c;
	cin>>a>>b;
	if(a==1 && b==2) c = 3;
	if(a==2 && b==1) c = 3;
	if(a==1 && b==3) c = 2;
	if(a==3 && b==1) c = 2;
	if(a==3 && b==2) c = 1;
	if(a==2 && b==3) c = 1;
	cout<<c<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int[] a = new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextInt();
        }
        int index = 0;
        int min = 9;
        for (int i = 0; i < 5; i++) {
            if (a[i] % 10 == 0) {
                continue;
            }
            if (min > (a[i] % 10)) {
                min = a[i] % 10;
                index = i;
            }
        }
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            int x = a[i];
            if (i == index) {
                continue;
            }
            if (a[i] % 10 != 0) {
                x = (a[i] / 10 + 1) * 10;
            }
            sum += x;
        }
        sum += a[index];
        System.out.println(sum);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main()
{
  int a[3][3];
  rep(i, 3) rep(j, 3) cin >> a[i][j];

  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) {
      if (a[i][j] == b) a[i][j] = 0;
    }
  }

  rep(i, 3) {
    if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
      puts("Yes");
      return 0;
    }
  }
  rep(j, 3) {
    if (a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0) {
      puts("Yes");
      return 0;
    }
  }

  if ((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) ||
       a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
         puts("Yes");
         return 0;
  }

  puts("No");

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

unsigned long long dp[301][301];

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


	int N, M;
	scanf("%d %d", &N, &M);

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	int mj = 0;
	int mk = 0;
	unsigned long long yabai = 1;
	rep1(i, N) {
		for (int j = i - 1; j >= mj; j--) {
			auto dpj = dp[j];
			for (int k = i - 1; k >= max(j, mk); k--) {
				dpj[i] += dpj[k];
				dp[k][i] += dpj[k];
			}
		}
		yabai *= i + 1;
		for (int j = i; j > xm[i][2]; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > max(xM[i][3], mj - 1); j--) {
			for (int k = i; k > max(max(xm[i][1], mk - 1), j - 1); k--) dp[j][k] = 0;
			if (yabai > 18446744073709551615 / (i + 1)) {
				for (int k = xm[i][1]; k > max(max(xM[i][2], mk - 1), j - 1); k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= mj; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		if (yabai > 18446744073709551615 / (i + 1)) {
			yabai = mod;
		}
		if (mj <= xM[i][3]) mj = xM[i][3] + 1;
		if (mk <= xM[i][2]) mk = xM[i][2] + 1;
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define debug1(a) cout<<#a<<" "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<" "#c<<" "<<(c)<<endl;
typedef long double ld;
void solve()
{
	ll n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
	cout << endl;

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	Int len = S.size();

	Int ans = 0;
	char temp;

	temp = S[0];
	for (Int i = 1; i < len; i++) {
		if (S[i] != temp) {
			ans++;
			temp = S[i];
		}
	}

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

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

using namespace std;

#define int long long 

signed main(){
	int n;
	cin >> n;
	int a[n][3];
	for(int i=0;i<n;i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=max(dp[i-1][(j+1)%3]+a[i][j],dp[i-1][(j+2)%3]+a[i][j]);
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    set<string> s;
    for(int i=0;i<n;i++){
        char l[6],r[12];
        scanf("%s %s",&l,&r);
        string k=r,h=l;
        if(h=="insert"){
            s.insert(k);
        }else{
            if(s.find(k)!=s.end()){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 27040
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;

int main() {
#ifdef HIRO
  ifstream cin("input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  d("x\n");
  string a, b;
  cin >> a >> b;
  cout << b << a << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=111;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
template<typename T>
inline void read(T &x){
	x=0;
	char ch=getchar();bool f=false;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,ans;
char s[maxn];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1,j=n;i<j;i++,j--) if(s[i]!=s[j]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    bitset<2000009> arr;
    long long n,i,sum=0;
    cin>>n;
    long long a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    arr[0]=1;
    for(i=0;i<n;i++)
    {
        arr=arr|(arr<<a[i]);
    }
    for(i=sum/2;i>=0;i--)
    {
        if(arr[i]==1)
        {
            cout<<sum-i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4404
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long sum =0;
    for (int i = 1; i <= n ; ++i) {
        if(i%3==0
        ||i%5==0)
            continue;
        else
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
using namespace std;

int func(int n){
	if(n%2==0)
		return n/2;

	return 3*n+1;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    int s;
    cin>>s;

    set<int> st;
    st.insert(s);

    int i=2;
    while(1){
    	s = func(s);
    	// cout<<s<<" ";
    	if(st.find(s)==st.end())
    		st.insert(s);
    	else{
    		cout<<i;
    		return 0;
    	}
    	i++;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 public class Main { 
public static void main(String[] args) {
 Scanner sc = new Scanner(System.in);
 int n = sc.nextInt();
 int i = 1;
 do{
 int x = i;
 if(x % 3 == 0){
 System.out.print(" " + i); 
 continue; 
} do{
 if(x % 10 == 3){
 System.out.print(" " + i);
 break;
 } 
 x /= 10;
 }while(x != 0); 
 }while(++i <= n);
  System.out.println();
 } 
} 


Measured memory_bytes: 28920
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int cnt[10] = {0}, a, b ,c;
	cin >> a >> b >> c;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	bool ans = 0;
	for(int i = 1; i <=9; i++){
		if(cnt[i] == 2)ans = 1;
	}
	if(ans)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll inf = 1e18;
int main(){
    int n;
    cin>>n;
    ll ans =(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(a*a*a);
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string str;
    cin>>str;
    if(str=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

class Program{
	static void Main(string[] args){
      
      string input = Console.ReadLine();
      
      List<char> list = new List<Char>();
      
      for(int i = 0;i < input.Length;i ++){
      	if(list.Contains(input[i]))list.Remove(input[i]);
        else list.Add(input[i]);
      }
      
      if(list.Count == 0)Console.WriteLine("Yes");
      else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
string s,a="CODEFESTIVAL2016";
int i,num;
int main()
{
	cin>>s;
	for(int i=0;i<=15;i++){
		if(s[i]!=a[i]){
			num++;
		}
	}
	cout<<num;
	return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;

  vector<int> B(M);
  for ( int i = 0; i < M; i++ )
    B.at(i) = 0;

  for ( int i = 0; i < N; i++ ) {
    int K;
    cin >> K;
    for ( int j = 0; j < K; j++ ) {
      int a;
      cin >> a;
      B.at(a-1)++;
    }
  }

  int ans = 0;
  for ( int i = 0; i < M; i++ )
    ans += B.at(i) / N;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
n = 0
for i in range(1000):
  ps = "%03d"%(i)
  s = S
  is_ok = True
  for j in list(ps):
    if j in s: s = s[s.index(j)+1:]
    else:
      is_ok = False
      break
  if is_ok: n+=1
print(n)

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>
#include <set>
#include <array>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

bool is_prime[55556] = {};
int main() {
	fill(is_prime, is_prime + 55556, true);
	is_prime[0] = is_prime[1] = false;
	vector<int> a; //5で割ったあまりが1の素数
	for (int i = 2; i < 55556; i++) {
		if (is_prime[i] == true) {
			if(i % 5 == 1)a.push_back(i);
			for (int j = 2; i * j < 55556; j++) {
				is_prime[i * j] = false;
			}
		}
	}
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cout << a[i];
		if (i < N - 1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
   int W, H, x, y, r;

    std::cin >> W >> H >> x >> y >> r;

    if((x < r) || (y < r)) {
        std::cout << "No" << std::endl;
    }else if(((W - x) < r) || ((H - y) < r)) {
        std::cout << "No" << std::endl;   
    }else {
        std::cout << "Yes" << std::endl;
    };
    return 0;

}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long L[] = new long[N+1];
		L[0] = 2; L[1] = 1;
		long res = solve(N,L);
		System.out.println(res);
	}

	private static long solve(int N, long[] L) {
		if(L[N]!=0)return L[N];
		else return L[N] = solve(N-1,L)+solve(N-2,L);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double; using pll = pair<lint, lint>;

int main(void) {
    lint n; cin >> n;
    vector<lint> x(n), y(n);
    repeat (i, n) cin >> x[i] >> y[i];
    
    lint parity = abs(x[0]) + abs(y[0]);
    parity %= 2;
    
    repeat (i, n) {
        lint cand = abs(x[i]) + abs(y[i]);
        cand %= 2;
        if (parity != cand) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    const lint m = 31;
    cout << (parity == 1 ? m : (m+1)) << endl;
    vector<lint> d(m);
    repeat_reverse_from_to (i, m-1, 0) {
        d[m-1-i] = (1 << i);
    }
    if (parity == 0) {
        d.push_back(1);
    }
    repeat_reverse_from_to (i, d.size()-1, 0) {
        cout << d[i] << " ";
    }
    cout << endl;
    
    auto dist = [](pll p) -> lint {
        return abs(p.fst) + abs(p.snd);
    };
    
    auto f = [&dist](pll p, lint d, char &c) -> pll {
        pll res = make_pair(1e10, 1e10);
        vector<lint> dx {1, 0, -1, 0};
        vector<lint> dy {0, 1, 0, -1};
        repeat (i, 4) {
            pll cand = make_pair(p.fst + dx[i] * d, p.snd + dy[i] * d);
            if (dist(cand) < dist(res)) {
                res = cand;
                if (i == 0) c = 'L';
                if (i == 1) c = 'D';
                if (i == 2) c = 'R';
                if (i == 3) c = 'U';
            }
        }
        return res;
    };
    
    repeat (i, n) {
        pll p = make_pair(x[i], y[i]);
        string str;
        repeat (j, d.size()) {
            //pdump(p); dump(j); dump(d[j]); el;
            char c;
            p = f(p, d[j], c);
            str += c;
        }
        reverse(str.begin(), str.end());
        cout << str << endl;
        assert (p.fst == 0 and p.snd == 0);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)1e9+7
#define eb emplace_back

/*
 2回足すか2回引くか1回足して1回引くか
 2回足すのはでかく、2回引くのは小さくしたい
 slsl...
 と並べる
 (l - s) + (l - s) + ...
 となる
 
 1. n % 2 == 0
 slsl...sl
 lsls...lsと同値
 l, sの数同じで端がl, s1個ずつだから
 
 2. n % 2 != 0
 真ん中のやつをsとするかlとするか
 s, lどっちか多くなる
 slsl...sls (内っ側のl all * 2)
 lsls...lsl (一番外のl1回ずつ足す)
 
 */
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    if (n % 2 == 0) {
        int k = n / 2 - 1;
        rep(i, k) ans -= 2 * a[i];
        ans -= a[k];
        ans += a[k + 1];
        rrep(i, k + 2, n) ans += 2 * a[i];
    } else {
        //slsl...sls
        int k = n / 2;
        rep(i, k) ans += 2 * a[n - 1 - i];
        rep(i, k - 1) ans -= 2 * a[i];
        ans -= a[k - 1];
        ans -= a[k];
        //lsls...lsl
        ll tmp = 0;
        rep(i, k) tmp -= 2 * a[i];
        rep(i, k - 1) tmp += 2 * a[n - 1 - i];
        tmp += a[k];
        tmp += a[k + 1];
        chmax(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

# 足りない（）の数を求めてみる
left = 0  # (
right = 0 # )
l_count = 0
for i in range(N):
    if S[i] == "(":
        right += 1
    elif S[i] == ")" and right > 0:
        right -= 1
    else:
        l_count += 1

r_count = 0
for i in range(N-1,-1,-1):
    if S[i] == ")":
        left += 1
    elif S[i] == "(" and left > 0:
        left -= 1
    else:
        r_count += 1

left = "".join(["(" for _ in range(l_count)])
right = "".join([")" for _ in range(r_count)])

print(left+S+right)


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

int main() {
  int fst,snd;
  int fPrice,sPrice;
  int stay;
  
  cin >> stay >> fst >> fPrice >> sPrice;
  snd = stay - fst;
  
  if( stay < fst){
    // K泊*X円 
    cout << stay * fPrice;
  }else{
    // K泊*X円 + K+1泊*Y円
    cout << (fst * fPrice) + (snd * sPrice);  
  }  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    long long  a,b,c;
    cin>> a>>b>>c;
    long long ans = 0;
    if(a + b >= c){
        ans = b + c;
    }else{
        ans = 2*b + a + 1;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s,t; cin >> s >> t;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
using namespace std;
bool cover(vector<int>&v){
	int n=0;
	for(int i=0;i<v.size()-1;i++){
		n+=v[i];
		if(n<=0)return false;
	}
	return true;
}
int main(){
	int N,W,H;
	scanf("%d%d%d",&N,&W,&H);
	vector<int>w(W+1);
	vector<int>h(H+1);
	for(int i=0;i<N;i++){
		int x,y,a;
		scanf("%d%d%d",&x,&y,&a);
		w[max(0,x-a)]++;
		w[min(W,x+a)]--;
		h[max(0,y-a)]++;
		h[min(H,y+a)]--;
	}
	puts(cover(w)||cover(h)?"Yes":"No");
}

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

int main()
{
  long long int n;
  cin>>n;
  long long int count=0;
  long long int fin=0;
  for(int i=0;n>=1;i++)
  {
    n=n/2;
    fin=pow(2,i);
    count=count+fin;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if a == b and c[a] > 1:
        c[a] -= 2
        ans += 1
    elif a != b and c[a] > 0 and c[b] > 0:
        c[a] -= 1
        c[b] -= 1
        ans += 1

print(ans)

Measured memory_bytes: 33296
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  int a[n], b[n], c[n - 1];
  REP(i, n)
  cin >> a[i];
  REP(i, n)
  cin >> b[i];
  REP(i, n - 1)
  cin >> c[i];
  int ans = 0;
  REP(i, n)
  {
    if (i > 0 && a[i] - a[i - 1] == 1)
    {
      ans += c[a[i - 1] - 1];
    }
    ans += b[a[i] - 1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

int n;
double cost[1002],sum[1005]={},memo[1005][1005];

double exp(int l,int r){
	if(memo[l][r]!=-1.0)return memo[l][r];
	double ret=1000000000.0;
	if(l==r)ret=cost[l];
	else{
		for(int k=l+1;k<r;k+=2)
			ret=min(ret,exp(l,k-1)+exp(k+1,r)+sum[r]-(l==0?0.0:sum[l-1]));
	}
	return memo[l][r]=ret;
}


int main() {
	cin>>n;
	for(int i=0;i<=2*n+2;i++)for(int j=0;j<=2*n+2;j++)memo[i][j]=-1.0;
	for(int i=1;i<=n;i++)cin>>cost[2*i];
	for(int i=0;i<=n;i++)cin>>cost[2*i+1];
	for(int i=1;i<=2*n+2;i++)sum[i]=cost[i]+sum[i-1];
	cout<<fixed<<exp(1,2*n+1)<<endl;
	return 0;
}


Measured memory_bytes: 11220
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
count = 0
AB.sort(key=lambda x:x[0])
cost = 0
for a in AB:
    if M > a[1]:
        cost += a[0] * a[1]
        M -= a[1]
    else:
        cost += a[0] * M
        break
print(cost)


Measured memory_bytes: 29024
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
ar=[0]+list(accumulate(a))
bru=[0]+list(accumulate(b))
from bisect import bisect_left as bl,bisect_right as br
ans=0
nb=0
for i in range(n,-1,-1):
    if ar[i]>k:continue
    while nb<m and ar[i]+bru[nb]<k:
        nb+=1
    if ar[i]+bru[nb]>k:nb-=1
    ans=max(ans,i+nb)

print(ans)

Measured memory_bytes: 51160
using System;

namespace B___A_to_Z_String
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var a = int.MaxValue;
            var z = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == 'A')
                {
                    if (i < a)
                    {
                        a = i;
                    }
                }
                if (s[i] == 'Z')
                {
                    z = i;
                }
            }
            Console.WriteLine (z - a + 1);
        }
    }
}

Measured memory_bytes: 11616
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;

int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, M;
int a[55], b[55];
bool visited[55];
bool G[55][55];

void dfs(int x) {
    visited[x] = true;
    for (int i = 1; i <= N; i++) {
        if (G[x][i]&&!visited[i]) {
            dfs(i);
        }
    }
}

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }
    int ans = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 1; j <= N; j++) {
            visited[j]=false;
        }
        G[a[i]][b[i]] = false;
        G[b[i]][a[i]] = false;
        dfs(1);
        bool flag = true;
        for (int j = 1; j <= N; j++) {
            flag &= visited[j];
        }
        if (!flag) {
            ans++;
        }
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::pair<i64, int>> vec;
	std::vector<i64> L(m), R(m), c(m);
	for(int i = 0; i < m; i++) {
		scanf("%lld%lld%lld", &L[i], &R[i], &c[i]);
		L[i]--;

		vec.push_back({L[i], i});
	}
	sort(begin(vec), end(vec));

	using P = std::pair<i64, int>;

	int cur = 0;
	std::vector<i64> min_cost(n, 1LL << 60); min_cost[0] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu;
	for(int i = 0; i < n; i++) {
		while(!qu.empty() and qu.top().second <= i) qu.pop();
		if(!qu.empty()) min_cost[i] = std::min(min_cost[i], qu.top().first);

		while(cur < m and vec[cur].first <= i) {
			int id = vec[cur++].second;
			qu.push({c[id] + min_cost[i], R[id]});
		}
	}
//	for(auto v: min_cost) cout << v << " "; cout << endl;
	
	if(min_cost[n - 1] == 1LL << 60) printf("-1\n");
	else printf("%lld\n", min_cost[n - 1]);
	return 0;
}


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

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

    int ans = (b - 1 + a - 2) / (a - 1);
    /*
    int s = a - 1;
    int t = b - 1;
    int ans = (t + s - 1) / s;
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll n;
	cin>>n;
	vector<ll>v;
	while(n>0)
	{
		n--;
		v.pb(n%26);
		n/=26;
	}
	reverse(v.begin(),v.end());
	for(ll i=0;i<v.size();i++)
	{
		cout<<char('a'+v[i]);
	}
	
}

Measured memory_bytes: 3608
a,b,t,i,N;
main(){
    long c=0;
    for(scanf("%d",&N);N--;i++){
        scanf("%d",&t);
        if(!i||a>=t)a=t;
        if(!i||b<=t)b=t;
        c+=t;
    }
    printf("%d %d %ld\n",a,b,c);
}

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

int main()
{
    int a,b;

    scanf("%d %d",&a,&b);

    if((a >= 1 && a <= 9) && (b >= 1 && b <= 9))
        printf("%d\n",a*b);
    else printf("-1");

    return 0;
}


Measured memory_bytes: 128
n,q = map(int,input().split())
s = input()
ans = []
li = [0] * (len(s))
count = 0

for i in range(1,len(s)):
    if s[i] == 'C' and s[i-1] == 'A':
        count += 1
    li[i] = count

for i in range(q):
    l,r = map(int,input().split())
    tmp = li[r-1] - li[l-1]
    ans.append(tmp)

for aa in ans:
    print(aa)


Measured memory_bytes: 10232
if __name__=="__main__":
    n = int(input())
    As = list(map(int,input().split()))
    Non_dup_As = list(set(As))
    count = len(Non_dup_As)
    if(count % 2 == 0):
        print(count - 1)
    else:
        print(count)


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

using namespace std;

long long N, ans, mx;

int main()
{
    cin >> N;
    long long arr[N];
    for (long long i = 0 ; i < N ; i ++) {
        cin >> arr[i];
    }
    for (long long i = 0 ; i < N ; i ++) {
        mx = max(mx, arr[i]);
        ans += mx - arr[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5196
let readInt _ = stdin.ReadLine() |> int


(readInt (), readInt (), readInt (), readInt ())
|> fun (a, b, c, x) ->
    seq {
        for c500 in [ 0 .. a ] do
            for c100 in [ 0 .. b ] do
                for c50 in [ 0 .. c ] do
                    yield c500 * 500 + c100 * 100 + c50 * 50
    }
    |> Seq.filter ((=) x)
    |> Seq.length
    |> printfn "%d"


Measured memory_bytes: 34708
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int H[100005];

bool preeq=false;
bool ok=true;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>H[i];
    for(int i=0;i<N-1;++i){
        if(H[i]>H[i+1]+1){
            ok=false;
            break;
        }
        else if(preeq&&H[i]==H[i+1]+1){
            ok=false;
            break;
        }
        else if(H[i]==H[i+1]+1){
            H[i]--;
            preeq=true;
        }
        else if(H[i]==H[i+1]){
            if(!preeq){
                H[i]--;
                preeq=false;
            }
            else preeq=true;
        }
        else if(H[i]<H[i+1])preeq=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1152
//import java.io.File;
import java.util.Scanner;
import java.util.LinkedList;

public class Main{
  public static void main(String[] args) {
try{
    //Scanner scan = new Scanner(new File("in.txt"));
    Scanner scan = new Scanner(System.in);

    int input1 = scan.nextInt();
    int input2 = scan.nextInt();

    while(input1!=0&&input2!=0) {
      LinkedList<Integer> ll = new LinkedList<>();

      for(int i = input1; i > 0; i--) {
        ll.add(i);
      }

      for(int j = 0; j < input2; j++) {
        /*
            for(int _s : ll) {
              System.out.println(_s);
            }
            System.out.println("end");
            */
        LinkedList<Integer> dummy = new LinkedList<>();

        int input3 = scan.nextInt()-1;
        int input4 = scan.nextInt();

        for(int i = 0; i < input4; i++) {
          dummy.add(ll.get(input3));
          ll.remove(input3);
        }

        ll.addAll(0,dummy);
      }

/*
      for(int _s : ll) {
        System.out.println(_s);
      }
      System.out.println("end000000000000");
      */
      System.out.println(ll.get(0));

      input1 = scan.nextInt();
      input2 = scan.nextInt();
    }
}catch(Exception e) {
  e.printStackTrace();
}
  }
}

Measured memory_bytes: 37556
/**
 *    author:  tourist
 *    created: 13.06.2020 15:12:10       
**/
#include <bits/stdc++.h>

using namespace std;

long long Solve(int w, int h, int k) {
  k = 2 * k - 2;
  long long ans = 0;
  for (int x = 1; x < w; x++) {
    for (int y0 = 1; y0 < h; y0++) {
      int a = (w - x) * y0 - __gcd(x, y0);
      if (a > k + 2 * w) {
        break;
      }
      // a + x * y1 <= k?
      // y1 <= (k - a) / x
      int bound = min(h - 1, max(0, (k - a) / x));
      ans += bound;
      for (int y1 = bound + 1; y1 < h; y1++) {
        int b = a + x * y1;
        if (b > k + 2 * w) {
          break;
        }
        int c = b - __gcd(w - x, y1) - __gcd(w, abs(y0 - y1));
        if (c <= k) {
          ans += 1;
        }
      }
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int w, h, k;
  cin >> w >> h >> k;
  cout << 2 * (Solve(w, h, k) + Solve(h, w, k)) << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
struct Node
{
	Node(int k) : depth(0) { vChildId.resize(k, -1); }
	int depth;
	vector<int> vChildId;
};

void SetNodeDepthRecursive(Node* n, vector<Node*>& vNode)
{
	int s = n->vChildId.size();
	if (0 == s) return;
	for (int i = 0; i < s; ++i){
		Node* cn = vNode[n->vChildId[i]];
		cn->depth = n->depth + 1;
		SetNodeDepthRecursive(cn, vNode);
	}
}

int main()
{
	int nu, id, k, c;
	cin >> nu;
	vector<int> vParentId(nu, -1);
	vector<Node*> vNode(nu, (Node*)0);
	while (nu--){
		cin >> id >> k;
		vNode[id] = new Node(k);
		for (int j = 0; j < k; ++j){
			cin >> c;
			vNode[id]->vChildId[j] = c;
			vParentId[c] = id;
		}
	}
	vector<Node*> vRoot;
	for (int i = 0; i < vNode.size(); ++i){
		if (vParentId[i] == -1)
			vRoot.push_back(vNode[i]);
	}
	for (int i = 0; i < vRoot.size(); ++i)
		SetNodeDepthRecursive(vRoot[i], vNode);

	Node* n;
	int pid;
	for (int i = 0; i < vNode.size(); ++i){
		n = vNode[i];
		pid = vParentId[i];
		cout << "node " << i << ": parent = " << pid << ", depth = " << n->depth << ", ";
		if (pid == -1){
			cout << "root, [";
			if (n->vChildId.size() == 0)
				cout << "]\n";
		}
		else if (n->vChildId.size() == 0) cout << "leaf, []\n";
		else cout << "internal node, [";
		if (n->vChildId.size() != 0){
			int cs = n->vChildId.size();
			for (int j = 0; j < cs; ++j){
				cout << n->vChildId[j];
				if (j < cs - 1)
					cout << ", ";
			}
			cout << "]\n";
		}
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<int> b;
  // 末尾から1文字飛ばしで数字を配列bに格納していく
  for (int i = n - 1; i >= 0; i -= 2) {
    b.push_back(a[i]);
  }
  // 偶数だったら0から、奇数だったら1から1文字飛ばしで数字を配列bに格納していく
  int i = n & 1 ? 1 : 0;
  for (; i < n; i += 2) {
    b.push_back(a[i]);
  }

  // 解答
  cout << b[0];
  for (int i = 1; i < b.size(); i++) {
    cout << " " << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long a,b;
long long yh(long long x){
	if(x%4==0)
	   return x;
	if(x%4==1)
	   return 1;
	if(x%4==2)
	   return x+1;
	return 0;
}
int main(){
	cin>>a>>b;
	if(a==0)
	   cout<<yh(b)<<endl;
	else
	   cout<<(yh(a-1)^yh(b))<<endl;
	return 0;
}


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

long long N;

int main(){
	scanf("%lld", &N);
	long long part = N / 11;
	if(11 * part == N) printf("%lld\n", part * 2);
	else if(N - 11 * part <= 6) printf("%lld\n", part * 2 + 1);
	else printf("%lld\n", part * 2 + 2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y,cloz;
    for(int i=1;;i++){
        cin>>x>>y;
        if(x==0&&y==0){
            break;
        }
        
        if(x>y){
            cloz=x;
            x=y;
            y=cloz;
        }
        cout<<x<<" "<<y<<endl;
    }
}



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

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


Measured memory_bytes: 256
n = int(input())
MOD = 10 ** 9 + 7
if n == 1:
    print(0)
    exit()
if n == 2:
    print(2)
    exit()

print((pow(10, n, MOD) - 2 * pow(9, n, MOD) + pow(8, n, MOD)) % MOD)


Measured memory_bytes: 9168
from collections import deque

def solve():
    n = int(input())
    a = []
    for i in range(n):
        ai = [int(j)-1 for j in input().split()]
        a.append(deque(ai))

    d = set()
    # 必ず(i < j)なるように入れる
    q = deque()
    for i in range(n):
        ai = a[i].popleft()
        if i < ai:
            q.append((i, ai))
        else:
            q.append((ai, i))

    ans = 0
    while q:
        ans += 1
        nxt_q = deque()
        while q:
            i, ai = q.pop()
            if (i, ai) in d:
                if a[i]:
                    ni = a[i].popleft()
                    if i < ni:
                        nxt_q.append((i, ni))
                    else:
                        nxt_q.append((ni, i))
                if a[ai]:
                    ni = a[ai].popleft()
                    if ai < ni:
                        nxt_q.append((ai, ni))
                    else:
                        nxt_q.append((ni, ai))
            else:
                d.add((i, ai))
        q = nxt_q

    # 残ってないかチェック
    if any(i for i in a):
        ans = -1
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 118620
#include<iostream>
#include<string>
int main(){
	int month,day;
	const int monthday[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	const std::string week[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int a=3;
	while(1){
		std::cin>>month>>day;
		if(month==0)break;
		int sum=day+a;
		for(int i=0;i<month-1;i++)sum+=monthday[i];
		std::cout<<week[(sum-1)%7]<<std::endl;
	}
	return 0;
	/*
	月曜日 Monday
	火曜日 Tuesday
	水曜日 Wednesday
	木曜日 Thursday
	金曜日 Friday
	土曜日 Saturday
	日曜日 Sunday
	*/
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
  #ifdef LOCAL
      input_from_file;
      output_to_file;
    #endif 
    IOS
    string str; cin>>str;
    int n = str.length();
    int ans = 0;
    for(int i=0;i<(n+1)/2;i++)
    {
      if(str[i] != str[n-i-1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

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

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

int N;
ll C;
vector<ll> x,v;

vector<ll> MAXCAL(vector<ll> x, vector<ll> v){
    vector<ll> S(N),cal(N),maxcal(N);
    ll M = 0;
    for ( int i = 0; i < N; ++i){
        if ( i == 0 ) S[i] = v[i];
        else S[i] = S[i-1] + v[i];
        cal[i] = S[i] - 2 * x[i];
        if ( cal[i] > M ) M = cal[i];
        maxcal[i] = M;
    }
    return maxcal;
}


int main() {
    cin >> N >> C;
    x.resize(N); v.resize(N);
    REP(i,N) cin >> x[i] >> v[i];
    
    ll sum = 0, maxcal = 0;
    vector<ll> r = MAXCAL(x,v);
    for ( int left = N-1; left >= 0; --left){
        sum += v[left];
        ll cal = sum - (C - x[left]);
        if ( left != 0 ) cal += r[left-1];
        chmax(maxcal,cal);
        //cout << maxcal << endl;
    }
    
    vector<ll> x2(N);
    REP(i,N) x2[i] = C - x[N-i-1];
    vector<ll> v2 = v;
    reverse(v2.begin(),v2.end());
    vector<ll> l = MAXCAL(x2,v2);
    reverse(l.begin(),l.end());
    sum = 0;
    for ( int right = 0; right < N; ++right){
        sum += v[right];
        ll cal = sum - x[right];
        if ( right != N-1 ) cal += l[right+1];
        chmax(maxcal,cal);
        //cout << maxcal << endl;
    }
    
    cout << maxcal << endl;
    
    return 0;
}


Measured memory_bytes: 11012
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t A, B, C, D;
  cin >> A >> B >> C >> D;

  if (D <= A) {
    cout << 0 << endl;
  } else if (B <= C) {
    cout << 0 << endl;
  } else {
    cout << min(B, D) - max(A, C) << endl;
  }

  return 0;
}


Measured memory_bytes: 256