akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  string str; cin >> str;
  string cpr = "AKIHABARA";


  string ans = "";
  for(ll i = 0, j = 0; i<str.size(), j<cpr.size(); ){
    if(str[i] == cpr[j]){
      ans+= str[i];
      i++;
      j++;
    }
    else if(str[i] != cpr[j] && cpr[j] == 'A')j ++;
    
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cerr << ans << "  "  << str << endl;
  if(ans == str)cout << "YES" << endl;
  else cout <<"NO" << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    //cout << n << " " << m << endl;
    vector <long> hight(n);
    vector <bool> isGood(n);
    for(int i = 0; i < hight.size(); i++){
        cin >> hight[i];
        isGood[i]=true;
    }
    #if 0
    for(int i = 0; i < hight.size(); i++){
        cout << hight[i] << " ";
    }
    cout << endl;
    #endif
    int pathNum = 0;
    while(pathNum<m){
        pathNum++;
        int index1,index2;
        cin >> index1 >> index2;
        index1--;
        index2--;
        if(hight[index1] > hight[index2]){
            isGood[index2]=false;
        }else if(hight[index2]> hight[index1]){
            isGood[index1]=false;
        }else{
            isGood[index2]=false;
            isGood[index1]=false;
        }
    }
   int result = 0;
    for(int i = 0; i < isGood.size(); i++){
        if(isGood[i]==true){
            result++;
        }
    }
    cout << result << endl;
    return 0;
}

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

using namespace std;

vector <int> coin;

int dp[100005];

int go(int cur) {
  if(cur < 0) return 1e5 + 10;
  if(cur == 0) return 0;
  if(dp[cur] != -1) return dp[cur];
  int res = 1e5 + 5;
  for(int i = 0; i < coin.size(); i++) {
    if(coin[i] <= cur) res = min(res, 1 + go(cur - coin[i]));
  }
  return dp[cur] = res;
}

int main() {
  int n; scanf("%d", &n);
  coin.push_back(1);
  for(int i = 6; i <= n; i *= 6) {
    coin.push_back(i);
  }
  for(int i = 9; i <= n; i *= 9) {
    coin.push_back(i);
  }
  //sort(coin.begin(), coin.end());
  //cout << coin.size() << '\n';
  memset(dp, -1, sizeof dp);
  printf("%d\n", go(n));
  return 0;
}

Measured memory_bytes: 3712
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const int N = 2e5+10;

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    int pv = -1;
    vector<int> a;
    for (int x; n--;) {
        cin >> x;
        if (x != pv)
            a.pb(x);
        pv = x;            
    }
    auto add = [&](int& s, int x) {
        s += x;
        if (s >= MOD)
            s -= MOD;
    };
    int dp = 1;
    vector<int> cnt(N);
    for (int i = 0; i < sz(a); ++i) {
        add(cnt[a[i]], dp);         
        dp = cnt[a[i]];    
    }
    cout << dp;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 1908
n, k = map(int, input().split())
s = list(input())


L = [0]
R = []
for i, (a, b) in enumerate(zip(s, s[1:])):
    if (a, b) == ('0', '1'):
        L.append(i+1)

    if (a, b) == ('1', '0'):
        R.append(i)
else:
    R.append(n-1)

ans = R[0]-L[0]+1
if s[0] == '0':
    k -= 1
k = min(k, len(R)-1)
for l, r in zip(L, R[k:]):
    x = r-l+1
    if ans < x:
        ans = x
print(ans)


Measured memory_bytes: 8660
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  int x; cin >> x;
  if(400 <= x && x <= 599){
    cout << 8;
  }
  if(600 <= x && x <= 799){
    cout << 7;
  }
  if(800 <= x && x <= 999){
    cout << 6;
  }
  if(1000 <= x && x <= 1199){
    cout << 5;
  }
  if(1200 <= x && x <= 1399){
    cout << 4;
  }
  if(1400 <= x && x <= 1599){
    cout << 3;
  }
  if(1600 <= x && x <= 1799){
    cout << 2;
  }
  if(1800 <= x && x <= 1999){
    cout << 1;
  }
  return 0;
}


Measured memory_bytes: 3632
def str10to3(x):
    a = ""
    while x >= 3:
        a += str(x % 3)
        x = x / 3
    a += str(x % 3)
    return "".join(reversed(a))


def str3to10(x):
    num_753 = ['7', '5', '3']
    return "".join([num_753[int(i)] for i in x])


N = input()
c = 0
for i in range(3 ** 10):
    num_753 = str3to10(str10to3(i))
    for i in range(9):
        if int('7' * i + num_753) <= N and set('7' * i + num_753) == set(['7', '5', '3']):
            c += 1
print c



Measured memory_bytes: 4484
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define y1 Emilia
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;

int main(){
    dracarys
    cin >> n;
    if (n % 2 == 1) {
        int a = n / 2 + 1;
        printf("%.10f", 1.0*a/n);
    } else {
        printf("%.10f", 1.0/2);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std; 
int main(void){ 
	long N,a,b,c,d,ans;
	cin >> N >> a >> b;
	c = N/(a+b);
	ans = 0;
	ans += c*a;
	d = N%(a+b);
	ans += min(d,a);
	cout << ans;
	 return 0;
}

Measured memory_bytes: 256
#include <memory.h>
#include "cmath"
#include "iostream"
int main() {
    int n;
    scanf("%d", &n);
    int a[100002];
    for(int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    int dp[100002];
    memset(dp, 0, sizeof dp);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = std::min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    printf("%d", dp[n]);
}

Measured memory_bytes: 4572
import numpy as np
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
a = np.cumsum(a)
b = np.cumsum(b)

ans = 0
for a_num, time in enumerate(a):
    if time > k:
        continue
    b_num = bisect_right(b, k - time)
    num = a_num + b_num - 1
    if num > ans:
        ans = num
print(ans)


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

int main() {

    set<string> se;

    string s;

    int k;

    cin >> s >> k;

    if(s.size() < k) {

        for (int i = 0; i < s.size(); i++) {
            string tmp = "";
            tmp += s[i];
            se.insert(tmp);
            for (int j = i + 1; j < s.size(); j++) {
                tmp += s[j];
                se.insert(tmp);
            }
        }

        int count = 0;

        for (auto sub : se) {
            count++;
            if (count == k) {
                cout << sub << endl;
                break;
            }
        }
    }
    else{

        char min_c = 'z';
        char min_second = 'y';

        for(auto c : s) {
            min_c = min(min_c, c);
        }

        for(auto c : s){
            if(c != min_c){
                min_second = min(min_second,c);
            }
        }

        set<string> se;

        for(int i=0; i<s.size(); i++){
            if(s[i] == min_c){
                string ans_tmp = "";
                for(int j=i; j<i+k; j++){
                    if(j == s.size()){
                        break;
                    }
                    ans_tmp += s[j];
                    se.insert(ans_tmp);
                }
            }
        }

        for(int i=0; i<s.size(); i++){
            if(s[i] == min_second){
                string ans_tmp = "";
                for(int j=i; j<i+k; j++){
                    if(j == s.size()){
                        break;
                    }
                    ans_tmp += s[j];
                    se.insert(ans_tmp);
                }
            }
        }

        int count = 0;

        for(auto sub : se){
            count++;
            if(count == k){
                cout << sub << endl;
                break;
            }
        }

    }


    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
#define MOD 1000000007
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;

int main()
{
    ll l, r;
    cin >> l >> r;
    for(int i = 1; i < 1000000; i++){
        if(2019*i >= l && 2019*i <= r){
            cout << 0 << endl;
            return 0;
        }
    }
    ll mn = 2019;
    rep(i,l,r+1){
        rep(j,i+1,r+1){
            if(i != j){
                mn = min(mn, (i*j)%2019);
            }
        }
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
double search(double start,double end,double n){
    if(end-start<1e-9)return start;
    double mid=(start+end)/2;
    if(mid*mid*mid>n)return search(start,mid,n);
    else return search(mid,end,n);
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    double n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<(n/3)*(n/3)*(n/3);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	int a = 0;
	cin >> s;
	for (auto ch : s) {
		if (ch == '+') a++;
		else a--;
	}
	cout << a << "\n";

	return 0;
}


Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main()
{
    int n;
    int a[100003];
    REP(i,100002) a[i] = 0;
    cin >> n;
    REP(i, n){
        int b;
        cin >> b;
        a[b]++;
    }

    int maxnum = 0;
    REP(i,100001){
        int cnt = 0;
        if(i == 0) cnt += a[i];  
        else if(i == 100000) cnt += a[i];
        else{
            cnt += a[i] + a[i-1] + a[i+1];
        }
        

        if(maxnum < cnt) maxnum = cnt;
    }
    cout << maxnum << endl;

    return 0;
}

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

int main(void) {
    string a;
    string b;
    cin >> a >> b;

    int a_len = a.length();
    int b_len = b.length();
    int m_len  = (a_len < b_len ? a_len : b_len);

    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<char>());

 //   cout << a << endl;
 //   cout << b << endl;

    bool h = false;

    for (int i = 0; i < m_len; i++) {
        if (a[i] < b[i]) {
            h = true;
            break;
        } else if (a[i] > b[i]) {
            h = false;
            break;
        } else if (i == (m_len - 1)) {
            if (a_len < b_len) {
                h = true;
                break;
            } else {
                h = false;
                break;
            }
        } else {
            /* nothing to do. */
        }
    }

    if (h == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}


    for(int k=0; k<m; k++){
      for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
          if(T[i][j]>T[i][k]+T[k][j]){
            T[i][j] = T[i][k]+T[k][j];
          }
        }
      }
    }

    int ans = INF;
      int t;
      for(int i=0; i<m; i++){
        int sum = 0;
        for(int j=0; j<m; j++){
          sum += T[i][j];
        }
        if(sum<ans){
          ans = sum;
          t=i;
        }
      }
        cout << t << ' ' << ans << endl;
    }

	return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <vector>

using namespace std;

vector<vector<long long int>> dp(105, vector<long long int>(100005, -1));
vector<int> weights, values;

//dp[n][w] = maximum sum of values for n items in a knapsack of max
//capacity of w
//Logic: either include the n'th item in the knapsack, or don't.
long long int solve(int n, int w)
{
    if(dp[n][w] != -1)
        return(dp[n][w]);
    if(n == 0)
        return(dp[n][w] = 0);
    if(w - weights[n] < 0)
        return(dp[n][w] = solve(n-1, w));
    return(dp[n][w] = max(values[n] + solve(n-1, w-weights[n]), solve(n-1, w)));
}

int main()
{
    int n, w;
    long long int ans;
    cin >> n >> w;
    weights.push_back(-1), values.push_back(-1);
    for(int i=0;i<n;i++)
    {
        int weight, value;
        cin >> weight >> value;
        weights.push_back(weight), values.push_back(value);
    }
    ans = solve(n, w);
    cout << ans << endl;
    return(0);
}

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

using namespace std;

int main() {
    unsigned long long n, answer;
    vector<unsigned long long> t(5, 0);
    cin >> n;
    for (int i = 0; i < 5; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());
    answer = n / t.front() + 4;
    if (n % t.front() != 0) ++answer;
    cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		dPA();

	}

	private static void dPA() {
		Scanner scanner = null;
		int numFlog = 0;

		try {
			scanner = new Scanner(System.in);
			numFlog = scanner.nextInt();
			int[] heightArray = new int[numFlog];

			for (int i = 0; i < numFlog; i++) {
				heightArray[i] = scanner.nextInt();
			}

			int[] koufukuArray = new int[numFlog];
			koufukuArray[0] = 0;
			koufukuArray[1] = Math.abs(heightArray[1] - heightArray[0]);
			for (int i = 2; i < heightArray.length; i++) {
				int val1 = Math.abs(heightArray[i] - heightArray[i - 1]);
				int val2 = Math.abs(heightArray[i] - heightArray[i - 2]);
				koufukuArray[i] = Math.min(koufukuArray[i - 1] + val1, koufukuArray[i - 2] + val2);
			}
			System.out.println(koufukuArray[koufukuArray.length - 1]);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 50348
from fractions import gcd

mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

L = 1
for a in A:
    L = L // gcd(L, a) * a

L %= mod

print(sum(L * pow(a, mod - 2, mod) for a in A) % mod)

Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {cin >> a[i]; a[i]--;}
    int p = 0;
    int cnt = 0;
    bool ok = false;
    rep(i,n) {
        p = a[p];
        cnt++;
        if(p==1) {
            ok = true;
            break;
        }
    }
    if(ok) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

void bubbleSort(int*,int);

int cnt=0;

int main()
{
  
  int i;
  int A[100],N;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  bubbleSort(A,N);
  for(i=0;i<N;i++){
    printf("%d",A[i]); 
    if(i != N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);

  
  return 0;
}

void bubbleSort(int* a,int n)
{
  int i,j,temp; 
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j] < a[j-1]){
	temp = a[j];
        a[j] = a[j-1];
	a[j-1] = temp;
	cnt++;
      }
    }
  }
}

Measured memory_bytes: 604
program atcoder
    implicit none
    integer :: k,i,j,l
    character :: s*5008,ans(5)*6
    read*,s,k
    ans = "zzzzz"
    l = len(trim(s))
    do i=1,l
        do j=1,5
            if( any(ans==s(i:i+j-1)) .or. l<i+j-1 )then
                cycle
            endif
            if(s(i:i+j-1)<ans(1))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = ans(2)
                ans(2) = ans(1)
                ans(1) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(2))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = ans(2)
                ans(2) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(3))then
                ans(5) = ans(4)
                ans(4) = ans(3)
                ans(3) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(4))then
                ans(5) = ans(4)
                ans(4) = s(i:i+j-1)
            else if(s(i:i+j-1)<ans(5))then
                ans(5) = s(i:i+j-1)
            endif
        enddo
    enddo
    write(*,'(a)')ans(k)
    stop 
contains
end program atcoder

Measured memory_bytes: 768
#include<iostream>
typedef long long ll;
using namespace std;
const int N=100000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,a[N],dp[N],i,k,j;
	cin>>n>>k;++k;
	for(i=0;i<n;++i) cin>>a[i];
	for(i=1;i<k;++i){
		dp[i]=abs(a[0]-a[i]);
	}
	for(i=k;i<n;++i){
		dp[i]=1e9;
		for(j=i-k+1;j<i;++j){
			dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
		}
	}
	cout<<dp[n-1];
}

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

int main() {
  int N;
  cin >> N;
  int A;
  cin >> A;
  int B;
  cin>>B;
  if (N * A >= B) {
    cout <<B;
  } else {
    cout << N * A;
  }
  
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 500000;
vector<int> g[MAX];
int m[MAX]; bool used[MAX];

int dfs(int u){
  if(used[u]) return -1;
  if(m[u]!=0) return m[u];

  int res = 0;
  used[u] = true;
  m[u] = 1;
  for(int v:g[u]) {
    int res = dfs(v);
    if(res<0) return m[u] = -1;
    m[u] = max(m[u],res+1);
  }
  used[u] = false;
  return m[u];
}
int main() {
  int n;
  cin >> n;

  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n)rep(j,n-1){
    cin >> a[i][j];
    --a[i][j];
  }
  vector<vector<int>> id(n,vector<int>(n));
  int v = 0;
  rep(i,n)rep(j,n) if(i<j) id[i][j] = id[j][i] = v++;

  rep(i,n){
    int p = id[i][a[i][0]];
    rep(j,n-2){
      int np = id[i][a[i][j+1]];
      g[p].emplace_back(np);
      p = np;
    }
  }

  int ans = 0;
  rep(i,n){
    int temp = dfs(id[i][a[i][0]]);
    if(temp<0){
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans,temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 37888
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;
int h,w;
string s[55][55];
int main(void){
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == "snuke"){
	printf("%c%d\n",'A'+j,i+1);
      }
    }
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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 (b < a) { a = b; return true; } return false; }

struct Dinic {
	using Flow = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Edge() {}
		Edge(int to, int rev, Flow cap) :to(to), rev(rev), cap(cap) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<bool> used;
	vector<int> level;
	vector<int> iter;
	Dinic(int n) :n(n), g(n), used(n), level(n), iter(n) {};
	void addArc(int from, int to, Flow cap) {
		g[from].emplace_back(to, (int)g[to].size(), cap);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0);
	}
	void addEdge(int a, int b, Flow cap) {
		g[a].emplace_back(b, (int)g[b].size(), cap);
		g[b].emplace_back(a, (int)g[a].size() - 1, cap);
	}
	Flow maximumFlow(int s, int t) {
		Flow total = 0;
		while (true) {
			levelize(s);
			if (level[t] < 0)return total;
			fill(iter.begin(), iter.end(), 0);
			Flow f;
			while (true) {
				f = augment(s, t, INF);
				if (f == 0)break;
				total += f;
			}
		}
	}
	Flow augment(int v, int t, Flow f) {
		if (v == t)return f;
		for (int &i = iter[v]; i < g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				Flow d = augment(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	void levelize(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while (q.size()) {
			int v = q.front(); q.pop();
			for (int i = 0; i < g[v].size(); i++) {
				Edge &e = g[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N, W; cin >> N >> W&&N;) {
		Dinic dinic(7 + N + 2);
		int src = 7 + N, snk = src + 1;
		rep(i, 0, 7)
			dinic.addArc(src, i, W);
		int total = 0;
		rep(i, 0, N) {
			int t, c; cin >> t >> c;
			total += t;
			dinic.addArc(7 + i, snk, t);
			rep(j, 0, c) {
				string s; cin >> s;
				if (s == "Sunday")
					dinic.addArc(0, 7 + i, W);
				else if (s == "Monday")
					dinic.addArc(1, 7 + i, W);
				else if (s == "Tuesday")
					dinic.addArc(2, 7 + i, W);
				else if (s == "Wednesday")
					dinic.addArc(3, 7 + i, W);
				else if (s == "Thursday")
					dinic.addArc(4, 7 + i, W);
				else if (s == "Friday")
					dinic.addArc(5, 7 + i, W);
				else if (s == "Saturday")
					dinic.addArc(6, 7 + i, W);
			}
		}
		cout << (dinic.maximumFlow(src, snk) == total ? "Yes" : "No") << endl;
	}
	return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> jobs(M+1);
    rep(i,N){
        int A,B;
        cin >> A >> B;
        if(A>M) continue; // AがMを超えていたら候補にならない
        jobs[A].push_back(B); // A日後に報酬を受け取れる仕事をまとめる
    }
    priority_queue<int> q;
    ll ans = 0;
    // M日後からi日前時点でできる仕事の中から報酬が最大のものを選ぶ
    for(int i=1;i<=M;i++){
        for(int B:jobs[i]){ // 拡張for文 
            q.push(B);
        }
        if(!q.empty()){ // 受けられる仕事がなければスルー
            ans+=q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
N,M=map(int,input().split())
B=[]
AB=[]
S=[]
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b])
    B.append(b)

S=sorted(AB)
D=[]
check=0
ans=0
for i in range(N):
    check+=S[i][1]
    if check<=M:
        D+=[S[i][1]]
    else:
        b=check-M
        D+=[S[i][1]-b]
        break
for i in range(len(D)):
    ans+=D[i]*S[i][0]
print(ans)


Measured memory_bytes: 21668
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include<cstdio>
using namespace std;

int main()
{
	int N, Y;
	int x, y, z;
	x = y = z = 0;

	cin >> N >> Y;
	for (x = 0; x <= N; x++) {
		for (y = 0; y <= N - x; y++) {
			z = N - x - y;
			if (x + y + z == N && 10000 * x + 5000 * y + 1000 * z == Y) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>dif(n);
  for(int i=0;i<n;i++){
    cin >> dif.at(i);
  }
  sort(dif.begin(),dif.end());
  int ans=dif.at(n/2)-dif.at(n/2-1);
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 1e5+7;
int dp[N];
int h[N];

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

    for (int i=1; i<=n; i++)    cin>>h[i];

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i=3; i<=n; i++)
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) );
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
//
#include <atcoder/all>
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void Yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    dsu d(N);
    rep(i, M)
    {
        ll A, B;
        cin >> A >> B;
        --A;
        --B;
        d.merge(A, B);
    }
    cout << d.groups().size() - 1;
    return 0;
}

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

int main(){

	int n, k, num, sum=0;
	cin >> n >> k;
	vector<int>p;
	
	while(cin>>num){
    	p.push_back(num);
    }
	sort(p.begin(),p.end());
    for(int i = 0; i < k; i++){
    	sum += p[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = sub(readLine().split(" ").map(_.toInt))
    def digit(a: Int, b: Int): Int = if(b == 0) a else digit(b, a % b)

    @tailrec
    def sub(n: Seq[Int]): Unit = {
        val gcd: Int = digit(n(0), n(1))
        val lcm: Long = n.map(_.toLong).product / gcd.toLong
        println(s"$gcd $lcm")
        val next: String = readLine()
        if(next == null) Unit else sub(next.split(" ").map(_.toInt))
    }
}

Measured memory_bytes: 44000
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		HashMap<Integer,Integer> unko=new HashMap<Integer,Integer>();

		int N=sc.nextInt();

		for(int i=0; i<N; i++) {
			int tmp=sc.nextInt();
			if(unko.containsKey(tmp)) {
				unko.replace(tmp, unko.get(tmp) + 1);
				//System.out.println(unko.get(tmp));
			}
			else {
				unko.put(tmp, 1);
			}
		}
		long kosu=0;
		for(Integer key:unko.keySet()) {
			int a=key;
			int b=unko.get(a);
			if(b>a) {
				kosu+=(b-a);
			}
			else if(b<a) {
				kosu+=b;
			}
			if(a==b) {
				//
			}
			//System.out.println();
		}
		System.out.println(kosu);
	}
}

Measured memory_bytes: 60860
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200200,oo=1000000001;
int i,j,k,n,m,ch,t,ma,tma,mi,tmi,Rmax,Rmin,Bmax,Bmin,sma,smi;
ll ans;
struct cc {
	int x,y;
	bool operator < (const cc &n) const {
		if (x==n.x) return y<n.y;
		return x<n.x;
	}
} A[N],B[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void W(ll x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int main() {
	R(n);
	ma=0;mi=oo;
	ans=(ll) mi*mi;
	for (i=1;i<=n;i++) {
		R(A[i].x);R(A[i].y);
		if (A[i].x>A[i].y) {
			t=A[i].x;A[i].x=A[i].y;A[i].y=t;
		}
		if (A[i].y>ma) ma=A[i].y,tma=i;
		if (A[i].x<mi) mi=A[i].x,tmi=i;
	}
	for (i=1;i<=n;i++) if (i!=tma && i!=tmi) B[++m]=A[i];
	sort(B+1,B+m+1);
	Rmax=ma;Bmin=mi;
	Bmax=A[tma].x;
	Rmin=A[tmi].y;
	for (i=1;i<=m;i++) {
		Rmin=min(Rmin,B[i].y);
		Bmax=max(Bmax,B[i].x);
	}
	ans=min(ans,(ll) (Rmax-Rmin)*(Bmax-Bmin));
	if (tma!=tmi) {
		Rmax=ma;Rmin=mi;
		Bmax=max(A[tma].x,A[tmi].y);
		Bmin=min(A[tma].x,A[tmi].y);
		sma=0;smi=oo;
		for (i=1;i<m;i++) {
			sma=max(sma,B[i].y);
			smi=min(smi,B[i].y);
			ans=min(ans,(ll) (Rmax-Rmin)*(max(Bmax,max(sma,B[m].x))-min(Bmin,min(smi,B[i+1].x))));
		}
		ans=min(ans,(ll) (Rmax-Rmin)*(max(Bmax,B[m].x)-min(Bmin,B[1].x)));
		sma=max(sma,B[m].y);
		smi=min(smi,B[m].y);
		ans=min(ans,(ll) (Rmax-Rmin)*(max(Bmax,sma)-min(Bmin,smi)));
	}
	W(ans);puts("");
}

Measured memory_bytes: 3328
fun main(args: Array<String>) {
    val a = (1..5).map { readLine()!!.toInt() }
    if(a.all{it%10==0}){
        println(a.sum())
    }else{
        val ans = a.map { (it+9)/10*10 }.sum() -10 +a.map { it%10 }.filter { it!=0 }.min()!!
        println(ans)
    }
}

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

using namespace std;

int main()
{
	int a,b, ans;
	string sum;
	while(cin >> a >> b)
	{
		ans = a + b;
		int i = 1;
		while(ans/=10) i++;
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
struct dice
{
	int s[6], b;
	void roll(char c)
	{
		if (c == 'W')
		{
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'E')
		{
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'S')
		{
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
			
		}
		if (c == 'N')
		{
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
	}
	int top()
	{
		return s[0];
	}
};
int main()
{
	string str;
	dice d;
	int i;
	for (i = 0; i < 6; i++)
	{
		cin >> d.s[i];
	}
	cin >> str;
	for (i = 0; i < str.size(); i++)d.roll(str[i]);
	cout<<d.top()<<endl;
	return 0;
}



Measured memory_bytes: 3164
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto dl = DList!long();

  foreach (_; 0..n) {
    auto rd = readln.chomp.splitter(' '), cmd = rd.front;
    switch (cmd) {
    case "insert":
      rd.popFront;
      auto x = rd.front.to!long;
      dl.insertFront(x);
      break;
    case "delete":
      rd.popFront;
      auto x = rd.front.to!long;
      auto r = dl[].find(x).take(1);
      if (!r.empty) dl.linearRemove(r);
      break;
    case "deleteFirst":
      dl.removeFront;
      break;
    case "deleteLast":
      dl.removeBack;
      break;
    default:
      assert(0);
    }
  }

  writeln(dl[].map!(to!string).join(" "));
}

Measured memory_bytes: 56236
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 105;

int w[N], v[N], dp[N][100005], ready[N][100005];

int solve (int i, int j) {
	if (j == 0) return 0;
	if (j < 0) return -inf;
	if (i == 0) return 0;
	if (ready[i][j]) return dp[i][j];
	dp[i][j] = max(v[i] + solve(i-1, j-w[i]), solve(i-1, j));
	ready[i][j] = 1;
	return dp[i][j];
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    	cin >> w[i] >> v[i];
    cout << solve(n, k);
    return 0;
}

Measured memory_bytes: 159232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, H;
    cin >> N >> H;

    vector<pii> as, bs;
    for(int i=0; i<N; i++)
    {
        int a, b;
        cin >> a >> b;
        as.emplace_back(a, i);
        bs.emplace_back(b, i);
    }

    sort(as.begin(), as.end(), greater<pii>());
    sort(bs.begin(), bs.end(), greater<pii>());

    pii bsum(0, -1);
    for(int i=0; i<N; i++)
    {
        if(bsum.first >= H)
        {
            cout << i << '\n';
            return 0;
        }
        if(bs[i].first < as[0].first) break;
        bsum.first += bs[i].first;
        bsum.second = i+1;
    }

    cout << (H - bsum.first + as[0].first - 1) / as[0].first + bsum.second << '\n';

    return 0;
}

Measured memory_bytes: 2036
import sys
m,n = map(int,input().split())
mlist = []
nlist = []
for i in range(m):
    a = input()
    mlist.append(list(a))
for i in range(n):
    a = input()
    nlist.append(list(a))

for i in range(m-n+1):
    for j in range(m-n+1):
        frag = 0
        for a in range(n):
            for b in range(n):
                if mlist[i+a][j+b] != nlist[a][b]:
                    frag = 1
            if frag == 1:
                break
        if frag == 0:
            print("Yes")
            sys.exit()
print("No")

Measured memory_bytes: 3064
# How Many Divisors?

n = [int(i) for i in input().rstrip().split()]
a = n[0]
b = n[1]
c = n[2]

divisorsCount = 0
for i in range(a, b + 1):
    if c % i == 0:
        divisorsCount += 1

print(divisorsCount)



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	cin>>n;
	cout<<n*n*n<<'\n';
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    int total = x * 4;
    if (total == y) {
        cout << "Yes";
        return 0;
    }
    for (int i = 0; i < x; i++) {
        total -= 2;
        if (total == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        String s = in.nextLine();
        if(s.charAt(0)>=65&&s.charAt(0)<=90)
            System.out.println('A');
        else System.out.println('a');
    }
}

Measured memory_bytes: 32668
import itertools
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0
for x in itertools.product([True, False], repeat=w):
    for y in itertools.product([True, False], repeat=h):
        t = 0
        for i in range(w):
            for j in range(h):
                if x[i] and y[j] and c[j][i] == '#':
                    t += 1
        if t == k:
            ans += 1
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
using namespace std;
const int N=2e5+5,M=6008;
int n,k,x,y,m;
string c;
int f[M][M];
int calc(int x1,int y1)
{
	int x2=x1+k-1,y2=y1+k-1;
	x1=max(1,x1),y1=max(1,y1);
	x2=min(x2,m),y2=min(y2,m);
	if(x2<x1||y2<y1)
		return 0;
	return f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;	
	m=2*k;
	memset(f,0,sizeof(f));
	rep(i,1,n)
	{
		cin>>x>>y>>c;
		if(c=="W")
			y+=k;
		x%=m,y%=m;
		x++,y++;
		f[x][y]++;
	}
	for(int i=1;i<=2*m;i++)
		for(int j=1;j<=2*m;j++)
			f[i][j]=f[i][j]+f[i][j-1]+f[i-1][j]-f[i-1][j-1];
	int res=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int cnt=calc(i,j);
			cnt+=calc(i-k,j-k)+calc(i-k,j+k)+calc(i+k,j-k)+calc(i+k,j+k);
			cnt+=calc(i-m,j)+calc(i+m,j)+calc(i,j-m)+calc(i,j+m);
			res=max(res,cnt);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>r(n),w(n);
    int temp=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
            temp+=1;
        w[i]=temp;
    }
    temp=0;
    for(int i=n-1;i>-1;i--)
    {
        r[i]=temp;
        if(s[i]=='R')
            temp+=1;
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            ans+=1;
    }
    for(int i=0;i<n;i++)
    {
        int a=w[i],b=r[i];
        ans=min(ans,max(a,b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5180
package main

import(
    
    "bufio"
    "fmt"
    "os"

    
    )
    
var r = bufio.NewReader(os.Stdin)
    
func main() {
    
    var a,b,c int
    fmt.Fscan(r,&a,&b,&c)
    
    if a < b && b < c {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
    
    
    
}


Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, x, n) for (int i = x; i < n; ++i)

int main()
{
    int r,d,x0;
    cin >> r >> d >> x0;

    i64 x = x0;
    rep(i,10)
    {
        x = r*x - d;
        cout << x << endl;
    }

    return 0;
}

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

int main() {
	int n;cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	int ans=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			ans+=d[i]*d[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	llong x;
	cin>>x;
	
	llong ans=0;
	llong now=0;
	while(now<x){
		ans++;
		now+=ans;
	}
	
	cout<<ans<<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++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int xsum=0;
    rep(i,n) xsum^=a[i];
    rep(i,n) cout<<(xsum^a[i])<<" ";
    cout<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int X, Y, Z,ans=0;
  cin >> X >> Y >> Z;
  X -= Y + 2 * Z;
  while(X>=0){
    X -= Y + Z;
    ans++;
  }
  X += Y + Z;
  cout << ans  << endl;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

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

  std::vector<int> A(N);
  std::vector<std::vector<std::pair<int, int>>> xy(N);
  rep(i, N) {
    std::cin >> A[i];
    rep(j, A[i]) {
      int x, y;
      std::cin >> x >> y;
      xy[i].push_back(std::make_pair(x - 1, y));
    }
  }

  int ans = 0;
  for(int b = 0; b < (1 << N); ++b) {
    bool ok = true;
    int cnt = 0;

    rep(i, N) {
      if(b & (1 << i)) {
        ++cnt;

        for(auto p : xy[i]) {
          int x = p.first;
          int y = p.second;

          if(y != (1 &(b >> x))) {
            ok = false;
            break;
          }
        }
        if(!ok) break;
      }
    }

    if(ok) {
      ans = std::max(ans, cnt);
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];

  ll xr = a[0];
  rep(i, 1, n) xr = xr ^ a[i];

  rep(i, 0, n){
    cout << (xr ^ a[i]) << (i == n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 4780