akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.charAt(0) != 'A') {
            System.out.println("WA");
            return;
        }

        int count = 0;
        int pos = -1;
        for (int i = 2; i <= s.length() - 2; i++) {
            if (s.charAt(i) == 'C') {
                count++;
                pos = i;
            }
        }
        if (count != 1) {
            System.out.println("WA");
            return;
        }
        s = s.substring(1, pos) + s.substring(pos + 1, s.length());

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) < 'a' || s.charAt(i) > 'z') {
                System.out.println("WA");
                return;
            }
        }

        System.out.println("AC");

    }
}


Measured memory_bytes: 21332
//https://atcoder.jp/contests/abc088/tasks/abc088_b
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans1=0,ans2=0,ans3;
	cin>>n;
	int c[n+1];
	for(int i=1; i<=n; i++){
		cin>>c[i];
	}
	sort(c+1,c+n+1);
	for(int x=1; x<=n; x++){
		if(x%2==0){
			ans2=ans2+c[x];
		}
		if(x%2==1){
			ans1=ans1+c[x];
		}
	}
	if(ans1>ans2){
		ans3=ans1-ans2;
	}
	if(ans2>ans1){
		ans3=ans2-ans1;
	}
	if(ans1==ans2){
		ans3=0;
	}
	cout<<ans3<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int n) {
  int ans = 111;
  for (int i = 1; i < 10; i++) {
    ans = 111 * i;
    if (n <= ans) {
      break;
    }
  }
  printf("%d\n", ans);
}

int main() {
  int n;
  cin >> n;
  solve(n);
  return 0;
}

Measured memory_bytes: 888
<?php
	fscanf( STDIN, "%d", $n );
	$shcd = array( 'S', 'H', 'C', 'D' );
	$cardSet = array();
	for( $i=0; $i<4; $i++ ) {
		for( $j=1; $j<=13; $j++ ) {
			array_push( $cardSet, $shcd[$i].' '.$j );
		}
	}
	$taroCards = array();
	for( $i=0; $i<$n; $i++ ) {
		$c = trim( fgets( STDIN ) );
		array_push( $taroCards, $c );
	}
	$result = array_diff( $cardSet, $taroCards  );
	if( count( $result ) ) {
		print implode( PHP_EOL, $result );
	} else {
		return;
	}
?>

Measured memory_bytes: 6616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (int H = in.nextInt(), W = in.nextInt(); 
                H != 0 || W != 0; 
                H = in.nextInt(), W = in.nextInt()) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 34876
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction

mod = 10 ** 9 + 7
mod1 = 998244353

# ------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase

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")




# --------------------------------------------------binary------------------------------------
n=int(input())
n-=400
print(8-n//200)



Measured memory_bytes: 10140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int m;
  ll k;
  cin >> m >> k;
  int mx = (1<<m);
  if(m == 1 && k == 1){
    cout<<-1<<endl;
    return 0;
  }
  else if( m == 1 && k == 0){
    cout<<"0 0 1 1"<<endl;
    return 0;
  }
  if(k>=mx){
    cout<<-1<<endl;
    return 0;
  }
  deque<int> q;
  q.push_back(k);
  rep(i,mx){
    if(k == i)continue;
    q.push_back(i);
    q.push_front(i);
  }
  q.push_back(k);
  while(!q.empty()){
    cout<<q.front()<<" ";
    q.pop_front();
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 4708
from heapq import heappop,heappush


N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
q = []
for i in range(N):
    heappush(q,-A[i])

for i in range(M):
    a = -heappop(q)
    heappush(q,- (a//2))

ans = 0
for i in range(N):
    ans-=heappop(q)

print(ans)

Measured memory_bytes: 66840
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<ll>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define sz(a) ll(a.size())

#define pb push_back
#define mp make_pair
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll INF = 1e6;

void solve()
{
    ll n, k,z;
    cin>>n;
    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";

}
 
int main()
{
    SPEED;
    ll t = 1;
    //cin>>t;
    while(t--) solve();
    return 0;
}



Measured memory_bytes: 3596
using System;
using System.Linq;

namespace V1165{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            while(true){
                var N = sr.Next<int>();
                if(N == 0) break;
                var P = sr.Next<int>(N - 1, 2).Select(a => new{n = a[0], d = a[1]}).ToArray();

                var d1 = new[]{0, 1, 0, 1};
                var d2 = new[]{-1, 1, 1, -1};
                var pos = new int[N, 2].ToJaggedArray();

                for(var i = 0; i < N - 1; i++){
                    var n = P[i].n;
                    var d = P[i].d;
                    pos[i + 1][1 - d1[d]] = pos[n][1 - d1[d]];
                    pos[i + 1][d1[d]] = pos[n][d1[d]] + d2[d];
                }

                var xmin = pos.Min(a => a[0]);
                var xmax = pos.Max(a => a[0]);
                var ymin = pos.Min(a => a[1]);
                var ymax = pos.Max(a => a[1]);
                Console.WriteLine((xmax - xmin + 1) + " " + (ymax - ymin + 1));
            }
            //---------------------------------
        }
    }

    public static class ExMethod{
        public static T[][] ToJaggedArray<T>(this T[,] src){
            var x = src.GetLength(1);
            var y = src.GetLength(0);
            var ret = new T[y][];

            for(var i = 0; i < y; i++){
                ret[i] = new T[x];
                for(var j = 0; j < x; j++){
                    ret[i][j] = src[i, j];
                }
            }

            return ret;
        } 
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a!=b){
		cout<<"No"<<endl;
		return 0;
	}
	if(a!=c){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// Recieve StdIn
    	Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int ret;

		// Declare
		int min;
		if (D==0) {
			min = 1;
		} else if (D==1) {
			min = 100;
		} else {
			min = 10000;
		}

		// Display
		if (N==100) {
			ret = min * (N + 1);
		} else {
			ret = min * N;
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}


int main() {
    string s;cin>>s;
    
    cout << s[0] <<s.size()-2<<s[s.size()-1]<<endl;
    return 0;
}







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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int a, b, ans;
  cin >> a >> b;
  
  rep(i, 10){
    ans = b*10 + i;
    if((ans*8)/100 == a){
      cout << ans << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
return 0;
}

Measured memory_bytes: 3616
class DualSegmentTree():

    def __init__(self, n, op, e):
        """
        :param n: 配列の要素数
        :param op: 作用素（モノイド＝結合則＋単位元存在）
        :param e:  単位元
        """
        self.n = n
        self.op = op
        self.e = e
        self.depth = (self.n - 1).bit_length()
        self.size = 1 << self.depth
        self.lazy = [self.e] * ((self.size << 1) + 1)

    def built(self, array):
        """
        arrayを初期値とするセグメント木を構築
        """
        for i in range(self.n):
            self.lazy[self.size + i] = array[i]

    def update(self, l, r, x):
        """
        半開区間 [l, r) の各々の要素 a に op(x, a)を作用させる （ 0-indexed ）　（ O(logN) ）
        """
        l += self.size
        r += self.size
        l0 = l//(l&-l)
        r0 = r//(r&-r)
        self.propagate(l0)
        self.propagate(r0-1)
        while l < r:
            if r&1:
                r -= 1              # 半開区間なので先に引いてる
                self.lazy[r] = self.op(x, self.lazy[r])
            if l&1:
                self.lazy[l] = self.op(x, self.lazy[l])
                l += 1
            l >>= 1
            r >>= 1

    def propagate(self, i):
        """
        根から葉に伝搬させる。可換モノイドの場合は更新時の伝搬をサボれる。　（ O(logN) ）
        """
        for k in range(i.bit_length()-1, 0,-1):
            x = i>>k
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e

    def get(self, i):
        """
        i 番目の値を取得（ 0-indexed ） ( O(logN) )
        """
        i += self.size
        self.propagate(i)
        return self.lazy[i]

    def __getitem__(self, i):
        return self.get(i)

    def __iter__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        for a in self.lazy[self.size:self.size+self.n]:
            yield a

    def __str__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        return str(self.lazy[self.size:self.size + self.n])

##################################################################################################################
import sys
from bisect import *
input = sys.stdin.readline

N, Q = map(int, input().split())

e = -1
op = lambda x, y: x if x != e else y
st = DualSegmentTree(Q, op, e)

Qu = [list(map(int, input().split())) for _ in range(N)]
Qu.sort(key=lambda x:x[2], reverse=True)

D = [int(input()) for _ in range(Q)]

for q in Qu:
    S, T, X = q
    L = bisect_left(D,S-X)
    R = bisect_left(D,T-X)
    st.update(L, R, X)
print(*st, sep="\n")

Measured memory_bytes: 146336
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	string s;
	int k;
	cin >> s >> k;
	if(s.size()==1){
		cout << s << endl;
		return 0;
	}
	vector<string> dic;
	for(int i=0; i<s.length(); i++){
		for(int j=1; j<=k && i+j<=s.length(); j++){
			string temp=s.substr(i,j);
			dic.push_back(temp);
		}
	}
	sort(dic.begin(),dic.end());
	int temp=1;
	for(int i=1; i<dic.size(); i++){
		if(dic[i]!=dic[i-1])temp++;
		if(temp==k){
			cout << dic[i] << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

const int INF = 1e9 + 239;

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

	int n, q;
	cin >> n >> q;
	vector<int> x(n);
	vector<int> l(n);
	vector<int> r(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> r[i] >> x[i];
		l[i] -= x[i];
		r[i] -= x[i];
	}
	vector<int> rl;
	vector<int> rr;
	vector<int> rx;
	{
		map<int, vector<int>> op;
		map<int, vector<int>> cl;
		set<int> h;
		for (int i = 0; i < n; i++) {
			op[l[i]].push_back(i);
			cl[r[i] - 1].push_back(i);
			h.insert(l[i]);
			h.insert(r[i] - 1);
		}
		multiset<int> v;
		v.insert(INF);
		int pr = -INF;
		for (auto t : h) {
			int tl = pr + 1;
			int tr = t - 1;
			if (tl <= tr) {
				rl.push_back(tl);
				rr.push_back(tr);
				rx.push_back(*v.begin());
			}
			for (auto i : op[t]) {
				v.insert(x[i]);
			}
			pr = t;
			rl.push_back(t);
			rr.push_back(t);
			rx.push_back(*v.begin());
			for (auto i : cl[t]) {
				v.erase(v.find(x[i]));
			}
		}
		rl.push_back(pr + 1);
		rr.push_back(INF);
		rx.push_back(*v.begin());
	}
	int pnt = 0;
	while (q--) {
		int d;
		cin >> d;
		while (d > rr[pnt]) {
			pnt++;
		}
		int ans = rx[pnt];
		if (ans == INF) ans = -1;
		cout << ans << '\n';
		
	} 
}


Measured memory_bytes: 116168
from math import ceil, sqrt


def main():
    n = int(input())
    f_min = 30
    for a in range(1, ceil(sqrt(n)) + 1):
        if n % a != 0:
            continue
        b = n // a
        f_min = min(f_min, max(len(str(a)), len(str(b))))
    print(f_min)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
  int A, B; cin >> A >> B;
  if (A > 9 || B > 9) {
    cout << -1 << endl;
  } else {
    cout << A*B << endl;
  }  
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <vector>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int find(int n){
  int c[3]={0};
  while(n>0){
    switch(n%10){
      case 3:
        c[0]++;
        break;
      case 5:
        c[1]++;
        break;
      case 7:
        c[2]++;
        break;
      default:
        return 0;
    }
    n/=10;
  }
  if(c[0]>=1 && c[1]>=1 && c[2]>=1) return 1;
  else return 0;
}
int main(void){
  initialize();
  ll n,m=0,i,j,k,result=0;
  int a[LIMIT2]={0};
  std::queue<ll> que;
  char s[LIMIT1];
  
  scanf("%lld",&n);
  que.push(3);
  que.push(5);
  que.push(7);
  while(i<=n){
    i = que.front();
    que.pop();
    if(!(i<=n)) break;
    if(find(i)==1) result++;
    que.push(i*10+3);
    que.push(i*10+5);
    que.push(i*10+7);
  }
  
  printf("%lld", result);
  while(!que.empty()) que.pop();
  
  return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int digits = 0;
  for (int i = b; i > 0; i /= 10) digits++;
  int n = int(a * pow(10, digits)) + b;
  for (int i = 1; i < n / 2; i++) {
    if (i * i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

using namespace std;
using ll = long long;
const int F = 26;
const int def = 1e6;

int n;
vector<int> c(F);
vector<vector<int>> a;



void init() {
    cin >> n;
    a.resize(n, vector<int>(F));
    for(int i = 0; i < F; i++)cin >> c[i];
    for(int i = 0; i < n; i++)for(int j = 0; j < F; j++)cin >> a[i][j];
}

int main()
{
    init();
    vector<int> t(n);
    for(int i = 0; i < n; i++)cin >> t[i],t[i]--;

    int sum = 0;
    vector<int> last(F, -1);

    for(int i = 0; i < n; i++) {
        sum += a[i][t[i]];
        last[t[i]] = i;
        for(int j = 0; j < F; j++)sum -= (i - last[j]) * c[j];
        //cout << max(sum + def, 0) << endl;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3684
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
p = 1
for i in range(n):
    p = a[p-1]
    if p==2:
        print(i+1)
        exit()
    if p==a[p-1]:
        break
print(-1)
    

Measured memory_bytes: 7188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void dump(int *A, int N)
{
	int i;

    for (i=0; i<N; i++){
		if (i)
			printf(" ");
        printf("%d", A[i]);
	}
    printf("\n");
}
void insertionSort(int *A, int N) // N??????????´??????????0-?????????????????????A
{
    int i,j,v;

    //printf("start sorting\n");
    for(i=1; i<N; i++){// ??? 1 ?????? N-1 ?????§
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
		dump(A, N);
    }
    //printf("end of sort\n");
}

char Arg[1024];
int main(void)
{
    int i,j,k,N, *Array; char work[5];

	gets(work);
    N=atoi(work);
    //printf("Number of element %d\n", N);
    Array=malloc(N*sizeof(int));
    if (Array==NULL)
        return -1;
    gets(Arg);
	//printf("-|%s|-\n", Arg);
    for(i=j=k=0; Arg[j]; ){
        for (j=i; Arg[j]!=' ' && Arg[j]; j++);
        if (i!=j){
            strncpy(work, &Arg[i], j-i);
			work[j-i]=0;
			//printf("%d|%s|%d\n", i, work, j);
            Array[k++]=atoi(work);
            i=j+1;
        }
    }
    //printf("array input done\n");
	dump(Array, N);
    insertionSort(Array, N);
    free(Array);
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int N;
	cin >> N;

	VI A(N + 1), B(N);
	
	rbf(a, A) cin >> a;
	rbf(b, B) cin >> b;

	ULL ans = 0;
	rep(i, N) {
		if (A[i] > B[i]) {
			ans += B[i];
		}
		else {
			ans += A[i];
			B[i] -= A[i];
			if (A[i+1] > B[i]) {
				ans += B[i];
				A[i + 1] -= B[i];
			}
			else {
				ans += A[i + 1];
				A[i + 1] = 0;
			}
		}
	}

	COUT(ans);

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>


int main()
 {
  long long int a,b,c,d,sum=0 ;
  char s[911];
  scanf("%lld",&a) ;
  b=a/500 ;
  sum=sum+b*1000 ;
  c=a%500 ;
  d=c/5 ;
  sum=sum+d*5 ;
  printf("%lld",sum) ;
  return 0 ;
 }

Measured memory_bytes: 128
N = int(input())
A = sorted(list(map(int,input().split())), reverse = True)

if N == 0:
    ans = 0
elif N == 1:
    ans = A[0]
else:
    ans = A[0]
    u = 1
    for i in range(2,N):
        ans += A[u]
        if i % 2 != 0:
            u += 1

print(ans)

Measured memory_bytes: 31600
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int M = 1e9 + 7 ;
const int SIZE = 2e5+1;
int fact[SIZE];
int inv[SIZE];
int n , a, b ;
int mypow (int p)
{
    if (p == 0 )return 1 ;
    if (p == 1 )return 2 ;
    if (p&1)return (2 * mypow(p-1)%M)%M ;
    ll cur = mypow(p/2)%M;
    return (cur * cur )%M;
}
int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}
int CmP(int c , int p)
{
    ll cur = 1 ;
    int curc = c ;
    int rm = p;
    while (rm--)
    {
        cur = (c*cur)%M ;
        c--;
    }
    while (p>0)
    {
        cur = (cur * inv[p])%M;
        p--;
    }
    return cur ;
}
int main()
{
    fact[0]=1;
    inv[0] = modInverse(0,M);
    for (int i = 1 ; i < SIZE ;i++)
    {
        fact[i]  = (1LL*fact[i-1] * i)%M ;
        inv[i]   = modInverse(i,M);
    }

    cin >> n >> a >> b ;

    int cur = (((mypow(n)-1+M)%M - CmP(n,a)-CmP(n,b))%M + M )%M;
    cout << cur <<"\n";

}


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

void AtCoder(map<int, vector<pair<int, int>>> &tree, vector<int> &ans, int now, int color) {
  if (ans[now] != -1) return;
  ans[now] = color;

  for (auto& root : tree[now])
  {
    int newcolor = color ^ (root.second % 2);
    AtCoder(tree, ans, root.first, newcolor);
  }
}

int main()
{
  int N; cin >> N;

  map<int, vector<pair<int, int>>> tree;

  for (int i = 0; i < N-1; i++)
  {
    int u, v, w; cin >> u >> v >> w;
    u--; v--;
    for (int j = 0; j < 2; j++)
    {
      if (tree.count(u) == 0) tree[u] = { make_pair(v, w) };
      else tree[u].push_back(make_pair(v, w));

      swap(u, v);
    }
  }

  vector<int> ans(N, -1);

  AtCoder(tree, ans, 0, 0);

  for (int i = 0; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n, m; cin >> n >> m;
  vector<vector<int>> v(m);
  rep(i, n){
    int a, b; cin >> a >> b;
    if(a > m) continue;
    v[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i = m-1; i >= 0; i--){
    for(int j = 0; j < v[i].size(); j++){
      q.push(v[i][j]);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 5760
<?php
$S=fgets(STDIN);
$ans=[];
for ($i=0; $i <strlen($S) ; $i++) {
  // code...
  if($S[$i]=='B'){
    if(count($ans)>=1){
      $D=array_splice($ans,count($ans)-1,1);
    }
  }else{
    $ans[]=$S[$i];
  }
}
for ($i=0; $i <count($ans) ; $i++) {
  // code...
  echo $ans[$i];
}
 ?>

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

int main()
{
    string s;
    ci >> s;

    stack<char> st;

    for(int i = 0; i < s.size(); i++) {

	if(st.size() == 0) {
	    st.push(s[i]);
	} else {
	    char top = st.top();
	    if(top != s[i]) st.pop();
	    else            st.push(s[i]);
	}
    }

    co << s.size() - st.size() << en;
    
    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long>a(N);
  vector<long long>b(N,0);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    b.at(a.at(i)-1)++;
  }
  
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    sum += b.at(i)*(b.at(i)-1)/2;
  }
  for (int i = 0; i < N; i++) {
    if (b.at(a.at(i)-1) > 0){
      cout << sum - b.at(a.at(i)-1)*(b.at(a.at(i)-1)-1)/2 + (b.at(a.at(i)-1)-2)*(b.at(a.at(i)-1)-1)/2 << endl;
    }
    else {
      cout << sum - b.at(a.at(i)-1)*(b.at(a.at(i)-1)-1)/2 << endl;
    }
  }
}
    
   

Measured memory_bytes: 6384
def g;gets.to_i;end
r=0..7
g.times{|n|gets
m=r.map{gets}
q=[[g-1,g-1]]
(x,y=q.pop;r===x&&r===y&&m[y][x]>?0&&(m[y][x]=?0;(-3..3).map{|i|q<<[x,y+i];q<<[x+i,y]}))while q!=[]
puts"Data #{n+1}:",m}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

int toIndex(char c)
{
	if (c == 'R')return 0;
	if (c == 'G')return 1;
	if (c == 'B')return 2;

	//cout << "nazo : " << c << endl;
	return 0;
}

void solve()
{
	int n;
	string s;
	cin >> n >> s;

	ll cnt[3] = { 0, 0, 0 };
	for(const auto& c : s)
	{
		cnt[toIndex(c)]++;
	}

	ll ans = 0;
	ans = cnt[0] * cnt[1] * cnt[2];

	for(int diff = 1; diff <= n / 2; ++diff)
	{
		for(int i = 0; i <= n - 1 - diff * 2; ++i)
		{
			int j = i + diff;
			int k = j + diff;
			if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
			{
				ans--;
			}
		}
	}

	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int w=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),min,max;
    min=Math.min(a,b);
    max=Math.max(a,b);
    if(max-min-w>0){
      System.out.println(max-min-w);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) c.begin(),c.end()
#define fs first
#define sc second
typedef pair<int,int> P;
struct edge{int to,d,c;};
vector<edge> G[10000];
int n,m,inf=1e8,d[10000];
bool comp(const edge& l,const edge& r){
	if(l.d!=r.d) return l.d<r.d;
	if(l.c!=r.c) return l.c<r.c;
	return l.to<r.to;
}
int ans;
void dijkstra(int s){
	ans=0;
	priority_queue<P,vector<P>,greater<P> > que;
	rep(i,n) d[i]=inf;
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.sc;
		if(d[v]<p.fs) continue;
		rep(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.d){
				d[e.to]=d[v]+e.d;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
int main(){
	while(true){
		cin >> n >> m;
		if(!n) break;
		rep(i,n) G[i].clear();
		rep(i,m){
			int u,v,d,c;
			cin >> u >> v >> d >> c;
			u--,v--;
			G[u].push_back({v,d,c});
			G[v].push_back({u,d,c});
		}
		rep(i,n) sort(all(G[i]),comp);
		dijkstra(0);
		int ans=0;
		rep(i,n){
			if(i==0) continue;
			int mn=inf;
			rep(j,G[i].size()){
				edge e=G[i][j];
				if(d[i]==d[e.to]+e.d) mn=min(mn,e.c);
			}
			ans+=mn;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3308
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  cout << ((1900 * M) + (100 * N - 100 * M)) * pow(2, M) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        X: u32,
        Y: u32,
    }
    println!("{}", X+Y/2);
}


Measured memory_bytes: 4352
#include <stdio.h>
#define pfNum 12

//gcm(data) = G.C.M.(pfdata,data)
void gcm(int data);
//Prime Fuctrized Data 2 int data
//reset pfdata (no need for this problem)
int getpf();
//Prime Num Checker. used in gcm
int pnCheck(int x);

//gcmdata. Prime Fuctrized Data (tmp name)
int pfdata[pfNum][2];

int main() {
	int i;
	int num;
	int data[10];

	scanf("%d", &num);
	for (i = 0; i < num; i++) scanf("%d", &data[i]);

	for (i = 0; i < pfNum; i++) {
		pfdata[i][0] = pfdata[i][1] = 0;
	}

	for (i = 0; i < num; i++) {
		gcm(data[i]);
	}

	i = getpf();
	printf("%d\n", i);
	
	return 0;
}


int pfdtn = 0;	//pfdata[/*cnthere*/][];
void gcm(int data) {
	if (data == 1)return;
	int i, j;
	int cnt;
	int cod = data;	//CopyOfData

		
	for (i = 2; i <= cod && i*i <= data; i += 2) {
		if ((cod%i == 0) && pnCheck(i)) {
			cnt = 0;
	//already i?
			for (j = 0; j < pfdtn; j++) {
				if (pfdata[j][0] == i) 	break;
			}
		//updata
			pfdata[j][0] = i;
			while (cod%i == 0) {
				cod /= i;
				cnt++;
			}

			if (cnt > pfdata[j][1]) {
				pfdata[j][1] = cnt;
			}
	//new data? (i)
			if(j==pfdtn) pfdtn++;
		}
		if (i == 2)i--;
	}
	if (cod!=1) {
		i = cod;
		cnt = 0;
	//already i?
		for (j = 0; j < pfdtn; j++) {
			if (pfdata[j][0] == i) 	break;
		}
		//updata
		pfdata[j][0] = i;
		while (cod%i == 0) {
			cod /= i;
			cnt++;
		}

		if (cnt > pfdata[j][1]) {
			pfdata[j][1] = cnt;
		}
	//new data? (i)
		if (j == pfdtn) pfdtn++;

	}
	return;
}


int getpf() {//sum(pfdata[n][0]^pfdata[n][1])
	int ans = 1;
	int i, j;
	for (i = 0; int pft = pfdata[i][0]; i++) {
		for (j = 0; j < pfdata[i][1]; j++) {
			ans *= pft;
		}
	}
/*	no need for this problem
	for (i = 0; i < pfNum; i++) {
		pfdata[i][0] = pfdata[i][1] = 0;
	}
*/
	return ans;
}

int pnCheck(int x) {
	if ((x != 2) && (x % 2 == 0))return 0;
	int i;
	int fl = 0;

	for (i = 3; i*i <= x; i += 2) {
		if (pnCheck(i)) {
			if (fl = (x % i == 0)) break;
		}
	}
	return !fl;
}

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

int N;
int ans;
vector<vector<pair<int, bool>>> D;

void solve(int d, vector<bool> t) {
    if (d != N) {
        t.push_back(true);
        solve(d + 1, t);
        t.pop_back();
        t.push_back(false);
        solve(d + 1, t);
    } else {
        // 矛盾が生じているかのチェック
        int a = 0;
        for (int i = 0; i < N; i++) {
            if (!t[i]) continue;
            a++;
            for (auto p : D[i]) {
                if (t[p.first] != p.second) a = INT_MIN;
            }
        }
        ans = max(ans, a);
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        vector<pair<int, bool>> d;
        for (int j = 1; j <= a; j++) {
            int x, y;
            cin >> x >> y;
            d.push_back(make_pair(x - 1, y));
        }
        D.push_back(d);
    }
    ans = INT_MIN;
    vector<bool> t;
    solve(0, t);
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int n,m,ans;
string s[200];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=0;i<n;++i) cin>>s[i],++mp[s[i]];
	cin>>m;
	for (int i=0;i<m;++i) cin>>s[n],--mp[s[n]];
	for (int i=0;i<n;++i) ans=max(ans,mp[s[i]]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

g = 0
for i in range(n-1):
  tmp = a[i+1]-a[i]
  if tmp > g:
    g = tmp
tmp = a[0] + (k - a[n-1])
if tmp > g:
  g = tmp

print(k-g)


Measured memory_bytes: 32192
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  string S;
  ll K;
  cin >> S >> K;
  
  for(ll i=0; i<K; ++i){
    if(S[i]!='1'){
      cout << S[i] << endl;
      break;
    }else if(i==K-1) cout << S[i] << endl;
  }
  
}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A==0) {
        cout << 0 << endl;
        return 0;
    }
    ll K = N/(A+B);
    ll M = N%(A+B);
    if (M <= A) cout << A*K+M << endl;
    else cout << A*K+A << endl;
    return 0;
}

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

int main() {
    string n;
    string m;
 
   cin >> n >> m;
  
   int as = -1;
  
   for(int i = 1;i<=m.length();i++){
     
      int d = as+i*2;
     
     
      
     
      char ch = m[i-1];
    
     std::string str{ch};     // "a"
       
       n.insert(d, str); 
     
    // cout << i << endl;
    // cout << str << endl;
    // cout << n << endl;
   }
  
    cout << n << endl;
   
  
  
  return 0;
}

Measured memory_bytes: 256
'''
（公式解説参照）
A[i]*A[i+1]+A[i]*A[i+2]+…+A[i]*A[N]=A[i]*(A[i+1]+A[i+2]+…+A[N])
リストAに対する累積和を求めておく
'''
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

# 累積和
total = []
total.append(A[0])
for i in range(1, N):
    total.append(total[i-1] + A[i])
# print(total)

# iの値について全探索
ans = 0
for i in range(N):
    tmp = (total[-1] - total[i])
    ans += A[i] * tmp
    ans %= MOD

print(ans)


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
long long A[100001];
int main(){
	cin>>N;
	REP(i,N){
	    cin>>A[i];
	}
	
	int c=0;
	REP(i,N){
	    if(A[i]%2==1)c++;
	}
	if(c%2==0){
	   cout<<"YES"<<endl;
	}else{
           cout<<"NO"<<endl;
        }
	return(0);
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

results = []
score = 0
for idx, t in enumerate(T):
    if idx - K < 0:
        if t == "r":
            results.append("p")
            score += P
        elif t == "s":
            results.append("r")
            score += R
        elif t == "p":
            results.append("s")
            score += S
    else:
        if t == "r" and results[idx - K] == "p":
            results.append("?")
        elif t == "r":
            results.append("p")
            score += P
        if t == "s" and results[idx - K] == "r":
            results.append("?")
        elif t == "s":
            results.append("r")
            score += R
        if t == "p" and results[idx - K] == "s":
            results.append("?")
        elif t == "p":
            results.append("s")
            score += S
print(score)


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

using namespace std;

#define ldouble long double
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, k, a[100001] = {};
    llong imomushi = 0, sum_of_plus = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> a[i];
        if (i < k) {
            imomushi += a[i];
        } else {
            if (a[i] > 0) sum_of_plus += a[i];
        }
    }

    priority_queue<llong> ans;
    rep(i, n - k + 1) {
        if(i == 0) {
            ans.push(imomushi + sum_of_plus);
            //cout << i << " " << imomushi << " " << sum_of_plus << endl;
        } else {
            int next = a[k - 1 + i], prev = a[i - 1];
            imomushi += next - prev;
            if (next > 0) sum_of_plus -= next;
            if (prev > 0) sum_of_plus += prev;
            ans.push(imomushi + sum_of_plus);
            ans.push(sum_of_plus);
            //cout << i << " " << imomushi << " " << sum_of_plus << " " << imomushi + sum_of_plus << " " << "prev " << prev << " " << "next " << next << " " << endl;
        }
    }

    cout << max((llong)0, ans.top()) << endl;

    return 0;
}

Measured memory_bytes: 2804
#include<bits/stdc++.h>
using namespace std;
int main(){
    std::string S;
    long a,b,size_s;cin >> S;
    a=0;b=0;
    size_s = S.size();
    for(int i=0;i<size_s;i++){
        if(i%2==0&&S[i]=='0'){
            a++;
        }else if(i%2==1&&S[i]=='1'){
            a++;
        }
    }
    for(int i=0;i<size_s;i++){
        if(i%2==0&&S[i]=='1'){
            b++;
        }else if(i%2==1&&S[i]=='0'){
            b++;
        }
    }
    if(a>=b){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
    return 0;
    
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.eyeTest();
		return;
	}
	
	//視力検査
	private void eyeTest() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			String inputStr = "";
			LinkedList<Double> leftEyeList = new LinkedList<Double>();
			LinkedList<Double> rightEyeList = new LinkedList<Double>();
			while (true) {
				
				inputStr = bufferedReader.readLine();
				
				if (inputStr == null || inputStr.equals("")) {
					break;
				}
				
				String[] inputEyeStr = inputStr.split(" ");
				double leftEyeNum = Double.parseDouble(inputEyeStr[0]);
				double rightEyeNum = Double.parseDouble(inputEyeStr[1]);
				leftEyeList.add(leftEyeNum);
				rightEyeList.add(rightEyeNum);
				
			}
			
			int leftA = 0;
			int leftB = 0;
			int leftC = 0;
			int leftD = 0;
			int rightA = 0;
			int rightB = 0;
			int rightC = 0;
			int rightD = 0;
			
			for (double leftEyeNum : leftEyeList) {
				
				if (1.1 <= leftEyeNum) {
					leftA++;
				} else if (0.6 <= leftEyeNum && 1.1 > leftEyeNum) {
					leftB++;
				} else if (0.2 <= leftEyeNum && 0.6 > leftEyeNum) {
					leftC++;
				} else if (0.2 > leftEyeNum) {
					leftD++;
				}
				
			}
			
			for (double rightEyeNum : rightEyeList) {
				
				if (1.1 <= rightEyeNum) {
					rightA++;
				} else if (0.6 <= rightEyeNum && 1.1 > rightEyeNum) {
					rightB++;
				} else if (0.2 <= rightEyeNum && 0.6 > rightEyeNum) {
					rightC++;
				} else if (0.2 > rightEyeNum) {
					rightD++;
				}
				
			}
			
			System.out.printf("%d %d\n", leftA, rightA);
			System.out.printf("%d %d\n", leftB, rightB);
			System.out.printf("%d %d\n", leftC, rightC);
			System.out.printf("%d %d\n", leftD, rightD);
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 16964
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Card struct {
	Sym string
	Num int
}

func BubbleSort03_5(a []Card, n int) {
	var isArranged = true

	for isArranged {
		isArranged = false
		for j := n - 1; j > 0; j-- {
			if a[j].Num < a[j-1].Num {
				a[j], a[j-1] = a[j-1], a[j]
				isArranged = true
			}
		}
	}
}

func SelectionSort03_5(a []Card, n int) {
	var minj int //index of min value

	for i := 0; i < n; i++ {
		minj = i
		for j := i; j < n; j++ {
			if a[j].Num < a[minj].Num {
				minj = j
			}
		}
		a[i], a[minj] = a[minj], a[i]
	}
}

func PrintNoParenthesis03_5(a []Card) {
	for i, n := range a {
		fmt.Printf("%s%d", n.Sym, n.Num)
		if i == len(a)-1 {
			fmt.Printf("\n")
		} else {
			fmt.Print(" ")
		}
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	cards1 := make([]Card, n)
	cards2 := make([]Card, n)
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		num, _ := strconv.Atoi(string(s[1]))
		card := Card{Sym: string(s[0]), Num: num}
		cards1[i] = card
	}

	copy(cards2, cards1)

	BubbleSort03_5(cards1, n)
	PrintNoParenthesis03_5(cards1)
	fmt.Println("Stable")
	SelectionSort03_5(cards2, n)
	PrintNoParenthesis03_5(cards2)
	isStable := true
	for i, _ := range cards1 {
		if cards1[i] != cards2[i] {
			isStable = false
			break
		}
	}
	if isStable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}



Measured memory_bytes: 1152