akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n;cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n;i++){
		ll tmp = i;
		ll cou = 0;
		while(tmp){
			cou++;
			tmp /= 10;
		}
		if(cou % 2)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,s;
    int yatai[3001],cost[3001];
    int dp[3001];
    rep(i,0,3001){dp[i]=0;}
    cin >> n >> k >> s;
    rep(i,0,n){
        cin >> yatai[i] >> cost[i];
    }
    int ans=0;
    rep(i,0,n){
        for(int j=k;0<=(j-cost[i]);--j){
            int a=j-cost[i];
            if((a>=s)||(j<=s)){
                dp[j]=max(dp[j],dp[a]+yatai[i]);
           // cout << j << " ";
            }
        }
    }
    printf("%d\n",*max_element(dp,dp+k+1));
    return 0;
}

Measured memory_bytes: 3324
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = [x for x in S.split("/")]
y = int(ls[0])
m = ls[1]
if y<=2018:
    a = "Heisei"
elif y == 2019 and m in ["01" ,"02", "03","04"]:
    a = "Heisei"
else:
    a = "TBD"
print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    while(cin>>n, n){
        ll d[51];
        for(int i=0; i<=50; i++){
            d[i]=1ll<<i;
        }
        vector<int> v[32];
        for(int i=0; i<n; i++){
            int f;
            cin>>f;
            while(f--){
                int day;
                cin >> day;
                v[day].push_back(i);
            }
        }
        int last=-1;
        for(int day=1; day<=30; day++){
            ll m=0;
            for(int i=0; i<v[day].size(); i++){
                m|=d[v[day][i]];
            }
            for(int i=0; i<v[day].size(); i++){
                d[v[day][i]]=m;
            }
            if(m==((1ll<<n)-1)){
                last=day; break;
            }
        }
        cout << last << "\n";
         
    }
     
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = LS()
    print(s[0][0]+s[1][0]+s[2][0])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

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

	return 0;
}

Measured memory_bytes: 256
/*
 * Copyright (c) 2019 ... All rights reserved.
 * ...
 */

 #include <iostream>
 #include <iomanip>
 #include <vector>
 #include <algorithm>
 #include <numeric>
 #include <functional>
 #include <cmath>
 #include <queue>
 #include <stack>

 #define repd(i,a,b) for (int i=(a);i<(b);i++)
 #define rep(i,n) repd(i,0,n)
 typedef long long ll;

 using namespace std;


 int inputValue(){
     int a;
     cin >> a;
     return a;
 };

 void inputArray(int * p, int a){
     rep(i, a){
         cin >> p[i];
     }
 };

 void inputVector(vector<int> * p, int a){
     rep(i, a){
         int input;
         cin >> input;
         p -> push_back(input);
     }
 }

 template <typename T>
 void output(T a, int precision) {
     if(precision > 0){
         cout << setprecision(precision)  << a << "\n";
     }
     else{
         cout << a << "\n";
     }
 }

 int main(int argc, const char * argv[]) {

     // source code
     int N = inputValue();
     string S;
     cin >> S;
     int K = inputValue();

     string target = S.substr(K-1, 1);

     rep(i, N){
         string s = S.substr(i, 1);
         if (s != target){
             S.replace(i, 1, "*");
         }
     }

     cout << S << endl;


     return 0;
 }

Measured memory_bytes: 256
class Fibonacci(object):
    record = [1, 1]
    
    def get_nth(self, n):
        if n < len(Fibonacci.record):
            return Fibonacci.record[n]
        
        for i in range(len(Fibonacci.record), n+1):
            result = Fibonacci.record[i-1] + Fibonacci.record[i-2]
            Fibonacci.record.append(result)
        
        return Fibonacci.record[n]
 
 
if __name__ == '__main__':
    num = int(input())
    f = Fibonacci()
    result = f.get_nth(num)
    print('{0}'.format(result))


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

int main(){
  int N,K,Q;
  cin >> N>>K>>Q;
  vector<int> x(N);
  
  for(int i=0;i<Q;i++){
    int A;
    cin >> A;
    
    x[A-1]++;
  }
  
  for(int i=0;i<N;i++){
    if(K-(Q-x[i])>0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
package main

import (
  "fmt"
)

func main() {
  var N, K int
  fmt.Scan(&N, &K)
  E := make([]float64, N)
  S := 0.0
  s := 0.0
  for i := 0; i < N; i++ {
    var p float64
    fmt.Scan(&p)
    E[i] = (p + 1.0) / 2.0
    s += E[i]
    if i >= K - 1 {
      if S < s {
        S = s
      }
      s -= E[i-K+1]
    }
  }
  fmt.Println(S)
}

Measured memory_bytes: 4992
using System;

namespace A____AtCoDeer_and_Paint_Cans
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = input[0];
            var b = input[1];
            var c = input[2];
            if(a!=b&&b!=c&&a!=c)
            {
                Console.WriteLine(3);
            }
            else if(a==b&&b!=c||a!=b&&b==c||a==c&&b!=a)
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;
// #include "prettyprint.hpp"

typedef long long ll;

int main()
{
    vector<int> dish(5);
    vector<int> flag(5, 0);

    int amari = 9;
    for (int i = 0; i < 5; ++i)
    {
        cin >> dish[i];
        if (dish[i] % 10 == 0)
        {
            flag[i] = 1;
        }
        else
        {
            amari = min(amari, dish[i] % 10);
            dish[i] += (10 - dish[i] % 10);
        }
    }
    // cout << dish << endl;
    // cout << amari << endl;

    int sum = 0;
    for (int i = 0; i < 5; ++i)
    {
        sum += dish[i];
    }

    int ansflag = 0;
    for (int i = 0; i < 5; ++i)
    {
        ansflag += flag[i];
    }

    if (ansflag == 5)
    {
        cout << sum << endl;
    }
    else
    {
        cout << sum - 10 + amari << endl;
    }
}

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

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

string s, output;

int main(){
    cin >> s;
    output = "";
    REP(i, s.size()){
        if((i+1)%2==1){
            output += s[i];
        }
    }
    cout << output << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long num1[105][105];
long long num2[105][105];
long long ans[105][105];
int main() {
	//freopen("in","r",stdin);
	int row, col_row, col; cin>>row>>col_row>>col;
	memset(ans,0,sizeof(ans));

	for(int i=0;i<row;i++) {
		for(int j=0;j<col_row;j++) {
			cin>>num1[i][j];
		}
	}

	for(int i=0;i<col_row;i++) {
		for(int j=0;j<col;j++) {
			cin>>num2[i][j];
		}
	}

	int row_k, col_k;
	for(int i=0;i<row;i++) {
		for(int j=0;j<col;j++) {
			for(int k=0;k<col_row;k++) {
				ans[i][j] += num1[i][k]*num2[k][j];
			}
		}
	}


	for(int i=0;i<row;i++) {
		for(int j=0;j<col;j++) {
			printf("%lld%c",ans[i][j],
				(j==(col-1))?'\n':' ');
		}
	}
	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

ll conv(int n, int k){
  if(n<k) return 0;
  if(k==0) return 1;
  if(k==1) return n;
  if(k==2) return n*(n-1)/2;
  if(k==3) return n*(n-1)*(n-2)/(3*2);
  else return 0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  int N = S.length();
  int K;cin >> K;
  int num = K;
  ll dp[N+1][2][K+1];
  rep(i,N+1) rep(j,2) rep(k,K+1) dp[i][j][k] = 0;
  dp[0][1][K] = 1;
  rep(i,N){
    rep(k,K+1) dp[i+1][0][k] =  dp[i][0][k];
    if(S[i] == '0') rep(j,2)rep(k,K+1) dp[i+1][j][k] =  dp[i][j][k];
    else{
      rep(k,K){
        dp[i+1][1][k] = dp[i][1][k+1];
        dp[i+1][0][0] += (S[i] - '1')*dp[i][1][k+1] * pow(9,k) * conv(N-i-1,k)
          + dp[i][1][k+1] * pow(9,k+1) * conv(N-i-1,k+1);
      }
      if(dp[i+1][1][0] == 1)++dp[i+1][0][0];
    }
  }
  cout << dp[N][0][0] << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int main(){
  int x, y;
  int A, B, R;

  scanf("%d",&x);
  if(x<1 || 1000000000<x) exit(1);

  scanf("%d",&y);
  if(y<1 || 1000000000<x) exit(2);

  A = x;
  B = y;

  while(B != 0){
    R = A%B;
    A = B;
    B = R;
  }
  printf("%d\n",A);


  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

typedef long long ll;
//#define int long long
#define stepn(i, s, e, n) decltype(e) i = (s); i < (e); i += (n)
#define step(i, s, e) decltype(e) i = (s); i < (e); ++i
#define range(i, n) step(i, 0, n)
constexpr int INF = 1e9;

decltype(1) main() {
    int n;
    cin >> n;

    int ans = 0;
    if (n > 9) {
        ans += 9;
    } else {
        cout << n << endl;
        return 0;
    }
    if (n > 999) {
        ans += 900;
    } else {
        cout << ans + max(0, n - 99) << endl;
        return 0;
    }
    if (n > 99999) {
        ans += 90000;
    } else {
        cout << ans + max(0, n - 9999) << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;


signed main(){
    
    int a[4];
    rep(i,4)cin >> a[i];
    sort(a,a+4);
    if(a[0] == 1 && a[1] == 4 && a[2] == 7&& a[3] == 9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;

    }

    


    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 
// rm -r -f test;oj dl http://arc074.contest.atcoder.jp/tasks/arc074_b

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)
class Point{
public:
  double x,y;
  Point(double x = 0, double y = 0):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 k){
    return Point(x*k,y*k);
  }
  Point operator / (double k){
    return Point(x/k,y/k);
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;
typedef vector<Point> Polygon;
double dot(Vector a,Vector b){
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a,Vector b){
  return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}
int main(){
  Point a,b,c,d;
  int n;
  cin >> n;
  int i;
  for(i=0;i<n;i++){
    cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
    if(isParallel(a-b,c-d)) cout << "YES" <<endl;
    else cout << "NO" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned ll
deque<int> q;
int main() {
	int n;
	cin>>n;
	bool f=false;
	for (int i=0; i<n; i++) {
		int x;
		cin>>x;
		if (!f) {
			q.push_back(x);
		} else
			q.push_front(x);
		f=!f;
	}
	if (f)
		while (!q.empty()) {
			cout<<q.back()<<' ';
			q.pop_back();
		}
	else {
		while (!q.empty()) {
			cout<<q.front()<<' ';
			q.pop_front();
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	if((n+1)/2>=m)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
}


Measured memory_bytes: 256
import copy
w, h = map(int,input().split())
while [h, w] != [0, 0]:
    area = []
    a = 1
    for i in range(h):
        area.append(list(input()))
        area[i].insert(0,"#")
        area[i].append("#")
    area.insert(0,["#" for i in range(w + 2)])
    area.append(["#" for i in range(w + 2)])

    que = []
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if area[i][j] == "@":
                que.append([i, j])
                break
        else:
            continue
        break
    while True:
        nque = []
        for i in que:
            h1 = i[0]
            w1 = i[1]
            if area[h1 - 1][w1] == ".":
                area[h1 - 1][w1] = "*"
                nque.append([h1 - 1, w1])
                a += 1
            if area[h1 + 1][w1] == ".":
                area[h1 + 1][w1] = "*"
                nque.append([h1 + 1, w1])
                a += 1
            if area[h1][w1 - 1] == ".":
                area[h1][w1 - 1] = "*"
                nque.append([h1, w1 - 1])
                a += 1
            if area[h1][w1 + 1] == ".":
                area[h1][w1 + 1] = "*"
                nque.append([h1, w1 + 1])
                a += 1
        if nque == []:
            break
        que = copy.deepcopy(nque)

    print(a)
        
    w, h = map(int,input().split())


Measured memory_bytes: 6340
//ainta's solution
#include<stdio.h>
#include<algorithm>
#include<cstdlib>
#include<set>
#define pli pair<long long, int>
using namespace std;
struct point{
	int x, y;
}w[101000];
int n, s1, s2, L;
bool v[101000];
set<pli>Set1, Set2;
long long p1[101000], p2[101000], Res;
long long Get(int a, int b){
	if(b == 1)return w[a].x*(1ll<<31) + w[a].y;
	else return w[a].y*(1ll<<31) + w[a].x;
}
void DFS(int a){
	v[a]=true;
	long long t1 = Get(a,1), t2 = Get(a,2);
	Set1.erase(pli(t1,a));
	Set2.erase(pli(t2,a));
	long long tt = L*(1ll<<31);
	set<pli>::iterator it;
	while(1){
		it = Set1.lower_bound(pli(t1+tt-L, 0));
		if(it!=Set1.end() && it->first <= t1+tt+L){
			DFS(it->second);
		}
		else break;
	}
	while(1){
		it = Set1.lower_bound(pli(t1-tt-L, 0));
		if(it!=Set1.end() && it->first <= t1-tt+L){
			DFS(it->second);
		}
		else break;
	}
	while(1){
		it = Set2.lower_bound(pli(t2+tt-L, 0));
		if(it!=Set2.end() && it->first <= t2+tt+L){
			DFS(it->second);
		}
		else break;
	}
	while(1){
		it = Set2.lower_bound(pli(t2-tt-L, 0));
		if(it!=Set2.end() && it->first <= t2-tt+L){
			DFS(it->second);
		}
		else break;
	}
}
int main(){
	int i;
	scanf("%d%d%d",&n,&s1,&s2);
	for(i=1;i<=n;i++){
		scanf("%d%d",&w[i].x,&w[i].y);
	}
	L = abs(w[s1].x-w[s2].x) + abs(w[s1].y-w[s2].y);
	for(i=1;i<=n;i++){
		int t = w[i].x-w[i].y;
		w[i].x = w[i].x+w[i].y;
		w[i].y = t;
		p1[i] = Get(i,1);
		p2[i] = Get(i,2);
		Set1.insert(pli(Get(i,1),i));
		Set2.insert(pli(Get(i,2),i));
	}
	DFS(s1);
	sort(p1+1,p1+n+1);
	sort(p2+1,p2+n+1);
	for(i=1;i<=n;i++){
		if(!v[i])continue;
		long long tt = L* (1ll<<31), t1 = Get(i,1), t2 = Get(i,2);
		Res += upper_bound(p1+1,p1+n+1,t1+tt+L) - lower_bound(p1+1,p1+n+1,t1+tt-L);
		Res += upper_bound(p1+1,p1+n+1,t1-tt+L) - lower_bound(p1+1,p1+n+1,t1-tt-L);
		Res += upper_bound(p2+1,p2+n+1,t2+tt+L-1) - lower_bound(p2+1,p2+n+1,t2+tt-L+1);
		Res += upper_bound(p2+1,p2+n+1,t2-tt+L-1) - lower_bound(p2+1,p2+n+1,t2-tt-L+1);
	}
	printf("%lld\n",Res/2);
}

Measured memory_bytes: 21376
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using namespace std;

bool f(int x){
    int digit =0;
    while(x){
        digit++;
        x /= 10;
    }
    return digit%2 != 0;
}

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


Measured memory_bytes: 3596
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, k;
	double p,res=0;
	cin >> n >> k;
	vector<double>daicesum(n+1);
	daicesum[0] = 0.0;
	rep(i, n) {
		cin >> p;
		daicesum[i + 1] = daicesum[i] + (p / 2.0 + 0.5);
	}
	rep(i, n - k+1) {
		res = max(res, daicesum[i + k] - daicesum[i]);
	}
	cout << fixed << setprecision(8) << res << endl;
	return 0;
}


Measured memory_bytes: 4824
'use strict'
let input = require("fs").readFileSync("/dev/stdin", "utf8");
const Nums = input.split('\n');
const S = Nums[0].split("");
const T = Nums[1].split("");
let ans = 0;
S.forEach((x,i)=> {
	if(x==T[i]){
    	ans++;
    }
});
console.log(ans);

Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;

const int COST[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

vi isUsable(10, 0);

int main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++) {
    ll a; cin >> a;
    isUsable[a] = 1;
  }

  vvi dp(N+1, vi(11, -1));
  dp[0] = vi(11, 0);
  for (int n = 0; n < N; n++) {
    if (dp[n][0] == -1) continue;
    for (int i = 9; i > 0; i--) {
      if (!isUsable[i]) continue;
      int nn = n + COST[i];
      if (nn > N) continue;
      vi cnts = dp[n];
      cnts[10-i]++; cnts[0]++;
      if (dp[nn][0] == -1 || dp[nn] < cnts) {
        dp[nn] = cnts;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int n = 0; n < dp[N][i+1]; n++) {
      cout << (9 - i);
    }
  } cout << endl;
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll r = 0;
  for (ll a = 1; a <= n; a++) {
    for (ll b = 1; b <= n; b++) {
      for (ll c = 1; c <= n; c++) {
        r += gcd(gcd(a, b), c);
      }
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3636
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = (1 << 30);
const int MOD = 1000000007;
ll n, k, ans = 0, h = 1, W, sum = 0, p;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    int N, P; string S;
    cin >> N >> P >> S;
    if (P == 2 || P == 5) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) ans += i + 1;
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> ama(P,0);
    int count = 1,now = 0; ama[0]++;
    rrep(i,N) {
        int a = (S[i] - '0') * count % P;
        now = (now + a) % P;
        ans += ama[now]; ama[now]++;
        count = count * 10 % P;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = list(map(int,input()))
    count = 0

    S = len(N)
    flag = 0
    for i in range(S):
        temp = flag + N[-1 - i]
        if temp > 5:
            count += 10 - temp
            flag = 1
        elif temp ==5  and i !=S-1 and N[-1-i-1]>=5:
            count+=temp
            flag=1

        else:
            count += temp
            flag = 0

    print(count + flag)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19492
h,w,k = map(int,input().split())
##複数行の文字列を一文字ずつリストの要素として格納
board = [list(input()) for _ in range(h)]

ans = 0
for paint_h in range(2 ** h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2 ** w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h >> i) & 1 == 0 and (paint_w >> j) & 1 == 0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j] == '#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt += 1
   if cnt == k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans += 1
print(ans)


Measured memory_bytes: 8944
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


 
int main(void){
    ll n;
    cin>>n;
    set<ll>s;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        s.insert(a);
    }
    ll len = s.size();
    if(len == n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
	return 0; 
}

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

int main(){

  int N, i, j, k=0;
  cin >> N;
  int a[N];
  for(i=0; i<N; i++){
    cin >> a[i];
  }

  i=0;
  while(N-i){
    j = a[k]-1;
    i++;
    if(j==1){
      cout << i << endl;
      return 0;
    }
    k = j;
  }

  cout << "-1" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	double x1, y1, x2, y2, x3, y3, x4, y4;

	getchar();getchar();
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4) != EOF )
	{
		if( (y2-y1)/(x2-x1) == (y4-y3)/(x4-x3) ){ puts("YES"); }
		else{ puts("NO"); }
	}
	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main() {
	// your code goes here
	int n,x[200001],y[200001],i,a,b;
	cin >> n;
	for(i=0;i<n;i++) {
		cin >> x[i];
		y[i]=x[i];
	}
	sort(y,y+n);
	a=y[(n-1)/2];
	b=y[(n+1)/2];
	for(i=0;i<n;i++){
		if(x[i]<=a) cout << b << endl;
		else cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,K;

vector<int> g[100010];
bool used[100010];
pair<int,int> col[100010];
int fix[100010];

int ival=1e7;
pair<int,int> INF=make_pair(-1e7,1e7);
pair<int,int> IMP=make_pair(1e9,1e9);

pair<int,int> dfs(int now){
    used[now]=true;
    int l=-ival,r=ival;
    if(fix[now]!=-1){
        l=fix[now];
        r=fix[now];
    }
    bool leaf=true;
    for(int i=0;i<g[now].size();i++){
        int next=g[now][i];
        if(used[next]) continue;

        leaf=false;
        pair<int,int> tp=dfs(next);
        if(tp==IMP) return IMP;
        else if(tp==INF) continue;

        if(r==ival){
            l=tp.first-1;
            r=tp.second+1;
        }else{
            if(r%2!=(tp.second+1)%2) return IMP;
            l=max(l,tp.first-1);
            r=min(r,tp.second+1);
        }
        
        if(r<l) return IMP;
    }

    if(leaf&&fix[now]==-1) return col[now]=INF;
    return col[now]=make_pair(l,r);
}

void rec(int now,int pval){
    used[now]=true;
    if(fix[now]==-1){
        if(col[now].first<=pval-1) fix[now]=pval-1;
        else fix[now]=pval+1;
    }
    for(int i=0;i<g[now].size();i++){
        int next=g[now][i];
        if(used[next]) continue;
        rec(next,fix[now]);
    }
    return;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++) fix[i]=-1;
  for(int i=1;i<N;i++){
      int a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }
  cin>>K;
  for(int i=0;i<K;i++){
      int v,p;
      cin>>v>>p;
      v--;
      fix[v]=p;
      col[v]=make_pair(p,p);
  }

  pair<int,int> f=dfs(0);
  /*for(int i=0;i<N;i++){
      cout<<col[i].first<<" "<<col[i].second<<endl;
  }*/
  if(f==IMP){
      cout<<"No"<<endl;
      return 0;
  }

  if(K<N){
      /*int start=0;
      for(int i=0;i<N;i++){
          if(fix[i]==-1&&col[i]!=INF) start=i;
          used[i]=false;
      }
      fix[start]=col[start].first;
      rec(start,fix[start]);*/
      for(int i=0;i<N;i++) used[i]=false;
      rec(0,col[0].first+1);
  }

  cout<<"Yes"<<endl;
  for(int i=0;i<N;i++) cout<<fix[i]<<endl;

  return 0;
}


Measured memory_bytes: 13952
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			for(int j=0;j<n;j++) {
				String s = sc.next();
				HashSet<String> set = new HashSet<String>();
				for(int i=0;i<s.length();i++) {
					String s1 = s.substring(0, i), rs1 = new StringBuilder(s1).reverse().toString();
					String s2 = s.substring(i), rs2 = new StringBuilder(s2).reverse().toString();
					set.add(s1 + s2); set.add(s1 + rs2);
					set.add(s2 + s1); set.add(s2 + rs1);
					set.add(rs1 + s2); set.add(rs1 + rs2);
					set.add(rs2 + s1); set.add(rs2 + rs1);
				}
				System.out.println(set.size());
			}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 55100
def pascal_parity(N):
    if N & -N == N:
        return [1] * N
    else:
        n = N - (1<<(N.bit_length()-1))
        p = pascal_parity(n)
        return p + [0]*(N-2*n) + p

N = int(input())
A = list(map(lambda x: int(x)-1, input()))
P = pascal_parity(N)
if 1 in A:
    if sum(a*p for a,p in zip(A, P)) % 2 == 1:
        print(1)
    else:
        print(0)
else:
    pa = 0
    for p, a in zip(P, A):
        if p==1 and a==2:
            pa += 1
    if pa % 2 == 1:
        print(2)
    else:
        print(0)


Measured memory_bytes: 28480
from operator import add
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# AC
# 解説見た
# 半分全列挙
# bit全探索

H, W, K = map(int, input().split())
MEIJI = []
for _ in range(H):
    MEIJI.append(list(map(int, list(input()))))

# 全部のカットを試す
INF = 10 ** 5
ans = INF
for h in range(2 ** (H - 1)):
    # 先に横の分割の数
    row = 1
    for i in range(H - 1):
        row += (h >> i) & 1

    num_cut = row - 1
    cnt = [0] * row

    #print("cut == ", h, "row == ", row)

    # 列は貪欲にカット
    for c in range(W):
        idx = 0
        tmp_cnt = [0] * row
        for r in range(H):

            if r != 0 and (h >> r - 1) & 1:
                idx += 1

            tmp_cnt[idx] += MEIJI[r][c]

        # チェック
        new_cnt = list(map(add, cnt, tmp_cnt))

        if any([K < x for x in new_cnt]):
            # 1行だけでもK以下が作れないならばbreak
            if any([K < x for x in tmp_cnt]):
                num_cut = INF
                break

            cnt = tmp_cnt
            num_cut += 1
        else:
            cnt = new_cnt

        #print("column:", c, tmp_cnt)

    ans = min(num_cut, ans)

print(ans)


Measured memory_bytes: 49244
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005
ll lenOfLongIncSubArr(ll arr[], ll n) 
{ 
    // 'max' to store the length of longest 
    // increasing subarray 
    // 'len' to store the lengths of longest 
    // increasing subarray at diiferent  
    // instants of time 
    ll max = 1, len = 1; 
      
    // traverse the array from the 2nd element 
    for (int i=1; i<n; i++) 
    { 
        // if current element if greater than previous 
        // element, then this element helps in building 
        // up the previous increasing subarray encountered 
        // so far 
        if (arr[i] <= arr[i-1]) 
            len++; 
        else
        { 
            // check if 'max' length is less than the length 
            // of the current increasing subarray. If true,  
            // then update 'max' 
            if (max < len)     
                max = len; 
                  
            // reset 'len' to 1 as from this element 
            // again the length of the new increasing 
            // subarray is being calculated     
            len = 1;     
        }     
    } 
      
    // comparing the length of the last 
    // increasing subarray with 'max' 
    if (max < len) 
        max = len; 
      
    // required maximum length 
    return max; 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		ll arr[n];
		rep(i,0,n)
		{cin>>arr[i];
		}
		cout<<lenOfLongIncSubArr(arr,n)-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stack>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
  for (int v = nt[u]; v < n; v++) {
    nt[u] = v + 1;
    if (M[u][v]) {
      return v;
    }
  }
  return -1;
}

void dfs_visit(int r) {
  for (int i = 0; i < n; i++) {
    nt[i] = 0;
  }

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while(!S.empty()) {
    int u = S.top();
    int v = next(u);
    if (v != -1) {
      if (color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for (int u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      dfs_visit(u);
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }

  int u, k, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--; // to 0 origin
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--; // to 0 origin
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


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

int main(void) {
    char s[200010];
    char t[200010];
    
    scanf("%s", s);
    scanf("%s", t);
    
    int count = 0;
    for(int i = 0; i < strlen(s); i++) {
        if(s[i] != t[i]) count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>

int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    int sum1,sum2,sum3;
    sum1 = 10*A+B+C;
    sum2 = 10*B+A+C;
    sum3 = 10*C+A+B;
    int max = sum1;
    if(sum2>=max){
        max = sum2;
    }
    if(sum3>=max){
        max = sum3;
    }
    printf("%d",max);    
    return 0;
}

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

long long part(vector<int> &C,vector<vector<int>> &S,vector<int> L,int i,int j){
  long long partsum=0;
  L.at(j)=i+1;
  partsum+=S.at(i).at(j);
  for(int k=0;k<26;k++){
    partsum-=C.at(k)*(i+1-L.at(k));
  }
  return partsum;
}
  
int main(){
  int D;
  cin >> D;
  vector<int> C(26);
  for(int i=0;i<26;i++){
    cin >> C.at(i);
  }
  long long sum=0;
  vector<vector<int>> S(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin >> S.at(i).at(j);
    }
  }
  vector<int> L(26);
  /*スコア関数
  for(int i=0;i<D;i++){
    int T;
    cin >> T;
    L.at(T-1)=i+1;
    sum+=S.at(i).at(T-1);
    for(int j=0;j<26;j++){
      sum-=C.at(j)*(i+1-L.at(j));
    }
    cout << sum << endl;
  }*/
  for(int i=0;i<D;i++){
    int tem=0;
    long long temsum=-1e9;
    for(int j=0;j<26;j++){
      long long partsum=part(C,S,L,i,j);
      if(partsum>temsum){
        temsum=partsum;
        tem=j;
      }
    }
    L.at(tem)=i+1;
    cout << tem+1 << endl;
  }
}


Measured memory_bytes: 3640
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define int ll

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair

#define DEBUG

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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;
}

ll R, C, N, K;

bool v[15][10005];

ll a[20];

signed main() {

    cin >> N;

    vector<ll> P(N),Q(N),Nlist(N);


    rep(i,N){
        Nlist[i] = i+1;
    }
    rep(i,N){
        cin >> P[i];
    }
    rep(i,N){
        cin >> Q[i];
    }


    int countA = 0;
    int countB = 0;
    int count = 0;
    do{
        count ++;
        bool ok = true;
        rep(i,N){
            if(P[i] != Nlist[i]){
                ok = false;
            }
        }
        
        if(ok){
            countA = count;
        }

        ok = true;
        rep(i,N){
            if(Q[i] != Nlist[i]){
                ok = false;
            }
        }
        
        if(ok){
            countB = count;
        }
    }while(next_permutation(Nlist.begin(),Nlist.end()));

    cout << abs(countA-countB) << endl;
}


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

int allSearch(int n) {
  int a;
  if(n <= 1) {
    a = 1;
  } else if(n <= 2) {
    a = allSearch(n-2) + allSearch(n-3);
  } else {
    a = allSearch(n-1) + allSearch(n-2) + allSearch(n-3);
  }
  return a;
}

int main() {
  int n;
  while(true){
  cin >> n;
  if(n == 0)break;
  cout << 1 + allSearch(n)/3650 << endl;
  }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
          int n;
          int i=0;
          long long a;
          long long b=1;
          cin >> n;
          while(i<n){
          	cin >> a;
            if(a == 0){
              b = 0;
              break;
            }
            if(a>1000000000000000000/b || b<0){
              b = -1;
              break;
            }
            b *= a;
            i++;
          }
          while(i<n){
          	cin >> a;
            if(a == 0){
              b = 0;
              break;
            }
            i++;
            }
          cout << b << endl;
          }

Measured memory_bytes: 3620
n = gets.chomp.to_i
hs = gets.chomp.split(/\s+/).map { |e| e.to_i }


max = 0
count = 0
hs.each_with_index { |e, i|
  next if i == 0

  if hs[i-1] >= e
    count += 1
  else
    max = count if count > max
    count = 0
  end
}
max = count if count > max

puts max


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

ll mod=1000000007;
ll add(ll a,ll b){ return (a+b)%mod; }
ll mul(ll a,ll b){ return (a*b)%mod; }

ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res=mpow( mul(a,a) , b/2 );
  if(b&1)res=mul(res,a);
  return res;
}

string A,B,C;

ll L[100000];
int solve(string &s){
  int n=s.size();
  int m=C.size();
  ll res=0;
  ll num=0;

  ll B=1;
  L[n]=0;
  for(int i=n-1;i>=0;i--){
    L[i]= add(L[i+1], B*(s[i]-'0') );
    B=mul(B,10);
  }
  
  for(int i=0;i+m<=n;i++){
    string tmp=s.substr(i,m);
    if( C < tmp ){

      if(C=="0")res=add(res,   mul(num,mpow(10,n-i-m))  );
      else res=add(res,   mul(num+1,mpow(10,n-i-m))  );
      
    }else if( C==tmp ){

      if(C=="0"){
        res=add(res,   mul( add(num,mod-1) , mpow(10,n-i-m))    );
        res=add(res,   L[i+m]+1  );
      }else{
        res=add(res,   mul(num, mpow(10,n-i-m))    );
        res=add(res,   L[i+m]+1  );
      }
      
    }else if( tmp < C ){

      res=add(res, mul(num,mpow(10,n-i-m) ) );
      
    }
    num=add( mul(num,10) , s[i]-'0');
  }

  if(C=="0")res=add(res,1);
  return res;
}

int main(){
  cin>>A>>B>>C;
  
  int ans=mod-solve(A);
  for(int i=0;i+(int)C.size()<=(int)A.size();i++){
    if(A.substr(i,C.size())==C)ans++;
  }
  ans+=solve(B);
  ans%=mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1316
S = str(input())
if 0 < int(S[:2]) <= 12 and  0 < int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif int(S[:2]) == 0 and int(S[2:]) == 0:
    print("NA")
elif 0 < int(S[:2]) <= 12:
    print("MMYY")
elif 0 < int(S[2:]) <= 12:
    print("YYMM")
else:
    print("NA")

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

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

    priority_queue<int> pq;
    vector<int> v;
    rep(i, n) {
        int k;
        cin >> k;
        pq.push(k);
    }

    while(!pq.empty()) {
        v.push_back(pq.top());
        pq.pop();
    }

    int total = 0;
    while(v.size() > 2) {
        int biggest,middle,lowest;
        biggest = v[0];
        v.erase(v.begin());
        
        reprv(low, v.size()) {
            lowest = v[low];
            reprv(mid, low) {
                middle = v[mid];
                if (lowest + middle > biggest) {
                    total += mid + 1;
                    break;
                }
            }
        }

    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
const long long M = 1e9 + 7;
int main(){
	long long n,k;
	cin>>n>>k;
	long long a[N]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long b=((1+k)*k/2)%M;
	long long c=((k-1)*k/2)%M;
	//cout<<b<<"  "<<c<<endl;
	long long ans=0;
	for(int i=0;i<n;i++){
		long long cnt=0,cnt1=0;
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				cnt++;
			}
		}
		cnt=cnt%M;
		cnt=(cnt*(b%M))%M	;
		for(int j=i-1;j>=0;j--){
			if(a[i]>a[j]){
				cnt1++;
			}
		}
		cnt1=((cnt1%M)*(c%M))%M;
		
		ans=(ans%M+cnt%M+cnt1%M)%M;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool dfs(int l,int r,vint a,vint b){
    if(a.size()==0)return true;

    bool flag=false,ex=false;
    rep(i,a.size()){
        if(l-1!=a[i]&&r+1!=a[i])continue;
        ex=true;
        vint aa=a;
        swap(aa[i],aa[a.size()-1]);
        aa.pop_back();
        flag|=dfs(l-(l-1==a[i]),r+(r+1==a[i]),b,aa)==false;
    }
    if(!ex)flag|=dfs(l,r,b,a)==false;
    return flag;
}

void solve(){
    bool ex[20]={};
    vint a,b;
    rep(i,6){
        int f;cin>>f;
        a.pb(f);
        ex[f]=true;
    }
    for(int i=1;i<=13;i++){
        if(i==7||ex[i])continue;
        b.pb(i);
    }

    if(dfs(7,7,a,b))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

signed main(){
    int N;
    cin>>N;
    while(N--)solve();
    return 0;
}

Measured memory_bytes: 3092
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
  	
  	string s;
  	cin >> s;
  	forn(i ,s.size() - 1){
		if(s[i] == s[i + 1]){
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int count=1;
    vector<int>v(n);
    v.push_back(a[1]);
    int min=a[1];
    for(int i=1;i<n;i++){
        v[i]=a[i+1];
        if(a[i+1]<min){
            count++;
            min=a[i+1];
        }
    }
    cout<<count<<endl;
}
    




Measured memory_bytes: 2560