akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, a[100010];

signed main() {
    cin >> N;
    int mi = INF;
    rep(i,0,N) {
        cin >> a[i];
        chmin(mi, a[i]);
    }

    bool ng = false, same = true;
    int cnt = 0;
    rep(i,0,N) {
        a[i] -= mi;
        if(a[i] >= 2) ng = true;
        else if(a[i] == 1) same = false;
        else if(a[i] == 0) cnt++;
    }

    if(same && mi != N-1 && N < 2 * mi) ng = true;
    if(!same && (mi < cnt || 2 * (mi - cnt + 1) > (N - cnt))) ng = true;
    // printf("mi = %lld, cnt = %lld\n", mi, cnt);
    cout << (ng ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    bool f = false;
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] >= k){
            f = true;
        }
    }
    int G = a[0];
    rep(i, 1, n){
        G = __gcd(G, a[i]);
    }
    if(k % G != 0) f = false;
    if(f) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  int Sum=1;

  for (int i=0; i<N; i++){
    if (Sum < K)
      Sum *= 2;
    else
      Sum += K;
  }
  
  cout << Sum << endl;
  
}


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

int main()
{
	int n,d;

	cin >> n >> d;

		if(n%(d*2+1)) {cout <<((n/(d*2+1))+1)<<endl;}
		else cout <<(n/(d*2+1))<<endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

type Node struct {
	childs []*Node
	v      int
}

func main() {
	var n, q int
	s := wordScanner(100)
	scanInts(s, &n, &q)

	var a, b int
	l := make(map[int]*Node, n)
	for i := 0; i < n-1; i++ {
		scanInts(s, &a, &b)
		if _, ok := l[b]; !ok {
			l[b] = &Node{[]*Node{}, 0}
		}
		if nodea, ok := l[a]; ok {
			nodea.childs = append(nodea.childs, l[b])
			l[a] = nodea
		} else {
			l[a] = &Node{[]*Node{l[b]}, 0}
		}
	}

	var p, x int
	for i := 0; i < q; i++ {
		scanInts(s, &p, &x)
		l[p].v += x
	}

	dfs(l[1], 0)

	ans := make([]string, n)
	for i := 0; i < n; i++ {
		ans[i] = strconv.Itoa(l[i+1].v)
	}

	fmt.Println(strings.Join(ans, " "))

	// 木構造作成 & 各ノードのへのアクセスをmapで管理 O(n)
	// mapでアクセスし、加算値を保持 O(n)
	// DFSで各ノードの値を計算 O(n+m)
	// mapにより各nodeへアクセスし解答 O(n)
}

func dfs(node *Node, v int) {
	node.v += v
	for _, child := range node.childs {
		dfs(child, node.v)
	}
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}


Measured memory_bytes: 52864
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let (n, k): (i64, i64) = input();
    let x = n / k;
    let mut ans = x.pow(3);
    if k % 2 == 0 {
        let y = max(n / (k / 2) - x, 0);
        ans += y.pow(3);
    }
    println!("{}", ans);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	int ai,bi;
	for (int i=1;i<=n;i++)
	{
		cin>>ai>>bi;
		ans+=(bi-ai+1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 string s; cin >> s;
 int start=0,end=0,count=0;
 for(int i=0;i<s.size();i++) {
   if(s[i]=='A'){
     start=i; 
     break;
   }
 }
   for(int i=0;i<s.size();i++) {
    if(s[i]=='Z') end=i;
 }
 cout << end-start+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  vector<P> LR(N);
  rep(i, N) {
    cin >> LR[i].fi >> LR[i].se;
    LR[i].fi--;
  }
  ll ans = 0;

  sort(all(LR));
  vector<ll> numL(N), mxL(N), mnL(N);
  ll Lmx = 0, Rmn = LINF;
  rep(i, N) {
    chmax(Lmx, LR[i].fi);
    chmin(Rmn, LR[i].se);
    mxL[i] = Lmx;
    mnL[i] = Rmn;
    numL[i] = max(0LL, Rmn - Lmx);
  }

  vector<ll> numR(N), mxR(N), mnR(N);
  Lmx = 0;
  Rmn = LINF;
  repr(i, N - 1, 0) {
    chmax(Lmx, LR[i].fi);
    chmin(Rmn, LR[i].se);
    mxR[i] = Lmx;
    mnR[i] = Rmn;
    numR[i] = max(0LL, Rmn - Lmx);
  }

  rep(i, N - 1) {
    ll temp = numL[i] + numR[i + 1];
    chmax(ans, temp);
  }

  rep(i, N) {
    ll temp = LR[i].se - LR[i].fi;
    if (i == 0) {
      temp += numR[1];
    } else if (i == N - 1) {
      temp += numL[N - 2];
    } else {
      temp +=
          max(0LL, min(mnL[i - 1], mnR[i - 1]) - max(mxR[i + 1], mxL[i + 1]));
    }
    chmax(ans, temp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6528
x,y = map(int,input().split())
i = [1,3,5,7,8,10,12]
j = [4,6,9,11]
k = [2]
if x in i and y in i:
    print('Yes')
elif x in j and y in j:
    print('Yes')
elif x in k and y in k:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
//
//  main.c
//  ITP1_11_D
//
//  Created by k16031kk on 2018/06/03.
//  Copyright © 2018年 AIT. All rights reserved.
//

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int area[100][6];
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        for(int j=0; j<6; j++) {
            scanf("%d", &area[i][j]);
        }
    }
    
    int a=0;
    int flag=0;
    
    for(int i=0; i<n; i++) {
        for(int j=n; j>i; j--) {
            for(int k=0; k<3; k++) {
                a=area[i][0];
                area[i][0]=area[i][3];
                area[i][3]=area[i][5];
                area[i][5]=area[i][2];
                area[i][2]=a;
                if(memcmp(area[i], area[j], sizeof(int)*6)==0) {
                    //printf("1\n");
                    flag=1;
                    break;
                }
                for(int l=0; l<3; l++) {
                    a=area[i][0];
                    area[i][0]=area[i][1];
                    area[i][1]=area[i][5];
                    area[i][5]=area[i][4];
                    area[i][4]=a;
                    if(memcmp(area[i], area[j], sizeof(int)*6)==0) {
                        //printf("2\n");
                        flag=1;
                        break;
                    }
                    for(int m=0; m<3; m++) {
                        a=area[i][0];
                        area[i][0]=area[i][4];
                        area[i][4]=area[i][5];
                        area[i][5]=area[i][1];
                        area[i][1]=a;
                        if(memcmp(area[i], area[j], sizeof(int)*6)==0) {
                            //printf("3\n");
                            flag=1;
                            break;
                        }
                        for(int n=0; n<3; n++) {
                            a=area[i][0];
                            area[i][0]=area[i][2];
                            area[i][2]=area[i][5];
                            area[i][5]=area[i][3];
                            area[i][3]=a;
                            if(memcmp(area[i], area[j], sizeof(int)*6)==0) {
                                //printf("4\n");
                                flag=1;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    if(flag==1) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  
  int ans = (log(n))/(log(k));
  cout << ans +1 << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        int ans = 1 << 28;
        for (auto& i : v) cin >> i;
        for (int i = 1; i < (1<<N)-1; i++) {
            int A = 0, B = 0;
            for (int j = 0; j < N; j++)
                if (i&(1<<j)) A+=v[j];
                else B+=v[j];
            ans = min(ans, abs(A-B));
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
function main (arg) {
	arg = arg.trim().split(' ');
  	var a = Number(arg[0]), b = Number(arg[1]), out = [];
  	out.push(a+b, a-b, a*b);
  	out = Math.max(...out);
  	console.log(out);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#include <stdio.h>
#include <string.h>
#define MAX_HEAP 1500000
#define NEG_INF -100000

int heap_size = 1;
int parent(int);
int left(int);
int right(int);

void maxHeapfy(int *, int);
void maxHeapInsert(int *, int);
void heapIncreaseKey(int *, int, int);
int heapExtractMax(int *);

int main(void) {
  int key;
  int ary[MAX_HEAP];
  char order[10];

  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      maxHeapInsert(ary, key);
    } else if (order[1] == 'x') {
      int max = heapExtractMax(ary);
      printf("%d\n", max);
    } else {
      break;
    } 
  }
    
  return 0;
}

int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}

void maxHeapify(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int largest;

  if (l <= heap_size && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= heap_size && A[r] > A[largest]) {
    largest = r;
  }

  if (largest != i) {
    /* A[i]とA[largest]の値を交換 */
    int tmp = A[largest];
    A[largest] = A[i];
    A[i] = tmp;

    maxHeapify(A, largest);
  }
}

void maxHeapInsert(int *A, int key) {
  heap_size++;
  A[heap_size] = NEG_INF;
  heapIncreaseKey(A, heap_size, key);
}

void heapIncreaseKey(int *A, int i, int key) {
  if (key < A[i]) {             /* 新しいキーは現在のキーより小さい */
    return;
  }

  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    /* 親と子を入れ替える */
    int tmp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = tmp;
    i = parent(i);
  }
}

int heapExtractMax(int *A) {
  if (heap_size < 1) {          /* ヒープアンダーフロー */
    return -1;
  }

  int max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(A, 1);
  return max;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(3, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> v[j][i];
    for (int i = 0; i < n; i++) {
        int ans = 0;
        for (int j = 0; j < 3; j++) {
            if (count(v[j].begin(), v[j].end(), v[j][i]) == 1)
                ans += v[j][i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
while True:
    line = input()
    H, W = map(int, line.split())

    if H == 0 and W == 0:
        break

    for i in range(1, H+1):
        for j in range(1, W+1):
            if i == 1 or i == H or j == 1 or j == W:
                c = '#'
            else:
                c = '.'
            print(c, end='')
        print('')
    print('')

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
string q="keyence";

int main()
{
    int k=0,ans=0;
    string s;
    cin>>s;
    if(s[0]=='k'){
        for(int i=0;i<s.size();i++)
        {
            if(s[i]==q[i]) k++;
            else break;
        }

        int l=6,i=s.size()-1,j=0,m=7-k;
        while(1)
        {
            if(m<1) break;
            if(s[i]==q[l]) j++;
            l--;i--;m--;
        }
        if(j+k==7) cout<<"YES\n";
        else cout<<"NO\n";

    }
    else{
        int l=6,i=s.size()-1,j=0;
        while(1)
        {
            if(l<0) break;
            if(s[i]==q[l]) j++;
            l--;i--;
        }
        if(j==7) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " = " << x << endl
#define print_array(arr, len) {cerr << #arr << " = "; for (int i = 0; i < len; i++) cerr << arr[i] << " "; cerr << endl;}
#define print_iterable(it) {cerr << #it << " = "; for (const auto &e : it) cerr << e << " "; cerr << endl;}
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0
#define print_iterable(it) (void)0
#endif

using ll = long long;

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    eprintf("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>

#define ff first
#define ss second

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

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> rnk1(n),rnk2(n);
    vector<int> idx1(n),idx2(n);
    vector<int> cnt(max(27,n+1));
    for(int i=0; i<n; i++) rnk1[i]=s[i]-'a'+1;
    if(n==1) rnk1[0]=1;
    for(int i=1; i<n; i<<=1){
        fill(cnt.begin(),cnt.end(),0);
        for(int j=0; j<n; j++) cnt[(i+j>=n)?0:rnk1[i+j]]+=1;
        for(int j=1; j<cnt.size(); j++) cnt[j]+=cnt[j-1];
        for(int j=n-1; j>=0; j--) idx1[--cnt[(i+j>=n)?0:rnk1[i+j]]]=j;
        fill(cnt.begin(),cnt.end(),0);
        for(int j=0; j<n; j++) cnt[rnk1[j]]+=1;
        for(int j=1; j<cnt.size(); j++) cnt[j]+=cnt[j-1];
        for(int j=n-1; j>=0; j--) idx2[--cnt[rnk1[idx1[j]]]]=idx1[j];
        rnk2[idx2[0]]=1;
        for(int j=1; j<n; j++){
            if(rnk1[idx2[j-1]]==rnk1[idx2[j]] && rnk1[idx2[j-1]+i]==rnk1[idx2[j]+i]) rnk2[idx2[j]]=rnk2[idx2[j-1]];
            else rnk2[idx2[j]]=rnk2[idx2[j-1]]+1;
        }
        rnk1=rnk2;
    }
    int common=0;
    int answer=0;
    vector<pii> lcp(n);
    for(int i=0; i<n; i++){
        if(rnk1[i]==1){
            lcp[rnk1[i]-1]={common,i};
            continue;
        }
        int prv=idx2[rnk1[i]-2];
        while(i+common<n && prv+common<n && s[i+common]==s[prv+common]) common+=1;
        lcp[rnk1[i]-1]={common,i};
        if(common>0) common-=1;
    }
    vector<pii> group(1);
    group[0].first=0;
    for(int i=1; i<n; i++){
        if(lcp[i].first==0){
            group.back().second=i-1;
            group.push_back({i,0});
        }
    }
    group.back().second=n-1;
    
    for(pii& p : group){
        for(int i=p.first; i<=p.second; i++){
            int len=INT_MAX;
            for(int j=i+1; j<=p.second; j++){
                len=min(len,lcp[j].first);
                answer=max(answer,min(abs(lcp[i].second-lcp[j].second),len));
            }
        }
    }
    cout<<answer;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> d(n);
  for (ll i = 0; i < n; i++) cin >> d[i];
  for (ll i = 0; i < n-1; i++) {
    for (ll j = i+1; j < n; j++) {
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int []x = new int [n+1];
		int []y = new int [n+1];
		int []t = new int [n+1];

		t[0] = 0;
        x[0] = 0;
        y[0] = 0;		
		for (int i = 1; i < n + 1; ++i) {
			t[i] =sc.nextInt();
			x[i] =sc.nextInt();
			y[i] =sc.nextInt();
		}

		boolean can = true;
		for (int i = 0; i < n; ++i) {
			int dt = t[i+1] - t[i];
			int dist = Math.abs(x[i + 1] - x[i])
				+ Math.abs(y[i + 1] - y[i]);
			if (dt < dist) {
				can = false;
			}
			if (dt % 2 != dist % 2) {
				can = false;
			}
		}
		if(can) {
			System.out.print("Yes");
		} else {
			System.out.println("No");
	    }
	}
}




Measured memory_bytes: 91540
#include <stdio.h>

int main(void) {
	int X,A,B;
	scanf("%d",&X);
	scanf("%d",&A);
	scanf("%d",&B);
	int y = B-A;
	if (y <= 0){
		printf("delicious\n");
	}else if (y > 0 && y <= X){
		printf("safe\n");
	}else {
		printf("dangerous\n");
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		do {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				while (true) {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
					if (x != 0)
						continue;
					else
						break;
				}
			}

		} while (++i <= n);
		System.out.println();
	}
}



Measured memory_bytes: 28812
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll K;
    cin>>K;
    ll n=s.size();
    ll dp[n+1][K+1][2];
    rep(i,n+1)rep(j,K+1)rep(k,2)dp[i][j][k]=0;
    reverse(all(s));
    dp[0][K][0]=1;
    rep(i,n){
        ll temp=s[i]-'0';
        rep(j,K+1){
            if(j==0){
                dp[i+1][j][0]+=dp[i][j][0]+dp[i][j][1];
                continue;
            }
            rep3(k,1,10){
                if(k>temp){
                    dp[i+1][j-1][1]+=dp[i][j][0]+dp[i][j][1];
                }else if(k==temp){
                    dp[i+1][j-1][1]+=dp[i][j][1];
                    dp[i+1][j-1][0]+=dp[i][j][0];
                }else{
                    dp[i+1][j-1][0]+=dp[i][j][0]+dp[i][j][1];
                }
            }
            if(temp==0){
                dp[i+1][j][0]+=dp[i][j][0];
                dp[i+1][j][1]+=dp[i][j][1];
            }else{
                dp[i+1][j][0]+=dp[i][j][0]+dp[i][j][1];
            }
            
        }
    }
    cout<<dp[n][0][0]<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
  dp = list(range(n+1))
  for a, b in zip(A, B):
    if b <= a:
      continue
    for i in range(n+1):
      if i-a >= 0:
        dp[i] = max(dp[i], dp[i-a]+b)
  return dp[n]
m = f(n)
A, B = B, A
ans = f(m)
print(ans)

Measured memory_bytes: 260424
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if(a[i] >= h && b[i] >= w) ans++;
        }
        System.out.println(ans);
    }
}

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

const ll MOD = 1e9 + 7;

inline ll read() {
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

ll qp(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}

const int N = 2e5 + 10;
ll fac[N];

ll C(ll a, ll b) {
    ll ans = fac[a] * qp(fac[b], MOD - 2) % MOD;
    ans = ans * qp((fac[a-b] + MOD) % MOD, MOD - 2) % MOD;
    return ans;
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % MOD;
    ll n = read(), m = read(), k = read();
    ll ans = C(n * m, k) * C(k, 2) % MOD * qp(3, MOD - 2) % MOD;
    ans = ans * (n + m) % MOD;
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

using ll = long long;

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(p[i] - 1, i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    void dfs(int s, const vector<vector<int>>& G, vector<bool>& used, vector<vector<ll>>& dp) {
        used[s] = true;

        for (auto next : G[s]) {
            if (used[next]) continue;

            dfs(next, G, used, dp);

            dp[s][0] *= dp[next][0] + dp[next][1];
            dp[s][1] *= dp[next][0];
            dp[s][0] %= mod;
            dp[s][1] %= mod;
        }
    }
}

int main() {

    int n = inp1;
    vector<int> x(n - 1), y(n - 1);
    rep(i, n - 1) cin >> x[i] >> y[i];
    vector<vector<int>> G(n, vector<int>());
    rep(i, n - 1) {
        G[x[i] - 1].push_back(y[i] - 1);
        G[y[i] - 1].push_back(x[i] - 1);
    }

    // 白からは白黒の２通り，黒からは白の１通りしかない

    // めちゃくちゃ典型的なDPなんだろうな
    // こういうのを直ぐに解けるようになりたい

    // それぞれのノードで白になる場合の数と黒になる場合の数を保存したい

    // dp[i][j] := i番目のノードをjで塗ったときに，根の部分木の場合の数
    vector<vector<ll>> dp(n, vector<ll>(2, 1LL));

    vector<bool> used(n, false);

    dfs(0, G, used, dp);

    Cout((dp[0][0] + dp[0][1]) % mod);

    return 0;
}


Measured memory_bytes: 18944
//Zory in 2018
//*******************头文件*******************
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
typedef long long ll;
typedef unsigned long long ull;
ll mymax(ll x,ll y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
int myabs(int x) {return x>0?x:-x;}
//*******************全局常量*******************
const int MAXN=110000;
//*******************全局定义*******************
ll f[MAXN],g[MAXN];//顺时针，逆时针
ll x[MAXN],v[MAXN];
//*******************实现*******************

//*******************主函数*******************
int main()
{
	//freopen("tmp.in","r",stdin);
    int n;ll c;scanf("%d%lld",&n,&c);
    for(int i=1;i<=n;i++) scanf("%lld%lld",&x[i],&v[i]);

    ll ans=0,sum;
    sum=0;for(int i=1;i<=n;i++) sum+=v[i],f[i]=sum-x[i],ans=mymax(ans,f[i]);
    sum=0;for(int i=n;i>=1;i--) sum+=v[i],g[i]=sum-(c-x[i]),ans=mymax(ans,g[i]);

    ll mx;
    mx=0;for(int i=n-1;i>=1;i--) mx=mymax(mx,g[i+1]),ans=mymax(ans,f[i]+mx-x[i]);
    mx=0;for(int i=2;i<=n;i++) mx=mymax(mx,f[i-1]),ans=mymax(ans,g[i]+mx-(c-x[i]));

    printf("%lld",ans);
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<cmath>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
#define MAX_V 2*100000+10

using namespace std;



bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli k, n, m, e;


int main() {
	string s;
	cin >> s;
	s = "L"+s+"R";
	vector <string::size_type>vec;
	string::size_type pos=s.find("LR");
	while (pos != string::npos) {
		vec.push_back(pos);
		pos = s.find("RL", pos + 1);
		if (pos == string::npos)break;
		vec.push_back(pos);
		pos = s.find("LR", pos + 1);
	}
	rep1(i,vec.size()/2) {
		rep0(j, (int)(vec[2*i-1] - vec[2*i-2])-1) {
			cout << "0 ";
		}
		
		cout << (int)(vec[2 * i] - vec[2 * i - 1]) / 2 + (int)(vec[2 * i -1] - vec[2 * i - 2]) / 2 + ((int)(vec[2 * i -1] - vec[2 * i - 2])) % 2 << " ";
		cout << (int)(vec[2 * i - 1] - vec[2 * i - 2]) / 2 + (int)(vec[2 * i] - vec[2 * i - 1]) / 2 + ((int)(vec[2 * i] - vec[2 * i - 1])) % 2 << " ";
		rep0(j, (int)(vec[2 * i] - vec[2 * i - 1]) - 1) {
			cout << "0 ";
		}
	}
	
	
}




Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

ll INF = (1e17);
vector < vector<ll> > N;
ll n,m,k,s;
ll q,p;
ll mati[200000];
ll cost[200000];
 
ll dist[200000];
void dijkstra(int costA,int costB){
  priority_queue< P , vector<P> , greater<P> > Q;
  for(int i=1;i<=n;i++)
    if(dist[i]==0)Q.push(P(0,i));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    ll cost=p.first;
    ll pos=p.second;

    if( dist[pos] < cost )continue;
    for(int i=0;i<(int)N[pos].size();i++){
      ll to=N[pos][i];
      ll ncost=cost;

      if(to!=n){
        if(mati[to]==0)ncost+=costA;
        if(mati[to]==1)continue;
        if(mati[to]==2)ncost+=costB;
      }

      if( dist[to] > ncost ){
        dist[to]=ncost;
        Q.push(P(ncost,to));
      }

    }
  }


}

int main(){

  ios::sync_with_stdio(false);
  cin.tie(0);

  cin>>n>>m>>k>>s;
  cin>>p>>q;

  for(int i=1;i<=n;i++)dist[i]=INF;

  ll c;
  while(k--){
    cin>>c;
    mati[c]=1;
    dist[c]=0;
  }

  N.resize( n+1 );
  while(m--){
    ll a,b;
    cin>>a>>b;
    N[a].push_back(b);
    N[b].push_back(a);
  }
  
  dijkstra(1,1);

  for(int i=1;i<=n;i++){
    if(dist[i]==0)mati[i]=1;
    if(1<=dist[i]&&dist[i]<=s)mati[i]=2;
    if(s<dist[i])mati[i]=0;
  }

  for(int i=1;i<=n;i++)dist[i]=INF;
  dist[1]=0;
  dijkstra(p,q);
  cout<<dist[n]<<endl;

  /*
  while(!Qb.empty()){
    ll a=Qb.front().first,b=Qb.front().second;
    Qb.pop();
    if(mati[a]==0)mati[a]=2;
    if(a>=s) continue;
    for(ll i=0;i<(ll)N[b].size();i++) {
      if(mati[ N[b][i] ]==2)continue;
      Qb.push(P(a+1,N[b][i]));
      if(mati[ N[b][i] ]==0)mati[ N[b][i] ] = 2;
    }
  }

  for(int i=0;i<=n;i++) cost[i]=1e+9;
  priority_queue<P, vector<P>, greater<P> > Q;
  Q.push(P(0,1));
  while(!Q.empty()){
    cout<<"OK"<<endl;
    ll a=Q.top().first,b=Q.top().second;
    if(b==n) break;
    Q.pop();
    if(cost[b]<a) continue;

    if(b!=1){
      if(mati[b]==2) a+=q;
      else a+=p;
    }

    for(int i=0;i<(int)N[b].size();i++)
      if(mati[N[b][i]]!=1 && cost[b]>a){
        cost[b]=a;
        Q.push(P(a,N[b][i]));
      }
  }
  cout<<Q.top().first<<endl;
  */
  return 0;
}

Measured memory_bytes: 13172
## constant

MAX_SUM = 20

### main

n = gets.strip.to_i
ds = gets.strip.split(' ').map{|s| s.to_i}

n -= 1
sum = ds.pop
#p [ds, sum]

psums = (MAX_SUM + 1).times.map{0}
psums[ds[0]] = 1

for i in (1...n)
  d = ds[i]
  csums = (MAX_SUM + 1).times.map{0}

  for s in (0..MAX_SUM)
    s0 = s + d
    csums[s0] += psums[s] if s0 <= MAX_SUM
    s1 = s - d
    csums[s1] += psums[s] if s1 >= 0
  end

  psums = csums
  #p [d, psums]
end

puts psums[sum]

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;

int main()
{
    string s;
    cin>>s;
    int cnt=0,MAX=0;
    rep(i,3){
        if(s[i]=='R')cnt++;
        else cnt=0;
        MAX = max(MAX,cnt);
    }
    cout<<MAX<<endl;
    return 0;
}


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  for(int A = 1; A <= 9; A++){
    for(int B = 1; B <= A; B++){
      if(A * B == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int A[] = new int[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		Arrays.parallelSort(A);
		for (int i=0;i<N;i++) {
			X-=A[i];
		}
		System.out.println(N+X/A[0]);
	}

}

Measured memory_bytes: 36060
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
  string S;cin>>S;
  string cs=S;
  string a="",b="",ca,cb;
  int A=0,B=1;
  int Q;cin>>Q;
  REP(i,Q){
    int t,f;string c;
    cin>>t;
    if(t==1){
      swap(A,B);
    }else{
      cin>>f>>c;
      if(A==0){
        if(f==1){
          b+=c;
        }else{
          a+=c;
        } 
      }else{
        if(f==2){
          b+=c;
        }else{
          a+=c;
        }
      }
    }
  }
  if(A==0){
    reverse(All(b));
    cout<<b<<S<<a<<endl;
  }else{
    reverse(All(a));
    reverse(All(S));
    cout<<a<<S<<b<<endl;
  }
}


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

int main(){
    int a[4]={0},b[4]={0};
    while(true){
        scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
        if(scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]) == EOF)
            break;
        int hit=0,blow=0;
        for(int i=0;i<4;++i)
            if(a[i] == b[i])
                hit++;
        for(int i=0;i<4;++i)
            for(int j=0;j<4;++j)
                if(i != j && a[i] == b[j])
                    blow++;
        cout << hit << ' ' << blow << endl;
    }

    return 0;
}


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

void dfs(vector<vector<pair<int, int>>>& g, int cur, int start,
         vector<int>& ans) {
    for (auto node : g[start]) {
        int v, w;
        tie(v, w) = node;
        if (ans[v] != -1) continue;
        int tmp = (w % 2 ? 1 - cur : cur);
        ans[v] = tmp;
        dfs(g, tmp, v, ans);
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        g[u].push_back(make_pair(v, w));
        g[v].push_back(make_pair(u, w));
    }
    vector<int> ans(n, -1);
    ans[0] = 0;
    dfs(g, 0, 0, ans);
    for (auto x : ans) cout << x << endl;
}


Measured memory_bytes: 8960
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 03:46:03 2020

@author: Dell
"""

n=int(input())
m=list(map(int,input().split()))
from collections import Counter
d=Counter(m)
p=0
l=0
for i in d:
    p+=1
    if d[i]%2==0:
        l+=1
if l%2==0:
    print(p)
else:
    print(p-1)

Measured memory_bytes: 97956
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    int N,A,B;
    cin >> N;
    A = N;
    vector<int> v;
    while(A > 0){
        v.push_back(A % 10);
        A /= 10;
    }
    int sum = 0;
    for(int i = 0; i < v.size(); i++){
        sum += v[i];
    }
    if(N %sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  long long H, M;
  scanf("%lld", &H);
  scanf("%lld", &M);
  if (H==1 && M==1){
    printf("1\n");
  } else if (H==1){
    printf("%lld\n", M-2);
  } else if (M==1){
    printf("%lld\n", H-2);
  } else {
    printf("%lld\n", (H-2)*(M-2));
  }
  return 0;
}


Measured memory_bytes: 760
'use strict'
function Main(input) {
	const lines = input.split('\n');
	const sArr = lines[0].split('');
	const lastInd = sArr.length - 1;
	let hugCount = 0;
	sArr.some((v, i) => {
		if (i >= lastInd - i) return true
		if (v !== sArr[lastInd - i]) hugCount++;
	});
	
	console.log(hugCount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
    int M;      //月
    int D;      //日
    int ans=0;    //積の日
    int i;      //月用ループ
    int j;      //日用ループ
    int mul;    //積
    int date;   //日
    
    scanf( "%d%d", &M, &D );
    
    for ( i=2; i<=9; i++ )
    {
        for( j=2; j<=9; j++ )
        {
            mul = i * j;
            date = (i * 10) + j;
            if( date <= D )
            {
                if( mul <= M )
                {
                    ans++;
                }
            }
        }
    }
    printf( "%d", ans );
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 1;

int n;
ll k, res = 0;
ll a[maxN];

map <ll, ll> mp;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, n)
    {
        cin >> a[i];
        a[i] = ((a[i] + a[i - 1] - 1) % k + k) % k;
    }
    int idx = n;
    for (int i = n; i > 0; --i)
    {
        while (i + k <= idx)
        {
            --mp[a[idx]];
            --idx;
        }
        res += mp[a[i]];
        ++mp[a[i]];
    }
    while (k <= idx)
    {
        --mp[a[idx]];
        --idx;
    }
    res += mp[0];
    cout << res;
    return 0;
}


Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static final String[] timeClass = { "AAA", "AA", "A",
			"B", "C", "D", "E", "NA" };
	static final double[][] timeTable = {
			{ 35.5, 71.0 }, // AAA
			{ 37.5, 77.0 }, // AA
			{ 40.0, 83.0 }, // A
			{ 43.0, 89.0 }, // B
			{ 50.0, 105.0 }, // C
			{ 55.0, 116.0 }, // D
			{ 70.0, 148.0 } // E
	};

	public static void main(String[] args)
			throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		String buf = null;
		while ((buf = br.readLine()) != null) {
			String[] time = buf.split(" ");
			System.out.println(judgeClass(
					Double.parseDouble(time[0]),
					Double.parseDouble(time[1])));
		}
	}

	public static String judgeClass(double timeOf500m,
			double timeOf1000m) {
		// 500m比較
		for (int timeClassOf500m = 0; timeClassOf500m < timeTable.length; timeClassOf500m++) {
			// 500mテーブル未満のとき
			if (timeOf500m < timeTable[timeClassOf500m][0])
				// 1000mテーブル比較
				for (int timeClassOf1000m = timeClassOf500m; timeClassOf1000m < timeTable.length; timeClassOf1000m++) {
					if (timeOf1000m < timeTable[timeClassOf1000m][1]) {
						return timeClass[timeClassOf1000m];
					}
				}
		}
		return timeClass[timeClass.length - 1];
	}
}

Measured memory_bytes: 16988
from sys import stdin
import numpy as np
from numpy import linalg as LA


a,b,x = [int(x) for x in stdin.readline().rstrip().split()]

if x >= (a**2)*b/2:
    takasa = b-(2*x-(a**2)*b)/(a**2)

    u = np.array([takasa,a])
    v = np.array([b,0])

    i = np.inner(u, v)
    n = LA.norm(u) * LA.norm(v)

    c = i / n
    j = np.rad2deg(np.arccos(np.clip(c, -1.0, 1.0)))

    print(90-j)

else:
    takasa = 2*x/(a*b)
    u = np.array([b,takasa])
    v = np.array([b,0])

    i = np.inner(u, v)
    n = LA.norm(u) * LA.norm(v)

    c = i / n
    j = np.rad2deg(np.arccos(np.clip(c, -1.0, 1.0)))

    print(90-j)

Measured memory_bytes: 21264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll inf = 1e18;
ll mod = 1e9+7;
double PI = acos(-1);
int main(){
    double r;
    cin >> r;
    cout << setprecision(20) << 2 * PI * r << endl;
    return 0;
}

Measured memory_bytes: 3808
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    set<int> a;
    int x;
    rep(i,n){cin>>x;a.insert(x);}
    cout<<a.size()<<endl;
}

Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//

const int N = 100010;
vector<int> adj[N];
int vis[N], dist[N], in[N];

void dfs(int nod)
{
    vis[nod] = 1;
    for(auto x: adj[nod])
    {
        dist[x] = max(dist[x], dist[nod] + 1);
        in[x]--;
        if(in[x] == 0)
            dfs(x);
    }
}

int32_t main()
{
    io;
    int n,m ;
    cin>>n>>m;
    while(m--)
    {
        int u, v;
        cin>>u>>v;
        adj[u].pb(v);
        in[v]++;
    }

    for(int i = 1; i<= n; i++)
        if(vis[i] == 0 && in[i] == 0)
            dfs(i);

    int ans = 0;
    for(int i = 1; i<= n;i++)
        ans = max(ans, dist[i]);

    cout<<ans;
    return 0;
}

Measured memory_bytes: 14860
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int ans=1e9;
    for(int i=-100;i<101;i++){
        int now=0;
        for(int j=0;j<n;j++){
            now+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}

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

struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y) {}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
    Point operator+(Point p){
        return Point(x + p.x, y + p.y);
    }
    Point operator*(double d){
        return Point(x * d, y * d);
    }
};
typedef Point Vector;
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
struct Line{
    Point p1;
    Point p2;
    Line(Point p1, Point p2) : p1(p1), p2(p2) {}
};
struct Circle{
    Point c;
    double r;
    Circle(Point c, double r): c(c), r(r) {}
};

Point cross_point1(Circle c, Line l){
    Vector b = l.p2 - l.p1;
    Vector h = c.c - l.p1;
    double d = fabs(cross(b, h)) / sqrt(dot(b, b));
    Point x =  l.p1 + b * (dot(h, b) / dot(b, b));
    return x + b * (sqrt(c.r * c.r - d * d) / sqrt(dot(b, b)));
}

Point cross_point2(Circle c, Line l){
    Vector b = l.p2 - l.p1;
    Vector h = c.c - l.p1;
    double d = fabs(cross(b, h)) / sqrt(dot(b, b));
    Point x =  l.p1 + b * (dot(h, b) / dot(b, b));
    return x - b * (sqrt(c.r * c.r - d * d) / sqrt(dot(b, b)));
}
void disp(Point a, Point b){
    Point f = a;
    Point s = b;
    if (f.x > s.x || (f.x == s.x && f.y > s.y)) swap(f, s);
    cout << fixed << setprecision(10);
    cout << f.x << " " << f.y << " " << s.x << " " << s.y << endl;
}

int main(){
    int cx, cy, r;
    cin >> cx >> cy >> r;
    Circle c(Point(cx, cy), r);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        Line l(Point(x1, y1), Point(x2, y2));
        disp(cross_point1(c, l), cross_point2(c, l));
    }
    return 0;
}



Measured memory_bytes: 3296