akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector<double>data(3000);//globalで宣言するときには大きさも入れとかないといけない
vector<vector<int>>done(3000,vector<int>(3000));
vector<vector<double>>memo(3000,vector<double>(3000));

double dp(int p,int q){
  if (p<q){
    done.at(p).at(q)=1;
    memo.at(p).at(q)=0;
    return memo.at(p).at(q);
  }
  else{
  if (done.at(p).at(q)){
  return memo.at(p).at(q);
  }
  else{
  double r;
  r=dp(p-1,q-1)*data.at(p-1)+dp(p-1,q)*(1-data.at(p-1));
 memo.at(p).at(q)=r;//こいつをどこにメモするか問題があるな
 done.at(p).at(q)=1;
  return r;
  }
  }
}
int main (){
  int n;
  cin >>n;
  for (int i=0;i<n;i++){
  cin >>data.at(i);
  } 
  //dataはi番目のデータはdata.at(i)にある。
  //初期化問題.memo.at(p).at(q)は
  memo.at(1).at(0)=1-data.at(0);
  done.at(1).at(0)=1;
  memo.at(1).at(1)=data.at(0);
  done.at(1).at(1)=1;
  for (int i=2;i<n+1;i++){
  memo.at(1).at(i)=0;
  done.at(1).at(i)=1;
  }
  for (int i=2;i<n+1;i++){
  memo.at(i).at(0)=memo.at(i-1).at(0)*(1-data.at(i-1));
  done.at(i).at(0)=1;
  }
  
  
  double s=0;
//cout <<dp(2,1)<<" "<<dp(1,2)<<" "<<memo.at(1).at(3);
  for (int i=n/2+1;i<n+1;i++){
 s+=dp(n,i);//dp(n,i)はカードをn枚使ったときに、面がi回出る確率
 }
  //cout <<s<<endl;
  printf("%.10f", s);
}

Measured memory_bytes: 108288
#include <bits/stdc++.h>
using namespace std;
const int MM = 1e9;
int main(){
  long long S;
  cin>>S;
  long long A,B;
  if(S == 1000000000000000000){
    cout << "0 0 1000000000 0 0 1000000000" << endl;
  }
  else{
    A = (S/MM)+1;
    B = MM-S%MM;
    cout << 0 << " " << 0 << " " << MM << " " << 1 << " " << B << " " << A << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

int n;
int cnt_e[300005];
int cnt_w[300005];
string s;
int res;

void read_input(){
    cin >> n >> s;
    res = n;

    for(int i = 0 ; i < n; ++i){
	cnt_e[i] = (s[i] == 'E');
	cnt_w[i] = (s[i] == 'W');
	if(i){
	    cnt_e[i] += cnt_e[i-1];
	    cnt_w[i] += cnt_w[i-1];
	}
    }

    for(int i = 0 ; i < n; ++i){
	int cur = 0 ;
	if(i)
	    cur = cnt_w[i-1];
	cur += (cnt_e[n-1] - cnt_e[i]);
	res = min(res,cur);
    }
    cout << res << endl;
}

int main(){
    read_input();
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#define NMAX 100000

int A[NMAX];
int partition(int q,int r){
  int x,i,j,tmp;
  x=A[r];
  i=q-1;
  for(j=q;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}
int main(){
int n,i=0,j;
int x,y,tmp,q;
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&A[i]);
}

q=partition(0,n-1);

for(i=0;i<n;i++){
  if(i)printf(" ");
  if(i==q)printf("[");
  printf("%d",A[i]);
  if(i==q)printf("]");
}
printf("\n");
  return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] split = input.split(" ");
        int h = Integer.parseInt(split[0]);
        int w = Integer.parseInt(split[1]);

        for (int i = 0; i < h; i++) {
            String s = scanner.nextLine();
            System.out.println(s);
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 22740
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int calculate_digits_total(int x) {
	int digits_total = 0;
	while (x) {
		digits_total += x % 10;
		x /= 10;
	}

	return digits_total;
}

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

	vector<int> l(N);
	rep(i, N) cin >> l[i];
	sort(RALL(l));

	int ans = 0;
	rep(i, K) ans += l[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT long long
#define MOD 1000000007
using namespace std;
INT n, a, b;
int main(void)
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    if( n*a <= b ) cout<<n*a<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;


int main() {
	ll n, m, l;
	cin >> n >> m >> l;
	vector<vector<ll>> a, b, c;
	a.resize(n);
	for (ll i = 0; i < n; i++) {
		a[i].resize(m);
		for (ll j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	b.resize(m);
	for (ll i = 0; i < m; i++) {
		b[i].resize(l);
		for (ll j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < l; j++) {
			if (j) {
				cout << " ";
			}
			ll tmp = 0;
			for (ll k = 0; k < m; k++) {
				tmp += a[i][k] * b[k][j];
			}
			cout << tmp;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3200
#include <stdio.h>

#include <string.h>

#define MAX 100



int main(){

    int n;

    int t_point=0, h_point=0;

    char tarou[MAX], hanako[MAX];



    scanf("%d", &n);

    for(;n>0;n--){

        scanf(" %s %s", tarou, hanako);

        if(strcmp(tarou, hanako)>0){

            t_point+=3;

        }else if(strcmp(tarou, hanako)==0){

            t_point+=1;

            h_point+=1;

        }else if(strcmp(tarou, hanako)<0){

            h_point+=3;

        }

    }

    printf("%d %d\n", t_point, h_point);



    return 0;

}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

lint gcd(lint a, lint b) {
  if (a<b) swap(a, b);
  while (a%b>0) {
    a%=b;
    swap(a, b);
  }
  return b;
}

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

/*
X = a_k * ( p + 0.5 )
  = 1/2 * a_k * ( 2*p + 1 ) <- 1, 3, 5, 7, 9

    1/2 * a_k * ( 2*p + 2 ) <- 2, 4, 6, 8, 
  = a_k * ( p + 1 )

 */

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint n, m;
  cin >> n >> m;
  vector< lint > a(n), h(n);
  for (lint i=0; i<n; ++i) {
    cin >> a[i];
    h[i] = a[i]/2;
  }
  lint h_lcm = h[0], f_lcm = a[0];
  for (lint i=1; i<n; ++i) {
    h_lcm = lcm(h_lcm, h[i]);
    f_lcm = lcm(f_lcm, a[i]);
  }
  for (lint i=0; i<n; ++i) {
    if (h_lcm / h[i] % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << m/h_lcm - m/f_lcm << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	cout << abs((a - 2) * (b - 2)) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
 vector<tuple<string, int, int>>mi(n);
  for(int i; i<n; i++){
    int b; 
    string a;
    cin >> a >> b;
    mi.at(i)=make_tuple(a, 100-b, i+1);
  }
  sort(mi.begin(), mi.end());
  for(tuple<string, int, int>x : mi){
    int num;
    tie(ignore, ignore, num)=x;
    cout << num << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
pair < int , int > a[200100];

int main()
{
    cin >> n;
    for(int i = 0;i<n;i++){
        int x,y;  cin >> x >> y;
        a[i].first = y;
        a[i].second = x;
    }
    sort(a , a + n);
    ll T = 0;
    for(int i = 0;i<n;i++){
        if(a[i].second + T > a[i].first)  return cout << "No" , 0;
        T+=(ll)a[i].second;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
struct Card{ char suit, value; };
void BubbleSort(struct Card A[], int N);
void SelectionSort(struct Card A[], int N);
void print(struct Card A[], int N);
bool isStable(struct Card A[], struct Card B[], int N);



int main(void)
{
	int N;
	Card A[100], B[100];

	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> A[i].suit >> A[i].value;
	}

	for(int i = 0; i < N; i++)
		B[i] = A[i];


	BubbleSort(A, N);
	SelectionSort(B, N);

	
	print(A, N);
	cout << "Stable" << endl;

	print(B,N);
	if(isStable(A, B, N))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	return 0;

}

void BubbleSort(struct Card A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		for(int j = N - 1; j > i - 1; j--)
		{
			if(A[j].value < A[j - 1].value)
				swap(A[j], A[j - 1]);
		}
	}
}

void SelectionSort(struct Card A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		int minj = i;
		for(int j = i; j < N; j++)
		{
			if(A[j].value < A[minj].value)
				minj = j;
		}
		swap(A[i], A[minj]);
	}
}

void print(struct Card A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(i > 0)
			cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card A[], struct Card B[], int N)
{
	for(int i = 0; i < N; i++)
		if(A[i].suit != B[i].suit || A[i].value != B[i].value)
			return false;
	return true;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
	char str[3];
	cin>>str;
	sort(str,str+3);
	if(str[0]=='a'&&str[1]=='b'&&str[2]=='c'){
		cout<<"Yes"<<endl;
	}else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int h,w;
    cin>>h>>w;
    char mine[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>mine[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(mine[i][j]=='.'){
                int count=0;
                for(int d=0;d<8;d++){
                    const int ni=i+dy[d];
                    const int nj=j+dx[d];

                    if(ni<0 or h<=ni) continue;
                    if(nj<0 or w<=nj) continue;
                    if(mine[ni][nj] =='#') count++;
                }
                mine[i][j]=(char)(count + '0');

            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<mine[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, m;

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

    if (n == m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

puts [A+B, A-B, A*B].max


Measured memory_bytes: 14332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int maximum(long long int a) {
    long long int buf = 2;
    int count = 0;
    while (buf <= a) {
        buf = buf * 2;
        count++;
    }
    return count;
}

int main() {
    long long int a = 0, b = 0;
    scanf("%lld %lld", &a, &b);
    if (a > b) {
        long long int bubub = a;
        a = b;
        b = bubub;
    }
    long long int ans = 0;
    int len = maximum(b);
    long long int com = (long long int)pow(2, len);
    long long int *a_2sin = (long long int *)malloc(sizeof(long long int)*(len+1));
    long long int buf = a;
    for (int i=0; i<len+1; i++) {
        if (com <= buf) {
            buf -= com;
            a_2sin[i] = 1;
        }
        else {
            a_2sin[i] = 0;
        }
        com = com / 2;
    }
    long long int *hoge = (long long int *)malloc(sizeof(long long int)*(len+2));
    hoge[len+1] = 0;
    for (int i=len; i>=0; i--) {
        hoge[i] = (long long int)(pow(2, len-i) * a_2sin[i]) + hoge[i+1];
    }
    com = (long long int)pow(2, len);
    for (int i=0; i<len+1; i++) {
        long long int count_one = 0;
        long long int hogehoge = hoge[i+1];
        long long int now = a - 1;
        now = now + com - hogehoge;
        if (now >= b) count_one = (b - a + 1) * a_2sin[i];
        else {
            count_one = (com - hogehoge) * a_2sin[i];
            long long int counting = (b - now) / com;
            now = now + counting * com;
            if (a_2sin[i] == 0) {
                if (counting % 2 == 0) {
                    count_one = count_one + (counting / 2) * com;
                    count_one = count_one + b - now;
                }
                else {
                    count_one = count_one + (counting/2 + 1) * com;
                }
            }
            else {
                if (counting % 2 == 0) {
                    count_one = count_one + (counting / 2) * com;
                }      
                else {
                    count_one = count_one + (counting / 2) * com;
                    count_one = count_one + b - now;
                }
            }
        }
        if (count_one % 2 != 0) ans = ans + com;
        com = com / 2;
    }
    printf("%lld", ans);
    free(a_2sin);
    free(hoge);
    return 0;
}


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

int main() {
    int n,k, ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i=0; i<n; ++i)
        cin >> p.at(i);

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

    for (int i=0; i<k; ++i)
        ans += p.at(i);

    cout << ans;
}


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


int main(){
   long long int a,b,k;
   cin>>a>>b>>k;
   if(a>=k)
   cout<< a-k<<" " << b<<endl;
   else if (k<=a+b)
   cout<<0<<" " <<b+a-k<<endl;
   else 
    cout<<0<<" "<<0<<endl;
return 0;
}

Measured memory_bytes: 256
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
 int a,b,c,k,ans=0;
 cin>>a>>b>>c>>k;
 ans+=min(a,k);
 k-=min(a,k);
 k-=min(b,k);
 ans-=min(c,k);
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3592
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,m = readInts()
ab = [0]*(n+1)
for i in range(m):
	a,b = readInts()
	ab[a]+=1
	ab[b]+=1

for i in range(1,n+1):
	print(ab[i])

Measured memory_bytes: 3444
import java.io.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        ArrayList<Integer> V = new ArrayList<>();
        str = br.readLine();
        for (String s:str.split(" ")){
            V.add(Integer.parseInt(s));
        }
        ArrayList<Integer> C = new ArrayList<>();
        str = br.readLine();
        for (String s:str.split(" ")){
            C.add(Integer.parseInt(s));
        }
        int ans = 0;
        for (int i=0;i<N;i++){
            if (V.get(i)-C.get(i)>0){
                ans += V.get(i)-C.get(i);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main()
{
	int n, m, c, B[20], A[20],i,j;
	int t = 0,x = 0;
	cin >> n >> m >> c;
	for (i = 0; i < m; ++i) {
		cin >> B[i];
	}
	for (i = 0; i < n; ++i) {
		for (j = 0; j < m; ++j) {
			cin >> A[j];
			x += A[j] * B[j];
		}
		if (x + c > 0)++t;
		x = 0;
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
using namespace std;

#ifdef DEBUG
#define dump(s) cerr << #s << " = " << s << endl
#else
#define dump(...)
#endif

char s[200];
char *p;
int n;

bool ok(int n){
    return 0<=n && n<(1<<10);
}

int E();
int F();
int T();
int N();

int E(){
    int res = F();
    while(*p=='+' || *p=='-'){
        if(*p=='+') p++, res += F();
        else if(*p=='-') p++, res -= F();
        if(!ok(res)) throw "";
    }
    return res;
}

int F(){
    int res = T();
    while(*p=='*' || *p=='/'){
        if(!ok(res)) throw "";
        if(*p=='*') p++, res *= T();
        else if(*p=='/') p++, res /= T();
        if(!ok(res)) throw "";
    }
    return res;
}

int T(){
    int res;
    if(*p=='(') p++, res = E(), p++;
    else res = N();
    if(!ok(res)) throw "";
    return res;
}

int N(){
    int res = 0;
    if(!isdigit(*p)) throw "";
    while(isdigit(*p)){
        res = res*2 + *p - '0';
        p++;
    }
    if(!ok(res)) throw "";
    return res;
}

bool chk(){
    for(int i=0;i<n;i++){
        if(s[i]!='(') continue;
        int j = i;
        int d = 0;
        int cnt = 0;
        while(s[j]){
            if(s[j]=='(') d++;
            else if(s[j]==')') d--;
            if(d==1) if(s[j]=='+' || s[j]=='-' || s[j]=='*' || s[j]=='/') cnt++;
            if(d==0) break;
            j++;
        }
        dump(cnt);
        dump(d);
        if(d!=0 || cnt==0) return false;
    }
    return true;
}

int main(){
    cin >> s;
    n = strlen(s);
    int x[6], k = 0;
    char cand[] = "01+-*())";
    for(int i=0;i<n;i++){
        if(s[i]=='.') x[k++] = i;
    }
    int ans = -1;
    for(int mask=0;mask<1<<(3*k);mask++){
        p = s;
        int t = mask;
        for(int i=0;i<k;i++) s[x[i]] = cand[t>>(3*i)&7];
        dump(s);
        if(!chk()) continue;
        try {
            int t = E();
            if(p-s!=n) continue;
            dump(t);
            ans = max(ans,t);
        } catch(...){}
    }
    cout << ans << endl;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  bool ok = true;
  string s;
  cin >> s;
  int count = 0;
  rep(i, 2, s.size()-1) {
    int n = 0;
    n = s.at(i);
    if (s.at(i) =='C') count++;
    else if (n<97 || n>122) count += 2;
  }
  if (count != 1) ok = false;
  if (s.at(0) != 'A') ok = false;
  int m = 0;
  m = s.at(1);
  if (m<97 || m>122) ok = false;
  int l = 0;
  l = s.at(s.size()-1);
  if (l<97 || l>122) ok = false;
  if (ok) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
ll dp[500005][6],sc[500005][6];
//bool check[5005];
char s[500005],t[500005];
bool flag,dame;

ll  fact[400005];
ll rfact[400005];
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<400000; i++){
        fact[i] = (fact[i-1]*i) % mod;
        rfact[i] = rui(fact[i],mod - 2);
    }
}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;
}

int main(){
	cin >> n >> s;
	for(i=0;i<n;i++){
		if(s[i] == '#')sum++;
		x[i] = sum;
	}
	ans = n - sum;
	for(i=0;i<n;i++){
		ans = min(ans,x[i] + n-1-i - (x[n-1] - x[i]));
	}
	p(ans);
	return 0;
}


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


int main(){
  int n;
  cin >> n;
  vector<int64_t> L(87);
  
  L[0]=2;
  L[1]=1;
  
  for(int i=2; i<n+1; i++){
    L[i]=L[i-2]+L[i-1];
  }
  
  cout << L[n] << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		// TODO 自動生成されたメソッド・スタブ
		BigDecimal one = new BigDecimal("1.00");
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		double mon = 0;
		int syo=0,hisi=0;
		double aaaa = 1;
		
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			for(int i=0;i<tmp.length();i++){
				if(tmp.charAt(i) == '@'){
					for(int j=0;j<Integer.parseInt(String.valueOf(tmp.charAt(i+1)));j++){
						System.out.print(tmp.charAt(i+2));
					}
					i +=2;
					
				}else{
					System.out.print(tmp.charAt(i));
				}
			}
			System.out.println();
			
		}
	}

}

Measured memory_bytes: 16952
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


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>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    int A[H][W];
    rep(i,0,H)rep(j,0,W)cin >> A[i][j];

    vector<tuple<int,int,int,int> > ans;
    rep(i,0,H){
        rep(j,0,W-1){
            if(A[i][j] % 2){
                ans.emplace_back(i+1, j+1, i+1, j+2);
                A[i][j+1] += 1;
            }
        }
        if(i != H-1 && A[i][W-1] % 2){
            ans.emplace_back(i+1, W, i+2, W);
            A[i+1][W-1] += 1;
        }
    }
    cout << ans.size() << endl;
    for(auto tp:ans){
        cout << get<0>(tp) << " " << get<1>(tp) << " " << get<2>(tp) << " " << get<3>(tp) << endl;
    }
}

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

typedef complex<int> P;

P rotate(P p) {
  return P(-p.imag(), p.real());
}

vector<P> rotate(vector<P> ps) {
  for(int i = 0; i < ps.size(); ++i) {
    ps[i] = rotate(ps[i]);
  }
  return ps;
}

vector<P> normalize(vector<P> ps) {
  int minX = ps[0].real(), minY = ps[0].imag();
  for(int i = 0; i < ps.size(); ++i) {
    minX = min(minX, ps[i].real());
    minY = min(minY, ps[i].imag());
  }
  P base(minX, minY);
  for(int i = 0; i < ps.size(); ++i) {
    ps[i] -= base;
  }
  return ps;
}

bool same(vector<P> a, vector<P> b) {
  if(a.size() != b.size()) return false;
  a = normalize(a);
  for(int r = 0; r < 2; ++r) {
    for(int k = 0; k < 4; ++k) {
      b = normalize(rotate(b));
      if(a == b) return true;
    }
    reverse(b.begin(), b.end());
  }
  return false;
}

int main() {
  for(int n; cin >> n && n; ) {
    vector<vector<P> > g(n+1);
    for(int i = 0; i <= n; ++i) {
      int m; cin >> m;
      while(m--) {
        P p; cin >> p.real() >> p.imag();
        g[i].push_back(p);
      }
    }
    for(int i = 1; i <= n; ++i) {
      if(same(g[0], g[i])) cout << i << endl;
    }
    cout << "+++++" << endl;
  }
  return 0;
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    Int res = 1;
    Int sub = 1;
    Int add = 1;
    for (Int i = 0; i < n; i++) {
        res *= 10;
        res %= mod;
        sub *= 9;
        sub %= mod;
        add *= 8;
        add %= mod;
    }
    res = (res - sub + mod) % mod;
    res = (res - sub + mod) % mod;
    res = (res + add) % mod;
    print(res);
}

int main() {
    solve();
    return 0;
}


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

#define int long long

#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;


struct mint {
	ll x; // typedef long long ll;
	mint(ll 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 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;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<ll>a(n); rep(i, n)cin >> a[i];
	mint  sum = 0;
	rep(i, n)sum += a[i];
	mint ans = 0;
	rep(i, n - 1) {
		sum -= a[i];
		mint tmp = sum; tmp *= a[i]; 
		ans += tmp; 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
n,k = map(int, input().split( ))
mod = 10**9+7
res1 = 1
res2 = 1
res3 = 1
res4 = 1
red = n-k
blue = k
for i in range(1,k+1):
    res1*=red - i + 2
    res1%=mod
    rev_i = pow(i,mod-2,mod)
    res2 *= rev_i
    res2%=mod
    if i >=2:
        res3*=blue-(i-1)
        res3%=mod
        rev2_i = pow(i-1,mod-2,mod)
        res4 *= rev2_i
        res4%=mod
    #print(res1,res2,res3,res4)
    print(res1*res2*res3*res4%mod)
#print(chs(n+1,i,mod)*chs(k-1,i-1,mod)%mod)

Measured memory_bytes: 3316
#前計算をしておく
$hw_dict = []
def init_dict()
	for w in (1..151)
		for h in (1...w)
			elm = [h*h+w*w,h,w]
			$hw_dict.push(elm)
		end
	end
	$hw_dict = $hw_dict.sort()
end

def pred_pair(p1,p2)
	if p1[0] < p2[0]
		1
	elsif p1[0] > p2[0]
		-1
	else
		if p1[1] < p2[1]
			1
		elsif p1[1] > p2[1]
			-1
		else
			0
		end
	end
end


def solve(h,w)
	l = 0
	r = $hw_dict.length() - 1
	p = [h*h+w*w,h,w]
	ansp = 0
	found = 0
	while r - l > 1
		m = (l + r) / 2
		if pred_pair(p,$hw_dict[m]) > 0
			r = m
		elsif pred_pair(p,$hw_dict[m]) < 0
			l = m
		else
			ansp = m + 1
			found = 1
			break
		end
	end
	if found == 0
		ansp = r
	end
	[$hw_dict[ansp][1],$hw_dict[ansp][2]]
end

init_dict()

while nums = STDIN.gets().chomp().split(" ")
	if nums[0].to_i() == 0 && nums[1].to_i() == 0
		exit
	else
		ans = solve(nums[0].to_i(),nums[1].to_i())
		puts "#{ans[0]} #{ans[1]}"
	end
end

Measured memory_bytes: 6420
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	String[] data = str.split(" ");
	int a = Integer.parseInt(data[0]);
	int b = Integer.parseInt(data[1]);
	int c = Integer.parseInt(data[2]);

	
	if(a < b && b < c) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
    }
 
}


Measured memory_bytes: 26244
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

typedef pair<int, int> iPair;

vector<vector<pair<int, int> > > graph;
vector<int> dist;

void add_edge(int u, int v, int wt) {
	graph[u].push_back(make_pair(v, wt));
}

int shorted_path_to_one(int V, int src) {
	priority_queue<iPair, vector<iPair>, greater<iPair> > pq;
	dist = vector<int> (V, INT_MAX);

	pq.push(make_pair(0, src));
	dist[src] = 0;

	while (!pq.empty()) {
		int u = pq.top().second;
		pq.pop();

		for (auto x : graph[u]) {
			int v = x.first;
			int weight = x.second;

			if (dist[v] > dist[u] + weight) {
				dist[v] = dist[u] + weight;
				pq.push(make_pair(dist[v], v));
			}
		}
	}

	return dist[1];
}

int main() {

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

	int h, w;
	cin >> h >> w;

	graph = vector<vector<pair<int, int> > > (10, vector<pair<int, int> > ());
	int c;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> c;
			add_edge(i, j, c);
		}
	}

	vector<int> shortest_to_one(10);
	for (int i = 0; i < 10; ++i) {
		shortest_to_one[i] = shorted_path_to_one(10, i);
	}
	
	int min_mp = 0;
	int digit;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> digit;
			if (digit != -1) {
				min_mp += shortest_to_one[digit];
			}
		}
	}

	cout << min_mp << "\n";

	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n; cin>>n;
    vector <int> L(n);
    rep(i,n) cin>>L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<i;k++){
                if(abs(L[i]-L[j])<L[k]&&L[i] + L[j]> L[k]) ans++;
            }
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main() {
  long long t[5];
  long long n;
  cin >> n;
  for (int i = 0; i < 5; i++) {
    cin >> t[i];
  }
  long long p = 1111111111111111;
  int p_i = 0;
  for (int i = 4; i >= 0; i--) {
    if (p >= t[i]) {
      p = t[i];
      p_i = i;
    }
  }
  cout << ((long long)((n + (p - 1)) / p) + p_i + (4 - p_i)) << endl;
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50==X:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
N,M = map(int,input().split())
sum = 0
array = []
for i in range(N):
    array.append(0)
for i in range(M):
    array.append(1)
for i in range(N+M-1):
    for j in range(i+1,N+M):
        if((array[i]+array[j])%2 == 0):
            sum += 1

print(sum)


Measured memory_bytes: 3060
from collections import deque

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

q = deque()
q.append(a[0])
ans = 0
for i in range(1, n):
    b = q.popleft()
    ans += b
    b = min(b, a[i])
    for _ in range(2):
        q.append(b)
print(ans)

Measured memory_bytes: 33124
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace P0017_CaesarCipher
{
    class Program
    {
        private static Encoding sjisEnc = Encoding.GetEncoding("Shift_JIS");

        static void Main(string[] args)
        {

            List<string> lines = new List<string>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(readLine);
                }
            }
            while (readLine != null);

            foreach (string line in lines)
            {

                int shift = 0;

                bool find = false;

                foreach (string word in line.Split(' '))
                {
                    if (word.Length == 3)
                    {
                        for (int i = 0; i < 26; i++)
                        {
                            if (DecryptionCaesar(word, i) == "the")
                            {
                                shift = i;
                                find = true;
                                break;
                            }
                        }
                    }
                    else if (word.Length == 4)
                    {
                        for (int i = 0; i < 26; i++)
                        {
                            if (DecryptionCaesar(word, i) == "that" || DecryptionCaesar(word, i) == "this")
                            {
                                shift = i;
                                find = true;
                                break;
                            }
                        }
                    }

                    if (find)
                    {
                        break;
                    }

                }

                Console.WriteLine(DecryptionCaesar(line, shift));
            
            }
   
        }

        private static string DecryptionCaesar(string cipherText, int shift)
        {
            byte[] bytes = sjisEnc.GetBytes(cipherText);

            for (int i = 0; i < bytes.Count(); i++)
            {
                if (bytes[i] >= 0x61 && bytes[i] <= 0x7A)
                {
                    bytes[i] = byte.Parse(((bytes[i] - 0x61 + shift) % 26 + 0x61).ToString());
                }
            }

            return sjisEnc.GetString(bytes);

        }

    }
}

Measured memory_bytes: 7456
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int main(){
    int n, x;
    cin >> n >> x;
    vi l(n);
    for(auto&& a:l)cin >> a;
    for(int i=0;i<n-1;i++)l[i+1] += l[i];
    cout << distance(l.begin(), upper_bound(l.begin(), l.end(), x)) + 1 << endl;
    return 0;
}


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

ll gcd(ll c, ll d){
    ll r = c % d;
    while(r != 0){
        c = d;
        d = r;
        r = c % d;
    }
    return d;
}
ll lcm(ll a, ll b){
    return a / gcd(a,b) *b; 
}
ll f(ll x, int c, int d){
    ll res = x;
    res -= x/c;
    res -= x/d; 
    res += x/lcm(c,d);
    return res;
}

int main()
{
    ll a,b;
    int c,d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
min = 0
max = N

for _ in range(M):
    L_i,R_i = map(int,input().split())
    if L_i > min:
        min = L_i
    if R_i < max:
        max = R_i

if min > max:
    print(0)
else:
    print(max - min + 1)



Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra


def resolve():
    N, X, Y = map(int, input().split())
    graph = np.zeros((N + 1, N + 1), dtype=np.int64)

    for i in range(1, N):
        graph[i, i + 1] += 1
        graph[i + 1, i] += 1
    graph[X, Y] = 1
    graph[Y, X] = 1

    dist = dijkstra(csgraph=csr_matrix(graph)).astype(np.int64)
    ans = np.bincount(dist[1:, 1:].ravel(), minlength=N) // 2
    return print(*ans[1:], sep='\n')


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 107300
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main(){
	//fastio
	int n;
	cin>>n;	
	vector<int> h(n);		//heights vector
	for(int& x : h) {
		scanf("%d",&x);
    // cin>>x;
	}
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0;i < n ; ++i) 
	{
        int j1 = i+1;
        int j2 = i+2;
		if(j1 < n)
		    dp[j1] = min(dp[j1] , dp[i] + abs(h[i] - h[j1]));  
		if(j2 < n)
		    dp[j2] = min(dp[j2] , dp[i] + abs(h[i] - h[j2]));
	}
// 	for(auto i : dp)
// 	cout<<i<<" ";
// 	cout<<endl;
	cout<<dp[n-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<pair<int, int>>>;
vector<int> color;
/////black: 1, white: 0, undecided: -1

void dfs(const Graph &G, int u,int before_u, int this_color){
    color[u] = this_color;
    for (auto next: G[u]){
        int w = next.second;
        int next_u = next.first;
        if (next_u == before_u) continue;
        if (w & 1) dfs(G, next_u, u, 1 - this_color);
        else dfs(G, next_u, u, this_color);
        // color[next_u] = this_color;
        // dfs(G, next_u, u, this_color);
    }
}

int main() {
    int N;
    cin >> N;
    Graph G;
    G.assign(N, vector<pair<int, int>>());
    for (int i = 1; i < N; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    color.assign(N, 0);
    dfs(G, 0, -1, 1);
    for (auto c: color) cout << c << endl;
    return 0;
}

Measured memory_bytes: 11548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
long long inf = pow(10, 9);

int n, k, r, s, p;
string t;
int dp[100000 + 1], res = 0;
int main(){
    cin >> n >> k >> r >> s >> p >> t;
    map<char, int> score;
    score['r'] = p;
    score['s'] = r;
    score['p'] = s;
    rep(i, n){
        if(i < k){
            dp[i] = 1;
            res += score[t[i]];
        }
        else if(t[i - k] == t[i]){
            if(dp[i - k] == 0){
                dp[i] = 1;
                res += score[t[i]];
            }
        }
        else{
            dp[i] = 1;
            res += score[t[i]];
        }
    }
    cout << res << endl;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		int x = (n + 1) / 4;
		int y = (n - 1) / 4;
		vector<pair<int, int>> f;
		for (int i = 0; i < x; i++) f.push_back(make_pair(i + 1, 2 * x - i));
		for (int i = 0; i < y; i++) f.push_back(make_pair(n - 2 * y + i, n - i));
		for (int i = 0; i < m; i++) cout << f[i].first << " " << f[i].second << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4200