akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define int long long

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((c >= a && c <= b) ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll q, cnt = 0,h,n, ans = 0,a,b; string s;
int dx[9] = { -2,-2,-2,-1,-1,-1,0,0,0 }, dy[9] = { 0,-1,-2,0,-1,-2,0,-1,-2 };
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int ngcd(vector<int> a) {
    int res;
    res = a[0];
    for (int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }return res;
}
template<typename T>
vector<T> smallest_prime_factors(T n) {
    vector<T> spf(n + 1);
    rep(i,n+1) spf[i] = i;
    for (T i = 2; i * i <= n; i++) {
        if (spf[i] == i) {
            for (T j = i * i; j <= n; j += i) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }return spf;
}
int main(void) {
    cin >> n; vector<int> a(n),b;
    vector<bool> f(1e6 + 10, 0);
    rep(i, n) cin >> a[i];
    int g = ngcd(a);
    if (g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }b = smallest_prime_factors<int>(1e6+5);
    int o;
    rep(i, n) {
        int now = a[i];
        while (b[now] != 1) {
            if (f[now]) {
                cout << "setwise coprime" << endl;
                return 0;
            }
            f[now] = 1;
            now /= b[now];
        }
    }cout << "pairwise coprime" << endl;
}

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

int main()
{
  int N ;
  cin>>N ;
  int t[N+1],x[N+1],y[N+1] ;
  t[0]=0,x[0]=0,y[0]=0 ;
  for(int i=1;i<N+1;i++) cin>>t[i]>>x[i]>>y[i] ;
  
  for(int i=0;i<N;i++){
    int tmp=t[i+1]-t[i]-x[i+1]+x[i]-y[i+1]+y[i] ;
    if(tmp%2!=0||tmp<0){
      cout<<"No"<<endl ;
      return 0 ;
    }
  }
  cout<<"Yes"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 1408
import itertools

N, M, X = map(int, input().split())

List = []

Max = 10 ** 7

for i in range(N):
    List.append(list(map(int, input().split())))

#print(List)
l = []
for i in range(N):
    l.append(i)

for i in range(N, 0, -1):
    for j in itertools.combinations(l, i):
        Sum = [0] * (M+1)
        flg = 0
        for k in j:
            for h in range(M+1):
                Sum[h] += List[k][h]
        #print(Sum)
        if Sum[0] <= Max:
            for a in range(1, M+1):
                if Sum[a] < X:
                    flg = 1
                    break
            if flg == 0:
                Max = Sum[0]

if Max == 10 ** 7:
    print(-1)
else:
    print(Max)
                


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
const int maxn = 107;
struct node{
	int x,y;
}red[maxn],blu[maxn];
vector<int> v[maxn];
int vis[maxn],match[maxn]; 
int dfs(int k){
	for(int i = 0;i < v[k].size();i++){
		int y = v[k][i];
		if(!vis[y]){
			vis[y] = 1; 
			if(!match[y] || dfs(match[y])){
				match[y] = k;
				return 1;
			}
		}
	}
	return 0; 
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		red[i].x = x;
		red[i].y = y;
	}
	for(int i = 1;i <= n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		blu[i].x = x;
		blu[i].y = y;
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(red[i].x < blu[j].x && red[i].y < blu[j].y){
				v[i].push_back(j);
			}
		}
	}
	int cnt = 0;
	for(int i = 1;i <= n;i++){
		memset(vis,0,sizeof(vis));
		if(dfs(i)) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference
//priority_queue implements max heap by default

int main(){
    fastio;
    int n;
    cin>>n;
    map<ll,ll> m;
    ll ans = 0;
    vl a(n);
    forn(i,0,n){
        cin>>a[i];
        m[a[i]]++;
    }
    for(auto x:m){
        ans += (x.se*(x.se-1))/2;
    }
    forn(i,0,n){
        ll temp = ans-(m[a[i]]-1);
        cout<<temp<<endl;
    }
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
double cal_max(const int current, const int max_section, const std::vector<int>& heights, std::vector<std::vector<double>>& memo) {
	if (current == heights.size()) return 0;
	if (memo[current][max_section] >= 0) return memo[current][max_section];
	if (max_section == 1) {
		double sum_height = std::accumulate(std::next(heights.begin(), current), heights.end(), 0.0);
		return memo[current][max_section] = sum_height / (heights.size() - current);
	}
	double sum_height = 0.0;
	double& result = memo[current][max_section];
	for (auto right = current; right < heights.size(); ++right) {
		sum_height += heights[right];
		result = std::max(result, cal_max(right + 1, max_section - 1, heights, memo) + sum_height / (right - current + 1));
	}
	return result;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> heights(n); for (auto& h : heights) std::cin >> h;
	std::vector<std::vector<double>> memo(n, std::vector<double>(m + 1, -1));
	std::cout << std::setprecision(10) << std::fixed << cal_max(0, m, heights, memo) << '\n';
}




Measured memory_bytes: 4996
S = input()
N = len(S) # タイルの数

a = sum((1 << i) for i in range(0, N, 2)) # 0b ...0101
b = sum((1 << i) for i in range(1, N, 2)) # 0b ...1010

a_flip = bin(a ^ int(S, base = 2))
b_flip = bin(b ^ int(S, base = 2))

print(min(a_flip[2:].count('1'), b_flip[2:].count('1')))

Measured memory_bytes: 3444
c = [list(map(int, input().split())) for _ in range(3)]
#print(c)

flg = True
for dj in range(2):
    t = c[0][1 + dj] - c[0][0 + dj]
    for i in range(3):
        if t != c[i][1 + dj] - c[i][0 + dj]:
            flg = False
            break
for di in range(2):
    t = c[1 + di][0] - c[0 + di][0]
    for j in range(3):
        if t != c[1 + di][j] - c[0 + di][j]:
            flg = False
            break
print('Yes' if flg else 'No')

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

int main() {
    int N,ans=0;
    cin >>N;
    for(int i=1;i<=N;i++){
        int count =0;
        for(int j=1;j<=i;j++){
            if(i%j==0 && i%2 !=0)count++;
        }
        if(count ==8) ans++;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
s = sum(A)
A = sorted(A, reverse=True)
ans = 'Yes'
for i in range(M):
  if A[i]*(4*M) < s: 
    ans = 'No'
    break

print(ans)

Measured memory_bytes: 8980
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> a(n+1);
  REP(i,n) cin >> a[i+1];
  vector<LL> b(n+1);
  for(int i = n;i>=1;--i) {
    LL balls = 0;
    for(int j = i;j<=n;j+=i) {
      balls += b[j];
    }
    if((a[i]+balls)%2) ++b[i];
  }
  vector<LL> ans;
  REP(i,n) if(b[i+1]) ans.push_back(i+1);
  cout << ans.size() << endl;
  REP(i,ans.size()) {
    if(i) cout << " ";
    cout << ans[i];
    if(i==ans.size()-1)cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
string s;
int main()
{
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        int rlen=1,llen=0;
        while(i+1<n && s[i+1]=='R')
            i++,rlen++;
        while(i+1<n && s[i+1]=='L')
            i++,llen++;

        for(int j=1;j<rlen;j++)printf("0 ");

        int v=(llen+rlen)/2;
        if((llen+rlen)%2==0)
            printf("%d %d ",v,v);
        else
        {
            int k=max(rlen,llen)-1,a,b;
            if(rlen>llen)
                a=v+1,b=v;
            else
                a=v,b=v+1;
            if(k&1)
                printf("%d %d ",b,a);
            else
                printf("%d %d ",a,b);
        }
        for(int j=1;j<llen;j++)printf("0 ");
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define MAX_N 200100

using namespace std;

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

using namespace std;

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

struct BIT{
	int bit[MAX_N + 1];
	void init(void){
		memset(bit, 0, sizeof(bit));
	}
 
	void add(int i, int x){
		while(i <= MAX_N){
			bit[i] += x;
			i += i & (-i);
		} // end while
	} // end function

	int sum(int i){
		int res = 0;
		while(i > 0){
			res += bit[i];
			i -= i & (-i);
		} // end while
		return res;
	} // end function
};
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string S; cin >> S;
	int n = (int)S.length();
	int white = 1, black = 0;
	rep (i, n){
		black += (int)(S[i] == 'W');
	} // end rep

	vector<int> a(n, 0);
	rep (i, n){
		a[i] = (S[i] == 'B' ? ++black : white++);
	} // end rep
/*
	for (int i = 0; i < n; ++i){
		cerr << a[i] << (i != n - 1 ? ' ' : '\n');
	} // end rep
*/	
	BIT bit;
	bit.init();
	ll ans = 0LL;
	rep (j, n){
		ans += (ll)(j - bit.sum(a[j]));
		bit.add(a[j], 1);
	} // end rep

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2196
def main():
    from math import gcd

    K = int(input())

    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            g = gcd(a, b)
            for c in range(1, K + 1):
                ans += gcd(g, c)
    print(ans)
    

if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 67664
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int a[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	int v=0;
	for (int i=1;i<=n;i++){
		if (a[a[i]]==i) v++;
	}
	cout<<v/2<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int size, valc, n;
string str;
vector<int> ans, path;
bool reject;

void init(){
  reject = false;
  ans.clear();
  path.clear();
  valc = -1;
  size = str.size();
}

void solve(int p){
  if(p == size){
    int sum = 0;
    for(int i=0;i<path.size();i++) sum += path[i];
    if(sum == valc){
      reject = true;
    }else if(valc < sum && sum <= n){
      valc = sum;
      ans = path;
      reject = false;
    }
  }else{
    for(int i=1;i+p<=size;i++){
      int tmp = atoi((str.substr(p, i)).c_str());
      path.push_back(tmp);
      solve(p+i);
      vector<int>::iterator ite = path.end();
      path.erase(--ite);
    }
  }
}

main(){
  while(cin >> n >> str){
    if(n == 0 && str == "0") break;
    init();
    solve(0);
    if(valc == -1) cout << "error" << endl;
    else if(reject) cout << "rejected" << endl;
    else{
      cout << valc;
      for(int i=0;i<ans.size();i++){
        cout << ' ' << ans[i];
      }
      cout << endl;
    }
  }
}

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

int main(){
    int n;
    cin >> n;
    long sum = 0;
    rep(i, n + 1){
        if(i % 3 != 0 && i % 5 !=0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
    fast_io();
    double l;
    cin >> l;
    double t;
    t = l / 3.0;
    cout <<fixed<<setprecision(12)<< t * t * t;
    return 0;
}

Measured memory_bytes: 256
text = input()
n = int(input())
for _ in range(n):
    do = input().split()
    m = int(do[1])
    s = int(do[2])
    if do[0] == "print":
        print(text[m:s + 1])
    elif do[0] == "reverse":
        text = text[0:m] + text[m:s+1][::-1] + text[s + 1:]
    else:
        text = text[0:m] + do[3] + text[s + 1:]



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
#define MAX 2001
vector<int> L;
vector<bool> used(MAX,false);

int main(){
    int cnt = 0;
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());

    for(int i=0;i<n-2;i++){
        int k = i+2;
        for(int j=i+1;j<n;j++){
            while(k<n && l[i]+l[j]>l[k]) k++;
            if(k > j) cnt += k-j-1;
        }
    }
    cout << cnt << endl;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

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

const ll maxn=1000001,mod=1e9+7;

bool check(pii a,ll x,ll y){
    if((x>=a.fi&&y>=a.se)||(x>=a.se&&y>=a.fi))
        return true;
    return false;
}

int main(){
sync
    int n;
    cin>>n;
    int h,w;
    cin>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = "NO";
		for(int i = 3; i <= 7; i+=2) {
			if(i == n) {
				ans = "YES";
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << "Alice" << endl;
    }
    else { 
        cout << "Borys" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
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;}
typedef long long ll;

ll N, K;
vector<ll> A;
vector<ll> AA;

pair<ll, ll> func1(ll s, ll c){
  if(AA[s] >= 0 || K == c){
    if(K == c){
      return {s, 0};
    }else{
      return {s, c};
    }
  }
  AA[s] = c;
  return func1(A[s], c+1);
}

ll func2(ll s, ll c, ll gc){
  if(c == gc){
    return s;
  }
  return func2(A[s], c+1, gc);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  A.assign(N, 0);
  AA.assign(N, -1);
  REPLL(i, N){
    ll tmp; cin >> tmp; tmp--;
    A[i] = tmp;
  }
  pair<ll, ll> tmp = func1(0, 0);
  if(tmp.second == 0){
    cout << tmp.first+1 << endl;
    return 0;
  }
  ll cnt = tmp.second - AA[tmp.first];
  ll res = (K-AA[tmp.first])%cnt;
  ll ans = func2(tmp.first, 0, res);
  cout << ans+1 << endl;
}

Measured memory_bytes: 6360
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	if(a>b){
		if(c%a==0)printf("%d\n",c/a);
		else printf("%d\n",(c/a)+1);
	}else{
		if(c%b==0)printf("%d\n",c/b);
		else printf("%d\n",(c/b)+1);
	}
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
N = int(input())
T = defaultdict(int)
for i in range(N):
    T[input()] += 1
U = []
M = 0
for k in T.keys():
    n = T[k]
    if n > M:
        M = n
        U = [k]
    elif n == M:
        U.append(k)
U.sort()
for u in U:
    print(u)

Measured memory_bytes: 95576
import java.io.*;
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
        solve();
      out.close();
  }

  private static void solve() {
      //String s = sc.next();
      int n = sc.nextInt();
      out.println(n == 0 ? 1 : 0);
  }

  public static void sort(int[] a) {
    int l = 0, r = a.length;
      ArrayList<Integer> list=new ArrayList<>();
      for (int i=l ; i<r; i++) list.add(a[i]);
      Collections.sort(list);
      for (int i=l; i<r; i++) a[i]=list.get(i-l);
  }

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
 
  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }
      
      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}

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

using namespace std;

int main()
{
  int i,j,k,cnt;
  bool check = true;
  string str;
  getline(cin,str);
  for(i=1;i<=str.size();i++)
  {
    if(i%2 != 0 && str[i-1] == 'L')
    {
      check = false;
    }
    if(i%2 == 0 && str[i-1] == 'R')
    {
      check = false;
    }
  }
  if(check == true) cout << "Yes";
  else cout << "No";
  
  return 0;
  
}

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

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

  int ans = 0;

  int L, A, B, C, D;
  cin >> L >> A >> B >> C >> D;

  ans = max(A/C + (A%C == 0 ? 0 : 1), B/D + (B%D == 0 ? 0 : 1));

  cout << L - ans << endl;

  return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

// flip pair
template <typename A, typename B>
pair<B, A> flip_pair(pair<A, B> src) {
	return pair<B, A> (src.second, src.first);
}

// flip map
template <typename A, typename B>
multimap<B, A> flip_map(map<A, B> src) {
	multimap<B, A> dst;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto a = flip_pair(*it);
		dst.insert(a);
	}
	return dst;
}

// get frequency mapping from vector
template <typename Tval>
multimap<int, Tval> freq(vector<Tval> src) {
	map<Tval, int> counter;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto it2 = counter.find(*it);
		if(it2 != counter.end()) counter[*it]++;
		else counter[*it] = 1;
	}
	auto dst = flip_map(counter);
	return dst;
}

int main(){
	string S;
	cin >> S;
	int X, min=1000;
	rep(i, S.length()-2)
	{
		X = stoi(S.substr(i, 3));
		min = (min>abs(X-753))?abs(X-753):min;
	}
	cout << min << endl;
	
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,sum=0;
int s[100]={};
cin>>n;
for(int i=0;i<n;i++){
cin>>s[i];
sum+=s[i];
}
sort(s,s+n);
if(sum%10==0){
for(int i=0;i<n;i++){
if(s[i]%10!=0){
sum-=s[i];
break;
}}}
if(sum%10==0)sum=0;
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define MP make_pair
#define vii vector<pii>
#define vi vector<int>
#define ll long long
using namespace std;
int n,x[]={0,9,999,99999},y[]={0,9,900,90000},ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int cnt=0,j=i;
		while(j)
		{
			j/=10;
			cnt++;
		}
		ans+=cnt%2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*Rabbi Zidni Ilma*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define mod 1000000007
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)

int main()
{
   ll n,x,y,i,cnt=0;
   scl(n);
   bool f=0;
   for(i=0;i<n;i++)
   {
   	scll(x,y);
   	if(x==y)
   	cnt++;
   	else
   	cnt=0;
   	if(cnt==3)
   	f=1;
   }
   if(f==1)
   printf("Yes\n");
   else
   printf("No\n");
}





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

const int maxn = 2e5+10;
char s[maxn];

int main(){
	scanf("%s",s);
	int len = strlen(s);
	// int cw=0,cb=0;
	int cnt=0;
	for(int i=0; i<len-1; i++){
		//if((s[i]=='B'&&s[i+1]=='W') || (s[i]=='W' && s[i+1]=='B')) cnt++,i++;
		while(s[i]==s[i+1]) i++;
		cnt++;
	}
	if(s[len-2]!=s[len-1]) cnt++;
	printf("%d\n",cnt-1);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	vector<ll> ans(n,INT_MAX);
	ans[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k&&(i+j)<n;j++)
		ans[i+j]=min(ans[i+j],ans[i]+abs(a[i]-a[i+j]));
	}
	cout<<ans[n-1]<<endl;
}

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

#define ll long long;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> s(6);
  for (int i = 0; i < H; ++i)
    cin >> s[i];
  int res = 0;
  for (int i = 0; i < 1 << H; ++i) {
    for (int j = 0; j < 1 << W; ++j) {
      int cnt = 0;
      for (int i2 = 0; i2 < H; ++i2)
        for (int j2 = 0; j2 < W; ++j2)
          if ((i >> i2 & 1) && (j >> j2 & 1) && s[i2][j2] == '#') // not turn red
            cnt++;
      if (cnt == K)
        res++;
    }
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

int main()
{
    //system("chcp 65001");

    int X,A;
    cin >> X >> A;

    if(X < A)
    {
        cout << "0";
    }
    else
    {
        cout << "10";
    }
    

    return 0;
}

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

int main() {
	long long int n;cin>>n;
	long long int m;m=sqrt(n);
	int flag=1;
	while (flag==1){
	    if(n%m==0)
	    flag=0;
	    else 
	    m--;
	}
	
	long long int c;
	c = m+n/m -2;
	
	cout<<c;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n;
int A[2005];
int sum;

//���͂����l�̂�����I�񂾗v�f�������Ă����ċA�֐�         
int solve(int i,int m){
  if(sum < m) return 0;
  if( m == 0)  return 1;
  if( i >= n) return 0;
  return  solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main(){
  int q,m;
  int i,j;

  sum =0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&m);
    // printf("%d",m);                                     
    if(solve(0,m)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
}

  return 0;
}




Measured memory_bytes: 2108
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(input.readLine());
			
			String[] line = input.readLine().split(" ");
			int first = Integer.parseInt(line[0]);
			int min = first;
			int max = first;
			long sum = first;
			for (int i = 1; i < n; i++) {
				int a = Integer.parseInt(line[i]);
				if (a < min) min = a;
				if (max < a) max = a;
				sum += a;
			}
			String answer = String.valueOf(min) + " " + String.valueOf(max) + " " + String.valueOf(sum);
			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25620
n,m=map(int,input().split())
g=[set() for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  g[a].add(b)
  g[b].add(a)

start=0
spath={0}
path=[0]
todo=[0]
next=g[0].pop()
spath.add(next)
path.append(next)
while g[path[-1]]-spath:
  next=g[path[-1]].pop()
  if next not in spath:
    spath.add(next)
    path.append(next)
rpath=[0]
while g[rpath[-1]]-spath:
  next=g[rpath[-1]].pop()
  if next not in spath:
    spath.add(next)
    rpath.append(next)
rpath.reverse()
rpath.pop()
rpath+=path
rpath=[i+1 for i in rpath]
print(len(rpath))
print(*rpath,sep=' ')


Measured memory_bytes: 115680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(u==s){
        a--;
    }else{
        b--;
    }
    cout << a << " " << b <<  endl;
    // printf("%d\n", N);
    return 0;
}

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

int main() {
  ll n,m,w,x;
  while(cin >> m >> n >> w >> x && n) {
    ll e[n][m],f[n][m];
    for(int i=0; i<m; i++) {
      for(int j=0; j<n; j++) cin >> e[j][i];
    }
    for(int i=0; i<m; i++) {
      for(int j=0; j<n; j++) cin >> f[j][i];
    }
    ll dp[n+1][w+1][x+1],ans=0;
    for(int i=0;i<=n;i++)for(int j=0;j<=w;j++)for(int k=0;k<=x;k++)dp[i][j][k]=-1;
    dp[0][0][0]=0;
    for(int t=0; t<n; t++) {
      for(int l=0; l<=w; l++) {
        for(int k=0; k<=x; k++) {
          if(dp[t][l][k]==-1) continue;
          dp[t+1][l][k]=max(dp[t+1][l][k],dp[t][l][k]);
          for(int i=0; i<m; i++) {
            ll z=0,y=0,xx=0;
            for(int j=i; j<m; j++) {
              if(!e[t][j]) break;
              if(j!=i) y=1;
              xx+=e[t][j];
              z+=f[t][j];
              if(z+l<=w&&k+y<=x) dp[t+1][z+l][k+y]=max(dp[t+1][z+l][k+y],dp[t][l][k]+xx);
            }
          }
        }
      }
    }
    for(int l=0;l<=w;l++)for(int k=0;k<=x;k++)ans=max(ans,dp[n][l][k]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void)
{
    int A, B;
    int ans;
    
    scanf("%d %d",&A,&B);
    
    ans = A - 2*B;
    
    if(ans < 0){
        printf("0\n");
    } else {
        printf("%d\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int map[17][17][17][17];
int dp[17][17];
int p;
int gx,gy;
int ax,ay,bx,by;
int i,j,k,l;
int Tc,tc;
int main(){
  scanf("%d",&Tc);
  for(tc=0;tc<Tc;tc++){

    for(i=0;i<17;i++)
      for(j=0;j<17;j++)
	for(k=0;k<17;k++)
	  for(l=0;l<17;l++)
	    map[i][j][k][l]=0;



    scanf("%d %d",&gx,&gy);
    gx++;
    gy++;
    scanf("%d",&p);
	
    for(i=0;i<p;i++){
      scanf("%d %d %d %d",&ax,&ay,&bx,&by);
      ax++;
      ay++;
      bx++;
      by++;
      map[ax][ay][bx][by]=1;
      map[bx][by][ax][ay]=1;
    }

    for(i=1;i<=gx;i++){
      for(j=1;j<=gy;j++){
	if(i==1&&j==1){
	  dp[i][j]=1;
	}else{
	  dp[i][j]=0;
	  if(map[i][j][i-1][j]==0)dp[i][j]+=dp[i-1][j];
	  if(map[i][j][i][j-1]==0)dp[i][j]+=dp[i][j-1];
	}
      }
    }

    if(dp[gx][gy]==0){
      printf("Miserable Hokusai!\n");
    }else{
      printf("%d\n",dp[gx][gy]);
    }

  }
  return 0;
}

Measured memory_bytes: 936
H, W, h, w = map(int, input().split())
A = [[0]*W for _ in range(H)]
P = 10**9-1
M = -10**9
for y in range(0, H, h):
    for x in range(0, W, w):
        A[y][x] = P
for y in range(h-1, H, h):
    for x in range(w-1, W, w):
        A[y][x] = M
s = sum(map(sum, A))
if s<=-1:
    print("No")
else:
    print("Yes")
    for a in A:
        print(*a)


Measured memory_bytes: 7860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  bool ans = true;
  if(a < b) {
    a += v * t;
    b += w * t;
    ans = a >= b;
  } else {
    a -= v * t;
    b -= w * t;
    ans = a <= b;
  }
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		String line;
		String sentence;
		StringBuilder buf = new StringBuilder();
		while (true)
		{
			line = sc.nextLine();
			if (line.equals("."))
			{
				break;
			}

			buf.append(line);
			if (buf.toString().endsWith("."))
			{
				sentence = buf.toString();
				buf.setLength(0);

				if (isBalanced(sentence))
				{
					System.out.println("yes");
				}
				else
				{
					System.out.println("no");
				}
			}
		}
	}

	static boolean isBalanced(String str)
	{
		int nestParentheses = 0, nestBracket = 0;
		int flag = 0; // 1:'('の中 2:'['の中
		int[] previousFlags = new int[1000]; // 外側のflag
		for (int p :
				previousFlags)
		{
			p = 0;
		}

		for (int i = 0; i < str.length(); i++)
		{
			switch (str.charAt(i))
			{
				case '(':
					previousFlags[nestParentheses + nestBracket] = flag;
					nestParentheses++;
					flag = 1;
					break;
				case '[':
					previousFlags[nestParentheses + nestBracket] = flag;
					nestBracket++;
					flag = 2;
					break;
				case ')':
					if (flag == 1)
					{
						nestParentheses--;
						flag = previousFlags[nestParentheses + nestBracket];
					}
					else
					{
						return false;
					}
					break;
				case ']':
					if (flag == 2)
					{
						nestBracket--;
						flag = previousFlags[nestParentheses + nestBracket];
					}
					else
					{
						return false;
					}
					break;
			}
		}

		return (nestParentheses == 0 && nestBracket == 0);
	}
}


Measured memory_bytes: 54468
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1010;
LL a[L];
LL dp[L];
int t[L];
int N;
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	LL r=a[0]-1;
	LL p=0;
	for(int i=N-1;i>=0;i--){
		dp[i]=a[i];
		for(int k=2;i+k<N;k+=2){
			if(dp[i]<a[i]+dp[i+k]){
				dp[i]=a[i]+dp[i+k];
				t[i]=k;
			}
		}
		//cerr << dp[i] << ", " << t[i] << endl;
		if(r<dp[i]){
			r=dp[i];
			p=i;
		}
	}
	//cerr << p << endl;
	vector<int> ret;
	for(int i=0;i<p;i++){
		ret.push_back(1);
	}
	while(t[p]){
		for(int i=t[p]/2;i>=1;i--){
			ret.push_back(i+1);
		}
		p=p+t[p];
	}
	while(N-1-p){
		ret.push_back(N-p);
		N--;
	}
	cout << r << endl;
	cout << ret.size() << endl;
	for(auto v:ret){
		cout << v << endl;
	}
	return 0;
}



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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;
#define INF_I  			(int)100000009;

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

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

	int N,M,C;
	int ans = 0;
	int sum;

	cin >> N >> M >> C;

	vector<int> B(M);
	vector< vector<int> > A(N, vector<int>(M, 0));

	REP(i,M){
		cin >> B.at(i);
	}

	REP(i,N){
		REP(j,M){
			cin >> A.at(i).at(j);
		}
	}


	REP(i,N){
		sum = 0;
		REP(j,M){
			sum += A.at(i).at(j) * B.at(j);
		}
		sum += C;

		if(sum > 0){
			ans++;
		}
	}

	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static boolean isPrime(int n) {
	    for(int i=2;i<n;i++) {
	        if(n%i==0)
	            return false;
	    }
	    return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
//		long a = sc.nextLong();
//		long b = sc.nextLong();
//		long k = sc.nextLong();
//		if (a - k <= 0) {
//			System.out.println(0 + " " + (b + a - k));
//		} else {
//			System.out.println((a - k) + " " + b);
//		}
		int a = sc.nextInt();
		while(true) {
			if (isPrime(a)) {
				System.out.println(a);
				break;
			}
			++a;
		}
		
		sc.close();
	}

}


Measured memory_bytes: 23636
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        //cout <<i <<  s[i];
        if(i%2 != 0){
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D');
            else {cout << "No";exit(0);}
        }
        else{
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D');
            else{cout << "No";exit(0);}
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
from collections import defaultdict,deque

N=input()
A=[[]]+[ map(int, sys.stdin.readline().split()) for _ in range(N) ]
C=defaultdict(lambda: 0)

Now=[ 0 for _ in range(N+1)]
game=set()
next_game=set()

for i in range(1,N+1):
	a=i
	b=A[i][0]
	if a>b: a,b=b,a
	game.add((a,b))

day=0

while game:
	next_game=set()
	Visit=defaultdict(lambda: None) 

	for x,y in game:
		now_x=Now[x]
		now_y=Now[y]

		xopp=A[x][now_x]
		yopp=A[y][now_y]

		if (x,y)==(yopp,xopp) and Visit[x] is None and Visit[y] is None:
			Visit[x]=1
			Visit[y]=1
			if now_x<N-2:
				now_x+=1
				Now[x]=now_x
				x_nextopp=A[x][now_x]
				if x_nextopp<x: x,x_nextopp=x_nextopp,x
				next_game.add((x,x_nextopp))

			if now_y<N-2:
				now_y+=1
				Now[y]=now_y
				y_nextopp=A[y][now_y]
				if y_nextopp<y: y,y_nextopp=y_nextopp,y
				next_game.add((y,y_nextopp))

	game=next_game
	day+=1


for i in range(1,N+1):
	if Now[i] != N-2:
		print -1
		quit()
else:
	print day


Measured memory_bytes: 42780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;




int main() {

	double a;
	cin >> a;
	int y=sqrt(a);
	cout << y*y << endl;



		return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

class Point
{
public:
    lint x, y, step;
    Point(lint y, lint x, lint step) : y(y),
                                       x(x),
                                       step(step)
    {
    }

    Point(){};
};

bool inside(lint y, lint x, lint h, lint w)
{
    if (0 <= y && y < h && 0 <= x && x < w)
        return true;
    else
        return false;
}

int main()
{
    lint h, w;
    scanf("%lld", &h);
    scanf("%lld", &w);
    std::vector<std::vector<lint>> maze(h, std::vector<lint>(w, 0));
    for (int i = 0; i < h; ++i)
    {
        std::string s;
        std::cin >> s;
        for (int j = 0; j < w; ++j)
        {
            if (s[j] == '.')
                maze[i][j] = 1;
        }
    }

    std::vector<std::vector<lint>> seen(h, std::vector<lint>(w, 0));

    std::deque<Point> q;
    q.push_back(Point(0, 0, 0));
    seen[0][0] = 1;

    std::vector<std::pair<lint, lint>> next;
    next.emplace_back(1, 0);
    next.emplace_back(0, 1);
    next.emplace_back(-1, 0);
    next.emplace_back(0, -1);

    lint goal_step = -1;

    while (!q.empty())
    {
        auto cur = q.front();
        q.pop_front();

        for (auto n : next)
        {
            lint next_y = cur.y + n.first;
            lint next_x = cur.x + n.second;
            if (next_y == h - 1 && next_x == w - 1)
            {
                goal_step = cur.step + 1;
                break;
            }
            if (inside(next_y, next_x, h, w) && seen[next_y][next_x] == 0 && maze[next_y][next_x] == 1)
            {
                seen[next_y][next_x] = 1;
                q.push_back(Point(next_y, next_x, cur.step + 1));
            }
        }
        if (goal_step > 0)
            break;
    }

    if (goal_step < 0)
    {
        printf("%lld", -1ll);
        return 0;
    }

    lint white_num = 0;
    for (auto row : maze)
    {
        white_num += std::count(row.begin(), row.end(), 1);
    }

    printf("%lld", white_num - goal_step - 1);

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    if(n%2 == 0){
                        cout<<"-1";
                        return ;
                    }
                    ll k = 7;
                    ll cnt = 1;
                    while(true){
                        if(k%n == 0){
                            cout<<cnt;
                            break;
                        }
                        if(cnt > n){
                            cout<<"-1";
                            break;
                        }
                        k = (k%n)*10 +7;
                        // cout<<k<<"\n";
                        ++cnt;
                    }
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}   

Measured memory_bytes: 3652
a, b, c, k = map(int, input().split())

# print(min(k, a) - max(c-(k-a-b), (k-a-b)))

# k-(k-a)
#
ans = 0
if k <= a:
    ans += k
else:
    ans += a
    k -= a
    if k <= b:
        ans += k*0
    else:
        k -= b
        if k <= c:
            ans -= k
        else:
            k -= c
            ans -= k

print(ans)


Measured memory_bytes: 9120
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion


//ABC 121 C - Energy Drink Collector
static int a[100001][2];
	int main(void) {
		int n, m,i;

		scanf("%d %d\n", &n,&m);
		for (i = 0; i < n; i++)
			scanf("%d %d", &a[i][0],&a[i][1]);


		qsort(a, n, sizeof(int)*2, i_asort);

		ll c = 0,ans=0;
		for (i = 0; i < n;i++) {
			c += a[i][1];
			ans += (ll)a[i][0]*a[i][1];
			if (c >= m) break;
		}
    
	if (c > m) ans -= ((c-m) * a[i][0]);
	printf("%lld\n", ans); return 0;

	return 0;

}




Measured memory_bytes: 3104
n,m,x,y=list(map(int,input().split()))
line1=list(map(int,input().split()))
line2=list(map(int,input().split()))
t=0
try:
    for i in range(x+1,y+1):
        c=0
        s=0
        for j in line1:
            if (i<=j):
                c+=1
            
        for j in line2:
            if(i>j):
                s+=1
              
        if ( c==0 and s==0):
            t=t+1
           
    
    if(t==0):
        print('War')
    if(t!=0):
        print('No War')
        
except:
    print('War')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
typedef long long ss;
 int main()
{
   start;
   ss n,m,k,i,j,s,ans=0,c=0;
   cin >> n >> m >> k;
   ss a[n+2]={0},b[m+2]={0};
   for(i=1;i<=n;i++)
   {
       cin>>s;
       a[i]=a[i-1]+s;
   }
   for(i=1;i<=m;i++)
   {
       cin>>s;
       b[i]=b[i-1]+s;
   }
   for(i=0;i<=n;i++)
   {
       for(j=m-c;j>=0;j--)
       {
           if(a[i]+b[j]<=k)
           {
               ans=max(ans,(i+j));
               break;
           }
           c++;
       }
   }
    cout<<ans<<endl;
 return 0;
}



Measured memory_bytes: 6780