akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	int N;
	cin >> N;
	vector<i64> A(N);
	rep(i, N) cin >> A[i];

	auto dfs = [&](auto&& _dfs,int i,  i64 p) -> int {
		if(i == N) return (p % 2 == 0);

		int ans = 0;
		ans += _dfs(_dfs, i+1, p*A[i]);
		ans += _dfs(_dfs, i+1, p*(A[i] - 1));
		ans += _dfs(_dfs, i+1, p*(A[i] + 1));

		return ans;
	};

	Cout(dfs(dfs, 0, 1));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


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

  sort(s.begin(), s.end(), [](int a, int b)-> bool{
			     return a > b;
			   });

  vector<mint> modinv(n+1);
  rep1(i,n) modinv[i] = (mint)1 / (mint)i;
  
  vector<vector<mint>> dp(n+1, vector<mint>(x+1));
  dp[0][x].x = 1;
  rep(i,n) {
    rep(j,x+1) {
      dp[i+1][j % s[i]] += dp[i][j];
      dp[i+1][j]        += dp[i][j] * (mint)(n - 1 - i);
    }
  }

  mint res;
  rep(j,x+1) res += dp[n][j]*(mint)j;
  cout << res.x << "\n";
  
  
  return 0;
}


Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)	for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
	if(a.first==b.first)return a.second<b.second;
	else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
	for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
	for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
	int sum=0;
	// for(auto x: v)sum+=x;
	fr(i,0,v.size())sum+=v[i];
	return sum;
}





 void solve()
{
	int n;
	cin>>n;
	vi v(n);
	cin>>v;
	sort(all(v));
	if(n<3){cout<<0;return;}
	int c=0;
	// cout<<v<<endl;
	fr(i,0,n-2)
	{
		fr(j,i+1,n-1)
		{
			if(v[j]==v[i])continue;
			fr(k,j+1,n)
			{
				if(v[k]==v[j])continue;
				if(v[i]+v[j]>v[k]){c++;}
			}
		}
	}
	cout<<c;



}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;	
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define int long long
const int PMAX=120000;
vector<int> PF(PMAX, 1);
void MKPF(){for (int i=2;i<sqrt(PMAX);i++) if(PF[i]==1) for(int j=i*2;j<PMAX;j+=i) PF[j] = 0;}
signed main(){
	MKPF();
	vector<int> sp(10001,0);
	int ix = 2;
	for(int i=1;i<10001;i++){
		while(PF[ix]!=1) ix++;
		sp[i] = sp[i-1] + ix;
		ix++;
	}
	int a;
	while( scanf("%lld", &a) != EOF ){
		if(a==0) break;
		cout << sp[a] << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
nu = gets.to_i
we = gets.chomp.split("")
check = Array.new(nu, nu)
count = 0
for i in 1..nu - 1
  if we[i] == "E"
    count += 1
  end
end
check[0] = count

for i in 1..nu - 1
  if (we[i] == "W" && we[i - 1] == "E") || (we[i] == "E" && we[i - 1] == "W")
    check[i] = check[i - 1]
  elsif we[i] == "W" && we[i - 1] == "W"
    check[i] = check[i - 1] + 1
  elsif we[i] == "E" && we[i - 1] == "E"
    check[i] = check[i - 1] - 1
  end
end

ans = nu - 1
for j in 0..nu - 1
  if ans > check[j]
    ans = check[j]
  end
end

print ans


Measured memory_bytes: 31884
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

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

int n;
cin>>n;

int sum=0;
vector<int>cnt(200005);
for(int i=0;i<n;i++)
{
    int x;
     cin>>x;
     cnt[x]++;
     sum+=x;
}

int q;
cin>>q;
while(q--)
{
    int b,c;
    cin>>b>>c;
    sum+=cnt[b]*(c-b);
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout<<sum<<"\n";
}



}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

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

	if(x>=a){
		cout<<10<<endl;
	}else{
		cout<<0<<endl;
	}

}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(200000), b(200000);
    set<int> st, go;
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        if(a[i]==1 || b[i]==1){
            if(a[i]==1) st.insert(b[i]);
            if(b[i]==1) st.insert(a[i]); 
        }else if(a[i]==n || b[i]==n){
            if(a[i]==n) go.insert(b[i]);
            if(b[i]==n) go.insert(a[i]);
        }
    }
    for(int i=2; i<n; i++){
        if(st.count(i) && go.count(i)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	//ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> n;

	printf("ABC%03d\n", n);


	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3680
prime=[2]
for i in range(3,1000000,2):
    primeq=True
    for p in prime:
        if i%p==0:
            primeq=False
            break
        if i<p*p:break
    if primeq:prime.append(i)
while True:
    try:
        n=int(input())
        ans=0
        for p in prime:
            if p>n:break
            ans+=1
        print(ans)
    except:break


Measured memory_bytes: 8760
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, M;
    cin >> N >> M;
    vec<ll> pen(N, -1);
    REP(i, M){
        int p;string S;
        cin >> p >> S;
        p--;
        if(S == "WA"){
            if(pen[p]<0){
                pen[p]--;
            }
        }else{
            if(pen[p]<0){
                pen[p]*=-1;
                pen[p]--;
            }
        }
    }
    ll sum_pen=0, sum_ac=0;
    REP(i, N){
        if(pen[i]>=0){
            sum_ac++;
            sum_pen+=pen[i];
        }
    }
    cout << sum_ac << " " << sum_pen << el;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<long long>vec(10000);
  for(int X=1;X<=100;X++){
    for(int Y=X;Y<=100;Y++){
      for(int Z=Y;Z<=100;Z++){
        if(X*X+Y*Y+Z*Z+X*Y+X*Z+Y*Z<10001){
          if(X!=Y&&X!=Z&&Y!=Z){
            vec.at(X*X+Y*Y+Z*Z+X*Y+X*Z+Y*Z-1)+=6;
          }
          else if(X==Y&&X==Z){
            vec.at(X*X+Y*Y+Z*Z+X*Y+X*Z+Y*Z-1)+=1;
          }
          else{
            vec.at(X*X+Y*Y+Z*Z+X*Y+X*Z+Y*Z-1)+=3;
          }
        }
      }
    }
  }
  for(int X=0;X<N;X++){
    cout<<vec.at(X)<<endl;
  }
}


Measured memory_bytes: 3640
#068c
N,M = map(int, input().split())

regular_service_list = [set()for _ in range(N+1)]

for i in range(1,M+1):
    a,b = map(int, input().split())
    regular_service_list[a].add(b)
    regular_service_list[b].add(a)
    
common_island = regular_service_list[1]&regular_service_list[N]

if len(common_island)>=1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	n = s.size() ;
	if(n & 1)
		return cout<<"No\n" , 0 ;
	string s2 = "" ;
	for(int i = 0 ; i < n ; i += 2)
	{
		s2 = "" ;
		s2.push_back(s[i]) ;
		s2.push_back(s[i+1]) ;
		if(s2 != "hi")
			return cout<<"No\n" , 0 ;
	}
	return cout<<"Yes\n" , 0 ;
}		

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

using namespace std;

#define int long long
const int N = 1001, oo = 10000000000000000LL;

int n,W,w[N],v[N],f[N*N],p[N*N];

signed main()
{
    cin >> n >> W;
    for (int i=1; i<=n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (int i=0; i<=n*N; i++)
        f[i] = p[i] = oo;
    f[0] = 0;
    /*
    for (int s=1; s<=n*N; s++)
    {
        for (int i=1; i<=n; i++)
        {
            if (s >= v[i])
            {
                p[s] = min(f[s], f[s-v[i]] + w[i]);
            }
        }
        f[s] = p[s];
    }
    */
    for (int i=1; i<=n; i++)
    {
        for (int s=n*N; s>=1; s--)
        {
            if (s >= v[i])
            {
                f[s] = min(f[s], f[s-v[i]] + w[i]);
            }
        }
    }
    int res = 0;
    for (int i=0; i<=n*N; i++)
    {
        if (f[i] <= W)
        {
            res = i;
        }
    }
    cout << res;
    return 0;
}


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

int main() {
  string S, T;
  cin >> S;
  int result = 0;
  for (int i = 0; i < S.size(); i++) {
    T = S;
    reverse(T.begin(), T.end());
    if (S.at(i) != T.at(i)) {
      S.at(i) = T.at(i);
      result++;
      if (S == T) continue;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n==1)printf("1");
		if(n>=2&&n<4)printf("2");
			if(n>=4&&n<8)printf("4");
				if(n>=8&&n<16)printf("8");
					if(n>=16&&n<32)printf("16");
						if(n>=32&&n<64)printf("32");
							if(n>=64&&n<=100)printf("64");
							return 0;

}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var n = input[0];
            var a = input[1];
            var b = input[2];
            var count = n / (a + b);
            if (n % (a + b) <= a)
                Console.WriteLine(count * a + n % (a + b));
            else
                Console.WriteLine(count * a + a);
            



            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	int n = in.nextInt();
        	int m = in.nextInt();
        	int[] nums = new int[m];
        	for(int i=0; i<m; i++) {
        		nums[i] = in.nextInt();
        	}
        	Arrays.sort(nums);
        	int[] diffs = new int[m-1];
        	for(int i=0; i<m-1; i++) {
        		diffs[i] = Math.abs(nums[i+1] - nums[i]);
        	}
        	Arrays.sort(diffs);
        	int ans = 0;
        	int i=0;
        	while(m-i>n) {
        		ans += diffs[i];
        		i++;
        	}
        	out.println(ans);
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

Measured memory_bytes: 34364
# -*- coding: utf-8 -*-
"""
A - Five Antennas
https://atcoder.jp/contests/abc123/tasks/abc123_a

"""
import sys


from itertools import combinations

def solve(antennas, k):
    for a, b in combinations(antennas, 2):
        if abs(a-b) > k:
            return ':('
    return 'Yay!'


def main(args):
    antennas = [int(input()) for _ in range(5)]
    k = int(input())
    ans= solve(antennas, k)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
def dict_count(dict, key):
	if key in dict:
		dict[key] = dict[key]+1
	else:
		dict[key] = 1
	return dict

N = int(input())
divs = {}
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
for n in range(2, N+1):
	for p in primes:
		while n%p==0:
			divs = dict_count(divs, p)
			n = n//p
		if p*p>n:
			break
	if n!=1:
		dict_count(divs, n)
result = 1
base = 10**9+7
for c in divs.values():
	result = (result*(c+1))%base
print(result)


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

int main(){
  int N,A = 0,B = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == 'D'){
      B--;
    }
    else {
      B++;
    }
    A = max(A,B);
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    ll n,ans = 0;
    cin>>n;
    if(n != 1){
        ll ans1 = 1,diff = 1,ans2 = 1;
        rep(i,n){
            ans1 *= 10;
            ans1 %= MOD;

            diff *= 9;
            diff %= MOD;

            ans2 *= 8;
            ans2 %= MOD;
        }
        ans = (ans1 - diff * 2 + ans2 + MOD * 2)%MOD;

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string a, b; cin >> a >> b;
	int a_len = a.length(); int b_len = b.length(); bool flag = true;
	if(a_len < b_len){
		flag = false;
		cout << "LESS" << endl;
	}else if(a_len > b_len){
		flag = false;
		cout << "GREATER" << endl;
	}else{
		Rep(i, a_len){
			if(a[i] - '0' > b[i] - '0'){
				flag = false;
				cout << "GREATER" << endl;
				break;
			}else if(a[i] - '0' < b[i] - '0'){
				flag = false;
				cout << "LESS" << endl;
				break;
			}else{
				continue;
			}
		}
	}
	if(flag){
		cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>
using namespace std;

int main(){
	int n, t, ans = 0;
	unordered_map<int, int> mp;
	scanf("%d", &n);
	
	for(int i = 0;i<n;i++){
		scanf("%d", &t);
		mp[t]++;
	}

	for(auto it = mp.begin(); it!= mp.end(); ++it){
		if(it->second&1)ans++;
	}
	printf("%d\n", ans);
		
	return 0;
}

Measured memory_bytes: 4388
/* Includes */
#include <stdio.h>

/* Prototypes */

/* Valuables */
int r, c;
int input[101][101];

/* Main */
int main()
{
    scanf("%d %d", &r, &c);

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            scanf("%d", &input[i][j]);
        }
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            input [i][c] += input[i][j];
        }
    }

    for (int j = 0; j <= c; j++) {
        for (int i = 0; i < r; i++) {
            input[r][j] += input[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            printf("%d", input[i][j]);

            if (j == c) {
                printf("\n");
            }
            else {
                printf(" ");
            }
        }
    }
}


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

int n, sum = 0;
vector <int> a, b;

int main() {
	cin >> n;
	a = vector<int>(n);
	for(int &i : a) {
		cin >> i;
		sum += i;
	}
	bool t = true;
	for(int i : a){
		if(i >= (sum - i)) t = false;
	}
	if(t) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    int x;
    rep1(i, 5){
        cin>>x;
        if(i!=x){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include<string>
using namespace std;
int main()
{
    int N;
    int f = 0;
    cin >> N;

    int keta = to_string(N).length();

    if (keta == 1)
    {
        f = N;
    }else if (keta == 2)
    {
        f = 9;
    }else if (keta == 3)
    {
        f = N - 99;
        f += 9;
    }else if (keta == 4)
    {
        f = 900;
        f += 9;
    }else if (keta == 5)
    {
        f = N - 9999;
        f += 900;
        f += 9;
    }else
    {
        f = 90000;
        f += 900;
        f += 9;
    }
    
    cout << f << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
long long fact(long long n)
{
    if(n==1)
        return 1;
    return n * fact(n-1);
}

int main(){
    string s,s2;
    cin>>s>>s2;
    s+=s2;
    int x=stoi(s);
    for(int i=1;i<400;i++){
        if((i*i)==x){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  int a = 1;
  while(1){
    if(a > N) break;
    
    else
      a *= 2;
  }
  
  cout << a / 2 << endl;
  
  return 0;
}

    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll getx(string str)
{
    if(str=="")
    {
        return 0ll;
    }
	stringstream ss;
	ss.clear();
	ss<<str;
	ll res;
	ss>>res;
	return res;
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	string s;
	cin>>s;
	int len=s.length();
	ll ans=0ll;
	std::vector<string> v;
	for(int i=1;i<=(1<<(len-1));i++)
	{
		v.clear();
		int num=1;
		for(int j=0;j<=(len-1);j++)
		{
			if((i&(1<<j)))
			{
				string temp=s.substr(len-1-j,num);
				v.push_back(temp);
				num=1;
			}else
			{
				num++;
			}
		}
		string temp=s.substr(0,num-1);
				v.push_back(temp);
		// ll tt=0ll;
		for(auto x:v)
		{
//		    db(x);
			ans+=getx(x);
		}

	}
	cout<<ans<<endl;

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



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

int getnum() {
    char C; int s = 0, t = 1;
    while (!isdigit(C = getchar())) if(C=='-') t=-1;
    do {s = s * 10 + C - '0'; } while( isdigit(C = getchar()));
    return s * t;
}   

int main() {
  int N = getnum();
  int K = getnum();
  vector<int> A(200000, 0);
  int maxint = 0, minint = 2000000;
  for (int i = 0; i < N; i++) {
    int a = getnum();
    A[a]++;
    maxint = max(maxint, a);
    minint = min(minint, a);
  }
  if (maxint-minint+1<= K) printf("%d\n", 0);
  else {
//    for (int i = 0; i<=maxint;i++) printf("%d", A[i]);
//    printf("\n");
    sort(A.begin()+minint, A.begin()+maxint+1);
//    for (int i = 0; i<=maxint;i++) printf("%d", A[i]);
//    printf("\n");
    int cnt = 0, i = 0;
    while(maxint-i+1>K) {
    cnt += A[i];
    i++;
    }
    printf("%d\n", cnt);
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define maxn (int)2e5 + 8



int main(){
	Fio;
	int t = 1;
	//cin >> t;
	while(t--){
		ll n;
		cin >> n;
		ll a[n], sum = 0, ans = 0;;
		for (int i = 0; i < n; ++i)
		{
			cin >> a[i];
			sum += a[i];
		}

		sum /= n;
		ll sum1 = sum+1, ans1 = 0;

		for (int i = 0; i < n; ++i)
		{
			ans += (sum - a[i])*(sum - a[i]);
			ans1 += (sum1 - a[i])*(sum1 - a[i]);
		}

		cout << min(ans, ans1);

	}

	return 0;
}

Measured memory_bytes: 256
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

Measured memory_bytes: 67744
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

bool cmp(int a,int b){
	return a>b;
}
int a[101];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	int s1=0,s2=0;
	for(int i=1;i<=n;i++){
		if(i%2==1) s1+=a[i];
		else s2+=a[i];
	}
	cout<<s1-s2;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>

using namespace std;

const int N = 2e6 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

#define int ll

void solve() {
	double L;
	cin >> L;
	double x = L / 3;
	cout << fixed << setprecision(7) << x * x * x;
}

signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String s = in.next();
		String t = in.next();
		int ans = N;
		for (int i = 0; i < s.length(); i++) {
			int index = i;
			boolean isOk = true;
			for (int j = 0; j < t.length() && index < s.length(); j++) {
				if (s.charAt(index) != t.charAt(j)) {
					isOk = false;
					break;
				}
				index++;
			}
			if (!isOk) {
				ans++;
			} else {
				ans = N + i;
				break;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 21972
l = int(input())
c = list(map(int, input().split()))

from collections import deque

def sign(n):
    if n<0: return -1
    if n>0: return 1
    return 0

ans = -1
neko = set()
q = deque()
j = 0
for i in c:
    if sign(i) == 1:
        if i in neko:
            ans = j
            break
        q.append(i)
        neko.add(i)
    else:
        if len(q) > 0:
            if -q.pop() != i or -i not in neko:
                ans = j
                break
            neko.remove(-i)
        else:
            ans = j
            break

    j += 1

if ans == -1:
    print("OK")
else:
    print(ans + 1)


Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
 {
	//code
  	int n,x,t;
  	cin>>n>>x>>t;
  	if(n<=x){
    	cout<<t;
    }else{
      
    	if(n%x==0){
        	cout<<(n/x)*t;
        }else{
        	cout<<((n/x)+1)*t;
        }
    }
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
 
int chek(int a,int b,int c)
{
    if((a+b)>c) return 1;
    else return 0;
}

int main()
{
    int n,x;
    cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;i++){cin>>x;l[i]=x;}
    sort(l.begin(),l.end());

    int f=2,b=0,m=1,num=0;

    for(int i=0;i<n-2;i++)
    {   int k=i+2;
       for(int j=i+1;j<n;j++)
       {
           while(k<n && chek(l[i],l[j],l[k])) k++;

           if(k>j) num+=k-j-1;
       }
    }
    cout<<num;

}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,d,x = LI()
        a = [LI() for _ in range(d)]
        for i in range(d-1):
            t = [0] * (x+1)
            t[x] = x
            for j in range(n):
                if a[i][j] >= a[i+1][j]:
                    continue
                aj = a[i][j]
                ak = a[i+1][j] - aj
                for k in range(x,aj-1,-1):
                    if t[k-aj] < t[k] + ak:
                        t[k-aj] = t[k] + ak
            x = max(t)

        rr.append(x)
        break

    return '\n'.join(map(str,rr))


print(main())




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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    else if (b == c) cout << a << endl;
    else cout << b << endl;
}


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

vector<int> adj_list[30];

// Check whether a set dset of size k is a dominating set of a graph
// of n vertices.
bool is_dominating_set(int dset, int n)
{
  bool dominated[30];
  int rem = n;                  // ??????????????????????????????????????°

  for (int i=0;i<n;i++) dominated[i]=false;
  for (int v=0;v<n;v++)
  {
    int vm = 1<<v;              // ??????v?????´??°??¨???
    int im;
    if (vm & dset)              // v???dset?????????
    {
      for (int i=0;i<adj_list[v].size();i++)
      {
        int w = adj_list[v][i];
        if (!dominated[w]) { dominated[w] = true; rem--; }
      }
    }
  }
  if (rem == 0) return true;
  else return false;
}

int main()
{
  int n, m;
  int u, v;
  while (cin >> n >> m)
  {
    bool found = false;

    if (n == 0) return 0;
    for (int i=0;i<n;i++) adj_list[i].clear();
    for (int i=0;i<n;i++) adj_list[i].push_back(i);
    for (int i=0;i<m;i++)
    {
      cin >> u >> v;
      adj_list[u].push_back(v);
      adj_list[v].push_back(u);
    }
    int Delta = 0;              // ?????§?¬???°
    for (int i=0;i<n;i++) Delta = max(Delta, (int)adj_list[i].size());

    int dset;
    for (int k=n/Delta;k<=n;k++)
    {
      // {0,...,n-1}?????¨???????????§????????????k??§???????????????????????????
      // ????????°???????????°????????????????????£??¬???????????????????????§
      dset = (1 << k) - 1;
      while (dset < 1<<n)
      {
        if (is_dominating_set(dset, n))
        {
          cout << k << endl;
          found = true;
        }
        if (found) break;

        int x = dset & -dset;
        int y = dset + x;
        dset = ((dset & ~y) / x >> 1) | y;
      }
      if (found) break;
    }
  }
}

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

int main() {
  int a, b, c, z;

  z = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) z++;
  }
  cout << z << endl;

  return 0;
}
  

Measured memory_bytes: 1160
#include <stdio.h>

int minimum(int a, int b) { return a < b ? a : b; }

int main(){
    int D, G, p[10], c[10], i, j, k, a, ans=100000, num, max;

    scanf("%d %d", &D, &G);

    for(i=0; i<D; i++){
        scanf("%d %d", &p[i], &c[i]);
    }

    for(i=0; i<(1<<D); i++){
        a=0;
        num=0;
        max=-1;
        for(j=0; j<D; j++){
            if((i>>j) & 1){
                a += p[j]*(j+1)*100 + c[j];
                num += p[j];
            }
            else
                max = j;
        }

        j=0;
        while(a < G && j < p[max]){
            a += (max+1)*100;
            num++;
            j++;
        }
        
        if(a >= G)
            ans = minimum(ans, num);
    }

    printf("%d\n", ans);

    return 0;
}

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

bool check(int n, bool l[]) {
	while (n > 0) {
		if (l[n%10]) return 0;
		n/=10;
	}
	return 1;
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, k, d;
	cin >> n >> k;
	
	bool l[10];
	for (int i = 0; i < 10; i++) {
		l[i] = 0;
	}
	while (k--) {
		cin >> d;
		l[d] = 1;
	}
	while (check(n, l) == 0) n++;
	cout << n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF ( 1ll << 15 ) - 1
using namespace std;
char s1[4010], s2[4010];
short sum1[4010][26], sum2[4010][26]; 
struct data {
	int s1, s2; short l;
	data() {}
	data( int _s1, int _s2, int _l ): s1(_s1), s2(_s2), l(_l) {}
	bool operator < ( const data& b ) const {
		if( s1 == b.s1 && s2 == b.s2 ) return l < b.l;
		else return s1 == b.s1 ? s2 < b.s2 : s1 < b.s1;
	} 
	bool operator == ( const data& b ) const {
		return ( s1 == b.s1 && s2 == b.s2 && l == b.l );
	}
} A[8000010], tmp;
int t = 0;
int main() {
	scanf( "%s", s1 + 1 ); scanf( "%s", s2 + 1 );
	short N = strlen( s1 + 1 ), M = strlen( s2 + 1 );
	for( short i = 1 ; i <= N ; ++ i ) 
		for( short j = 0 ; j < 26 ; ++ j ) sum1[i][j] = sum1[i - 1][j] + ( s1[i] == j + 'a' );
	for( short i = 1 ; i <= M ; ++ i ) 
		for( short j = 0 ; j < 26 ; ++ j ) sum2[i][j] = sum2[i - 1][j] + ( s2[i] == j + 'a' );
	for( short i = 1 ; i <= N ; ++ i )
		for( short j = 1 ; j <= min( (short)( N - i + 1 ), (short)M ) ; ++ j ){
			tmp.s1 = 0; tmp.s2 = 0;
			for( short k = 0 ; k < 26 ; ++ k ) tmp.s1 = ( (ll)tmp.s1 * 2333333333 + sum1[i + j - 1][k] - sum1[i - 1][k] ) % 1000000009,
											   tmp.s2 = ( (ll)tmp.s2 * 23333333 + sum1[i + j - 1][k] - sum1[i - 1][k] + 100007 ) % 1000000007;
			tmp.l = j;	A[++ t] = tmp;
		} 
	sort( A + 1, A + 1 + t );
	short ans = 0;
	for( short i = 1 ; i <= M ; ++ i )
		for( short j = max( (short)1, ans ) ; j <= min( (short)( M - i + 1 ), (short)N ) ; ++ j ) {
			tmp.s1 = 0; tmp.s2 = 0; tmp.l = j;
			for( short k = 0 ; k < 26 ; ++ k ) tmp.s1 = ( (ll)tmp.s1 * 2333333333 + sum2[i + j - 1][k] - sum2[i - 1][k] ) % 1000000009,
											   tmp.s2 = ( (ll)tmp.s2 * 23333333 + sum2[i + j - 1][k] - sum2[i - 1][k] + 100007 ) % 1000000007;
			int r = lower_bound( A + 1, A + 1 + t, tmp ) - A;
			if( A[r] == tmp ) ans = max( ans, A[r].l );
		} 
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 97360
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 01:13:08 2020

@author: liang
"""
"""
ABC  171 D 差分更新　パケット変換
【無駄な探索は行わない（メモリ化） ⇒　パケット変換】
パケット
　値vが出現する回数を記録しておく

dict()方式　⇒　探索にO(logn) or O(n)がかかる
配列方式　⇒　探索がO(1)となる!

【差分更新】
値Bが全て値Cになる
　⇒　(C - B) * 値Bの個数だけ増加する
 ⇒　値Cの個数　+= 値Bの個数
 ⇒　値Bの個数　= 0
"""

N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())

d = [0]*(10**5)

for i in A:
    d[i-1] += 1

ans = sum(A)

for i in range(Q):
    b, c = map(int,input().split())
    ans += (c-b)*d[b-1]
    d[c-1] += d[b-1]
    d[b-1] = 0
    print(ans)

Measured memory_bytes: 21292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>

using namespace std;

int main(void){
	string n;
	cin >> n;
	for(char c:n){
		if(c == '1'){
			cout << 9;
		}else{
			cout << 1;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int32_t main()
{
	fast;
	int n;cin>>n;
	vip v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].ff>>v[i].ss;


	for(int i=2;i<n;i++)
	{
		//trace6(v[i-2].ff,v[i-2].ss,v[i-1].ff,v[i-1].ss,v[i].ff,v[i].ss);
		if(v[i-2].ff==v[i-2].ss and v[i-1].ff==v[i-1].ss and v[i].ff==v[i].ss)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define repeat(i, n) for(int (i) = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	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 = Integer.parseInt(sc.nextLine());
        long[] d = {0, 0, 0, 0, 0};
        for (int i = 0; i < n; i++) {
            String name = sc.nextLine();
            if (name.charAt(0) == 'M') {
                d[0]++;
            } else if (name.charAt(0) == 'A') {
                d[1]++;
            } else if (name.charAt(0) == 'R') {
                d[2]++;
            } else if (name.charAt(0) == 'C') {
                d[3]++;
            } else if (name.charAt(0) == 'H') {
                d[4]++;
            }
        }
        sc.close();

        long p = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = i+1; j < 4; j++) {
                for (int k = j+1; k < 5; k++) {
                    if (d[i] * d[j] * d[k] > 0) {
                        p += d[i] * d[j] * d[k];
                    }
                }
            }
        }
        System.out.println(p);
    }
}


Measured memory_bytes: 91836
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if ((x + y) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    long long int ans = 1;
    for(int i=1;i<n+1;i++){
        ans *= i;
        if(ans>=1000000007) ans%=1000000007;
    }
    cout << ans << endl;
}

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

int main(){
    using namespace std;
    unsigned long H, W;
    cin >> H >> W;
    vector<vector<unsigned long>> m(H + 2, vector<unsigned long>(W + 2, 2));
    {
        for(unsigned long i{1}; i <= H; ++i){
            string S;
            cin >> S;
            transform(S.begin(), S.end(), m[i].begin() + 1, [](char c){return c & 1;});
        }
    }
    deque<pair<unsigned long, unsigned long>> d, e{{1, 0}, {0, 1}};
    vector<vector<unsigned long>> dist(H + 2, vector<unsigned long>(W + 2, numeric_limits<unsigned long>::max() / 5));
    d.emplace_back(1, 1);
    dist[1][1] = 0;
    while(!d.empty()){
        auto t = d.front();
        d.pop_front();
        auto di = dist[t.first][t.second];
        if(t.first == H && t.second == W)break;
        for(const auto& i : e)if(m[t.first + i.first][t.second + i.second] != 2){
            unsigned long f = m[t.first + i.first][t.second + i.second] != m[t.first][t.second];
            if(dist[t.first][t.second] + f < dist[t.first + i.first][t.second + i.second]){
                dist[t.first + i.first][t.second + i.second] = dist[t.first][t.second] + f;
                f ? d.emplace_back(t.first + i.first, t.second + i.second) : d.emplace_front(t.first + i.first, t.second + i.second);
            }
        }
    }
    cout << (dist[H][W] + 1) / 2 + (m[1][1] && m[H][W]) << endl;
    return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  s <- getLine
  putStrLn $ take 5 s ++ " " ++ take 7 (drop 6 s) ++ " " ++ drop 14 s


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

const int MAXN = 2.1e5;
const int K = 10;
int dp[MAXN][K];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int N = int(s.size());
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int a = 0; a <= i && a < K; a++) {
			for (int b = 1; i+b <= N && b < K; b++) {
				if (a != b || s.substr(i-a, a) != s.substr(i, b)) {
					dp[i+b][b] = max(dp[i+b][b], dp[i][a] + 1);
				}
			}
		}
	}
	int ans = 0;
	for (int a = 0; a < K; a++) {
		ans = max(ans, dp[N][a]);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 8724