akhauriyash/Code-Regression huggingface dataset:
s=input()
ans=0
for i in range(2**(len(s)-1)):
	r=0
	d="0"*10+bin(i)
	for j in range(len(s)-1):
		if d[-j-1]=="1":
			ans+=int(s[r:j+1])
			r=j+1
	ans+=int(s[r:])
print(ans)




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

void min_definite(int input,int *min_num);
void maxdiff_definite(int input,int min_num,int *max_diff);

int main(void){

  int data_num;
  int input;
  int min_num;
  int max_diff;

  cin >> data_num;

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

    cin >> input;

    if ( i == 0 ){
      min_num = input;
    }else if(i == 1){
      max_diff = input - min_num;
      min_definite(input,&min_num);
    }else{
      maxdiff_definite(input,min_num,&max_diff);
      min_definite(input,&min_num);
    }
  }

  cout << max_diff << endl;

  return 0;
}

void min_definite(int input,int *min_num){
  if( input < *min_num){
    *min_num = input;
  }
}

void maxdiff_definite(int input,int min_num,int *max_diff){
  if ((input - min_num) > *max_diff){
    *max_diff = input - min_num;
  }
}

Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	int K;
	cin >> N >> K;
	bool D[10] = {};
	for (int i = 0; i < K; i++) {
		int Di;
		cin >> Di;
		D[Di] = true;
	}

	for (int i = N; i < 100000; i++) {
		int n = i;
		bool flag = false;
		while (n > 0) {
			if (D[n % 10]) {
				flag = true;
				break;
			}
			n /= 10;
		}
		if (!flag) {
			cout << i << endl;
			return 0;
		}
	}

	for (int i = 1; i <= 9; i++) {
		if (D[i]) continue;
		cout << i * 100000 << endl;
		break;
	}

	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll INF = 1LL << 40;
const ll LIM = 100 * 1000;

int solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

int solve(void)
{

	ll N;
	cin >> N;

	vector<pll> ans;
	{
		if (N % 2 == 1)
		{
			for (int i = 0; i < N-1; i++)
			{
				ans.push_back(pll(N, i+1));
			}
			N --;
		}
		for (ll i = 0; i < N / 2; i++)
		{
			for (ll j = 0; j < N / 2; j++)
			{
				if(i <= j) { continue; }
				ans.push_back(pll(i+1, j+1));
				ans.push_back(pll(i+1, N-j));
				ans.push_back(pll(N-i, j+1));
				ans.push_back(pll(N-i, N-j));
			}
		}
	}
	
	cout << ans.size() << endl;
	for(auto a :ans)
		cout << a.first << " " << a.second << endl;


	return 0;
}

Measured memory_bytes: 512
import * as fs from "fs";

function strArr2numArr(strArr: string[]): number[] {
    let numArr: number[] = [];
    strArr.map((item) => {
        numArr.push(+item);
    });
    return numArr;
}

const MOD: number = 1e9 + 7;

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

let k: number;
let s: string;

k = +input[0];
s = input[1];

let subs: string = s.substr(0, k);

let ans: string = s.length > k ? subs + "..." : s;
console.log(ans);


Measured memory_bytes: 29704
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int n,p;
	string s;
	cin >> n;
	pair<pair<string, int>, int> r[110];
	for (int i = 0; i < n;i++) {
		cin >> s >> p ;
		r[i] = make_pair(make_pair(s, -p), i);
	}
	sort(r,r+n);
	for (int i = 0; i < n;i++) {
		cout << r[i].second + 1 << endl;
	}
}

Measured memory_bytes: 256
b1,b2,b3=(int(x) for x in input().split())
if (b1==0 or 1) and (b2==0 or 1) and (b3==0 or 1):
   if b1==1 and b2==0 and b3==0 or b1==0 and b2==1 and b3==0 or b1==0 and b2==0 and b3==0 :
      print("Close")
   elif b1==1 and b2==1 and b3==0 or b1==0 and b2==0 and b3==1:
      print("Open")
   else:
      pass
else:
   pass



Measured memory_bytes: 5604
object Main extends App {
  import scala.math._
  
  def F(a:Long,b:Long) = {
    Array(a.toString.length,b.toString.length).max
  }
  
  val n = readLong
  
  println((for (a <- 1 to sqrt(n).ceil.toInt if n % a == 0; b = n / a) yield F(a,b)).min)
}

Measured memory_bytes: 29768
/*input
5
aaaaa aaaaa
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    string s, t; cin >> s >> t;
    for(int i = 0; i < 2 * n; i++) if(i & 1) cout << t[i/2];
    else cout << s[i/2];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

double t, x;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> t >> x;
	cout << fixed << setprecision(4) << t / x << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define INF 1e9
using namespace std;
typedef pair <int,int> P;
typedef pair <P,P> PP;
vector <PP> G[200];
int n,m,H,com,S,T;
priority_queue<PP,vector<PP>, greater<PP> > Q;
 
 
int dijkstra(int b){
  while(!Q.empty())Q.pop();
  int D[25][200];
  for(int i=0;i<=H;i++)for(int j=0;j<=n;j++) D[i][j]=INF;
  Q.push(PP(P(0,0),P(S,-1)));
  D[0][0]=0;
  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,h=t.f.s,pos=t.s.f;
    if(pos==T) return cost;
    if(D[h][pos]<cost)continue;
 
    for(int i=0;i<(int)G[pos].size();i++){
      int ncost=cost+G[pos][i].f.s;
      int nh=h+G[pos][i].s.f;
      int nx=G[pos][i].f.f;
      if((b&(1<<G[pos][i].s.s)))ncost=cost;
      if(nh>H)continue;
      if(D[nh][nx]>ncost)Q.push(PP(P(ncost,nh),P(nx,-1)));
      D[nh][nx]=min(D[nh][nx],ncost);
    }
  }
  return INF;
}
 
int main(){
  while(1){
    cin>>n>>m>>H>>com;
    if(!n&&!m&&!H&&!com)break;
 
    for(int i=0;i<200;i++)G[i].clear();
 
    for(int i=0,a,b,c,h,r;i<m;i++){
      cin>>a>>b>>c>>h>>r;
      a--,b--,r--;
      G[a].push_back(PP(P(b,c),P(h,r)));
      G[b].push_back(PP(P(a,c),P(h,r)));
    }
     
    cin>>S>>T;
    S--,T--;
    int pass;
 
    P pc[300];
    cin>>pass;
    for(int i=0;i<pass;i++){
      int j;
      pc[i].s=0;
      cin>>j>>pc[i].f;
      while(j--){
    int a;
    cin>>a;
    pc[i].s|=(1<<(a-1));
      } 
    }
 
    int dp[100000];
    for(int i=0;i<300;i++)dp[i]=INF;
    dp[0]=0;
     
    for(int i=0;i<(1<<com);i++)    
      for(int j=0;j<pass;j++){
    if(dp[i]>=INF)continue;
    int b=i|pc[j].s,ncost=dp[i]+pc[j].f;
    dp[b]=min(dp[b],ncost);
      }
     
    int ans=INF;
    for(int i=0;i<(1<<com);i++){
      if(dp[i]<INF) ans=min(ans,dp[i]+dijkstra(i));
    }
 
    if(ans>=INF) ans=-1;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1428
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 14:35:24 2018

@author: sugawara
"""


N = int(input())
A = [int(i) for i in input().split()]
#N = 6
#A = [-679, -2409, -3258, 3095, -3291, -4462]
#N = 3
#A = [3, 5, -1]

# iからi+1への移動距離
delta_A = [abs(A[0])] + [abs(A[i] - A[i-1]) for i in range(1, N)] + [abs(A[-1])]
sum_of_all = sum(delta_A)

A = [0] + A + [0]
res = []
for i in range(N):
    res.append(sum_of_all - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i]))
    
    
for i in range(N):
    print(res[i])

Measured memory_bytes: 16820
k = gets.to_i
k /= 7  if k%7 == 0
A = [nil]*k
i = x = 1
(i+=1; x=x*10+1)  while x < k
while 0 < x%=k
  while x < k
    exit 0&p(-1)  if A[x]
    A[x] = i += 1
    x = x*10 + 1
  end
end
p i

Measured memory_bytes: 21944
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n = int(input())
    if n >= 30:
        print('Yes')
    else:
        print('No')

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 62580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	string n;
	cin >>n;
	int a;
	 a=n.length();
	string ans;
	ans="No";
	int w=0;
	rep(i,a){
		w+=(n[i]-48);
	}
//	cout <<"W="<<w<<endl;
	if ((w%9)==0)ans="Yes";
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int m = n/2;

    int v[n];
    rep(i, n) {
        cin >> v[i];
    }

    int o[m], e[m];     //v[n]の奇数番目(1-index)の項がo[m],偶数番目(1-index)の項がe[m]
    rep(i, m) {
        o[i] = v[2*i];
        e[i] = v[2*i+1];
    }
    sort(o, o+m);
    sort(e, e+m);

    int to = o[0];
    int ko = 0;
    vector<int> co(m);
    rep(i, m) {
        if(to < o[i]) {
            to = o[i];
            ko++;
            co[ko]++;
        } 
        else {
            co[ko]++;
        }
    }

    int te = e[0];
    int ke = 0;
    vector<int> ce(m);
    rep(i, m) {
        if(te < e[i]) {
            te = e[i];
            ke++;
            ce[ke]++;
        } 
        else {
            ce[ke]++;
        }
    }

    sort(co.begin(), co.end());
    reverse(co.begin(), co.end());
    sort(ce.begin(), ce.end());
    reverse(ce.begin(), ce.end());

    int ao = o[0];  //aoにはoの最頻値(oにco[0]個ある数)が入る
    int bo = 0;
    rep(i, m) {
        if(ao < o[i]) {
            if(bo == co[0]) {
                break;
            }
            ao = o[i];
            bo = 0;
        }
        bo++;
    }

    int ae = e[0];  //aeにはeの最頻値(eにce[0]個ある数)が入る
    int be = 0;
    rep(i, m) {
        if(ae < e[i]) {
            if(be == ce[0]) {
                break;
            }
            ae = e[i];
            be = 0;
        }
        be++;
    }

    int ans;
    if(ao != ae) {  //最頻値が異なる数の場合
        ans = n - (co[0] + ce[0]);
    }
    else {  //最頻値が同じ数の場合
        int u = co[0] + ce[1];
        int v = co[1] + ce[0];
        ans = n - max(u, v);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
typedef pair<ll,ll> P;
const ll MOD=1000000007LL;
int main(){
  string s;cin>>s;
  ll zero=0,one=0;
  rep(i,s.size()){
    if(s[i]=='0')zero++;
    else one++;
  }
  cout<<min(zero,one)*2<<endl;
}

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

#define LIM 300020
using namespace std;

int main(){
	
	int n;
	bool isprime[LIM]={0};
	vector<int> primes;
	
	for(int i=2; i<LIM; ++i)
		isprime[i]=true;
	
	for(int i=2; i*i<LIM; ++i){
		
		if(isprime[i] && (i%7==1 || i%7==6)){
			for(int j=i; i*j<LIM; j++){
				if(j%7==1 || j%7==6){
					isprime[i*j]=false;
				}
			}
		}
	}
	
	for(int i=0; i<LIM; ++i){
		
		if(isprime[i] && (i%7==1 || i%7==6))
			primes.push_back(i);
	}
	
	while(cin>>n, n>1){
		
		cout << n << ":";
		
		for(int i=0; i<primes.size(); ++i){
			
			if(n%primes[i]==0)
				cout << " " << primes[i];
		}
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1644
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    ll k[Q];
    for (int i = 0; i < Q; i++) {
        cin >> k[i];
    }
    bool d[N], n[N], c[N];
    fill(d, d + N, false);
    fill(n, n + N, false);
    fill(c, c + N, false);
    ll dst = -1;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'D') {
            d[i] = true;
            if (dst == -1) {
                dst = i;
            }
        } else if (S[i] == 'M') {
            n[i] = true;
        } else if (S[i] == 'C') {
            c[i] = true;
        }
    }
    for (int q = 0; q < Q; q++) {
        if (dst == -1) {
            cout << 0 << endl;
            continue;
        }
        ll ans = 0;
        ll nnum = 0;
        ll cnum = 0;
        ll start = dst;
        ll last = min(dst + k[q], N);
        for (int i = dst + 1; i < last; i++) {
            if (n[i]) {
                nnum++;
            } else if (c[i]) {
                ans += nnum;
                cnum++;
            }
        }
        ll tmp = ans;
        for (int i = dst + 1; i < N; i++) {
            if (d[i]) {
                for (int j = start + 1; j < i; j++) {
                    if (n[j]) {
                        tmp -= cnum;
                        nnum--;
                    } else if (c[j]) {
                        cnum--;
                    }
                }
                ll nexlast = min(i + k[q], N);
                for (int j = last; j < nexlast; j++) {
                    if (n[j]) {
                        nnum++;
                    } else if (c[j]) {
                        tmp += nnum;
                        cnum++;
                    }
                }
                ans += tmp;
                start = i;
                last = min(start + k[q], N);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,M;
  cin>>N>>M;
  VL X(N),Y(M);
  rep(i,N) cin>>X[i];
  rep(i,M) cin>>Y[i];
  ll XX=0,YY=0;
  ll mod=1e9+7;
  rep(i,N-1) (XX+=(X[i+1]-X[i])*(i+1)%mod*(N-1-i)%mod)%=mod;
  rep(i,M-1) (YY+=(Y[i+1]-Y[i])*(i+1)%mod*(M-1-i)%mod)%=mod;
  cout<<XX*YY%mod<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

int N, X, Y, Z;

int push(int s, int a) {
   return ((s << a) + (1<<(a-1))) % (1<<(X+Y+Z));
}
bool hasXYZ(int s, int a) {
   int p = push(s, a);
   return p >> (Z-1) & 1 && p >> (Y+Z-1) & 1 && p >> (X+Y+Z-1) & 1;
}

int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}

signed main()
{
   cin >> N >> X >> Y >> Z;
   vector<vector<int>> dp(N+1, vector<int>(1<<(X+Y+Z)));
   dp[0][0] = 1;
   REP(i, 0, N) {
      REP(s, 0, 1<<(X+Y+Z)) {
         REP(a, 1, 11) {
            if (!hasXYZ(s, a)) {
               dp[i+1][push(s, a)] = mod(dp[i+1][push(s, a)] + dp[i][s]);
            }
         }
      }
   }
   int ans = powM(10,N);
   REP(s, 0, 1<<(X+Y+Z)) {
      ans = mod(ans - dp[N][s]);
   }

   cout << ans << endl;

   return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  
  int ans = 0;
  rep(i,n)rep(j,n)rep(k,n)
  {
    if(i<j && j<k)
    {
      if(l[i] == l[j]) continue;
      if(l[j] == l[k]) continue;
      if(l[k] == l[i]) continue;
      
      if(l[i]+l[j]+l[k] > max({l[i],l[j],l[k]})*2)
      {
        ++ans;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   String[] n1 = new String[N];
 
   for(int i=0;i<N;i++) n1[i]= sc.next();
   
   int M = sc.nextInt();
   String[] m1 = new String[M];
 
   for(int i=0;i<M;i++) m1[i]= sc.next();
   int ans =0;
   int count =0;
   for(int i=0;i<N;i++)
   {
     count =0;
     for(int k=0;k<N;k++)
     {
       if(n1[i].equals(n1[k])) count++;
     }
     for(int k=0;k<M;k++)
     {
       if(n1[i].equals(m1[k])) count--;       
     }
     if(ans <count )ans = count;
   }
 
   System.out.println(ans);
 }
}

Measured memory_bytes: 21844
from itertools import product

N, M = map(int, input().split())
cakes = [tuple(map(int, input().split())) for _ in range(N)]

choice = [1, -1]
ans = 0
for c in product(choice, repeat=3):
    cake_scores = sorted([cake[0]*c[0] + cake[1]*c[1] + cake[2]*c[2] for cake in cakes], reverse=True)
    ans = max(ans, sum(cake_scores[:M]))
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main()
{
    int A,B,C,D,E;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);

    D=A-B;
    E=C-D;

    if(E>0)
    {
        printf("%d\n",E);
    }
    else
    {
        printf(" 0 \n");
    }
     return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;

  vector<string> we(H);
 
  for (int i = 0; i < H; i++){
   cin >> we.at(i);
  }  

//1行目  
    for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl;
//2行目以降 
  
  for (int i = 0; i < H; i++){
    cout << "#" ;
    cout << we.at(i);
    cout << "#" << endl;
  }

     for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl; 


}



Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	a = parseInt(input[0],10)
  	b = parseInt(input[1],10)
	//文字列から10進数に変換するときはparseIntを使います
	
  	c = a + b
  	d = a - b
  	e = a * b
  
  	arr = [c,d,e]
  
  	answer = Math.max.apply(null,arr)
  
	console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
char s[4005],t[4005];u[4005],m,i,j,c,d;main(n){for(;d=~scanf("%s%s",s,t);i=m=!printf("%d\n",m))for(n=strlen(s);d;d=t[i++])for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	map<int,int> even;
	map<int,int> odd;
	rep(i,n){
		if(i % 2 == 0){
			even[a[i]]++;
		}else{
			odd[a[i]]++;
		}
	}
	vector<pair<int,int>> vp_odd;
	vector<pair<int,int>> vp_even;
	for(auto p: even){
		vp_even.emplace_back(p.second, p.first);
	}
	for(auto p: odd){
		vp_odd.emplace_back(p.second, p.first);
	}
	sort(vp_even.rbegin(),vp_even.rend());
	sort(vp_odd.rbegin(),vp_odd.rend());
	int ans = 0;
	if(vp_even[0].second == vp_odd[0].second){
		ans = min(n- vp_even[0].first - vp_odd[1].first, n- vp_even[1].first - vp_odd[0].first);
	}else{
		ans = n - vp_even[0].first - vp_odd[0].first;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9264
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M;
string A[50], B[50];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, M) {
		cin >> B[i];
	}
	REP(dy, N - M + 1) {
		REP(dx, N - M + 1) {
			bool flag = true;
			REP(i, M) {
				REP(j, M) {
					flag &= (A[dy + i][dx + j] == B[i][j]);
				}
			}
			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x, k, d, ans;
int main()
{
	cin >> x >> k >> d;
	ll a = abs(x) / d;
	if (a == k)
	{
		ans = abs(x) - d * a;
	}
	else if (a < k)
	{
		ll c = k - a;
		if (c & 1)
		{
			ans = d * (a + 1) - abs(x);
		}
		else
		{
			ans = abs(x) - d * a;
		}
	}
	else
	{
		ans = abs(x) - d * k;
	}
	cout << ans << endl;
	return 0;
}

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

long long a, b, c, u, v;

int main(){
	cin >> a >> b >> c;
	if (c<(a+b)){
		cout << "No\n";
		return 0;
	}
	u=4*a*b;
	v=(c-a-b)*(c-a-b);
//	cout << u << " " << v << "\n";
	if (u<v) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
from sys import stdin

def main():
    S = input()

    ans, cnt = 0, 0
    for s in S:
        if s in {'A', 'C', 'G', 'T'}:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    print(max(ans, cnt))

input = lambda: stdin.readline().rstrip()
main()


Measured memory_bytes: 2940
import Control.Monad
import Data.Maybe
import Data.List
import Data.Char

main = do
  [n, m] <- map read.words <$> getLine
  sc <- replicateM m $ readPair.words <$> getLine
  print $ solve n sc

solve :: Int -> [(Int, Int)] -> Int
solve n sc = fromMaybe (-1) $ find eval can where
  eval n = all (\(s, c) -> show n !! (s-1) == intToDigit c) sc
  can = case n of 
    1 -> [0..9]
    2 -> [10..99]
    3 -> [100..999]

readPair [a, b] = (read a, read b)

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k, a[200010];
int b[200010];
int ta[200010];
int loop;
int ka;
int cnt;
int cnt2;
vector<int> ans;

signed main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	fill(b, b + 200010, INF);
	for (int i = 0; i < 2 * n; i++) {
		if (b[a[i%n]] != INF) {
			ta[b[a[i%n]]] = (i + 1) % n;
		}
		b[a[i%n]] = i % n;
	}
	int j = 0;
	while (1) {
		if (j + 1 < ta[j])loop += ta[j] - j;
		else if (j == n - 1 && ta[j] == 0)loop += ta[j] + 2 * n - j;
		else loop += ta[j] + n - j;
		j = ta[j];
		if (j == 0)break;
	}
	ka = (n*k) % loop;
	j = 0;
	while (1) {
		cnt2 = cnt;
		if (j + 1 < ta[j])cnt += ta[j] - j;
		else if (j == n - 1 && ta[j] == 0)cnt += ta[j] + n * 2 - j;
		else cnt += ta[j] + n - j;
		if (cnt > ka) {
			cnt = cnt2;
			break;
		}
		j = ta[j];
	}
	for (int i = cnt; i < ka;) {
		int c = 0;
		if ((i%n) + 1 < ta[i%n])c = ta[i%n] - (i % n);
		else if ((i%n) == n - 1 && ta[i%n] == 0)c = ta[i%n] + 2 * n - i % n;
		else c = ta[i%n] + n - i % n;
		if (i + c <= ka)i += c;
		else {
			ans.push_back(a[i%n]);
			i++;
		}
	}
	for (int i = 0; i < (int)ans.size(); i++) {
		if (i != (int)ans.size() - 1)cout << ans[i] << " ";
		else cout << ans[i] << endl;
	}
}

Measured memory_bytes: 7920
A,V=map(float,input().split())
B,W=map(float,input().split())
T=int(input())
if A==B:
    print('YES')
if A<B:
    if A+V*T>=B+W*T:
        print('YES')
    else:
        print('NO')
if B<A:
    if A-V*T<=B-W*T:
        print('YES')
    else:
        print('NO')
    

Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    string s; cin >> s;
    int k; cin >> k;
    set<string> st;
    for(int i=0; i<s.size(); ++i){
        for(int j=1; j<=k && i+j<=s.size(); ++j){
            string ss=s.substr(i, j);
            st.insert(ss);
        }
    }
    for(int i=0; i<k-1; ++i){
        st.erase(st.begin());
    }
    cout << *st.begin() << endl;
    return 0;
}


Measured memory_bytes: 1664
// AOJ 1542: Yu-kun Likes Letters in the English Alphabet
// 2019.2.23 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX 100003
char a[MAX]; int p[MAX];
int hi[MAX], *to[MAX];
int V, E;

int leastBit(int pat)
{
	int i = 0, a = 1;
	while (pat & a) i++, a <<= 1;
	return i;
}

int main()
{
	int i, j, f, s, t;
	int *memo, sz;

	V = in(), E = in(), f = 0;
	for (i = 0; i < V; i++) {
		j = gc(), gc();
		if (j != '?') a[i] = j;
		else f++;
	}
	if (f == 0) goto Done;
	if (f == V && V == 0) {
		while (f--) pc('a');
		pc('\n');
		return 0;
	}

	memo = malloc(E * 2 * sizeof(int)), sz = 0;
	for (i = 0; i < E; i++) {
		memo[sz++] = s = in(), memo[sz++] = in();
		hi[s]++;
	}
	for (i = 0; i < V; i++) if (hi[i]) to[i] = malloc(hi[i] * sizeof(int));

	memset(hi, 0, V * sizeof(int));
	sz = 0;
	for (i = 0; i < E; i++) {
		s = memo[sz++], t = memo[sz++];
		if (a[s]) p[t] |= 1 << (a[s] - 'a');
		if (a[t]) p[s] |= 1 << (a[t] - 'a');
		to[s][hi[s]++] = t;
	}
	free(memo);

	for (i = 0; i < V; i++) {
		if (a[i] == 0) a[i] = 'a' + leastBit(p[i]);
		for (j = 0; j < hi[i]; j++) p[to[i][j]] |= 1 << (a[i] - 'a');
	}

Done:
	for (i = 0; i < V; i++) pc(a[i]);
	pc('\n');
	return 0;
}


Measured memory_bytes: 7744
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k <= a + b) {
		cout << min(k, a) << endl;
	}
	else {
		cout << a - (k - a - b) << endl;
	}
}


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

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

    int n, m;
    cin >> n >> m;

    vector<int> cand;
    map<int, int> one;
    map<int, int> two;

    rep(i, m){
        int a, b;
        cin >> a >> b;

        if(a==1) {
            ++one[b];
            cand.push_back(b);
        }
        if(b==n) ++two[a];
    }

    for (int num: cand){
        if(two[num] > 0){
            puts("POSSIBLE");
            return 0;
        }
    }

    puts("IMPOSSIBLE");
    return 0;
}

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

int main(){
  string s;
  int cnt = 0;
  cin >> s;
  for(int i = 0 ; i < s.size() ; i++)
    if(s[i] == 'x') cnt++;
  
  if(cnt >= 8) cout << "NO\n";
  else cout << "YES\n";
  return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long a, b;
	cin >> a >> b;
	if (a == b) cout << "IMPOSSIBLE\n";
	else if ((a % 2 == 0 && b % 2 != 0) || (a % 2 != 0 && b % 2 == 0)) cout << "IMPOSSIBLE\n";
	else cout << (a + b) / 2 << '\n'; 
	return 0;
}

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

int T,n,m,i,j,k,s;

int main(){
	scanf("%d",&T);
	while (T--){
		scanf("%d%d",&n,&m);
		while (n>=m){
			k=(n/m+1),n-=n%m/k*k;
			if (n%m==0) break;
			else n-=k;
		}
		if (n>=m) s^=n/m;
	}
	if (s) printf("Takahashi");
	else printf("Aoki");
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}
	vector<int>flag(n + 1,0);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (flag[i])continue;
		if (i == v[v[i]]) {
			ans++;
			flag[i] = flag[v[i]] = true;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
// B: Maximum Sum
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "3 3 4\n2"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();

const process = inputRaw => {
  const inputs = inputRaw.split("\n");
  const integerList = inputs[0].split(" ").map(item => parseInt(item));
  const K = inputs[1];
  let max = Math.max.apply(Math, integerList);
  let maxIndex = integerList.indexOf(max);

  for (let i = 0; i < K; i++) {
    max = 2 * max;
  }

  console.log(
    integerList.reduce(
      (acc, curr, index) => acc + (index === maxIndex ? max : curr),
      0
    )
  );
};

process(rawInput);


Measured memory_bytes: 7372
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    c = sorted([[k, v] for k, v in c.items() if v > 1])
    if len(c) < 2:
        print(0)
        return
    if c[-1][1] >= 4:
        print(c[-1][0] ** 2)
    else:
        print(c[-1][0] * c[-2][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 18600
#include<stdio.h>
#include<ctype.h>

int main()
{
	int a;
	scanf("%d",&a);
	char b[a];
	int k;
	scanf("%d",&k);
	int i;
	/*for(i=0;i<a;i++){

		scanf("%c",&b[i]);
	}
	for(i=0;i<a;i++){
		printf("%c",b[i]);
	}*/

	scanf("%s",b);
	//tolower(b[k-1]);
	for(i=0;i<a;i++){
		if(i==k-1){
			putchar(tolower(b[i]));
		}
		else{
			putchar(b[i]);
		}
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#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(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
vector<ll>dp(100010,-1);
ll f(ll n){
  if(n==0)return 0;
  if(dp[n]!=-1)return dp[n];
  ll r=INF;
  for(int pow6=1;pow6<=n;pow6*=6)r=min(r,f(n-pow6)+1);
  for(int pow9=1;pow9<=n;pow9*=9)r=min(r,f(n-pow9)+1);
  return dp[n]=r;
}
int solve(){
  int n;
  cin>>n;
  cout<<f(n)<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
int n;
std::string s;

int main()
{
    std::cin >> s;
    n = s.size();
    long long ans = 0;

    for(int bit = 0; bit < (1 << n); bit++){
        long long num = 0;
        std::string cur;
        for(int i = 0; i < n; i++){
            cur.push_back(s[i]);
            if(bit & (1 << i)){
                num += std::stol(cur);
                cur = {};
            }
        }
        if(cur.size() != 0)num += std::stol(cur);
        ans += num;
    }
    std::cout << ans / 2 << std::endl;
}

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

int main()
{
  int n;
  vector<int> v;
  cin >> n;
  for(int i = 0; i < 4; i++)
  {
    int t = n % 10;
    v.push_back(t);
    n /= 10;
  }
  if((v[0]==v[1] && v[1]==v[2]) ||
    (v[1]==v[2]) && v[2]==v[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;

    ll ans = (n-m)*100+m*1900;
    ans *= (1<<m);

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

Measured memory_bytes: 256
h,w,k=map(int,input().split())
s=[list(input())for _ in range(h)]
g=1
for i in range(h):
    for j in range(w):
        if s[i][j]!='#':continue
        s[i][j]=g
        k=j-1
        while k>=0 and s[i][k]=='.':
            s[i][k]=g
            k-=1
        k=j+1
        while k<w and s[i][k]=='.':
            s[i][k]=g
            k+=1
        g+=1
for i in range(h-2,-1,-1):
    if s[i][0]=='.':
        for j in range(w):
            s[i][j]=s[i+1][j]
for i in range(h):
    if s[i][0]=='.':
        for j in range(w):
            s[i][j]=s[i-1][j]
for t in s:
    print(*t)

Measured memory_bytes: 50908
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};
typedef Point Vector;

struct Circle{
	Point center;
	double r;
};

double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}


int main(){

	Circle c1,c2;

	scanf("%lf %lf %lf",&c1.center.x,&c1.center.y,&c1.r);
	scanf("%lf %lf %lf",&c2.center.x,&c2.center.y,&c2.r);

	vector<Point> ans = getCrossPoints(c1,c2);

	if((ans[0].x > ans[1].x) || (fabs(ans[0].x-ans[1].x) < EPS && ans[0].y > ans[1].y)){
		swap(ans[0],ans[1]);
	}

	printf("%.10lf %.10lf %.10lf %.10lf\n",ans[0].x,ans[0].y,ans[1].x,ans[1].y);

	return 0;
}



Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main() {
	int W, H, x, y, r = 0;
	cin >> W >> H >> x >> y >> r;
	if (x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
  int l,n;
  cin >> l>>n;
  int a,b;
  int c=0;
  int x[50000],w[50000];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    c+=a*b;
  }
  int f=0;
  if(c<0){
    c*=-1;
    f=1;
  }
  int k=0;
  if(c!=0)
    while(1){
      if(c<50000){
	w[k]=c;
	x[k]=1;
	k++;
	break;
      }
      else{
	w[k]=50000;
	x[k]=1;
	k++;
	c-=50000;
	continue;
      }
      break;
    }
  cout << k << endl;
  for(int i=0;i<k;i++){
    if(f==1)x[i]*=-1;
    cout << x[i]*-1 <<" "<< w[i]<< endl;
  }
  return 0;
}

Measured memory_bytes: 3112
using System;
 
public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		double n, k;
		n = double.Parse(s[0]);
		k = double.Parse(s[1]);
		
	    double x = Math.Floor(n/k);
		double y = Math.Floor(n/k - 0.5) + 1;
	    long z;
		
		if (k%2 == 1){
			z = (long)Math.Pow(x,3);
		} else {
			z = (long)Math.Pow(x,3) +(long)Math.Pow(y,3);
		}
		Console.WriteLine(z);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define DEBUG(X) cerr << X << " (" << __LINE__ << ", " << __func__ << " )" << endl;

typedef long long ll;
using namespace std;

int main() {
	cin.tie(0); //?????±?????????????????????
	ios::sync_with_stdio(false); //printf??¨??±??????????????????
	string str;
	while (getline(cin, str)) {
		for (int i = -26; i <= 26; i++) {
			string newstr = str;
			for (int j = 0; j < str.size(); j++) {
				if ('a' <= newstr[j] && newstr[j] <= 'z') {
					newstr[j] = str[j] + i;
					if (newstr[j] < 'a') {
						newstr[j] -= 'a';
						newstr[j] += 123;
					} else if (newstr[j] > 'z') {
						newstr[j] -= 'z' + 1;
						newstr[j] += 'a';
					}
				}
			}
			//cerr << newstr << endl;
			if (newstr.find("the", 0) != string::npos ||
					newstr.find("this", 0) != string::npos ||
					newstr.find("that", 0) != string::npos) {
				cout << newstr << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int A, B;

	std::cin >> A >> B;

	if ((A+B) % 2 == 1) {
		std::cout << "IMPOSSIBLE\n";
	} else {
		std::cout << ((A + B) / 2) << "\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N;
  string ans;
  ans = "No";
  cin >> N;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == N){
        ans = "Yes";
        break;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int l;
  cin >> l;
  ll a[l];
  rep(i,l)cin >> a[i];
  ll b[l][5];
  rep(i,l){
    b[i][0]=a[i];
    b[i][4]=a[i];
    if(a[i]==0){
      b[i][1]=2;
      b[i][2]=1;
      b[i][3]=2;
    }
    else{
      b[i][1]=a[i]%2;
      b[i][3]=a[i]%2;
      b[i][2]=(a[i]+1)%2;
    }
  }
  ll dp[l+1][5];
  rep(i,l+1){
    rep(j,5)dp[i][j]=inf;
  }
  dp[0][0]=0;
  rep(i,l+1){
    rep(j,4)dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
    if(i!=l){
      rep(j,5)dp[i+1][j]=dp[i][j]+b[i][j];
    }
  }
  cout << dp[l][4] << endl;
}


Measured memory_bytes: 20820