akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

pair<ll,pair<ll,ll>> dp[3333][3333];
int ss[3333][33];
int tt[3333][33];
int mp[33];

int main(){
	
	string s,t;cin >> s >> t;
	
	REP(i,33)mp[i] = s.size();
	for(int i = s.size() - 1;i >= 0;i--){
		REP(j,33)ss[i][j] = mp[j];
		mp[s[i] - 'a'] = i;
	}
	REP(i,33)mp[i] = t.size();
	for(int i = t.size() - 1;i >= 0;i--){
		REP(j,33)tt[i][j] = mp[j];
		mp[t[i] - 'a'] = i;
	}
	
	REP(i,s.size()){
		REP(j,t.size()){
			if(s[i] == t[j])dp[i][j] = MP(1,MP(-1,-1));
			else dp[i][j] = MP(-1,MP(-1,-1));
		}
	}
	
	REP(i,s.size()){
		REP(j,t.size())if(dp[i][j].FI != -1){
			REP(k,33){
				int a = ss[i][k];
				int b = tt[j][k];
				if(a < s.size() && b < t.size());
				dp[a][b] = max(dp[a][b],MP(dp[i][j].FI + 1,MP(i,j)));
			}
		}
	}
	
	ll ma = 0;
	int x,y;
	REP(i,s.size()){
		REP(j,t.size()){
			if(ma < dp[i][j].FI){
				ma = dp[i][j].FI;
				x = i;
				y = j;
			}
		}
	}
	
	if(ma == 0){
		cout << "" << endl;
		return 0;
	}
	
	vector<char> ans;
	while(x != -1){
		ans.PB(s[x]);
		int xx = dp[x][y].SE.FI;
		int yy = dp[x][y].SE.SE;
		x = xx;
		y = yy;
	}
		
	REV(i,ans.size())cout << ans[i];cout << endl;
		
	return 0;
}


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

int N;
long int A[101];

int main(){

  std::cin >> N;

  for(int i = 0; i < N; i++) std::cin >> A[i];

  int ans = 0;

  for(int i = 0; i < N; i++){

    for(int j = 0; j < N; j++){

      int absA = A[i] - A[j];
      if(absA < 0) absA *= -1;
      ans = std::max(ans, absA);

    }

  }

  std::cout << ans << '\n';

}


Measured memory_bytes: 256
import java.util.*;
    public class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n= Integer.parseInt(sc.next());
        int k= Integer.parseInt(sc.next());
        long ans=0L;
        long mod=1000000007;
        for(;k<=n+1;k++){
          ans+=(n-k+1)*k+1;
          ans=ans%mod;
        }
        System.out.println(ans);
      }
    }

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  cout << (N+1)/2 << endl;
}


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

using namespace std;

int main(){
  int n, m, x;
  std::cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int> > a(n, vector<int>(m));
  for(int i=0; i<n; i++){
    std::cin >> c[i];
    for(int j=0; j<m; j++){
      std::cin >> a[i][j];
    }
  }

  int min = INT_MAX;
  bitset<12> b(1);
  bitset<12> maxsize(pow(2, n));
  for(; b!=maxsize;){
    vector<int> sum_a(m,0);
    int val = 0;
    for(int j=0; j<n; j++){
      if(b[j]){
        for(int i=0; i<m; i++){
          sum_a[i] += a[j][i];
        }
        val += c[j];
      }
    }
    int comp_flag = true;
    for(int z=0; z<m; z++){
      if(sum_a[z] < x){
        comp_flag = false;
      }
    }
    if(comp_flag){
      if(val < min){
        min = val;
      }
    }
    b = bitset<12>(b.to_ulong() + 1);
  }

  if(min == INT_MAX){
    std::cout << "-1" << '\n';
  }else{
    std::cout << min << '\n';
  }
  return 0;
}


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

int A[301000];
int n, N;
long long ans;

int main() {
	scanf("%d",&n);
	N = n * 3;
	for (int i = 1; i <= N; i++) scanf("%d",&A[i]);
	sort(A + 1, A + N + 1);
	for (int i = n + 1; i <= N; i += 2) ans += (long long) A[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
	double l[10], sum, v1, v2;
	char c;

	while (1) {
		for (int i = 0; i < 10; i++) {
			cin >> l[i] >> c;
		}
		if (cin.eof())	break;

		cin >> v1 >> c >> v2;

		sum = 0;
		for (int i = 0; i < 10; i++) {
			sum += l[i];
		}

		sum *= v1 / (v1 + v2);

		for (int i = 0; i < 10; i++) {
			sum -= (double)l[i];
			
			if (sum <= 0) {
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int m=-1,j;
void print(int a,int b)
{
	//cout<<a<<"  "<<b<<endl;
	for(int i=0;i<a;i++)
	{
		if(s1[i]!='?') cout<<s1[i];
		else cout<<'a';
	}
	cout<<s2;
	for(int i=b+1;i<s1.size();i++)
	{
		if(s1[i]!='?') cout<<s1[i];
		else cout<<'a';
	}
}
int main()
{
	cin>>s1>>s2;
	for(int i=s1.size()-1;i>=s2.size()-1;i--)
	{
		//cout<<endl<<i<<endl;
		for(j=0;j<s2.size();j++)
		{
			//cout<<j<<" ";
			if(s1[i+j-s2.size()+1]!=s2[j]&&s1[i+j-s2.size()+1]!='?') break;
			if(j==(s2.size()-1))
			{
				print((i-s2.size()+1),i);
				return 0;
				//cout<<i<<endl;
			}
		}
	}
	cout<<"UNRESTORABLE";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll (i)=1;(i)<=(n);(i)++)
 
int main(){
    ll K;
    cin >> K;
    ll sum= 0;
    rep(i, K){
        rep(j, K){
            rep(k, K){
                sum += gcd(k, gcd(i, j));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;


    return 0;
}

Measured memory_bytes: 3608
from sys import stdin
import string

s = stdin.readline().rstrip()
l = []
for i in string.ascii_lowercase:
    l.append(i)

for i in s:
    l.remove(i)

if s == string.ascii_lowercase[::-1]:
    print(-1)
    exit()
elif len(l) > 0:
    print(s+l[0])
else:
    k = s[::-1]
    li = [k[0]]
    for i in range(1,len(k)):
        li.append(k[i])
        if string.ascii_lowercase.index(k[i]) < string.ascii_lowercase.index(k[i-1]):
            a = li[-1]
            li.sort()
            print(s[:len(s)-i-1]+li[li.index(a)+1])
            exit()

Measured memory_bytes: 3828
n,m=list(map(int,input().split(" ")))
a=[]
dp=[float("inf") for i in range(n+1)]
for i in range(m):
  a=int(input())
  dp[a]=0
dp[0]=1
if dp[1] != 0:
  dp[1]=1
for i in range(2,n+1):
  if dp[i]!=0:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)
  

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
int main( void ){
	// initialize();
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])
		cout << "Yes\n";
	else
		cout << "No\n";
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, A, B) for (ll I = (A); I <= (B); ++I)
using namespace std;
const ll N = 2e5+5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("A.in", "r", stdin); 
    //freopen("A.out", "w", stdout);

    int r, c, n;
    cin >> r >> c >> n;
    int a[n + 1];
    repp(i,1,n) cin >> a[i];
    int grid[r + 1][c + 1];
    int num = 1;
    int cnt = 0;
    string dir = "right";
    repp(i,1,r)
    {
        if(dir == "right")
        {
            repp(j,1,c)
            {
                cnt++;
                grid[i][j] = num;
                if(cnt == a[num]) 
                {
                    cnt = 0;
                    num++;
                }
                if(j == c)
                {
                    dir = "left";
                }
            }
        }
        else
        {
            for(int j = c; j > 0; j--)
            {
                cnt++;
                grid[i][j] = num;
                if(cnt == a[num])
                {
                    cnt = 0;
                    num++;
                }
                if(j == 1)
                {
                    dir = "right";
                }
            }
        }
    }
    repp(i,1,r) 
    {
        repp(j,1,c)
        {
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
int main(){
ULL N, A, B, ans=0; cin >> N >> A >> B;
if((B-A)%2==0){ ans=(B-A)/2; }else{ ans=min(A+(B-A-1)/2, (N-B+1)+(B-A-1)/2); }
cout << ans << "\n";
}

Measured memory_bytes: 256
#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 n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<int> hidari(n+2,0);
    vector<int> migi(n+c+3,0);

    for(int i=1;i<=n; ++i){
        if(s[i-1]=='x'){
            hidari[i]=hidari[i-1];
        }
        else{
            if(i-c-1<=0){
                hidari[i]=1;
            }
            else{
                hidari[i]=hidari[i-c-1]+1;
            }
        }
    }

    vector<int> in(n+2,0);
    vector<int> out(n+c+2,0);

    for(int i=n+1; i>0; --i){
        if(i-1>=n){
            migi[i]=0;
        }
        else if(s[i-1]=='x'){
            if(i+1<=n) migi[i]=migi[i+1];
        }
        else{
            if(i+1+c>n) migi[i]=1;
            else{
                migi[i]=migi[i+1+c]+1;
            }
        }

        /*
        int temp = migi[i];
        if(i-c-1>=0){
            temp +=hidari[i-c-1];
        }
        if(temp>=k){
            cout << "i: "<<i<<endl;
            out[i]+=1;
            if(i-c>=0) in[i-c]+=1;
            else in[0]+=1;
        }*/

    }

    if(c==0){
        if(hidari[n]>k){
            return 0;
        }
        else{
            rep(i,n){
                if(s[i]=='o') cout << i+1 << endl;
            }
        }
        return 0;
    }

    for(int r=1; r<=(n+c+1); ++r){
        int temp = migi[r];
        if(r-c-1>=0){
            temp+= hidari[r-c-1];
        }
        if(temp>=k){
            out[r]+=1;
            if(r-c>=0){
                in[r-c]+=1;
            }
            else in[0]+=1;
        }
    }



    /*
    for(auto h:hidari){
        cout << h << " ";
    }
    cout << endl;
    for(auto m:migi){
        cout << m << " ";
    }
    cout << endl;
    */
   int temp=0;
    rep(i,n+1){
        temp+=in[i];
        temp-=out[i];
        //cout <<"i: "<< i <<"t:" <<temp << endl;
        if(temp>=1){
            continue;
        }

        if(i==0) continue;
        if(s[i-1]=='x') continue;

        cout << i << endl;
    }

    /*
    cout << "in" << endl;
    for(auto x:in) cout << x << " ";
    cout << endl << "out" << endl;
    for(auto x:out) cout << x << " ";
    cout << endl;
    */
}

Measured memory_bytes: 4996
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class DDCC2020_QUALB
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var AList = NNList(N);
            var ans = 1000000000000000000;
            var sum = AList.Sum();
            var ruiseki = new long[N + 1];
            for (var i = 1; i <= N; i++)
            {
                ruiseki[i] = ruiseki[i - 1] + AList[i - 1];
            }
            for (var i = 1; i < N; i++)
            {
                ans = Min(ans, Abs(ruiseki[i] - (sum - ruiseki[i])));
            }
            Console.WriteLine(ans);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 43600
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define N 200009
char color[N];

int n;

void ope(int u, int count){
    if (u<=n-2){
        if (color[u]==color[u+1]){
        ope(u+1, count);
        }
        else{
            count+=1;
            ope(u+1, count);
        }
    }
    else{
        cout<<count+1<<endl;
    }
}

int main(){
    
    cin>>n;
    char a;
    for (int i=0; i<n; i++){
        cin>>a;
        color[i]=a;
    }
    ope(0,0);
}

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

void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B)
{
    vector<vector<ll>> edges(N + 1);
    for (ll i = 0; i < M; i++) {
        edges[A[i]].push_back(B[i]);
        edges[B[i]].push_back(A[i]);
    }

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        auto height = H[i];
        bool good = true;
        for (auto e : edges[i]) {
            if (height <= H[e]) {
                good = false;
                break;
            }
        }
        if (good) {
            ans++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N+1);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 11468
#include <iostream>
using namespace std;
int main()
{
    int n;
    int mansion[4][3][10];
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 10; k++)
                mansion[i][j][k] = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        mansion[b - 1][f - 1][r - 1] += v;
    }
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                cout << " " << mansion[i][j][k];
            }
            cout << endl;
        }
        if (i < 3)
            cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int r, d, x; cin >> r >> d >> x;
    rep(i,10){
        x = r * x - d; 
        cout << x << endl; 
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	char a;
	scanf ("%c", &a);
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	{
		printf ("vowel\n");
	}
	else 
	printf ("consonant\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
int par1[200010];
int r1[200010];
int par2[200100];
int r2[200010];

void init(int n){
  for(int i=0;i<n;i++){
    par1[i]=i;
    r1[i]=0;
    par2[i]=i;
    r2[i]=0;
  }
  return;
}

int root1(int n){
  if(par1[n]==n){
    return n;
  }
  else{
    return par1[n]=root1(par1[n]);
  }
}

int root2(int n){
  if(par2[n]==n){
    return n;
  }
  else{
    return par2[n]=root2(par2[n]);
  }
}

void unite1(int x, int y){
  x=root1(x);
  y=root1(y);
  if(x==y) return;
  if(r1[x]<r1[y]){
    par1[x]=y;
  }
  else {
    par1[y]=x;
    if(r1[x]==r1[y]) r1[x]++;
  }
  return;
}

void unite2(int x, int y){
  x=root2(x);
  y=root2(y);
  if(x==y) return;
  if(r2[x]<r2[y]){
    par2[x]=y;
  }
  else {
    par2[y]=x;
    if(r2[x]==r2[y]) r2[x]++;
  }
  return;
}

bool same1(int x,int y){
  return root1(x)==root1(y);
}

bool same2(int x,int y){
  return root2(x)==root2(y);
}

int main() {
  int n,k,l;
  cin>>n>>k>>l;
  init(n);
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    unite1(a-1,b-1);
  }
  for(int i=0;i<l;i++){
    int a,b;
    cin>>a>>b;
    unite2(a-1,b-1);
  }
  map<pair<int,int>,int> memo;
  for(int i=0;i<n;i++){
    memo[{root1(i),root2(i)}]++;
  }
  for(int i=0;i<n;i++){
    cout<<memo[{root1(i),root2(i)}];
    if(i!=n-1) cout<<' ';
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  std::vector<stack<int> > v(n);
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      int t, x;
      cin >> t >> x;
      v[t].push(x);
    } else if (op == 1) {
      int t;
      cin >> t;
      if (v[t].size() > 0)
        cout << v[t].top() << endl;
    } else {
      int t;
      cin >> t;
      if (v[t].size() > 0)
        v[t].pop();
    }
  }
}


Measured memory_bytes: 4452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17 -I .
//push_back -> emplace_back
int main(){
   string s;
   cin>>s;
   int n=sz(s);
   rep(i,n-1){
      if(s[i]==s[i+1]){
         cout<<i+1<<" "<<i+2<<endl;
         return 0;
      }
   }
   rep(i,n-2){
      if(s[i]==s[i+2]){
         cout<<i+1<<" "<<i+3<<endl;
         return 0;
      }
   }
   cout<<"-1 -1"<<endl;
   return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	int n;
	cin >> n;
	vector<int> a(n);
	ll ans = 0;
	map<int, int> ma;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		ans += a[i];
		ma[a[i]] += 1;
	}
	int q;
	cin >> q;
	vector<int> b(q), c(q);
	for(int i = 0; i < q; i++) {
		cin >> b[i] >> c[i];
		ans += (c[i] - b[i]) * ma[b[i]];
		ma[c[i]] += ma[b[i]];
	    ma[b[i]] = 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 8808
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  for (int i=0; i<A; i++) cin >> a[i];
  for (int i=0; i<B; i++) cin >> b[i];
  for (int i=0; i<M; i++) cin >> x[i] >> y[i] >> c[i];
  vector<int> a_copy = a, b_copy = b;
  sort(a_copy.begin(), a_copy.end());
  sort(b_copy.begin(), b_copy.end());
  int ans = a_copy[0]+b_copy[0];
  for (int i=0; i<M; i++) ans = min(ans, a[x[i]-1]+b[y[i]-1]-c[i]);
  cout << ans << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    vector <vector<int>> data(10 ,vector <int>(10 )); //繋がっているか
    vector <int> amari(10);
    for(int i=0;i<m;i++){
       int x; cin>>x;
       for(int j=0;j<x;j++){
            int a; cin>>a;
            data[i][a-1]=1;
        }
    }
    for(int i=0;i<m;i++){
        cin>>amari[i];
        
    }
    /*for(int i=0;i<m;i++){
        cout<<amari[i]<<' ';
    }*/
    int bit;
    int ans =0 ;
    for(bit=0;bit<(1<<n);bit++){
        bool ok = true;
        vector <int> on(10);
        for(int i=0;i<n;i++){
            
            
            if(bit&(1<<i)){
                on[i]=1;
                
            }
            

        }
        for(int i=0;i<m;i++){
                int cnt=0;
                //cout<<i<<'*'<<endl;
                for(int j=0;j<n;j++){
                    if(data[i][j]) {cnt+=on[j];} //cout<<on[i]<<endl;}
                }
                //cout<<cnt<<' '<<i<<endl;
                if(cnt%2 != amari[i]) ok=false;
            }
        if(ok) ans++;
        //cout<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
typedef struct vec vec;

struct vec {
	double x, y;
};

static vec P(double x, double y){
	vec P = {x, y};
	return P;
}

static vec sub(vec a, vec b){
	return P(a.x - b.x, a.y - b.y);
}

static double cross(vec a, vec b){
	return (a.x * b.y - a.y * b.x);
}

int main (void){

	double Area = 0;
	double x0, y0;
	double xn, yn;
	double xm, ym;
	vec v0, n, m;
	int i;

	scanf("%lf,%lf", &x0, &y0);
	v0 = P(x0, y0);
	
	scanf("%lf,%lf", &xn, &yn);
	n = P(xn, yn);
	n = sub(v0, n);

    for(i = 0; i < 19; i++){    
	    if(scanf("%lf,%lf", &xm, &ym)){
    	    m = P(xm, ym);
    	    m = sub(v0, m);    
            Area = Area + fabs(cross(n, m) / 2);
            n = m;
	    }
	    else
	        break;
    }

	printf("%lf\n", Area);

    return 0;
}




Measured memory_bytes: 2028
r,c = map(int,input().split())
result = [0 for i in range(c+1)]
for _ in range(r):
    add = [int(x)for x in input().split()]
    add.append(sum(add))
    print(" ".join([str(x) for x in add]))
    result = [i + j for i,j in zip(result,add)]
print(" ".join([str(x) for x in result]))


Measured memory_bytes: 5624
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)

main ::  IO ()
main = do
  Just (n,_) <- BS.readInt <$> BS.getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'-')) <$> BS.getLine
  print $ query as

query :: VU.Vector Int -> Int
query as = VU.minimum totalWork
  where
    totalWork = VU.zipWith (+) incWork decWork
    incWork :: VU.Vector Int
    incWork = VU.reverse $ VU.cons 0 $ VU.scanl' (+) 0 $ (`evalState` Nil)
      $ VU.imapM addition $ VU.reverse incDiff
    decWork = VU.cons 0 $ VU.scanl' (+) 1 $ VU.map (+1) $ (`evalState` Nil)
      $ VU.imapM addition decDiff
    incDiff = VU.map (*2) $ VU.zipWith surpassExp4 as (VU.tail as)
    decDiff = VU.map (*2) $ VU.zipWith surpassExp4 (VU.tail as) as

data Stack = Nil | Cons {-# UNPACK #-} !Int {-# UNPACK #-} !Int !Stack

{-# INLINE addition #-}
addition :: Int -> Int -> State Stack Int
addition = \ !i !x ->
  if | x < 0     -> state $ ((0,) $!) . Cons (i+1) (-x)
     | otherwise -> consume x (i+1)

{-# INLINE consume #-}
consume :: Int -> Int -> State Stack Int
consume = \ !consumed !i -> state $ loop 0 consumed i
  where
    loop !acc !consumed !i0 (Cons i1 power rest)
      | consumed < power
        = ((,) $! acc + consumed * (i0-i1)) $! Cons i1 (power-consumed) rest
      | otherwise = loop (acc + consumed * (i0-i1)) (consumed-power) i1 rest
    loop !acc !consumed !i0 Nil
      = (,Nil) $! acc + consumed * i0

-- minimum e with x <= 4^e * y. Assumes x,y > 0.
surpassExp4 x y = (surpassExponent x y + 1) `shiftR` 1

-- minimum e with x <= 2^e * y. Assumes 0 < x,y < 2^62.
surpassExponent :: Int -> Int -> Int
surpassExponent x y
  | xShifted <= yShifted = bitDiff
  | otherwise            = bitDiff + 1
  where
    !xlz = countLeadingZeros x
    !ylz = countLeadingZeros y
    !bitDiff = ylz - xlz
    !xShifted = x `shiftL` (xlz - 2)
    !yShifted = y `shiftL` (ylz - 2)


Measured memory_bytes: 32124
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 11 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    ivv(t);
    ivv(x);
    cout<<(double)t/x<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

#define ld long double

signed main(){
    
    vector <int> v;
    
    int n, x; cin >> n;
    
    for(int i = 1; i <= n; i++){
         v.push_back(i);
    }
    
    map <int, pair <ld, ld> > ms;
    
    int y, cnt = 1, m = n;
    while(m--){
         cin >> x >> y;
         ms[cnt++] = {x,y};
    }
    ld tot = 0.0;
    do{ 
        for(int i = 0; i < n-1; i++){
            ld one = ms[v[i]].first - ms[v[i+1]].first;
            ld two = ms[v[i]].second - ms[v[i+1]].second;
            one = sqrt(one*one + two*two);
            tot += one;
        }
    }
    while(next_permutation(v.begin(), v.end()));
    
    int divi = 1;
    
    for(int i = 2; i <= n; i++) divi*=i;
    
    tot = tot/(1.0*divi);
    cout << setprecision(12) << tot << '\n';
}

Measured memory_bytes: 256
a, b = [int(i) for i in input().split()]

if a > 0:
    print("Positive")
elif a == 0:
    print("Zero")
else:
    if b >= 0:
        print("Zero")
    else:
        if (b - a) % 2 == 0:
            print("Negative")
        else:
            print("Positive")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++){
        cin >> v[i];
    }

    long long res = 0;    
    for (int i = 0; i <= min(K, N); i++){
        for (int j = 0; j <= min(K, N) - i; j++){
            vector<long long> q;
            long long cur = 0;
            for (int k = 0; k < i; k++) q.push_back(v[k]), cur += v[k];
            for (int l = 0; l < j; l++) q.push_back(v[N-l-1]), cur += v[N-l-1];
            
            sort(q.begin(), q.end());

            for (int m = 0; m < min(K-i-j, (int)q.size()); m++){
                if(q[m] < 0) cur -= q[m];
            }
            res = max(res, cur);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {

  int in, i, count, a = 0, b = 0, c = 0, check = 0, d = 0;

  for (i = 0; i < 12; i++) {
    scanf("%d", &in);
    
    if (i == 0) a = in;

    if (a != in) {
      if (b == 0) {
	b = in;
	check++;
      }
      d++;

      if (b != in) {
	if (c == 0) {
	  c = in;
	  check++;
	}

	if(c != in) {
	  printf("no\n");
	  return 0;
	}
      }
    }
	  
  }

  if(check == 0 || check == 2 || d == 4 || d == 8) {
    printf("yes\n");
  } else {
    printf("no\n");
  }
  

}



Measured memory_bytes: 2092
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

l = [0 for _ in range(K + 1)]
for i in range(1, K + 1):
  l[i] = pow(K//i, N, MOD)

for i in range(K, 0, -1):
  for j in range(i * 2, K + 1, i):
    l[i] -= l[j]
    l[i] %= MOD

ans = 0
for i in range(1, K + 1):
  ans += l[i] * i % MOD
  ans %= MOD
print(ans)

Measured memory_bytes: 11404
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int const maxn=1e3+5;
char s[maxn];
int main()
{
	scanf("%s",s);
	printf("%s",s);
	int len = strlen(s);
	if(s[len-1]=='s') puts("es");
	else puts("s");
}

Measured memory_bytes: 3824
n, a, b = map(int, input().split())
f = [""]*n
f[a-1], f[b-1] = "A", "B"
i = 0
ans = ""
while i <= 1000:
  nowA = f.index("A")
  nowB = f.index("B")
    
  if f[nowA+1] == "B":
    if not nowA == 0:
      f[nowA-1] = "A"
      f[nowA] = ""
    else:
      ans = "Borys"
      break
  else:
    f[nowA+1] = "A"
    f[nowA] = ""
  
  if f[nowB-1] == "A":
    if not nowB == n-1:
      f[nowB+1] = "B"
      f[nowB] = ""
    else:
      ans = "Alice"
      break
  else:
    f[nowB-1] = "B"
    f[nowB] = ""

if ans:
  print(ans)
else:
  print('Draw')

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 10000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

void solve(int n) {
	vector<int> p(n + 2), t(n + 2);
	for (int i = 1; i <= n; i++)
		cin >> p[i] >> t[i];
	t[n + 1] = INT_MAX;
	vector<int> dp(3);
	for (int i = 0; i < n + 1; i++) {
		vector<int> _dp(3, INT_MAX);
		bool flag = false;
		for (int k = 0; k < 3; k++) {
			if (dp[k] == INT_MAX) continue;
			flag = true;
			int dt = t[i + 1] - t[i];
			if (k + 1 < 3) {
				int dx = abs(p[i + 1] - p[i]);
				if (dx * (k + 2) <= dt)
					_dp[k + 1] = min(_dp[k + 1], dp[k] + dx);
			}
			int dx = p[i] + p[i + 1];
			if (p[i] * (k + 2) + p[i + 1] <= dt)
				_dp[0] = min(_dp[0], dp[k] + dx);
		}
		if (!flag) {
			cout << "NG " << i << endl;
			return;
		}
		dp = _dp;
	}
	cout << "OK " << dp[0] << endl;
}

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		solve(n);
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a, b, c, k, sum = 0;
	cin >> a >> b >> c >> k;
	if (k >= a)
	{
		sum += a;
		k -= a;
	}
	else
	{
		sum += k;
		cout << sum << endl;
		return 0;
	}
	if (k >= b)
		k -= b;
	else
	{
		cout << sum << endl;
		return 0;
	}
	if (k >= c)
	{
		sum -= c;
		k -= c;
	}
	else
	{
		sum -= k;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
using namespace std;
int main(void){
    int k, x;
    cin>>k>>x;
    for(int i=x-k+1; i<=x+k-1; i++){
        cout << i;
        if(i==x+k-1) {cout<<endl;}
        else cout<<" ";
    }
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

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

    int cnt   = 0;
    for(int i =0; i < n-2;i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')cnt++;
    }


    cout << cnt << endl;
    return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  map<char, long> mp;
  const string march = "MARCH";
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    mp[S[0]]++;
  }
  unsigned long long int ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += mp[march[i]] * mp[march[j]] * mp[march[k]];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define mod 1000000007
 #define f first
 #define se second
 #define pb push_back
 #define int long long int
using namespace std;
 signed main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);cout.tie(NULL);
     
     // #ifndef ONLINE_JUDGE
     //     freopen("input.txt","r",stdin);
     //     freopen("output.txt","w",stdout);
     // #endif

         int n;
         cin>>n;
         int arr[n+1];
         arr[0] =0;
         for(int i=1;i<=n;i++)
            cin>>arr[i];

        int dp[n+1][2];

        memset(dp,0,sizeof dp);
        dp[0][1] = -mod;
        dp[1][0] = arr[1];
        dp[1][1] = -arr[1];
        for(int i=2;i<=n;i++)
        {
            dp[i][0] = max(dp[i-1][0]+arr[i],dp[i-1][1]-arr[i]);
            dp[i][1] = max(dp[i-1][0]-arr[i],dp[i-1][1]+arr[i]);

        }

       
        cout<<dp[n][0]<<"\n";


 }      


Measured memory_bytes: 2560
function main(input) {
    input = input.trim().split(" ");
    var n = parseInt(input[0], 10);
    var ans = 0;

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

    console.log(ans);

  }
   
  main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36032
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

h,w=MI()
for i in range(w+2):
    print("#",end="")
print("")
for j in range(h):
    print("#",end="")
    print(input().rstrip(),end="")
    print("#")
for i in range(w+2):
    print("#",end="")

Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
    int N,m,count,j,x,flag;
    scanf("%d\n",&N);
    m=N-1;
    int a[m];
    scanf("%d",&a[0]);
    for(N=1;N<=m;N++){
        scanf(" %d",&a[N]);
    }
    flag=1;
    count=0;
    while(flag==1){
        flag=0;
        for(j=N-1;j>0;j--){
            if(a[j] < a[j-1]){
                x=a[j];
                a[j]=a[j-1];
                a[j-1]=x;
                flag=1;
                count++;
            }
        }
    }
    printf("%d",a[0]);
    for(N=1;N<=m;N++){
        printf(" %d",a[N]);
    }
    printf("\n%d\n",count);
    return 0;
}


Measured memory_bytes: 2096
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x = int(readline())
print('ABC' if x<1200 else 'ARC')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

int main(){
    int N,ans=0;
    cin >> N ;
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        ans = ans+y-x+1;
    }
    cout << ans << endl;

    }



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

int mod_pow(int n, int e, int mod){
    int ans = 1;
    n = n % mod;
    while(e != 0){
        if(e % 2 == 1){
            ans = (ans * n) % mod;
        }
        e /= 2;
        n = (n * n) % mod;
    }
    return ans;
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;

    vector<int> rem(s.size(), 0);
    int pow_ten = 1;
    for(int i=s.size()-1; i>=0; i--){
        rem[i] = ((s[i] - '0') * pow_ten) % 2019;
        pow_ten = (pow_ten * 10) % 2019;
    }    
    
    for(int i=1; i<s.size(); i++){
        rem[i] = (rem[i] + rem[i-1]) % 2019;
    }

    vector<int> num(2019, 0);
    num[0] = 1;
    for(int i=0; i<s.size(); i++){
        num[rem[i]]++;
    }

    int ans = 0;
    for(int i=0; i<num.size(); i++){
        ans += (num[i]-1)*num[i]/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5080
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 

 
int main(){
 
	int n; 
	while(scanf("%d",&n),n){

		vector<pair<int,int> > rw(n);
		int sum_r=0,sum_w=0;
		for(int i=0;i<n;i++){
			cin>>rw[i].first>>rw[i].second;
			sum_r+=rw[i].first;
			sum_w+=rw[i].second;
		}
		sort(rw.begin(),rw.end(),greater< pair<int,int> >());

		int r0=rw[0].first;
		int r=sum_r-r0;

		if(r0 <= r){
			cout<<sum_r+sum_w<<endl;
		}else{

			int res=2*rw[0].first;
			vector<vector<bool> > dp(1001,vector<bool>(1000,false));

			//r0-r???w?????°??????
			//dp[pos][sum]

			dp[1][0]=true;
			for(int i=1;i<n;i++){
				for(int j=0;j<=1000;j++){
					if(dp[i][j]){
						dp[i+1][j]=true; //??°?????????
						if(j+rw[i].second<=10000)
							dp[i+1][j+rw[i].second]=true; //??°??????
					}
				}
			}

			int opt=0;
			for(int i=1;i<=r0-r;i++){
				if(dp[n][i]) opt=i;
			}

			res+=sum_w-opt;
			cout<<res<<endl;



		}
		
		
	}
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    vector<ll> w;
    REP(i, 0, n){
        cin >> v[i];
        if(v[i] % 10 != 0) w.push_back(v[i]);
    }
    sort(w.begin(), w.end());

    ll ans = accumulate(ALL(v), 0LL);
    if(w.empty()) ans = 0;
    if(!w.empty() && ans % 10 == 0) ans -= w[0];

    cout << ans << endl;
}


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

using namespace std;

int main(void){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if(((x - r)>=0) && (x + r)<=W && (y-r)>=0 && (y+r)<=H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116