akhauriyash/Code-Regression huggingface dataset:
import sys

def insert(S, k):
    S.append(k)
    idx = len(S) - 1
    while True:
        p = (idx + 1) / 2 - 1
        if p < 0 or S[idx] <= S[p]:
            break
        else:
            S[idx], S[p] = S[p], S[idx]
            idx = p

def maxHeapify(A, i, size):
    l = 2 * i + 1
    r = 2 * i + 2

    if l < size and A[l] > A[i]:
        largest = l
    else:
        largest = i

    if r < size and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest, size)

def extract(S):
    print S[0]
    S[0] = S[-1]
    S.pop()
    maxHeapify(S, 0, len(S))

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    lines.pop()

    S = []
    for line in lines:
        if line[0] == "i":
            insert(S, int(line[7:]))
        else:
            extract(S)

Measured memory_bytes: 158956
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,weg;
	cin>>n>>weg;
	vector < pii > v;
	ll s=0;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		s+=b;
		v.pb({b,a});
	}
	ll dp[s+1];
	for(ll i=0;i<=s;i++) dp[i] = 1000000000000000;
	dp[0]=0;
	for(ll i=0;i<n;i++){
		for(ll j=s;j>=v[i].first;j--){
			dp[j] = min(dp[j] , v[i].second+dp[j-v[i].first]);
		}
	}
	for(ll i=s;i>=0;i--){
		if(dp[i]<=weg) {
			cout<<i;
			break;
		}
	}
	return 0;
}


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

int main()
{
	while(1)
	{
		int h=20,y=4,m,d,W,ans;
		char *youbi[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		cin>>m>>d;
		if(m==0)break;
		if(m<3)
		{
			y--;
			m+=12;
		}
		W=(y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
		cout<<youbi[W]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
N, Q = (int(x) for x in input().split())
a, b = [0]*(N-1), [0]*(N-1)
p, x = [0]*Q, [0]*Q
back_edge = [None]*N
counter = [0]*N
for i in range(N-1):
    a[i], b[i] = (int(x)-1 for x in input().split())
    back_edge[b[i]] = a[i]
for j in range(Q):
    p[j], x[j] = (int(x) for x in input().split())
    counter[p[j]-1] += x[j]
for i in range(N):
    if back_edge[i] is not None:
        counter[i] += counter[back_edge[i]]
else:
    print(*counter)


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

int main() {
  int A, B, C ;
  cin >> A >> B;
  C = (A*B)%2;
  if (C==0) {
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl; 
  }
  // ここにプログラムを追記
}


Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
  a, b = map(str,input().split())
  d = int(b)
  l.append([a, d, i+1])

l.sort(key=lambda x:(x[0], x[1]))
l.reverse()
l.sort(key=lambda x:(x[0]))


c = [x[2] for x in l]
for i in range(n):
  print(c[i])

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

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    //cout<< static_cast<double>(a) / (double)(1.0 * b) <<'\n';
    printf("%f\n", (float) a/b );
    //printf("%lf\n", (double) a/b );
    //cout<< (double)a / (double)b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans, a[1001];

int cnt[1001];

int main() {
	//freopen("x.in", "r", stdin);

	cin >> n;
	F0(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(a, a + n);

	int good = 1;

	int L = a[n - 1], mm = n + 1;

	for (int i = 0; i <= L; i++) {
		int X = max(i, L - i);
		if (!cnt[X]) good = 0;
		cnt[X]--;
		mm = min(mm, X);
	}
	F1(i, n) if (cnt[i] && i <= mm) good = 0;

	if (good) cout << "Possible"; else cout << "Impossible";


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){

	
	 double n;
	cin>>n;
	
	cout<<fixed<< setprecision(11);
	if( ( ll )n%2==1 ){
		
		cout<<  (( n+1)/2 /n)<<endl;
		
	}
	else{
		
		cout << (n/2)/n <<endl;
		
	}
		
	
	
return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3804
package main
 
import (
  "fmt"
)
 
func main(){
  var a,b,c int
  fmt.Scanf("%d", &a)
  fmt.Scanf("%d", &b)
  c = a%b
  if c==0 {
    fmt.Printf("%d", a/b)
  } else {
    fmt.Printf("%d", a/b+1)
  }
}

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

// Aliases
#define enable_fast_io()  	ios_base::sync_with_stdio(false); 	\
			  				cin.tie(nullptr); 					\
							cout.tie(nullptr)  

#define N 300010LL
#define round(n) int64_t(n+0.5)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pi;

int main(){
	enable_fast_io();

	string s, t;
	cin >> s >> t;

	int ans = 0;
	for(int i=0; i<s.size();++i) if(s[i] ^ t[i]) ++ans;

	cout << ans << "\n"; 
	
	return 0;
}

Measured memory_bytes: 3828
N, K = map(int, input().split())
X = list(map(int, input().split()))
town = []
dic = {}
i = 0
j = 0
while i not in dic and j < K:
    dic[i] = j
    town.append(i)
    i = X[i] - 1
    j += 1

if j == K:
    print(i + 1)

else:
    num = dic[i]
    loop = j - num
    print(town[((K - num) % loop) + num] + 1)


Measured memory_bytes: 33096
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int sum = 0;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		sum += a[i];
	}
	sum = sum/(4*k) + !(sum%(4*k)==0);
	bool is_pos = true;
	sort(a, a+n, greater<int>());
	for(int i=0; i<k; i++)
	{
		if(a[i] < sum)
		{
			is_pos  = false;
			break;
		}
	}
	if(is_pos)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
};


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

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

    string s[N];
    FOR(i,0,N) cin >> s[i];

    sort(s,s+N);

    string ans;
    FOR(i,0,N) ans += s[i];

    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n, m, q;
char c[2005][2005];
int vertices[2005][2005];
int horizontal[2005][2005];
int vertical[2005][2005];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> q;
    for (int i = 1; i <= n; ++i) cin >> (c[i] + 1);
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
        vertices[i][j] = vertices[i-1][j] + vertices[i][j-1] - vertices[i-1][j-1] + (c[i][j] == '1');
        vertical[i][j] = vertical[i-1][j] + vertical[i][j-1] - vertical[i-1][j-1] + (c[i][j] == '1' && c[i-1][j] == '1');
        horizontal[i][j] = horizontal[i-1][j] + horizontal[i][j-1] - horizontal[i-1][j-1] + (c[i][j] == '1' && c[i][j-1] == '1');
    }
    for (int i = 0; i < q; ++i) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        int V = vertices[u][v] - vertices[x-1][v] - vertices[u][y-1] + vertices[x-1][y-1];
        int E = vertical[u][v] - vertical[x][v] - vertical[u][y-1] + vertical[x][y-1] +
                horizontal[u][v] - horizontal[x-1][v] - horizontal[u][y] + horizontal[x-1][y];
        cout << V - E << '\n';
    }
}


Measured memory_bytes: 52864
# 安いお店から買えるだけ買う
n,m = list(map(int, input().split()))
ab = sorted([tuple(map(int, input().split())) for _ in range(n)])

ans = 0
for a,b in ab:
    c = min(m,b)
    ans+=a*c
    m-=c
    if m==0:
        break

print(ans)

Measured memory_bytes: 23540
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    int k = 0;
    cin >> k;
    vector<string> candi;
    for (int i=0; i<s.size(); i++) {
        string buf = "";
        for (int j=i; j<min(i+5, (int)s.size()); j++) {
            buf += s.at(j);
            candi.push_back(buf);
        }
    }
    sort(candi.begin(), candi.end());
    unique(candi.begin(), candi.end());
    cout << candi.at(k-1) << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <queue>

using std::queue;

const int MAXHW=105;
int n,h,w,a;
int sqr[MAXHW][MAXHW];

queue<int> q,ans;

int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		q.push(a);
	}
	int k=0;
	while(++k,q.size()){
		a=q.front();
		q.pop();
		for(int i=1;i<=a;++i)
			ans.push(k);
	}
	for(int i=1;i<=h;i+=2){
		for(int j=1;j<=w;++j){
			sqr[i][j]=ans.front();
			ans.pop();
		}
		for(int j=w;j && ans.size();--j){
			sqr[i+1][j]=ans.front();
			ans.pop();
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j)
			printf("%d ",sqr[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> c, p = {};
  for(int i = 2; i < 55555; i++){
    c.push_back(i);
  }
  while(true){
    vector<int> v = {};
    p.push_back(c.front());
    for(int i = 1; i < c.size(); i++){
      if(c[i] % c[0] != 0)v.push_back(c[i]);
    }
    c = v;
    if(c.front() > 235){
      for(int i = 0; i < v.size(); i++){
        p.push_back(v[i]);
      }
      break;
    }
  }
  vector<int> pp;
  for(int i = 0; i < p.size(); i++){
    if(p[i] % 5 == 4)
    pp.push_back(p[i]);
  }
  int n;
  cin >> n;
  for(int i = 0; i < n - 1; i++){
    cout << pp[i] << ' ';
  }
  cout << pp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <string>

std::string shufle(std::string str, int n) {
    std::string temp;
    temp = str.substr(0, n);
    str = str.substr(n, str.size() - n) + temp;
    return str;
}

int main() {
    while (true) {
        std::string str;
        std::cin >> str;
        if(str=="-")
            break;
        int m;
        std::cin >> m;
        for (int i = 0; i < m; i++) {
            int n = 0;
            std::cin >> n;
            str = shufle(str, n);
        }
        std::cout << str << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int maxn = 1e5;
#define m(a,b) memset(a,b,sizeof(a));
vector<PII>edg[maxn+5];
vector<int>ans[maxn+5];
int mp[2*maxn+5];
int main(){
	int n;
	cin >> n;
	int ans = n/3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#!/usr/bin/env python3
#ABC116 B

s = int(input())

a = [s]

while 1:
    if a[-1] % 2 == 0:
        if a[-1]//2 in a:
            ans = len(a)+1
            break
        a.append(a[-1]//2)
    elif a[-1] % 2 == 1:
        if 3*a[-1] + 1 in a:
            ans = len(a)+1
            break
        a.append(3*a[-1]+1)
print(ans)


Measured memory_bytes: 38384
#include<stdio.h>
int main() {
	int i,j,k,sum;
	scanf("%d %d", &i,&j);
	sum = i % j;
	if (sum == j) {
		printf("%d\n", i / j);
	}
	else if (sum < j) {
		printf("%d\n",sum+i/j);
	}
	return 0;
}


Measured memory_bytes: 2732
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y = map(int,input().split())
ans = 'No'
if x in a and y in a or x in b and y in b or x in c and y in c:
    ans = 'Yes'
print(ans)

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

int main()
{
  char s[4];
  int a = 0;
  cin >> s;
  for( int i = 1; i < 4; i++ )
  {
    if( s[i] == s[i-1] ){
      a = 1;
    }
  }
  if( a == 1 )
  {
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [N, M] = input[0].split(' ').map(x => parseInt(x))
  const counts = Array(M).fill(0)

  for (let i = 0; i < N; i++) {
    const likes = input[i + 1].split(' ').map(x => parseInt(x))
    for (let i = 0; i < likes[0]; i++) {
      counts[likes[i + 1] - 1]++
    }
  }

  let ans = 0
  for (let i = 0; i < M; i++) {
    if (counts[i] === N) {
      ans++
    }
  }
  console.log(ans)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30600
import java.util.Scanner;

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

		for (int i = 0; i < K; i++) {
			int d = scan.nextInt();
			for (int y = 0; y < d; y++) {
				int A = scan.nextInt();
				s[A - 1]++;
			}
		}

		int answer = 0;
		for (int i = 0; i < N; i++) {
			if (s[i] == 0) {
				answer += 1;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 46208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int n;
    cin >> n;
    long ans = long(pow(3, n));
    long minus = 1;
    REP(i,n) {
        long a;
        cin >> a;
        if (a % 2 == 0) {
            minus *= 2;
        }
    }
    cout << ans - minus << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	long fib[45] = {0, 1};
	int n, i;

	scanf("%d", &n);
	for (i = 2; i <= n + 1; i++){
		fib[i] = fib[i - 1] + fib[i - 2];
	}
	printf("%ld\n", fib[n + 1]);

	return (0);
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<set>
#include<map>

// zarray
template<typename S>
void zarray(S s, std::vector<int>& Z) {
  int N = s.size(), L, R = 0;
  Z.resize(N);
  for(int i = 1; i < N; ++i) {
    if(i > R) {
      L = R = i;
      while(R < N && s[R-L]==s[R]) ++R;
      Z[i] = R-- -L;
    } else if(Z[i-L] < R-i+1) {
      Z[i] = Z[i-L];
    } else {
      L = i;
      while(R < N && s[R-L] == s[R]) ++R;
      Z[i] = R-- -L;
    }
  }
}

int main() {
  int N; std::cin >> N;
  std::vector<int> a(N), b(N), c(N*3-2);
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  for(int i = 0; i < N; ++i) std::cin >> b[i];
  for(int i = 0; i < N-1; ++i) c[i] = a[i]^a[i+1];
  c[N-1] = -1;
  for(int i = 0; i < N+N-2; ++i) c[N+i] = b[i%N]^b[(i+1)%N];

  std::vector<int> Z;
  zarray(c, Z);
  std::set<std::pair<int,int>> ans;
  for(int i = 0; i < N; ++i) if(Z[N+i]>=N-1) {
    ans.insert(std::make_pair((N-i)%N, a[0]^b[i]));
  }
  for(auto p: ans) std::cout << p.first << " " << p.second << "\n";
  return 0;
}


Measured memory_bytes: 19032
#include<bits/stdc++.h>
using namespace std;
int y,m,d;
int main()
{
	scanf("%d/%d/%d",&y,&m,&d);
	if(y>2019||(y==2019&&m>4)||(y==2019&&m==4&&d>30))
		cout<<"TBD"<<endl;
	else
		cout<<"Heisei"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int mount[10]={}, i, max1=0, max2=0, max3=0;
     
    for(i=0; i<10; i++){
        cin >> mount[i];
        if(max3 < mount[i]){
            if(max2 < mount[i]){
                if(max1 < mount[i]){
                    max3 = max2;
                    max2 = max1;
                    max1 = mount[i];
                }
                else{
                    max3 = max2;
                    max2 = mount[i];
                }
            }
            else{
                max3 = mount[i];
            }
        }
    }
     
    cout << max1 << endl;
    cout << max2 << endl;
    cout << max3 << endl;
    return 0;
}

/*
　max1…１番高い山、max2…２番目に高い山、max3…３番目に高い山　とします。
　max1より高い山が現れたら、max1に設定し、max2、max3は順送りします。
　max1より低く、max2より高い山が現れたら、max2に設定し、max3は順送りします。
　max2より低く、max3より高い山が現れたら、max3に設定します。
*/


Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
	int  i,j,h,w;
	while(1) {
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
			for(i=1;i<=h;i++){
				for(j=1;j<=w;j++){
					if(i%2==0){
						if(j%2==0){
							printf("#");
						}
						else{
							printf(".");
						}
					}
					else{
						if(j%2==0){
							printf(".");
						}
						else{
							printf("#");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
	
	}
	return 0;
}
						


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

int main()
{
    int n , m, ans = 0;
    cin >> n >> m;
    long long int x[m];
    for (int i = 0; i < m; i++)
        cin >> x[i];
    sort(x, x+m);
    long long int y[m-1];
    if (m == 1 || n >= m)
    {    
        cout << 0 << endl;
        return (0);
    }
    for (int i=0; i < m-1; i++)
        y[i]=x[i+1] - x[i];
    sort(y, y+m-1);
    for (int i = 0; i < m - n; i++)
        ans+=y[i];
    cout << ans << endl;
}

Measured memory_bytes: 5008
import java.util.*;
import java.awt.*;
import java.math.BigInteger;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int n=s.length();
        if(s.length()<4){
            out.println("No");
        }else{
            s=s.substring(0,4);
            if(s.equals("YAKI")){
                out.println("Yes");
            }else{
                out.println("No");
            }
        }
    }
}

Measured memory_bytes: 23380
#include <stdio.h>

int main(void) {
	int num,i,j;
		
	while(1){
		int guest[10000]={0};
		
		scanf("%d", &num);
		if(num==0) break;
		
		for(i=0; i<num; i++) 
			scanf("%d", &guest[i]);
	
		for(i=0; i<num; i++) {
			for(j=i; j<num; j++) {
				if(guest[i] > guest[j]) {
					int tmp = guest[i];
					guest[i] = guest[j];
					guest[j] = tmp;
				}
			}
		}
	
		long sum=0, total=0;
		for(i=1; i<num; i++) {
			sum += guest[i-1];
			total += sum;
		}
	
		printf("%ld\n", total);
	
	}
	
	return 0;
}

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

int main() {
	cout << fixed << setprecision( 10 );

	int n;
	cin >> n;

	vector<int> x( n );
	vector<int> y( n );
	for( auto& v: x ) { cin >> v; }
	for( auto& v: y ) { cin >> v; }

	double D = 0;

	for( int i = 0; i < n; ++i ) {
		D += abs( x.at( i ) - y.at( i ) );
	}
	cout << D << endl;

	D = 0;
	for( int i = 0; i < n; ++i ) {
		D += pow( x.at( i ) - y.at( i ), 2 );
	}
	cout << sqrt( D ) << endl;

	D = 0;
	for( int i = 0; i < n; ++i ) {
		D += pow( abs( x.at( i ) - y.at( i ) ), 3 );
	}
	cout << pow( D, 1.0 / 3 ) << endl;

	D = 0;
	for( int i = 0; i < n; ++i ) {
		D = max<double>( D, abs( x.at( i ) - y.at( i ) ) );
	}
	cout << D << endl;
}



Measured memory_bytes: 3416
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int maxn = 1e5+500;
ll T,n,m;
int num[maxn];
int a[maxn];
int main() {
   int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>num[i];
	int now = 1;
	a[0] = 0;
	for(int i=1;i<n;i++){
		if(num[i]<=num[i-1])
			a[i] = a[i-1]+1;
		else 
			a[i] = 0;
	}
	int maxx=  0;
	for(int i=0;i<n;i++)
		maxx = max(a[i],maxx);
	cout<<maxx<<endl;
}



Measured memory_bytes: 1024
n,m = map(int,input().split())
raw = []
for _ in range(n):
  raw.append(list(map(int,input().split())))
time = [0,0,0]
def nex(t):
  for d in range(3):
    if t[d] == 0:
      t[d] = 1
      return t
    else:
      t[d] = 0
  else:
    return 'over'
can = []
while time != 'over':
  now = []
  for i in range(n):
    tmp = 0
    for d in range(3):
      if time[d] == 0:
        tmp += raw[i][d]
      else:
        tmp -= raw[i][d]
    now.append(tmp)
  now.sort(reverse=True)
  can.append(sum(now[:m]))
  time = nex(time)
print(max(can))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int count = 0, max = 0;
	REP(i, n) {
		if (s[i] == 'I') {
			count++;
		}
		else {
			count--;
		}
		if (count > max) {
			max = count;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

struct Op {
  int y1, x1, y2, x2;
};

int main() {
  int H, W;
  while (cin >> H >> W) {
    vec<int, 2> a = make_v(H, W, 0);
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> a[i][j];
      }
    }
    vector<Op> operations;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (a[i][j] % 2 == 0) continue;
        if (j + 1 < W) {
          a[i][j] -= 1;
          a[i][j + 1] += 1;
          operations.push_back({i, j, i, j + 1});
          continue;
        }
        if (i + 1 < H) {
          a[i][j] -= 1;
          a[i + 1][j] += 1;
          operations.push_back({i, j, i + 1, j});
        }
      }
    }
    cout << operations.size() << endl;
    for (auto op : operations) {
      cout << op.y1 + 1 << " " << op.x1 + 1 << " " << op.y2 + 1 << " "
           << op.x2 + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5232
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll a[101010];
ll solve()
{
    ll n;
    cin >> n;
    map<ll, ll> m;
    for(int i=0; i < n; i++){
        cin >> a[i];
        m[i + 1] = a[i];
    }
    ll ans = 0;
    for(int i=0; i < n; i++){
        ans += a[i] / 2;
        a[i] %= 2;
        if(a[i] == 1 && a[i+1]>=1){
            a[i] = 0;
            a[i + 1]--;
            ans++;
        }

    }
    cout << ans << endl;

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    ll ans=0;
    ll r=-1;
    int a;
    int b;
    REP(l,n){
        if(r<l){
            r=l;
            a=vec[l];
            b=vec[l];
        }
        while(r+1<n){
            int p=a|vec[r+1];
            int q=b^vec[r+1];
            if(p!=q){
                break;
            }else{
                a=p;
                b=q;
                r++;
            }
        }
        ans+=r-l+1;
        a^=vec[l];
        b^=vec[l];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      m: usize,
      abs: [(usize,usize); m],
    }
    let mut ans = vec![0; n+1];
    for (a, b) in abs {
        ans[a] += 1;
        ans[b] += 1;
    }
    for a in ans {
        if a % 2 == 1 {
            return println!("{}", "NO");
        }
    }
    println!("{}", "YES");
}


Measured memory_bytes: 6396
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; } 
//s2>s1;if(not) rtrn -1;
// Driver Program to test above function 
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;
//int N=1000001;

//SieveOfEratosthenes
	//   cin>>tt;
	      while(tt--)
{
	/*
	2 2
*.
.**/
ll n,m;
cin>>n>>m;
string s[n];
fo(i,n)
{
	cin>>s[i];
	cout<<s[i];
	ee;
	cout<<s[i];
	ee;
}
}
return 0;
}















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

int n;
vector<string> res;

void dfs(string& s, char c = 'z') {
	if (c == 'a') {
		res.push_back(s);
		return;
	}
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (s[i] == c - 1) {
			s[i] = c;
			dfs(s, c - 1);
			s[i] = c - 1;
		}
		else if (s[i] == c) {
			ok = false;
			break;
		}
	}
	if (ok) {
		dfs(s, c - 1);
	}
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	string s;
	while (cin >> s, s != "#") {
		n = s.size();
		dfs(s);
		sort(res.begin(), res.end());
		cout << res.size() << endl;
		if ((int)res.size() > 10) {
			res.erase(res.begin() + 5, res.end() - 5);
		}
		for (auto& t : res) {
			cout << t << endl;
		}
		res.clear();
	}
	return 0;
}



Measured memory_bytes: 4104
#include <bits/stdc++.h>
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    using namespace std;
    typedef long long   ll;
    typedef unsigned long long   ull;
    typedef long double ld;
    typedef pair<ll, ll>    pll;
    typedef pair<ull, ull>    pull;
    typedef pair<ll, ll>  pii;
    typedef pair<ld, ld>  pld;
    ll n, k;
    ll a[109];
    ll dp[100009];
    ll upd[100009];
    ll mod = 1e9+7;
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
     
        cin >> n >> k;
        for(int i = 0; i < n; ++i)
            cin >> a[i];
        dp[0] = 1;
        for(int i = 0; i < n; ++i){
            for(int j = k; j >= 0; --j){
                upd[j+1] += dp[j];
                upd[j+1] %= mod;
                if(j+a[i]+1 <= k){
                    upd[j+a[i]+1] -= dp[j];
                    upd[j+a[i]+1] %= mod;
                    if(upd[j+a[i]+1] < 0)
                        upd[j+a[i]+1] += mod;
                }
            }
            for(int j = 1; j <= k; ++j){
                upd[j] += upd[j-1];
                upd[j] %= mod;
                dp[j] += upd[j];
                dp[j] %= mod;
            }
            for(int j = 1; j <= k; ++j)
                upd[j] = 0;
        }
        cout << dp[k] << "\n";
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
int main(){
    long long n,k;
    cin >> n >> k;
    vector<long long>a(n);
    vector<long long>pos;//0以上の数を受け取る
    vector<long long>neg;//負の値を受け取る
    for(long long i=0;i<n;i++){
        long long x;
        cin >> x;
        a[i]=x;
        if(x>=0)pos.push_back(x);
        else neg.push_back(x);
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());//絶対値が大きい順
    reverse(pos.begin(),pos.end());//大きい順にする
    long long ans=1;
    //k=nの時
    if(k==n){
        for(long long i=0;i<n;i++){
            ans*=(a[i]+MOD);
            ans%=MOD;
        }
        cout << ans << endl;
        return 0;
    }
    //正の数がないとき
    if(pos.empty()){
        //答えが負になるとき絶対値の小さい順
        if(k%2){
            reverse(neg.begin(),neg.end());
            for(long long i=0;i<k;i++){
                ans*=(MOD+neg[i]);
                ans%=MOD;
            }
            cout << ans << endl;
            return 0;
        }
        //答えが正になるとき大きい順でとる
        else{
            for(long long i=0;i<k;i++){
                ans*=(MOD+neg[i]);
                ans%=MOD;
            }
            cout << ans << endl;
            return 0;
        }
    }

    //kが奇数の時正の数の最大値をあらかじめ取っておく
    if(k%2){
        ans*=pos[0];
        pos.erase(pos.begin());
    }

    long long p=pos.size();
    long long ne=neg.size();
    vector<long long>pos_pair(p/2);
    vector<long long>neg_pair(ne/2);
    for(long long i=0;i<p/2;i++){
        pos_pair[i]=(pos[i*2]*pos[i*2+1]);
    }
    for(long long i=0;i<ne/2;i++){
        neg_pair[i]=(neg[i*2]*neg[i*2+1]);
    }
    long long pk=0,nk=0;
    for(long long i=0;i<k/2;i++){
        if(pk==p/2){
            neg_pair[nk]%=MOD;
            ans*=neg_pair[nk];
            ans%=MOD;
            nk++;
        }
        else if(nk==ne/2){
            pos_pair[pk]%=MOD;
            ans*=pos_pair[pk];
            ans%=MOD;
            pk++;
        }
        else{
            if(pos_pair[pk]>neg_pair[nk]){
                pos_pair[pk]%=MOD;
                ans*=pos_pair[pk];
                ans%=MOD;
                pk++;
            }
            else{
                neg_pair[nk]%=MOD;
                ans*=neg_pair[nk];
                ans%=MOD;
                nk++;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
	int n , i , j , k , l;
	cin >> n;
	int a[n] , dp[n];
	fill(dp , dp+n , INT_MAX);
	for(i=0;i<n;++i) cin >> a[i];
	dp[0] = 0;dp[1] = abs(a[1] - a[0]);
	for(i=2;i<n;++i) {
	    dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]) , dp[i-1] + abs(a[i] - a[i-1]));
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
  ll n, k;
  cin >> n >> k;
  vll a(n+1);
  REP(i,1,n){
    cin >> a[i];
  }
  REP(i,1,k){
    bool flag = 1;
    REP(i,1,n){
      if(a[i] < n){
        flag = 0;
      }
    }
    if(flag){
      break;
    }
    vll b(n+1);
    ll light = 0;
    vll c(n+1, 0);
    REP(i,1,n){
      ll l = i - a[i];
      ll r = i + a[i];
      if(l <= 0){
        light++;
      }else{
        c[l]++;
      }
      if(r + 1 <= n){
        c[r+1]--;
      }
    }
    REP(i,1,n){
      light += c[i];
      a[i] = light;
    }

  }
  REP(i,1,n){
    cout << a[i];
    if(i < n){
      cout << " ";
    }
  }
  cout << endl;

}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, h;
    int a[100000], b[100000];
    cin >> n >> h;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    vector<pair<int, int>> v, v2;
    for (int i = 0; i < n; i++)
    {
        v.push_back(make_pair(a[i], b[i]));
        v2.push_back(make_pair(b[i], a[i]));
    }
    sort(all(v));
    sort(all(v2));

    // for (int i = 0; i < n; i++)
    // cout << v2[i].first << "," << v2[i].second << endl;
    int fmx = v[n - 1].first;
    int smx = v[n - 1].second;
    bool use = false;
    int sum = 0;
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (v2[i].first >= fmx && sum < h)
        {
            sum += v2[i].first;
            cnt++;
            // cout << "*";
        }
        // cout << v2[i].first << endl;
    }

    // cout << "cnt=" << cnt << "," << sum << endl;

    if (h - sum > 0)
    {
        int sub = h - sum;
        // cout << sub << "," << smx << "," << fmx << "," << max(0LL, (sub - smx + fmx - 1) / fmx) << endl;
        // cout << ((h - sum) + fmx - 1) / fmx << endl;
        cnt += (((h - sum) + fmx - 1) / fmx);
        // cnt++;
    }

    cout << cnt << endl;
}

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

#define ll long long
#define mod 1000000007

ll dp[1005][1005], n, m;
char grid[1005][1005];


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	cin >> n >> m;

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

	dp[0][0] = 1;;
	for (int i = 1; i < n; i++) {
		dp[i][0] = 0;
		if (grid[i - 1][0] != '#') {
			dp[i][0] = dp[i - 1][0];
		}
	}
	for (int i = 1; i < m; i++) {
		dp[0][i] = 0;
		if (grid[0][i - 1] != '#') {
			dp[0][i] = dp[0][i - 1];
		}
	}

	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			dp[i][j] = 0;
			if (grid[i][j - 1] != '#') {
				dp[i][j] += dp[i][j - 1];
			}
			if (grid[i - 1][j] != '#') {
				dp[i][j] += dp[i - 1][j];
			}

			dp[i][j] %= mod;
		}
	}

	cout << dp[n - 1][m - 1];
	return 0;
}

Measured memory_bytes: 9088
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let v: Vec<usize> = input_vector();
    if n == 2 {
        println!("{}", v[1]);
        println!("{}", v[0]);
    } else {
        let mut w = v.clone();
        w.sort();
        for z in &v {
            if w.binary_search(z).unwrap() < n / 2 {
                println!("{}", w[n / 2]);
            } else {
                println!("{}", w[n / 2 - 1]);
            }
        }
    }
}

Measured memory_bytes: 10928
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

string s;

void solution() {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    cout << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# cheapest price without using discount ticket
min_price = min(a) + min(b)

for i in range(m):
    arr = list(map(int, input().split()))
    discounted_price = a[arr[0] - 1] + b[arr[1] - 1] - arr[2]
    min_price = min(min_price, discounted_price)
print(min_price)

Measured memory_bytes: 24808
#include <iostream>
    #include <string>
    using namespace std;
     
    int main()
    {
    	string str;
    	cin >> str;
    	
    	int K;
    	cin >> K;
    	
    	for (int i=0;i<str.length();++i){	
    		if (str[i] == 'a'){
    			continue;
    		}	
    		if ('z' - str[i] + 1 <= K){
    			K -= 'z' - str[i] + 1;
    			str[i] = 'a';			
    		}
    	}
    	
    	K = K%26;
    	str[str.length()-1] += K;
     
    	cout << str << endl;
    	return 0;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 
    
    int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

    int main(){
        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */

        fast;
        int n;
        cin>>n;
        ll ans=0;
        rep(i,1,n+1){
            rep(j,1,n+1){
                rep(k,1,n+1){
                    ans+=gcd(i,gcd(j,k));
                    //cout<<ans<<" ";
                }
            }
        }
        cout<<ans;
        return 0;  
    }       
 
 
    //keep it simple stupid



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

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> w(N), d(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> d[i];
	}
	ll lb = 0, ub = 2e18;
	while (ub - lb > 1) {
		ll m = (lb + ub) / 2, cnt = 1;
		for (int i = 0; i < N; i++) {
			cnt += m >= w[i] ? (m - w[i]) / d[i] + 1 : 0;
		}
		if (cnt > K) {
			ub = m;
		}
		else {
			lb = m;
		}
	}
	cout << ub << endl;
	return 0;
}


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

using ll=long long;
ll h,w;
ll ans; 
ll ans1;
ll ans2;
ll ans3;
ll big;
ll small;

int main()
{
    ios::sync_with_stdio(false);

	cin>>h>>w;
	
//	if (h%3==0 || w%3==0) return 0*puts("0");
	
	ans=h*w;
	for (ll i=1;i<w;i++)
	{
		big=small=ans1=i*h;
		ans2=h/2*(w-i);
		ans3=(h+1)/2*(w-i);
		
		big=max(big,ans2);
		big=max(big,ans3);
		small=min(small,ans2);
		small=min(small,ans3);
		
		ans=min(ans,big-small);
	}
	for (ll i=1;i<w;i++)
	{
		big=small=ans1=i*h;
		ans2=(w-i)/2*h;
		ans3=(w-i+1)/2*h;
		
		big=max(big,ans2);
		big=max(big,ans3);
		small=min(small,ans2);
		small=min(small,ans3);
		
		ans=min(ans,big-small);
	}
		
	swap(h,w);
	for (ll i=1;i<w;i++)
	{
		big=small=ans1=i*h;
		ans2=h/2*(w-i);
		ans3=(h+1)/2*(w-i);
		
		big=max(big,ans2);
		big=max(big,ans3);
		small=min(small,ans2);
		small=min(small,ans3);
		
		ans=min(ans,big-small);
	}
	for (ll i=1;i<w;i++)
	{
		big=small=ans1=i*h;
		ans2=(w-i)/2*h;
		ans3=(w-i+1)/2*h;
		
		big=max(big,ans2);
		big=max(big,ans3);
		small=min(small,ans2);
		small=min(small,ans3);
		
		ans=min(ans,big-small);
	}
		
	cout<<ans;
}

Measured memory_bytes: 256