akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int a, b;
	cin >> a >> b;

	if (a <= 8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

bool f(unsigned long long b, unsigned long long n, unsigned long long s) {
  unsigned long long k = 0;
  while (n) {
    k += n % b;
    n /= b;
  }
  return k == s;
}

int main() {
  unsigned long long n, s;
  std::cin >> n >> s;
  if (n < s) {
    std::cout << -1;
    return 0;
  }
  for (unsigned long long i = 2; i < std::sqrt(n) + 1; ++i) {
    if (f(i, n, s)) {
      std::cout << i;
      return 0;
    }
  }
  std::vector<unsigned long long> ans;
  for (unsigned long long i = 1; i < std::sqrt(n) + 1; ++i) {
    if ((n - s) % i) { continue; }
    auto k = (n - s) / i + 1;
    if (k > 1 && f(k, n, s)) {
      ans.push_back(k);
    }
  }
  if (!ans.empty()) {
    std::sort(ans.begin(), ans.end());
    std::cout << ans[0];
    return 0;
  }
  if (s == n) {
    std::cout << n + 1;
    return 0;
  }
  std::cout << -1;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N,T = list(map(int,input().split()))

ct = np.array([list(map(int,input().split())) for _ in range(N)])

cost_min = max(ct[:,0])
ans = "TLE"
for ct0 in ct:
    cost_i = ct0[0]
    time_i = ct0[1]
    if time_i <= T:
        if cost_i <= cost_min:
            cost_min = cost_i
            ans = cost_min

print(ans)

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

using namespace std;
using ll = long long;

int main() {
	int H, W, N, sr, sc;
	cin >> H >> W >> N >> sr >> sc;
	string s, t;
	cin >> s >> t;

	bool ok = true;
	int l = 1, r = W;
	int u = 1, d = H;
	for (int i = N - 1; i >= 0; --i) {
		if (t[i] == 'R') { l = max(1, l - 1); }
		if (t[i] == 'L') { r = min(W, r + 1); }
		if (t[i] == 'D') { u = max(1, u - 1); }
		if (t[i] == 'U') { d = min(H, d + 1); }

		if (s[i] == 'R') { r -= 1; }
		if (s[i] == 'L') { l += 1; }
		if (s[i] == 'D') { d -= 1; }
		if (s[i] == 'U') { u += 1; }
		
		ok = ok && (l <= r);
		ok = ok && (u <= d);
	}
	ok = ok && ((l <= sc) && (sc <= r)) && ((u <= sr) && (sr <= d));

	if (ok) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


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


vector<int> a(50),b(50),c(50),d(50);
int n,m,k,ans= -1;


void solve(vector<int> &v){
	
	if(v.size() == n){
		int maxa = 0;
		for(int i=0;i<k;i++){
			if(v[b[i]] - v[a[i]] == c[i]){
				maxa += d[i];
			}
		}
		ans = max(maxa,ans);
		return ;
	}
	
	int start = 1;
	if(v.size())
		start = v.back();
	for(int i=start;i<=m;i++){
		v.push_back(i);
		solve(v);
		v.pop_back();
	}
	
	
	
}





int main(){
  
	
	cin>>n>>m>>k;
	for(int i=0;i<k;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i] -= 1;
		b[i] -= 1;
	}
	vector<int> v;
	solve(v);
	cout<<ans<<endl;
	
	
	
  
  
  
  
	return 0; 
  
}

Measured memory_bytes: 3572
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      int max = -1;
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextInt() - i - 1;
        max = Math.max(max, arr[i] + i + 1);
      }
      int left = -1 * max;
      int right = max;

      while(left < right) {
        int mid1 = left + (right - left) / 3;
        int mid2 = right - (right - left) / 3;
        long leftRes = cal(arr, mid1);
        long rightRes = cal(arr, mid2);
        if(leftRes < rightRes)
          right = mid2 - 1;
        else if (leftRes > rightRes)
          left = mid1 + 1;
        else {
          left = mid1 + 1;
          right = mid2;
        }
      }
      
      System.out.println(cal(arr, left));
  }

  private static long cal(int[] arr, int b) {
    long sum = 0;
    for(int a : arr) {
      sum += Math.abs(a - b);
    }
    return sum;
  }
}

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

int main() {
  string s,t;
  cin >> s >> t;
  
  int num = s.size();
  bool jud = false;
  
  for (int i=0; i<s.size(); i++){
    string temp =s.at(num-1) + s.substr(0,num-1);
    if (temp == t) jud = true;
    s = temp;
  }
  
  if (jud) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):
    cur = sum(A)
    for i in range(N-1,-1,-1):
        if cur>K: cur -= A[i]
        else:break
    if cur==0:
        max_k = 0
        l = 0
    else:
        max_k = i+1
        l = 1
    max_pk = max_k

    p = 0
    while(p<M):
        if cur+B[p] <= K:
            cur+=B[p]
            max_k = max_pk+p+1
            p+=1
        else:
            break

    # print(cur,max_k)
    if l ==1:
        for q in range(i,-1,-1):
            cur -= A[q]
            while(p<M):
                if cur+B[p] <= K:
                    cur+=B[p]
                    max_k = max(q+p+1, max_k)
                    p+=1
                else:
                    break
    print(max_k)





    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    const auto MAX = 1e5+1;
    // setup
    vector<int> cnt(MAX,0);
    vector<bool> is_prime(MAX,true);
    is_prime[0] = false;
    is_prime[1] = false;
    FOR(i,2,MAX) {
        if(!is_prime[i]) continue;
        int k = i + i;
        while(k < MAX) {
            is_prime[k] = false;
            k += i;
        }
    }

    FOR(i,1,MAX) {
        if(i%2) {
            if(is_prime[i] && is_prime[(i+1)/2]) cnt[i] = cnt[i-1]+1;
            else cnt[i] = cnt[i-1];
        }
        else cnt[i] = cnt[i-1];
    }
    int Q;
    cin >> Q;
    REP(_,Q) {
        int l,r;
        cin >> l >> r;
        if(l!=1) l -=2;
        cout << cnt[r] - cnt[l] << endl;
    }

}

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

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            abc112_a();
        }

        static void abc112_a()
        {
            // A - Programming Education
            int age = int.Parse(Console.ReadLine());
            if (age == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                int ans = a + b;
                Console.WriteLine(ans);
            }
        }
    }
}

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

int main() {
    int a, b, ans = 0;
    cin >> a >> b;
    for(int i = a; i <= b; i++) {
        string str = to_string(i);
        if(str.at(0) == str.at(4) && str.at(1) == str.at(3)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll count=0;
    ll k=1;
    vector<vector<pll>> e(20);
    for(int i=0;i<18;i++){
        e[i].push_back({i+1,0});
        e[i].push_back({i+1,k});
        count+=2;
        k<<=1;
    }
    ll K=0;
    ll l;
    cin>>l;
    if(l>>19&1){
        e[18].push_back({19,0});
        e[18].push_back({19,k});
        count+=2;
        K=k*2;
    }
    for(int i=18;i>=0;i--){
        if(l>>i&1){e[i].push_back({19,K}); count++; K+=1LL<<i;}
    }
    cout<<20<<" "<<count<<endl;
    for(int i=0;i<20;i++){
        for(int t=0;t<e[i].size();t++){
            cout<<i+1<<" "<<e[i][t].F+1<<" "<<e[i][t].S<<endl;
        }
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		ArrayList<Integer> one_pos = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			final int val = sc.nextInt();
			
			if(val == 1){
				one_pos.add(i);
			}
		}
		
		int[] runs = new int[m];
		for(int i = 0; i < m; i++){
			runs[i] = sc.nextInt();
		}
		
		int answer = Integer.MAX_VALUE;
		for(int i = 0; i < 2; i++){
			boolean bit = (i == 1);
			
			ArrayList<Integer> answer_one_pos = new ArrayList<Integer>();
			int sum = 0;
			for(int j = 0; j < m; j++){
				if(bit){
					for(int k = 0; k < runs[j]; k++){
						answer_one_pos.add(sum + k);
					}
				}
								
				sum += runs[j];
				bit = !bit;
			}
			//System.out.println(one_pos + " " + answer_one_pos);
			if(one_pos.size() != answer_one_pos.size()){
				continue;
			}
			
			int score = 0;
			for(int j = 0; j < one_pos.size(); j++){
				score += Math.abs(one_pos.get(j) - answer_one_pos.get(j));
			}
			
			answer = Math.min(answer, score);
		}
		
		System.out.println(answer);
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
 
}

Measured memory_bytes: 24452
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    inl(X, Y);

    if (abs(X - Y) <= 1)
        out("Brown");
    else
        out("Alice");
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int a[400];
LL dp[400][400];    //! [head][tail] minimal cost to merge slimes from head to tail
LL sum[400][400];   //! [head][tail] total size of merged slime from head to tail

LL solve(int head, int tail)
{
    LL ret = dp[head][tail];
    if (!ret) {
        if (head == tail) {
            ret = 0;
        } else if (head+1 == tail) {
            ret = a[head] + a[tail];
        } else {
            //! final merge is done between head and head+1
            ret = a[head] + sum[head+1][tail] + solve(head+1, tail);
            for (int h = head+1; h < tail; ++h) {
                //! final merge is done between h and h+1
                LL x = solve(head, h) + solve(h+1, tail) + sum[head][h] + sum[h+1][tail];
                ret = min(ret, x);
            }
        }
        dp[head][tail] = ret;
        // cout << "dp[" << head << "][" << tail << "] = " << dp[head][tail] << endl;
    }
    return ret;
}

int main()
{
    int N;
    cin >> N;
    rep(i, N) cin >> a[i];

    for (int h = 0; h < N; ++h) {
        LL s = a[h];
        sum[h][h] = s;
        for (int t = h+1; t < N; ++t) {
            s += a[t];
            sum[h][t] = s;
        }
    }

    cout << solve(0, N-1) << endl;

    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=i;
	ans-=n;
	cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long s=0,i;
    string a;
    cin>>a;
    for(i=0;i<a.size();i++)
    {
        s=s+a[i]-'0';
    }
    if(s % 9 ==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");

    }
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using graph = vector<vi>;
const int MAXN = 112345;
const ll mod = 1000000007;
int pai[MAXN];
ll dp[2][MAXN];
bool seen[2][MAXN];
graph g;

ll dfs(int u, int c) {
    ll b = 1, w = 1;
    bool folha = 1;
    if (seen[c][u]) return dp[c][u];
    for (auto v : g[u]) {
        if (pai[u] == v) continue;
        pai[v] = u;
        if (c == 1) {
            w = w * dfs(v, 0) % mod;
        } else {
            w = w * dfs(v, 0) % mod;
            b = b * dfs(v, 1) % mod;
        }
        folha = 0;
    }
    if (folha) return c == 0 ? 2 : 1;
    seen[c][u] = 1;
    return dp[c][u] = c ? w : (b+w)%mod;
}
int main() {
    int n, m, k;
    scanf("%d", &n);
    g.assign(n+1, vi());
    for (int i = 1, u, v; i<n; ++i) {
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }

    printf("%lld\n", dfs(1, 0));

}



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

using namespace std;

int main() {
    /*int a,b,h,s;
    cin >> a >> b >> h;
    
    s=(a+b)*h/2;
    
    cout << s << endl;*/
    
    /*int N,A,B;
    cin >> N >> A;
    B=N*N-A;
    
    cout << B << endl;*/
    
   /* int A,B,C,D,s1,s2;
    cin >> A >> B >> C >> D;
    
    s1=A*B;
    s2=C*D;
    
    if(s1>s2){
        cout << s1 << endl;
    }
    else if(s1<s2){
        cout << s2 << endl;
    }
    else{
        cout << s1 << endl;
    }*/
    
   /* int a,b,c,s;
    cin >> a >> b >> c;
    
    s=0;
    if(a!=b){
        s=s+1;
    }
    if(a!=c){
        s=s+1;
    }
    if(b!=c){
        s=s+1;
    }
    if(a==b&&a==c&&b==c){
        s++;
    }
    cout << s << endl;*/
    
    int N,K,X,Y,s;
    cin >> N >> K >> X >> Y;
    
    if(N>K){
        s=K*X+Y*(N-K);
    }
    
    
    
    else if(N<=K){
        s=N*X;
    }
    
    cout << s << endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

int main(){
  int n,m,x; cin>>n>>m>>x;
  vector<int> a(n);
  for (int i=0; i<m; i++) cin>>a[i];
  sort(a.begin(), a.end());
  
  auto iter=upper_bound(a.begin(), a.end(), x);
  int ans2=a.end()-iter;
  int ans1=m-ans2;
  cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int n,a[1000] = {};
	cin >> n;
	for (int i=1;i<=n;i++) {
		int d=i;
		for (int j=2;j<=i;j++) {
	      	if (i%j==0) {
    	    	while( d%j == 0 ) {
        			d/=j;
        			a[j-1]++;
        		}
			}
		}
	}
	long long c=1;
	for (int i=0;i<1000;i++) c*=a[i]+1,c%=1000000007;
	cout << c; 
}

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

using namespace std;

int main() {
    string x, y;
    cin >> x >> y;
    if (x[0] == y[2] && x[1] == y[1] && x[2] == y[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define N 200000
#define M 100

int main(){
	 int n, i, j,k,flag = 0, ans = 0;

	cin >> n;
	cin >> i >> j;

	for (k = i; k <= j; k++) {
		if ((k % n) == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	
	return 0;
}

Measured memory_bytes: 3632
a, b, c, d = map(int, input().split())

if a <= b <= c:
    if max(b - a, c - b) <= d:
        ans = 'Yes'
    else:
        ans = 'No'

elif c <= b <= a:
    if max(a - b, b - c) <= d:
        ans = 'Yes'
    else:
        ans = 'No'

else:
    if abs(c - a) <= d:
        ans = 'Yes'
    else:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 9132
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=998244353;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y;
        y.a=n;
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>=MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,s;
    in>>n>>s;
    vector<int> a(n);
    fr(i,n) in>>a[i];
    vector<modint> dp(s+1);
    modint ans{};
    dp[0]=1;
    fr(i,n){
        if(a[i]<=s){
            for(int j=s;j>a[i];--j) dp[j]+=dp[j-a[i]];
            dp[a[i]]+=i+1;
            ans+=dp[s]*(n-i);
            dp[s]=0;
        }
    }
    cout<<ans<<endl;
}

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

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

int main(){
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a>=0){
		if(d>=0) cout << b*d << endl;
		else cout << a*d << endl;
	}
	else if(c>=0){
		if(b>=0) cout << b*d << endl;
		else cout << b*c << endl;
	}
	else{
		LL ans=max(a*c,b*d);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
[解説AC]
1. k>=2**mのとき
明らかに-1
2. m=0のとき
同じ数2つなのでxorは必ず0
3. m=1のとき
k=0なら2種類の数を2つずつ並べる
k!=0なら2種類の数2つずつの並べ方はk=0の場合の並べ方以外で
2種類(交互に並べる,片方の種類の数の間にもう一方の数2枚)
交互に並べる場合,明らかにxorが異なる⇒×
片方の種類の数の間にもう一方の数2枚,明らかにxor=0になる⇒×
つまり、k!=0のとき-1
4.m>=2のとき
k以外の0以上2**m未満の数を昇順に並べる⇒bとする
k以外の0以上2**m未満の数を降順に並べる⇒cとする
bkckと並べると常にxor=kを満たす
k以外の0以上2**m未満の数の任意の数について、その間にはkが1つと
他の数が常に2つずつ入っている⇒xorは必ずk
kについて、間にはcがあるが、cはk以外の0以上2**m未満の数であり、
kが2つとc⇒0以上の2**未満の数とkのxor
0以上2**m未満の数については(2**m)-1が偶数個作れるため0であり、0xork=k
"""

m,k = LI()

if k >= 2**m:
    print(-1)
    quit()
if m == 0:
    if k == 0:
        print(0,0)
    else:
        print(-1)
elif m == 1:
    if k == 0:
        ans = [i for i in range(2**(m+1))]
        ans = [i//2 for i in ans]
        print(*ans)
    else:
        print(-1)
else:
    ans = [i for i in range(2**m) if i != k]
    ans = ans + [k] + ans[::-1] + [k]
    print(*ans)

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

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

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

    ll x2 = 0;
    rep(i, 0, n)
    {
        if (i % 2 == 0)
            x2 += a[i];
        else
            x2 -= a[i];
    }

    vector<ll> ans(n, 0);
    // 答えの半分の値
    ans[0] = x2 / 2;
    rep(i, 0, n - 1)
    {
        ans[i + 1] = a[i] - ans[i];
    }
    rep(i, 0, n) ans[i] *= 2;
    rep(i, 0, n) printf("%lld%c", ans[i], i == n - 1 ? '\n' : ' ');
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    
    if ('A' <= st[0] && st[0] <= 'Z') {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

  vector<int64_t> NUM(K, 0);
  for (int i = 1; i <= N; i++) {
    NUM[i % K]++;
  }

  int64_t Ans = 0;
  for (int a = 0; a < K; a++) {
    int b = (K - a) % K;
    int c = (K - a) % K;
    if ((b + c) % K)
      continue;
    Ans += (NUM[a] * NUM[b] * NUM[c]);
  }
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int N; cin >> N;
    vi A(N); for (int i = 1; i < N; i++) cin >> A[i];
    vi V(N+1, 0);

    for (int i = 1; i < N; i++) {
        V[A[i] - 1]++;
    }

    rep (i, N) cout << V[i] << endl;
    return 0;
}

Measured memory_bytes: 4768
//mondai niha saigo ni kaigyou wo ireru toha kaitearimasendesitaga
//saigo ni kaigyou wo irenai to presentation error ni narimasu.
//kiwotukemasyou(^^)

#include <stdio.h>
int main(void){
  
  int n;
  scanf("%d",&n);
  int a[n];
  int i;

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

Measured memory_bytes: 600
sx,sy,tx,ty = map(int,input().split())
st = "U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)
st += "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(st)

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

int main(){
  int N;
  int sum = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
    if ( i == N - 1 ) {
      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int N, A, B, C;
vector<int> l(8);
int answer = INT_MAX;

// 深さ優先探索
// n : 階層
// cost : コスト
// a : A竹の長さ
// b : B竹の長さ
// c : C竹の長さ
void depthFirstSearch(int n, int cost, int a, int b, int c)
{
	// 深さがn == Nになった場合
	if (n == N)
	{
		if (a == 0 || b == 0 || c == 0)
		{
			return;
		}
		//  3 本の長さが a, b, c となったとき、A, B, C との差分をとって総コストの計算
		cost += abs(A - a) + abs(B - b) + abs(C - c);
		// 長さ0の竹に合成のコストはかからないための対応
		cost -= 10 * 3;
		// 最小のコストの計算を行う。
		answer = min(cost, answer);
		
		return;
	}
	
	// Aの竹のコスト計算、Bの竹のコストの計算、Cの竹のコストの計算、使わない場合のコスト計算
	depthFirstSearch(n + 1, cost + 10, a + l[n], b, c);
	depthFirstSearch(n + 1, cost + 10, a, b + l[n], c);
	depthFirstSearch(n + 1, cost + 10, a, b, c + l[n]);
	depthFirstSearch(n + 1, cost, a, b, c);
}

int main()
{
	// 入力
	cin >> N >> A >> B >> C;
	for(int i = 0; i < N; i++)
	{
		cin >> l[i];
	}
	
	// 深さ優先探索を用いて、全検索を行う
	depthFirstSearch(0, 0, 0, 0, 0);
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

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

int main() {

    int A, B, C, K;
    scanf("%i", &A);
    scanf("%i", &B);
    scanf("%i", &C);
    scanf("%i", &K);

    if (A >= K) {
        printf("%i", K);
        return 0;
    }

    int sum = A;

    K -= A;
    K -= B;

    printf("%i", sum-abs(K));

}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define test() ll t;cin>>t;while(t--)
int main()
{
	ll n;
	cin>>n;
	vector<ll> people(n);
	for(int i=0;i<n;i++)
	{
		cin>>people[i];
	}
	ll min=10e18;
    sort(people.begin(),people.end());
	for(int i=people[0];i<=people[n-1];i++)
	{
		ll anstemp=0;
		for(int j=0;j<n;j++)
			{
				anstemp+=(i-people[j])*(i-people[j]);
			}
			if(anstemp<=min)
			{
				min=anstemp;
			}
	}
	cout<<min;
	
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define rrep(i, a, b) for (int i = b - 1; i >= int(a); i--)

using namespace std;

using ll = long long;
using vi = vector<int>;

bool exor(bool a, bool b) {
    if ((a && b) or (!a && !b)) {
        return false;
    } else {
        return true;
    }
}

int main() {
    string tmp;
    int Q;
    cin >> tmp >> Q;

    deque<char> S;
    rep(i, 0, tmp.size()) { S.push_back(tmp[i]); }

    bool forward = true;
    rep(i, 0, Q) {
        int t;
        cin >> t;

        if (t == 1) {
            forward = !forward;
        } else {
            int f;
            char c;
            cin >> f >> c;

            if (exor(f == 1, forward)) {
                S.push_back(c);
            } else {
                S.push_front(c);
            }
        }
    }

    if (forward) {
        while (!S.empty()) {
            cout << S.front();
            S.pop_front();
        }
    } else {
        while (!S.empty()) {
            cout << S.back();
            S.pop_back();
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 896
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

r = SORO_INT()
x = 3*r*r
print(x)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#define ll long long

int dp[64][64];
char str[50];

int main(void){
  int n;
  scanf("%d",&n);
  ll ans = 0;
  for(int i = 0;i<n;i++){
    scanf("%s",str);  
    ll tmp = 0;
    int len = strlen(str);
    int cnt = 0;
    int pt = 0;
    for(int j = 0;j<len;j++){
      if(str[j] == '.'){
        pt = 1;
      }else{
        tmp += str[j] - '0';  
        tmp *= 10;
        if(pt)cnt++;
      };
    };
    tmp /= 10;
    for(int j = cnt;j<9;j++){
      tmp *= 10;  
    };
    //printf("%lld\n",tmp);
    int zw = 0;
    int fw = 0;
    ll ttmp = tmp;
    while(ttmp > 0 && ttmp % 5 == 0){
      fw++;
      ttmp /= 5;  
    };
    ttmp = tmp;
    while(ttmp > 0 && ttmp % 2 == 0){
      zw++;  
      ttmp /= 2;
    };
    //printf("%d %d\n",zw,fw);
    for(int k = 0;k<64;k++){
      for(int j = 0;j<64;j++){
        if(k + zw >= 18 && j + fw >= 18){
          ans += dp[k][j];
        };
      };  
    };
    dp[zw][fw]++;
  };
  printf("%lld\n",ans);
  return 0;
};


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

matP G(100010, vp(0));
vec dist(100010,0);
vector<bool> used(100010,false);
void dfs(ll to){
    used[to] = true;
    for(P p : G[to]){
        if(!used[p.fi]){
            dist[p.fi] += dist[to] + p.se;
            dfs(p.fi);
        }
    }
}

int main() {
    cin>>N;
    rep(i,N-1){
        cin>>A>>B>>C;
        --A; --B;
        G[A].emplace_back(B,C);
        G[B].emplace_back(A,C);
    }
    cin>>Q>>K;
    --K;
    dfs(K);
    rep(i,Q){
        cin>>A>>B;
        --A; --B;
        cout<<dist[A] + dist[B]<<endl;
    }
}

Measured memory_bytes: 14336
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
int main()
{
	int n,a,A;
	while(~scanf("%d",&n))
	{
		int max=1;
		a=sqrt(n);
		for(int i=1;i<=a;i++)
		{
			A=i;
			for(int j=1;j<10;j++)
			{
				A=A*i;
				if(A>max&&A<=n)
				max=A;
			}	
		}
		printf("%d\n",max);
	}
}


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

int W, H;
string P[60];

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

set<int> done;

pair<double,int> dfs(int X, int Y)
{
	int xl = X, xr = X;

	queue<int> que;
	que.push(Y * 100 + X);
	double sum = 0;
	int num = 0;
	while (!que.empty())
	{
		int p = que.front(); que.pop();
		if (done.find(p) != done.end()) continue;
		done.insert(p);

		int y = p / 100;
		int x = p % 100;

		sum += (double)x + 0.5;
		num++;

		if (Y == H - 1)
		{
			if (y == H - 1)
			{
				xl = min(xl, x);
				xr = max(xr, x);
			}
		}
		else
		{
			if (P[y + 1][x] == P[Y + 1][X])
			{
				xl = min(xl, x);
				xr = max(xr, x);
			}
		}

		rep(i, 0, 4)
		{
			int xx = x + dx[i];
			int yy = y + dy[i];
			if (xx < 0 || W <= xx) continue;
			if (yy < 0 || H <= yy) continue;
			if (P[yy][xx] == '.') continue;

			if (P[yy][xx] == P[y][x])
			{
				que.push(yy * 100 + xx);
			}
			else
			{
				if (x != xx) continue;
				if (y + 1 == yy) continue;

				if (done.find(yy*100+xx) != done.end()) continue;

				auto pp = dfs(xx, yy);
				if (pp.second == 0) return pair<double, int>(0, 0);

				sum += pp.first;
				num += pp.second;
			}
		}
	}

	xr++;

	double G = sum / (double)num;
	bool a = (double)xl < G - EPS;
	bool b = G < (double)xr - EPS;
	if(!(a && b)) return pair<int, int>(0, 0);
	return pair<double,int>(sum,num);
}

bool solve()
{
	done.clear();

	rep(x, 0, W) if (P[H - 1][x] != '.')
	{
		auto p = dfs(x, H - 1);
		if (p.second == 0)
			return false;
		else
			return true;
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	while (cin >> W >> H)
	{
		if (W == 0) return 0;

		rep(y, 0, H) cin >> P[y];

		if (solve())
			cout << "STABLE" << endl;
		else
			cout << "UNSTABLE" << endl;
	}
}

Measured memory_bytes: 3248
N = int(input())

a = list(map(int, input().split(" ") ) )
b = list(map(int, input().split(" ") ) )
c = list(map(int, input().split(" ") ) )
score = 0
for i in range(N):
    now = a[i]
    if i > 0:
        if now == before + 1:
          score += (b[a[i]-1] + c[before-1])
          before = now
          continue
    score += b[now-1]
    before = now
print(score)

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  int cnt=0,mx=0;
  for(int i=0;i<n-1;i++){
	if( h.at(i) >= h.at(i+1) ){
      cnt++;
      mx = max(mx,cnt);
    }else{
      mx = max(mx,cnt);
      cnt = 0;
    }
  }
  
  cout << mx << endl;
    
      
  return 0;
}


Measured memory_bytes: 768
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int nagasa = scan.nextInt();
		int[] num = new int[nagasa];
		for(int i=0;i<nagasa;i++){
			num[i] = scan.nextInt();
		}
		for(int i=0;i<nagasa;i++){
			System.out.print(num[i]);
			if(i == nagasa-1){
				System.out.println("");
			}
			else{
				System.out.print(" ");
			}
		}
		for (int i=1;i <= nagasa-1;i++){
			int v = num[i];
			int j = i - 1;
			while(j >= 0 && num[j] > v){
				num[j+1] = num[j];
				j -= 1;
			}
			num[j+1] =v;
			for(int ii=0;ii<nagasa;ii++){
				System.out.print(num[ii]);
				if(ii == nagasa-1){
					System.out.println("");
				}
				else{
					System.out.print(" ");
				}
			}
		}
	}
}

Measured memory_bytes: 34292
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int a,b;
  int ans=1;
  cin >> a >> b;
  if(b==1){cout << 0 << endl;
  return 0;}
  for(int i=1;i<21;i++){
    ans+=a-1;
    if(b<=ans){cout << i << endl;
    return 0;}
  }

}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

ans = 0
if N%2==1:
    print(0)
    exit(0)
for i in range(1, 40):
    cnt = N//(5**i)
    ans += cnt//2
print(ans)

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

int main(){
    string s; cin>>s;
    bool flag = 1;
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='L') flag = 0;
        }
        if(i%2==1){
            if(s[i]=='R') flag = 0;
        }
    }
    cout << (flag?"Yes":"No")<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int count1 = 0;
  for(int i=1;i<=N;i++){
    int count2 = 0;
    for(int j=1;j<=N;j++){
      if(i%j==0){
        count2++;
      }
    }
    if(count2 == 8 && i%2!=0){
      count1++;
    }
  }
  cout<<count1<<endl;
  return 0;
}

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

path = [[0]*(N+1) for _ in range(N+1)]

for i in range(M):
    a,b = map(int,input().split())
    path[a][b] = 1
    path[b][a] = 1

visited = [0]*(N+1)

def dfs(now,depth):
    if visited[now]:
        return 0
    if depth == N:
        return 1 # 最後まで探索したらはじめて+1
    
    visited[now] = 1
    
    total_paths = 0
    
    for i in range(1,N+1):
        if path[now][i]:
            total_paths += dfs(i, depth + 1)
            
    visited[now] = 0
    
    return total_paths

print(dfs(1,1))

Measured memory_bytes: 9220
#ユークリッド要復習
from sys import stdin
INF = 10**9 + 7
flag = 0
ans = 0
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        tmp = a
        a = b
        b = tmp
        u -= t * v
        tmp = u
        u = v
        v = tmp
    u %= m
    if u < 0:
        u += m
    return u
s = int(stdin.readline().rstrip())
if s < 3:
    ans = 0
    flag = 1
n = s // 3#ケタ
for i in range(1, n):
    if flag == 1:
        break
    t = s - 3 * (i+1)
    a = 1
    b = 1
    for j in range(0, i):
        a = (a * (i + t - j)) % INF
        if i-j != 0:
            b = (b * (i - j)) % INF
    b2 = modinv(b, INF)
    ans = (ans + (a * b2) % INF) % INF
if flag != 1:
    ans = (ans + 1) % INF
print(ans)

Measured memory_bytes: 68288
<?php
fscanf(STDIN, '%d %d %d %d', $N, $M, $X, $Y);
$XsHope = explode(' ', trim(fgets(STDIN)));
$YsHope = explode(' ', trim(fgets(STDIN)));
for ($i=$X; $i <= $Y; $i++) {
  if (max($XsHope) < $i && min($YsHope) >= $i && $i > $X && $i <= $Y) {
    echo "No War\n";
    exit;
  }
}
echo "War\n";


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  REP(i,N) cin >> a[i];

  vector<int> b(N);
  REP(i,N) b[i] = max(0, a[i]);
  vector<ll> cuma(N + 1, 0), cumb(N + 1, 0);
  REP(i,N) cuma[i + 1] = cuma[i] + a[i];
  REP(i,N) cumb[i + 1] = cumb[i] + b[i];

  ll res = 0;
  for(int i = K; i <= N; ++i) {
    ll tmp1 = cumb[i - K] + cumb[N] - cumb[i] + cuma[i] - cuma[i - K];
    ll tmp2 = cumb[i - K] + cumb[N] - cumb[i];
    res = max(res, tmp1);
    res = max(res, tmp2);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a < b && b < c){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100
program main
   implicit none
   integer n,h,w
   integer i,counter
   integer,allocatable,dimension(:)::a,b
   read(*,*)n,h,w
   allocate(a(n),b(n))
   do i=1,n
      read(*,*)a(i),b(i)
   enddo
   counter=0
   do i=1,n
      if(a(i)>=h .and. b(i)>=w)counter=counter+1
   enddo
   write(*,*)counter
end program main


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

int main()
{
	string s1,s2;
	int ans=0;
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	 if(s1[i]!=s2[i])
		ans++;
	
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3860
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  long count[n];
  long com[n],com_minus[n];
  F(k,0,n){
    count[k]=0;
    com[k]=0;
    com_minus[k]=0;
  }
  F(i,0,n){
    scanf("%d",a+i);
    count[a[i]-1]++;
  }
  long sumcom=0;
  F(l,0,n){
    if(count[l] != 0){
      com[l]=(count[l]*(count[l]-1))/2;
      com_minus[l]=((count[l]-1)*(count[l]-2))/2;
    }
    sumcom += com[l];
  }
  F(i,0,n){
    printf("%ld\n",sumcom-com[a[i]-1]+com_minus[a[i]-1]);
  }
  return 0;
}

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

using namespace std;

int main() {
	string a, b; cin >> a >> b;
	string sum = a + b;
	int Sum = stoi(sum);

	for(int i = 1; i <= Sum; i++) {
		if(i*i == Sum){
			cout << "Yes" << endl;
			return 0;
		}	
	}
	cout << "No" << endl;
}

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

using namespace std;

int main(void){
    string n;

    cin >> n;

    for(auto c : n){
        if(c == '7'){
            cout << "Yes"<< endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
using namespace std;
int main()
{
	int a, b, c, d, e, i, j, k, l, m, n, o, p, q, r;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> i;
	cin >> j;
	cin >> k;
	d += a;
	d += b;
	d += c;
	k += e;
	k += i;
	k += j;
	cout << max(k, d) << endl;
	return 0;
}

Measured memory_bytes: 1160
N, K = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

def sum_num(n):
    return (n*(n+1))//2

for k in range(K, N+1):
    min_sum = sum_num(k-1)
    max_sum = sum_num(N) - sum_num(N-k)
    # print(k, min_sum, max_sum)
    ans += max_sum - min_sum + 1

ans += 1
ans %= mod
print(int(ans))


Measured memory_bytes: 9192
n, m = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort()

ans = 0
for _ab in ab:
    if m == 0:
        break

    if _ab[1] <= m:
        ans += _ab[0]*_ab[1]
        m -= _ab[1]
    elif _ab[1] > m:
        ans += _ab[0]*m
        m = 0

print(ans)


Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  int minn = 1000;
  for(int i=0; i<s.size()-2; i++){
    int n = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
    minn = min(minn, abs(n-753));
  }
  cout << minn << endl;
}

Measured memory_bytes: 256
package main

//参考ページ
//https://qiita.com/zurazurataicho/items/e66645bac16d9a482369
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// 文字列を1行入力
func StrStdin() (stringInput string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput = scanner.Text()

	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

func main() {
	i, err := IntStdin()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(48 - i)
	}
}


Measured memory_bytes: 640
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, Counter
from sys import exit
import math


def main():
    n = getN()
    nums = getList()
    den = [num - i for i, num in enumerate(nums)]
    cnt = Counter(den)
    ans = 0
    for i in range(n-1):
        k1, k2 = nums[i], nums[i+1]
        su = k1 + k2
        tgt = den[i+1] - su + 1
        if tgt in cnt.keys():
            ans += cnt[tgt]
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 131448
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let mut txy = get!(i64, i64, i64; N);

    txy.insert(0, (0, 0, 0));
    // マンハッタン距離を求め、時間が間に合う、かつ、パリティが合うならば移動可能
    let ans = if (0..N).all(
        |i|
        {
            let (t1, x1, y1) = txy[i];
            let (t2, x2, y2) = txy[i + 1];
            let d = (x2 - x1).abs() + (y2 - y1).abs();
            let dt = t2 - t1;
            d <= dt && (dt - d) % 2 == 0
        }
    ) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 12540