akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

int main(){


	int N,M,a,b;

	cin >> N >> M;


	vector <pair <int ,bool>> P(N);

	for(int i=0; i<N; i++){

		if(i==0) P[0].second = 1;

		 else P[i].second=0;

		 P[i].first = 1;
	}


		for(int i=0; i<M; i++){
		//	for(int i=0; i<N; i++){ cout <<"  mae   " <<P[i].first <<" " << P[i].second << endl;}
			cin >> a >> b;
			a--;b--;

			if(P[a].second == 1 )P[b].second = 1;

			P[a].first--;
			P[b].first++;

			if(P[a].first == 0 )P[a].second = 0;

		//	for(int i=0; i<N; i++){ cout <<"     " <<P[i].first <<" " << P[i].second << endl;}
			

		}
		int ans = 0;

		for(int i=0; i<N; i++){

			if(P[i].second== 1 )ans++;
		}

		cout << ans << endl;


}


Measured memory_bytes: 1024
"use strict";
function main(input) {
    const line = input.split("\n");
    let a = line[0];
   a = parseInt(a[a.length-1]);
    if(a==3) console.log("bon");
    else if(a==0 || a==1 || a==6 || a==8) console.log("pon");
    else console.log("hon");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//main(require('fs').readFileSync('input.txt', 'utf8'));

Measured memory_bytes: 29460
s = gets.chomp
if s.size == 1
  puts s
elsif (s[0] != '9' && s.count('9') == s.size - 1) || s.count('9') == s.size
  puts s.split('').map(&:to_i).reduce(:+)
else
  puts s[0].to_i - 1 + (s.size - 1) * 9
end


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

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

int N;
vector<int> d;
int main() {

	cin >> N;
	rep(i, N) {
		int j;
		cin >> j;
		d.push_back(j);		
	}

	sort(d.begin(), d.end());

	int ans = d.at(N/2)- d.at(N/2-1);

	cout << ans << endl;
	
}

Measured memory_bytes: 892
//Scannerクラスをimport
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//Scannerクラスのインスタンスを作成
		//標準入力はSystemクラスのinフィールドから取得できる
		Scanner sc = new Scanner(System.in);

		//nextIntにて整数を取得
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a + b/2);
	}

}

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

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

	int a[n][m],b[m],c[n];

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

	for(int i=0;i<n;i++){
		c[i]=0;
		for(int j=0;j<m;j++){
			c[i]=c[i]+a[i][j]*b[j];
		}
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 1196
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap.Strict    as M
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, k] <- readInts
  as <- readInts
  print $ solve n k as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> Int -> [Int] -> Int
solve n k as = sum $ take (l - k) cs where
  cs = sort hist
  hist = M.elems $ foldr (M.alter countup) M.empty as
  countup Nothing  = Just 1
  countup (Just x) = Just $ x + 1
  l = length cs


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

const int dh[4] = {-1, 0, 0, 1};
const int dw[4] = {0, -1, 1, 0};

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    for(int i = 0; i < H; i++) cin >> s[i];
    
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int count = 0;
            if(s[i][j] == '.') continue;
            for(int d = 0; d < 4; d++) {
                int h = i + dh[d];
                int w = j + dw[d];
                if(h < 0 || H <= h) continue;
                if(s[h][w] == '#') count++;
            }
            if(count == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# にぶたんが失敗したので両端からしゃくとりするような感じでやってみる
# 差分でソートして大きく足りないものは大きく余ってるやつをぶつける

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
D = []
pre_ans = 0  # 確実に変えなくてはいけないやつ
for i in range(N):
    if A[i] != B[i]:
        D.append(A[i] - B[i])
        if A[i] < B[i]:
            pre_ans += 1
D = sorted(D)

used = 0
tmp = 0
# print(D)
l, r = 0, len(D)
while r - l > 1:
    # print("now tmp: {}".format(tmp))
    if tmp + D[l] < 0:
        # 新たに借りる
        r -= 1
        used += 1
        tmp += D[r]
    tmp += D[l]
    l += 1
print(used + pre_ans)


Measured memory_bytes: 18356
fun main(args: Array<String>) {
    while(true)
    {
        val list = readLine()!!.split(" ").map(String::toInt)
        if ((list[0]==0) or (list[1]==0))
        {
            return
        }
        for (j in 1..list[0])
        {
            for (i in 1..list[1])
            {
                if ((i + j) % 2 == 1)
                {
                    print('.')
                }
                else
                {
                    print('#')
                }

            }
            println("")
        }
        println("")
    }
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const int N=200001;
int st[4*N+3];

    //Write reqd merge functions

    //Handle lazy propagation appriopriately

    int  Query(int node, int L, int R, int i, int j)
    {
        if(j<L || i>R)
            return 0;
        if(i<=L && R<=j)
            return st[node];
        int M = (L + R)/2;
        int left=Query(node*2, L, M, i, j);
        int right=Query(node*2 + 1, M + 1, R, i, j);
        //data cur;
      return max(left,right);

    }
    void pUpdate(int node, int L, int R, int pos, int val)
    {

        if(L == R)
        {
            st[node]=val;
            return;
        }
        int M = (L + R)/2;
        if(pos <= M)
            pUpdate(node*2, L, M, pos, val);
        else
            pUpdate(node*2 + 1, M + 1, R, pos, val);
      st[node]=max(st[2*node],st[2*node+1]);
        //merge(st[node], st[node*2], st[node*2 + 1]);
    }
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
  cin>>n;
  int h[n],a[n];
  for(i=0;i<n;i++)
    cin>>h[i];
for(i=0;i<n;i++)
    cin>>a[i];
int ans=0;
//init(200001);
for(i=0;i<n;i++)
{
    int t1=Query(1,1,n,1,h[i]-1);
    ans=max(ans,t1+a[i]);
    pUpdate(1,1,n,h[i],t1+a[i]);
}
cout<<ans;

}

}


Measured memory_bytes: 10864
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0
 
def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        count += 1
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
 
def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
 
mergeSort(S, 0, n)
print(*S)
print(count)

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

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;

		try {
			input = br.readLine();
		} catch (IOException e) {
		}
		double r = Double.parseDouble(input);
		double menseki =  r * r * Math.PI;
		double syuu =  (2 * r) * Math.PI;

		//System.out.println(menseki + " " + syuu);
		System.out.printf("%f %f\n", menseki, syuu);
	}
}


Measured memory_bytes: 24768
#include<bits/stdc++.h>
using namespace std;
vector<int> dp(100000,0);

int main(){
    int n;cin>>n;
    int a,b,c;
    a=1;b=6;c=9;
    for(int i=1;i<n+1;i++){
        if(i>=b*6) b*=6;
        if(i>=c*9) c*=9;
        if(i<6) dp[i]=i;
        else if(i<9) dp[i]=min(dp[i-a]+1,dp[i-b]+1);
        else dp[i]=min({dp[i-a]+1,dp[i-b]+1,dp[i-c]+1});
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
// 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) { break; }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;
// ... 平均値averageと，分散varianceを計算しよう ...
                double b=0;
                double s=0;
                for(int i=0; i<scores.length;i++) {
                    s=s+scores[i];
                }
                double a;
                average=s/n;
                for(int i=0; i<scores.length;i++) {
                    a = Math.pow((scores[i] - average), 2);
                    b = a + b;
                }
                variance=b/n;
                System.out.println(Math.sqrt(variance));

            }
        }
     }
}


Measured memory_bytes: 30968
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
vector<int>f;
int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int t=max(a,b);
    for(int i=1;i<=t;i++)
		if(a%i==0&&b%i==0)
			f.push_back(i);
	sort(f.begin(),f.end(),cmp);
	printf("%d\n",f[k-1]);
    return 0;
}


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

int main()
{
  int N, M; cin >> N >> M;
  int A[2*M]; rep(i,2*M) cin >> A[i];
  //集計
  int map[N+1] = {0};
  rep(i,2*M) map[A[i]]++;
  //表示
  rep(i,N) cout << map[i] << endl;
}

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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    string s;
    cin >> s;
    bool flg = true;
    for (int i = 1; i < s.size(); ++i) {
        flg &= (s[i] != s[i - 1]);
    }
    if(flg){
        puts("Good");
    }else{
        puts("Bad");
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
using namespace std;

main(){ 
int S;
int h,m,s;

cin >> S;

s = S%60;
m = (int) floor((float) S / 60) %60;
h = floor((float) S / 60 / 60);

cout << h << ":" << m << ":" << s << endl;
return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int mochi=1, i, j;
  for(i=0; i < N-1; i++){
    j = i+1;
    if(vec.at(i) > vec.at(j)){
      mochi += 1;
    }
  }  
  cout << mochi << endl;
}

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

signed main() {
  int n,k; string s;
  cin >> n >> k >> s;
  s[k-1]+=32;
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
void Y()
{
    cout<<"Yes"<<endl;
}
void N()
{
    cout<<"No"<<endl;
}
int main()
{
    FAST;
    LL n;
    DL x;
   cin>>n;
   x=(DL)n;
   cout<<fixed<<setprecision(2)<<2*PI*x<<endl;

    return 0;
}


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

using LL = long long;

set<LL> prime_factor(LL n) {
  set<LL> prime;
  for(LL i = 2; i <= n / i; ++i)
    for(; n % i == 0; n /= i)
      prime.emplace(i);
  if(n != 1) prime.emplace(n);
  return prime;
}

string solve() {
  LL N;
  cin >> N;
  vector<LL> A(N);
  for(auto& i: A) cin >> i;

  auto pc = [&]() {
    set<LL> used;
    for(auto i: A) for(auto p: prime_factor(i)) {
      if(used.count(p)) return false;
      used.emplace(p);
    }
    return true;
  };

  auto sc = [&]() {
    return 1 == accumulate(begin(A), end(A), A[0], [](auto s, auto i) {return gcd(s, i);});
  };

  if(pc()) return "pairwise coprime";
  if(sc()) return "setwise coprime";
  return "not coprime";
}

int main() {
  cout << solve() << endl;
}


Measured memory_bytes: 11180
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;

void add_edge(vector<vll> &G, ll u, ll v){
    G[u].push_back(v); G[v].push_back(u);
}

bool dfs(vector<vll> &G, vb &checked, vll &match, ll v){
    //* match is initialized -1 outside
    checked[v] = true;
    REP(i, G[v].size()){
        ll u = G[v][i], w = match[u];
        if(w < 0 || !checked[w] && dfs(G, checked, match, w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

ll BipartiteMatching(vector<vll> &G){
    ll N = G.size();
    vb checked(N, false);
    vll match(N, -1);
    ll res = 0;
    REP(v, N){
        if(match[v] < 0){
            fill(ALL(checked), false);
            if(dfs(G, checked, match, v)){
                res++;
            }
        }
    }
    return res;
}

//! submitted to: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp
int main(){
    ll X, Y, E; cin >> X >> Y >> E;
    ll N = X+Y;
    vector<vll> G(N);
    REP(i, E){
        ll x, y;
        cin >> x >> y;
        y += X;
        add_edge(G, x, y);
    }
    ll m = 0;
    m = BipartiteMatching(G);
    cout<<m<<endl;
}


Measured memory_bytes: 3300
str = input()
q = int(input())
line = []
for _ in range(0,q):
    line[:] = input().split()
    cmd = line[0]
    a = int(line[1])
    b = int(line[2])
    #print(' '.join(line))
    if (cmd == 'print'):
        print(str[a:b+1])
    elif (cmd == 'reverse'):
        rev = ''
        for i in range(a, b+1):
            rev = str[i:i+1] + rev
        str = str[:a]+rev+str[b+1:]
    elif (cmd == 'replace'):
        p = line[3]
        str = str[:a]+p+str[b+1:]
 


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

int main(){
  int n;
  cin>>n;
  while(n--){
    string messengers;
    string message;
    cin>>messengers;
    cin>>message;
    for(int i=(int)messengers.size()-1;i>=0;i--){
      if(messengers[i]=='J'){
	char first=message[(int)message.size()-1];
	for(int i=(int)message.size()-1;i>=1;i--){
	  message[i]=message[i-1];
	}
	message[0]=first;
      }else if(messengers[i]=='C'){
	char last=message[0];
	for(int i=0;i<(int)message.size()-1;i++){
	  message[i]=message[i+1];
	}
	message[(int)message.size()-1]=last;
      }else if(messengers[i]=='E'){
	string sleft=message.substr(0,(message.size())/2);
	string sright=message.substr((message.size()+1)/2);
	for(int i=0;i<int(message.size()/2);i++){
	  message[i]=sright[i];
	  message[i+(message.size()+1)/2]=sleft[i];
	}
      }else if(messengers[i]=='A'){
	reverse(message.begin(),message.end());
      }else if(messengers[i]=='P'){
	for(int i=0;i<(int)message.size();i++){
	  if('0'<=message[i] && message[i]<='9'){
	    if(message[i]=='0') message[i]='9';
	    else message[i]--;
	  }
	}
      }else{
	for(int i=0;i<(int)message.size();i++){
	  if('0'<=message[i]&&message[i]<='9'){
	    if(message[i]=='9') message[i]='0';
	    else message[i]++;
	  }
	}
      }
    }
    cout<<message<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int X;

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> X;
  cout << 360/gcd(360, X) << endl;
}


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

bool is_samestr(string S) {
    char fst = S[0];
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != fst) return false;
    }
    return true;
}

int main(void) {
    string S;
    cin >> S;
    string Orig = S;

    sort(S.begin(), S.end());
    // cout << S << endl;

    int count = 1;
    char comp = S[0];
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != comp) {count++; comp = S[i];}
    }
    // cout << count << endl;

    char ele[count];
    comp = S[0];
    int j = 0;
    ele[0] = comp;
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] != comp) {j++; comp = S[i]; ele[j] = comp;}
    }

    // cout << ele << endl << endl;

    string tempstr;
    int lcount, end;
    int min_count = 10000000;
    char cur_ele;
    for (int i = 0; i < count; ++i) {
        cur_ele = ele[i];
        tempstr = Orig;
        end = tempstr.length() - 1;
        lcount = 0;
        // cout << cur_ele << endl;
        while (is_samestr(tempstr) != true) {
            // cout << tempstr << endl;
            for (int j = 0; j < end; ++j) {
                if (tempstr[j+1] == cur_ele) {tempstr[j] = cur_ele;}
            }
            tempstr.pop_back();
            lcount++; end--;
        }
        min_count = min(lcount, min_count);
        // cout << endl;
    }
    cout << min_count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<ctype.h>
using namespace std;
int temp;
int d,n;
int t[10000];
int a[10000],b[10000],c[10000];
int dp[10000][10000];
int i,j,k;
int main(void){
	int max=0;
	scanf("%d %d",&d,&n);	//d=見る日数 n=服の種類
	for(i=0;i<d;i++){
		scanf("%d",&t[i]);	//i日目の最高温度
	}
	for(i=0;i<d;i++){
		for(j=0;j<n;j++){
			dp[i][j]=-1;	//派手さ
		}
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);	//a=最低温度 b=最高温度 c=派手
	}
	for(i=0;i<n;i++){
		if(a[i]<=t[0] && b[i]>=t[0]){
			dp[0][i]=0;
		}
	}
	for(i=1;i<d;i++){
		for(j=0;j<n;j++){
			if(dp[i-1][j]!=-1){
				for(k=0;k<n;k++){
					if(a[k]<=t[i] && b[k]>=t[i]){
						if(dp[i][k]==-1) {
							dp[i][k]=0;
						}
						temp=c[k]-c[j];
						//printf("c[k]%d c[j]%d\n",c[k],c[j]);
						if(temp<0)	temp=0-temp;
						if(max<=temp){
							max=temp;
						}
						//printf("max%d\n",max);
						//printf("dpa%d i=%d k=%d\n",dp[i][k],i,k);
						if(dp[i][k]<=dp[i-1][j]+max){
							dp[i][k]=dp[i-1][j]+max;
						//printf("aa%d %d %d %d\n",dp[i][j],dp[i][k],i,j);
						}
					}
			max=0;
				}
			}
			//printf("\n");
		}
		//printf("\n");
	}
	/*for(i=0;i<d;i++){ //でバグ
		printf("%d\n",t[i]);
		for(j=0;j<n;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/			
	max=0;
	for(j=0;j<n;j++){
		//printf("%d ",dp[d-1][j]);
		if(dp[d-1][j]>max){
			max=dp[d-1][j];
		}
	}
	//printf("\n");
	printf("%d\n",max);
	return 0;
}
	

Measured memory_bytes: 7452
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	minA := (a*100 + 7) / 8
	maxA := ((a+1)*100+7)/8 - 1
	minB := (b*100 + 9) / 10
	maxB := ((b+1)*100+9)/10 - 1

	debugf("A: %d - %d, B: %d - %d\n", minA, maxA, minB, maxB)

	if max(minA, minB) > min(maxA, maxB) {
		_, _ = fmt.Fprintf(writer, "%d", -1)
	} else {
		_, _ = fmt.Fprintf(writer, "%d", max(minA, minB))
	}

}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int M[3];
vi G[3][MAX_N];
int grundy[3][MAX_N];
ll E[3][2010];
ll pw10[MAX_N];

void solve() {
	cin >> N;
	rep(q, 0, 3) {
		cin >> M[q];
		rep(i, 0, M[q]) {
			int a, b;
			cin >> a >> b; a--; b--;
			G[q][a].pb(b);
			G[q][b].pb(a);
		}
	}
	pw10[0] = pw10[1] = 1;
	rep(_, 0, 18) MUL(pw10[1], 10);
	rep(i, 1, N) pw10[i + 1] = pw10[i] * pw10[1] % mod;
	rep(q, 0, 3) {
		rer(i, N, 0) {
			set<int> S;
			rep(j, 0, sz(G[q][i])) {
				int n = G[q][i][j];
				if(n > i) {
					// debug(q, i, n, grundy[q][n]);
					S.insert(grundy[q][n]);
				}
			}
			while(!S.empty() && grundy[q][i] == *S.begin()) {
				grundy[q][i]++;
				S.erase(S.begin());
			}
			// debug(q, i, grundy[q][i]);
			ADD(E[q][grundy[q][i]], pw10[i + 1]);
		}
	}
	ll res = 0;
	rep(i, 0, 1024) {
		rep(j, 0, 1024) {
			ADD(res, E[0][i] * E[1][j] % mod * E[2][i ^ j] % mod);
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 100010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;
int n;
//ll f[maxN];
char s[maxN]; 
int tag[27];
//ll p[maxN][27];
//ll ans = 0;
//ll d[27];
//int vis[27];
//void dfs(int i,int k)
//{
//	if(i > k)
//	{
//		ll res = 1;
//		for(int i=1;i<=k;i++)
//		{
//			res = (res * tag[d[i]])%MOD;
//		}
//		ans += res;
//		return;
//	}
//	for(int j=1;j<=26;j++)
//	{
//		if(vis[j] != 1)
//		{
//			if(j < d[i-1]) continue;
//			vis[j] = 1;
//			d[i] = j;
//			dfs(i+1,k);
//			vis[j] = 0;
//		}
//	}	
//}
ll f[27];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		int x = s[i] - 'a' + 1;
		tag[x]++;
	}
	int len = 26;
	f[0] = 1;
	for(int i=1;i<=len;i++)
	{
		for(int j=0;j<i;j++)
		{
			f[i] += (tag[i] * f[j])%MOD;
		}
	}
	ll ans = 0;
	for(int i=1;i<=len;i++)
	{
		ans = (ans + f[i])%MOD;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;

#define df(b, e) ((b) > (e))
#define fore(i, b, e) for (auto i = (b) - df(b, e); i != e - df(b, e); i += 1 - 2 * df(b, e))
#define sz(x) (int)(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long lli;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

#ifdef LOCAL
  #include "debug.h"
  const int N = 12;
#else
  #define debug(...)
  const int N = 2e5 + 5;
#endif
const int INF = 1e9 + 7;

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

vi g[N];
lli dp[N], ans[N], mod;
int n;

lli dfs (int u, int parent = 1) {
  auto &nans = dp[u] = 1;
  for (auto v: g[u]) {
    if (v != parent) { 
      (nans *= dfs(v, u) + 1) %= mod;
    }
  }
  return nans;
}

void solve (int u, int parent = 1) {
  debug(u, parent);
  vector<lli> list;
  for (auto v: g[u]) {
    list.eb(dp[v]);
  }
  debug(list);
  vector<lli> pre, suf;
  for (auto x: list) {
    pre.eb(((sz(pre) ? *pre.rbegin() : 1LL) * (x + 1)) % mod);
  }
  reverse(all(list));
  for (auto x: list) {
    suf.eb(((sz(suf) ? *suf.rbegin() : 1LL) * (x + 1)) % mod);
  }
  reverse(all(suf));
  ans[u] = (sz(list) == 0 ? 1: suf[0]);
  debug(pre);
  debug(suf);
  auto get = [&] (int k) -> lli {
    return ((k == 0 ? 1: pre[k - 1]) * (k == sz(list) - 1 ? 1: suf[k + 1])) % mod;
  };
  int cnt = 0;
  for (auto v: g[u]) {
    if (v != parent) {
      dp[u] = get(cnt);
      solve(v, u);
    }
    cnt++;
  }
}

int main() {
  cin.tie(0) -> sync_with_stdio(0), cout.tie(0);
  int u, v;
  cin >> n >> mod;
  fore (i, 0, n - 1) {
    cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  dfs(1);
  solve(1);
  fore (i, 1, n + 1)
    cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 33628
#include<bits/stdc++.h>
using namespace std;
string s;
vector<char> v[2];
long long q;
int n,now=0,x;
char zz;
int main()
{
    cin>>s>>q;
    for(int i=0;i<q;i++)
    {
        cin>>n;
        if(n==1)
        {
            now=!now;
        }
        else{
            cin>>x;
            if(x==1)
            {
                cin>>zz;
                if(now)
                {
                    v[1].push_back(zz);
                }
                else{
                    v[0].push_back(zz);
                }
            }
            else{
                cin>>zz;
                if(now)
                {
                    v[0].push_back(zz);
                }
                else{
                    v[1].push_back(zz);
                }
            }
        }
    }
    if(now==0)
    {
        for(int i=v[0].size()-1;i>=0;i--)
            printf("%c",v[0][i]);
        cout<<s;
        for(int i=0;i<v[1].size();i++)
            printf("%c",v[1][i]);
    }
    else{
        for(int i=v[1].size()-1;i>=0;i--)
            printf("%c",v[1][i]);
        reverse(s.begin(),s.end());
        cout<<s;
        for(int i=0;i<v[0].size();i++)
            printf("%c",v[0][i]);
    }
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
#include <sstream>
#include <ctime>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mes(a, b) memset((a), (b), sizeof (a))
#define IosF ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;

struct Point{
    double x, y;
    Point(double a = 0, double b = 0) : x(a), y(b) {};
};

typedef Point Vector;
inline Vector operator + (Vector A, Vector B) {return Vector(A.x + B.x, A.y + B.y);}
inline Vector operator - (Vector A, Vector B) {return Vector(A.x - B.x, A.y - B.y);}
inline Vector operator * (Vector A, double x) {return Vector(A.x * x, A.y * x);}
inline Vector operator / (Vector A, double x) {return Vector(A.x / x, A.y / x);}
inline double Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;} //向量点乘
inline double Len(Vector A) {return sqrt(Dot(A, A));}
inline double Ang(Vector A, Vector B) {return acos(Dot(A, B) / Len(A) / Len(B));} //向量夹角
inline double Cro(Vector A, Vector B) {return A.x * B.y - A.y * B.x;} //向量叉乘
inline double Area(Vector A, Vector B) {return Cro(A, B) * 0.5;} //组成三角形面积
inline Vector Rotate(Vector A, double rad) {return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));} //向量逆时针旋转角度rad
inline Vector Normal(Vector A) {double len = Len(A); return Vector(-A.y / len, A.x / len);}//求向量A的单位法线

typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int M = 0x3f3f3f3f;
const int inf = 0x7fffffff;
const int mod = 9901;
const double PI = acos(-1);

string mp[7];
inline void Solve() {
    int c, r, s;
    cin >> r >> c >> s;
    for ( int i = 0; i < r; i ++ )
        cin >> mp[i];

    int n = 1, ans = 0;
    for ( int i = 0; i < c + r; i ++ ) n *= 2;
    for ( int k = 0; k < n; k ++ ) {
        bitset<12> p(k);
        int num = 0;
        for ( int i = 0; i < r; i ++ )
        for ( int j = 0; j < c; j ++ ) {
            if ( p[i] || p[j + r] ) continue;
            else if ( mp[i][j] == '#' ) num ++;
        }
        if ( num == s ) ans ++;
    }

    cout << ans << endl;
}

int main() {
    IosF;
    Solve();
    return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().toCharArray()[0];
		char b= sc.next().toCharArray()[0];


		if (a < b) {
			System.out.println("<");
		} else if (b < a) {
			System.out.println(">");
		} else {
			System.out.println("=");
		}

		sc.close();

	}

}


Measured memory_bytes: 35604
from heapq import heappop, heappush


class WeightedEdge:
    """Weighted edge."""

    def __init__(self, a, b, weight):
        self.a = a
        self.b = b
        self.weight = weight

    def __repr__(self):
        return "(%d - %d: %d)" % (self.a, self.b, self.weight)

    def __lt__(self, other):
        return self.a < other.b


class EdgeWeightedGraph:
    """Undirected Edge-weighted graph (1-n indexed)."""

    def __init__(self, V):
        self.__adj = [[] for _ in range(V + 1)]

    def add_edge(self, a, b, weight):
        self.__adj[a].append(WeightedEdge(a, b, weight))
        self.__adj[b].append(WeightedEdge(b, a, weight))

    def adj(self, a):
        return self.__adj[a]

    def num_nodes(self):
        return len(self.__adj) - 1


class Dijkstra:
    """Single root shortest path by Dijkstra."""

    def __init__(self, graph, s, t):
        self.dist_to = [float('inf') for _ in range(graph.num_nodes() + 1)]
        self.dist_to[s] = 0
        pq = []
        heappush(pq, (0, s))
        while pq:
            w, a = heappop(pq)
            if a == t:
                return
            if self.dist_to[a] < w:
                continue
            for edge in graph.adj(a):
                if self.dist_to[edge.b] > self.dist_to[a] + edge.weight:
                    self.dist_to[edge.b] = self.dist_to[a] + edge.weight
                    heappush(pq, (self.dist_to[edge.b], edge.b))


if __name__ == '__main__':
    while True:
        n, m = map(int, input().split())
        if n == 0 and m == 0:
            break

        g_cost = EdgeWeightedGraph(m)
        g_time = EdgeWeightedGraph(m)
        for _ in range(n):
            a, b, cost, time = map(int, input().split())
            g_cost.add_edge(a, b, cost)
            g_time.add_edge(a, b, time)

        k = int(input())
        for _ in range(k):
            p, q, r = map(int, input().split())
            if r == 0:
                fw_cost = Dijkstra(g_cost, p, q)
                ans = fw_cost.dist_to[q]
            else:
                fw_time = Dijkstra(g_time, p, q)
                ans = fw_time.dist_to[q]
            print(ans)

Measured memory_bytes: 7484
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────

int main() {
	int n, m; cin >> n >> m;
	vi c(m); rep(i, m) cin >> c[i];

	vi dp(50010, inf);
	dp[0] = 0;

	rep(i, n + 1) {
		rep(j, m) {
			if (i >= c[j]) {
				dp[i] = min(dp[i - c[j]] + 1, dp[i]);
			}
		}
	}

	cout << dp[n] << endl;
}


Measured memory_bytes: 3112
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := nextInt(), nextInt()
	s := make([]string, n)
	for i := range s {
		s[i] = next()
	}
	sort.Sort(sort.StringSlice(s))

	for i := range s {
		putf("%s", s[i])
	}
	putf("\n")
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
# -*- coding:utf-8 -*-

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

count = 0

for i in reversed(range(max((Y//10000)+1, N+1))):
    for j in range(max((Y//5000)+1, N+1)):
        if i+j > N:
            break
        if i*10000 + j*5000 + (N-i-j)*1000 == Y:
            print("{0} {1} {2}".format(i, j, N-i-j))
            exit()

print("-1 -1 -1")


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

int main() {
    string S;

    cin >> S;

    vector<int> alphabet_vec(30, 0);
    string alphabet = "abcdefghijklmnopqrstuvwxyz";

    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < alphabet.size(); j++) {
            if(S.at(i) == alphabet.at(j)) {
                alphabet_vec.at(j) += 1;    
            }
        }
    }

    bool check = false;
    for(int i = 0; i < alphabet.size(); i++) {
        if(alphabet_vec.at(i) == 0) {
            cout << alphabet.at(i) << endl;
            check = true;
            break;
        }
    }

    if(check == false) {
        cout << "None" << endl;        
    }
}


Measured memory_bytes: 512
from math import sqrt
from itertools import combinations
N = int(input())

k = round((1+sqrt(1+8*N))/2)

if k*(k-1) != 2*N:
  print('No')
  exit()

print('Yes')
print(k)

S = [list() for _ in range(k)]

for i,(a,b) in enumerate(combinations(range(k),2)):
  S[a].append(i+1)
  S[b].append(i+1)

for s in S:
  print(len(s),' '.join(map(str,s)))

Measured memory_bytes: 12276
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define mod 1000000007

int main() {
	ll s;
	cin >> s;
	ll buf1, buf2;
	ll ans = 0;
	if (s < 2) {
		cout << 0 << endl;
		return 0;
	}
	vector<ll> dp(s + 1 , 0);
	dp[0] = 1;
	for (int i = 3; i <= s; i++) {
		dp[i] = (dp[i - 1] + dp[i - 3])%mod;
	}

	cout << dp[s] << endl;
	return 0;
}

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

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  using ll = long long;
  int n;
  cin >> n;
  ll res = 0;
  vector cnt(50, vector<int>(20));
  while (n--) {
    long double x;
    cin >> x;
    x *= 1e9;
    ll a = round(x);
    int e2 = 0;
    while (a % 2 == 0) {
      ++e2;
      a /= 2;
    }
    int e5 = 0;
    while (a % 5 == 0) {
      ++e5;
      a /= 5;
    }
    for (int i = max(18 - e2, 0); i < 50; ++i) {
      for (int j = max(18 - e5, 0); j < 20; ++j) {
        res += cnt[i][j];
      }
    }
    ++cnt[e2][e5];
  }
  cout << res << '\n';
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#include <iomanip>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

const int N = 100 * 1000 + 5;
vector <int> v[N];
vector <int> A(N, MOD);
vector <int> l(N, 0), r(N, MOD), val(N);
bool ok = true;
void dfs(int s, int pr) {
	if (A[s] != MOD) {
		l[s] = A[s];
		r[s] = A[s];
	}
	for (auto g : v[s]) {
		if (g != pr) {
			dfs(g, s);
			l[s] = max(l[s], l[g] - 1);
			r[s] = min(r[s], r[g] + 1);
		}
	}
}
void dfs2(int s, int pr) {
	if (A[s] != MOD && A[s] != val[s]) {
		ok = false;
	}
	for (auto g : v[s]) {
		if (g != pr) {
			if (val[s] + 1 >= l[g] && val[s] + 1 <= r[g]) {
				val[g] = val[s] + 1;
			}
			else if (val[s] - 1 >= l[g] && val[s] - 1 <= r[g]) {
				val[g] = val[s] - 1;
			}
			else {
				ok = false;
			}
			dfs2(g, s);
		}
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int k;
	cin >> k;
	for (int i = 0; i < k; i++) {
		int x, y;
		cin >> x >> y;
		A[x] = y;
	}
	dfs(1, 0);
	if (l[1] > r[1]) {
		cout << "No\n";
	}
	else {
		val[1] = l[1];
		dfs2(1, 0);
		if (!ok) {
			cout << "No\n";
		}
		else {
			cout << "Yes\n";
			for (int i = 1; i <= n; i++) {
				cout << val[i] << "\n";
			}
		}
	}
}


Measured memory_bytes: 14208
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0: break
    for j in range(H):
        for i in range(W):
            if (i + j)%2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print("")


Measured memory_bytes: 7000
package main

import "fmt"

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	sum := 0
	for i := 0; i < n-1; i++ {
		costA := a * (xs[i+1] - xs[i])
		costB := b
		sum += smaller(costA, costB)
	}
	fmt.Println(sum)
}


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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

ll  n, m, use[100000], a,b,c, result=0;

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

	cin>>n>>m;
	fill(use,use+m,0);
	int bef,cur;
	cin>>bef;
	bef--;
	for(int i=1;i<m;i++){
		cin>>cur;
		cur--;
		use[min(bef, cur)]++;
		use[max(bef, cur)]--;
		bef=cur;
	}
	for(int i=0;i<n-1;i++){
		cin>>a>>b>>c;
		use[i+1]+=use[i];
		result+=min(a*use[i],b*use[i]+c);
	}
	cout<<result<<en;

	return 0;
}

Measured memory_bytes: 4004
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,m = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = [0]*m
  
  for i in range(n):
    for k in range(1,a[i][0]+1):
      lis[a[i][k]-1] += 1
  print(lis.count(n))  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
from math import sqrt
from sys import stdin

n, d = map(int, input().split())
xys = []
for _ in range(n):
    xys.append(tuple(map(int, stdin.readline().split())))
ans = 0

for x, y in xys:
    if sqrt(x**2 + y**2) <= d:
        ans += 1

print(ans)


Measured memory_bytes: 96708
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////
vector<ll> see;
vector<vector<ll>> g;

void dfs(ll v) {
	see[v] = 1;

	for (ll w : g[v]) {
		if (see[w] == 1) { continue; }
		dfs(w);
	}
	return;
}


int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> Lng(M + 1);

	repn(i, N) {
		ll K;
		cin >> K;
		repn(j, K) {
			ll L;
			cin >> L;
			Lng[L].push_back(i);
		}
	}

	g.resize(N + 1);
	repn(i, M) {
		ll ls = Lng[i].size();
		repn(j, ls - 1) {
			g[Lng[i][0]].push_back(Lng[i][j]);
			g[Lng[i][j]].push_back(Lng[i][0]);
		}
	}

	see.assign(N + 1, 0);
	see[1] = 1;
	dfs(1);

	string ans = "YES";
	repn(i, N) if (see[i] == 0) { ans = "NO"; }

	cout << ans << endl;
	

	
	system("PAUSE");
}


Measured memory_bytes: 10600
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from itertools import accumulate
def resolve():
    D,N=pin()
    if D==0:
        if N!=100:print(N)
        else:print(101)
    if D==1:
        if N!=100:print(N*100)
        else:print(10100)
    if D==2:
        if N!=100:print(N*10000)
        else:print(1010000)
#%%submit!
resolve()

Measured memory_bytes: 38256