akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, P = MI()
    s = list(map(int, S()[::-1]))
    ans = 0
    sum_of_d = 0
    cnts = [0] * P
    cnts[0] = 1
    A = [0] * N
    D = [0] * N

    if P == 2 or P == 5:
        for i in range(N):
            if s[i] % P == 0:
                ans += N - i
        print(ans)
        return

    for i in range(N):
        d = s[i] * pow(10, i, P)
        A[i] = d % P
        if i == 0:
            D[i] = A[i]
        else:
            D[i] = (D[i-1] + A[i]) % P
        cnts[D[i]] += 1
        # sum_of_d = (sum_of_d + d) % p
        # cnts[sum_of_d] += 1

    for i in cnts:
        ans += i * (i - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long int LLI;

int n, s;
LLI dp[12][1002][102];

int main() {
  dp[0][0][0] = 1;
  for (int i=0; i<9; i++) {
    for (int k=0; k<=100; k++) {
      for (int l=k; l<=100; l++) {
        for (int j=0; j<=1000-l; j++) {
          dp[i+1][j+l][l+1] += dp[i][j][k];
        }
      }
    }
  }

  while (1) {
    scanf("%d%d", &n, &s);
    if (n == 0 && s == 0) return 0;

    LLI ans = 0;
    for (int i=0; i<=101; i++) {
      ans += dp[n][s][i];
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 9868
import sys
input = sys.stdin.readline

N = int(input())
cs = 0
x = 0
for i in range(1, N + 1):
  x = i
  cs += x
  if cs >= N:
    break
for i in range(1, x + 1):
  if i == cs - N:
    continue
  print(i)

Measured memory_bytes: 42456
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

# 整数 N が 9 の倍数であることと、N を十進法で表したときの各桁の数の和が 
# 9 の倍数であることは同値です。
# N が 9 の倍数であるか判定してください。

n = I()
s = 0

n_list = list(str(n))

for i in n_list:
    s = s + int(i)

if s % 9 == 0:
    print("Yes")
else:
    print("No")

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

int main() {
	unordered_map<char, string> Map;
	Map['A'] = "T";
	Map['T'] = "A";
	Map['C'] = "G";
	Map['G'] = "C";
	char c;
	cin >> c;
	cout << Map[c] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    int sum=0;
    for(int i=0;i<N;i++){
        int t; cin >> t;
        A[i]=t-1;
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
        sum += B[i];
    }
    for(int i=0;i<N-1;i++) cin >> C[i];

    for(int i=0;i<N;i++){
        if(A[i]==A[i+1]-1){
            sum += C[A[i]];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
//Link : https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_c

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 300005
#define mod 1000000007

int add(int x,int y) {
  int ret = ((x+y)%mod+mod)%mod;
  if(ret<0) {
    ret+= mod;
  }
  assert(ret>=0 && ret<mod);
  return ret;
}
int mul(int x,int y) {
  ll ret = x;
  ret*=y;
  ret%=mod;
  assert(ret>=0 );
  return ret%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

int fac[N];

int combination(int n,int r) {
  return mul(fac[n], mul(mypow(fac[r],mod-2) , mypow(fac[n-r],mod-2)));
}

void solve() {
  fac[0] = 1;
  int n,a,b,c;scanf("%d %d %d %d ", &n,&a,&b,&c);

  a = mul(a, mypow(100-c,mod-2));
  b = mul(b, mypow(100-c,mod-2));
  for(int i=1;i<N;++i) {
    fac[i] = mul(fac[i-1],i);
  }

  int ret = 0,z = add(1,-c);
  z = mypow(z,mod-2);
  z = mul(100, mypow(add(100,-c),mod-2));
  for(int i=n;i<=2*n-1;++i)   {
    int tmp = mul(i,z);
    int combi = combination(i-1,n-1);
    int ad = add(mul(mypow(a,n),mypow(b,i-n)),mul(mypow(a,i-n),mypow(b,n)));
    ad = mul(ad, mul(tmp,combi));
    ret = add(ret,ad);
  }
  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 1408
N, M = map(int, input().split())
A = list(map(int, input().split()))

sum = 0
for score in A:
    sum += score

number = 0
for i in range(N):
    if A[i] >= sum / (4 * M):
        number += 1
    else:
        number += 0

print('Yes' if number >= M else 'No' )

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

int main() {
  int a,b;
  cin >> a >>b;
  vector<string> vec(a);
  for(int i=0; i<b+2;i++)
    cout << "#";
  cout<< endl;
  for (int i=0;i<a;i++){
    cin>> vec.at(i);
    cout <<"#"<<vec.at(i)<<"#"<<endl;
  }
  for(int i=0; i<b+2;i++)
    cout << "#";
  cout<< endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>
# include <cmath>
# include <iomanip>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

struct Circle{
    double x, y, r;
    Circle(){}
    Circle(double _x, double _y, double _r){
        x = _x,
        y = _y,
        r = _r;
    }
};

Circle barriers[1005];
double distance(Circle u, Circle v){
    double dis = hypot(u.x - v.x, u.y - v.y);
    dis = max(0.0, dis - u.r - v.r); //check whether the circle is intersects or not
    return dis;
}

vector<pair<int, double> > graf[1005];

double dp[1005];
double dijkstra(int from, int to){
    dp[from] = 0.0;
    priority_queue<pair<double,int>, vector<pair<double,int> >, greater<pair<double,int> > > q;
    q.push(make_pair(0, from));

    while(!q.empty()){
        pair<double,int> state = q.top(); q.pop();
        int u = state.second;
        REP(i, graf[u].size()){
            int v = graf[u][i].first;
            double w = graf[u][i].second;

            if(dp[u] + w < dp[v]){
                dp[v] = dp[u] + w;
                q.push(make_pair(dp[v], v));
            }
        }
    }

    return dp[to];
}

int main(){

    ios :: sync_with_stdio(false);
    
    double x,y;
    Circle start, goal;
    
    cin >> x >> y;
    start = Circle(x,y,0);

    cin >> x >> y;
    goal = Circle(x,y,0);

    int N;
    cin >> N;
    FOR(i,N){
        double x,y,r;
        cin >> x >> y >> r;
        barriers[i] = Circle(x,y,r);
    }
    barriers[0] = start;
    barriers[N+1] = goal;
    N++;

    REP(i,N+1){
        dp[i] = 1e18;
        REP(j,N+1){
            if(i == j) continue;
            double weight = distance(barriers[i], barriers[j]);
            graf[i].push_back(make_pair(j, weight));
            graf[j].push_back(make_pair(i, weight));
        }
    }

    double ans = dijkstra(0, N);
    cout << fixed << setprecision(9) << ans << endl;

    return 0;
}

Measured memory_bytes: 38836
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main(){
    int a, b; cin >> a >> b;
    set<int> s;
    s.insert(a);
    s.insert(b);
    if(s.count(1) == 0) cout << 1 << endl;
    else if(s.count(2) == 0) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF INT_MAX
#define PI 3.141592653
#define inf 2000007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int n,m;

vector<int> adj[200500];
vector<int> d(inf),p(inf);
vector<bool> used(inf);
void bfs(int s){
    queue<int> q;
    q.push(s);
    used[s]=true;
    p[s]=-1;
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int u:adj[v]){
            if(!used[u]){
                used[u]=true;
                q.push(u);
                d[u]=d[v]+1;
                p[u]=v;
            }
        }
    }
}
int main(){
    cin>>n>>m;
    pans(i,m+1,1){
        // cout<<"run"<<endl;
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    bfs(1);
    bool flag=true;
    pans(i,n+1,2){
        flag&=(d[i]>0);
    }
    if(flag){
        cout<<"Yes"<<endl;
        pans(i,n+1,2){
            cout<<p[i]<<endl;
        }
    }
    
}

Measured memory_bytes: 28132
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string s, t;
cin >> s >> t;
int n = s.size();
int m = t.size();
 
string ans = "~";
for(int i=0; i<=n-m; ++i){
    bool ok = true;
    string s2 = s;
    for(int j=0; j<m; ++j){
        if(s[i+j] != '?' && s[i+j] != t[j])
            ok = false;
        s2[i+j] = t[j];
    }
    if(ok){
        replace(s2.begin(), s2.end(), '?', 'a');
        ans = min(ans, s2);
    }
}
 
if(ans == "~") cout << "UNRESTORABLE" << endl;
else cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
N = int(input())
h = [int(n) for n in input().split(' ')]
start = 0
out = 0

def end(start, h):
    m = h[start]
    for i in range(start, N):
        if h[i] != 0:
            if h[i] < m:
                m = h[i]
        else:
            return i-1, m
    else:
        return i, m

while start < len(h):
    i, m = end(start, h)
    if i != start-1:
        for j in range(start, i+1):
            h[j] -= m
        out += m
    else:
        start += 1
else:
    print(out)

Measured memory_bytes: 3064
from math import gcd

N, M = map(int, input().split())
S = input()
T = input()

def lcm(m, n):
    return (m * n) // gcd(m, n)

lc = lcm(N, M)

ss = lc//N
tt = lc//M

for i in range(1, lc+1, ss*tt):
    s_tmp = (i - 1) // ss
    t_tmp = (i - 1) // tt

    if S[s_tmp] != T[t_tmp]:
        print(-1)
        exit()

print(lc)

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    long long int n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0;
        return 0;
    }
    long long int a=1000000007;
    long long int b=1,c=1;
    for(int i=1;i<n+1;i++){
        b*=i;
        b=b%a;
    }
    for(int i=1;i<m+1;i++){
        c*=i;
        c=c%a;
    }
    long long int d,e;
    if(n==m){
    d=2*b*c;
    }else{
    d=b*c;
    }
    cout<<d%a;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//****************************************************************************************************************************************//

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

//*****************************************************************************************************************************************//

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

//*****************************************************************************************************************************************//

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

//******************************************************************************************************************************************//


void solve(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


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


double f(double x){
  double sum = (x*(x+1))/2;
  return sum/x;
};

int main(){
 int n,k;cin>>n>>k;
 vector<double> p(n);
 for (auto && a : p) {
   cin>>a;
 }
 vector<double> kitaichi(n);
 for (int i = 0; i < n; i++) {
   kitaichi.at(i) = f(p.at(i));
 }
 double tmp = 0;
 for (int i = 0; i < k; i++) {
   tmp += kitaichi.at(i);
 }
 double ans = -1;
 for (int i = k; i < n; i++) {
   tmp -= kitaichi.at(i-k);
   tmp += kitaichi.at(i);
  ans = max(tmp,ans);
 }
ans = max(tmp,ans);
 cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            var line = Input.ReadIntArray();
            long r = line[0];
            long d = line[1];
            long x = line[2];
            for (int i = 0; i < 10; i++)
            {
                x *= r;
                x -= d;
                Console.WriteLine(x);
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int  is_prine(int m)
{
    if(m <= 1)
        return 0;
    for(int i = 2;i<m;i++){
        if(m % i == 0)
            return 0;
    }

    return m;
}

void so(int m,int b[],int a[])
{
    int i = 0;
    while(m != 1){
        if(b[i] == 0 ) break;

        if(m % b[i] == 0){
            
            m /= b[i];
            
            a[b[i]]++;
        }else  i++;
    }
}

int main (void)
{
    int n;
    int a[10000] = {0};
    int b[10000] = {0};
    int i;
    int j = 0; 
    long long  ans = 1;

    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(is_prine(i) != 0){
            b[j] = is_prine(i);
            j++;
        }
    }

    for(i=1;i <= n;i++){
        so(i,b,a);
    }

    for(i=0;i<=n;i++){
        ans *= a[i] + 1;
        if(ans > (1000000000 + 7))
            ans %= (1000000000 + 7);
    }

  //  for(i=0;i<=n;i++){
        //printf("a[%d] = %d , b[%d] = %d\n",i,a[i],i,b[i]); 
    //}

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

    return 0;
}

Measured memory_bytes: 256
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int m = 0;
    srep(i,1,n+1){
        if(i%2==1)m++;
    }

    double ans = (double)m/ n;

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
//const ll mod = 1e9+7;
int gcd(int a, int b){if(a<b) swap(a,b); if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R;

int main(){
  cin >> N;
  vi A(N+2,0);
  vi B(N+2,0);
  ll ssum = 0;
  rep2(i,1,N+1){
    cin >> A[i]; 
    B[i] = abs(A[i]-A[i-1]);
    ssum += B[i];
  }  
  B[N+1]=abs(A[N]);
  ssum += B[N+1];
  
  rep2(i,1,N+1){
    cout << ssum-B[i]-B[i+1]+abs(A[i+1]-A[i-1]) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 4020
#include <cstdio>

using namespace std;

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

    scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

    int xDiff = tx - sx;
    int yDiff = ty - sy;

    int i;

    for (i = 0; i < yDiff; i++) printf("U");
    for (i = 0; i < xDiff; i++) printf("R");
    for (i = 0; i < yDiff; i++) printf("D");
    for (i = 0; i < xDiff; i++) printf("L");
    printf("L");
    for (i = 0; i < yDiff + 1; i++) printf("U");
    for (i = 0; i < xDiff + 1; i++) printf("R");
    printf("D");
    printf("R");
    for (i = 0; i < yDiff + 1; i++) printf("D");
    for (i = 0; i < xDiff + 1; i++) printf("L");
    printf("U\n");

    return 0;
}


Measured memory_bytes: 128
D = "mcxi"
V = [1000, 100, 10, 1]
def conv1(s):
    v = 0; t = 1
    for c in s:
        idx = D.find(c)
        if idx > -1:
            v += t * V[idx]
            t = 1
        else:
            t = int(c)
    return v
def conv2(v):
    s = []
    for i in range(4):
        if v >= V[i]:
            k = v // V[i]
            if k > 1:
                s.append(str(k))
            s.append(D[i])
            v -= k * V[i]
    return "".join(s)

N = int(input())
ans = []
for i in range(N):
    p, q = input().split()
    ans.append(conv2(conv1(p) + conv1(q)))
print(*ans, sep='\n')



Measured memory_bytes: 5856
function Main(input){
	inputs = input.split(' ');
    x = Math.floor(inputs[1] / inputs[0]);
    if(x >= inputs[2]){
    console.log(inputs[2]);
    }else if(x <= inputs[2]){
    console.log(x);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n, ans = 0;
    cin >> n;
    vector<string> s(n);
    ll front_b = 0, back_a = 0, ab = 0;
    
    rep(i, n){
        cin >> s[i];
        ll num = s[i].size();
        if (s[i][0] == 'B' && s[i][num - 1] == 'A')
            ab++;
        else if (s[i][0] == 'B')
            front_b++;
        else if (s[i][num - 1] == 'A')
            back_a++;
    }

    ans += max(0ll, ab - 1);
    if (ab >= 1)
        ab = 1;

    if(!(front_b==0 && back_a==0)){
        if (front_b >= back_a){
            ans += (back_a + ab);
        }else{
            ans += (front_b + ab);
        }
    }

    rep(i, n){
        rep(j, s[i].size() - 1){
            if (s[i][j] == 'A' && s[i][j + 1] == 'B')
                ans++;
        }
    }

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

Measured memory_bytes: 3676
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    char[] a=sc.next().toCharArray();
    char[] b=sc.next().toCharArray();
    char[] c=sc.next().toCharArray();
    a[0]=String.valueOf(a[0]).toUpperCase().charAt(0);
    b[0]=String.valueOf(b[0]).toUpperCase().charAt(0);
    c[0]=String.valueOf(c[0]).toUpperCase().charAt(0);
    char[] d={a[0],b[0],c[0]};
    String s=String.valueOf(d);
    System.out.println(s);
  }
}

Measured memory_bytes: 20948
A, B, M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

amin = min(a)
bmin = min(b)

ans = amin + bmin

for i in range(M):
  x, y, c = map(int, input().split())
  ans = min( ans , a[x-1] + b[y-1] - c )

print(ans)

Measured memory_bytes: 18736
N = int(input())
A = list(map(int,input().split()))
l, r = 0, 0
a = 0
cnt = 0
while l < N:
    if r < N and a & A[r] == 0:
        assert a+A[r] == a^A[r]
        a += A[r]
        r += 1
    else:
        cnt += r-l
        assert a-A[l] == a^A[l]
        a -= A[l]
        l += 1
print(cnt)

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

class Program
{
    static void Main(string[] args)
    {
        List<int> NK = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();
        int N = NK[0], K = NK[1];
        List<char> S = Console.ReadLine().ToList();

        K--;
        foreach (var x in S.Select((o, p) => new { Index = p, Value = o }))
        {
            if (x.Index == K)
                Console.Write(char.ToLower(x.Value));
            else
                Console.Write(x.Value);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll ans=0,maxx=0,val;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>val;
    maxx=max(maxx,val);
    ans+=abs(maxx-val);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(void)
{
    int n,a[20],b[20],c[20],i,m,s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(i=0;i<n-1;i++)
        scanf("%d",&c[i]);
    m=n;
    for(i=0;i<n;i++){
        s+=b[a[i]-1];
        if(a[i]-1==m+1)
            s+=c[a[i]-2];
        m=a[i]-1;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N = 1005;
int n,m,id[N][N],cnt;
int main(){
	n=gi();
	while (m*(m-1)/2<n) ++m;
	if (m*(m-1)/2!=n) return puts("No"),0;
	for (int i=1;i<=m;++i)
		for (int j=i+1;j<=m;++j)
			id[i][j]=id[j][i]=++cnt;
	printf("Yes\n%d\n",m);
	for (int i=1;i<=m;++i){
		printf("%d ",m-1);
		for (int j=1;j<=m;++j)
			if (i!=j) printf("%d ",id[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, k; cin >> n >> k;
	vl h(n);
	REP(i, n) cin >> h[i];

	vl dp(n, TEN(10));
	dp[0] = 0;

	REP(i, n) {
		REP(j, k + 1) if (i + j < n) MINC(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin >> n;
  vector<int> vec1={2,4,5,7,9};
  vector<int> vec2={0,1,6,8};
  if(find(vec1.begin(),vec1.end(),n%10) != vec1.end())
  {
    cout << "hon" << endl;
  }
  else if(find(vec2.begin(),vec2.end(),n%10) != vec2.end())
    cout << "pon" << endl;
  else
    cout << "bon"<< endl;
  
}

Measured memory_bytes: 3608
import sys
for s in sys.stdin:
  y,m,d=map(int,s[:-1].split())
  x=y*10000+m*100+d
  def f(i,w):
    print ["meiji","taisho","showa","heisei"][i],y-w,m,d
  if x<18680908:print"pre-meiji"
  elif x<19120730:f(0,1867)
  elif x<19261225:f(1,1911)
  elif x<19890108:f(2,1925)
  else:f(3,1988)

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define ROF(i,n,e) for(int i=n;i>e;i--)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define TEST(t) while(t--)
#define mod 1e9+7
#define MAX 1000005    //10^5+5
#define MAXQ 200005    //2*10^5+5
#define pi pair<int,int>
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
#define f first
#define s second
typedef pair<int,int> pii;
typedef pair<int,pii> node;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string a,b;
    int n;
    cin>>n;
    cin>>a>>b;
    string ans(2*n,' ');
    for(int i=0,j=0,k=0;i<2*n;i++){
    	if(i%2==0){
    		ans[i]=a[j++];
    	}else{
    		ans[i]=b[k++];
    	}
    }
    cout<<ans<<"\n";
    return 0;    
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
int main(){int n,m,i,j,a=0,b=0;std::string s[101],t[101];
           std::cin>>n;for(i=0;i<n;++i)std::cin>>s[i];std::cin>>m;for(i=0;i<m;++i)std::cin>>t[i];
           for(i=0;i<n;++i){
             for(j=0,b=0;j<n;++j)if(s[i]==s[j])++b;
             for(j=0;j<m;++j)if(s[i]==t[j])--b;
             a=(a<b?b:a);
           }
           std::cout<<a<<"\n";
          }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n, x, y;
int main(){
	scanf("%d", &x);
	int n = x;
	while(n){
		y += n % 10;
		n /= 10;
	}
	if(x % y == 0) puts("Yes");
	else puts("No");
	return 0;
} 

Measured memory_bytes: 256
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

const int N = 22;
const int N2 = 1<<22;
const int mod = 1e9 + 7;
int n;
int dp[N][N2];
int a[N][N];



int solve(int id, int bit)
{
    if(id == -1) return 1;
    if(dp[id][bit] != -1) return dp[id][bit];
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[id][i] == 1 && !(bit & (1 << i))){
            ans += solve(id-1, bit|(1<<i) );
            ans %= mod;
        }
    }
    return dp[id][bit] = ans;

}

int32_t SALI()
{

    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];

    cout << solve(n-1,0);
}




/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 724516
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int f2[26];
int f[51][26];
char s[51];

int main(){
	DRI(n);
	REP(i,26)f2[i]=1<<30;
	REP(i,n){
		RS(s);
		int l=LEN(s);
		REP(j,l){
			f[i][s[j]-'a']++;
		}
		REP(j,26){
			f2[j]=min(f2[j],f[i][j]);
		}
	}
	REP(i,26){
		REP(j,f2[i])printf("%c",'a'+i);
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;


//const int mod=1000000007;
const int mod=998244353;
//



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d;
    cin >> a >> b >> c >> d;
    bool cond=true;
    while(a>0&&c>0){
        if(cond){
            c-=b;
            cond=false;
        }
        else{
            a-=d;
            cond=true;
        }
    }
    cout << (a>c?"Yes":"No") << el;
    return 0;
    
}



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

long long exponent(long long b,long long p){
	if(p == 0){
		return 1;
	}
	else if(p == 1){
		return b;
	}else{
		return b * exponent(b,p - 1);
	}
}

long long n,k,base;

int main(){
	cin>>n>>k;
	for(long long i = 1;i <= 1000000000;i++){
		if(n >= exponent(k,i)){
			base++;
			continue;
		}else{
			break;
		}
	}
	cout<<base + 1<<endl;
}


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

int main() {
  string S;
  cin >> S;
  int a, b, c, Y, Z;
  int ans = 1000;
  for (int i = 0; i < S.size() - 2; i++) {
    a = S.at(i) - '0';
    b = S.at(i+1) - '0';
    c = S.at(i+2) - '0';
    Y = 100*a + 10*b + c;
    if (753 < Y)
      Z = Y - 753;
    else
      Z = 753 - Y;
    ans = min(ans, Z);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>

int main() {

	int n, room_num[4][3][10], i, s, b, f, r, v;

	scanf("%d", &n);

	for (i = 0; i <  3; i++) {

		for (s = 0; s < 10; s++) {
			room_num[0][i][s] = 0;
			room_num[1][i][s] = 0;
			room_num[2][i][s] = 0;
			room_num[3][i][s] = 0;

		}

	}
	for (i = 1; i <= n; i++) {

		scanf("%d %d %d %d", &b, &f, &r, &v);
		
		room_num[b - 1][f - 1][r - 1] = room_num[b - 1][f - 1][r - 1] + v;
		


	}

	for (i = 0; i < 3; i++) {

		for (s = 0; s < 10; s++) {

			printf(" %d",room_num[0][i][s]);
		}
		printf("\n");
	}

	printf("####################\n");

	for (i = 0; i < 3; i++) {

		for (s = 0; s < 10; s++) {

			printf(" %d", room_num[1][i][s]);
		}
		printf("\n");
	}

	printf("####################\n");

	for (i = 0; i < 3; i++) {

		for (s = 0; s < 10; s++) {

			printf(" %d", room_num[2][i][s]);
		}
		printf("\n");
	}

	printf("####################\n");

	for (i = 0; i < 3; i++) {

		for (s = 0; s < 10; s++) {

			printf(" %d", room_num[3][i][s]);
		}
		printf("\n");
	}

	
	return 0;
}

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

using namespace std;

char Rosu[505][505],Albastru[505][505],Mov[505][505];

int main()
{
    int H,W;
	cin >> H >> W;
	for (int i = 0;i < H;i++)
    {
		for (int j = 0;j < W;j++)
		{
			if ((j == 0 || i % 2 == 0) && j != W - 1)
                Rosu[i][j] = '#';
			else
                Rosu[i][j] = '.';
			if ((j == W - 1 || i % 2 == 1) && j != 0)
                Albastru[i][j] = '#';
			else
                Albastru[i][j] = '.';
			cin >> Mov[i][j];
			if(Mov[i][j] == '#')
			{
				Rosu[i][j] = '#';
				Albastru[i][j] = '#';
			}
		}
	}
	for(int i = 0;i < H;i++)
	{
		for(int j = 0;j < W;j++)
            cout << Rosu[i][j];
        cout << '\n';
	}
	cout << '\n';
	for(int i = 0;i < H;i++)
	{
		for(int j = 0;j < W;j++)
            cout << Albastru[i][j];
        cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int p[55]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> p[i];
	
	bool ans=false;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			int tmp[55]={};
			for(int k=0;k<N;k++)
				tmp[k]=p[k];
			tmp[i]=p[j];
			tmp[j]=p[i];

			bool sorted=true;
			for(int k=0;k<N-1;k++)
			{
				if(tmp[k]>tmp[k+1])
				{
					sorted=false;
					break;
				}
			}

			if(sorted)
			{
				ans=true;
				break;
			}
		}
	}

	if(ans)
		cout << "YES";
	else 
		cout << "NO";
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(size_t i=0;i<(size_t)(n);i++)
#define rrep(i,n) for(size_t i=(size_t)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n; cin >> n;
  for(int i=1;i<=n;i++){
    if(i*(i+1)/2 >= n){
      int k = i*(i+1)/2-n;
      for(int j=1;j<=i;j++){
        if(j!=k) cout << j << endl;
      }
      return 0;
    }
  }
}


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

using namespace std;

typedef long long ll;

const int N = (1 << 16) + 5;
int arr[16][16];
int n;
ll val[N];
vector<int> m[N];

void get_masks(int idx, int mask, int pos)
{
  if(idx == n)
  {
    if(mask)
      m[pos].push_back(mask);
    return;
  }
  get_masks(idx + 1, mask, pos);
  if(mask & (1 << idx))
    get_masks(idx + 1, mask ^ (1 << idx), pos);
}

ll dp[N];

ll solve(int mask)
{
  if(mask == (1 << n) - 1)
    return 0;
  ll &ans = dp[mask];
  if(~ans)
    return ans;
  ans = 0;
  for(auto &x: m[mask])
  {
    ans = max(ans, solve(mask | x) + val[x]);
  }
  return ans;
}
int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> arr[i][j];
  for(int i = 0; i < (1 << n); i++)
  {
    for(int j = 0; j < n; j++)
    {
      for(int k = j + 1; k < n; k++)
      {
        if((i & (1 << j)) && (i & (1 << k)))
          val[i] += arr[j][k];
      }
    }
  }
  for(int i = 0; i < (1 << n); i++)
  {
    int newMask = i;
    for(int j = 0; j < n; j++)
      newMask ^= (1 << j);
    get_masks(0, newMask, i);
  }
  memset(dp, -1, sizeof dp);
  cout << solve(0);
  return 0;
}


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

typedef long long ll;
const int MN = 2e5+5;
ll nxt[MN][2], n, i, arr[MN], ord[MN], ans;

int main(){
    for(scanf("%lld",&n),i=1;i<=n;i++){
        scanf("%lld",&arr[i]);
        ord[i] = i;
        nxt[i][0]=i+1;
        nxt[i][1]=i-1;
    }
    sort(ord+1,ord+n+1,[](ll i,ll j){return arr[i]>arr[j];});
    for(i=1;i<=n;i++){
        ll x = ord[i];
        ll l=nxt[x][1], r=nxt[x][0];
        nxt[l][0]=r; nxt[r][1]=l;
        ans += arr[x]*(r-x)*(x-l);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;

namespace ITP1_8_B
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string> vs = new List<string>();

			// 入力
			while(true) {
				string buf = Console.ReadLine();
				if(buf == "0") {
					break;
				}

				vs.Add(buf);
			}

			// 計算
			List<int> sums = new List<int>();

			foreach(string v in vs) {
				char[] cs = v.ToCharArray();
				int sum = 0;
				for(int i = 0; i < cs.Length; i++) {
					sum += int.Parse(cs[i].ToString());
				}

				sums.Add(sum);
			}

			// 出力
			foreach(int sum in sums) {
				Console.WriteLine(sum);
			}
		}
	}
}



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

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

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e-a <= k) puts("Yay!");
    else puts(":(");
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

void dolphin(int sx, int sy, int tx, int ty)
{
    int dx, dy;
    dx = tx - sx;
    dy = ty - sy;
    for(int i=0; i<dx; ++i){
        cout << "R";
    }
    for (int i=0; i<dy; ++i){
        cout << "U";
    }
    for (int i=0; i<dx; ++i){
        cout << "L";
    }
    for (int i=0; i<dy+1; ++i){
        cout << "D";
    }
    for (int i=0; i<dx+1; ++i){
        cout << "R";
    }
    for (int i=0; i<dy+1; ++i){
        cout << "U";
    }
    cout << "LU";
    for (int i=0; i<dx+1; ++i){
        cout << "L";
    }
    for (int i=0; i<dy+1; ++i){
        cout << "D";
    }
    cout << "R";
}

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

Measured memory_bytes: 256
a=set([1,3,5,7,8,10,12])
b=set([4,6,9,11])
c=set([2])
x,y=map(int,input().split())
if (x in a and y in a)or(x in b and y in b)or(x in c and y in c):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

i64 largest_rectangle(vi& hist) {
    hist.push_back(0);
    using ii = pair<i64, int>;
    stack<ii> st;
    i64 ret = 0;
    for (int i = 0; i < hist.size(); i++) {
        if (st.empty() || st.top().first < hist[i]) {
            st.push(ii(hist[i], i));
        } else {
            int s;
            while (st.size() && st.top().first >= hist[i]) {
                ret = max(ret, st.top().first * (i - st.top().second));
                s = st.top().second;
                st.pop();
            }
            st.push(ii(hist[i], s));
        }
    }
    
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int h, w;
    cin >> h >> w;
    vvi b(h, vi(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int c;
            cin >> c;
            if (c == 0) {
                if (i == 0) {
                    b[i][j] = 1;
                } else {
                    b[i][j] = b[i - 1][j] + 1;
                }
            } else {
                b[i][j] = 0;
            }
        }
    }

    i64 ret = 0;
    for (int i = 0; i < h; i++) {
        ret = max(ret, largest_rectangle(b[i]));
    }
    cout << ret << endl;
}


Measured memory_bytes: 28744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String Word=new String();
		Word=sc.next();
		sc.close();
		Character word[]=new Character[3];
		for(int i=0;i<3;i++)
			word[i]=Word.charAt(i);
		int count=0;
		int max=0;
		for(int i=0;i<3;i++) {
			if(word[i].equals('R')) {
				count++;
				if(count>max)
					max=count;
			}else {
				count=0;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    cin >> N;
    REPS(i, N) {
        if (i % 15 == 0) {
            continue;
        } else if (i % 3 == 0) {
            continue;
        } else if (i % 5 == 0) {
            continue;
        } else {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

int a[ 100010 ], b[ 100010 ];

int main() {
	int n, m, q;
	int mi;
	int x = 1000000, y = 1000000, z;
	scanf( "%d%d%d", &n, &m, &q );
	for( int i = 1; i <= n; ++i ) {
		scanf( "%d", &a[ i ] );
		x = min( x, a[ i ] );
	}
	for( int i = 1; i <= m; ++i ) {
		scanf( "%d", &b[ i ] );
		y = min( y, b[ i ] );
	}
	mi = x + y;
	for( int i = 0; i < q; ++i ) {
		scanf( "%d%d%d", &x, &y, &z );
		mi = min( a[ x ] + b[ y ] - z, mi );
	}
	printf( "%d", mi );
	return 0;
}

Measured memory_bytes: 1024