akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    int k; string s , tmp;
    cin >> k >> s;
    if(k >= s.size()) cout << s << endl;
    else {
        tmp = s.substr(0 , k);
        rep(i , 3){
            tmp += '.'; 
        }
        cout << tmp << endl;
    }
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
li = [0] * M

for i in range(M):
    P, Y = map(int, input().split())
    li[i] = (P, Y)

li2 = sorted(li)

s = '000000'
tmp = 0
cnt = 1
dic = {}
for i in li2:
    if tmp == i[0]:
        cnt += 1
    else:
        cnt = 1
        tmp = i[0]

    s1 = s[0:6-len(str(i[0]))] + str(i[0])
    s2 = s[0:6-len(str(cnt))] + str(cnt)
    s3 = s1 + s2
    dic[i] = s3

for i in li:
    print(dic[i])


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

int main() {
  int n;
  cin>>n;
  priority_queue<double, vector<double>, greater<double>> nabe;
  for(int i=0; i<n; i++) {
    double v;
    cin>>v;
    nabe.push(v);
  }

  while(nabe.size()>1) {
    double a,b;
    a = nabe.top();
    nabe.pop();
    b = nabe.top();
    nabe.pop();
    nabe.push((a+b)/2);
  }

  double ans = nabe.top();

  cout<<fixed<<setprecision(10)<<ans<<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>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int v[100001];
int n;
long long  dp[100001][2];
long long go(int i,int pre)
{
    if(i==n-1){
        if(pre==0)
            return v[i];
        else
            return -v[i];
    }
    if(dp[i][pre]!=-1)
        return dp[i][pre];
    else
    {
            {  if(pre==0)
                dp[i][pre]=max(v[i]+go(i+1,0),-v[i]+go(i+1,1));
               if(pre==1) 
                  dp[i][pre]=max(v[i]+go(i+1,1),-v[i]+go(i+1,0));
                return dp[i][pre];
            }     
    }
}

int main() {
    off;
  
    int t;
    //cin>>t;
    t=1;
    while(t--){    
        cin>>n;
        memset(dp,-1,sizeof(dp));
        for(int i=0;i<n;i++)
            cin>>v[i];
         cout<<max(v[0]+go(1,0),-v[0]+go(1,1))<<'\n';          
    }
      return 0;
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var sum1 = a1[0];
            var sum2 = a2.Sum();
            var now = sum1 + sum2;
            var ans = sum1 + sum2;

            for(int i = 0; i < n - 1; i++)
            {
                now = now + a1[i + 1] - a2[i];
                if(now > ans)
                {
                    ans = now;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len,tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> >tree)
    :tree(tree),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
    len=vector<vector<int> >(pathCount);

    REP(i,pathCount){
      int m=pathSize[i];
      len[i].resize(2*m);
      fill(ALL(len[i]),0);
      fill(len[i].begin()+m,len[i].begin()+2*m,1);
      for(int j=2*m-1;j>1;j-=2)len[i][j>>1]=len[i][j]+len[i][j^1];
    }
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll N; cin >> N;
    if (N%2 == 1) cout << 0;
    else {
        ll two = 0, five = 0;
        for (int i = 0; (N>>i); ++i) {
            two += (N>>i);
        }
        ll f = 10;
        for (; N >= f; f *= 5) {
            five += N/f;
        }
        cout << min(two,five);
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int cnt = 0;
   int grid[5];
   for(int i = 0; i < 5; i++){
      cin >> grid[i];
   }
   int k;
   cin >> k;

   for(int i = 0; i < 5; i++){
      for(int j = i+1; j < 5; j++){
         if(abs(grid[i] - grid[j]) > k){
            cout << ":(" << endl;
            return 0;
         }
      }
   }
   cout << "Yay!" << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=p.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3604
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=(u+i*d)%2019
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)

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

using namespace std;

int main(){
    int H,W,K,n,cnt,m;
    char map[6][6];
    
    cin >> H >> W >> K;
    cnt = 0;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cin >> map[i][j];
            if(map[i][j] == '#') cnt++;
        }
    }

    m = 0;
    for(int i = 0;i < (1 << H);i++){
        for(int j = 0;j < (1 << W);j++){
            n = 0;
            bitset<6> b1(i);
            bitset<6> b2(j);
            for(int k = 0;k < H;k++){
                for(int l = 0;l < W;l++){
                    if(b1.test(k) || b2.test(l)){
                        if(map[k][l] == '#'){
                            n++;
                        }
                    }
                }
            }
            if(cnt - n == K){
                m++;
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int m;

vector<pair<int, int>> a;

void input() {
  cin >> n >> m;

  a.resize(n);
  for (auto&& i: a) {
    cin >> i.first >> i.second;
  }
}

void solve() {
  sort(a.begin(), a.end());

  int cur = 0;
  int i = 0;
  ll ans = 0;

  while (cur < m) {
    int can = min(m - cur, a[i].second);

    cur += can;
    ans += 1ll * can * a[i++].first;
  }

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


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

namespace Competitive
{
    internal class Solution
    {
        public string S;
        public long K;
        public void Run()
        {
            S = Console.ReadLine();
            K = Input.ReadLong();

            for (int i = 0; i < K; i++)
            {
                if (S[i] != '1')
                {
                    Console.WriteLine(S[i]);
                    return;
                }
            }

            Console.WriteLine("1");
            return;
        }
    }

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


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

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

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

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

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

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

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

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
S = int(input())
a = 0
count = 0
n,m = map(int,input().split())
while count == 0:
    a += S
    if n <= a and m >= a:
        count = 1
    if a >= 1000:
        break
if count == 0:
    print("NG")
else:
    print("OK")

Measured memory_bytes: 61660
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e9 + 7, M = 1e9 + 7, P = 769, sq = 360, lg = 26;
typedef pair <int, int> pii;
map <string, int> mp;

int32_t main() {	
	int n;
	cin >> n;
	set <string> st;
	int mx = 0;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		st.insert(s);
		mp[s]++;
		mx = max(mx, mp[s]);
	}
	set <string> ans;
	for(auto u : st) 
		if(mp[u] == mx)
			ans.insert(u);
	for(auto u : ans)
		cout << u << endl;
	return 0;	
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 43904
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,t,p,o,a[200001],b[200011];
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    
    for(j=0;j<k;j++)
    {
        memset(b,0,sizeof(b));
        for(i=1;i<=n;i++)
        {
           ll l=max(1LL,i-a[i]),h=min(n,i+a[i]);
           b[l]++;
           b[h+1]--;
        }
        for(i=1;i<=n;i++)
        {
            b[i]+=b[i-1];
        }
        ll flag=1;
        for(i=1;i<=n;i++)
        {
            a[i]=b[i];
            if(a[i]!=n)
            {
                flag=0;
            }
        }
        if(flag)
        {
            break;
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t x;
  std::cin >> x;
  int ret = INT_MAX;
  while (x >= 100) {
    ret = std::min(ret, abs(753 - int(x % 1000)));
    x /= 10;
  }
  std::cout << ret;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')
if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int M;
int X;
int Y;
int x[101];
int y[101];
int main(){
  rd(N);
  rd(M);
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(x[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<M;KL2GvlyY++){
      rd(y[KL2GvlyY]);
    }
  }
  {
    int Q5VJL1cS, e98WHCEY;
    if(N==0){
      e98WHCEY = 0;
    }
    else{
      e98WHCEY = x[0];
      for(Q5VJL1cS=1;Q5VJL1cS<N;Q5VJL1cS++){
        e98WHCEY = max_L(e98WHCEY, x[Q5VJL1cS]);
      }
    }
    chmax(X,e98WHCEY);
  }
  {
    int RZTsC2BF, cTE1_r3A;
    if(M==0){
      RZTsC2BF = 0;
    }
    else{
      RZTsC2BF = y[0];
      for(cTE1_r3A=1;cTE1_r3A<M;cTE1_r3A++){
        RZTsC2BF = min_L(RZTsC2BF, y[cTE1_r3A]);
      }
    }
    chmin(Y,RZTsC2BF);
  }
  if(X<Y){
    wt_L("No War");
    wt_L('\n');
  }
  else{
    wt_L("War");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, M, X, Y, x[101], y[101];
// {
//   rd(N,M,X,Y,x(N),y(M));
//   X >?= max(x(N));
//   Y <?= min(y(M));
//   wt( if[X<Y, "No War", "War"] );
// }


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    string s;
    cin >> s;
    ll size = s.size();
    set<char> st;
    rep(i,size) st.insert(s[i]);
    if(size==st.size()){
        cout << "yes" << "\n";
    }else{
        cout << "no" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int main()
{
    int n; cin>>n;
    int a[301];
    int s[301]; s[0]=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    int dp[2][2][2][90001]={};
    dp[0][0][0][0]=1;
    for(int i=0; i<n; i++){
      for(int j=0; j<2; j++){
        for(int k=0; k<2; k++){
          fill(dp[j][k][(i+1)&1], dp[j][k][(i+1)&1]+s[i+1]+1, 0);
        }
      }
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                for(int l=0; l<=s[i]; l++){
                    dp[1][k][(i+1)&1][l]+=dp[j][k][i&1][l];
                    dp[1][k][(i+1)&1][l]%=MOD;
                    dp[j][1][(i+1)&1][l]+=dp[j][k][i&1][l];
                    dp[j][1][(i+1)&1][l]%=MOD;
                    dp[j][k][(i+1)&1][l+a[i]]+=dp[j][k][i&1][l];
                    dp[j][k][(i+1)&1][l+a[i]]%=MOD;
                }
            }
        }
    }
    ll ans=1;
    for(int i=0; i<n; i++) ans*=3, ans%=MOD;
    ll p2=1;
    for(int i=0; i<n; i++) p2*=2, p2%=MOD;
    ans=(ans-3*p2%MOD+3+MOD)%MOD;
    for(int i=(s[n]+1)/2; i<=s[n]; i++){
        ans=(ans-3*(ll)dp[1][1][n&1][i]%MOD+MOD)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3072
inp=list(map(int,input().split()))
n=inp[0]
arr=[]
for i in range(n):
  inp=list(map(int,input().split()))
  arr.append(inp)
ans=0
for i in range(len(arr)):
  for j in range(i+1,len(arr)):
    x=0
    for k in range(len(arr[0])):
      x+=(arr[i][k]-arr[j][k])**2
    z=int(pow(x,0.5))
    if z**2==x:
      ans+=1
print (ans)

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int h, w, k;

int main() {
    cin >> h >> w >> k;
    k--;
    vector<vector<ll>> cur_count(h, vector<ll>(w, 0));
    cur_count[0][0] = 0;
    for (int i = 0; i < 1 << (w - 1); i++) {
        bool valid = true;
        for (int k = 0; k < w - 2; k++) {
            if ((i >> k & 1) && (i >> (k + 1) & 1)) {
                valid = false;
                break;
            }
        }
        if (!valid)
            continue;
        if (i & 1) {
            cur_count[0][1]++;
        } else {
            cur_count[0][0]++;
        }
    }
    for (int l = 1; l < h; l++) {
        for (int m = 0; m < w; m++) {
            for (int i = 0; i < 1 << (w - 1); i++) {
                bool valid = true;
                for (int k = 0; k < w - 2; k++) {
                    if ((i >> k & 1) && (i >> (k + 1) & 1)) {
                        valid = false;
                        break;
                    }
                }
                if (!valid)
                    continue;
                if (m > 0 && (i >> (m - 1) & 1)) {
                    cur_count[l][m] += cur_count[l - 1][m - 1] % MOD;
                } else if (m < w - 1 && (i >> m & 1)) {
                    cur_count[l][m] += cur_count[l - 1][m + 1] % MOD;
                } else {
                    cur_count[l][m] += cur_count[l - 1][m] % MOD;
                }
                cur_count[l][m] %= MOD;
            }
        }
    }
    cout << cur_count[h - 1][k];
    return 0;
}


Measured memory_bytes: 256
a_1 = gets.split.map(&:to_i)
a_2 = gets.split.map(&:to_i)
a_3 = gets.split.map(&:to_i)
n = gets.to_i
b = []
n.times do
  b << gets.to_i
end
c = b.sort.combination(3).to_a

a = [a_1.sort, a_2.sort, a_3.sort, [a_1[0], a_2[1], a_3[2]].sort, [a_1[2], a_2[1], a_3[0]].sort]

(0..2).each { |i| a << [a_1[i], a_2[i], a_3[i]].sort }

puts (a & c).size >= 1 ? "Yes" : "No"

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

class Program
{
    public static void Main()
    {
        var n = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var right = n[2] - n[0] - n[1];
        var ans = ( 0< right) && (right*right-n[0]*n[1]*4 > 0) ? "Yes" : "No";
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define SZ(v) ((int)(v).size())

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

int main(){
	char s[11], t[11], u[11];
	scanf("%s%s%s", s, t, u);
	printf("%c%c%c\n", s[0]-'a'+'A', t[0]-'a'+'A', u[0]-'a'+'A');
	return 0;
}

Measured memory_bytes: 256
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

S = str(input())
T = str(input())
ans = 0
for i in range(len(S)):
    if S[i] == T[i]:
        ans += 1
print(ans)


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll s, w;
  cin >> s >> w;
  if(w >= s) cout  <<"unsafe";
  else cout << "safe";
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> M(6);
  vector<int> n(4);
  int d;
  
  for (int i = 0; i < 6; i++){
      cin >> M.at(i);
  }
  for (int i = 0; i < 4; i++){
  	n.at(i) = count(M.begin(),M.end(),i+1);
  }
 
  d = count(n.begin(), n.end(), 2);
  if (d == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 256
N = int(input())
A = N // 1000
B = (N // 100) - (A * 10)
C = (N // 10) - (A * 100) - (B * 10)
D = N - (A * 1000) - (B * 100) - (C * 10)

op_1 = 0
op_2 = 0
op_3 = 0

def printplus_minus(i):
	if i == 0:
		return"-"
	elif i == 1:
		return"+"
	else:
		return"Bug"
		
for i in range(2):
	for j in range(2):
		for k in range(2):
			NUM = A + B*((-1) ** (i + 1)) + C * ((-1) ** (j+1)) + D*((-1) ** (k + 1))
			if NUM == 7:
				op_1 = i
				op_2 = j
				op_3 = k
		
				

		
print(str(A)+printplus_minus(op_1)+str(B)+printplus_minus(op_2)+str(C)+printplus_minus(op_3)+str(D)+"=7")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
A,B,K = map(int, input().split())

if A>K:
	print('{} {}'.format(A-K,B))
else:
	if K-A<B:
		print('{} {}'.format(0,B-(K-A)))
	else:
		print('{} {}'.format(0,0))

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n,m;
string f;

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>f;
		cout<<f<<endl<<f<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

x = map(int, input().split())    
y = map(int, input().split())

tmp_x = 0
tmp_y = 0
mod = 10**9+7
for i, xi in enumerate(x):
    tmp_x += (xi+1)*(2*i-(n-1))
    
tmp_x = tmp_x % mod

for i, yi in enumerate(y):
    tmp_y += (yi+1)*(2*i-(m-1))
    
tmp_y = tmp_y % mod

print((tmp_x*tmp_y)%mod)


Measured memory_bytes: 19452
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

ll n;
ll k;
ll ans = 0;
string s;

void solve(ll i, ll y)
{
    if(i == n+1)
    {

            ans += y;

        return ;
    }
    ll cur = 0;
    for(int j=i; j<=n; j++)
    {
        cur = (10*cur) + (s[j] - '0');
        solve(j+1, y + cur);
    }
}

int main()
{
    //freopen("EXP.inp","r",stdin);
    //freopen("EXP.out","w",stdout);
    cin >> s;
    n = s.size();
    s = ' ' + s;
    solve(1, 0);
    cout << ans;

}


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

int n, m;
char s[100005];
char t[100005];
int dn, dm;

int main(){
    scanf("%d%d", &n, &m);
    int gcd = __gcd(n, m);
    dn = m / gcd; dm = n / gcd;
    scanf("%s", s);
    scanf("%s", t);
    int ii = 0, jj = 0;
    while(ii < n || jj < m){
        if(ii * dn == jj * dm){
            if(s[ii] != t[jj]){
                printf("-1\n");
                return 0;
            }
            ii++; jj++;
        }else if(ii * dn > jj * dm){
            jj++;
        }else{
            ii++;
        }
    }
    long long ans = n; ans *= m; ans /= gcd;
    printf("%lld\n", ans);
}


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

using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    
    int i = 0, lbn = 0;
    
    while (i < s.length()) {
        if (s[i] == '(') {
            lbn++;
        } else {
            if (lbn > 0) {
                lbn--;
            } else {
                s = '(' + s;
                i++;
            }
        }
        i++;
    }
    for (int i = 0; i < lbn; ++i) s += ')';
    
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
multiset<ll> med1, med2;

int main() {
	int q, cnt=0; ni(q);
	ll bsm = 0, lo = 0, hi = 0;
	while (q--) {
		int t; ni(t);
		if (t == 1) {
			ll a, b; scanf("%lld %lld", &a, &b);
			cnt++;
			bsm += b;
			if (med1.empty() || a <= *med1.rbegin()) {
				lo += a;
				med1.insert(a);
			} else {
				hi += a;
				med2.insert(a);
			}
			while (med1.size() > med2.size() + 1) {
				lo -= *med1.rbegin();
				hi += *med1.rbegin();
				med2.insert(*med1.rbegin());
				med1.erase(--med1.end());
			}
			while (med2.size() > med1.size()) {
				lo += *med2.begin();
				hi -= *med2.begin();
				med1.insert(*med2.begin());
				med2.erase(med2.begin());
			}
		} else {
			printf("%lld %lld\n", *med1.rbegin(), bsm + hi - lo + (ll)((ll)med1.size() - (ll)med2.size()) * *med1.rbegin());
		}
	}
    return 0;
}


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

#define MAXH (810)

int h, w, k, sx, sy;
int ans, dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
char str[MAXH][MAXH];
int dis[MAXH][MAXH];

void bfs(){
	std::queue<std::pair<int, int> > queue;
	memset(dis, -1, sizeof(dis));
	dis[sx][sy] = 0;
	queue.push({sx, sy});
	while(!queue.empty()){
		int x = queue.front().first, y = queue.front().second;
		queue.pop();
		for(int i = 0; i < 4; ++ i){
			int dx = x + dir[i][0], dy = y + dir[i][1];
			if(dx < 1 || dx > h || dy < 1 || dy > w || ~dis[dx][dy] || str[dx][dy] == '#') continue;
			dis[dx][dy] = dis[x][y] + 1;
			if(dis[dx][dy] <= k){
				queue.push({dx, dy});
				ans = std::min(ans, (std::min(std::min(dx - 1, h - dx), std::min(dy - 1, w - dy)) + k - 1) / k + 1);
			}
		}
	}
}

int main(){
	scanf("%d%d%d", &h, &w, &k);
	for(int i = 1; i <= h; ++ i){
		scanf("%s", str[i] + 1);
		for(int j = 1; j <= w; ++ j){
			if(str[i][j] == 'S'){
				sx = i;
				sy = j;
			}
		}
	}
	ans = (std::min(std::min(sx - 1, h - sx), std::min(sy - 1, w - sy)) + k - 1) / k + 1;
	bfs();
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  int left = a + b;
  int right = c + d;

  if (left > right) {
    cout << "Left" << endl;
    return 0;
  }

  if (left < right) {
    cout << "Right" << endl;
    return 0;
  }

  cout << "Balanced" << endl;
}


Measured memory_bytes: 256
from sys import stdin

if __name__ == '__main__':
    A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
    if A == B and A != C:
        print("Yes")
    elif A == C and A != B:
        print("Yes")
    elif B == C and B != A:
        print('Yes')
    else:
        print("No")

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

typedef long long ll;
using namespace std;

int main()
{
    int N, x, y, tmp;
    cin >> N;
    vector <int> A(N, 0), B(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A[i] = tmp;
        B[i] = tmp;
    }

    sort(A.begin(), A.end());
    x = A[N/2-1];
    y = A[N/2];

    for (int i = 0; i < N; i++) {
        if (B[i] <= x) cout << y << endl;
        else cout << x << endl;
    }
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

int n,x,y;
int all[20005];

int main () {

    cin >> n >> x >> y;

    for (int i = 1; i <= n; i++) all[i] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dist1 = abs(j-i);
            int dist2 = abs(x - i) + 1 + abs(j - y);
            int min_dist = min(dist1, dist2);
            all[min_dist]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << all[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    string S;
    int N,num = 0,mx = 0;
    cin >> N >> S;
    for(char c:S){
        if(c=='I')num++;
        else num--;
        mx = max(mx,num);
    }
    cout << mx << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')'<<' ';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define OUTP(x) cout<<'('<<x.first<<','<<x.second<<')'<<endl;
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),ALL(b));}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  int N,M;cin>>N>>M;
  vector<bool> qs(N, false);
  vector<int> ws(N, 0);
  REP(i,M) {
    int p;string S;cin>>p>>S;
    if (S=="AC") qs[p-1] = true;
    else {
      if (!qs[p-1]) ws[p-1]++;
    }
  }
  int pen = 0;
  REP(i,N) if (qs[i]) pen += ws[i];
  cout<<count(ALL(qs), true)<<' '<<pen<<endl;

  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    int mam = 0;
    cin >> a >> b >> c;
    mam = max(max(a,b) ,c);
    if((mam*3 - a - b - c) % 2 == 1) mam++;
    cout << (mam * 3 - a - b - c) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  vector<int> v=input(n);
  
  int sum1=0;
  rep(i,n){
    sum1 += v[i];
  }
  
  int sum2=0,ans=10000;
  rep(i,n){
    sum2 += v[i];
    ans = min({abs(2*sum2-sum1),ans});
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> A(N,-1);
//  S += S;
  int cmax = 0;
  for( int cntm= N / 2; cntm >0; --cntm ) {
    if ( cmax == cntm ) {
      cout << cmax << endl;
      return 0;
    }
    for ( int i=cntm; i<N-cntm+1; ++i ) {
      if ( A[i] != -1 ) continue;
      int cnt = 0;
      for ( int j=0; j<N-i; ++j ) {
//        printf("%d %d %d %c %c\n",cntm, i, j, S[j], S[i+j] );
        if (S[j] == S[i+j]) {
          cnt++;
          if( cnt == cntm ) {
            cout << cntm << endl;
            return 0;
          }
          cmax = max( cmax, cnt );
        } else {
          cnt = 0;
        }
      }
      A[i] = cmax;
    }
  }
  cout << "0" << endl;
}


Measured memory_bytes: 384
n,m,c=map(int,input().split())
a=[]
for i in range(n+1):  
  a.append(list(map(int,input().split())) )
y=0
for i in range(n):
  x=0  
  for j in range(m):
    x+=a[i+1][j]*a[0][j]
  if x+c>0:
    y+=1
print(y)

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int x;
	cin >> x;
	if(x < 1200)
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string s;
    cin >> s;
    int d = s.size();
    FOR(i, 1, d-1) {
        if(s[i] != '9') {
            cout << s[0]-'0' - 1 + 9*(d-1) << endl;
            return 0;
        }
    }
    cout << s[0]-'0' + 9*(d-1) << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> w(n);
  for (int i=0 ; i<n ; i++)
    cin >> w.at(i);
  
  int ans = 1;
  for (int i=0 ; i<n-1 ; i++){
    for (int j=i+1 ; j<n ; j++){
      if (w.at(i) == w.at(j)){
        ans = 0;
        break;
      }
    }
    if (w.at(i).at(w.at(i).size()-1) != w.at(i+1).at(0))
      ans = 0;
    if (ans == 0)
      break;
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    rep(i,26){
        rep(j,16){
            if(4*i+7*j==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;
vector<int> a;
vector<vector<int> > memo;

int solve(int turn, int k)
{
	if(memo[turn][k] != -1)
		return memo[turn][k];

	int n = a.size();
	int ans = abs(a[k] - a[n-1]);
	if (turn == 0) {
		for(int i=k+1; i<n-1; ++i)
			ans = max(ans, solve(1, i));
	}
	else{
		for(int i=k+1; i<n-1; ++i)
			ans = min(ans, solve(1, i));
	}
	return memo[turn][k] = ans;
}

int main()
{
	int n;
	cin >> n;
	a.resize(n+2);
	for(int i=0; i<n+2; ++i)
		cin >> a[i];

	memo.assign(2, vector<int>(n+2, -1));
	cout << solve(0, 1) << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

const int MN=500000;
int N,K;
int a[MN],b[MN];
vector<int> G[MN];
int deg[MN];
int ans[MN];

void add_edge(int a,int b){
//	printf("%d->%d\n",a,b);
	G[a].pb(b);
	deg[b]++;
}
int main(){
	cin>>N>>K;
	rep(i,N){
		cin>>a[i];
		a[i]--;
		b[a[i]]=i;
	}
	typedef pair<int,int> P;
	set<P> st;
	rep(i,N){
		P p(a[i],i);
		st.insert(p);
		if(i>=K){
			st.erase(P(a[i-K],i-K));
		}
		auto it = st.lower_bound(p);
		if(it!=st.begin()){
			it--;
			int l = it->sc;
			add_edge(i,l);
			it++;
		}
		it++;
		if(it!=st.end()){
			int r = it->sc;
			add_edge(r,i);
		}
	}
	priority_queue<int> que;
	rep(i,N) if(deg[i]==0) que.push(i);
	rep(t,N){
		int v = que.top();que.pop();
		ans[v]=N-1-t;
		for(int u:G[v]){
			deg[u]--;
			if(deg[u]==0) que.push(u);
		}
	}
	rep(i,N) cout<<ans[i]+1<<endl;
}


Measured memory_bytes: 62720
# 2019-11-14 20:54:46(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def main():
    a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    divisors = 0
    divisors += b // c - (a - 1) // c
    divisors += b // d - (a - 1) // d
    l = lcm(c, d)
    divisors -= b // l - (a - 1) // l
    ans = b - (a - 1) - divisors
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0) cout<<s[i];
    }
    cout<<endl;
}

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

if 25*(A+1)/2 <= 10*B or 10*(B+1) <= 25*A/2:
    print(-1)
else:
    for i in range(10*B,10*(B+1)):
        if 25*A <= 2*i < 25*(A+1):
            print(i)
            break

Measured memory_bytes: 3064
n,m=map(int,input().split())

if abs(n-m)>=2:
    print(0)
else:
    nm=1
    p=10**9+7
    for ni in range(1,n+1):
        nm=nm*ni%p
    for ni in range(1,m+1):
        nm=nm*ni%p
    if abs(n-m)==1:
        print(nm)
    else:
        print((2*nm)%p)

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

int main() {
  vector<int> num(31);
  int n;
  for (int i = 0; i < 28; i++) {
    cin >> n;
    num[n]++;
  }
  for (int i = 1; i <= 30; i++) if (!num[i]) cout << i << endl;
  return 0;
}


Measured memory_bytes: 3116
s=[]
while True:
    tmp=list(map(str,input().split()))
    if tmp[1]=="?":
        break
    else:
        s.append(tmp)

for i in range(len(s)):
    a,b=int(s[i][0]),int(s[i][2])
    op=s[i][1]
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(a//b)
    


Measured memory_bytes: 5600
# coding: utf-8

n, k = map(int, input().split())

counts = []

for i in range(1, n+1):
    a = i
    count = 0
    while a < k:
        a *= 2
        count += 1
    counts.append(count)

result = 0


for count in counts:
    result += (1 / n ) * ((0.5) ** count)

print(result)


Measured memory_bytes: 3864
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
using namespace std;
#pragma warning(disable:4996)

int main()
{
	int n, m;
	cin >> n >> m;
	cout << fixed << setprecision(6) << 1.0*n / m;
}


Measured memory_bytes: 256