akhauriyash/Code-Regression huggingface dataset:
//IIT Kanpur FacelessMen India
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int main(){
  // freopen("product.in","r",stdin);
  // freopen("product.out","w",stdout);
  int n;
  int s=1,cur=0,ct=0,prv;
  scanf("%d",&n);
  REP(i,n){
    int x; scanf("%d",&x);
    if(ct==0) prv=x;
    ct++;
    if(prv!=x){
      if(cur==0) {
        if(prv<x) cur =1;
        else cur = -1;
      }else if(cur>0&&prv>x){
        ct=1;s++; cur=0;
      }else if(cur<0&&prv<x){
        ct=1;s++; cur=0;
      }
    }
    prv=x;
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Objects;
import java.util.AbstractCollection;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuMST1 solver = new AizuMST1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuMST1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            final int[][] g = new int[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    int w = in.nextInt();
                    g[i][j] = w;
                }
            }

            out.printf("%d\n", prims(g, 0));
        }

        private int prims(final int[][] g, final int s) {
            final int n = g.length;
            Set<Integer> visited = new HashSet<>();
            visited.add(s);

            Set<AizuMST1.Edge> mst = new HashSet<>();

            PriorityQueue<AizuMST1.Edge> pq = new PriorityQueue<>((x, y) -> Integer.compare(x.weight, y.weight));
            for (int i = 0; i < n; i++) {
                if (g[s][i] != -1) {
                    pq.add(new AizuMST1.Edge(s, i, g[s][i]));
                }
            }

            while (!pq.isEmpty()) {
                final AizuMST1.Edge e = pq.poll();

                if (visited.contains(e.to)) {
                    continue;
                }

                visited.add(e.to);
                for (int j = 0; j < n; j++) {
                    if (g[e.to][j] != -1) {
                        pq.add(new AizuMST1.Edge(e.to, j, g[e.to][j]));
                    }
                }
                mst.add(e);
            }

            int w = 0;
            for (final AizuMST1.Edge e : mst) {
                w += e.weight;
            }

            return w;
        }

        static class Edge {
            int from;
            int to;
            int weight;

            Edge(final int from, final int to, final int weight) {
                this.from = from;
                this.to = to;
                this.weight = weight;
            }


            public boolean equals(final Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                final AizuMST1.Edge edge = (AizuMST1.Edge) o;
                return from == edge.from &&
                        to == edge.to;
            }


            public int hashCode() {
                return Objects.hash(from, to);
            }

        }

    }
}




Measured memory_bytes: 45148
<?php

fscanf(STDIN, '%d', $n);
$a = rtrim(fgets(STDIN), PHP_EOL);
$a = explode(' ', $a);
rsort($a);


$first = 0;
$second = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i % 2 === 0) {
        $first += $a[$i];
    } else {
        $second += $a[$i];
    }
}
echo $first - $second . PHP_EOL;


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

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        int h = sc.Int();
        int w = sc.Int();
        int d = sc.Int();

        var p = new Coord[h * w + 1];

        for (int i = 0; i < h; i++) {
            var a = sc.Int(w);
            for (int j = 0; j < w; j++) {
                p[a[j]] = new Coord { x = j, y = i };
            }
        }

        var table = new int[h * w + 1];

        for (int i = d + 1; i <= h * w; i++) {
            table[i] = table[i - d] + Math.Abs(p[i].x - p[i - d].x) + Math.Abs(p[i].y - p[i - d].y); 
        }

        var q = sc.Int();

        for (int i = 0; i < q; i++) {
            var l = sc.Int();
            var r = sc.Int();

            pr.WriteLine(table[r] - table[l]);
        }
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        const int d = 2;
        var ret = new int[d, d];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < d; j++)
            {
                for (int k = 0; k < d; k++)
                {
                    ret[i, j] += a[i, k] * a[k, j];
                }
            }
        }

        return ret;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

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

int main(){
    /* A
    int r;
    cin >> r;
    
    cout << 2*r*M_PI << endl;*/
    /* B
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++)cin >> a[i];

    int sum = 0;
    for(int i=0;i<m;i++)sum += a[i];
    if(n>=sum)cout << n-sum <<endl;
    else cout << "-1" << endl; */

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n-1;i++){
        int num;
        cin >> num;
        a[num-1]++;
    }

    for(int i=0;i<n;i++){
        cout << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    string s;
    cin >> s;
    cout << (s == "ARC"? "ABC":"ARC");
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(void)
{
    int n, h[110];
    cin >> n;
    for (int i = 0; i < n;i++){
        cin >> h[i];
    }
    int ans = 0, move = 0;
    for (int i = 0; i < n;i++){
        if(move>h[i]){
            move = h[i];
        }
        else{
            ans += h[i] - move;
            move = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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




int main() {
	// your code goes here
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	ll sum=0;
	ll a=0,b=0,c=0;
	for(int i=0;i<n;i++)
	{
	    if(s[i]=='R')
	    a++;
	    else if(s[i]=='G')
	    b++;
	    else
	    c++;
	}
	sum=a*b*c;
	for(int i=0;i<n;i++)
	{
	    for(int j=i+1;j<n;j++)
	    {
	        int k=j+j-i;
	        if(k>=n)
	        break;
	        if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k])
	        sum-=1;
	    }
	}

	cout<<sum;
	
	
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n; cin >> n;
    int a[n][n];
    rep(i, n)rep(j, n) cin >> a[i][j];
    lint mod = 1e9 + 7;
    int MAX = 1 << n;
    vector<vector<lint>> dp(2, vector<lint>(MAX, 0));
    dp[0][0] = 1;
    rep(i, n)rep(j, MAX)if(dp[i&1][j]){
        rep(k, n)if(!((j>>k)&1) && a[i][k]){
            dp[(i+1)&1][j+(1<<k)] = (dp[(i+1)&1][j+(1<<k)] + dp[i&1][j]) % mod;
        }
    }
    cout << dp[n&1][MAX-1] << endl;
}

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

int main(){
	int k, s;
	cin >> k >> s;
	
	int sum=0;
	int cnt=0;
	for(int x=0; x<k+1; x++){
		for(int y=0; y<k+1; y++){
			sum=s-x-y;
				if(sum<=k&&sum>=0) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

const int N = 10000;

int main(void)
{
	int a[N]={0}, n, maxn= -1000005 ,minn = 1000005;
	long long sum =0;
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i++ )
	{
	scanf("%d",&a[i]);
	if(a[i] > maxn)
	{
	  maxn=a[i];
	}
	if(a[i] < minn)
	{
	 minn = a[i];
	}
	sum += a[i];
	}
	printf("%d %d %lld\n", minn ,maxn ,sum); 
	return 0;
 } 


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

int main() {
    while (true) {
        int b, r, g, c, s, t;
        cin >> b >> r >> g >> c >> s >> t;
        if (b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) {
            break;
        }
        int bonusGame = 5 * b + 3 * r,
            normalGame = t - bonusGame,
            medal = 100 + 13 * bonusGame + 15 * (b + r) + 7 * g + 2 * c - 3 * (normalGame - s);
        cout << medal << endl;
    }
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();
            var n = s[0];
            var a = s[1];
            var b = s[2];

            var d =  n  / (a + b);
        
            var r = n % (a + b);
            if(r >= a){
                r = a;
            }

            Console.WriteLine(d * a + r);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int n, k; cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) {
		cin >> h[i];
	}
	sort(allg(h));
	ll sum = 0;
	for (int i = k; i < n; i++) {
		sum += h[i];
	}
	cout << sum << endl;



	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int n,sum;
int a[101],b[101];
int main()
{
	scanf("%d",&n);
	b[0]=1e9;
	b[n]=1e9;
	for(int i=1;i<n;i++)
	{
		scanf("%d",&b[i]);
		a[i]=min(b[i],b[i-1]);
		sum+=a[i];
	}
	a[n]=min(b[n],b[n-1]);
	sum+=a[n];
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
cntAB = {i:0 for i in range(1,N+1)}
for _ in range(M):
  a,b = map(int,input().split())
  cntAB[a] += 1
  cntAB[b] += 1
for key, num in cntAB.items():
  if num%2 == 1:
    print('NO')
    exit()
print('YES')

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

int rs, st[200005];
string s;

int main()
{
  ios_base::sync_with_stdio(0);

  cin >> s;

  for(auto it : s)
    if(it == 'S') st[++rs] = 1;
    else if(st[rs] == 1) --rs;
         else st[++rs] = 2;

  cout << rs << '\n';

  return 0;
}

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

typedef long long ll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << " "; err(++it, args...); }

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

const int MX = 3e3+5;

ll dp[MX][MX];
ll ara[MX];

int main()
{
    optimize
    int n;
    cin>>n;

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

    for(int L = n-1; L >= 0; L--){
        for(int R = L; R < n; R++){
            if(L == R){
                dp[L][R] = ara[L];
            }
            else{
                dp[L][R] = max(ara[L]-dp[L+1][R], ara[R]-dp[L][R-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 49788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	int p[100100];
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		p[i]--;
	}
	int ans = 0;
	for (int i = 0; i < N;) {
		if (i == p[i]) {
			ans++;
			i += 2;
		}
		else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<typename T, std::size_t S>
class matrix_t {
public:
  T m_[S][S];

public:
  matrix_t() {
    for (int i = 0; i < S; i ++)
      for (int j = 0; j < S; j ++)
        m_[i][j] = i == j ? 1 : 0;
  };

  matrix_t(const matrix_t& m) {
    for (int i = 0; i < S; i ++)
      for (int j = 0; j < S; j ++)
        m_[i][j] = m[i][j];
  };

public:
  const T* operator[](int i) const {
    return m_[i];
  };

  T* operator[](int i) {
    return m_[i];
  };

public:
  matrix_t<T, S> operator*(const matrix_t<T, S>& m) const {
    matrix_t<T, S> mm;

    for (int i = 0; i < S; i ++)
      for (int j = 0; j < S; j ++) {
        T s = 0.0;

        for (int k = 0; k < S; k ++)
          (s += m_[i][k] * m[k][j] % MOD) %= MOD;

        mm[i][j] = s;
      }

    return mm;
  };

  matrix_t<T, S>& operator*=(const matrix_t<T, S>& m) {
    matrix_t<T, S> mm;

    for (int i = 0; i < S; i ++)
      for (int j = 0; j < S; j ++) {
        T s = 0.0;

        for (int k = 0; k < S; k ++)
          (s += m_[i][k] * m[k][j] % MOD) %= MOD;

        mm[i][j] = s;
      }

    for (int i = 0; i < S; i ++)
      for (int j = 0; j < S; j ++)
        m_[i][j] = mm[i][j];

    return *this;
  };
};

template<typename T, std::size_t S>
class matrix_fn_t {
public:
  matrix_fn_t(matrix_t<T, S>& m) : m_(m) {};

public:
  matrix_t<T, S> pow(long long n) const {
    matrix_t<T, S> m, mm(m_);

    for ( ; n; n >>= 1, mm *= mm)
      if (n & 1)
        m *= mm;

    return m;
  };

private:
  matrix_t<T, S>& m_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long K;

  std::cin >> N >> K;

  matrix_t<long long, 55> m;

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

  matrix_fn_t<long long, 55> fn(m);

  m = fn.pow(K);

  long long x = 0;
  
  for (int i = 0; i < N; i ++)
    for (int j = 0; j < N; j ++)
      (x += m[i][j]) %= MOD;

  std::cout << x << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


bool a[105];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>d(n); rep(i, n)cin >> d[i];
	rep(i, 105) {
		a[i] = false;
	}
	rep(i, n) {
		a[d[i]] = true;
	}
	int ans = 0;
	rep(i, 105) {
		if (a[i] == true)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int K;
  string S;
  cin>>K>>S;
  int x=S.size();
  
  if(x <= K)
    cout<< S << endl;
  
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout<<"..."<<endl;
  }

}


Measured memory_bytes: 3644
while 1:
    a,d,n=map(int,input().split())
    if a==d==n==0:break
    count=0
    while 1:
        if a in [2,3,5,7]:count+=1
        elif a%2==0 or a<11:pass
        else:
            for i in range(3,int(a**0.5)+1,2):
                if a%i==0:break
            else:count+=1
        if count==n:break
        a+=d
    print(a)


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)
ll md=1000000007;
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    f(i,0,n) cin>>a[i];
    ll ans=0,sm=a[0];
    f(i,1,n){
        ans+=(a[i]*sm)%md;
        ans%=md;
        sm+=a[i];
        sm%=md;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5204
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque


'''
dp[i][j]...(0,0)からスタートして(i,j)に到達する経路のなかでの最大の価値
dp[i][j]=max(dp[i][j-1],dp[i-1][j]) + v[i][j]


dp[i][j][k] ... (0,0)からスタートして(i,j)に到達する経路のなかでi行目ですでにk(以下)個選んでいるときの最大の価値

遷移は、i,jのvを拾うときと拾わないときのmax
dp[i][j][k] = max(dp[i][j-1][k-1]+V[i,j], dp[i][j-1][k]
                  ) #k個のままのほうが価値が高いかk-1から拾ったほうが価値が高いか

上からの遷移 # 拾うか拾わないかでこうかな
dp[i][j][0]=max(dp[i][j-1][0],max_k(dp[i-1][j]))
dp[i][j][1]=max(dp[i][j-1][0],max_k(dp[i-1][j][k])+V[i][j])
'''

R, C, K = ints()
RCV = read_tuple(K)
V = [[0] * C for _ in ra(R)]
for r, c, v in RCV:
    V[r - 1][c - 1] = v

# dp = [[[0] * 4 for _ in ra(C)] for _ in ra(R)]
dp0 = [[0] * C for _ in ra(R)]
dp1 = [[0] * C for _ in ra(R)]
dp2 = [[0] * C for _ in ra(R)]
dp3 = [[0] * C for _ in ra(R)]

# dp[0][0][0] = 0
dp1[0][0] = V[0][0]
dp2[0][0] = V[0][0]
dp3[0][0] = V[0][0]

for j in ra(1, C):
    dp1[0][j] = max(dp1[0][j - 1], dp0[0][j - 1] + V[0][j])
    dp2[0][j] = max(dp2[0][j - 1], dp1[0][j - 1] + V[0][j])
    dp3[0][j] = max(dp3[0][j - 1], dp2[0][j - 1] + V[0][j])

for i in ra(1, R):
    dp0[i][0] = dp1[i - 1][0]
    dp1[i][0] = dp0[i][0] + V[i][0]
    dp2[i][0] = dp0[i][0] + V[i][0]
    dp3[i][0] = dp0[i][0] + V[i][0]


for i in ra(1, R):
    for j in ra(1, C):
        ma = max(dp0[i - 1][j],
                 dp1[i - 1][j],
                 dp2[i - 1][j],
                 dp3[i - 1][j])

        dp0[i][j] = max(dp0[i][j - 1],  # 左
                        ma)  # 上

        dp1[i][j] = max(dp0[i][j - 1] + V[i][j],  # 左から来て拾う
                        dp1[i][j - 1],  # 拾わないほうが大きい場合もある
                        ma + V[i][j])  # 上から来て拾う

        dp2[i][j] = max(dp1[i][j - 1] + V[i][j], dp2[i][j - 1])
        dp3[i][j] = max(dp2[i][j - 1] + V[i][j], dp3[i][j - 1])


print(max(dp0[R - 1][C - 1],
          dp1[R - 1][C - 1],
          dp2[R - 1][C - 1],
          dp3[R - 1][C - 1],
          ))

# print(*values, sep='\n')
# print(*dp, sep='\n')

# dp2 = [[-1] * C for _ in ra(R)]
# for i in ra(R):
#     for j in ra(C):
#         dp2[i][j] = max(dp[i][j])
# print(*dp2, sep='\n')


Measured memory_bytes: 458964
import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String in = "";
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    try {
      while ((in = br.readLine()) != null) {
        if (in.equals("")) break;
        for(String s : in.split("(?<=.)")) {
          s = s.toLowerCase();
          int count = map.containsKey(s) ? map.get(s) : 0;
          map.put(s, count + 1);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    int ans = 0;
    for(String s : "abcdefghijklmnopqrstuvwxyz".split("(?<=.)")) {
      if (!map.containsKey(s)) {
        ans = 0;
      } else {
        ans = map.get(s);
      }
      System.out.println(s + " : " + ans);
    }
  }
}

Measured memory_bytes: 19160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
ll dp[110][100010];
int main(){
    ll n,W;cin>>n>>W;
    vector<ll>w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    dp[0][w[0]]=v[0];
    REP(i,1,n){
        rep(j,w[i])dp[i][j]=dp[i-1][j];
        REP(j,w[i],W+1)dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
    ll ma=0;
    rep(i,W+1)ma=max(ma,dp[n-1][i]);
    cout<<ma<<endl;;
}

Measured memory_bytes: 79360
#include <stdio.h>
int main() {
  int a, b;
  scanf("%i %i", &a, &b);
  if (a > b) {
    puts("a > b");
  } else if (a < b) {
    puts("a < b"); 
  } else {
    puts("a == b");
  }
  return 0;
}


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

using namespace std;

struct ball {
	int red;
	int sum;
};

ball arr[100005];

int main() {
	int n, m;
	cin >> n >> m;
	arr[1].red = 1; arr[1].sum = 1;
	for (int i = 2; i <= n; ++i) {
		arr[i].sum = 1;
	}
	int a, b;
	while (m--) {
		cin >> a >> b;
		if (arr[a].red) {
			arr[a].sum--;
			arr[b].red = 1;
			arr[b].sum++;
		}
		else {
			arr[a].sum--;
			arr[b].sum++;
		}
		if (arr[a].sum == 0)arr[a].red = 0;
	}
	int answer = 0;
	for (int i = 1; i <= n; ++i) {
		if (arr[i].sum && arr[i].red)answer++;
	}
	cout << answer << endl;  
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  int a,b,k;cin>>a>>b>>k;
  int cnt = 0;
  for (int i=100;i>0;i--){
    if(a%i==0&&b%i==0){
      cnt++;
      cerr << i << " ";
      if(cnt==k){
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
// Oh damn, cann't you see I'm fine?

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

const int max_n = 1e6 + 5;
const int M = 1e9 + 7;

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

	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	vector <long long> x = {a, b};
	vector <long long> y = {c, d};
	if(a+1 <= b) x.push_back(a+1);
	if(b-1 >= a) x.push_back(b-1);
	if(c+1 <= d) y.push_back(c+1);
	if(d-1 >= c) y.push_back(d-1);

	long long mx = -1e18-8;
	for(long long e : x) {
		for(long long ee : y) {
			mx = max(mx, e*ee);
		}
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

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

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

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

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, m;
	cin >> n >> m;
	vvi v(n, vi(m));
	vvi dp(n, vi(m, INT_MAX));
	rep(i,0,n)
		rep(j,0,m)
		{
			char c;
			cin >> c;
			v[i][j] = (c == '.' ? 0 : 1);
		}
	dp[0][0] = v[0][0];
	rep(i,0,n)
		rep(j,0,m)
		{
			if(i)
				dp[i][j] = min(dp[i][j], (v[i-1][j] == 0 and v[i][j] == 1) + dp[i-1][j]);
			if(j)
				dp[i][j] = min(dp[i][j], (v[i][j-1] == 0 and v[i][j] == 1) + dp[i][j-1]);
		}
	cerr << dp << '\n';
	cout << dp.back().back();
}


Measured memory_bytes: 384
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const ll INF=2e20;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
/*struct Point{
    ll x,y;
    void read(){
        scanf("%lld%lld",&x,&y);
    }
    bool operator<(const Point&rhs) const{
        if (x==rhs.x) return y<rhs.y;
        return x<rhs.x;
    }
}p[100];
int n,k;
int main(){
    read(n),read(k);
    for (int i=1;i<=n;i++) p[i].read();
    sort(p+1,p+1+n);
    ll ans=INF;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++)if (i!=j){
            int cnt=0;
            for (int k=1;k<=n;k++){
                if (p[k].x>=min(p[i].x,p[j].x) && p[k].x<=max(p[i].x,p[j].x)
                    && p[k].y>=min(p[i].y,p[j].y) && p[k].y<=max(p[i].y,p[j].y)){
                        cnt++;
                    }
            }
            if (cnt>=k){
                ans=min(ans,(max(p[i].x,p[j].x)-min(p[i].x,p[j].x))*(max(p[i].y,p[j].y)-min(p[i].y,p[j].y)));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}*/
/*int a,b,c;
int main(){
    read(a),read(b),read(c);
    if (a==b) cout<<c<<endl;
    else if (a==c) cout<<b<<endl;
    else cout<<a<<endl;
    return 0;
}*/
int h,w;
int dir_x[]={0,1,0,-1,-1,-1,1,1};
int dir_y[]={1,0,-1,0,-1,1,-1,1};
char maze[55][55];
int main(){
    read(h),read(w);
    for (int i=0;i<h;i++){
        scanf("%s",maze[i]);
        for (int j=0;j<w;j++){
            if (maze[i][j]=='.') maze[i][j]='0';
        }
    }
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (maze[i][j]=='#'){
                for (int k=0;k<8;k++){
                    int tx=i+dir_x[k];
                    int ty=j+dir_y[k];
                    if (tx<0 || tx>=h || ty<0 || ty>=w || maze[tx][ty]=='#') continue;
                    maze[tx][ty]++;
                }
            }
        }
    }
    for (int i=0;i<h;i++) puts(maze[i]);
    return 0;
}


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e6 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll n;
	cin >> n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			for(ll k=1;k<=n;k++){
				ans+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout << ans;
}

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

	
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}

	return 0;
}
	

Measured memory_bytes: 3668
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy
setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
ans=[[0]*n for _ in range(n)]
for i in range(n):
    v=list(map(int,stdin.readline().rstrip().split()))
    for j in v[2:]:
        ans[v[0]-1][j-1]=1
for i in ans:
    print(*i)


Measured memory_bytes: 6436
#include<iostream>
using namespace std;
int main()
{
    char str[100];
   cin >> str;
    int i,len=0;
    i=0;
    while(str[i]!='\0')
    {
        i++;
        len++;
    }
    for(i=0;i<len;i++)
    {
        if(str[i]>='A'&&str[i]<='Z')
        {
            cout << "A";
        }
        else
        {
            cout << "a";
        }
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using Cards = vector<pair<string, int>>;
const int INF = INT_MAX;
void merge(Cards &cards, int left, int mid, int right) {
  int nl = mid - left, nr = right - mid;
  Cards L(nl + 1), R(nr + 1);
  for (size_t i = 0; i < nl; i++) {
    L.at(i) = cards.at(left + i);
  }
  L.at(nl) = make_pair('a', INF);

  for (size_t i = 0; i < nr; i++) {
    R.at(i) = cards.at(mid + i);
  }
  R.at(nr) = make_pair('a', INF);

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].second <= R[j].second) {
      cards[k] = L[i++];
    } else {
      cards[k] = R[j++];
    }
  }
}
void mergeSort(Cards &cards, int left, int right) {
  if ((right - left) == 1) return;
  int mid = (left + right) / 2;
  mergeSort(cards, left, mid);
  mergeSort(cards, mid, right);
  merge(cards, left, mid, right);
}
int mypartition(Cards &cards, int p, int r) {
  int x = cards[r].second, i = p - 1;
  pair<string, int> tmp;
  for (int j = p; j < r; j++) {
    if (cards[j].second <= x) {
      i++;
      tmp = cards[j];
      cards[j] = cards[i];
      cards[i] = tmp;
    }
  }

  tmp = cards[++i];
  cards[i] = cards[r];
  cards[r] = tmp;

  return i;
}

void quickSort(Cards &cards, int p, int r) {
  if ((r - p) <= 0) return;
  int q = mypartition(cards, p, r);
  quickSort(cards, p, q - 1);
  quickSort(cards, q + 1, r);
}
int main() {
  int n;
  cin >> n;
  Cards qcards(n), mcards(n);
  for (size_t i = 0; i < n; i++) {
    cin >> qcards.at(i).first >> qcards.at(i).second;
    mcards.at(i) = qcards.at(i);
  }
  quickSort(qcards, 0, n - 1);
  mergeSort(mcards, 0, n);
  bool isStable = true;
  for (size_t i = 0; i < n; i++) {
    if (qcards[i] != mcards[i]) {
      isStable = false;
      break;
    }
  }

  if (isStable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (auto &&i : qcards) {
    cout << i.first << ' ' << i.second << endl;
  }
}


Measured memory_bytes: 12204
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int q = int.Parse(str[1]);
        var lists = new LinkedList<int>[n];
        for(int i=0; i<n; i++){
            lists[i] = new LinkedList<int>();
        }
        for(int i=0; i<q; i++){
            int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            switch(line[0]){
                case 0:
                    lists[line[1]].AddLast(line[2]);
                    break;
                case 1:
                    Console.WriteLine(string.Join(" ",lists[line[1]]));
                    break;
                case 2:
                    if(lists[line[1]].Count < lists[line[2]].Count){
                        foreach(var node in lists[line[1]]){
                            lists[line[2]].AddLast(node);
                        }
                    }
                    else{
                        foreach(var node in lists[line[2]].Reverse()){
                            lists[line[1]].AddFirst(node);
                        }
                        var temp = lists[line[2]];
                        lists[line[2]] = lists[line[1]];
                        lists[line[1]] = temp;
                    }
                    lists[line[1]].Clear();
                    break;
                default:
                    break;
            }
            /*Console.WriteLine("----------");
            for(int j=0; j<n; j++){
                Console.WriteLine(string.Join(" ",lists[j]));
            }
            Console.WriteLine("----------");*/
        }
    }
}



Measured memory_bytes: 64640
import collections

n, k = map(int, input().split())
array = [int(x) for x in input().split()]
_dict = collections.Counter(array)

res = 0
tmp = len(_dict.values())
if len(_dict.values()) < k:
    print(0)
else:
    sort_dict = collections.OrderedDict(sorted(_dict.items(), key=lambda x: x[1], reverse=True))
    value_dict = sort_dict.values()
    print(sum(list(value_dict)[k:]))

Measured memory_bytes: 106512
n, x = map(int, input().split())

pate, slice = [1], [1]
for _ in range(n):
    pate.append(2 * pate[-1] + 1)
    slice.append(2 * slice[-1] + 3)

ans = 0
for i in range(n)[::-1]:
    if x >= slice[i] + 2:
        ans += pate[i] + 1
        x -= slice[i] + 2
    elif x < slice[i] + 2:
        x -= 1
print(ans + (x > 0))


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

int main(){
  int a, b, c; cin >> a >> b >> c;
  int k; cin >> k;
  int u = max(a, max(b, c));
  int ans = a + b + c - u;
  for (int i = 0; i < k; i++) {
    u *= 2;
  }
  cout << ans + u << endl;
  return 0;
}


Measured memory_bytes: 256
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;int x=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            if(s[j]=='A'||s[j]=='T'||s[j]=='G'||s[j]=='C'){x=max(x,j-i+1);}
            else break;
        }
    }
    cout<<x<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
   cin >> N;
   vector<double> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
   double x = vec.at(0);
  for (int i = 1; i < N; i++) {
    x = (x + vec.at(i))/2;
}
  cout << x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
main()
{
    long int size, maxer, miner, temp;
    fscanf(stdin, "%ld", &size);
    fscanf(stdin, "%ld", &miner);
    fscanf(stdin, "%ld", &temp);
    maxer = temp - miner;
    miner = min(miner, temp);
    size -= 2;
    while(size--){
        fscanf(stdin, "%ld", &temp);
        maxer = max(maxer, temp - miner);
        miner = min(miner, temp);
    }
    printf("%ld\n", maxer);
}

Measured memory_bytes: 1848
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;


int main(){
    LONG i, j, k;
    LONG n, m, d;

    cin >> n >> m >> d;

    double ret;
    if(d == 0){
        ret = n;
    }
    else{
        ret = 2 * (n - d);
    }
    ret *= m - 1;
    ret /= n * n;

    cout << fixed << setprecision(7) << ret;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = long.Parse(Console.ReadLine());
            var v = 1000000000;

            var x = (v - S % v) % v;
            var y = (S + x) / v;

            Console.WriteLine($"0 0 1000000000 1 {x} {y}");
        }
    }
}


Measured memory_bytes: 13268
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  if N == 1
    println(0)
    return
  end
  prime = Vector{int}(undef,2*10^6)
  isprime = Vector{Bool}(undef,2*10^6)
  prime .= 0
  isprime .= true
  
  Nprime = 0
  isprime[1] = false
  for i in 2:2*10^6
    if isprime[i]
      Nprime += 1
      prime[Nprime] = i
      for j in 2i:i:2*10^6
        isprime[j] = false
      end
    end
  end
  
  bunkai = Vector{int}(undef,10^5)
  bunkai .= 0
  b = 0
  for i in 1:Nprime
    n = prime[i]
    if N%n == 0
      b += 1
      while N%n == 0
        bunkai[b] += 1
        N = N÷n
      end
    end 
  end
  if N > 1
    b +=1
    bunkai[b] = 1
  end

  count = 0
  for i in 1:b
    c = 1
    while bunkai[i] >= c
      count += 1
      bunkai[i] -= c
      c += 1
    end
  end
  println(count)
end

main()

Measured memory_bytes: 194108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,tw;
    cin>>n>>tw;
    ll int w[n],val[n];
    for(int i=0;i<n;i++)
    cin>>w[i]>>val[i];
    ll int dp[n+1][tw+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=tw;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(w[i-1]<=j)
            {
                dp[i][j]=max(val[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][tw]<<endl;
    
    
    
	return 0;
}


Measured memory_bytes: 79232
s = input()
dp = [[0 for _ in range(13)] for _ in range(len(s)+1)]
s= '0'+s
dp[0][0] =1
mod = 1000000007
def factory (i,j):
    for premod in range(13):
        curMod = (premod*10+j)%13
        dp[i][curMod]+=dp[i-1][premod]
        dp[i][curMod]%=mod
for i in range(1,len(s)):
    if s[i]!='?':
        factory(i,int(s[i]))
    else:
        for num in range(10):
            factory(i,num)
print(dp[len(s)-1][5]%mod)

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

    public static long dp[][] = new long[3001][3001];

    public static long solve(int i,int j,int arr[],int turn){
        if(i > j) return 0;
        if(dp[i][j] != -1){
            return dp[i][j];
        }
        if(turn == 1) dp[i][j] = Math.max( arr[i]+solve(i+1,j,arr,0), arr[j]+solve(i,j-1,arr,0) );
        else dp[i][j] = Math.min(solve(i+1,j,arr,1),solve(i,j-1,arr,1));
        return dp[i][j];
    }

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

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

        for(int i=0;i<=3000;i++){
            for(int j=0;j<=3000;j++){
                dp[i][j] = -1;
            }
        }

        long x = solve(0,n-1,arr,1);
        long y = sum - x;

        System.out.println(x - y);
    }
}

Measured memory_bytes: 131264