akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	k := scanInt(sc)
	visited := map[int]struct{}{}
	it := 7
	num := 0
	for true {
		num++
		if _, ok := visited[it]; ok {
			return -1
		}
		visited[it] = struct{}{}
		if it%k == 0 {
			break
		}
		it = (moduloMul(it, 10, k) + 7) % k
	}
	return num
}

func moduloAdd(a, b, modulo int) int {
	result := a%modulo + b%modulo
	if result < 0 {
		result += modulo
	}
	return result % modulo
}

func moduloSub(a, b, modulo int) int {
	result := a%modulo - b%modulo
	if result < 0 {
		result += modulo
	}
	return result % modulo
}

func moduloMul(a, b, modulo int) int {
	return a % modulo * b % modulo
}

func moduloDiv(a, b, modulo int) int {
	return a % moduloInv(b, modulo) % modulo
}

func moduloInv(a, modulo int) int {
	b := modulo
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a, b = b, a-t*b
		u, v = v, u-t*v
	}
	u %= modulo
	if u < 0 {
		u += modulo
	}
	return u
}

func moduloPow(a, b, modulo int) int {
	res := 1
	for b > 0 {
		if b&1 == 1 {
			res = res * a % modulo
		}
		a = a * a % modulo
		b >>= 1
	}
	return res
}

const length = 510000

var (
	_fac  = map[int][]int{}
	_finv = map[int][]int{}
	_inv  = map[int][]int{}
)

func moduloCombiInit(modulo int) {
	fac := make([]int, length)
	finv := make([]int, length)
	inv := make([]int, length)

	defer func() {
		_fac[modulo] = fac
		_finv[modulo] = finv
		_inv[modulo] = inv
	}()

	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < length; i++ {
		fac[i] = fac[i-1] * i % modulo
		inv[i] = modulo - inv[modulo%i]*(modulo/i)%modulo
		finv[i] = finv[i-1] * inv[i] % modulo
	}
}

func moduloCombi(n, k, modulo int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return _fac[modulo][n] * (_finv[modulo][k] * _finv[modulo][n-k] % modulo) % modulo
}

func moduloLog(a, b, modulo int) int {

	a %= modulo
	b %= modulo
	m := int(math.Sqrt(float64(modulo)))

	values := map[int]int{}
	val := 1
	for i := 0; i < m+2; i++ {
		if _, ok := values[val]; !ok {
			values[val] = i
		}
		val = moduloMul(val, a, modulo)
	}

	compound := moduloInv(moduloPow(a, m, modulo), modulo)
	val = b
	for i := 0; i < m+2; i++ {
		if l, ok := values[val]; ok {
			return (i*m%modulo + l) % modulo
		}
		val = moduloMul(val, compound, modulo)
	}
	return -1
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 46876
MOD = 1000000007

def solve(n, s1, s2):
    if s1[0] != s2[0]:
        ans = 6
        i = 2
        prev_solid = False
    else:
        ans = 3
        i = 1
        prev_solid = True
    shape_factor_mapping = {
        (True, True): 2,
        (True, False): 2,
        (False, True): 1,
        (False, False): 3
    }
    while i < n:
        solid = (s1[i] == s2[i])
        factor = shape_factor_mapping[prev_solid, solid]
        ans = (factor * ans) % MOD
        i += 2 - solid
        prev_solid = solid
    return ans

n = int(input())
s1 = input()
s2 = input()
print(solve(n, s1, s2))

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

int a,b,c;
string s;

int main(){
    cin >> s;
  for(int i=0;i<3;i++)
  {
    if(s[i] == 'a')
      a++;
    if(s[i] == 'b')
      b++;
    if(s[i] == 'c')
      c++;
  }
  if(a*b*c){
    cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
    }
    
	return 0;
}




Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  int A, B;
  cin >> a >> b >> A >> B >> c;
  if(a == c) A--;
  if(b == c) B--;
  cout << A << " " << B << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
S = input()
T = input()

change_num = 1000000000
count = 0

for i in range(len(S)):
    if (len(T) + i) > len(S):
        break

    s = S[i:len(T) + i]
    for j, k in enumerate(s):
        if k != T[j]:
            count += 1

    if count < change_num:
        change_num = count

    count = 0


print(change_num)


Measured memory_bytes: 8936
#include<cstdio>
#define N 1000000

using namespace std;

int main(void){
	int i,j;
	int num[N+1];
	int n,count;

	num[0]=0;
	num[1]=0;
	for(i=2;i<N+1;i++)
		num[i]=1;
	for(i=2;i<N+1;i++)
		if(num[i])
			for(j=i+i;j<=N;j+=i)
				num[j]=0;

	for(;;){
		scanf("%d",&n);
		if(!n)
			break;

		count=0;
		for(i=2;i<=n/2;i++)
			if(num[i] && num[n-i])
				count++;
		
		printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

LL modt[100002], imodt[100002];

int n, in[100001];
int samel, samer;

LL modpow(LL a, LL b) {
	LL x = 1, times = a;
	while (b > 0) {
		if (b & 1)x *= times;
		times *= times;
		x %= MOD;
		times %= MOD;
		b >>= 1;
	}
	return x;
}
LL comb(LL n, LL r) {
	if (r > n)return 0;
	LL ans = modt[n];
	ans = (ans * imodt[r]) % MOD;
	ans = (ans * imodt[n - r]) % MOD;
	return ans;
}

int a[100100];
int C[100100];

int main() {
	modt[0] = 1;
	modt[1] = 1;
	for (int i = 2; i <= 100001; i++) {
		modt[i] = modt[i - 1] * i;
		modt[i] %= MOD;
	}

	imodt[100001] = modpow(modt[100001], 1000000005);
	for (int i = 100000; i >= 0; i--) {
		imodt[i] = imodt[i + 1] * (i + 1);
		imodt[i] %= MOD;
	}

	int n;
	cin >> n;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
		C[a[i]]++;
	}
	int pos1 = -1, pos2;
	for (int i = 0; i < n + 1; i++) {
		if (C[a[i]] == 2) {
			if (pos1 == -1)pos1 = i + 1;
			else pos2 = i + 1;
		}
	}
	if (n == 1) {
		for (int i = 1; i <= n + 1; i++) {
			cout << 1 << endl;
		}
		return 0;
	}
	LL ans = 0;
	for (int i = 1; i <= n + 1; i++) {
		ans = comb(n + 1, i);
		ans -= comb(pos1 - 1 + n + 1 - pos2, i - 1);
		ans += MOD;
		ans %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3584
n=int(input())
m=[[]*n for i in range(3)]

for i in range(n):
    a,b,c=map(int,input().split())
    m[0].append(a)
    m[1].append(b)
    m[2].append(c)

dp=[[0]*n for i in range(3)]
dp[0][0]=m[0][0]
dp[1][0]=m[1][0]
dp[2][0]=m[2][0]

for i in range(1,n):
    for j in range(3):
        for k in range(3):
            if(j==k):continue
            dp[j][i]=max([dp[j][i],dp[k][i-1]+m[j][i]])

print(max([dp[0][n-1],dp[1][n-1],dp[2][n-1]]))

Measured memory_bytes: 26876
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};


Node *root, *NIL;

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;   
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}  

Measured memory_bytes: 22024
import java.util.*;

public class Main {

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

    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        scanner.nextLine();
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] cnt = new int[100_001];
        for (int n: a) {
            cnt[n]++;
        }

        for (int i = 0; i < cnt.length; i++) {
            if (cnt[i] < 2) {
                continue;
            }
            if (cnt[i] % 2 == 1) {
                cnt[i] = 1;
            } else {
                cnt[i] = -1;
            }
        }

        long total = Arrays.stream(cnt).filter(x -> x > 0).sum();
        long even = Arrays.stream(cnt).filter(x -> x < 0).count();
        total += even;
        if (even % 2 == 1) {
            total--;
        }
        System.out.println(total);
    }

}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    ll n,ans = 0;
    cin >> n;
    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }else{
        int count = 1;
        for(ll i = 10; i <= n; i *= 5){
            ans += (n / i);
            count++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = map(str, input().split())
n_a, n_b = map(int, input().split())
s_u = str(input())
s_a = 1 if a == s_u else 0
s_b = 1 - s_a
out = "{0} {1}".format(n_a - s_a, n_b - s_b)
print(out)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        if(op.equals("+")){
            System.out.println(a+b);
        }
        if(op.equals("-")){
            System.out.println(a-b);
        }
        if(op.equals("*")){
            System.out.println(a*b);
        }
        if(op.equals("/")){
            System.out.println(a/b);
        }   
        if(op.equals("?")){
            break;
        }   
        }   
        sc.close();
    }
}


Measured memory_bytes: 26388
def calculator(a, b, op):

    res = None

    if op == "?":
        pass
    elif op == "+":
        print(str(int(a + b)))

    elif op == "-":
        res = a - b
        print(str(int(a - b)))

    elif op == "*":
        res = a * b
        print(str(int(a * b)))

    elif op == "/":
        res = a / b
        print(str(int(a / b)))
    
    else:
        pass


if __name__ == "__main__":

    while(1):


        param = input()
        param = param.split(" ")
        
        a = int(param[0])
        op = param[1]
        b = int(param[2])

        if op != "?":
            calculator(a, b, op)
        else:
            break



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


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] data = in.readLine().split(" ");
		int[] num = new int[6];
		for(int i=0; i<6; i++){
			num[i] = Integer.parseInt(data[i]);
		}
		Dices dice = new Dices(num[0],num[1],num[2],num[3],num[4],num[5]);
		String order = in.readLine();
		char[] chOrder = order.toCharArray();
		for(int j=0; j<order.length(); j++){
			if(chOrder[j]=='N'){
				dice.north();
			} else if(chOrder[j]=='E'){
				dice.east();
			} else if(chOrder[j]=='W'){
				dice.west();
			} else if(chOrder[j]=='S'){
				dice.south();
			}
		}
		System.out.println(dice.on);
	}
}

class Dices{
	public int on, tw, th, fo, fi, si;
	public Dices(int on, int tw, int th, int fo, int fi, int si){
		this.on = on;
		this.tw = tw;
		this.th = th;
		this.fo = fo;
		this.fi = fi;
		this.si = si;
	}
	void north(){
		int temp = on;
		on = tw;
		tw = si;
		si = fi;
		fi = temp;
	}
	void east(){
		int temp = on;
		on = fo;
		fo = si;
		si = th;
		th = temp;
	}
	void west(){
		int temp = on;
		on = th;
		th = si;
		si = fo;
		fo = temp;
	}
	void south(){
		int temp = on;
		on = fi;
		fi = si;
		si = tw;
		tw = temp;
	}
}

Measured memory_bytes: 17060
#include<stdio.h>
#define MAX 36
#define True 1
#define False 0
 
typedef struct{
  char c;
  int num;
} card;
 
void cardsort(card []);
void select(card []);
int search(card [],card []); 
 
int number;
 
int main(){
  int i,j;
  card data[MAX];
  card data2[MAX];
   
   
  scanf("%d",&number);
  for(i=0;i<number;i++) {
    scanf(" %c%d",&data[i].c,&data[i].num);
  }
   
  for(i=0;i<number;i++) {
    data2[i] = data[i];
  }
   
  cardsort(data);
  select(data2);
 
   
  for(i=0;i<number-1;i++){
    printf("%c%d ",data[i].c,data[i].num);
  }
  printf("%c%d\n",data[number-1].c,data[number-1].num);
  printf("Stable\n");
 
   
  for(i=0;i<number-1;i++){
    printf("%c%d ",data2[i].c,data2[i].num);
  }
  printf("%c%d\n",data2[number-1].c,data2[number-1].num);
 
  if(search(data,data2)==1) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}
 
 
void cardsort (card n[]){
  int i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    for(j=number-1;j>i;j--){
      if(n[j].num<n[j-1].num){
    tmp=n[j].num;
    n[j].num=n[j-1].num;
    n[j-1].num=tmp;
 
    tmpc=n[j].c;
    n[j].c=n[j-1].c;
    n[j-1].c=tmpc;
      }
    }
  }
}
 
 
void select(card n[]){
 
  int min,i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    min=i;
    for(j=i;j<number;j++){
      if(n[j].num<n[min].num){
    min=j;
      }
    }
    if(min != i){
      tmp=n[i].num;
      n[i].num=n[min].num;
      n[min].num=tmp;
 
      tmpc=n[i].c;
      n[i].c=n[min].c;
      n[min].c=tmpc;
    }
  }
}
 
int search(card data[],card data2[]){
  int i,count=0;
    for(i=0;i<number;i++){
      if(data[i].c != data2[i].c || data[i].c != data2[i].c){
    return False;
      }
    }
    return True;
}
 

Measured memory_bytes: 608
#include <iostream>
#include<stdio.h>
using namespace std;
int main() {
	double a, b; int d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = static_cast<int>(a) % static_cast<int>(b);
	f = a / b;
	printf("%d %d %.8f\n", d, r, f);
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  vector<int> a(5);
  int k;
  cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4) >> k;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (abs(a.at(i) - a.at(j)) > k) {
	cout << ":(\n";
	return 0;
      }
    }
  }
  cout << "Yay!\n";

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n,x;
    cin>>n>>x;
    long int a[n];
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int ans=1,d=0;
    for(long int i=0;i<n;i++)
    {
        d+=a[i];
        if(d>x)
        {
            break;
        }
        ans++;
    }
    cout<<ans<<endl;
    
    
       
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int MAXN = 1e5 + 10;

ll Combination(ll n, ll k)
{
    ll c[n+1][k+1];
    
    for(ll i=0; i<=n; i++)
    {
        for(ll j=0; j<=min(i, k); j++)
        {   
            if(j==0)
            c[i][j]=1;
            else
            {
               c[i][j]=c[i-1][j]+c[i-1][j-1];
            }
            c[i][j+1]=0;
        }
    }
    return c[n][k];
}
void solve()
{   
    ll n1, m1;
    cin>>n1>>m1;
    ll a, b;
    cout<<Combination(n1, 2)+Combination(m1, 2)<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//ll t;
	//cin>>t;
		solve();
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

for i in range(n-1):
    a[i+1]+=a[i]

j=0
k=2
ans=10**9

for i in range(1,n-1):
    while abs(a[j]*2-a[i])>abs(a[j+1]*2-a[i]):
        j+=1
    while abs(a[k]*2-a[i]-a[n-1])>abs(a[k+1]*2-a[i]-a[n-1]):
        k+=1
    t=[a[j],a[i]-a[j],a[k]-a[i],a[n-1]-a[k]]
    ans=min(ans,max(t)-min(t))
print(ans)

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

int main() {

int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;


if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H)
{
  cout << "Yes" <<endl; 
}else{
  cout<<"No"<<endl;
}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double w,h,x,y;
  cin >> w >> h;
  cin >> x >> y;

  if((int)h % 2 == 0 && (int)w % 2 == 0){
    if(h/2 == y && w/2 == x){
      printf("%0.10lf 1\n",h*w/2.0);
      return 0;
    }
  }
  printf("%0.10lf 0\n",h*w/2.0);
  return 0;

}


Measured memory_bytes: 256
s = input()
ans = ""
a = int(s[0]+s[1])
b = int(s[2]+s[3])

if a == 0 and b == 0:
    ans = "NA"
elif a > 12 and b == 0:
    ans = "NA"
elif a == 0 and b > 12:
    ans = "NA"
elif a > 12 and b > 12:
    ans = "NA"
elif a > 12 and b < 13 and b != 0:
    ans = "YYMM"
elif a < 13 and b > 12 and a != 0:
    ans = "MMYY"
elif a == 0 and b < 13:
    ans = "YYMM"
elif a < 13 and b == 0:
    ans = "MMYY"
else:
    ans = "AMBIGUOUS"

print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33872
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

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

long long x[N];
long long y[N];


rep(i,N){
    cin>>x[i]>>y[i];
}
map<pair<long long ,long long>,int>I;
//I[make_pair(dx,dy)]:=距離dx,dyの辺の数

for(int i=0;i<N;i++){
    for(int k=0;k<N;k++){
        if(i==k)continue;
        long long dx=x[i]-x[k];
        long long dy=y[i]-y[k];
        I[(make_pair(dx,dy))]++;
    }
}

int best=0;
auto iter=I.begin();

while(iter!=I.end()){
best=max(iter->second,best);
iter++;
}
cout<<N-best<<endl;

 return 0;
}
/*

2
1 1
2 2

1

3
1 4
4 6
7 8

1


4
1 1
1 2
2 1
2 2

2
*/

Measured memory_bytes: 384
/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define in insert
#define cn count
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef set<int> si;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/
void solve() {
	int n;
	R(n);
	vi v(n), pre(n);
	rep(i, 0, n - 1) R(v[i]);
	pre[0] = v[0];
	rep(i, 1, n - 1) {
		pre[i] = min(v[i], pre[i - 1]);
	}
	int ans = 1;
	rep(i, 1, n - 1) {
		if (pre[i] >= v[i])
			ans++;
	}
	W(ans);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
int main() {
	int N, M;
	cin >> N >> M;
	if (N > M) swap(N, M);
	if (N == 1) {
		cout << max(M - 2, 1) << endl;
		return 0;
	}
	else if (N == 2) {
		cout << 0 << endl;
		return 0;
	}
	cout << (LL)(N - 2)*(M - 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int total = 0;
    rep(i, n) {
        cin >> a[i];
        total += a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    rep(i, m){
        if(a[i] < ((double)total * (1.0 / (4.0 * (double)m)))){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 110
using namespace std;
int a[maxn];

int main() {
	int n;
	while(~scanf("%d", &n)) {
		memset(a, 0, sizeof(a));
		int sum = 0;
		for(int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			sum += a[i];
		}
		sort(a + 1, a + 1 + n);
		int count = 0;
		while(sum % 10 == 0 && count != n) {
			if(a[count + 1] % 10 != 0) {
				sum -= a[count + 1];
			}
			count++;
		}
		if(sum % 10 == 0) {
			puts("0");
		}
		else {
			printf("%d\n", sum);
		}
	}
	return 0;
} 

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
dic={}
for a in A:
  if a in dic:
    dic[a]+=1
  else:
    dic[a]=1
   

c=0
for i in dic.values():
  c+=i*(i-1)/2
for j in range(1,N+1):
  d=c-dic[A[j-1]]+1
  print(int(d))
  


Measured memory_bytes: 26140
#include<bits/stdc++.h>
/*
ID: arun.ga1
LANG: C++
TASK: 
 */

using namespace std;

#define prime 1000000007
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }

/////////////////////////////////////////////////////////////////////

void quick_sort (int *a, int n,int *b) 
{
	int i,j,p,t;
	if(n<2)
	{
		return;
	}
	p=a[n/2];
	for(i=0,j=n-1;;i++,j--)
	{
		while(a[i]<p)
		{
			i++;
		}
		while(p<a[j])
		{
			j--;
		}
		if(i>=j)
		{
			break;
		}
		t=a[i];
		a[i]=a[j];
		a[j]=t;

		t=b[i];
		b[i]=b[j];
		b[j]=t;
	}
	quick_sort(a,i,b);
	quick_sort(a+i,n-i,b+i);
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	char a;
	cin >> a;
	if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u')
		cout << "vowel\n";
	else
		cout << "consonant\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int[] number = {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};

        System.out.println(number[K-1]);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;

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

#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
template<class T>
class Ruiseki
{
private:
	int num;

public:
	vector<T> sumVal;
	Ruiseki(const vector<T> &srcVal)
	{
		num = srcVal.size();
		sumVal.resize(num + 1, 0);
		for (int i = 0; i < num; i++) {
			sumVal[i + 1] = sumVal[i] + srcVal[i];
		}
	}

	T GetSumAll()
	{
		return sumVal[num];
	}

	T GetSumRange(int startIdx, int stopIdx)
	{
		return sumVal[stopIdx] - sumVal[startIdx];
	}

	T GetSumFromTop(int stopIdx)
	{
		return sumVal[stopIdx] - sumVal[0];
	}

	T GetSumFromEnd(int startIdx)
	{
		return sumVal[num] - sumVal[startIdx];
	}
};

int main()
{
	ll N;
	cin >> N;
	vector<ll> A(N);
	for_each(ALL(A), [](ll &a){cin >> a;});

	Ruiseki<ll> ruiseki(A);
	map<ll, ll> mp;
	for_each(ruiseki.sumVal.begin() + 1, ruiseki.sumVal.end(), [&](ll val){mp[val]++;});
	ll ans = mp[0];
	for_each(mp.begin(), mp.end(), [&ans](P mpOne){ans += mpOne.second * (mpOne.second - 1) / 2; });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ta = 0LL;
    ll tb = 0LL;
    rep(i, n){
        ll tmp = b[i] - a[i];
        if(tmp < 0LL) tb -= tmp;
        else ta += tmp / 2;
    }
    if(tb <= ta)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,l;cin>>n>>l;
  ll a[n+1];for(ll i=1;i<=n;i++)cin>>a[i];
  ll num,len=0;
  vector<ll>v;
  for(ll i=1;i<n;i++){
    if(a[i]+a[i+1]>len){
      len=a[i]+a[i+1];
      num=i;
    }
  }
  if(len<l){
    cout<<"Impossible"<<endl;
    return 0;
  }
  v.push_back(num);
  ll f=num+2;
  ll b=num-1;
  for(;;){
    if(f==n+1&&b==0)break;
    ll p=0,q=0;
    if(f<=n){
      p=a[f];
    }
    if(b>0){
      q=a[b];
    }
    if(p>=q){
      v.push_back(f-1);
      f++;
    }
    else{
      v.push_back(b);
      b--;
    }
  }
  cout<<"Possible"<<endl;
  for(ll i=0;i<v.size();i++){
    cout<<v[v.size()-1-i]<<endl;
  }
}

Measured memory_bytes: 2548
#include <iostream>
#include <string>
using namespace std;
int main(void){
	char c;
	cin >> c;
	if (c == 'a')
		cout << "vowel" << endl;
	else if (c == 'i')
		cout << "vowel" << endl;
	else if (c == 'u')
		cout << "vowel" << endl;
	else if (c == 'e')
		cout << "vowel" << endl;
	else if (c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}
	
	

Measured memory_bytes: 256
/*Filename: aoj0019.cpp
 *Author: Mushiyo
 */

#include <iostream>

using namespace std;

long long factorial(int n){
	long long result = 1;

	for(int i = 1; i <= n; ++i){
		result *= i;
	}

	return result;
}

int main(){
	int n = 0;

    while(cin >> n){
        cout << factorial(n) << endl;
    }

	return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int ans = 0;
    for(int i=0;i<a;i++){
      b[i] = sc.nextInt();
    }
    for(int i=0;i<a;i++){
      for(int j=i+1;j<a;j++){
        ans += b[i] * b[j];
      }
    }
    System.out.println(ans);
  }
}

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

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

int main(){
    ll m,n;
    cin >> n >> m;
    ll a,b;
    ll ans = 0;
    a = min(n,m); b = max(n,m);
    if(a==1){
        if(b==1){ans = 1;}
        else{ans = b-2;}
    }else if(a==2){
        ans = 0;
    }else{
        ans = (a-2)*(b-2);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
using namespace std;

#define MAX_W 30
#define MAX_H 60
#define INF (1<<28)

int w, h;
char s[MAX_H][MAX_W];
int m[MAX_H][MAX_W][2];

const int l = 0;
const int r = 1;

struct P {
    int lx, ly;
    int rx, ry;
    int t;
    int cur;
    P() {}
    P(int ly, int lx, int ry, int rx, int cur, int t) :
        ly(ly), lx(lx), ry(ry), rx(rx), cur(cur), t(t) {}
};

int ldx[] = {-1, -1, -1, -1, -1,
                 -2, -2, -2,
                     -3
};
int ldy[] = {-2, -1, 0, 1, 2,
                 -1, 0, 1,
                     0
};
int rdx[] = {1, 1, 1, 1, 1,
                2, 2, 2,
                   3,
};
int rdy[] = {-2, -1, 0, 1, 2,
                 -1, 0, 1,
                     0
};

int bfs(int sy, int sx, int f) {
    int ans = INF;
    m[sy][sx][f] = 0;
    queue<P> q;
    if (f == r) q.push(P(sy, sx, -1, -1, f, 0));
    else q.push(P(-1, -1, sy, sx, f, 0));
    while (!q.empty()) {
        P p = q.front(); q.pop();
        if (p.cur == l) {
            for (int i = 0; i < 9; i++) {
                int ny = p.ry + ldy[i];
                int nx = p.rx + ldx[i];
                if (0 <= nx && nx < w && 0 <= ny && ny < h && 
                        s[ny][nx] != 'X' && s[ny][nx] != 'S' && m[ny][nx][l] > p.t + s[ny][nx] - '0') {
                    if (s[ny][nx] == 'T') {
                        ans = min(ans, p.t);
                        continue;
                    }
                    q.push(P(ny, nx, p.ry, p.rx, r, p.t+s[ny][nx]-'0'));
                    m[ny][nx][l] = p.t + s[ny][nx] - '0';
                }
            }
        } else {
            for (int i = 0; i < 9; i++) {
                int ny = p.ly + rdy[i];
                int nx = p.lx + rdx[i];
                if (0 <= nx && nx < w && 0 <= ny && ny < h && 
                        s[ny][nx] != 'X' && s[ny][nx] != 'S' && m[ny][nx][r] > p.t + s[ny][nx] - '0') {
                    if (s[ny][nx] == 'T') {
                        ans = min(ans, p.t);
                        continue;
                    }
                    q.push(P(p.ly, p.lx, ny, nx, l, p.t+s[ny][nx]-'0'));
                    m[ny][nx][r] = p.t + s[ny][nx] - '0';
                }
            }
        }
    }
    return ans;
}

int main() {
    while (cin >> w >> h, w || h) {
        for (int i = 0; i < h; i++) 
            for (int j = 0; j < w; j++) 
                cin >> s[i][j];

        for (int i = 0; i < h; i++) 
            for (int j = 0; j < w; j++)
                m[i][j][l] = m[i][j][r] = INF;
        int ans = INF;
        for (int i = 0; i < w; i++) {
            if (s[h-1][i] == 'S') {
                ans = min(ans, bfs(h-1, i, l));
                ans = min(ans, bfs(h-1, i, r));
            }
        }
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}

Measured memory_bytes: 1396
import java.util.Scanner;

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

		long x = scan.nextLong();
		long ans = - 1;
	
		long temp = x / 11 , remain = x % 11;
		ans = temp * 2;
		if (remain > 0) {
			if (remain <= 6)
				ans ++;
			else
				ans += 2;
		}
		
		System.out.println(ans);
		
	}
	
}






	

Measured memory_bytes: 9808
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}

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

	string s;
	cin>>s;
	vi c(2020);
	int t=0,out=0,w=1;
	c[0]=1;
	rep(i,s.size()){
		(t+=w*(s[s.size()-1-i]-'0')%2019)%=2019;
		(w*=10)%=2019;;
		out+=c[t];
		c[t]++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
int n;

void solve(){
    vector<string> s(n);
    vector<int> d(n,0);
    rep(i,n) cin>>s[i];
    for(int i=0;i<n;i++){
        if(s[i][0]!='.') continue;
        int idx=0;
        while(s[i][idx]=='.'){
            s[i][idx++]=' ';
        }
        d[i]=idx;
        s[i][--idx] = '+';
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(d[j]<d[i]) break;
            if(d[i]==d[j]){
                for(int k=i+1;k<j;k++){
                    s[k][d[i]-1] = '|';
                }
                break;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << s[i] << endl;
    }
}

int main(){
    while(cin>>n){
        if(n==0) break;
        solve();
    }
}

Measured memory_bytes: 3668
n,m = map(int,input().split())
d = [None]*n
for i in range(n):
    a,b = map(int,input().split())
    d[i] = [a,b]

d.sort(key=lambda x: x[0])

ryoukin = 0
cnt = 0
for lst in d:
    for i in range(lst[1]):
        ryoukin += lst[0]
        cnt += 1
        if cnt == m:
            print(ryoukin)
            exit()

Measured memory_bytes: 21216
#include <stdio.h>

int main(void) {
	int number[2][1000];
	int count;
	int date;
	int swap;
	char str[100];
	int tmp, ans;
	int i, j, k, l, m;
	i = 0;
	while (1) {
		gets(str);
		if (str[0] == '\0')
			break;
		sscanf(str, "%d,%d", &number[0][i], &date);
		i++;
	}
	
	for (j = 0; scanf("%d,%d", &number[1][j], &date) != EOF; j++);

	for (k = 0; k < i; k++) {
		for (l = 0; l < i - k - 1; l++) {
			if (number[0][l] > number[0][l+1]) {
				swap = number[0][l];
				number[0][l] = number[0][l+1];
				number[0][l+1] = swap;
			}
		}
	}
	for (k = 0; k < j; k++) {
		for (l = 0; l < j - k - 1; l++) {
			if (number[1][l] > number[1][l+1]) {
				swap = number[1][l];
				number[1][l] = number[1][l+1];
				number[1][l+1] = swap;
			}
		}
	}
	
	k = 0; l = 0;
	while (1) {
		if (k >= i || l >= j)
			break;
		if (number[0][k] > number[1][l])
			l++;
		else if (number[0][k] < number[1][l])
			k++;
		else {
			tmp = number[0][k];
			count = 0;
			while (1) {
				if (k >= i && l >= j)
					break;
				if (k >= i) {
					if (number[1][l] == tmp) {
						l++;
						count++;
					}
					else
						break;
				}
				else if (l >= j) {
					if (number[0][k] == tmp) {
						k++;
						count++;
					}
					else
						break;
				}
				else {
					if (number[0][k] == tmp) {
						k++;
						count++;
					}
					if (number[1][l] == tmp) {
						l++;
						count++;
					}
					if (number[0][k] != tmp && number[1][l] != tmp)
						break;
				}
			}
			printf("%d %d\n", tmp, count);
		}
	}
	return 0;
}

Measured memory_bytes: 616
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextText() string {
	var i string
	if sc.Scan() {
		i = sc.Text()
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var s = nextText()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


Measured memory_bytes: 1756
<?php
while(true) {  
    $a = fscanf(STDIN,'%d %d %d %d');
    if(feof(STDIN)) {
        break;
    }
    $b = fscanf(STDIN,'%d %d %d %d');
    $hit = 0;
    $blow = 0;
    $h = array();
    foreach($a as $v) {
        $h[$v] = true;
    }
    for ($i = 0; $i < 4; $i++) {
        if($a[$i] == $b[$i]) {
            $hit++;
            continue;
        }
        //配列内にキーの値が存在するか調べる
        //$a($h)ないに配列$bの値が存在するか調べる
         if (isset($h[$b[$i]])) {
            $blow++;
        }
    }
    echo sprintf('%d %d',$hit,$blow).PHP_EOL;
}




Measured memory_bytes: 9288
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int A,B,M;
    int a[100000],b[100000],x[100000],y[100000],c[100000];
    cin>>A>>B>>M;
    rep(i,A) cin>>a[i];
    rep(i,B) cin>>b[i];
    int min_a = 1000000,min_b = 1000000;
    rep(i,A){
        min_a = min(min_a,a[i]);
    }
    rep(i,B){
        min_b = min(min_b,b[i]);
    }
    int ans = min_a+min_b;
    rep(i,M){
        cin>>x[i]>>y[i]>>c[i];
        ans = min(ans, a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long long M = 1000000007;

long long f[N * 2];
void pre()
{
    f[0] = 1;
    for (int i = 1; i < N * 2; ++i)
        f[i] = (f[i - 1] * i) % M;
}

long long ast(long long x, long long n)
{
    x = (x % M);
    long long res = 1;
    while (n)
    {
        if (n % 2 == 1)
        {
            res = (res * x) % M;
            --n;
        }
        x = (x * x) % M;
        n /= 2;
    }
    return res;
}

long long C(long long n, long long k)
{
    return (f[n] * ast(f[n - k] * f[k], M - 2)) % M;
}

long long Q(long long n, long long m)
{
    return C(n + m - 2, n - 1);
}

int n, m;
int k;
pair<int, int> a[N];

long long dp[N];
int main()
{
    pre();
    scanf("%d%d", &n, &m);
    scanf("%d", &k);
    for (int i = 0; i < k; ++i)
        scanf("%d%d", &a[i].first, &a[i].second);
    sort(a, a + k);
    for (int i = 0; i < k; ++i)
    {
        int x = a[i].first;
        int y = a[i].second;
        dp[i] = Q(x, y);
        for (int j = 0; j < i; ++j)
        {
            int x1 = a[j].first;
            int y1 = a[j].second;
            if (x1 <= x && y1 <= y)
            {
                dp[i] = (dp[i] - (dp[j] * Q(x - x1 + 1, y - y1 + 1)) % M + M) % M;
            }
        }
    }
    long long ans = Q(n, m);
    for (int i = 0; i < k; ++i)
    {
        int x = a[i].first;
        int y = a[i].second;
        ans = (ans - (dp[i] * Q(n - x + 1, m - y + 1)) % M + M) % M;
    }
    cout << ans << endl;
    return 0;
}


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

using std::cout;
using std::cin;
using std::endl;

bool check_kaibun(std::string s) {
	int si = s.size();
	int half = (si + 1)/2;
	bool is_kaibun{ true };
	for (int i = 0; i < half; i++)
	{
		is_kaibun &= s[i] == s[si - i - 1];
	}
	return is_kaibun;
}

int main() {
	std::string s;
	cin >> s;
	bool is_kaibun{ true };
	is_kaibun &= check_kaibun(s);
	is_kaibun &= check_kaibun(s.substr(0, (s.size() - 1)/2));
	cout << (is_kaibun ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    double N, K;
    cin >> N >> K;

    double ans = 0;

    for (double i = 1; i <= N && i <= K - 1; i++){
        double count = 0;
        double i0 = i;
        while (i0 < K){
            count ++;
            i0 *= 2;
        }
        double p = 1 / N;
        for(double j = 0; j < count; j++){
            p = p * 1/2;
        }
        ans += p;
    }
    

    if (N >= K){
        ans += (N - K + 1) / N;
    }

    cout << fixed << setprecision(10) << ans << endl; // C++
    
    return 0;
}

Measured memory_bytes: 256