akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            Println($"ABC{ReadInt():000}");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char a[105];
char b[105];
char c[105];
int a_n=0;
int b_n=0;
int c_n=0;

int pa(){
  int num;
  if(a[a_n] == 'a')
    num = 1;
  if(a[a_n] == 'b')
    num = 2;
  if(a[a_n] == 'c')
    num =3;
  if(a[a_n] == '\0')
    num = 4;

  //cout<<num<<'*'<<endl;
  a_n++;
  return num;
}
int pc(){
  int num;
  if(c[c_n] == 'a')
    num = 1;
  if(c[c_n] == 'b')
    num = 2;
  if(c[c_n] == 'c')
    num =3;
  if(c[c_n] == '\0')
    num = 6;

  //cout<<num<<'+'<<endl;

  c_n++;
  return num;
}
int pb(){
  int num;
  if(b[b_n] == 'a')
    num = 1;
  if(b[b_n] == 'b')
    num = 2;
  if(b[b_n] == 'c')
    num =3;
  if(b[b_n] == '\0')
    num = 5;
  //cout<<num<<'&'<<endl;
  b_n++;
  return num;
}

int main(){
  
  int num =1;
  scanf("%s%s%s",a,b,c);
  //cout<<"move1"<<endl;
  while(1){
    //cout<<num<<'@'<<endl;
    if( num == 1){
      num = pa(); continue;}
    if( num == 2){
      num = pb(); continue;}
    if( num == 3){
      num = pc(); continue;}
    if( num == 4){
      cout<<'A';break;
    }
    if( num == 5){
      cout<<'B';break;
    }
    if( num == 6){
      cout<<'C';break;
    }
    //return 0;
  }
  cout<<endl;
  return 0;
}
    
      


  
  


Measured memory_bytes: 256
a=int(raw_input())
b=int(raw_input())
c=int(raw_input())
x=[[0]*3 for _ in xrange(3)]
x[0][0]=a;x[0][1]=b;x[1][1]=c
for i in xrange(1000+1):
    x[0][2]=i
    msum=a+b+i
    x[2][1]=msum-x[0][1]-x[1][1]
    x[2][2]=msum-x[0][0]-x[1][1]
    if msum-x[2][1]-x[2][2]==msum-x[1][1]-x[0][2]:
        x[2][0]=msum-x[2][1]-x[2][2]
    else:
        continue
    x[1][0]=msum-x[0][0]-x[2][0]
    if msum-x[0][2]-x[2][2]==msum-x[1][0]-x[1][1]:
        x[1][2]=msum-x[0][2]-x[2][2]
    else:
        continue
    for j in xrange(3):
        print(" ".join(map(str,x[j])))
    break

Measured memory_bytes: 2796
main = do
    let deck = [x ++ " " ++ (show y) | x <- ["S","H","C","D"], y <- [1..13]]
    n <- getLine
    ss <- getContents
    let cards = lines ss
    let remaining = removeC deck cards
    mapM_ putStrLn remaining


removeC deck [] = deck
removeC deck (x:xs) = removeC (filter (/=x) deck) xs


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

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

    int S;
    cin >> S;

    int h, m, s;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = S % 60;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char W[11], T[1001];
    int i, count=0;
    scanf("%s", W);
    while (scanf("%s", T)!=EOF) {
        for (i=0; T[i]!='\0'; i++) {
            T[i]=tolower(T[i]);
        }
        if (strcmp(W, T)==0) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}



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

using namespace std;

#define MAX 10000
#define INFTY (1<<29)

class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i=0; i<size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

class Edge{
public:
    int source, target, cost;
    Edge(int source = 0, int target = 0, int cost = 0):
    source(source), target(target), cost(cost){}
    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
};

int kruskal(int N, vector<Edge> edges){
    int totalCost = 0;
    sort(edges.begin(), edges.end());

    DisjointSet dset = DisjointSet(N);

    for(int i=0; i<N; i++) dset.makeSet(i);

    int source, target;
    for(int i=0; i<edges.size(); i++){
        Edge e = edges[i];
        if(!dset.same(e.source, e.target)){
            //MST.push_back(e);
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}


int main(){
    int N, M, cost;
    int source, target;

    cin >> N >> M;

    vector<Edge> edges;
    for(int i=0; i<M; i++){
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));
    }

    cout << kruskal(N, edges) << endl;

    return 0;
}


Measured memory_bytes: 5472
#include<iostream>
using namespace std;
#define INFTY (1<<21)
#define MAX 100
#define rep(i, n) for ( int i = 0; i < (int)n; i++)

void floyd(int m, int C[MAX][MAX], int T[MAX][MAX]){
    rep(k, m) rep(i, m) rep(j, m){
	C[i][j] = min( C[i][j], C[i][k] + C[k][j] );
	T[i][j] = min( T[i][j], T[i][k] + T[k][j] );
    }
}

main(){
    int n, m, a, b, c, t, k, q, C[MAX][MAX], T[MAX][MAX];
    while( cin >> n >> m && n && m){
	rep(i, m) rep(j, m) { C[i][j] = T[i][j] = INFTY; }
	rep(i, n){
	    cin >> a >> b >> c >> t;
	    C[a-1][b-1] = C[b-1][a-1] = c;
	    T[a-1][b-1] = T[b-1][a-1] = t;
	}
	floyd(m, C, T);
	cin >> k;
	rep(i, k){
	    cin >> a >> b >> q;
	    if ( q ) cout << T[a-1][b-1] << endl;
	    else cout << C[a-1][b-1] << endl;
	}
    }
}

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

int main(){
    char s[200002];
    char c;
    int i,j,k,l;
    while((c=getchar())!='\n'){
        s[i]=c;
        i++;
    }
    for(j=0;j<i;j++){
        if(s[j]=='A'){
            k=j;
            break;
        }
    }
    for(j=i;j>0;j--){
        if(s[j]=='Z'){
            l=j;
            break;
        }
    }
    printf("%d\n",l-k+1);
}

Measured memory_bytes: 384
#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Measured memory_bytes: 62616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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

int x, n, total = 10000005, ans;
int p[105];

int main() {

	cin >> x >> n;
	if (n != 0)rep(i, n)cin >> p[i];
	
	REP(i, -1, 102) {
		if (total > abs(x - i)) {
			bool f = true;
			rep(j, n) {
				if (i == p[j])f = false;
			}
			if (f) { ans = i; total = abs(x - i); }
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;
int dp[100100][3];

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    srep(i,1,n) {
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
    }
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
    return 0;
}


Measured memory_bytes: 2560
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, D = LI()
X = [[] for i in range(N)]
for i in range(N):
    X[i] = LI()

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        l = 0
        for d in range(D):
            l += (X[i][d] - X[j][d]) ** 2
        if math.sqrt(l) % 1 == 0:
            cnt += 1

print(cnt)


Measured memory_bytes: 6732
S = str(input())
T = str(input())
lens = len(S)
lent = len(T)
ans = []

for i in range(lens-lent + 1):
      count = 0
      U = S[i: i+lent]
      for j in range(lent):
            if U[j] != T[j]:
                count += 1
      ans.append(count)
print(min(ans))

Measured memory_bytes: 9020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(min(a+c,b+d),min(a+d,b+c)) << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d\n", &N)

	arr := make([]int, N)
	var sum int
	for i := 0; i < N; i ++ {
		var n int
		fmt.Scanf("%d", &n)
		arr[i] = n
		sum += n
	}
  avr := float64(sum) / float64(N)
  v := int(avr)
  if float64(int(avr)+1)-avr <= 0.5 {
    v +=1
  }
	var min int
	for _, n := range arr {
			min = min + (n - v) * (n - v)
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
//02, 12, 2018, 10:07:27 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

vector< int > con;

void gen(int pos, int mark1, int mark2, int mark3, int number){
    if(pos == 0){
        if(mark1 && mark2 && mark3){
            con.push_back(number);
        }
    }else{
        gen(pos - 1, 1, mark2, mark3, number * 10 + 3);
        gen(pos - 1, mark1, 1, mark3, number * 10 + 5);
        gen(pos - 1, mark1, mark2, 1, number * 10 + 7);

        if(!mark1 && !mark2 && !mark3){
            gen(pos - 1, 0, 0, 0, 0);
        }
    }
}

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

    gen(9, 0, 0, 0, 0);

    int n;

    cin >> n;

    int cnt = 0;

    for(int i = 0 ; i < con.size() ; i++){
        if(con[i] <= n){
            cnt++;
        }
    }

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

Measured memory_bytes: 512
from collections import Counter
n=int(input())
S=[]
for i in range(n):
    S.append(input())
T=Counter(S)
S=list(set(S))
M=max(T.values())
U=[]
j=0
for i in S:
    if T[i]==M:
        U.append(S[j])
    j+=1
U.sort()
for i in U:
    print(i)

Measured memory_bytes: 171444
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] l = new int[n];
    for(int i=0; i<n; ++i)
      l[i] = sc.nextInt();
    int ans = 1;
    int area = 0;
    for(int i=0; i<n; ++i){
      area += l[i];
      if( area <= x )
        ++ans;
      else
        break;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
int n,k;
long cnt_n = 0,cnt_even = 0;
int main(){
 cin >> n >> k;
 cnt_n = n / k;
 if(k % 2 == 0){
  for(int i = 1;i <= n;i++)if(i%k == (k/2))cnt_even++;
 }
 cout << cnt_n * cnt_n *  cnt_n + cnt_even * cnt_even * cnt_even << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
int main() {
  cin >> n;
  i64 ans = 0;
  for (i64 i = 1; i <= n; ++i) {
    if ((0 <= i && i <= 9) || (100 <= i && i <= 999)
        || (10000 <= i && i <= 99999))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
    int N;

    cin >> N;

    vector<int> f(N, 0);
    vector<int> p(N, 0);
    
    for(int i = 0; i < N; ++i)
    {
        cin >> f[i] >> p[i];
    }    

    bool ans = false;
    for(int i = 2; i < N; ++i)
    {
        if(f[i] == p[i] && f[i-1] == p[i-1] && f[i-2] == p[i-2]) ans = true;

    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long  N=0;
long long  maxNum=0;
long long  minNum=10000000000;

int main(){
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    maxNum = max(maxNum,A.at(i));
    minNum = min(minNum,A.at(i));
  }
  cout << maxNum-minNum  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x,i=0;
    string s;
    cin >> s;
    x=s.length();
    while (i<x)
    {
        s[i] = 'x';
        i += 1;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = n * (n - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

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

using namespace std;

int main()
{
  int H, W;
  cin >> H >> W;
  
  int h, w;
  cin >> h >> w;
  
  cout << (W-w) * (H-h) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 10;
int a, b;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  if(a>b) swap(a, b);
  FOR(i, 0, b) cout << a;
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int fact(int N){
	static vector<int> _fact(1, 1);
	for(int i = _fact.size(); i <= N; i++){
		_fact.push_back(MOD(i * _fact[i - 1]));
	}
	return _fact[N];
}
 
int fact_inv(int N){
	static vector<int> inv(2, 1), _fact_inv(2, 1);
	for(int i = inv.size(); i <= N; i++){
		inv.push_back(MOD(-(p / i) * inv[p % i]));
		_fact_inv.push_back(MOD(inv[i] * _fact_inv[i - 1]));
	}
	return _fact_inv[N];
}
 
int combination(int N, int k){
	if(k < 0 || N < k || N < 0) return 0;
	else return MOD(fact(N) * MOD(fact_inv(N - k) * fact_inv(k)));
}

int dfs(vector<vector<int>> &t, vector<vector<int>> &is_parent, vector<int> &sub_size, int v, int parent){
	for(int i = 0; i < t[v].size(); i++){
		if(t[v][i] == parent){
			is_parent[v][i] = 1;
		}
		else{
			sub_size[v] += dfs(t, is_parent, sub_size, t[v][i], v);
		}
	}
	return sub_size[v];
}

signed main(){
	int N, x, y, i, j, k;
	scanf("%lld", &N);
	vector<vector<int>> t(N, vector<int>(0)), is_parent(N, vector<int>(0));
	for(i = 1; i < N; i++){
		scanf("%lld%lld", &x, &y);
		x--;
		y--;
		t[x].push_back(y);
		t[y].push_back(x);
		is_parent[x].push_back(0);
		is_parent[y].push_back(0);
	}
	vector<int> sub_size(N, 1), rest_max(N, 0);
	int res = dfs(t, is_parent, sub_size, 0, -1);
/*	printf("sub_size:\n");
	for(i = 0; i < N; i++){
		printf("%lld ", sub_size[i]);
	}
	printf("\n");
*/	int cog, cnt = 0;
	for(i = 0; i < N; i++){
		rest_max[i] = N - sub_size[i];
		for(j = 0; j < t[i].size(); j++){
			if(is_parent[i][j] == 0){
				rest_max[i] = max(rest_max[i], sub_size[t[i][j]]);
			}
		}
//		printf("rest_max[%lld] = %lld\n", i, rest_max[i]);
		if(rest_max[i] <= N / 2){
			cog = i;
			cnt++;
		}
	}
//	printf("(cog, cnt) = (%lld, %lld)\n", cog, cnt);
	if(cnt == 2){
		printf("%lld\n", MOD(fact(N / 2) * fact(N / 2)));
		return 0;
	}
	vector<int> a(1);
	if(cog != 0){
		a.push_back(N - sub_size[cog]);
	}
	for(j = 0; j < t[cog].size(); j++){
		if(is_parent[cog][j] == 0){
			a.push_back(sub_size[t[cog][j]]);
		}
	}
/*	printf("a:\n");
	for(i = 0; i < a.size(); i++){
		printf("%lld ", a[i]);
	}
	printf("\n");
*/	vector<vector<int>> dp(a.size(), vector<int>(N + 1, 0));
	dp[0][0] = 1;
	for(i = 1; i < a.size(); i++){
		for(j = 0; j <= N; j++){
			for(k = 0; k <= a[i] && k <= j; k++){
				dp[i][j] = MOD(dp[i][j] + MOD(MOD(combination(a[i], k) * combination(a[i], k)) * fact(k)) * dp[i - 1][j - k]);
			}
		}
	}
/*	for(i = 0; i < a.size(); i++){
		printf("dp[%lld]:", i);
		for(j = 0; j <= N; j++){
			printf("%lld ", dp[i][j]);
		}
		printf("\n");
	}
*/	int ans = 0;
	for(j = 0; j <= N; j++){
		ans = MOD(ans + (j % 2 == 0 ? 1 : -1) * fact(N - j) * dp[a.size() - 1][j]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 196608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


vector<ll> arr(100001,0);
int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  ll sum = 0;
  rep(i,n){
    cin >> vec[i];
    arr[vec[i]]++;
    sum += vec[i];
  }
  ll q;
  cin >> q;
  rep(i,q){
    cin >> t1 >> t2;
    sum += arr[t1] * (t2-t1);
    arr[t2] += arr[t1];
    arr[t1] = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 4804
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>

#define MAX_V 25
#define INF 1e+8

using namespace std;

void dijkstra(int s);

int goCost[MAX_V][MAX_V],backCost[MAX_V][MAX_V];	//cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int dist[MAX_V];	//頂点sからの最短距離
bool used[MAX_V];	//既に使われたかどうかのフラグ
int V;	//頂点数
int M;	//辺の数


int main(void){
	
	cin>>V;
	cin>>M;

	int a,b,c,d,sTown,gTown,reward,pay,ans;
	
	//ポインタにキャストして渡すと2次元配列が初期化出来る
	fill((int *)goCost,(int *)(goCost+MAX_V),(int)INF);    
	//fill((int *)backCost,(int *)(backCost+MAX_V),INF);
	
	for(int i=0;i<M;i++){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		goCost[a-1][b-1]=c;
		goCost[b-1][a-1]=d;
	}
	
	scanf("%d,%d,%d,%d",&sTown,&gTown,&reward,&pay);
	

	dijkstra(sTown-1);
	a=dist[gTown-1];
	dijkstra(gTown-1);
	b=dist[sTown-1];
	
	ans=reward-(a+b+pay);
	printf("%d\n",ans);
}

void dijkstra(int s){
	fill(dist,dist+V,(int)INF);
	fill(used,used+V,false);
	dist[s]=0;

	while(true){
		int v=-1;
		
		//まだ使われていない頂点のうち距離が最小のものを探す
		for(int u=0;u<V;u++){
			if(used[u]==false && (v==-1 || dist[u]<dist[v])){
				v=u;
			}
		}

		if(v==-1){
			break;
		}

		used[v]=true;

		for(int u=0;u<V;u++){
			dist[u]=min(dist[u],dist[v]+goCost[v][u]);			
		}
	}
}

Measured memory_bytes: 1228
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N+1];
		int ans = 0;
		int[] C = new int[N];
		for(int i=1;i<=N;i++) {
			A[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			ans += sc.nextInt();
		}
		for(int i=1;i<=N-1;i++) {
			C[i]=sc.nextInt();
		}
		sc.close();
		for(int i=2;i<=N;i++) {
			if(A[i]-A[i-1]==1) {
				ans += C[A[i-1]];
			}
		}
		System.out.println(ans);


	}
}

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

long long n;
string ans="";

int main(){
	cin >> n;
	while (n>0){
		ans.push_back(((n-1)%26)+'a');
		n--;
		n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <stdio.h>

#define MAX_N 100010
int a[MAX_N];

int gcd(int s, int t)
{
    if (t == 0) return s;
    return gcd(t, s % t);
}

int main(void)
{
    int n, k;
    scanf("%d%d", &n, &k);
    int Max = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        Max = a[i] > Max? a[i]: Max;
    }
    bool flag = false;
    for (int i = 0; i < n; i++)
        if (k == a[i])
            flag = true;
    if (!flag) {
        if (n == 1) flag = false;
        else if (k > Max) flag = false;
        else {
            int Gcd = a[0];
            for (int i = 1; i < n; i++)
                Gcd = gcd(a[i], Gcd);
            if (Gcd == 1) flag = true;
            else if (gcd(k, Gcd) > 1) flag = true;
        }
    }
    if (flag) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


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

int main() {
  int d, g; cin >> d >> g;
  vector<int> p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i];

  int ans = 1e9;
  rep(bit, (1<<d)) {
    int tmp = 0;
    int sum = 0;
    int pmax = d-1;
    rep(i, d) {
      if (bit&(1<<i)) {
        sum += c[i] + p[i]*100*(i+1);
        tmp += p[i];
      }
      else pmax = i;
    }
    if (sum < g) {
      int add = 100 * (pmax + 1);
      int padd = (g - sum + add - 1)/add;
      if (padd >= p[pmax]) continue;
      tmp += padd;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn solve(g: &Vec<Vec<usize>>) -> bool {
    for v in g {
        if v.len()%2 == 1 { return false }
    }
    let mut p4 = Vec::new();
    for i in 0..g.len() {
        if g[i].len() >= 6 { return true }
        if g[i].len() == 4 { p4.push(i); }
    }
    if p4.len() != 2 { return p4.len() >= 3 }
    for &t in &g[p4[0]] {
        let mut prev = p4[0];
        let mut p = t;
        while g[p].len() == 2 {
            let next = g[p][if g[p][0] != prev { 0 } else { 1 }];
            prev = p;
            p = next;
        }
        if p == p4[0] { return true }
    }
    false
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let m = it.next().unwrap().parse::<usize>().unwrap();
    let mut g = vec![Vec::new(); n];
    for _ in 0..m {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    println!("{}", if solve(&g) { "Yes" } else { "No" });
}


Measured memory_bytes: 12540
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;



int main() {
	int k; cin >> k;
	vector<pair<double, ll>> can;
	for (ll i = 0; i <= 12; i++) {
		ll p = 0, q = 1;
		for (ll j = 0; j < i; j++) p = 10*p + 9, q *= 10;
		for (ll a = 0; a <= 9; a++) {
			for (ll b = 0; b <= 9; b++) {
				for (ll c = 0; c <= 9; c++) {
					ll v = (100 * a + 10 * b + c)*q + p;
					can.push_back({ (double)v / (double)(a + b + c + 9 * i), v });
				}
			}
		}
	}
	sort(can.begin(), can.end());
	ll ma = 0;
	int cnt = 0;
	for (auto p : can) {
		ll a = p.second;
		if (a <= ma) continue;
		cout << a << endl;
		ma = a;
		cnt++;
		if (cnt >= k) break;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;
struct Circle{
  Point c;
  double r;
  Circle() {}
  Circle(Point c, double r) : c(c), r(r) {}
};

int sign(double x){
  if(x > EPS) return +1;
  if(x < -EPS) return -1;
  return 0;
}

void normalize(double& x){
  while(x > M_PI) x -= 2 * M_PI;
  while(x < -M_PI) x += 2 * M_PI;
}

typedef pair<double, int> Event;

int main(){
  int N;
  while(cin >> N && N){
    vector<Circle> C(N);
    REP(i, N) cin >> C[i].c.real() >> C[i].c.imag() >> C[i].r;
    double ans = 0;
    for(int i = 0; i < N; i++){
      bool contained = false;
      vector<Event> events;
      events.push_back(Event(-M_PI, 0));
      events.push_back(Event(M_PI, 0));
      for(int j = 0; j < N; j++){
        if(i == j) continue;
        double d = abs(C[i].c - C[j].c);
        if(sign(d - abs(C[j].r - C[i].r)) <= 0){
          if(sign(C[i].r - C[j].r) <= 0) contained = true;
          continue;
        }
        if(sign(d - (C[i].r + C[j].r)) >= 0) continue; // テ、ツコツ、テ」ツつ湘」ツつ嘉」ツ?ェテ」ツ??
        double a = arg(C[j].c - C[i].c);
        double b = acos( (d * d + C[i].r * C[i].r - C[j].r * C[j].r) / (2.0 * d * C[i].r));
        double A = a - b;
        double B = a + b;
        normalize(A);
        normalize(B);
        if(A < B){
          events.push_back(Event(A, -1));
          events.push_back(Event(B, +1));
        }else{
          events.push_back(Event(-M_PI, -1));
          events.push_back(Event(B, +1));
          events.push_back(Event(A, -1));
        }
      }
      if(contained) continue;
      sort(events.begin(), events.end());
      int L = events[0].second;
      double sub_ans = 0;
      for(int j = 1; j < events.size(); j++){
        assert(L <= 0);
        if(L == 0){
          sub_ans += C[i].r * (events[j].first - events[j - 1].first);
        }
        L += events[j].second;
      }
      //printf("%d: %lf\n", i, sub_ans);
      ans += sub_ans;
    }
    printf("%.12lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1340
using System;

namespace ABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line1 = new int[5];
            int[] line2 = new int[5];

            for(var i = 0; i < 5; i++)
            {
                line1[i] = int.Parse(Console.ReadLine());
            }

            for(var i = 0; i < 5; i++)
            {
                var v = line1[i] % 10;
                if(v == 0)
                {
                    line2[i] = 10;
                }
                else
                {
                    line2[i] = v;
                }
            }

            int min = 1000;
            int minno = 1000;

            for(var i = 0; i < 5; i++)
            {
                if(min > line2[i])
                {
                    min = line2[i];
                    minno = i;
                }
            }

            int sum = 0;

            for(var i = 0; i < 5; i++)
            {
                if(i == minno)
                {
                    sum += line1[i];
                }
                else
                {
                    if(line2[i] == 10)
                    {
                        sum += line1[i];
                    }
                    else
                    {
                        sum += (line1[i] / 10 + 1) * 10;
                    }
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	int n;
	double x[100] = {0}, y[100] = {0};
	double p_1 = 0, p_2 = 0, p_3 = 0, p_inf = -1;

	scanf("%d", &n);

	for(int i = 0;i < n;i++) {
		scanf("%lf", &x[i]);
	}
	for(int i = 0;i < n;i++) {
		scanf("%lf", &y[i]);
	}

	for(int i = 0;i < n;i++) {
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i]) * (x[i] - y[i]);
		p_3 += abs(pow((x[i] - y[i]), 3));
		p_inf = (p_inf >= abs(x[i] - y[i])) ? p_inf : abs(x[i] - y[i]);
	}

	printf("%.6lf\n", p_1);
	printf("%.6lf\n", sqrt(p_2));
	printf("%.6lf\n", cbrt(p_3));
	printf("%.6lf\n", p_inf);

	return 0;
}



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

#define ll long long int

typedef pair<ll,ll> pii;

#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vvl vector<vector<ll,ll> >
#define vvs vector<vector<string> >
#define pb push_back
#define mk make_pair
#define sbit(a)  __builtin_popcount(a)
#define f(i,a,n) for(i=a;i<n;i++)
#define fb(i,a,n) for(i=a;i>=n;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define nextp(s) next_permutation(s.begin(), s.end()); 
#define ignor cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define bsearch(a,x) binary_search(a.begin(),a.end(),x)
#define ini ll i,j,k,l,m,n,x,y,sm=0,cnt=0
const ll mod=1e9+7;
const double pi=acos(-1);


bool prime[1000000];
void sieve(ll n) 
{ 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

ll primefunc(ll n)
{
    ll i;
    if(n<2)
    return 0;
    f(i,2,sqrt(n)+1)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}

ll bs(ll arr[], ll l, ll r, ll x)
{
   if (r >= l)
   {
        ll mid = l + (r - l)/2;
        if (arr[mid] == x)  
            return mid;
        if (arr[mid] > x) 
            return bs(arr, l, mid-1, x);
        return bs(arr, mid+1, r, x);
   }
   return -1;
}


ll moex(ll x,ll n,ll mod)

{
    
	if(n==0)
        
       		return 1;
    
	else if(n%2 == 0)   
        	
		return moex((x*x)%mod,n/2,mod);
    
	else 
              return (x*moex((x*x)%mod,(n-1)/2,mod))%mod;

}


ll modi(ll a, ll m) 
{ 
      	ll k=moex(a, m-2, m); 
	return k;
} 

void subString(string s, int n) 
{
    for (int i = 0; i < n; i++) 
        for (int len = 1; len <= n - i; len++)
            cout << s.substr(i, len) << endl;
}


int main(){
    	fast;
       ll n;
       cin>>n;
       ll a[n];
       ll i,j,m1=-1,m2=-2;
       f(i,0,n){
       cin>>a[i];
       if(a[i]>=m1)
       {
           m2=m1;
           m1=a[i];
       }
       else if(a[i]>=m2)
       m2=a[i];
       }
      f(i,0,n)
      {
          if(a[i]==m1)
          cout << m2<<endl;
          else
          cout <<m1<<endl;
      }
       
       
    return 0;
}


Measured memory_bytes: 3200
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

constexpr ll INF = numeric_limits<ll>::max();

ll N;
ll A[300][300];

void solve()
{
    // 条件を満たすグラフはAの部分グラフ
    // よって、ワーシャルフロイドで更新があれば存在しない
    FOR(k, 0, N) {
        REP(i, N) {
            REP(j, N) {
                if(A[i][j] > A[i][k] + A[k][j]) {
                    cout << -1 << "\n";
                    return;
                }
            }
        }
    }

    // 全てのi,j (i!=j)について
    // A[i][j] == A[i][k] + A[k][j] なるkがあればi,j間の辺を取り除く
    ll total = 0;
    FOR(i, 0, N) {
        FOR(j, i+1, N) {
            bool del = false;
            FOR(k, 0, N) {
                if(i == k || k == j) continue;
                if(A[i][k] == 0 || A[k][j] == 0) {
                    ;
                }
                else if(A[i][j] == A[i][k] + A[k][j]) {
                    del = true;
                }
                else {
                    ;
                }
            }
            if(del) {
                //A[i][j] = 0;
                //A[j][i] = 0;
            }
            else {
                total += A[i][j];
            }
        }
    }

    cout << total << "\n";
}

int main()
{
    cin >> N;
    REP(i, N) {
        REP(j, N) {
            cin >> A[i][j];
        }
    }

    solve();

    return 0;
}


Measured memory_bytes: 896
import sys
from io import StringIO
import unittest
from itertools import accumulate
def resolve():
    end=100000
    input=sys.stdin.readline
    N,C=map(int,input().rstrip().split())
    S=[list(map(int,input().rstrip().split())) for _ in range(N)]

    l=[[0 for _ in range(C)] for __ in range(2*end)]
    for i in range(N):
        l[S[i][0]*2-1][S[i][2]-1]+=1
        if S[i][1]!=end:
            l[S[i][1]*2+1][S[i][2]-1]-=1
    """
    ans=0
    npl=np.array(l)
    for i in range(C):
        snpl=npl[:,i]
        buf=list(snpl)
        asum = list(accumulate(buf))
        M=max(asum)
        ans=max(ans,M)
    """
    asum=[0 for __ in range(2*end)]
    for i in range(2*end):#列(C)で和を取る
        for j in range(C):
            asum[i]+=l[i][j]
    asum2=list(accumulate(asum))
    ans=max(asum2)
    ans=min(ans,C)

    print(int(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2
1 7 2
7 8 1
8 12 1"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 4
1 3 2
3 4 4
1 4 3"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 146276
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int year, month, day;
    while(cin >> year >> month >> day){
        if(year > 1989 || (year == 1989 && month > 1) || (year == 1989 && month == 1 && day >= 8))
            cout << "heisei " << -1*(1989 - 1 - year) << ' ' << month << ' ' << day << endl;
        else if(year > 1926 || (year == 1926 && month > 12) || (year == 1926 && month == 12 && day >= 25))
            cout <<  "showa " << -1*(1926 - 1 - year) << ' ' << month << ' ' << day << endl;
        else if(year > 1912 || (year == 1912 && month > 7) || (year == 1912 && month == 7 && day >= 30))
            cout << "taisho " << -1*(1912 - 1 - year) << ' ' << month << ' ' << day << endl;
        else if(year > 1868 || (year == 1868 && month > 9) || (year == 1868 && month == 9 && day >= 8))
            cout <<  "meiji " << -1*(1868 - 1 - year) << ' ' << month << ' ' << day << endl;
        else
            cout << "pre-meiji" << endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n;
	cin >> n;
	cout << (n - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

namespace ManyFormulas
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputNumber = Console.ReadLine();
            var ans = CalcManyFormulas(inputNumber);
            Console.WriteLine(ans);
            //Console.ReadKey();
        }

        static private long CalcManyFormulas(string inputNumber)
        {
            long ans = 0;
            int plusNum = inputNumber.Length - 1;
            long loop = (long)Math.Pow(2, plusNum);
            for (var i = loop - 1; i >= 0; i--)
            {
                var temp = inputNumber;
                for (var j = 0; j < plusNum; j++)
                {
                    if ((i >> j) % 2 != 0)
                    {
                        ans += long.Parse(temp.Substring(plusNum - j));
                        temp = temp.Substring(0, plusNum - j);
                    }
                }
                ans += long.Parse(temp);
            }

            return ans;
        }
    }
}


Measured memory_bytes: 2776
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
n, m = inpl()
C = sorted(inpl())
DP = list(range(n+1))

for c in C[1:]:
    for i in range(n-c+1):
        if DP[i] + 1 < DP[i+c]:
            DP[i+c] = DP[i] + 1
            
print(DP[-1])


Measured memory_bytes: 7520
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int N = 2e5+7;
ll s[N],h[N],a[N];
int main()
{
    int n,k;scanf("%d%d",&n,&k);
	for(int i = 1;i <= n;++i)	s[i] = s[i - 1] + i;
	for(int i = n;i >= 1;--i)	h[i] = h[i + 1] + i;
    ll res = 1;
    for(int i = k;i <= n;++i)	res = (res + h[n - i + 1] - s[i - 1] + 1) % MOD;
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 6352
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005




int main() {
    string s;
    cin >> s;
    int start=-1, end=-1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A' && start==-1) start = i;

        if (s[i] == 'Z' && start!=-1) end = i;


    }
    cout << end - start + 1 << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

string a,b;
int dp[1010][1010];
bool u[1010][1010];

int fn(int i,int j){
    if( i < 0 || j < 0 ) return 0;
    if( u[i][j] ) return dp[i][j];
    u[i][j] = true;
    int ans = max( fn(i-1,j) , fn(i,j-1) );
    if( a[i]==b[j] ) ans = max( ans , 1+fn(i-1,j-1) );
    return dp[i][j] = ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    for(int i=1; i<=t; i++){
        cin >> a >> b;
        for(int j=0; j<a.size(); j++) for(int k=0; k<b.size(); k++) u[j][k] = false;
        cout << fn( a.size()-1 , b.size()-1 ) << "\n";
    }

    return 0;
}



Measured memory_bytes: 8256
#include<iostream>
using namespace std;
int main(){
    int b=0,n,i,minj,j,swap;
    int a[100];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    if(n>1){
        for(i=0;i<n-1;i++){
          
            minj=i+1;
            for(j=i+1;j<n;j++){
                if(a[minj]>a[j]){
                    
                    minj=j;
                }
            }
            if(a[minj]<a[i]){
                swap=a[i];
                a[i]=a[minj];
                a[minj]=swap;
                b++;
            }
            /*for(int k=0;k<n-1;k++){
                cout<<a[k]<<" "<<flush;
            }
            cout<<a[n-1]<<endl;*/
        }
    }
    else{
        cout<<a[0]<<endl;
        cout<<0<<endl;
        return 0;
    }
    for(i=0;i<n-1;i++){
        cout<<a[i]<<" "<<flush;
    }
    cout<<a[n-1]<<endl;
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 3112