akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define pb push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; };
int main()
{
    fast_IO;
    int k, x;
    cin >> k >> x;
    vi in;
    for (int i = x - 1; i > x - k; i--)
    {
        in.push_back(i);
    }
    for (int i = x; i < x + k; i++)
    {
        in.push_back(i);
    }
    sort(in.begin(), in.end());
    for (int &x : in)
    {
        cout << x << ' ';
    }
    cout << '\n';
}

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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
  	cout << "#";
  }
  cout << endl;
  
  string a;
  
  for (int j = 0; j < H; j++) {
  	cin >> a;
    cout << "#" << a << "#" << endl;
  }
  
   for (int k = 0; k < W + 2; k++) {
  	cout << "#";
  }
  
}


Measured memory_bytes: 764
# https: // onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_B
# クイックソートを理解するために必要な問題。まあやるだけ


def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


input()
A = list(map(int, input().split()))

idx = partition(A, 0, len(A) - 1)
A[idx] = f'[{A[idx]}]'
print(*A)



Measured memory_bytes: 16404
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int R, C, K; cin >> R >> C >> K;
	vector<vector<ll>> V(R + 1, vector<ll>(C + 1));
	for (int i = 0; i < K; i++) {
		ll r, c, v; cin >> r >> c >> v;
		V[r][c] = v;
	}

	vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(4)));
	for (int i = 0; i <= R; i++) {
		for (int j = 0; j <= C; j++) {
			for (int k = 0; k < 4; k++) {
				if (i + 1 <= R) {
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + V[i + 1][j]);
				}
				if (j + 1 <= C) {
					if (k < 3)dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + V[i][j + 1]);
					dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
				}
			}
		}
	}

	cout << max(max(dp[R][C][0], dp[R][C][1]), max(dp[R][C][2], dp[R][C][3])) << endl;
}


Measured memory_bytes: 707168
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll A, B, C, K;

void solve() {
	cin >> A >> B >> C >> K;
	cout << (K % 2 ? B - A : A - B) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

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

int main()
{
    vector<int> a(3);
    bool b = 0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());

    rep(i,2){
        if(a[i] == a[i+1]){
            b ^= 1;
        }
    }

    if(b){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)

n = int(input())
if n == 1:
    print(1)
else:
    edge=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int,input().split())
        edge[u-1].append((v-1,w%2))
        edge[v-1].append((u-1,w%2))
 
    color =[-1]*n
    def dfs(node,edge):
        for next_node,w in edge[node]:
            if color[next_node] != -1:
                continue
            if w == 1:
                color[next_node] = color[node]^1
            elif w == 0:
                color[next_node] = color[node]
            dfs(next_node,edge)
        
        
    color[0] = 0
    dfs(0,edge)
    print(*color,sep="\n")

Measured memory_bytes: 76464
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] = ((s[i] - 'A') + n) % 26 + 'A';
	}
	cout << s;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n  =sc.nextInt();
		int cnt[] = new int[100010];
		
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			cnt[a]++;
		}
		
		int ans = 0;
		for(int i= 1;i<100000;i++){
			ans = Math.max(ans, cnt[i] + cnt[i+1] + cnt[i-1]);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 50088
n = gets.to_i
array = []
while string = gets
  array << string.chomp
end
if array.size != array.uniq.size
  puts "No"
else
  i = 0
  s = 0
  while i < n-1 do
    l = array[i].to_s
    r = array[i+1].to_s
    if l[l.size-1] == r[0]
      s += 1
    end
    i += 1
  end
  if s == n-1
    puts "Yes"
  else
    puts "No"
  end
end

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

if N - 2 * D > 0:
  if D == 0:
    print(((N - 2 * D) + 2 * D) / N ** 2 * (M - 1))
  else:
    print(((N - 2 * D) * 2 + 2 * D) / N ** 2 * (M - 1))
else:
  print((M - 1) / N)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

auto dp = make_v<int64>(19, 10, 2);

int64 calc(int64 d, int64 head, int64 lzero, int64& rest, int64 now) {
  if (d == 1) {
    if (!lzero)
      rest--;
    return (rest == 0 ? now : -1);
  }
  if (~dp[d][head][lzero]) {
    if (rest > dp[d][head][lzero]) {
      rest -= dp[d][head][lzero];
      return -1;
    }
  }
  dp[d][head][lzero] = rest;
  int64 l = (lzero ? 0 : max(head-1, (int64)0)), r = (lzero ? 10 : min(head+2, (int64)10));
  FOR(i, l, r) {
    int64 ret = calc(d-1, i, lzero && (i == 0), rest, now * 10 + i);
    if (ret != -1) return ret;
  }
  dp[d][head][lzero] = abs(dp[d][head][lzero] - rest);
  return -1;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K;
	cin >> K;
	fill_v<int64>(dp, -1);
	cout << calc(18, 0, 1, K, 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)

{
    int N, i, counter = 1;
    string str;
    cin>>N>>str;
    char ch;
    ch = str[0];
    for(i = 0; i < N; i++){
        if(str[i] == ch){

        }
        else{
            ch = str[i];
            counter++;
        }
    }
    cout<<counter<<"\n";
    return 0;
}

Measured memory_bytes: 512
// Problem D

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 2000
#define pb push_back
#define mp make_pair

using namespace std;

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

int N, M;
int a, b, c, d;
char tab[MAXN][MAXN];
int cc[MAXN][MAXN];
bool arco[MAXN][MAXN];
bool was[MAXN*MAXN];
int dist[MAXN*MAXN];
vector<ii> e[MAXN*MAXN];

void dfs(int i, int j, int nome) {
  if (cc[i][j] != -1) return;
  cc[i][j] = nome;
  e[nome].pb(mp(i,j));
  if (i>0 && tab[i-1][j] == '.') dfs(i-1,j,nome);
  if (i<N && tab[i+1][j] == '.') dfs(i+1,j,nome);
  if (j>0 && tab[i][j-1] == '.') dfs(i,j-1,nome);
  if (j<M && tab[i][j+1] == '.') dfs(i,j+1,nome);
}

int main() {
  cin >> N >> M;
  cin >> a >> b >> c >> d;
  for (int i=0; i<N; i++)
    for (int j=0; j<M; j++) {
      cin >> tab[i][j];
      cc[i][j] = -1;
    }
  
  int contacc = 0;
  for (int i=0; i<N; i++)
    for (int j=0; j<M; j++)
      if (tab[i][j] == '.' && cc[i][j] == -1) {
	dfs(i,j,contacc);
	contacc++;
      }
      
  //~ cout << contacc << endl;
  
  int start = cc[a-1][b-1];
  int end = cc[c-1][d-1];
  
  if (start == end) {
    cout << 0 << endl;
    return 0;
  }
  
  for (int i=0; i<N*M; i++) dist[i] = -1;
  dist[start] = 0;
  queue<int> Q;
  Q.push(start);
  while (!Q.empty()) {
    int CC = Q.front();
    Q.pop();
    if (was[CC]) continue;
    was[CC] = true;
    // guardo i figli
    for (int k=0; k<(int)e[CC].size(); k++) {
      int i=e[CC][k].first;
      int j=e[CC][k].second;
      for (int I=-2; I<=2; I++)
	for (int J=-2; J<=2; J++) {
	  if (i+I>=0 && i+I<=N && j+J>=0 && j+J<=M) {
	    if (tab[i+I][j+J] == '.' && dist[cc[i+I][j+J]] == -1) {
	      dist[cc[i+I][j+J]] = 1 + dist[CC];
	      Q.push(cc[i+I][j+J]);
	    }
	  }
	}
    }
  }
  
  
  cout << dist[end] << endl;
  
  return 0;
}


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

using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------
 
int n;
int arr[100005];


void solve()
{
	cin>>n;rep(i,0,n)cin>>arr[i];
	
	int ans=0;
	vi source;
	
	source.pb(arr[n-1]);
	
	repD(i,n-2,-1)
	{
		int pos=upper_bound(all(source),arr[i])-source.begin();
		if (pos==source.size())source.pb(arr[i]);
		else source[pos]=arr[i];
	}
	cout<<source.size();
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
   // cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

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

	ll n, m, k, ans = 0;
	cin >> n;
	vvll dp(3, vll(n, 0));
	rep(i, n) cin >> dp[0][i] >> dp[1][i] >> dp[2][i];
	REP(i, 1, n) {
		dp[0][i] += max(dp[1][i - 1], dp[2][i - 1]);
		dp[1][i] += max(dp[0][i - 1], dp[2][i - 1]);
		dp[2][i] += max(dp[1][i - 1], dp[0][i - 1]);
		//cout << dp[0][i] << " " << dp[1][i] << " " << dp[2][i] << endl;
	}
	cout << max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1])) << endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  set<int> se;
  int k;
  for(int i = 1; i*(i-1)/2 <= 100000; i++){
    se.insert(i*(i-1)/2);
    if(N==i*(i-1)/2) k = i;
  }
  if(!se.count(N)){
    cout << "No" << endl;
    return 0;
  }
  //k個の集合、それぞれの要素数はk-1
  vvi ans(k, vi(0));
  int num = 1;
  for(int i = 0; i < k-1; i++){
    int t = k-1 - ans.at(i).size(); //追加する要素数
    for(int j = 1; j <= t; j++){
      ans.at(i).push_back(num);
      ans.at(i+j).push_back(num);
      num++;
    }
  }
  cout << "Yes" << endl;
  cout << k << endl;
  for(int i = 0; i < k; i++){
    cout << k-1 << ' ';
    for(int j = 0; j < k-1; j++){
      cout << ans.at(i).at(j);
      if(j == k-2) cout << endl;
      else cout << ' ';
    }
  }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll a, p;

    cin >> a >> p;

    cout << setprecision(20) << (3*a + p) / 2 << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define frep(i,m,n) for(int (i)=(m); (i)<(int)(n); (i)++)
#define rrep(i,n) for(int (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(int (i)=(n)-1; (i)>(int)(m)-1; (i)--)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;
const int MOD = 1000000007;

// A:array of pair, N:size of array
void sort_second(vector<pair<ll, ll>> &A, int N);
// a^n
ll a_n(ll a, ll n);
// make vector of (n!)%MOD, (n!)^(-1)%MOD to calculate nCk
void nCk(vector<ll> &n, vector<ll> &ninv);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int n, k;
    cin >> n >> k;
    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> a;
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(all(a));

    vector<ll> N(101010);
    vector<ll> NINV(101010);
    nCk(N, NINV);

    ll ans = 0;
    frep(i, 1, n) {
        if(i < k-1) continue;
        else {
            ll combi;
            combi = (N[i] * NINV[k-1])%MOD;
            combi = (combi * NINV[i-(k-1)])%MOD;
            ans += (combi * a[i])%MOD;
            ans %= MOD;
        }
    }
    frrep(i, 0, n-1) {
        if(n-1-i < k-1) continue;
        else {
            ll combi;
            combi = (N[n-1-i] * NINV[k-1])%MOD;
            combi = (combi * NINV[(n-1-i)-(k-1)])%MOD;
            ans -= (combi * a[i])%MOD;
            (ans += MOD)%=MOD; 
        }
    }
    cout << ans << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret = (ret * ret) % MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD ;
}

/* calculate a^n with no recursive process (%MOD)
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    int num = 1;
    vector<ll> memory(100);
    memory.at(0) = a;

    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
        memory.at(num) = ret;
        num++;
    }
    if(count == n) return ret;
    else {
        bitset<100> bit = bitset<100>(n-count);
        rep(i, 100) {
            if(bit.test(i)) ret = (ret * memory.at(i)) % MOD;
        }
        return ret;
    }    
}
*/

void nCk(vector<ll> &n, vector<ll> &ninv) {
    n[0] = 1;
    for(int i = 1; i < n.size(); i++) n[i] = (n[i-1] * i) % MOD;
    ninv[n.size()-1] = inv(n[n.size()-1]);
    for(int i = n.size() - 2; i > -1; i--) ninv[i] = (ninv[i+1] * (i+1)) % MOD;
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
int field[5000][5],tmp[5000][5];
 
void down()
{
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j < 5; j++) {
	int p = 4999;
	for (int i = 4999; i >= 0; i--) {
	    if (field[i][j] == -1) continue;
	    tmp[p--][j] = field[i][j];
	}
    }
    for (int i = 0; i < 5000; i++) {
	for (int j = 0; j < 5; j++) {
	    field[i][j] = tmp[i][j];
	}
    }
}
 
void remove()
{
    bool flg = false;
    for (int i = 0; i < 5000; i++) {
	int cnt = 0;
	for (int j = 0; j < 5; j++, cnt++) {
	    if (!field[i][j]) break;
	}
	if (cnt == 5) {
	    flg = true;
	    for (int j = 0; j < 5; j++) {
		field[i][j] = -1;
	    }
	}
    }
   
    if (flg) {
	down();
    }
}
 
int main()
{
    int N, d, p, q;
 
    while (cin >> N, N) {
	memset(field, 0, sizeof(field));
	for (int i = 0; i < N; i++) {
	    cin >> d >> p >> q; q--;
	    if (d == 1) {
		int min = INF;
		for (int j = q; j < p+q; j++) {
		    for (int i = 0; i < 5000; i++) {
			if (i == 4999 || field[i+1][j] == 1) {
			    min = std::min(min, i);
			    break;
			}
		    }
		}
		for (int j = q; j < p+q; j++) {
		    field[min][j] = 1;
		}
	    } else {
		for (int i = 0; i < 5000; i++) {
		    if (i == 4999 || field[i+1][q] == 1) {
			for (int j = 0; j < p; j++) {
			    field[i-j][q] = 1;
			}
			break;
		    }
		}
	    }
	    remove();
	}
	int ans = 0;
	for (int i = 0; i < 5000; i++) {
	    for (int j = 0; j < 5; j++) {
		if (field[i][j] == 1) ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

vector<vector<int> > adj;
vector<bool> vis;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
      int n,m; cin>>n>>m;
      vector<int> h(n);
      for(int i=0;i<n;i++)
        cin>>h[i];

      int ans=0;
      vector<int> xh(n,0);
      for(int i=0;i<m;i++){
        int x,y; cin>>x>>y;
        x--;y--;
        xh[x]=max(xh[x],h[y]);
        xh[y]=max(xh[y],h[x]);
      }
      for(int i=0;i<n;i++)
        if(xh[i]<h[i])
          ans++;
      cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3956
// https://atcoder.jp/contests/abc116/tasks/abc116_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pii> v(n);
    REP(i, n) cin >> v[i].first >> v[i].second;
    // 第2引数を降順にする
    sort(ALL(v),
         [](const pii &x, const pii &y) { return x.second > y.second; });
    // 今までに出現したネタか判定する
    set<int> st;
    // ダブったネタの価値を小さい順に保存
    priority_queue<int, vector<int>, greater<int>> q;
    ll sum = 0;
    REP(i, k) {
        if (st.count(v[i].first) == 0) {
            st.insert(v[i].first);
        } else {
            q.push(v[i].second);
        }
        sum += v[i].second;
    }
    ll maxv = sum + st.size() * st.size();
    FOR(i, k, n) {
        if (q.empty())
            break;
        if (st.count(v[i].first) == 0) {
            st.insert(v[i].first);
            sum += v[i].second - q.top();
            q.pop();
            maxv = max(maxv, (ll)(sum + st.size() * st.size()));
        }
    }
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

const ll M = (ll) 1e9 + 7;

int main() {
    map<int, int> mp;
    int n;
    string s;
    cin >> n >> s;
    ll ans = 1;

    for (int i = 0; i < n; ++i) {
        mp[s[i] - 'a']++;
    }

    for (auto m : mp) {
        (ans *= m.second + 1) %= M;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
typedef std::vector<ll> vl;
typedef std::vector<vector<ll>> vvl;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n; 
    while(cin>>n){
        vl a(n);
        for(int i=0; i<n; i++)
            cin>>a[i];
        
        vvl dp(n, vl(n));

        for(int l=0; l<n; l++){
            for(int r=l; r>=0; r--){
               	// cout<<l<<" "<<r<<" "<<endl;
               	if(l==r)
					dp[l][r] = a[l];
				else 
					dp[l][r] = max(a[l] - dp[l-1][r] , a[r] - dp[l][r+1]);
            }
        }
		cout<<dp[n-1][0]<<endl;

        // for(int l=n-1; l>=0; l--){
        //     for(int r=l; r<n; r++){
        //         cout<<l<<" "<<r<<" "<<r-l<<endl;
        //         if(l==r)
        //             dp[l][r] = a[l];
        //         else 
        //             dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
        //     }
        // }
        // cout<<dp[0][n-1]<<endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  bool a=0;
  
  rep(i,30){
    rep(j,30){
      if(i*4 + j*7 == n){
        a=1;
      }
    }
  }
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

#define MOD 1000000007

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	for(int i = 1;i <= n;i++){
		ans *= (i % MOD);
		ans = ans % MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}

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

namespace test01
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(e => int.Parse(e)).ToList();
            var N = line[0];
            var K = line[1];

            List<int> t = new List<int>();
            for (int i = 0; i < N; i++)
            {
                t.Add(int.Parse(Console.ReadLine()));
            }
            t = t.OrderBy(e => e).ToList();

            List<int> ans = new List<int>();
            for (int i = 0; i < N; i++)
            {
                var maxIndex = i + K - 1;
                if (N <= maxIndex) break;
                ans.Add(t[maxIndex] - t[i]);
            }

            Console.WriteLine(ans.Min());
            
        }
    }
}


Measured memory_bytes: 19676
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

int main()
{
	while (1)
	{
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0)break;

		int count = 0;

		for (int i = 1; i <= n; i++)
		{
			if (i + (i + 1) + ( i + 2 ) > x)break;
			for (int j = i + 1; j <= n; j++)
			{
				if (i + j + (j + 1) > x)break;
				for (int k = j + 1; k <= n; k++)
				{
					if ((i + j + k) == x)
					{
						count++;
						break;
					}
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}

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

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

    vector<long> a(n);
    for(auto &e: a) cin >> e;
    sort(a.begin(), a.end());

    if(a[0] == a[n-1]) {
        // all eq
        if(2*a[0] <= n) {
            cout << "Yes" << endl;
            return 0;
        }
        if(a[0] == n-1) {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }

    if(a[n-1] - a[0] >= 2) {
        cout << "No" << endl;
        return 0;;
    }

    assert(a[n-1] - a[0] == 1);

    long k = a[0];
    long i = upper_bound(a.begin(), a.end(), k) - a.begin();
    // [0, i) ... k, [i, n) .. k+1
    long c = i - 0; // uniq
    cout << (k+1-c>0 && 2*((k+1)-c) <= n-c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    for(ll i=1;i<1009;i++)
    {
      if((floor(i*0.08)==a) && (floor(i*0.1)==b))
      {
        cout<<i;
        return 0;
      }
    }
    cout<<"-1";
}

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


ll solve(){

	ll n;
	cin>>n;
	vector<ll> v(n),p(n);
	for(ll i=0;i<n;++i) {cin>>v[i]; p[i] = v[i];}
	for(ll i=1;i<n;++i) p[i] = max(p[i-1] , v[i]);

	ll ans =0;
	for(ll i=0;i<n;++i) ans += p[i] - v[i];

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

 	ll t = 1;
    // cin>>t;

    while(t--){
    	solve();
    }   

    return 0;
}	 

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  
  for (int i = 1; i <= N; i++) {
    cin >> a.at(i);
  }
  
  int number = 1;
  int result = -1;
  int count = 0;
  
  for (int i = 1; i < N; i++) {
    number = a.at(number);
    count++;
    if (number == 2) {
      result = count;
      break;
    }
  }
  cout << result << endl;
}

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

stu_list = []
cp_list = []

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

for j in range(M):
    cp_list.append(list(map(int, input().split())))

for i in range(len(stu_list)):
    min_cp = 0
    min_d = 10**9
    for j in range(len(cp_list)):
        d = abs(stu_list[i][0] - cp_list[j][0]) + abs(stu_list[i][1] - cp_list[j][1])

        if min_d > d:
            min_cp = j + 1
            min_d = d

    print(min_cp)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int sz = s.size();
    int l=1, r=sz+1; //L OK, R NG
    while(r-l>1){
        int mid = (l+r)/2;
        bool f0=false,f1=false;
        rep(i,2*mid-sz){
            int j = sz-mid+i;
            if (s[j]=='0') f0 = true;
            if (s[j]=='1') f1 = true;
        }
        if (f0&&f1){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout<<l<<endl;
    return 0;
}


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

int main(){
	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: 1168
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	for (int i = 0; ; i++)
	{
		C -= B;
		if (C <= 0)
		{
			cout << "Yes" << endl;
			break ;
		}
		A -= D;
		if (A <= 0)
		{
			cout << "No" << endl;
			break ;
		}
	}

}


Measured memory_bytes: 3104
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=9;
const ll LINF=100000000000000000;

int main(){
  int N;
  cin >> N ;
  priority_queue<int,vector<int>,greater<int>> que;
  int sum=0;
  rep(i,N){
    int s;
    cin >> s ;
    sum+=s;
    if(s%10!=0) que.push(s);
  }
  int ans;
  if(sum%10==0){
    if(!que.empty()) ans=sum-que.top();
    else ans=0;
  }else{
    ans=sum;
  }
  cout << ans << endl;
  return 0;
}


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

ll dp[18][2];

int main(){ 
  string s;
  cin >> s;
  int n = sz(s);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      int d = s[i] - '0';
      if (i > 0) {
        for (int c = 0; c <= (j ? d : 9); c++) {
          dp[i+1][j] = max(dp[i+1][j], dp[i][j] + c);
          if (j & c < d) dp[i+1][0] = max(dp[i+1][0], dp[i][j] + c);
        }
      } else {
        for (int c = 0; c <= (j ? d : d - 1); c++) dp[i+1][j] = max(dp[i+1][j], dp[i][j] + c);
      }
    }
  }
  cout << max(dp[n][0], dp[n][1]) << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isprime(int x) {
	if(x <= 1) return false;
	for(int i = 2; i * i <= x; i++) {
		if(x % i == 0) return false;
	}
	return true;
}
int q, n, ret;
int main() {
	cin >> q;
	while(q--) {
		cin >> n;
		ret += isprime(n);
	}
	cout << ret << endl;
}

Measured memory_bytes: 3032
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
INF = 1001001001
dp = Array.new(n, INF)
dp[0] = 0
(n-1).times{|i_|
  i = i_ + 1
  c1 = i>0 ? dp[i-1]+(h[i]-h[i-1]).abs : INF
  c2 = i>1 ? dp[i-2]+(h[i]-h[i-2]).abs : INF
  dp[i] = [c1, c2].min
}
p dp[n-1]


Measured memory_bytes: 11404
#include<stdio.h>
int main(void){
  	int a,b,c,d,e;
  	int h1 = 0;
  	int h2 = 0;
  	int ans = 0;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  h1 = a * 60 + b;
  h2 = c * 60 + d;
  ans = h2 - h1;
  printf("%d\n",ans - e);
  return 0;
}
  

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

void solve() {
    int a, b;
    cin >> a >> b;
    int ans = max(0, a - 2 * b);
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define int long long
//#define double long double
#define moder 1000000007
#define P std::pair<int,int>
using namespace std;

double n,x[110],y[110];
signed main(){
	cin>>n;
	double sum1=0;
	double sum2=0;
	double sum3=0;
	double ma=0;
	rep(i,n)cin>>x[i];
	rep(i,n){
		cin>>y[i];
		sum1+=abs(x[i]-y[i]);
		sum2+=pow(abs(x[i]-y[i]),2);
		sum3+=pow(abs(x[i]-y[i]),3);
		ma=max(ma,abs(x[i]-y[i]));
	}
	printf("%lf\n%lf\n%lf\n%lf\n",sum1,sqrt(sum2),cbrt(sum3),ma);
	return 0;
}


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve(){

	int n;
	cin >> n;

	cout << n * (n + 1) / 2;
	
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
}

Measured memory_bytes: 764
N = int(input())
monsters = list(map(int, input().split()))
braves = list(map(int, input().split()))
braves.append(0)

new = old = 0
ans = 0
for monster, brave in zip(monsters, braves):
    new = brave
    m = monster

    damage = min(old, m)
    m -= damage
    ans += damage

    damage = min(new, m)
    new -= damage
    ans += damage

    old = new

print(ans)


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

int main(){
	int n,m,x,y;
	scanf("%d %d",&n,&m);
	scanf("%d %d",&x,&y);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		x=max(x,a);
	}
	for(int i=1;i<=m;i++){
		scanf("%d",&a);
		y=min(y,a);
	}
	if(y>x){
		printf("No War\n");
	}
	else printf("War\n");
	
	return 0;
}

Measured memory_bytes: 256
/*

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

using namespace std;

#define ll           long long int
#define mp           make_pair
#define pb           push_back
#define fi           first
#define si           second
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;



int main(){
fastIO
	ll n; cin>>n;
	ll *h = new ll[n];
	F(h, n);
	ll *dp = new ll[n];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(ll i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cerr<<#x << " = " << x <<endl;

int main(){
	int n,v[100];
	
	cin>>n;
	rep(i,1,n+1){
		cin>>v[i];
	}
	
	int ok=0;
	rep(i,1,n+1){
		debug(ok)
		if(v[i]==i)continue;
		if(v[v[i]]==i) ok++;
		else ok=0x3f3f3f3f;
	}
	if(ok<=2)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  int a, b, c, t, ans;
  cin >> a >> b >> t;
  c = (t + 0.5) / a;
  ans = c * b;
  cout << ans;
  return 0;
}

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

int main(void){

  int a, b, c;
  cin >> a >> b >> c;

  if ((a == b && a != c) || (a != b && b == c) || (c == a && c != b)) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define MAX 500
using namespace std; 
#define ll long long int
void printString(ll n) 
{ 
	char str[MAX]; 
	ll i = 0; 

	while (n > 0) { 
		// Find remainder 
		ll rem = n % 26; 

		// If remainder is 0, then a 'Z' must be there in output 
		if (rem == 0) { 
			str[i++] = 'z'; 
			n = (n / 26) - 1; 
		} 
		else // If remainder is non-zero 
		{ 
			str[i++] = (rem - 1) + 'a'; 
			n = n / 26; 
		} 
	} 
	str[i] = '\0'; 

	// Reverse the string and print result 
	reverse(str, str + strlen(str)); 
	cout << str << endl; 

	return; 
} 

// Driver program to test above function 
int main() 
{ 
	ll n;
	cin>>n;
	printString(n);
	return 0; 
} 


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
#include<ext/rope>
using namespace __gnu_cxx;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll a,b,n;
ll d[55];
int main()
{
    //IOS;
    string s;
    while(cin>>n)
    {
        cin>>s;
        ll sum=0;
        rep(i,s.size()-1)
        {
            if(s[i]!=s[i+1]) sum++;
        }
        cout<<sum+1;
    }
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

static const int MAX_N = 1<<17;
pii dat[2 * MAX_N -1];
int n;

struct SegmentTree{
    
    
    
    SegmentTree(int n_){
        n=1;
        while(n<n_) n*= 2;
        for(int i=0;i<2*n-1;i++){
            dat[i].first = -1;
            dat[i].second=(1LL<<31)-1;
        }
    }
    int query(int k){
        k += n-1;
        pii value=dat[k];
        while(k>0){
            k=(k-1)/2;
            value=max(value,dat[k]);
        }
        return value.second;
    }
    void update(int a,int b,int k,pii P,int l,int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            dat[k]=P;
        }
        else{
            update(a,b,k*2+1,P,l,(l+r)/2);
            update(a,b,k*2+2,P,(l+r)/2,r);
        }
    }
    
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int _n,q;
    cin>>_n>>q;
    SegmentTree sg(_n);
    rep(i,q){
        int c;
        cin>>c;
        if(!c){
            int s,t,x;
            cin>>s>>t>>x;
            sg.update(s,t+1,0,pii(i,x),0,n);
        } else{
            int x;
            cin>>x;
            cout<<sg.query(x)<<endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5280
#include <iostream>
using namespace std;
int main(){

  int cards[4][13]={0},a,b;
  char m;

  cin >>b;

  for(int i=0;(b-i)>0;i++){

    cin >>m>>a;

    if(m == 'S'){
      cards[0][a-1]=1;
    }else if(m == 'H'){
      cards[1][a-1]=1;
    }else if(m == 'C'){
      cards[2][a-1]=1;
    }else if(m == 'D'){
      cards[3][a-1]=1;
    }
  }
  
  for(int j=0;(13-j)>0;j++){
    if(cards[0][j] == 0){
      cout <<"S"<<" "<<j+1<<"\n";
    }
  }
  for(int k=0;(13-k)>0;k++){
    if(cards[1][k] == 0){
      cout <<"H"<<" "<<k+1<<"\n";
    }
  }
  for(int l=0;(13-l)>0;l++){
    if(cards[2][l] == 0){
      cout <<"C"<<" "<<l+1<<"\n";
    }
  }
  for(int n=0;(13-n)>0;n++){
    if(cards[3][n] == 0){
      cout <<"D"<<" "<<n+1<<"\n";
    }
  }
  
  return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

vi to[100100];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N, M;
    cin >> N >> M;
    vi h(N);
    rep(i, 0, N) cin >> h[i];

    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vi used(N, 0);
    rep(i, 0, N) {
        if (used[i] == 1) continue;
        bool ok = true;
        for (auto v : to[i]) {
            if (h[i] <= h[v]) {
                ok = false;
                break;
            } else {
                used[v] = 1;
            }
        }
        if (ok) {
            used[i] = 2;
            // debug2(i, h[i]);
        }
    }

    int ans = 0;
    rep(i, 0, N) if (used[i] == 2) ans++;

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


Measured memory_bytes: 10572
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
char a[111];
int main()
{
	gets(a);
	int len,flag=0,num;
	len=strlen(a);
	for(int i=0;i<=len-1;i++)
	{
		if (a[i]=='C')
		{
			flag=1;
			num=i;
			break;
		}
	}
	if (flag==0)
	{
		cout<<"No";
		return 0;
	}
	for (int i=num+1;i<=len-1;i++)
	{
		if (a[i]=='F')
		{
			flag=2;
			break;
		}
	}
	if (flag==1)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int x,y,z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n, tab[maxn];

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i=1; i<=n; ++i) {cin >> tab[i]; tab[i] *= 2; }
	int maks = 0; tab[0] = -1;
	for (int i=1; i<=n; ++i)
		if (tab[maks] < tab[i]) maks = i;

	int best = tab[maks] / 2, st = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (maks == i) continue;
		int d1 = abs(best - tab[i]);
		int curr_len = abs(best - tab[st]);
		if (curr_len > d1) st = i;
		else if (curr_len == d1) st = min(st, i); 
	}
	
	//cout << min(maks, st) << ' ' << max(maks, st) << endl;
	cout << tab[maks] / 2 << ' ' << tab[st] / 2 << endl;
}


Measured memory_bytes: 640