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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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 N,K;
int score[3];
int T[100005];

int dp[100005];
int ans;

signed main(){
    cin>>N>>K;
    cin>>score[0]>>score[1]>>score[2];
    for(int i=0;i<N;++i){
        char c;
        cin>>c;
        if(c=='r')T[i]=0;
        if(c=='s')T[i]=1;
        if(c=='p')T[i]=2;
    }
    for(int i=0;i<K;++i){
        int pret=-1;
        for(int j=i;j<N;j+=K){
            int t=(T[j]+2)%3;
            if(pret!=t){
                dp[i]+=score[t];
                pret=t;
            }
            else {
                if(j+K>=N)continue;
                int nt=(T[j+K]+2)%3;
                pret=(nt+2)%3;
            }
        }
    }
    for(int i=0;i<K;++i)ans+=dp[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<ll> res;
int v[3] = {3, 5, 7};
ll n;

void dfs(ll value, ll mask=0){
    REP(i, 3){
        ll nv = value*10+v[i];
        ll nm = mask | (1<<i);
        if((nm==7) && nv<=n) res.push_back(nv);
        if(nv<=n) dfs(nv, nm);
    }
}



int main(){
    cin >> n;
    dfs(0);
    cout << res.size() << endl;
}

Measured memory_bytes: 3656
n = int(input())
line = input()
arr= line.split(" ")
nums = []
for c in range(n):
    nums.append(int(arr[c]))

convert_n = 0
for i in range(len(nums)):
    minj = i
    for j in range(i, len(nums)):
        if nums[j] < nums[minj]:
            minj = j
    tmp = nums[i]
    nums[i] = nums[minj]
    nums[minj] = tmp
    if i != minj:
        convert_n += 1

n_list_str = ""
for num in nums:
    n_list_str += str(num)
    n_list_str += " "
print(n_list_str.rstrip(" "))
print(convert_n)

Measured memory_bytes: 5600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class P
{
    static void Main()
    {
        var a = ReadLine().Split().Select(int.Parse).ToList();
        int n = a[0], m = a[1], l = a[2];
        var A = new List<List<long>>();
        var B = new List<List<long>>();
        var C = new List<List<long>>();
        for (int i = 0; i < n; i++)
        {
            A.Add(ReadLine().Split().Select(long.Parse).ToList());
        }
        for (int i = 0; i < m; i++)
        {
            B.Add(ReadLine().Split().Select(long.Parse).ToList());
        }
        for (int ni = 0; ni < n; ni++)
        {
            for (int li = 0; li < l; li++)
            {
                long inner = 0;
                for (int mi = 0; mi < m; mi++)
                {
                    inner += A[ni][mi] * B[mi][li];
                }
                if (li > 0) Write(" ");
                Write(inner);
            }
            WriteLine();
        }
    }
}



Measured memory_bytes: 18468
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

long[][] p_triangle(long n)
{
	auto dp = new long[][](n+1, n+1);
	dp[0][0] = 1;
	foreach (i; 1..n+1)
	{
		foreach (j; 0..n+1)
		{
			if (j >= 1)
				dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	return dp;
}

void main()
{
	auto N = RD;
	auto A = RD;
	auto B = RD;
	auto v = RDR.ARR;
	v.sort!"a > b"();
	auto avg = sum(v[0..A]) / cast(double)A;
	auto x = v[A-1];
	long k;
	foreach_reverse (i; 0..A)
	{
		if (v[i] != x) break;
		++k;
	}
	long n = k;
	long preCnt = A - k;
	foreach (i; A..N)
	{
		if (v[i] != x) break;
		if (v[i] == avg) ++k;
		++n;
	}
	auto pt    = p_triangle(n);
	auto begin = min(A - preCnt, k);
	auto end   = min(B - preCnt, k) + 1;
	long cnt;
	foreach (i; begin..end)
		cnt += pt[n][i];
	writefln(FMT_F, avg);
	writeln(cnt);
	stdout.flush();
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)
 func main() {
 	var c string
 	fmt.Scan(&c)
 	
 	a := [26]string{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}

 	for i := 0; i < len(a)-1; i++ {
 		if a[i] == c {
 			fmt.Println(a[i+1])
 			break
		}
	}
 }

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >>H >> W;
    while(H--) {
        string s;
        cin >> s;
        cout << s << endl << s << endl;
    }
    return 0;
}


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

int main(int argc, char **argv)
{
	unsigned int k;
	cin >> k;

	vector<long long> a;
	for (int i = 1; i < 10; ++i)
		a.push_back(i);
	
	while (true)
	{
		if (k <= a.size())
		{
			std::cout << a[k-1] << std::endl;
			return 0;
		}
		k -= a.size();
		
		vector<long long> old;
		swap(old, a);
		for (long long x : old)
		{
			int last = x % 10;
			for (int i = -1; i <= 1; ++i)
			{
				int dx = last + i;
				if (dx < 0 || 9 < dx) continue;
				else
				{
					long long nx = x*10 + dx;
					a.push_back(nx);
				}
			}
		}
	}
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct UnionFind {
    vector<int> par, siz;
    UnionFind(int n) {
        par.resize(n);
        siz.resize(n, 1);
        for(int i = 0; i < n; i++)
            par[i] = i;
    }
    int find(int x) {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if(u == v)
            return false;
        if(siz[u] < siz[v])
            swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    }
    bool same(int u, int v) { return find(u) == find(v); }
};
struct edge {
    ll u, v, cost;
    bool operator<(const edge& e) { return cost < e.cost; }
};
ll d;
vector<ll> a;
vector<edge> es;
void calc(int l, int r) {
    if(r - l <= 1) {
        return;
    }
    int m = (l + r) / 2;
    ll mi = LINF, s, t;
    for(ll i = l; i < m; i++) {
        ll k = -i * d + a[i];
        if(mi > k) {
            mi = k;
            s = i;
        }
    }
    mi = LINF;
    for(ll i = m; i < r; i++) {
        ll k = i * d + a[i];
        if(mi > k) {
            mi = k;
            t = i;
        }
    }
    for(ll i = l; i < m; i++) {
        es.push_back({i, t, (t - i) * d + a[t] + a[i]});
    }
    for(ll i = m; i < r; i++) {
        es.push_back({s, i, (i - s) * d + a[i] + a[s]});
    }
    calc(l, m);
    calc(m, r);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n >> d;
    a.resize(n + 1);
    for(ll i = 1; i <= n; i++) {
        cin >> a[i];
    }
    calc(1, n + 1);
    UnionFind uf(n + 1);
    sort(all(es));
    ll ans = 0;
    for(auto e : es) {
        if(uf.unite(e.u, e.v)) {
            ans += e.cost;
        }
    }
    cout << ans << endl;
}


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

class Dice{
public:
    int face[6];
    int tmp[4];
    void direction(char ch){
        if(ch == 'N') move(0,1,5,4);
        if(ch == 'S') move(0,4,5,1);
        if(ch == 'W') move(0,2,5,3);
        if(ch == 'E') move(0,3,5,2);
    }
    void move(int a,int b,int c,int d){
            tmp[0] = face[a];
            tmp[1] = face[b];
            tmp[2] = face[c];
            tmp[3] = face[d];

            face[a] = tmp[1];
            face[b] = tmp[2];
            face[c] = tmp[3];
            face[d] = tmp[0];
    }
};

int main(){
    Dice dice1;
    string D;
    for(int i = 0;i < 6;i++){
        cin>>dice1.face[i];
    }
    cin>>D;
    for(int j = 0;j < D.size();j++){
        dice1.direction(D[j]);
    }
    cout<<dice1.face[0]<<endl;

    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int n; cin >> n;
  vl a(n); rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(bit,60){
    ll cnt_0 = 0,cnt_1 = 0;
    ll mul = (1LL << bit)%MOD;
    rep(i,n) {
      if(a[i] & (1LL << bit)) cnt_1++;
      else cnt_0++;
    }
    mul = (mul * cnt_0)%MOD;
    mul = (mul * cnt_1)%MOD;
    ans = (ans + mul)%MOD;
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
/*
   AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

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

    int K, N;
    cin>>N>>K;

    int x;
    int pos = 0;
    for(int i=0;i<N;i++){
        cin >> x;
        if(x == 1) pos = i;
    }

    int moves;

    if(K==N){
        moves = 1;
    } else {
        moves = (N - 1) / (K - 1);
        if((N - 1) % (K - 1) != 0){
            moves++;
        }
    }

    cout << moves << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define forr(i, b, e)     for (int i = b; i < e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 100056
#define offset 10000000
typedef pair<int,short> par;
int actmapa[tam];
int mapa[350];
int main()
{
    forr(i,0,tam)
    actmapa[i]=1e6;
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;

    forr(i,0,n)
    {
        string txt;
        cin>>txt;
        memset(mapa,0,sizeof mapa);
        forr(i,0,txt.size())
        {
            mapa[txt[i]]++;
        }
        forr(i,'a','z'+1)
        {
            actmapa[i]=min(actmapa[i],mapa[i]);
        }
    }    
    forr(i,'a','z'+1)
    {
        forr(j,0,actmapa[i])
        cout<<char(i);
    }
    cout<<endl;
}
// PLUS ULTRA!

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

int main() {
    int N, K, R, S, P, ans = 0;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    for (int i = 0; i < N; ++i) {
        if (i >= K && T[i] == T[i - K]) T[i] = 'o';
        if (T[i] == 'r') ans += P;
        else if (T[i] == 's') ans += R;
        else if (T[i] == 'p') ans += S;
    }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n%10==7)
    cout<<"Yes"<<endl;
  else if(n/100==7)
    cout<<"Yes"<<endl;
  else if((n/10%10)== 7)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
  


Measured memory_bytes: 3620
#include<stdio.h>
 
int main(void){
    int cockingT[5], array[5], min = 9, signum = 0, sum = 0, count = 0;
 
    int i;
    for(i = 0; i < 5; i++){
        scanf("%d", &cockingT[i]);
    }
 
    for(i = 0; i < 5; i++){
        array[i] = cockingT[i] - (cockingT[i] / 10) * 10;
    }
 
    for(i = 0; i < 5; i++){
        if(array[i] != 0){
            if(array[i] < min){
                min = array[i];
                signum = i;
            }
        }else{
            count += 1;
        }
    }
  	if(count == 5){
    	count -= 1;
    }
    sum += cockingT[signum];
    for(i = signum + 1; i < 5; i++){
        sum += cockingT[i] + 10 - array[i];
    }
    for(i = signum - 1; i >= 0; i--){
        sum += cockingT[i] + 10 - array[i];
    }
    sum -= count * 10;
    printf("%d", sum);
    return 0;
 
 
}

Measured memory_bytes: 128
from collections import defaultdict

N,M = map(int,input().split())
question = []
number = {}
counts = defaultdict(int)
for i in range(M):
    city,value = map(int,input().split())
    question.append([i,city,value])
sorted_question = sorted(question,key=lambda x: x[2])
for i,city,value in sorted_question:
    counts[city] += 1
    number[i] = "{:06}{:06}".format(city,counts[city])
for i in range(M):
    print(number[i])

Measured memory_bytes: 47320
#include<bits/stdc++.h>
using namespace std;
short a,b;
int c[14]={-1,12,0,1,2,3,4,5,6,7,8,9,10,11};
string d;
int main(){
    cin>>a>>b;
    d=(c[a]<c[b])?"Bob":"Alice";
    if(a==b)d="Draw";
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string s,t;
    cin>>s>>t;
    if(s<t)
        swap(s,t);
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }

cout<<cnt<<endl;
}




Measured memory_bytes: 3920
ABCD = [int(i) for i in input()]

if ABCD[0] + ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] - ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll a, b, c, d, cnt = 1;
    cin >> a >> b >> c >> d;
    while(true){
        if(cnt & 1){
            c -= b;
        }else{
            a -= d;
        }
        if(c <= 0){
            cout << "Yes\n";
            break;
        }
        if(a <= 0){
            cout << "No\n";
            break;
        }
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[301],n,dp[301][301];
main(){
  while(cin>>n,n){
    int ans=0;
    r(i,n)cin>>a[i];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<n;i+=2)
      for(int j=0;j<n-i;j++){
        dp[j][j+i]=dp[j+1][j+i-1];
        for(int k=1;k<=i;k+=2)dp[j][j+i]=max(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]);
        if(abs(a[j]-a[j+i])<2&&dp[j+1][j+i-1]==i-1)dp[j][j+i]=max(dp[j][j+i],i+1);
      }
    r(i,n)r(j,n)ans=max(ans,dp[i][j]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, h[100100], dp[100100], K;

signed main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        dp[i] = INFL;
    }
    dp[0] = 0ll;
    for(int i = 0; i < N; i++){
        for(int j = i - 1; j >= i - K && j >= 0; j--){
            dp[i] = min(dp[i], dp[j] + max(h[i] - h[j], h[j] - h[i]));
        }
    }
    cout << dp[N - 1] << endl;


    return 0;
}
/*



*/



Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int n, r = 0;
    cin >> n;
    for(int i = 0; i <= n; i++){
        r += i;
    }   
    cout << r; 
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String p = sc.next();
		boolean b1 = false;
		
		for(int is = 0; is < s.length(); is++) {
			boolean b2 = true;
			for(int ip = 0; ip < p.length(); ip++) {
				b2 = b2 && (s.charAt((is+ip)%s.length())==p.charAt(ip));
			}
			b1 = b1 || b2;
		}
		
		if(b1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    char ary[n];
    rep(i,n) cin >> ary[i];
    bool flag = false;
    rep(i,n) {
	    if (ary[i] == 'Y')
	    {
		    flag = true;
		    break;
	    }
    }
    if (flag)
    {
	    cout << "Four" << endl;
    }
    else
    {
	    cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << (w*h)/2 << ((w*h%2)?".50000000000 ":".00000000000 ");
	cout << (((x*2==w)&&(y*2==h))?1:0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define N 400004
int a[2][N],b[2][N],c[2][N],e[N],f[N],h[N],i,l,n,q[N],r,s[N],t,x,y;bool d[N][2],g[N];
inline bool cmp(int u,int v){return f[u]!=v&&u!=f[v]&&f[u]!=f[v]&&f[f[u]]!=v&&u!=f[f[v]];}
int u,v;
int main()
{
	for(scanf("%d%d%d",&n,&x,&y),i=t=1;i<n;i++)scanf("%d%d",&u,&v),b[0][++t]=a[0][u],c[0][a[0][u]=t]=v,b[0][++t]=a[0][v],c[0][a[0][v]=t]=u;
	for(i=t=1,e[n]=-1;i<n;e[i++]=-1)scanf("%d%d",&u,&v),b[1][++t]=a[1][u],c[1][a[1][u]=t]=v,b[1][++t]=a[1][v],c[1][a[1][v]=t]=u;
	for(d[q[r++]=x][e[x]=0]=true,d[q[r++]=y][e[y]=1]=true;l<r;)for(v=e[u=q[l++]],i=a[v][u];i;i=b[v][i])if(e[c[v][i]]<e[u])d[q[r++]=c[v][i]][e[c[v][i]]=e[u]]=true,g[c[v][i]]=h[c[v][i]]==h[f[c[v][i]]=u]+1,h[c[v][i]]=h[u]+1;
	for(i=1;i<n;i++)if(cmp(c[0][i<<1],c[0][i<<1|1])&&(!g[c[0][i<<1]]&&*d[c[0][i<<1]]||!g[c[0][i<<1|1]]&&*d[c[0][i<<1|1]]))return 0&puts("-1");
	for(i=1,v=0;i<=n;i++)if(*d[i]&&v<h[i])v=h[i];
	return 0&printf("%d\n",v<<1);
}

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

string narabikae(string str){
    string re = "";
    rep(i,str.length()){
        re = re + str[str.length()-i-1];
    }
    return re;
}

int main() {
    string S;
    cin >> S;
    int N = S.length();
    bool an = true;
    string S1 = S.substr(0,(N-1)/2);
    if(S!=narabikae(S)){
        an = false;
    }
    if(S1!=narabikae(S1)){
        an = false;
    }
    string S2 = S.substr((N+3)/2-1);
    if(S2!=narabikae(S2)){
        an = false;
    }
    if(an){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll cnt=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1)cnt++;
    }
    if(cnt%2==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
 
   

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int h, w, d;
int a[333][333];
int q;
int memo[101010];
int posi[101010], posj[101010];

int main() {
	cin >> h >> w >> d;
	REP(i, h)REP(j, w)cin >> a[i][j], posi[a[i][j]] = i, posj[a[i][j]] = j;
	for (int num = h*w; num >= 1; num--) {
		if (num + d > h*w)continue;
		memo[num] = memo[num + d] + abs(posi[num] - posi[num + d]) + abs(posj[num] - posj[num + d]);
	}
	cin >> q;
	REP(i, q) {
		int l, r;
		cin >> l >> r;
		cout << abs(memo[l] - memo[r]) << endl;
	}
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
# As = [[0]*m for i in range(n)]
# b = [0] * m
As = []
b = []
for i in range(n):
    a = list(map(int, input().split()))
    As.append(a)
for _ in range(m):
    b.append(int(input()))

c = [0] * n

for i in range(n):
    sum = 0
    for j in range(m):
        sum += As[i][j] * b[j]
    c[i] = sum

for c_ in c:
    print(c_)


Measured memory_bytes: 6020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Pair
{
	public int Y { get; private set; } = -1;
	public int X { get; private set; } = -1;

	public Pair(int y, int x)
	{
		Y = y;
		X = x;
	}
}


public class D
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int H = Int32.Parse(args[0]);
		int W = Int32.Parse(args[1]);
		
		char[,] s = new char[H,W];
		int[,] cost = new int[H,W];
		int numWhite = 0;
		for(int i = 0; i < H; i++)
		{
			string str = Console.ReadLine();
			for(int j = 0; j < W; j++)
			{
				cost[i,j] = Int32.MaxValue;
				s[i,j] = str[j];
				if(str[j] == '.')
					numWhite++;
			}
		}

		int[] dy = new int[4] {-1, 0, 1, 0};
		int[] dx = new int[4] {0, -1, 0, 1};
		
		Queue<Pair> queue = new Queue<Pair>(H * W);
		cost[0,0] = 0;
		queue.Enqueue(new Pair(0,0));
		while(queue.Count > 0)
		{
			Pair p = queue.Dequeue();
			for(int i = 0; i < 4; i++)
			{
				int y = p.Y + dy[i];
				int x = p.X + dx[i];

				if((y < 0) || (y >= H) || (x < 0) || (x >= W))
					continue;

				if((s[y,x] == '#') || (cost[y,x] < Int32.MaxValue))
					continue;

				cost[y,x] = cost[p.Y,p.X] + 1;
				queue.Enqueue(new Pair(y,x));			
			}			
		}

		Console.WriteLine((cost[H-1,W-1] < Int32.MaxValue) ? numWhite - cost[H-1,W-1] - 1 : -1);
	}	
}





Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define oo int(1e9)
using namespace std;
typedef long long ll;
const ll INF = (ll)(1e18);
int n, W;

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
	cin >> n >> W;
	vector<int> w(n);
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	
	int sumvalue = 0;
	for (int x: v) sumvalue += x;
	
	vector<ll> dp(sumvalue + 1,INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	    for (int j = sumvalue; j >= v[i]; j--)
	        dp[j] = min(dp[j], dp[j - v[i]] + (ll)w[i]);
	
	for (int j = sumvalue; j > 0; j--)
	    if (dp[j] <= W){
	        cout << j;
	        break;
	    }
	
	return 0;
}

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

int main(){
  int n,d,i,ans;
  cin >> n >> d;
  i = d+1;
  i += d;
  if(n%i == 0){
    ans = n/i;
  }else{
    ans = n/i +1;
  }
    
  cout << ans << endl;    
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N,0);
    vector<ll> unique(1000001,0);
    vector<bool> check(1000001,true);
    ll cnt=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        unique[A[i]]++;
    }
    for(ll i=0;i<N;i++){
        if(!check[A[i]]){
            continue;
        }
        if(unique[A[i]]!=1){
            check[A[i]]=false;
        }
        for(ll elem=2*A[i];elem<=1000000;elem+=A[i]){
            check[elem]=false;
        }
    }
    for(ll i=0;i<N;i++){
        if(check[A[i]]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 12680
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char C[2200010];
char *ci = C, ct;
void pakuri_sort(int N, ll A[], int ichi[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = ichi[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			ichi[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	fread(C, 1, 2200010, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	ll S[200000];
	int ichi[200001];
	rep(i, N) {
		ll s = 0;
		ichi[i] = ci - C;
		int k = 10;
		while ((ct = *ci++) >= 'a') {
			s = s * 27 + ct - '`';
			k--;
		}
		rep(i, k) s *= 27;
		S[i] = s;
	}
	pakuri_sort(N, S, ichi);
	int kazu = 0;
	int saidai = 0;
	ll mae = 0;
	rep(i, N) {
		if (S[i] != mae) {
			chmax(saidai, kazu);
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	chmax(saidai, kazu);
	kazu = 0;
	mae = 0;
	
	rep(i, N) {
		if (S[i] != mae) {
			if (saidai == kazu) {
				char *tmp = C + ichi[i - 1];
				while (*tmp >= 'a') putchar_unlocked(*tmp++);
				putchar_unlocked('\n');
			}
			kazu = 1;
			mae = S[i];
		}
		else kazu++;
	}
	if (saidai == kazu) {
		char* tmp = C + ichi[N - 1];
		while (*tmp >= 'a') putchar_unlocked(*tmp++);
		putchar_unlocked('\n');
	}

	Would you please return 0;
}

Measured memory_bytes: 8320
s = input()
n = len(s)
if s == s[::-1] and s[:(n-1)//2] == s[:(n-1)//2][::-1] and s[((n+3)//2-1):] == s[((n+3)//2-1):][::-1]:
    print('Yes')
else:
    print('No')

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

typedef pair<ll,ll> P;

int main(){
  ll n,x,d; scanf("%lld%lld%lld",&n,&x,&d);
  if(d==0){printf(x==0?"1\n":"%lld\n",n+1); return 0;}
  ll g=__gcd(abs(x),abs(d)); if(d<0)g*=-1;
  x/=g; d/=g; map<ll,vector<P>> mp;
  rep(k,0,n+1){
    ll lb=1LL*k*(k-1)/2,rb=1LL*(2*n-k-1)*k/2;
    ll rem=(x*k)%d; if(rem<0)rem+=d;
    ll add=(x*k-rem)/d; lb+=add; rb+=add;
    mp[rem].push_back({lb,rb+1});
  }
  ll ans=0;
  for(auto p:mp){
    vector<P> vec=p.second;
    sort(ALL(vec)); ll ma=-INF;
    rep(i,0,vec.size()){
      ll lb=vec[i].first,rb=vec[i].second;
      chmax(lb,ma);
      ans+=max(0LL,rb-lb);
      chmax(ma,rb);
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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

#define INF 100000000

int main(){
    ll n,m,q;
    cin>>n>>m>>q;
    ll a[q], b[q], c[q], d[q];
    rep(i,q) cin>>a[i]>>b[i]>>c[i]>>d[i];

    int ans = 0;

    rep2(i1,1,m+1){
        rep2(i2,i1,m+1){
            rep2(i3,i2,m+1){
                rep2(i4,i3,m+1){
                    rep2(i5,i4,m+1){
                        rep2(i6,i5,m+1){
                            rep2(i7,i6,m+1){
                                rep2(i8,i7,m+1){
                                    rep2(i9,i8,m+1){
                                        rep2(i10,i9,m+1){
                                            int x[11] = {1,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10};
                                            int temp = 0;
                                            // cout<<i1<<" "<<i2<<" "<<i3<<" "<<i4<<" "<<i5<<" "<<i6<<" "<<i7<<" "<<i8<<" "<<i9<<" "<<i10<<" "<<endl;

                                            rep(j,q){
                                                if(x[b[j]] - x[a[j]] == c[j]) temp += d[j];
                                            }
                                            ans = max(ans, temp);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }


    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    height = a[0]
    ans = 0

    for i in range(1, n):
        if height > a[i]:
            ans += height - a[i]
        else:
            height = a[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31444
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

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

int main(){
	int N;
	int r_num = 0,b_num=0;
	cin >> N;
	int s[N];
	map<char,int> mp;
	mp['R'] = 0;
	mp['B'] =1;
	
	char tmp;
	REP(i,N){
		cin >>tmp;
		if(mp[tmp] ==0){
			r_num++;
		}else{
			b_num++;
		}
	}
	if(r_num > b_num){
		cout << "Yes"<<endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int N,A=0;
  int64_t Z=0;
  cin>>N;
  vector<vector<int64_t>> d(N,vector<int64_t>(N));
  vector<vector<int>> p(N,vector<int>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>d.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(d.at(i).at(k)==d.at(i).at(j)+d.at(j).at(k)&&d.at(i).at(j)!=0&&d.at(j).at(k)!=0){
          p.at(i).at(k)++;
        }
        if(d.at(i).at(k)>d.at(i).at(j)+d.at(j).at(k)){
          A++;
          break;
        }
      }
    }
  }
  if(A!=0){
    cout<<"-1"<<endl;
  }
  else{
    for(int i=0;i<N;i++){
      for(int j=i;j<N;j++){
        if(p.at(i).at(j)==0){
          Z+=d.at(i).at(j);
        }
      }
    }
    cout<<Z<<endl;
  }
}




Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k)cout<<s<<endl;
  else{
    for(int i=0;i<k;i++){
      cout<<s.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;string s,t;
	cin>>n>>s>>t;
	while(s!=t){
		s.erase(s.begin()+0);
		t.pop_back();
	}
	cout << n+(n-s.size());
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
# 2019/08/16

s=list(input())
t=list(input())

c1={}
c2={}
for ss,tt in zip(s,t):
    if c1.get(ss) is None:
        c1[ss]=tt
    if c2.get(tt) is None:
        c2[tt]=ss
    if c1[ss]==tt and c2[tt]==ss:continue
    else:
        print('No')
        exit()

print('Yes')


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

int main(){
    int X,Y,s,n;
    n=0;
    cin >> X >> Y;
    for(int i=0; i<=X; i++){
        s=2*i+4*(X-i);
        if(Y==s){
            n+=1;
        }
        s=0;
    }
//    cout << n << endl;
    if(n==0){
        cout << "No" << endl;
    }
    else if(n==1){
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int inf = 0x7fffffff;
int f[1<<15][15];
int w[1<<15][15];
int map[15][15];
int n, m;
void up(int &x, int y) { if(x < y) x = y; }
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	int sum = 0;
	for(i = 1; i <= m; i++){
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d); x--; y--;
		map[x][y] = map[y][x] = d;
		sum += d;
	}
	for(i = 1; i < 1<<n; i++){
		int res = 0;
		for(j = 0; j < n; j++){
			for(k = j+1; k < n; k++) if(i&(1<<j) && i&(1<<k)) res += map[j][k];
		}
		for(j = 0; j < n; j++){
			if(i&(1<<j)) continue;
			w[i][j] = res;
			for(k = 0; k < n; k++){
				if(i&(1<<k)) w[i][j] += map[j][k];
			}
		}
	}
	for(j = 0; j < 1<<n; j++) for(i = 0; i < n; i++) f[j][i] = -inf;
	f[1][0] = 0;
	for(i = 1; i < 1<<n; i += 2){
		for(j = 0; j < n; j++){
			if(!(i&(1<<j))) continue;
			for(k = 0; k < n; k++){
				if(i&(1<<k) && j != k && map[j][k] != 0) up(f[i][j], f[i^(1<<j)][k]+map[j][k]);
			}
			for(k = (i-1)&i; k; k = (k-1)&i) if(k&(1<<j)) up(f[i][j], f[k][j]+w[i^k][j]);
		}
	}
	printf("%d\n", sum-f[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 3968
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import Counter

def main():
  n = int(input())
  Ss = [input().strip() for _ in range(n)]
  counts = sorted(Counter(Ss).items(), key=lambda x:x[1], reverse=True)
  max = counts[0][1]
  Ss_max = []
  for S, count in counts:
    if count != max:
      break
    Ss_max.append(S)
  print('\n'.join(sorted(Ss_max)))



if __name__=='__main__':
  main()

Measured memory_bytes: 45032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = (int)1e5 + 100;
int gcd(int a, int b) {
    while (a > 0 && b > 0) {
        if (a < b) swap(a, b);
        a %= b;
    }
    return (a + b);
}
int pref[maxN], suf[maxN];
int n;
int v[maxN], c[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    srand(228);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int c;
        cin >> c;
        ans += max(0, v[i] - c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
s = "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"
s2 = s.split(",")
k = int(input())
print(s2[k-1])

Measured memory_bytes: 38256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[100002];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll x=1;
    ll maxi=1;
    for (int i = 1; i < n; ++i)
    {
        if(a[i]>a[i-1])
        {
            maxi=max(maxi,x);
            x=1;
        }
        else
        {
            x++;
        }
    }
    maxi=max(maxi,x);
    cout<<maxi-1<<'\n';
}


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

using ll = long long;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;

void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//shift r is search & replace
//shift d is delete a line

bool comp(pii a, pii b){
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
int main(){
    setIO();
    int n, k; cin >> n >> k;
    int p[n];
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    sort(p, p + n);
    int sum = 0;
    for(int i = 0; i < k; ++i){
        sum += p[i];
    }
    cout << sum << "\n";
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100;

int a[MAX_N][MAX_N];
int n;

int main()
{
	scanf("%d",&n);
	rep(i,n){
        rep(j,n){
            scanf("%d",&a[i][j]);
        }
	}
    ll res = 0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            res += min(a[i][j],a[j][i]);
        }
    }
    cout << res << "\n";
	return 0;
}

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

using namespace std;

const int N = 100100;

int aa[N], bb[N], cc[N];

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	multiset <pair<int, int> > s;
	for (int i = 0; i < a; ++i) {
		cin >> aa[i];
		s.insert(make_pair(-aa[i], 1));
	}
	for (int i = 0; i < b; ++i) {
		cin >> bb[i];
		s.insert(make_pair(-bb[i], 2));
	}
	for (int i = 0; i < c; ++i) {
		cin >> cc[i];
		s.insert(make_pair(-cc[i], 3));
	}
	long long ans = 0;
	int coloress = 0;
	while(!s.empty()) {
		pair<int,int> v = *s.begin();
		s.erase(s.begin());
		if(x + y == coloress)break;
		if(v.second == 1 && x > 0) {
			ans += -v.first;
			x--;
		}
		if(v.second == 2 && y > 0) {
			ans += -v.first;
			y--;
		}
		if(v.second == 3) {
			ans += -v.first;
			coloress++;
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 15488
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int d[2005];
int n;
int main()
{
    cin>>n;
    d[0]=1;
    for(int i=1;i<=n;i++)
	{
        for(int j=0;j<=i-3;j++)
		{
            d[i]+=d[j];
            d[i]%=mod;
        }
    }
    cout<<d[n]<<endl;
    return 0;
}


Measured memory_bytes: 3200
let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let s = Array.init h (fun _ -> Scanf.scanf " %s" (fun x -> x)) in
  let f x y = s.(x).[y] in

  let t = Array.make_matrix h w (-3) in
  let g x y v = t.(x).(y) <- t.(x).(y) + v in

  let rec loop n f g h w =
    if n <= 0 then ()
    else begin
      for i = 0 to h-1 do
        let u = Array.make w 0 in
        if f i 0 = '.' then u.(0) <- 1;
        for j = 1 to w-1 do
          if f i j = '.' then
            u.(j) <- u.(j-1) + 1
        done;
        u |> Array.iteri (g i);
      done;
      loop (n-1) (fun x y -> f (h-1-y) x) (fun x y -> g (h-1-y) x) w h
    end
  in
  loop 4 f g h w;

  Array.fold_left (Array.fold_left max) 0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 66048