akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// wrap,pair
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

// pairをsecond基準で昇順sort
// sort(vector_name.begin(),vector_name.end(),compare_by_b);
bool compare_by_b(pair<int, int>a, pair<int, int>b) {
	if (a.second != b.second) return a.second < b.second;
	else return a.first < b.first;
}

// ----------------------------------------------------------------

int main(void) {

	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	REP(i, m) cin >> x[i];
	
	sort(x.begin(), x.end());

	vector<int> btw(m - 1);
	int ans = 0;
	FOR(i, 1, m) {
		btw[i - 1] = abs(x[i] - x[i - 1]);
		ans += btw[i - 1];
	}
	sort(btw.begin(), btw.end(), greater<int>());

	if (n > m)n = m;
	int k = 0;
	while (n > 1) {
		ans -= btw[k];
		n--;
		k++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

ll dp[3005][3005];

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

  ll mod=998244353;
  ll n,s;cin>>n>>s;
  vector<ll> A(n);
  for(ll i=0;i<n;i++)cin>>A[i];

  dp[0][0]=1;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<=s;j++){
      ll a = A[i];
      dp[i+1][j] += dp[i][j] * 2ll;
      dp[i+1][j] %= mod;
      if(j-a>=0){
        dp[i+1][j] += dp[i][j-a];
        dp[i+1][j] %= mod;
      }
    }
  }
  cout<<dp[n][s]<<endl;
  
  return 0;
}


Measured memory_bytes: 74032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<ll> x(n),y(m);
    ll xx=0,yy=0;
    for(int i=0;i<n;i++){
        cin >> x[i];
        (xx+=(2*(i+1)-n-1)*x[i]%mod)%=mod;
    } 
    for(int i=0;i<m;i++){
        cin >> y[i];
        (yy+=(2*(i+1)-m-1)*y[i]%mod)%=mod;
    }
    cout << xx*yy%mod << endl;    
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    S s,t;
    cin >> s >> t;
    vc u(s.size());
    vs ans;
    rp(i,s.size()-t.size()+1){
        int cnt=0;
        rp(j,s.size()){
            u.at(j)=s.at(j);
        }
        rp(k,t.size()){
            if(s.at(i+k)==t.at(k)||s.at(i+k)=='?'){
                cnt++;
                if(s.at(i+k)=='?'){
                    u.at(i+k)=t.at(k);
                }
            }
        }
        if(cnt==t.size()){
            S r="";
            rp(j,s.size()){
                if(u.at(j)=='?'){
                    r=r+'a';
                }else{
                    r=r+u.at(j);
                }
            }
            ans.pb(r);
        }
    }
    if(ans.size()){
        sort(ans);
        cout << ans.at(0) << endl;
    }else{ 
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
const ll mod=1e9+7;
typedef double db;
const db pi=3.1415926535898;
char s[205][205];
int n;
int vis[205];
int dep[205];
struct node{
    int a,b,d;
};
queue<node>q;
vector<int>v[205];
void clear(queue<node>& q) {
    queue<node> empty;
    swap(empty,q);
}

int flag=1;

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<n;j++){
            if(s[i][j]=='1')
                v[i].push_back(j+1);
        }
    }
    node t,g;
    int ans=0;
    int fff=1;
    for(int k=1;k<=n;k++){
    flag=1;
    t.a=0,t.b=k,t.d=1;
    //vis[1]=1;
    q.push(t);
    int pp=0;
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++) dep[i]=-1;
    while(!q.empty()){
        t=q.front();
        q.pop();
        int b=t.b;
        if(vis[b]) continue;
        //cout<<b<<endl;
        vis[b]=1;
        dep[b]=t.d;
        pp=b;
        for(int i=0;i<v[b].size();i++){
            if(vis[v[b][i]]==1){
                //if(v[b][i]==b) continue;
                if(abs(dep[v[b][i]]-dep[b])!=1){
                    //cout<<b<<' '<<v[b][i]<<endl;
                    flag=0;
                }
                continue;
            }
            else{
                g.a=b,g.b=v[b][i];
                g.d=t.d+1;
                q.push(g);
            }
        }
    }
    //cout<<'*'<<endl;
    //cout<<pp<<endl;
    memset(vis,0,sizeof(vis));
    clear(q);
    if(flag){
        t.a=0,t.b=pp,t.d=1;
        //vis[pp]=1;
        q.push(t);
        while(!q.empty()){
            t=q.front();
            q.pop();
            ans=max(ans,t.d);
            int b=t.b;
            if(vis[b]) continue;
            //cout<<b<<endl;
            vis[b]=1;
            for(int i=0;i<v[b].size();i++){
                if(vis[v[b][i]]==1){
                    continue;
                }
                else{
                    g.a=b,g.b=v[b][i];
                    g.d=t.d+1;
                    q.push(g);
                }
            }
        }
    }
    if(flag==0) fff=0;
    }

    if(!fff) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 824
<?php
   $sum=0;
    fscanf(STDIN,"%d",$N);

    for($i=0;$i<$N;$i++){
       if($i%15==0){

       }elseif($i%3==0){

       }elseif($i%5==0){

       }else{
           $sum += $i;
       }
    }

    $sum=0;
    fscanf(STDIN,"%d",$N);

    for($i=1;$i<=$N;$i++){
       if($i%15==0){

       }elseif($i%3==0){

       }elseif($i%5==0){

       }else{
           $sum += $i;
       }
    }

    echo $sum."\n";

Measured memory_bytes: 16160
#include <stdio.h>
int main(void){
    int n,i,x;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&x);
        a[x-1]=i+1;
    }
    for(i=0;i<n;i++) printf("%d ",a[i]);
    return 0;
}

Measured memory_bytes: 1152
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a:usize =read!();
    let mut v:Vec<isize>=Vec::new();
    let s:isize=read!();
    for i in 0..a {
        v.push(s+i as isize);
    }
    let mut ans=0;
    let mut x:isize=1000000;
    for i in 0..a {
        ans+=v[i];
        if (v[i]).abs()<x.abs() {x=v[i]}
    }
    println!("{}",ans-x)
}

Measured memory_bytes: 2184
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[][] fig = new String[h][w];
    for(int i = 0; i < h; i++) {
      String s = sc.next();
      for(int j = 0; j < w; j++) {
        fig[i][j] = String.valueOf(s.charAt(j));
      }
    }
    int f = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(!(fig[i][j].equals("."))) {
          int t = 0;
          if((j - 1) >= 0) {
            if(!(fig[i][j - 1].equals("."))) t++;
          }
          if((i - 1) >= 0) {
            if(!(fig[i - 1][j].equals("."))) t++;
          }
          if((j + 1) < w) {
            if(!(fig[i][j + 1].equals("."))) t++;
          }
          if((i + 1) < h) {
            if(!(fig[i + 1][j].equals("."))) t++;
          }
          if(t == 0) f++;
        }
      }
    }
    String ans = "Yes";
    if(f > 0) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 20692
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int X, Y, Z, K;
    scanf("%d%d%d%d", &X, &Y, &Z, &K);
    std::vector<long long> A(X);
    rep(i, X) scanf("%lld", &A[i]);
    std::vector<long long> B(Y);
    rep(i, Y) scanf("%lld", &B[i]);
    std::vector<long long> C(Z);
    rep(i, Z) scanf("%lld", &C[i]);
    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> AB;
    rep(i, X) {
        rep(j, Y) {
            AB.push(A[i] + B[j]);
            if(AB.size() > K) {
                AB.pop();
            }
        }
    }
    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> ABC;
    while(!AB.empty()) {
        long long ab = AB.top();
        AB.pop();
        rep(i, Z) {
            ABC.push(ab + C[i]);
            if(ABC.size() > K) ABC.pop();
        }
    }
    std::vector<long long> ans(K);
    rep(i, K) {
        ans[i] = ABC.top();
        ABC.pop();
    }
    for(int i = K - 1; i >= 0; i--) {
        std::cout << ans[i] << '\n';
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main() {
    int b[26]={0};
    char a;
    while(scanf("%c",&a)!=EOF) {
        if (a>='a'&&a<='z') {
            b[a-97]++;
        }
        if (a>='A'&&a<='Z') {
            b[a-65]++;
        }
    }
    for(int i=0,a='a';i<26;a++,i++) {
        printf("%c : %d\n", a, b[i]);
    }
    return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    string s;
    string srev;
    int slen;
    int count = 0;


    cin >> s;
    srev = s;
    reverse(srev.begin(),srev.end());
    slen = s.size();


    for(int i=0;i<slen;i++){
        if(s[i]!=srev[i]){
            if(s[i]=='x'){
                srev.insert(srev.begin()+i,'x');
                s.insert(s.end()-i,'x');
                count++;
            }
            else if(srev[i]=='x'){
                s.insert(s.begin()+i,'x');
                srev.insert(srev.end()-i,'x');
                count++;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 772
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class arcC {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N);
        vector<int> a4, a2, aR;
        for (int i = 0; i < N; ++i) {
            in >> a[i];
            if (a[i] % 4 == 0) {
                a4.push_back(a[i]);
            } else if (a[i] % 2 == 0) {
                a2.push_back(a[i]);
            } else {
                aR.push_back(a[i]);
            }
        }
        if (aR.size() <= a4.size() || (a2.size() == 0U && a4.size() + 1U >= aR.size())) {
            if (aR.size() == 0U && a2.size() == 1U) {
                out << "No\n";
            } else {
                out << "Yes\n";
            }
        } else {
            out << "No\n";
        }
    }
};


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

	arcC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1404
gets
x = Array.new
x[0] = 0
gets.chomp.split(' ').each{|n| x.push(n.to_i)}
x.push(0)

distance = 0
for i in 0..(x.size-2)
  distance += (x[i+1] - x[i]).abs
end

for i in 1..(x.size-2)
  p distance - (x[i+1] - x[i]).abs - (x[i] - x[i-1]).abs + (x[i+1] - x[i-1]).abs 
end


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

int main(void){
    int a, b;
    cin >> a >> b;
    for (int i = 0;i < 10000;i++) {

        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b){

            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    if n < 3:
        print(0)
        exit()

    count = 0

    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                tmp_list = [num_list[i], num_list[j], num_list[k]]
                if len(set(tmp_list)) != 3:
                    continue
                tmp_list.sort()
                if tmp_list[0] + tmp_list[1] > tmp_list[2]:
                    count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73308
text = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())

print(text[N - 1])

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

namespace mondi0006
{
    class Program
    {
        static int Main(string[] args)
        {
            string input = Console.ReadLine();
            string output = "";

            for (int i = input.Length ; 0 < i; i--)
            {
                output += input.Substring(i-1, 1);    
            }

            Console.WriteLine(output);

            return 0;
        }
    }
}

Measured memory_bytes: 5212
#include <iostream>
using namespace std;
typedef pair<int ,int > pp;

int N;

void swap(pp *kr,pp *kl){
    pp t=*kr;
    *kr=*kl;
    *kl=t;
}

void sortF( pp *a)
{  
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(a[i].first>a[j].first){
                swap(&a[i],&a[j]);
            }
        }
    }
}

void sortS(pp *a)
{   
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(a[i].second<a[j].second){
                swap(&a[i],&a[j]);
            }
        }
    }
}

int main()
{
    cin >> N;
    pp red[N], blue[N];
    for (int i = 0; i < N; i++)
    {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> blue[i].first >> blue[i].second;
    }
    sortS(red);
    sortF(blue);
    bool isUsed[N]={};
    int count =0;
    int MaxY=-1;
    int Max=0;
    for(int i=0;i<N;i++){
        MaxY=-1;
        Max=0;
        for(int j=0;j<N;j++){
            if((blue[i].first<=red[j].first)||(blue[i].second<=red[j].second)){
                continue;
            }
            if(isUsed[j]){
                continue;
            }
            count++;
            isUsed[j]=true;
            break;
        }
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    priority_queue<long long, vector<long long>, greater<long long> > queue;
    priority_queue<long long, vector<long long>, greater<long long> > queue_next;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        queue.push(a);
    }
    long long ans = 0;
    while(true){
        if(queue.size() == 1){
            ans = queue.top();
            break;
        } else {
            long long m = queue.top();
            queue.pop();
            queue_next.push(m);
            while(!queue.empty()){
                long long q = queue.top();
                queue.pop();
                long long next = q % m;
                if(next != 0){
                    queue_next.push(next);
                }
            }
            while(!queue_next.empty()){
                queue.push(queue_next.top());
                queue_next.pop();
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n, m;
    cin>>n>>m;
    map<int, int> mp;
    rep(i, m){
        int a, b;
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }
    bool ok = true;
    for(auto p : mp){
        if(p.second%2) ok = false;
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	int m, k;
	cin >> m >> k;
	int t = pow<int>(2, m);
	if (k >= t) {
		put(-1);
		return 0;
	}
	if (m == 0) {
		if (k == 0) {
			put(0, 0);
		} else {
			put(-1);
		}
		return 0;
	}
	if (m == 1) {
		if (k == 0) {
			put(0, 0, 1, 1);
		} else {
			put(-1);
		}
		return 0;
	}
	if (k == 0) {
		REP(i, t) {
			cout << i << " " << i << " ";
		}
		put("");
		return 0;
	}
	vector<P> p;
	vector<int> used(t, 0);
	REP(i, t) {
		if (used[i] == 0) {
			p.push_back(P(i, i ^ k));
			used[p.back().first] = 1;
			used[p.back().second] = 1;
		}
	}
	REP(i, t / 2) {
		cout << p[i].first << " " << p[i].second << " ";
	}
	REP(i, t / 2) {
		cout << p[i].second << " " << p[i].first << " ";
	}
	return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


//template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
//template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    fast
    ll a;
    vector<ll>v;
    set<ll>s;
    ll b;
    cin>>a;
    for(auto i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
        s.insert(b);
    }
    if(v.size()!=s.size())
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 1 << 31
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define PI acos(-1)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

int main() {
    int n, l;
    cin >> n >> l;
    vi t(n);
    double ansx = 0, ansy = 0;
    rep(i, n) cin >> t[i];
    rep(i, n) REP(j, i + 1, n) {
        int p = abs(i - j);
        ansx += (p - 1) * cos(((double)(t[i] + t[j]) * PI) / (double)l + PI) +
                (n - p - 1) * cos((double)(t[i] + t[j]) * PI / (double)l);
        ansy += (p - 1) * sin((double)(t[i] + t[j]) * PI / (double)l + PI) +
                (n - p - 1) * sin((double)(t[i] + t[j]) * PI / (double)l);
        // cout << t[i] << " " << t[j] << " " << p << endl;
        // cout << ansx << " " << ansy << endl;
    }
    double all = (double)n * (n - 1) * (n - 2) / 6;
    cout << fixed;
    cout << setprecision(15) << ansx / all << " " << ansy / all << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int H, W;
    while(1){
        scanf("%d%d", &H, &W);
        if ( H == 0 && W == 0 ){
            break;
        }
        for (int i = 1; i <= H; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if (i == 1 || i == H || j == 1 || j == W){
                    printf("#");
                }
                 else {
                    printf(".");
                }
            }        
        printf("\n");
        }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
N,M = map(int,input().split())
ls = []

for i in range(M):
  s = list(map(int,input().split()))
  ls.append(s[1:])

p = list(map(int,input().split()))
#greedy O(2^N)(MN) : (all set of switch N) = 2^10 * M 10 10^4 OK
ans = 0
for i in range(2**N): # all set of N  2**N == 1 << N (shif operator N right shift)
  for j in range(M): # i_th lump consider
    cnt = 0 
    for k in ls[j]:
      if i&(1<<(k-1)): # if switch k is ON, then return non-zero(True)
        cnt += 1
    if cnt%2 != p[j]:
      break
  else:
    ans +=1
print(ans)


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

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int get_random(int l, int r) {
  int k = r - l + 1;
  return l + rng() % k;
}

const int N = 365 + 7;
const int K = 26 + 7;
int n;
int c[K], s[N][K], t[N], last[K], sol[N], best = -(int) 2e9;

int get() {
  for (int j = 1; j <= 26; j++) {
    last[j] = 0;
  }
  int sol = 0, grow = 0;
  for (int i = 1; i <= n; i++) {
    sol += s[i][t[i]];
    grow += c[t[i]] * (i - last[t[i]]);
    last[t[i]] = i;
    sol += grow;
  }
  return sol;
}

void upd() {
  int cur = get();
  if (cur > best) {
    best = cur;
    for (int i = 1; i <= n; i++) {
      sol[i] = t[i];
    }
  }
}

void make_better(double seconds) {
  time_t bg = clock();
  int c = 0;
  int cur = get();
  while (1) {
    c++;
    if (c % 10 == 0) {
      time_t nd = clock();
      if ((double) (nd - bg) / CLOCKS_PER_SEC > seconds) {
        break;
      }
    }
    int i = get_random(1, n), x = get_random(1, 26);
    while (x == t[i]) {
      x = get_random(1, 26);
    }
    int init = t[i];
    t[i] = x;
    int after = get();
    if (after > cur) {
      cur = after;
    } else {
      t[i] = init;
    }
  }
  upd();
}

void generate_max() {
  for (int i = 1; i <= n; i++) {
    t[i] = 1;
    for (int j = 1; j <= 26; j++) {
      if (s[i][j] > s[i][t[i]]) {
        t[i] = j;
      }
    }
  }
}

void generate_random() {
  generate_max();
  int modif = get_random(1, 20);
  while (modif--) {
    int i = get_random(1, n), x = get_random(1, 26);
    while (t[i] == x) {
      x = get_random(1, 26);
    }
    t[i] = x;
  }
}

void generate_random2() {
  t[1] = 1;
  for (int j = 1; j <= 26; j++) {
    if (c[j] > c[t[1]]) {
      t[1] = j;
    }
  }
  for (int i = 2; i <= n; i++) {
    t[i] = t[1];
  }
  int modif = get_random(1, 100);
  while (modif--) {
    int i = get_random(1, n), x = get_random(1, 26);
    while (t[i] == x) {
      x = get_random(1, 26);
    }
    t[i] = x;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 26; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= 150; i++) {
    generate_random();
    make_better(0.01);
    upd();
  }
  for (int i = 1; i <= 15; i++) {
    generate_random2();
    make_better(0.01);
    upd();
  }
  generate_max();
  make_better(0.2);
  upd();
  for (int i = 1; i <= n; i++) {
    cout << sol[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

vint prime;

int main() {
	for(int i=2;i<11111;++i){
		int j;
		for(j=2;j*j<=i;++j)if(i%j==0)break;
		if(j*j<=i)continue;
		prime.PB(i);
	}
	IL{
		int n=in();
		if(n==0)break;
		int a=0,b=0,sum=0,res=0;
		for(;prime[b]<=n;++b){
			sum+=prime[b];
			while(sum>n){
				sum-=prime[a++];
			}
			if(sum==n){
				++res;
				continue;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int cnt[3];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, A, B, P;
	for(cin>>N>>A>>B;N;N--) {
		cin>>P;
		if(P<=A) cnt[0]++;
		else if(P<=B) cnt[1]++;
		else cnt[2]++;
	}
	cout<<min(cnt[0],min(cnt[1],cnt[2]))<<'\n';
	return 0;
}

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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}



int main() {
	double X, T;
	cin >> X>>T;
	cout << X/T << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int N,W;cin>>N>>W;
    VLL w(N+10),v(N+10);rep(i,N)cin>>w[i]>>v[i];
    vector<vector<ll>> dp(N+10,vector<ll>(W+10,0));
    //dp[i][sum_w]はi-1番目までの商品を使ってｗが丁度sum_wになるように選んだ時の価値の最大
    rep(i,W+1)dp[0][i]=0;
    dp[0][0]=0;//初期条件
    REP(i,N){
        rep(sum_w,W+1){
            if(sum_w>=w[i-1]){
                dp[i][sum_w]=max(dp[i][sum_w],dp[i-1][sum_w-w[i-1]]+v[i-1]);//i-1番目を使う
            }
            dp[i][sum_w]=max(dp[i-1][sum_w],dp[i][sum_w]);//i-1番目を使わない
            //printf("dp[%d][%d]=%lld\n",i,sum_w,dp[i][sum_w]);
        }
    }
    cout<<dp[N][W]<<endl;
}






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


int A[100100];


int main(){
	int n,cnt=1,a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	sort(A,A+n);
	a=A[0];
	for(int i=1;i<n;i++){
		if(A[i]!=a){
			a=A[i];
			cnt++;
		}
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
-- end of templete

main = do
    [n,a,b] <- getInts
    print $ min b $ a*n

Measured memory_bytes: 508
from math import factorial as fac
from collections import defaultdict as ddict
n,m = map(int,input().split())
d = ddict(int)
ans = 1
mod = 10**9+7
def f2(n,r):
  ret = 1
  for i in range(n,n-r,-1):
    ret *= i
  return ret
def cc(n,r):
  t = min(r,n-r)
  return f2(n,t)//fac(t)
for i in range(2,int(m**.5)+1):
  while m % i == 0:
    d[i] += 1
    m //= i
if m > 1:
  d[m] += 1
for x in d:
  ans = ans * cc(d[x]+n-1,d[x])%mod
print(ans)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

bool issquare(int N) {
    for (int i = 1; i*i <= N; i++) {
        if (i*i == N) {
            return true;
        }
    }

    return false;
}

void solve(){
    int N, D;
    cin >> N >> D;

    int x[N][D];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> x[i][j];
        }
    }

    int dist = 0, ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            for (int k = 0; k < D; k++) {
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if (issquare(dist)) {
                ans++;
            }
            dist = 0;
        }
    }


    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			List<Edge>[] lists = new ArrayList[n];
			for (int i = 0; i < n; i++) {
				lists[i] = new ArrayList<Edge>();
			}
			for (int i = 0; i < m; i++) {
				int from = scanner.nextInt() - 1;
				int to = scanner.nextInt() - 1;
				int cost = scanner.nextInt();
				lists[from].add(new Edge(to, cost));
				lists[to].add(new Edge(from, cost));
			}
			int g = n - 1;
			PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
			pq.offer(new Edge(0, 0, 2));
			int[][] cost = new int[3][n];
			for (int i = 0; i < 3; i++)
				Arrays.fill(cost[i], 1 << 20);
			cost[2][0] = 0;
			while (!pq.isEmpty()) {
				Edge edge = pq.poll();
				if (edge.to == g && edge.ticket != 1) {
					System.out.println(edge.cost);
					break;
				}

				for (Edge e : lists[edge.to]) {
					if (edge.ticket == 1) {
						if (cost[0][e.to] > edge.cost) {
							cost[0][e.to] = edge.cost;
							pq.offer(new Edge(e.to, edge.cost, 0));
						}
					} else {
						if (edge.ticket == 2) {
							pq.offer(new Edge(e.to, edge.cost, 1));
						}
						if (cost[edge.ticket][e.to] > edge.cost + e.cost) {
							cost[edge.ticket][e.to] = e.cost + edge.cost;
							pq.offer(new Edge(e.to, edge.cost + e.cost,
									edge.ticket));
						}
					}
				}
			}
		}
	}

	class Edge implements Comparable<Edge> {
		int to, cost, ticket;

		public Edge(int to, int cost, int ticket) {
			super();
			this.to = to;
			this.cost = cost;
			this.ticket = ticket;
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + ", ticket=" + ticket
					+ "]";
		}

		@Override
		public int compareTo(Edge o) {
			if (this.cost == o.cost)
				return o.to - this.to;
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 33624
#include<stdio.h>
 
int main(void)
{
   int n, i;
   char s[101], t[101], v[201];
 
   scanf("%d",&n);
   scanf("%s%s",s,t);
  
   for(i=0;i<n;i++){
      v[i*2]=s[i];
      v[i*2+1]=t[i];
   }
  
   v[n*2]='\0';
 
   printf("%s\n",v);
  
   return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        ArrayList<Integer> distance = new ArrayList<Integer>();
        distance = getNumArray(line);
        int a = distance.get(0);
        int b = distance.get(1);
        int c = distance.get(2);
        int d = distance.get(3);
        
        if(isSpeakable(a, c, d)){
            System.out.println("Yes");
        }else if(isSpeakable(a, b, d) && isSpeakable(b, c, d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
    public static ArrayList<Integer> getNumArray(String line){
        String[] str = line.split(" ");
        ArrayList<Integer> num = new ArrayList<Integer>();
        for(String strNum : str){
            num.add(Integer.parseInt(strNum));
        }
        return num;
    }
    
    public static boolean isSpeakable(int n1, int n2, int distance){
        boolean speakable = true;
        boolean unspeakable = false;
        
        if(Math.abs(n1 - n2) <= distance){
            return speakable;
        }else{
            return unspeakable;
        }
    }
}



Measured memory_bytes: 21076
#include<stdio.h>
int main(void){
int S, h, m, s, t;
  scanf("%d", &S);
  h = S / 3600;
  t = S % 3600;
  m = t / 60;
  t = t % 60;
  s = t;
  printf("%d:%d:%d\n", h, m, s); 
  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define maxn 23000000
#define int long long
#define mod 1000000007
int digit[maxn], ans, S;

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

int Qpow(int times)
{
	int x = 10, base = 1;
	for(; times; times >>= 1, x = x * x % mod)
		if(times & 1) base = base * x % mod;
	return base;
}

void Up(int &x, int y) { x = (x + y) % mod; }
signed main()
{
    S = read(); int lim = S / 8, now = 0;
    for(int i = 1; i < maxn; i ++) digit[i] = digit[i / 10] + 1;
    for(int i = 1, now = 0, tem = 0; i < 1e7; i ++)
    {
    	while(tem < S) { tem += digit[now]; now ++; }
		if(tem == S) { ans += 1; if(ans >= mod) ans -= mod; } 
		tem -= digit[i];
    }
    for(int i = 1; i <= lim; i ++)
	{
		if(!(S % i)) 
		{
			int l = S / i, sum = Qpow(l - 1) * 9 % mod;
			if(l < 8) continue;
			Up(ans, (sum - i + 1 + mod) % mod);
		}
		else 
		{ 
			int l = (S - S % i) / i; if(l < 8) continue;
			ans += 1; if(ans >= mod) ans -= mod; 
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 179968
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 500010
using namespace std;
ll n,k,c,dp[N];
string s;
vector<ll> mst;
int main(){
	ll i;
	cin>>n>>k>>c>>s;
	for(i=0;i<n;i++)
	{
		if(s[i]=='o')
		{
			mst.push_back(i);
			i+=c;
		}
	}
	if(mst.size()>k)
	{
		return 0;
	}
	for(i=n;i>=0;i--)
	{
		if(s[i]=='o')
		{
			dp[i]=max(dp[i+1],dp[i+c+1]+1);
		}
		else
		{
			dp[i]=dp[i+1];
		}
	}
	for(i=0;i<mst.size();i++)
	{
		if(i+dp[mst[i]+1]==k-1)
		{
			cout<<mst[i]+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4980
#include<stdio.h>
#define N 100

int main(){
  int i, j, n, o, p, q;
  int A[N][N];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      A[i][j] = 0; 
  }
}

for(i = 0 ; i < n ; i++){
  scanf("%d%d",&o,&p);
    for(j = 0 ; j < p ; j++){
      scanf("%d",&q);
      A[i][q-1] = 1;
    }
 }

for(i = 0 ; i < n ; i++){
  for(j = 0 ; j < n ; j++){
    if(j == n - 1){
      printf("%d\n",A[i][j]);
    }
    else printf("%d ",A[i][j]);
  }
 }

return 0;
}

Measured memory_bytes: 632
fun main() {
    val num = readLine()!!.toInt()
    val array = readLine()!!.split(" ").map(String::toInt).toIntArray()
    var count = 0
    while (isEven(array)) {
        for(i in 0 until num) {
            array[i] = array[i]/2
        }
        count ++
    }
    println(count)
}

fun isEven(array: IntArray): Boolean {
    var isEven = true
    array.forEach{
        if(it%2 == 1) isEven = false
    }
    return isEven
}


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

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) count++;
    }
    cout << count << endl;
}

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

using namespace std;


int main(){
    
    int N,Q;cin>>N>>Q;
    string S;
    cin >> S;
    vector<int> l(Q);
    vector<int> r(Q);
    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
    }
    
    vector<int> dp(N);
    dp[0] = 0;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            dp[i+1] = dp[i] + 1;
        }else{
            dp[i+1] = dp[i];
        }
    }
    for (int i = 0; i < Q; i++) {
        cout << dp[r[i]-1] - dp[l[i]-1] << endl;
    }
    
    
}


Measured memory_bytes: 2176
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(list(input().rstrip()) for i in range(n))
    B = list(list(input().rstrip()) for i in range(m))
    A = np.array(A)
    B = np.array(B)
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            a_b = A[i:i+m,j:j+m]
            if (a_b==B).all():
                print('Yes');exit()
    print('No')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 27096
#include<stdio.h>
int main(){
  int a,s,d,f,g,h=0;

  scanf("%d%d%d",&a,&s,&d);

  for(f=a;f<=s;f++){

    g=d%f;

    if(g==0){
      h++;}
  }
  printf("%d\n",h);
  return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
# problem B

N = int(input())
S = str(input())

x = 0
x1 = 0


for i in range(N):
    if S[i] == 'I':
        x += 1
    if S[i] == 'D':
        x -= 1
    if x > x1:
        x1 = x

print(int(x1))

Measured memory_bytes: 3064
//AOJ0298.cpp

#include <iostream>
using namespace std;

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

  int h[101], m[101];
  for(int i=0; i<N; i++){
    cin >> h[i] >> m[i];
  }
  h[N] = 24; m[N] = 0;

  int M;
  cin >> M;

  int k[101], g[101];
  for(int j=0; j<M; j++){
  cin >> k[j] >> g[j];
  }
  k[M] = 24; g[M] = 0;

  for(int i=0, j=0; i<N || j<M;){
    if(h[i]==k[j] && m[i]==g[j]){
      cout << h[i] << ':' << m[i]/10 << m[i]%10;
      i++;  j++;
    }
    else if(h[i]<k[j] || (h[i]==k[j] && m[i]<g[j])){
      cout << h[i] << ':' << m[i]/10 << m[i]%10;
      i++;
    }
    else{
      cout << k[j] << ':' << g[j]/10 << g[j]%10;
      j++;
    }

    if(i==N && j==M){
      cout <<endl;
    }
    else{
      cout << ' ';
    }
  }

  return 0;
}

Measured memory_bytes: 3084