akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;

string s1,s2;
int dp[3001][3001];
string sol="";

int main() {
    cin >> s1 >> s2;
    for (int i=1;i<=s1.size();i++) {
        for (int j=1;j<=s2.size();j++) {
            if (s1[i-1]==s2[j-1]) {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    int i=s1.size();
    int j=s2.size();
    while(i>0 && j>0) {
        if (dp[i][j]==dp[i-1][j]) {i--;}
        else if (dp[i][j]==dp[i][j-1]) {j--;}
        else {
            sol.push_back(s1[i-1]);
            i--;
            j--;
        }
    }
    reverse(sol.begin(),sol.end());
    cout << sol << endl;
}



Measured memory_bytes: 38824
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

struct BinaryIndexedTree
{
  vector< int > data;
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }
  int Query(int a)
  {
    int ret = 0;
    for(++a; a > 0; a -= a & -a) (ret += data[a]) %= mod;
    return(ret);
  }
  void Add(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) (data[k] += x) %= mod;
  }
};

int main()
{
  int N, L, x[5000], a[5000];
  vector< BinaryIndexedTree > dp(5001, BinaryIndexedTree(5005));

  cin >> N >> L; ++L;
  for(int i = 0; i < N; i++) {
    cin >> x[i]; ++x[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  dp[0].Add(0, 1);
  for(int i = 0; i < N; i++) {
    if(a[i] == 0) {
      dp[i + 1].Add(x[i], dp[i].Query(x[i] - 1));
    } else {
      for(int j = x[i]; j < L; j += a[i]) {
        dp[i + 1].Add(j, dp[i].Query(j - 1));
      }
    }
  }
  cout << dp[N].Query(L) << endl;
}

Measured memory_bytes: 98956
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// Translate dy0607's code
//https://beta.atcoder.jp/contests/arc090/submissions/2037210

const (
	MOD = 1000*1000*1000 + 7
	N   = 3*1000*1000*10 + 10
)

func Pow(x, e int) int {
	ret := 1
	for e != 0 {
		if e%2 == 1 {
			ret = (ret * x) % MOD
		}
		x = (x * x) % MOD
		e >>= 1
	}

	return ret
}

func UnderN(S int) int {
	sum := InitSetting()
	ans, l := 0, 0
	for r := range sum {
		if r == 0 {
			continue
		}
		if r > N-5 {
			break
		}
		for l < 9999998 && sum[r]-sum[l] > S {
			l++
		}
		if sum[r]-sum[l] == S {
			ans++
		}
	}
	return ans
}

func OverN(S, ans int) int {
	ans += S / 8

	for i := 1; i*i <= S; i++ {
		if S%i == 0 {
			if i > 7 {
				ans = (ans + MOD + (9 * Pow(10, i-1)) - (S / i)) % MOD
			}
			if i*i != S && S/i > 7 {
				ans = (ans + MOD + (9 * Pow(10, (S/i)-1)) - i) % MOD
			}
		}
	}

	return ans
}

func InitSetting() []int {
	sum := make([]int, N)
	for i := range sum {
		if i == 0 {
			continue
		}
		if i > N-5 {
			break
		}
		sum[i] = sum[i/10] + 1
	}
	for i := range sum {
		if i == 0 {
			continue
		}
		if i > N-5 {
			break
		}
		sum[i] += sum[i-1]
	}

	return sum
}

func main() {
	in := IOInitialize()
	S := Int(in)
	ans := UnderN(S)
	ans = OverN(S, ans)

	fmt.Println(ans)
}

//////////
//
//

func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func IntArray(s *bufio.Scanner, size int) []int {
	deepArray := make([]int, size)
	for i := range deepArray {
		deepArray[i] = Int(s)
	}
	return deepArray
}

func GraphSetByEdge(s *bufio.Scanner, v int) [][]int {
	g := make([][]int, v)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for xxNonUsedInLoopI := 0; xxNonUsedInLoopI < v-1; xxNonUsedInLoopI++ {
		a, b := Int(s)-1, Int(s)-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	return g
}


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

int main(){
  int n;
  string s, s2;
  cin >> n >> s >> s2;
  ll ans = 3; //1列目を縦として初期化
  bool frag = true;
  int i=1;
  if(n != 1 && s[0] == s[1]){  //1列目が横だった場合
    ++i;
    ans = 6;
    frag = false;
  }
  for( ; i<n; ++i){
    if(frag && i<n-1 && s[i] == s[i+1]){ //縦→横
      ans *= 2;
      ans %= MOD;
      frag = false;
      ++i;
    }
    else if(frag){ //縦→縦
      ans *= 2;
      ans %= MOD;
    }
    else if(i<n-1 && s[i] == s[i+1]){ //横→横
      ans *= 3;
      ans %= MOD;
      ++i;
    }
    else{ //縦→縦
      frag = true;
    }
  }
  cout << ans << endl;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		int sum = 0;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i]; sum += a[i];
		}
		int res = 0;
		for (int i = 0; i < n; i++) {
			res += (a[i] * n <= sum);
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    A, B, C = map(int, input().split())

    if C+B-A < 0:
        print(0)
    else:
        print(C+B-A)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc136","a",main)

Measured memory_bytes: 2940
#include <iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int M=1046527;
const int L=14;
char H[M][L];
int getChar(char str)
{
    if(str=='A')return 1;
    else if(str=='T')return 2;
    else if(str=='C')return 3;
    else if(str=='G')return 4;
    else return 0;
}
int getInt(char str[])
{
    int q;
    int sum=0;
    for(int i=0; i<strlen(str); i++)
    {
        q=getChar(str[i]);
        sum=sum*5+q;
    }
    return sum;
}
int h1(int key)
{
    return key%M;
}
int h2(int key)
{
    return 1+(key%M);
}
int h(int key,int i)
{
    return (h1(key)+i*h2(key))% M;
}
int insertKey(char str[])
{
    int key=getInt(str);
    int i=0;
    while(true)
    {
        int position=h(key,i);
        if(strcmp(H[position],str)==0)return 1;
        else if(strlen(H[position])==0)
        {
            strcpy(H[position],str);
            return 1;
        }
        i=i+1;
    }
    return 0;

}
int findKey(char str[])
{
    int key=getInt(str);
    int i=0;
    while(true)
    {
        int position=h(key,i);
        if(strcmp(H[position],str)==0)return 1;
        else if(strlen(H[position])==0)return 0;
        i=i+1;
    }
    return 0;
}
int main()
{
    int n;
    char str[L],com[9];
    scanf("%d",&n);
    for(int i=0;i<M;i++)H[i][0]='\0';
    while(n--)
    {
        scanf("%s %s",com,str);
        if(com[0]=='i')
        {
            insertKey(str);
        }
        else
        {
            if(findKey(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }
    return 0;
}

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

int main(){
    string t;
    cin >> t;
    int n = 0, w = 0, s = 0, e = 0;
    for(char c : t){
        switch(c){
            case 'N':
                n = 1;
                break;
            case 'W':
                w = 1;
                break;
            case 'S':
                s = 1;
                break;
            case 'E':
                e = 1;
                break;
        }
    }
    cout << (!(n^s) && !(w^e) ? "Yes" : "No") << endl;

    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll A,B,V,W,T;
  cin>>A>>V>>B>>W>>T;
  if(V-W > 0){
    if(abs(A-B) <= (V-W)*T){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int value,cost;
};

Info info[100][50];
int item_num[100];
int dp[301];

int main(){

	int S,D,M;

	while(scanf("%d %d %d",&S,&D,&M) != EOF){

		for(int i = 0; i < S; i++){
			scanf("%d",&item_num[i]);

			for(int k = 0; k < item_num[i]; k++){
				scanf("%d %d",&info[i][k].value,&info[i][k].cost);
			}
		}

		dp[0] = 0;
		for(int i = 1; i <= M; i++)dp[i] = -1;


		int tmp;
		for(int loop = 0; loop < D; loop++){
			scanf("%d",&tmp);

			for(int k = 0; k < item_num[tmp]; k++){
				for(int budget = M; budget-info[tmp][k].cost >= 0; budget--){
					if(dp[budget-info[tmp][k].cost] >= 0){
						dp[budget] = max(dp[budget],dp[budget-info[tmp][k].cost]+info[tmp][k].value);
					}
				}
			}
		}

		int max_effect = -1,min_budget;
		for(int budget = 0; budget <= M; budget++){
			if(max_effect < dp[budget]){
				max_effect = dp[budget];
				min_budget = budget;
			}
		}

		printf("%d %d\n",max_effect,min_budget);
	}
	return 0;
}

Measured memory_bytes: 3156
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)


A, B, C, D = map(int,input().split())
mabigki = 0
mabigki +=  B//C + B//D - B//(lcm(C,D))
b = A - 1
mabigki -=  b//C + b//D - b//(lcm(C,D))
ans = B-A+1 -mabigki
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    int A,B,a[100100]={},b[100100]={},ans=20000000,M,minA=10000000,minB=10000000,x=0,y=0,c=0,temp=0;

    cin >> A >> B >> M;

    for(int i=1;i<=A;i++){
        cin >> a[i];
        if(a[i]<minA){
            minA=a[i];
        }
    }

    for(int i=1;i<=B;i++){
        cin >> b[i];
        if(b[i]<minB){
            minB=b[i];
        }
    }

    ans = minA+minB;

    for(int i=1;i<=M;i++){
        cin >> x>>y>>c;

        temp = a[x] + b[y] - c;

        if(temp<ans){
            ans = temp;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int a, b;
int main() {
	cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << a + b << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m, c;
	cin >> n >> m >> c;

	vector<int> b(m);
	for (auto &v : b) {
		cin >> v;
	}

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

		int score = 0;
		for (int j = 0; j < m; j++) {
			score += a[j] * b[j];
		}
		score += c;

		ans += score > 0;
	}

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


Measured memory_bytes: 256
// AtCoder
// ABC A - Fine Variables

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;


int main()
{
	//steady_clock::time_point start = steady_clock::now();
	int x[5];

	for (int i=0; i < 5; i++) {
		cin >> x[i];
	}

	// 計算
	int ans;
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) cout << i+1;
	}

	//計算時間集計
	/*
	steady_clock::time_point end = steady_clock::now();
    steady_clock::duration d = end - start;
	cout << "計算時間は" << duration_cast<milliseconds>(d).count() << "ミリ秒です。\n";
	*/
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x,a,b;
  cin >> x >> a >> b;
  if(b - a <= 0)cout << "delicious" << endl;
  else if(b - a <= x)cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	while (Q--) {
		int u, v;
		cin >> u >> v;
		if (N == 1) {
			cout << min(u, v) << endl;
			continue;
		}
		vector<int> x, y;
		while (u > 0) {
			x.push_back(u);
			u = (u + N - 2) / N;
		}
		while (v > 0) {
			y.push_back(v);
			v = (v + N - 2) / N;
		}
		reverse(y.begin(), y.end());
		for (auto val : x) {
			if (binary_search(y.begin(), y.end(), val)) {
				printf("%d\n", val);
				break;
			}
		}
	}
	return 0;
}

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

int main(){

  string S;
  bool ans=false;
  cin >> S;
  if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[3]) ans=true;
  if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]) ans=true;
  if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[2]) ans=true;

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 5011;
int n, k, a[MN];
bitset<5011> f;

bool isGood(int mid) {
    if (a[mid] >= k) return true;

    f.reset();
    f[0] = 1;

    FOR(i,1,n) if (i != mid)
        f = f | (f << a[i]);

    FOR(i,k-a[mid],k-1)
        if (f[i] == 1) return true;
    return false;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);
    while (cin >> n >> k) {
        FOR(i,1,n) cin >> a[i];
        sort(a+1, a+n+1);

        int l = 1, r = n, res = n+1;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (isGood(mid)) {
                res = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }

        cout << n - (n - res + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >> s;
  ll ans = 0, l = (ll)pow(2,s.size());
  for(ll i=s.size()-1;i>=0;i--){
    ans += l * (s[i]-'0');
    l = (l*10 + (1<<s.size()))/2;
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int a[100], b[100];
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0; i<n; i++){
        int ans = 0;
        for(int j=0; j<m; j++){
            if(a[j]==i+1){
                ans++;
            }
            if(b[j]==i+1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define ll long long
#define ar array

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

	int x, ans;
	cin >> x;
	ans = 0;
	while (x >= 500) {
		x -= 500;
		ans += 1000;
	}
	while(x >= 5) {
		x -= 5;
		ans += 5;
	}
	cout << ans;
}


Measured memory_bytes: 256
import sys
import fractions
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x: x//2, A))

def dev2(x):
    c=0
    while x%2==0:
        x=x//2
        c+=1
    return c

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

if n==1:
    if A[0]<=m:
        print(int((m/A[0]+1)/2))
    else:
        print(0)
else:
    d=dev2(A[0])
    for i in range(n-1):
        if dev2(A[i+1]) != d:
            print(0)
            sys.exit()
    l=A[0]
    for i in range(n-1):
        l=lcm(l,A[i+1])
        if l>m:
            print(0)
            sys.exit()
    print(int((m/l+1)/2))

Measured memory_bytes: 16296
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  int res = 1;
  int count = 0;
  for (int i = 2; i <= N; ++i) {
    int cur = 0;
    for (int j = i; j % 2 == 0; j /= 2)
      ++cur;

    if (cur > count) {
      res = i;
      count = cur;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
    int x;
    int i=0;
    while (1)
    {
        scanf("%d", &x);
        if(x==0)break;
        i++;
        cout << "Case " << i << ": " << x << endl;
    }
    
}


Measured memory_bytes: 3116
def calc(K, xyc):
    K2 = K * 2
    N = len(xyc)

    p = [[0] * K2 for i in range(K2)]
    for x, y, c in xyc:
        y += c * K
        p[x % K2][y % K2] += 1
        p[(x + K) % K2][(y + K) % K2] += 1

    def isum(xs):
        r = 0
        yield r
        for x in xs:
            r += x
            yield r

    psum = [list(isum(row)) for row in p]
    pksum = [[b - a for a, b in zip(row, row[K:])] for row in psum]

    rmax = N / 2
    for y in range(K):
        rcount = sum(row[y] for row in pksum[:K])
        for x in range(K):
            rmax = max(rmax, rcount, N - rcount)
            rcount += -pksum[x][y] + pksum[x + K][y]

    return rmax

if __name__ == '__main__':
    N, K = [int(e) for e in input().split()]
    xyc = [(int(x), int(y), c == "W") for x, y, c in [input().split() for i in range(N)]]
    print(calc(K, xyc))


Measured memory_bytes: 102560
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

ll int a,b,n;

ll int func(ll int x)
{
	ll int tmp=(a*x)/b;
	ll int tmp2=x/b;
	tmp2*=a;
	return tmp-tmp2;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		cin>>a>>b>>n;
		ll int maxi=func(n);
		if(n>=b-1)
		{
			maxi=max(maxi,func(b-1));
		}
		ll int low=1,high=1e18/b;
		while(low<=high)
		{
			ll int mid=(low+high)/2;
			ll int tmp=mid*b-1;
			if(tmp<=n)
			{
				maxi=max(maxi,func(tmp));
				low=mid+1;
			}
			else
			{
				high=mid-1;
			}
		}
		cout<<maxi<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int> >A;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A.push_back(make_pair(a,i+1));
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
    cout << A[i].second << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    string str;
    cin >> str;
    stack<char> stk;
    int sum_t = 0;
    rep(i, SZ(str)) {
        if (str[i] == 'S') stk.push(str[i]);
        else {
            if (SZ(stk) != 0) {
                stk.pop();
            } else sum_t++;
        }
    }
    out(SZ(stk) + sum_t);
}


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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;
const long long mod = 998244353 ;

long long n , A , B , K ;

long long bigmod( long long B , long long P , long long M ) {
    long long R = 1LL ;
    while( P > 0 ) {
        if( P % 2 == 1 ) {
            R = (R * B) % M ;
        }
        P /= 2 ;
        B = (B * B )% M ;
    }
    return R ;
}

long long fact[N] , inv[N] ;

long long comb( long long n , long long r ) {
    long long ans = ( fact[n] * inv[r] % mod * inv[n - r] % mod ) % mod ;
    return ans ;
}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    scanf("%lld %lld %lld %lld" , &n , &A , &B , &K ) ;
    fact[0] = 1LL , inv[0] = 1LL ;
    for( long long i = 1 ; i <= n ; i++ ) {
        fact[i] = (fact[i - 1] * i) % mod ;
        inv[i] = bigmod( fact[i] , mod - 2 , mod ) ;
    }
    long long ans = 0 ;
    for( long long i = 0 ; i <= n ; i++ ) {
        long long r = K - i*A ;
        if( r < 0 || r > n*B || r % B != 0 ) continue ;
        r /= B ;
        ans += comb(n , i) * comb(n , r) ;
        if( ans >= mod ) ans %= mod ;
    }
    printf("%lld\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1; 
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,m,d1,d2,i,j,flag,cnt,book[605][605];
void ss(int x){
	flag=0;
	while((x&3)==0){
		x>>=2;
		flag++;
	}
	if(x&1){
		for(i=0;i<m;i++)
			for(j=0;j<m;j++)
				if(((i>>flag)+(j>>flag))&1)
					book[i][j]=1;
	}
	else{
		for(i=0;i<m;i++)
			for(j=0;j<m;j++)
				if((i>>flag)&1)
					book[i][j]=1;
	}
}
int main(){
//	freopen("number.in","r",stdin);
//	freopen("number.out","w",stdout);
	n=read();d1=read();d2=read();
	m=n*2;
	ss(d1);
	ss(d2);
	for(i=0;i<m;i++)
		for(j=0;j<m;j++){
			if(book[i][j]==0){
				pus(i,1);
				pus(j,2);
				cnt++;
			}
			if(cnt==n*n)
				return 0;
		}
  	return 0;
}

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

int main() {
  string S;
  cin >> S;

  vector<string> week = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

  for (int i = 0; i < week.size(); i++) {
    if (S == week.at(i)) {
      cout << week.size() - i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int num;
  char seq[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  scanf("%d",&num);
  printf("%d",seq[num-1]);
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int N, M;
int A[2100];
int a, b;

int main() {
    while (cin >> N >> M) {
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        
        int res[2100];
        memset(res, 0, sizeof(res));
        
        for (int i = 0; i < M; ++i) {
            cin >> b;
            
            int pMax = -1;
            for (int j = 0; j < N; ++j) {
                if (A[j] <= b && pMax == -1) {
                    pMax = j;
                }
            }
            res[pMax]++;
        }
         
        int ans = -1, Max = -1;
        for (int i = 0; i < N; ++i) if (chmax(Max, res[i])) ans = i;
        
        cout << ans+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1184
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const S=input[0];
  const MOD=10**9+7;
  var possibility=new Array(13);
  possibility.fill(0);
  if(S[S.length-1]==='?'){
    for(var i=0;i<=9;i++){
      possibility[i]=1;
    }
  }else{
    possibility[S[S.length-1]-0]=1;
  }
  var ten=1;
  var next;
  for(var j=S.length-2;j>=0;j--){
    ten=ten*10%13;
    next=new Array(13);
    next.fill(0);
    if(S[j]==='?'){
      for(var i=0;i<13;i++){
        [0,1,2,3,4,5,6,7,8,9].forEach(e=>{
          next[(i+ten*e)%13]+=possibility[i];
        });
      }
    }else{
      for(var i=0;i<13;i++){
        next[(i+ten*(S[j]-0))%13]=possibility[i];
      }
    }
    possibility=next.slice().map(e=>{
      return e%MOD;
    });
  }
  console.log(possibility[5]);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35904
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int has[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool ispalin(string s)
{
	string k = s;
	reverse(k.begin(),k.end());
	if(k == s)
	{
		return true;
	}

	return false;
}


signed main()
{
    
	speedrap
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		int k,n;
		cin>>k>>n;
		int a[n];
		for(int i = 0 ; i < n ; i++)
		{
			cin>>a[i];
		}

		int dis = INT_MAX;

		for(int i = 0 ; i < n ; i++)
		{
			int d1  = -1;
			int d2 = -1;

			if(i == 0)
			{
				d1 = a[n-1] - a[0];
				d2 = a[0] + k - a[1];
				dis = min(d1,d2);
				continue;
			}

			if(i == n-1)
			{
				d1 = a[n-1] - a[0];
				d2 = k - a[n-1] + a[n-2];
				dis = min(dis,min(d1,d2));
				continue;
			}

			d1 = k - a[i] + a[i-1];
			d2 = a[i] + k - a[i+1];

			dis = min(dis,min(d1,d2));

		}
		cout<<dis;
	}
}
		

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

int six[7] = {1, 6, 36, 216, 1296, 7776, 46656};
int nine[6] = {1, 9, 81, 729, 6561, 59049};
int l[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
int DP[12][100001]={};

int main(){
  int n;
  cin >> n;
  for(int i=0; i<=100000; i++){
    DP[0][i] = i;
    DP[1][i] = i/6+i%6;
  }
  for(int i=2; i<12; i++){
    for(int j=1; j<=n; j++){
      int m = 100000;
      for(int k=0; j-l[i]*k>=0; k++){
        m = min(m, DP[i-1][j-l[i]*k] + k);
      }
      DP[i][j] = m;
    }
  }
  cout << DP[11][n] << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    std::sort(res.begin(),res.end());
    return res;
}

ll calc(ll n, ll k) {

    while(n >= k) {
        if(n % k)n %= k;
        else n /= k;
    }
    return n;
}

int main()
{
    ll n;
    cin >> n;
    int cnt = divisor(n - 1).size() - 1;
    vector<ll> dis = divisor(n);
    //cerr << "yay" << endl;
    for(auto i : dis) {
        if(i == 1)continue;
        if(calc(n, i) == 1)cnt++;
    }
    cout << cnt << endl;

}

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

int main(void){
    int n,m,c;
    cin >> n >> m>> c;
    vector<int>b(m);
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    int a;

    int cnt = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<m;j++){
            cin >> a;
            sum += a*b[j];
        }
        if(sum + c > 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *   author: Shubham Srivastava
 *   created: 05 February 2019  00:34:57
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)
    	cin>>s[i];
    int arr[n][m];
    bool flag = 0;
    for(int i=0;i<m;i++)
    {
    	if(s[0][i] == '.' && !flag)
    		arr[0][i] = 1;
    	else{
    		flag = 1;
    		arr[0][i] = 0;
    	}
    }
    flag = 0;
    for(int j=0;j<n;j++)
    {
    	if(s[j][0] == '.' && !flag)
    		arr[j][0] = 1;
    	else{
    		flag = 1;
    		arr[j][0] = 0;
    	}
    }
    for(int i=1;i<n;i++){
    	for(int j=1;j<m;j++)
    		if(s[i][j] == '.')
    			arr[i][j] = 1;
    		else
    			arr[i][j] = 0;
    }
    for(int i=1;i<n;i++)
    {
    	for(int j=1;j<m;j++)
    	{
    		if(arr[i][j])
    			arr[i][j] = (arr[i-1][j]%mod+arr[i][j-1]%mod)%mod;
    	}
    }
    cout<<arr[n-1][m-1];
return 0;
}

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

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

#define INF 1e10

using namespace std;

bool isprime(int n) {
	if (n == 1) return false;
	if (n == 2 || n == 3) return true;
	if (n % 2 == 0) return false;

	for (int i = 3; i < n / 2; i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

signed main(void) {
	int X, ans;
	cin >> X;
	ans = X;
	
	while (true) {
		if (isprime(ans)) break;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

s = input().rstrip()
q = int(input())

isRev = False

head = ''

for i in range(q):
    query = list(input().split())
    if len(query) == 1:
        isRev = not isRev
    else:
        if isRev and query[1] == '1':
            s = s + query[2]
        elif query[1] == '1':
            head = head + query[2]
        elif isRev and query[1] == '2':
            head = head + query[2]
        elif query[1] == '2':
            s = s + query[2]
            
if isRev:
    s = s[::-1] + head
else:
    s = head[::-1] + s
        
print(s)
        


Measured memory_bytes: 4212
#include<iostream>
using namespace std;
int main()
{
    unsigned int k,a,b,sign=0,i;
    cin>>k>>a>>b;
    for(i=a/k;k*i<=b;i++){
        if(k*i>=a && k*i<=b){
            sign=1;
            break;
        }
    }
    if(sign==1) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();		
		System.out.println(n % 2 == 0 ? (n/2) - 1 : ((n + 1)/2) - 1);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    k=v[0]+v[v.SZ-1];
    for(i=0;i<n-2;i++)
    {
        k+=min(v[i],v[i+1]);
    }
    cout<<k<<endl;
}



Measured memory_bytes: 256
n=int(input())
cnt = 0
flag = False
for i in range(0,n):
    inp = input()
    a,b = inp.split()
    if(a == b):
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=LLONG_MAX,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll d,t,s;
        cin>>d>>t>>s;
        if(s*t>=d){
            cout<<"Yes"<<endl;
        }
        else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin>>N;
    vector<ll> cnt(N+1,0);
    for(ll i=1;i<=N;i++){
        for(ll kake=1;kake*i<=N;kake++){
            cnt[kake*i]++;
        }
    }
    ll sum=0;
    for(ll i=1;i<=N;i++){
        sum+=i*cnt[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 81392
PROGRAM AttackSurvival
      IMPLICIT NONE
      integer(16) :: n,k,q
      integer(16),allocatable :: a(:),point(:)
      integer(16) :: i
      
      read*,n,k,q
      allocate( a(q),point(n) )
      do i = 1,q
        read*,a(i)
      end do
!    print*,n,k,q
!    do i = 1,q
!      print*,a(i)
!    end do
      
      point(:) = k - q
      
      do i = 1,q
        point(a(i)) = point(a(i)) + 1
      end do
      
      do i = 1,n
        if( point(i)>0 )then
          print*,'Yes'
        else
          print*,'No'
        end if
      end do
      
      END PROGRAM

Measured memory_bytes: 3840
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = LI()
    a.sort()
    a, b, c = a
    print(int(str(c)+str(b))+a)
    return

#B
def B():
    n, m, X, Y = LI()
    x = LI()
    y = LI()
    x.append(X)
    y.append(Y)
    x.sort()
    y.sort()
    print("No " * (x[-1] < y[0]) + "War")
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;

	return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	int a[7]={1,3,5,7,8,10,12},b[4]={4,6,9,11};
	for(int i=0;i<7;++i){
		if(x==a[i])	x=0;
		else if(y==a[i])y=0;
	}
	for(int i=0;i<4;++i){
		if(x==b[i])x=1;
		else if(y==b[i])y=1;
	}
	if(x==2||y==2)cout << "No" << endl;
	else cout << (x==y?"Yes":"No") << endl;
	return 0;
}

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

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    bool flag = false;
    int cnt = 0;
    for (int i = a; i < max(c, d); i++){
        if (flag){
            if (s[i] == '#') cnt++;
            else {
                if (cnt > 1) {
                    cout << "No" << endl;
                    exit(0);
                }
                flag = false;
                cnt = 0;
            }
        }
        else if (s[i] == '#'){
            flag = true;
            cnt++;
        }
    }
    if (cnt > 1) {
        cout << "No" << endl;
        exit(0);
    }

    if (c < d){
        cout << "Yes" << endl;
    }
    else {
        flag = false;
        cnt = 0;
        for (int i = b - 2; i <= d; i++){
            if (flag){
                if (s[i] == '.') cnt++;
                else {
                    if (cnt > 2) {
                        cout << "Yes" << endl;
                        exit(0);
                    }
                    flag = false;
                    cnt = 0;
                }
            }
            else if (s[i] == '.'){
                flag = true;
                cnt++;
            }
        }
        if (cnt > 2) {
            cout << "Yes" << endl;
            exit(0);
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <iostream>
#include <iterator>
#include <sstream>

class Dice {
 private:
  std::array<int, 6> inner_;
  const size_t TABLE[6][2] = {{1, 3}, {5, 2}, {4, 0}, {5, 1}, {0, 3}, {4, 2}};

 public:
  Dice(std::string str) {
    std::istringstream stream(str);
    for(int i = 0; i != 6; ++i) {
      stream >> inner_[i];
    }
  }

  void roll(char dir) {
    std::array<int, 6> new_dice;
    switch(dir) {
    case 'N':
      new_dice[0] = inner_[1];
      new_dice[1] = inner_[5];
      new_dice[2] = inner_[2];
      new_dice[3] = inner_[3];
      new_dice[4] = inner_[0];
      new_dice[5] = inner_[4];
      break;
    case 'S':
      new_dice[0] = inner_[4];
      new_dice[1] = inner_[0];
      new_dice[2] = inner_[2];
      new_dice[3] = inner_[3];
      new_dice[4] = inner_[5];
      new_dice[5] = inner_[1];
      break;
    case 'W':
      new_dice[0] = inner_[2];
      new_dice[1] = inner_[1];
      new_dice[2] = inner_[5];
      new_dice[3] = inner_[0];
      new_dice[4] = inner_[4];
      new_dice[5] = inner_[3];
      break;
    case 'E':
      new_dice[0] = inner_[3];
      new_dice[1] = inner_[1];
      new_dice[2] = inner_[0];
      new_dice[3] = inner_[5];
      new_dice[4] = inner_[4];
      new_dice[5] = inner_[2];
      break;
    }
    inner_ = new_dice;
  }

  int get(int i) {
    return inner_.at(i);
  }

  std::size_t index(int x) {
    auto it = std::find(inner_.begin(), inner_.end(), x);
    return std::distance(inner_.begin(), it);
  }

  int right_side(int top, int front) {
    auto t = index(top);
    auto f = index(front);
    auto side = 3 - std::min(t, 5 - t) - std::min(f, 5 - f);
    return get(f == TABLE[t][0] || f == TABLE[t][1] ? side : 5 - side);
  }

  friend std::ostream &operator<<(std::ostream &out, const Dice &dice) {
    for(int i = 0; i != 5; ++i) {
      out << dice.inner_.at(i) << " ";
    }
    out << dice.inner_.at(5);
    return out;
  }
};

int main() {
  std::string line;
  std::getline(std::cin, line);
  Dice dice(line);

  int n;
  std::getline(std::cin, line);
  std::istringstream stream(line);
  stream >> n;

  for(int i = 0; i != n; ++i) {
    std::getline(std::cin, line);
    int a, b;
    std::istringstream stream(line);
    stream >> a >> b;
    std::cout << dice.right_side(a, b) << std::endl;
  }
  return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}

}

int arr[100001];
int f[100001];
int ma[100001];
int ans[100001];

int Find(int x) {

	if (x == f[x])
		return x;

	return f[x] = Find(f[x]); 

}
const int Mod = 1e9 + 7;

long long fastPower(long long base, long long power) {
	long long result = 1;
	while (power > 0) {
		if (power & 1) { 
			result = result * base % Mod;
		}
		power >>= 1; 
		base = (base * base) % Mod;
	}
	return result;
}
 
int Inv(int x) {
	return fastPower(x, Mod - 2);
}


int nChoosek(int n, int k) {
 
	int ans = 1;

	for (int i = 1; i <= k; ++i) 
		ans = ans * Inv(i) % Mod *(n - i + 1) % Mod;

	return ans % Mod;


}




int32_t  main() {

	IOS;

	int n, a, b;

	cin >> n >> a >> b;

	int ans = fastPower(2, n) - 1;

	ans -= nChoosek(n, a);
	ans -= nChoosek(n, b);

	ans = (ans%Mod + Mod) % Mod;

	cout << ans << endl;
 
}


Measured memory_bytes: 3176