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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int d[110][110];

vi ans;
int cmin=0;
int main(void){
	int n;
	cin >> n;
	rep(i,n)rep(j,n) cin >> d[i][j];
	ll ans=0;
	rep(i,n)rep(j,i) ans+=min(d[i][j],d[j][i]);
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define int long long
const int N = 1e6 + 10;

signed main(){

	int n , k;
	cin>>n>>k;

	string s;
	cin>>s;
	--k;
	s[k]+=32;

	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int room[4][3][10]={0},n=0,i,j,k,a,b,c,d;

    scanf("%d",&n);

    for (i=0; i<n; i++) {
        scanf("%d %d %d %d",&a,&b,&c,&d);
        room[a-1][b-1][c-1]=room[a-1][b-1][c-1]+d;
    }

    for (i=0; i<4; i++)
    {
        for (j=0; j<3; j++)
        {
            for (k=0; k<10; k++)
            {
                printf(" %d",room[i][j][k]);
            }
            printf("\n");
        }
        if (i!=3)
        printf("####################\n");
    }

    return 0;
}

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

static class Prime {
    public static List<int> Sieve(int n) {
        var tab = new bool[n+1];
        var ps = new List<int>();
        if (n >= 2) ps.Add(2);
        for (int i = 3; i <= n; i += 2) {
            if (!tab[i]) { // i is prime
                ps.Add(i);
                for (int j = i+i; j <= n; j += i) {
                    tab[j] = true;
                }
            }
        }
        return ps;
    }
}

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static List<int> Factor(int n, List<int> primes) {
        var xs = new List<int>();
        foreach (int p in primes) {
            if (p * p > n) break;
            while (n % p == 0) {
                xs.Add(p);
                n /= p;
            }
        }
        if (n > 1) xs.Add(n);
        return xs;
    }

    static void Main() {
        int n = ReadInt();
        var primes = Prime.Sieve((int)Math.Sqrt(1e9));
        var xs = Factor(n, primes);
        Console.Write("{0}:", n);
        foreach (var x in xs)
            Console.Write(" {0}", x);
        Console.WriteLine();
    }
}

Measured memory_bytes: 9380
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t>vec(N);
    int64_t sum = 0;
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    for (int i=0; i<K; i++) {
        sum += vec[i];
    }

    for (int i=K; i<N; i++) {
        int64_t now = sum - vec[i-K] + vec[i];
        if (now > sum) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

        sum = now;
    }

    return 0;
}

Measured memory_bytes: 4828
a,b = input().split()
a = int(a)
b = int(b)

if 0 <= a <= 100:
    if 2 <= b <= 1000 and (b%2 == 0):
        if a >= 13 :
            print(int(b))
        if 6 <= a <= 12:
            x = b/2
            print(int(x))
        if a <= 5 :
            print(int(0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<vector<int>> f;
    vector<vector<int>> p;

    rep(i,n){
        vector<int> tmpv;
        rep(j,5){
            int tmp1,tmp2;
            cin >> tmp1 >> tmp2;

            tmpv.pback(tmp1);
            tmpv.pback(tmp2);
        }
        f.pback(tmpv);
    }

    rep(i,n){
        vector<int> tmpv;
        rep(j,11){
            int tmp1;
            cin >> tmp1;

            tmpv.pback(tmp1);
        }
        p.pback(tmpv);
    }

    int ans = INT_MIN;

    for(int bit = 1; bit < (1<<10); bit++){
        int tmpans = 0;

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

            int together = 0;

            for(int j = 0; j < 10; j++){
                if(bit & (1 << j)){
                    if(f[i][j] == 1){
                        together++;
                    }
                }
            }

            tmpans = tmpans + p[i][together];
        }

        ans = max(ans,tmpans);

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
from collections import deque
s = input()
que = deque(list(s))
q = int(input())
flag = True
for _ in range(q):
    l = input()
    if flag:
        if l[0] == "1":
            flag = False
        else:
            if l[2] == "1":
                que.appendleft(l[4])
            else:
                que.append(l[4])
    else:
        if l[0] == "1":
            flag = True
        else:
            if l[2] == "1":
                que.append(l[4])
            else:
                que.appendleft(l[4])
if flag:
    ans = list(que)
    print("".join(ans))
else:
    ans = list(que)[::-1]
    print("".join(ans))

Measured memory_bytes: 10204
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    map<string,int> m;
    int ans = 0;
    rep(i,n){
        string s; cin >> s;
        if(m[s] == 0) ans++;
        m[s]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19128
#include <iostream>
#include<string>
using namespace std;
void output(int array[],int array2[],int number){
    int num = 0;
    for(int j = 0;j<number;j++){
        num = num + array[j]*array2[j];               
    }
    cout<<num<<endl;
}

int main(){
    string str;
    getline(cin,str);
    for(int i = 0;i<str.size();i++){
        if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
        else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
    }
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3164
N = int(input())
H = list(map(int,input().split()))

flag = True

for i in range(N-1):
    if H[i] <= H[i+1]:
        continue
    elif H[i] == H[i+1]+1:
        H[i+1] += 1
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14224
def examA():
    A, B, C, D = LI()
    if A+B==C+D:
        ans= "Balanced"
    elif A+B<C+D:
        ans = "Right"
    else:
        ans = "Left"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
	}
    sort(ALL(a));
    rep(i,n){
        ans += a[i];
	}
    int i=0;
    ptr=ans;
    while(ptr%10==0 && i<n){
        ptr=ans;
        if(ptr%10==0){
            ptr -= a[i];
        }
        i++;
    } 
    ans = ptr;
    if(i==n)
        cout << 0 << endl;
    else 
        cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

main = do
  s <- BS.getLine
  let c3 = BS.index s 2
      c4 = BS.index s 3
      c5 = BS.index s 4
      c6 = BS.index s 5
  putStrLn $ if c3 == c4 && c5 == c6
             then "Yes"
             else "No"

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define ll long long
const ll MAX=100050;
const ll modn=1e9+7;
using namespace std;

void slove(){
    int n;
    cin>>n;
    if(n%2==0||n%5==0)
        printf("-1\n");
    else{
        int sum=0;
        for(int i=1;i<=n;i++){
            sum=sum%n*10+7;
            if(sum%n==0){
                cout<<i;
                break;
            }
        }
    }

}

int main() {
    int _;
    //scanf("%d",&_);
    _=1;
    while(_--) {
        slove();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define INF 100000000000

using namespace std;

ll prep[1005];

ll get(ll mask, ll dp[], ll &m, ll cst[])
{
    if(dp[mask]!=-1)
        return dp[mask];
    
    if(mask == 0)
        return dp[mask] = 0;
    
    ll ans = INF;
    
    for(ll i=0;i<m;i++)
    {
        ll temp = (mask&prep[i]);
        if(temp == 0)
            continue;
        ll tempo = get(mask - temp,dp,m,cst) + cst[i];
        if(tempo>=INF)
            continue;
        ans = min(ans,(ll)tempo);    
    }
    
    return dp[mask] = ans;
}

int main()
{
   FAST/**/

   ll n,m;
   cin>>n>>m;
   
   unordered_map<ll,ll> hold[m];
   ll cst[m];
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       
       cst[i] = a;
       while(b--)
       {
           ll temp;
           cin>>temp;
           hold[i][temp-1]++;
       }
   }
   
   for(ll i=0;i<m;i++)
   {
       ll mask = 0;
       for(ll j=0;j<n;j++)
            mask+=((hold[i][j] == 0)?0:(1LL<<j));
       prep[i] = mask;    
       //cout<<mask<<"\n";
   }
   
   ll dp[1LL<<n];
   memset(dp,-1,sizeof(dp));
   ll temp = (1LL<<n) - 1;
   ll tempo = get(temp,dp,m,cst);
   if(tempo >= INF)
        tempo = -1;
    cout<<tempo;        
   
   return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstring>
using namespace std;
int main(){
    int n;
    cin >> n;
    char suit;
    int rank;
    int s[14] = {0};
    int h[14] = {0};
    int c[14] = {0};
    int d[14] = {0};
    
    for(int i = 0; i < n; i++){
        cin >> suit >> rank;
        switch (suit){
            case 'S':
                s[rank] = 1;
                break;
            case 'H':
                h[rank] = 1;
                break;
            case 'C':
                c[rank] = 1;
                break;
            default:
                d[rank] = 1;
                break;
        }
    }
    
    for(int i = 1; i < 14; i++){
        if(s[i] != 1){
            cout << "S " << i << endl;
        }
    }
    for(int i = 1; i < 14; i++){
        if(h[i] != 1){
            cout << "H " << i << endl;
        }
    }
    for(int i = 1; i < 14; i++){
        if(c[i] != 1){
            cout << "C " << i << endl;
        }
    }
    for(int i = 1; i < 14; i++){
        if(d[i] != 1){
            cout << "D " << i << endl;
        }
    }
}



Measured memory_bytes: 3080
x,y = map(str,input().split())
X = x.replace('A','10').replace('B','11').replace('C','12').replace('D','13').replace('E','14').replace('F','15')
Y = y.replace('A','10').replace('B','11').replace('C','12').replace('D','13').replace('E','14').replace('F','15')
if int(X) > int(Y):
  print('>')
elif int(X) < int(Y):
  print('<')
else:
  print('=')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static bool[,] edges;
    static bool[] visited;
    static int n;

    static void dfs(int x)
    {
	visited[x] = true;
	for (int i = 0; i < n; i++)
	{
	    if((!visited[i]) && edges[x, i])
	    {
		dfs(i);
	    }
	}
    }
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0]; int m = tmp[1];

	edges = new bool[n, n];
	int[] a = new int[m];
	int[] b = new int[m];

	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    a[i] = tmp[0] - 1;
	    b[i] = tmp[1] - 1;
	    edges[a[i], b[i]] = true;
	    edges[b[i], a[i]] = true;
	}
	
	visited = new bool[n];

	int ans = 0;
	for (int i = 0; i < m; i++)
	{
	    edges[a[i], b[i]] = false;
	    edges[b[i], a[i]] = false;

	    for (int j = 0; j < n; j++){ visited[j] = false; }

	    dfs(0);

	    for (int j = 0; j < n; j++)
	    {
		if (!visited[j])
		{
		    ans++;
		    break;
		}
	    }
		
	    edges[a[i], b[i]] = true;
	    edges[b[i], a[i]] = true;
	}

	WriteLine(ans);
    }
}


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

pair<int, int> ii(int n) {
    int a, b = n % 10;
    while(n > 0) {
        a = n;
        n /= 10;
    }
    return make_pair(a, b);
}

int main() {
    int N; cin >> N;
    vector<vector<int>> A(10, vector<int>(10));
    for(int i = 1; i <= N; ++i) {
        int a, b;
        tie(a, b) = ii(i);
        A[a][b]++;
    }
    int64 ans = 0;
    for(int i = 1; i <= N; ++i) {
        int a, b;
        tie(a, b) = ii(i);
        ans += A[b][a];
    }
    cout << ans << '\n';
    return 0;
}


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

int main()
{
  int m,n;
  cin>>n>>m;
  int food[31];
  memset(food,0,sizeof(food));
  for(int i=1;i<=n;i++)
  {
    int k;
    cin>>k;
    for(int j=0;j<k;j++)
    {
      int like;
      cin>>like;
      food[like]++;
    }
  }
  int count=0;
  for(int i=1;i<=30;i++)
  {
    if(food[i]>=n)
      count++;
  }
  cout<<count;
}

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

int main() {
  int A, B, K; cin >> A >> B >> K;

  vector<int> Ans;

  rep( i, 1, min( A, B )+1 ) {
    if ( A%i == 0 && B%i == 0 ) Ans.push_back(i);
  }

  cout << Ans.at( Ans.size()-K ) << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> you = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    int ans = 0;
    bool f = false;
    REP(i,14){
        if(f==false){
            if(you[i%7]==s){
                f=true;
            }
        }else{
            ans++;
            if(you[i%7]=="SUN"){
                cout << ans << endl;
                return 0;
            }
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		calc(str);
	}

	public static void calc(String str) {
		String[] result = str.split(" ");

		int num1 = Integer.parseInt(result[0]);
		int num2 = Integer.parseInt(result[1]);
		int num3 = Integer.parseInt(result[2]);

		if (num1 < num2) {
			if(num2 < num3){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24144
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

struct point{
  int a,b;
  int c,d;
};

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int> > a(H+1,vector<int>(W+1,0));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> a[i][j];
    }
  }
  vector<point> ans;
  int cnt=0;

  for(int i=1;i<=H;i++){
    if(i%2==1){
      for(int j=1;j<=W;j++){
        if(a[i][j]%2==1){
          a[i][j]--;
          if(j==W){
            if(i==H){
              a[i][j]++;
              continue;
            }
            a[i+1][j]++;
            ans.push_back({i,j,i+1,j});
            cnt++;
            //cout << i << " " << j << " " << i+1 << " " << j << endl;
          }else{
            a[i][j+1]++;
            ans.push_back({i,j,i,j+1});
            cnt++;
            //cout << i << " " << j << " " << i << " " << j+1 << endl;
          }
        }
      }
    }else{
      for(int j=W;j>=1;j--){
        if(a[i][j]%2==1){
          a[i][j]--;
          if(j==1){
            if(i==H){
              a[i][j]++;
              continue;
            }
            a[i+1][j]++;
            ans.push_back({i,j,i+1,j});
            cnt++;
            //cout << i << " " << j << " " << i+1 << " " << j << endl;
          }else{
            a[i][j-1]++;
            ans.push_back({i,j,i,j-1});
            cnt++;
            //cout << i << " " << j << " " << i << " " << j-1 << endl;
          }
        }
      }
    }
  }

  cout << cnt << endl;
  for(auto itr=ans.begin();itr!=ans.end();itr++){
    cout << (*itr).a << " " << (*itr).b << " " << (*itr).c << " " << (*itr).d << endl;
  }
}


Measured memory_bytes: 5232
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        k: usize,
    }
    for _ in 0..k {
        print!("ACL");
    }
    println!("");
}


Measured memory_bytes: 2120
#include <cstdio>

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

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

    const int NO_OF_COLOURS = 8, SPECIAL = 8;
    int frequency[NO_OF_COLOURS + 1] = {0}, special_colours = 0;

    while(no_of_contestants--)
    {
        int rating;
        scanf("%d", &rating);

        if(rating < 3200)
            frequency[rating/400]++;
        else
            special_colours++;
    }

    int normal_colours = 0;
    for(int i = 0; i < SPECIAL; i++)
        normal_colours += (frequency[i] > 0);

    int min_colours = (normal_colours == 0 ? 1 : normal_colours);
    int max_colours = normal_colours + special_colours;

    printf("%d %d", min_colours, max_colours);
    return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a==b and b==c) cout << 1;
    else if(a==b or b==c or a==c) cout << 2;
    else cout << 3;
}

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

int main(){
  int n;cin>>n;
  vector<map<char, int>> S(n);
  map<char,int> mp;
  string ans;
  for(char c='a';c<='z';c++) mp[c]=1000;
  REP(i,n){
    string s;cin>>s;
    REP(j,s.size()) S.at(i)[s.at(j)]++;
  }
  
  REP(i,n){
    for(char c='a';c<='z';c++){
      mp[c]=min(mp[c],S.at(i)[c]);
    }
  }
  
  for(char c='a';c<='z';c++){
    REP(i,mp[c]){
      ans+=c;
    }
  }

  cout<<ans;
}

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

int main() {
  long long N;
  cin >> N;
  long long A = N / 15;
  long long B = N / 3;
  long long C = N / 5;
  long long sum1 = 0;
  long long sum2 = 0;
  long long sum3 = 0;
  long long sum4 = 0;
  for (long long i = 0; i < N; i++) {
    sum1 = sum1 + i + 1;
  }
  for (long long i = 0; i < A; i++) {
    sum2 = sum2 + 15 * i + 15;
  }
  for (long long i = 0; i < B; i++) {
    sum3 = sum3 + 3 *i + 3;
  }
  for (long long i = 0; i < C; i++) {
    sum4 = sum4 + 5 * i + 5;
  }
  cout << sum1 + sum2 - sum3 - sum4 << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.rbegin(), h.rend());
  ll sum = 0;
  if(k >= n) {
    cout << 0 << endl;
    return 0;
  }
  else {
    h.erase(h.begin(), h.begin() + k);
    rep(i, n-k) {
      sum += h[i];
    }
  }
  cout << sum << endl;
  return 0;
}
    

Measured memory_bytes: 3940
#include<iostream>

using namespace std;
int main()
{
    int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
    return 0;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N, K;
    read(N, K);

    long double sum = 0;

    const auto need = [&](int i) {
        int cnt = 0;
        while (i < K) { i *= 2; ++cnt; }
        return cnt;
    };

    reps(i, 1, N) {
        const int k = need(i);
        sum += (1.0 / (1LL << k));
    }

    cout << fixed << setprecision(12);
    print(sum / N);

    return 0;
}


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

int main()
{
     int n,sum=0,k=0;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     {
      cin>>a[i];
     }
       for(int i=0;i<n-1;i++){
         for(int j=1+i;j<n;j++)
          {
            sum+=a[i]*a[j];

          }

          } cout<<sum<<endl;


return 0;}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a=nxtl();
    string b;
    cin>>b;
    ll pow=1;
    ll y=0;
    for(int i=b.length()-1;i>=0;i--){
        if(b[i]!='.')
        {
            y+=(b[i]-48)*pow;
            pow*=10;
        }
    }
    ll test= a*y;
    test/=100;
    cout<<test<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 3644
N = int(input())
a = [int(x) for x in input().split()]
stim = [0]

even_cnt = 0
odd_cnt = 0
even_opr = 0
odd_opr = 0
for i in a:
    stim.append(stim[-1]+i)
stim = stim[1:]
for ind,x in enumerate(stim):
    if(ind%2==0):
        if(x+odd_opr>0):
            odd_cnt += abs(-1-(x+odd_opr))
            odd_opr += -1-(x+odd_opr)
        elif(x+odd_opr==0):
            odd_opr -= 1
            odd_cnt += 1
        if(x+even_opr<0):
            even_cnt += abs(1-(x+even_opr))
            even_opr += 1-(x+even_opr)
        elif(x+even_opr==0):
            even_opr += 1
            even_cnt += 1
    else:
        if(x+odd_opr<0):
            odd_cnt += abs(1-(x+odd_opr))
            odd_opr += 1-(x+odd_opr)
        elif(x+odd_opr==0):
            odd_opr += 1
            odd_cnt += 1
        if(x+even_opr>0):
            even_cnt += abs(-1-(x+even_opr))
            even_opr += -1-(x+even_opr)
        elif(x+even_opr==0):
            even_opr -= 1
            even_cnt += 1
print(min(even_cnt,odd_cnt))
        

Measured memory_bytes: 14332
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

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

    sort(a.begin(), a.end());

    int ans = INF;
    for(int i = -100; i <= 100; i++) {
        int sum = 0;
        for(int j = 0; j < n; j++) {
            sum += pow(a[j] - i, 2);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i=(n);i>=0;i--)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

void a(){
    string s; cin >> s;
    if(s.find("A")==string::npos){
        cout << "No";
    }else if(s.find("B")==string::npos){
        cout << "No";
    }else{
        cout << "Yes";
    }
}


void b(){

}

int main(){
    a();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    string ans;
    int l=0, r=0;
    for(int i=N-1; i>=0; i--) {
        if(S[i] == ')') {
            r++;
        } else if(r - l <= 0) {
            l++;
            S += ')';
            r++;
        } else {
            l++;
        }
    }

    string start(r - l, '(');
    cout << start << S << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    constexpr ll MOD = 1e9 + 7;

    int n;
    string s;
    cin >> n >> s;

    vector<int> cur(n + 1, 1), nxt(n + 1);
    cur[0] = 0;

    for (int i = 2; i <= n; ++i) {
        fill(nxt.begin(), nxt.begin() + n - i + 2, 0);

        if (s[i - 2] == '<') {
            for (int j = 1, sum = 0; j <= n - i + 1; ++j) {
                (sum += cur[j]) %= MOD;
                (nxt[j] += sum) %= MOD;
            }
        }
        else {
            for (int j = n - i + 1, sum = 0; 1 <= j; --j) {
                (sum += cur[j + 1]) %= MOD;
                (nxt[j] += sum) %= MOD;
            }
        }

        swap(cur, nxt);
    }

    cout << cur[1] << endl;

    return 0;
}


Measured memory_bytes: 256
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(l[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
  ll m,n;
  cin >> n>>m;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]%=m;
  }
  vector<ll> cumusum(n);
  cumusum[0]=a[0];
  rep(i,n-1){
    cumusum[i+1]=a[i+1]+cumusum[i];
    cumusum[i+1]%=m;
  }
  ll result=0;
  rep(i,n){
    if(cumusum[i]==0){
      result++;
    }
  }
  map<ll,ll> nums;
  rep(i,n){
    if(nums.find(cumusum[i])==nums.end()){
      nums.insert({cumusum[i],1});
    }else{
      nums[cumusum[i]]++;
    }
  }
  for(auto itr = nums.begin(); itr != nums.end(); ++itr){
    result+=((itr->second)*(itr->second-1))/2;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 5760
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", 48 - n);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int N, T, c, t;
  cin >> N >> T;
  
  int min_c = 1001;
  for(int i=0; i<N; i++) {
    cin >> c >> t;
    if(t>T) {
      continue;
    } else {
      if(c<min_c) {
        min_c = c;
      }
    } 
  }
  
  if(min_c==1001) {
    cout << "TLE" << endl;
  } else {
    cout << min_c << endl;
  }
  
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a;
    string b;
    cin >> a >> b;
    ll b1 = (b.at(0) - '0')*100 +  (b.at(2) - '0')*10 +  (b.at(3) - '0');
     ll c = a*b1;
    cout << c/100 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[200005][5];
int n,k;
int dp[100005][5];
int func(int i,int j)
{

    if(i==n+1)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int ret = INT_MIN;

    for(int k=1;k<=3;k++)
    {
        if(k==j)
            continue;
       ret = max(ret,ar[i][k]+func(i+1,k));
    }
    return dp[i][j] = ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // mem(dp,-1);
    cin >> n ;
    for(int i=1; i<=n; i++)
        cin >> ar[i][1] >> ar[i][2] >> ar[i][3];


     //int ans = func(1,0);
     int j=0;
    for(int i=1; i<=n; i++)
    {
        dp[i][1] = max(dp[i][1],dp[i-1][2]+ar[i][1]);
        dp[i][1] = max(dp[i][1],dp[i-1][3]+ar[i][1]);
        dp[i][2] = max(dp[i][2],dp[i-1][1]+ar[i][2]);
        dp[i][2] = max(dp[i][2],dp[i-1][3]+ar[i][2]);
        dp[i][3] = max(dp[i][3],dp[i-1][1]+ar[i][3]);
        dp[i][3] = max(dp[i][3],dp[i-1][2]+ar[i][3]);
    }

    cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << endl;
    return 0;

}


Measured memory_bytes: 7484
#include <cstdio>
#include <algorithm>

long long int a, b, k;

int main(){
  scanf("%lld%lld%lld", &a, &b, &k);

  if(a >= k){
    printf("%lld %lld\n", a-k, b);
  }
  else {
    printf("%lld %lld\n", 0LL, std::max(a+b-k, 0LL));
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

typedef pair<double,string> p;

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		vector<p> vec(n);
		rep(i,n){
			double weight[2];
			string num;
			cin>>num>>weight[0]>>weight[1];
			vec[i].first=abs(22-weight[1]/pow(weight[0]*pow(10,-2),2));
			vec[i].second=num;
		}
		sort(vec.begin(),vec.end());
		cout<<vec[0].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include<stdio.h>
int main(void)
{
	int K,c,x;
	int sum=0;

	while(1){
		scanf("%d",&K);
		if( K==0 )
			break;
		else{
			c=K*(K-1)/2;

			while(c--){
				scanf("%d",&x);
				sum+=x;
			}
			printf("%d\n",sum/(K-1));
			sum=0;
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>

//by Skeef79

//НЕ ИСПОЛЬЗУЙ endl, есть свой en!!
//Иногда нужно не просто придумывать решение, а метматически расписать систему уравнений
//для задач с cin/cout в большом кол-ве - gnu , иначе вижуалки. А ваще пробуй два если TL

//для интерактивок - cout<<flush
// cin.tie и sync_with_stdio убирать для интерактивок

typedef long long ll;
typedef long double ld;

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

using namespace std;

const int INF = 1e9 + 1233;
const ll LINF = 1e18 + 1233;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
}

template <typename T> void Input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}


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

	int k, x;
	cin >> k >> x;

	for (int i = x - k + 1; i <= x + k - 1; i++)
		cout << i << ' ';

}





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

int graph0[111][111];
int graph1[111][111];

int main(){
    int n,m;
    while(cin >> m >> n && n){
        rep(i,n+1)rep(j,n+1) graph0[i][j] = graph1[i][j] = i==j ? 0 : 1e8;
        rep(i,m){
            int a,b, c,d;
            cin >> a >> b >> c >> d;
            graph0[a][b] = graph0[b][a] = c;
            graph1[a][b] = graph1[b][a] = d;
        }
        for(auto & g : {graph0, graph1}){
            rep(k,n+1)rep(i,n+1)rep(j,n+1) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
        int q;
        cin >> q;
        rep(qq,q){
            int a,b,c;
            cin >> a >> b >> c;
            if(c == 0){
                cout << graph0[a][b];
            } else {
                cout << graph1[a][b];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1252
#include<stdio.h>
int main(void){
int a,b,c,i;
int d=0;
    scanf("%d %d %d", &a, &b, &c);
    for(i=a;i<=b; i++){
    if (c%i==0){
    d++;}
}
printf("%d\n", d);
return 0;
}


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

typedef long long ll;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;

    for (int i = 0; i < (tx-sx); i++) {
        ans += 'R';
    }
    for (int i = 0; i < (ty-sy); i++) {
        ans += 'U';
    }
    for (int i = 0; i < (tx-sx); i++) {
        ans += 'L';
    }
    for (int i = 0; i < (ty-sy); i++) {
        ans += 'D';
    }

    ans += 'D';
    for (int i = 0; i < (tx-sx+1); i++) {
        ans += 'R';
    }
    for (int i = 0; i < (ty-sy+1); i++) {
        ans += 'U';
    }
    ans += 'L';
    ans += 'U';
    for (int i = 0; i < (tx-sx+1); i++) {
        ans += 'L';
    }
    for (int i = 0; i < (ty-sy+1); i++) {
        ans += 'D';
    }
    ans += 'R';

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

struct BIT {
    BIT(int n) : s(n + 1), n(n) {}
    int sum(int k) {
        int r = 0;
        for (; k > 0; k -= k & -k) r += s[k];
        return r;
    }
    void add(int i, int v) {
        for (int k = i + 1; k <= n; k += k & -k) s[k] += v;
    }
    vector<int> s;
    int n;
};

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

    int n, k;
    cin >> n >> k;

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

    vector<int> c(n + 1);
    for (int i = 0; i <= n; i++) {
        c[i] = i;
    }
    sort(c.begin(), c.end(), [&](int i0, int i1) {
        return b[i0] < b[i1];
    });

    vector<int> d(n + 1);
    int m = 0;
    for (int i = 0; i <= n; i++) {
        if (i > 0 && b[c[i]] != b[c[i - 1]]) m++;
        d[c[i]] = m;
    }

    BIT bit(m + 1);
    int64_t r = 0;
    for (int i = 0; i <= n; i++) {
        r += bit.sum(d[i] + 1);
        bit.add(d[i], 1);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4224
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t n, a, b;
  cin >> n >> a >> b;
  // const int64_t L = static_cast<int64_t>(T.length());

  Mint nCa = 1;
  int64_t temp = n;
  for (int64_t i = 1; i <= a; ++i) {
    nCa *= temp;
    nCa /= i;
    --temp;
  }

  Mint nCb = 1;
  temp = n;
  for (int64_t i = 1; i <= b; ++i) {
    nCb *= temp;
    nCb /= i;
    --temp;
  }

  Mint result = 2;
  result = result.Pow(n);
  result -= 1;
  result -= nCa;
  result -= nCb;

  cout << result.value << endl;
  return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
ll n,k,ans=0;
cin>>n>>k;
while(n)
{
	ans++;
	n/=k;
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100010
int num,n,m,root,h[N],sz[N],son[N];
ll ans=0;
struct node{int to,z,next;}mp[N<<1];
inline char gc(){
    static char *S,*T,buf[1<<16];
    if(T==S){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}
    return *S++;
}
inline int read(){
    int x=0,f=1;char ch=gc();
    while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=gc();}
    while('0'<=ch && ch<='9') x=x*10+ch-'0',ch=gc();
    return x*f;
}
inline void ins(int x,int y,int z){
	mp[++num].to=y;mp[num].z=z;mp[num].next=h[x];h[x]=num;
	mp[++num].to=x;mp[num].z=z;mp[num].next=h[y];h[y]=num;
}
void dfs1(int x,int fa){
	sz[x]=1;
	for(int i=h[x];i;i=mp[i].next){
		int y=mp[i].to;if(y==fa) continue;
		dfs1(y,x);
		sz[x]+=sz[y];
		son[x]=max(son[x],sz[y]); 
	}
	son[x]=max(son[x],n-sz[x]);
	if(son[x]<son[root]) root=x;
}
void dfs2(int x,int fa,ll dis){
	sz[x]=1;
	for(int i=h[x];i;i=mp[i].next){
		int y=mp[i].to;if(y==fa) continue;
		dfs2(y,x,dis+mp[i].z);
		sz[x]+=sz[y];
	}ans+=dis;
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int x=read(),y=read(),z=read();
		ins(x,y,z);
	}
	son[0]=0x3f3f3f3f;
	dfs1(1,0);
	dfs2(root,0,0);
	int tmp=0x3f3f3f3f;
	for(int i=h[root];i;i=mp[i].next){
		int to=mp[i].to;
		if(sz[to]==(n+1)/2){tmp=mp[i].z;break;}
		else tmp=min(tmp,mp[i].z);
	}
	printf("%lld\n",2ll*ans-1ll*tmp);
	return 0;
}

Measured memory_bytes: 7808
from bisect import bisect_left, bisect_right

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

cnt = 0
for b in B:
    cnt += bisect_left(A, b) * (N - bisect_right(C, b))
print(cnt)

Measured memory_bytes: 29384