akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(){
    int N;  cin >> N;
    VVI dp(N,vector<int>(3,0));
    VVI v(3,vector<int>(N,0));
    
    REP(i,N){
        cin >> v[0][i] >> v[1][i] >> v[2][i];
    }

    dp[0][0] = v[0][0];
    dp[0][1] = v[1][0];
    dp[0][2] = v[2][0];
  
    for(int i=1; i < N;i++){
        REP(j,3){
            int m = 0;
            REP(k,3){
                if(j != k){
                    m = max(m, dp[i-1][k] + v[j][i]);
                }
            }
            dp[i][j] = m ;
        }
    }

    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;  
    return 0;
}
   


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

using namespace std;

int main(void){
//string S;
int N;
string S;
cin >> N;
cin >> S;
//vector<int> P(N);
int pos = 0, abcnum = 0;

while(pos < S.size()){
  int tmp = S.find("ABC",pos);
  if(tmp != string::npos){
    abcnum++;
    pos = tmp + 3;
  }else if(tmp == string::npos){
    break;
  }

}

cout << abcnum << endl;

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 100;
const int MAXW = 10000;
int v[MAXN + 1], w[MAXN + 1];
int maxVal[MAXN + 1][MAXW + 1] = { 0 };
int main()
{
	int itemNum, maxCap;
	cin >> itemNum >> maxCap;
	for (int i = 1; i <= itemNum; i++)
		cin >> v[i] >> w[i];
	for(int i=1;i<=itemNum;i++)
		for (int c = 0; c <= maxCap; c++)
		{
			maxVal[i][c] = maxVal[i - 1][c];
			if (w[i] <= c)
				maxVal[i][c] = max(maxVal[i - 1][c], maxVal[i - 1][c-w[i]] + v[i]);
		}
	cout << maxVal[itemNum][maxCap] << endl;
}


Measured memory_bytes: 6968
S = input()
blank_cnt = len(S) - 1
ans = 0
for i in range(2 ** blank_cnt):
  formula = S[0]
  for j in range(blank_cnt):
    if (i >> j) & 1:
      formula += "+" + S[j + 1]
    else:
      formula += S[j + 1]
  ans += sum(list(map(int, formula.split("+"))))
print(ans)

Measured memory_bytes: 8928
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let ta: Vec<u64> = read_vec();
    let mut s1 = ta[0];
    let mut s2 = ta[1];
    for _ in 1..n {
        let ta: Vec<u64> = read_vec();
        let t = ta[0];
        let a = ta[1];
        let tmp = max((s1 - 1) / t + 1, (s2 - 1) / a + 1);
        s1 = tmp * t;
        s2 = tmp * a;
    }
    println!("{}", s1 + s2);
}


Measured memory_bytes: 4352
n = int(input())
a = []
b = []
for _ in range(n):
    aa, bb = [int(i) for i in input().split()]
    a.append(aa)
    b.append(bb)
a.sort()
b.sort()

if n % 2 == 0:
    mi = a[n // 2] + a[n // 2 - 1]
    ma = b[n // 2] + b[n // 2 - 1]
else:
    mi = a[n // 2]
    ma = b[n // 2]
print(ma - mi + 1)


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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf  = 1ll * inf * 5;
const int N = 100000 + 7;
const int M = 1007;
const int multipleTest = 0;

int k, n;

int dp[N];
int nxt[N];

void solve() {
    cin >> k;
    memset(dp, inf, sizeof(dp));
    
    dp[1] = 1;
    priority_queue<ii> heap;
    heap.push(mk(-dp[1], 1));
    
    while (!heap.empty()) {
        int u = heap.top().second;
        int rr = -heap.top().first;
        heap.pop();
        if (rr != dp[u]) continue;
        for (int j = 0; j < 10; ++j) {
            int mask = (u * 10 + j) % k;
            if (dp[mask] > dp[u] + j) {
                dp[mask] = dp[u] + j;
                heap.push(mk(-dp[mask], mask));
            }
        }
    }
    
    cout << dp[0];
    
}


void solve2() {
    cin >> k >> n;
    if (k % 2 == 0) {
        cout << k / 2 << ' ';
        rep(i, 1, n) printf("%d ", k);
    } else {
        if (n & 1) {
            rep(i, 0, n) printf("%d ", (k + 1) / 2);
        } else {
            rep(i, 1, n) printf("%d ", (k + 1) / 2);
            cout << k / 2;
        }
    }
    
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


Measured memory_bytes: 2804
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> L;
    for(int i=0;i<N;i++){
      int num;
        cin >> num;
      L.push_back(num);
    }
    int count = 0;
    sort(L.begin(),L.end(),greater<int>());
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(L[i]==L[j]) continue;
            for(int k=j+1;k<N;k++){
                if(L[j]==L[k]) continue;
                if(L[i]<L[j]+L[k]) count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 3732
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
inf = float('inf')
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n,m=reads()
ls=[]
link=[[]for i in range(n)]
for i in range(m):
  a,b=reads()
  a-=1
  b-=1
  link[a].append(b)
  link[b].append(a) 
count=[inf]*n
count[0]=0
#check={i:1 for i in range(n)}
#target=1-1
hoge=[0]
for i in range(n):
    targets=hoge
    hoge=[]
    for target in targets:
        for ele in link[target]:
            if count[ele]==inf:
                count[ele]=target+1
                #link[ele-1].remove(target)
                hoge.append(ele)
    if not hoge:
        break
if inf in count:
    print("No")
    exit()
print("Yes")
for i in count[1:]:
    print(i)

Measured memory_bytes: 93612
#include<stdio.h>
int A[101][101];
int main(){
  int n,i,j,k,id,kn;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&kn);
    for(j=0;j<kn;j++){
      scanf("%d",&k);
      A[id][k]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n-1;j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }
  return 0;
}
  
 



Measured memory_bytes: 2104
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

ans1=int(0)
ans2=int(0)

for i in range(x,n+1):
    if i in a:
        ans1+=1

for i in range(x,0,-1):
    if i in a:
        ans2+=1

print(min(ans1,ans2))


Measured memory_bytes: 3060
from collections import Counter

N = int(input())

if N <= 2:
    print(0)
else:
    count = 0
    for ii in range(3, N+1, 2):
        s = ii
        num = []
        for jj in range(3, s+1, 2):
            if s % jj == 0:
                s = s // jj
                num.append(jj)
                break
        if s == 1:
            continue
        for jj in range(num[-1]+2, s+1, 2):
            if s % jj == 0:
                s = s // jj
                num.append(jj)
                break
        if s == 1:
            continue
        for jj in range(num[-1]+2, s+1, 2):
            if s % jj == 0:
                count += 1
                break
    print(count)

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

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

	int i;
	int n;
	int t;
	int gettime = 0;
	
	Queue<String> p = new LinkedList<String>();
	Queue<Integer> time = new LinkedList<Integer>();
	
	n = sc.nextInt();
	t = sc.nextInt();
	
	for(i=0; i<n; i++){
	    p.add(sc.next());
	    time.add(sc.nextInt());
	}
	
	while(0 < p.size()){
	    if(0 < (time.peek() - t)){
		p.add(p.poll());
		time.add(time.poll() - t);
		gettime = gettime + t;
	    }else{
		gettime = gettime + time.poll();
		System.out.println(p.poll() + " " + gettime);
	    }
	}
    }
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, p, a, ev, od;
ll r, m[100][100];

ll c(int n, int r) {
	ll &res = m[n][r];
	if (res) return res;
	if (n==r || r==0) return res = 1;
	if (r==1) return res = n;
	return res = c(n-1, r-1) + c(n-1, r);
}

int main() {
	cin >> n >> p;
	rep(i,n) {
		cin >> a;
		ev += (a%2==0);
	}
	od = n - ev;
	
	// p==0 => (奇数をod個から偶数個選ぶ) * (偶数をev個から好きな個数選ぶ)
	// p==1 => (奇数をod個から奇数個選ぶ) * (偶数をev個から好きな個数選ぶ)
	repst(i,0,od) if (i%2==p) r += c(od, i);
	r *= 1ll<<ev;
	cout << r << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	
	int ti = n / x + ((n%x) ? 1 : 0);
	cout << ti * t;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

int main() {
	long x;
	scanf("%ld",&x);
	long n = 1;
	x *= 2;
	while (n*(n+1)<x) {
		n++;
	}
	printf("%ld\n",n);
	return 0;
}

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

using namespace std;

#define loop(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n, m; cin >> n >> m;
    vector<int> f(m), s(m);
    vector <bool> used(m, false);
    rep(i, m){
        int a, b; cin >> a >> b;
        f[i] = a - 1;
        s[i] = b - 1;
    }
    int ans = 0;

    int l = 0;
    bool ok = true;
    while (1){
        int cp = -1;
        int i;
        for (i = 0; i < m; i++){
            if (f[i] <= l && (cp == -1 || s[i] > s[cp])) cp = i;
        }
        if (cp == -1 || used[cp] == true) { ok = false; break; }
        ans++;
        used[cp] = true;
        if (s[cp] == n - 1) break;
        else l = s[cp] + 1;

    }
    if (ok) cout << ans << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
AZ = [chr(i) for i in range(65, 65+26)]
M = ""

for i in S:
    for j in range(len(AZ)):
        if i == AZ[j]:
            i = AZ[(j+N) % 26]
            M += i
            break;

print(M)


Measured memory_bytes: 42092
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, a, b, c, d = [int(x) for x in input().split()]
    s = input() + '#'
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    
    gg = 0
    y = s.find('##', a)
    if y != -1 and y <= max(c, d) and y > min(a, b):
        gg = 1
    if c > d:
        x = s.find('...', b)
        xd = 1
        if ((s[b + 1] == s[b - 1] and s[b - 1] == '.') 
            or (s[b+1] == s[b+2]  and s[b+1] == '.')
            or (x != -1 and x + 1 <= d)):
            xd = 0
        if gg or xd:
            print("No")
        else:
            print("Yes")
    else:
        if gg:
            print("No")
        else:
            print("Yes")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""


Measured memory_bytes: 9548
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main() {
	long long N, H[100002], count1, count2;
	count1 = 0;
	count2 = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	H[N] = 2000000000;
	for (int i = 0; i < N; i++) {
		if (H[i] >= H[i + 1]) {
			count1++;
		}
		else {
			if (count2 < count1) {
				count2 = count1;
		}
			count1 = 0;
		}
}
	cout << count2 << endl;


	return 0;
}


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

int main() {
    int N;
    int p[30];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> p[i];
    int c = 0;
  
    for (int i = 1; i < N-1; ++i){
    	  if(p[i]>p[i-1] && p[i+1]>p[i]) c++;
          else if(p[i]<p[i-1] && p[i+1]<p[i]) c++;
    }  
    
    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
 
int main() {
  // input
    int n;cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i < n + 1; i++) cin >> a[i];

  // compute
    vector<int> b(n);
    int counter = 1;
    int f = 0;

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }    

    for(int i = 1; i < n; i++) b[i] = a[i + 1] - a[i];

    //flag
    if(b[1] > 0){
        f = 1;
    }else if(b[1] < 0){
        f = -1;
    }    

    for(int i = 1; i < n - 1 ; i++){
        if(f == 1){
            if(b[i + 1] >= 0){
            }else{
                counter++;
                f = 0;
            }
        }else if(f == -1){
            if(b[i + 1] <= 0){
            }else{
                counter++;
                f = 0;
            }            
        }else{
            if(b[i + 1] > 0){
                f = 1;
            }else if(b[i + 1] < 0){
                f = -1;
            }  
        }
        }

  // output  
    cout << counter << endl;

}


Measured memory_bytes: 4060
#include<stdio.h>
struct EyeTest {
	int left_eye;
	int right_eye;
};
int main(void) {
	struct EyeTest data[4] = {0,0};
	double l, r;
	int i;

	while (scanf("%lf %lf", &l, &r) != EOF) {
		if (l >= 1.1) 
			data[0].left_eye++;
		else if (l >= 0.6 &&  l < 1.1)
			data[1].left_eye++;
		else if (l >= 0.2 &&  l < 0.6)
			data[2].left_eye++;
		else if (l < 0.2)
			data[3].left_eye++;

		if (r >= 1.1)
			data[0].right_eye++;
		else if (r >= 0.6 &&  r < 1.1)
			data[1].right_eye++;
		else if (r >= 0.2 &&  r < 0.6)
			data[2].right_eye++;
		else if (r < 0.2)
			data[3].right_eye++;
	}
	for (i = 0; i < 4; i++) 
		printf("%d %d\n",data[i].left_eye,data[i].right_eye);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  long min;
  long total=0;
  for(int i=0;i<100;i++){
    total = 0;
    for(int j=0;j<n;j++){
      total += (x[j]-(i+1))*(x[j]-(i+1));
    }
    if(i==0){
      min = total;
    }else if(total<min){
      min = total;
    }
  }
  cout << min;
  
  
}




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

int N;
vector<int> W;

void solve(){
	int ans = 100000;
	for(int t=0;t<N;t++){
		int s_1 = 0;
		int s_2 = 0;
		for(int i=0;i<N;i++){
			if(i<=t) s_1 += W[i];
			else s_2 += W[i];
		}
		ans = min(ans, abs(s_1-s_2));
	}
	cout << ans << endl;
}


int main(){
	cin >> N;
	W.resize(N);
	for(int i=0;i<N;i++){
		cin >> W[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int k;
	cin >> k;
	int now = 7;
	for (int i = 1; i < 1000010; i++) {
		if (now % k == 0) {
			cout << i << '\n';
			return 0;
		}
		now *= 10; now += 7; now %= k;
	}
	cout << "-1\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"------------------------"<<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int n;
int ara[1009];
int sum[1009];
int sum1[1009];
int  main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>ara[i];
        sum[i]+=sum[i-1]+ara[i];
    }
    for(int i=n;i>=1;i--)
    {
        sum1[i]+=sum1[i+1]+ara[i];
    }
    int maxi=INT_MAX;
    for(int i=1;i<n;i++)
    {
        int d=sum[i];
        int e=sum1[i+1];
        int ans=fabs(d-e);
        if(ans<maxi) maxi=ans;
    }
    cout<<maxi<<endl;
}


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

int tree(int i, vector<int> &v, vector<int> &s, vector<int> &memo){

    int i_target;
    i_target = v.at(i);
    if(i_target == -1){
        return memo.at(i) = s.at(i);
    }

    if(memo.at(i_target) == -1){
        return s.at(i) + tree(i_target, v, s, memo);
    }else{
        return memo.at(i) = s.at(i) + memo.at(i_target);
    }

}

int main(){

    int N, Q;
    cin >> N >> Q;

    vector<int> t(N, -1);
    int a, b;
    for(int i = 0; i < N - 1; i++){
        cin >> a >> b;
        t.at(b - 1) = a - 1;
    }

/*
    for(int i = 0; i < N; i++){
        cout << t.at(i) << endl;
    }
*/

    int p, x;
    vector<int> s(N, 0);
    for(int i = 0; i < Q; i++){
        cin >> p >> x;
        s.at(p - 1) += x;
    }

/*
    for(int i = 0; i < N; i++){
        cout << s.at(i) << endl;
    }
*/

    vector<int> memo(N, -1);
    for(int i = 0; i < N; i++){
        cout << tree(i, t, s, memo) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4736
S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 1:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))

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

int main() {
int W,H,x,y,r;
cin >>W>>H>>x>>y>>r;
if(r<=x&&x<=W-r && r<=y&&y<=H-r){
	string s="Yes";
	cout<<s<<endl;
}else{
	string s="No";
	cout<<s<<endl;
}


}

Measured memory_bytes: 3204
##WA 和がSになる組み合わせを列挙しようとしたけど無理だった。
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
mod = 998244353
n,s = ma()
A = list(ma())
dp = [[0]*(s+1) for i in range(n+1)]#dp[i][j]はi番目までの要素を用いてjになるような場合の数
dp[0][0] = 1
for i in range(n):
    a = A[i]
    for j in range(s+1):
        dp[i+1][j] =(dp[i][j]*2)%mod
        if a<=j:
            dp[i+1][j] = (dp[i][j-a] +dp[i+1][j]) %mod

print(dp[n][s])
#print(dp)


Measured memory_bytes: 139652
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	long long int x, y;
	long long int count = 0;
	long long int point = 0;

	cin >> x >> y;
	point = x;
	while (1) {
		if (point <= y) {
			point += point;
			count++;
		}
		else {
			break;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e2+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = 3.14159265358979323846;

void solve(){
    int n,cnt=0;
    double d;
    cin>>n>>d;
    loop(n,i,0){
        double x,y;
        cin>>x>>y;
        if(d*d>=x*x+y*y)
            cnt++;
    }
    cout<<cnt<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3792
import math
N, K = map(int, input().split())
mod = 10**9+7

def combinations_count(n, k):
    return math.factorial(n) // (math.factorial(n - k) * math.factorial(k))

comb = combinations_count(N, K)

cnt = K
for i in range(min(K-1, N-K)):
    ans = combinations_count(K-1, i) * combinations_count(N-K+1, i+1) 
    comb -= ans
    ans %= mod
    print(ans)
    cnt -= 1

print(comb % mod)
cnt -= 1

if cnt != 0:
    for i in range(cnt):
        print(0)


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	vector<double>P(N);
	for (int i = 0; i < N; ++i)cin >> P[i];
	double dp[3100][3100];
	//dp[i][j]:=最初のi枚のコインを投げた時に表がj枚となる確率
	//とすると緩和式は次のコインが表の時:dp[i+1][j+1]+=dp[i][j]*p
	//次のコインが裏の時:dp[i+1][j]+=dp[i][j]*(1-p)となります
	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * P[i];
			dp[i + 1][j] += dp[i][j] * (1 - P[i]);
		}
	}
	double res = 0.0;
	for (int j = (N + 1) / 2; j <= N; ++j)res += dp[N][j];
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}

Measured memory_bytes: 74752
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}
const ll MOD = 1e9 + 7;
int n, m;
ll fact[400000];
ll ifact[400000];

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

ll cnk(ll n, ll k)
{
    ll res = fact[n];
    res *= ifact[k];
    if (res >= MOD) res %= MOD;
    res *= ifact[n - k];
    return res % MOD;
}

signed main()
{
    fact[0] = 1;
    for (int i = 1; i < 400000; i++) fact[i] = fact[i - 1] * i % MOD;
    for (int i = 0; i < 400000; i++) ifact[i] = inq(fact[i], MOD - 2);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    vector<int> v;
    for (int j = 2; j * j <= m; j++)
    {
        int cnt = 0;
        while (m % j == 0)
        {
            m /= j;
            cnt++;
        }
        v.push_back(cnt);
    }
    if (m > 1)
    {
        v.push_back(1);
    }
    ll ans = 1;
    for (int i = 0; i < v.size(); i++)
    {
        ans = (ans * cnk(v[i] + n - 1, n - 1)) % MOD;
    }
    cout << ans;
}

Measured memory_bytes: 6656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int h = sc.NextInt();
        int w = sc.NextInt();

        for (int i = 0; i < h; i++)
        {
            string str = sc.Next();
            Console.WriteLine(str);
            Console.WriteLine(str);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			var n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		List<Pair> L=new List<Pair>();
		
		for(int i=0;i<N;i++){
			var d=ria();
			L.Add(new Pair(d[0],d[1]));
		}
		
		L.Sort((x,y)=>x.W>y.W?1:x.W<y.W?-1:0);
		
		bool chk=true;
		int sum=0;
		for(int i=0;i<N;i++){
			sum+=L[i].T;
			if(sum>L[i].W){
				chk=false;
				break;
			}
		}
		
		Console.WriteLine(chk?"Yes":"No");
		
		
	}
	
	int N;
	public Sol(int n_){
		N=n_;
	}
	
	class Pair{
		public int T;
		public int W;
		public Pair(int t,int w){
			T=t;W=w;
		}
	}



	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5540
#include <iostream>

using namespace std;

int main(void)
{
  int A, N = 0, i = 0, flag = 0;
  cin >> N >> A;
  
  while (N >= 500) N -= 500;
  if (N == 0) flag = 1;
  
  for (i = 0; i < A; i++) {
    N -= 1;
    if (N == 0) { flag = 1; break; }
  }
  
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
int n,q;
string s;
int main(){
    int l,r;
    cin>>n>>q>>s;
    vector<int>index;
    rep(i,n-1){
        string ac=s.substr(i,2);
        if(ac=="AC"){
            index.push_back(i);
        }
    }
    rep(i,q){
        cin>>l>>r;
        l--;r--;
        auto ite_l=lower_bound(ALL(index),l);
        auto ite_r=lower_bound(ALL(index),r);
        cout<<ite_r-ite_l<<endl;
    }
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000007];
int b[1000007];
int main(){
  int n;
  cin>>n;
  int m=0;
  for(int i=0;i<n;i++){
      cin>>a[i];
     if(a[i]>m) m=a[i];
  }
 
  for(int i=0;i<n;i++){
      int j=a[i];
    for(;j<=m;j+=a[i]){
      b[j]++;
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++){
if(b[a[i]]==1) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

int f[110];
int p[110][15];

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int s = 0;
        rep(j,10){
            bool x;
            cin >> x;
            if(x)s=(s<<1)|1;
            else s=s<<1;
        }
        f[i]=s;
    }
    ll ans = -INF;
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }
    for (int bit =1;bit<(1<<10);bit++){
        ll tmp = 0;
        rep(i,n){
            int now = bit&f[i];
            int cnt = __builtin_popcount(now);
            tmp += p[i][cnt];
        }
        chmax(ans,tmp);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll n, m;
V<V<int>> G;
V<V<ll>> x;
V<ll> dp;
V<int> pp;

void dfs1(const int &i, const int &p) {
    dp[i] = 1;
    for(int e : G[i]) {
        if(e != p) {
            dfs1(e, i);
            x[i].push_back((dp[e] + 1) % m);
            dp[i] *= dp[e] + 1;
            dp[i] %= m;
        } else {
            pp[i] = x[i].size();
            x[i].push_back(-1);
        }
    }
}

void dfs2(const int &i, const int &p, const ll &d_p = -1) {
    if(p != -1) {
        x[i][pp[i]] = d_p;
        (dp[i] *= d_p) %= m;
    }
    V<ll> s1, s2;
    s1 = s2 = x[i];
    rep(j, s1.size() - 1)(s1[j + 1] *= s1[j]) %= m;
    FORR(j, s2.size() - 1)(s2[j] *= s2[j + 1]) %= m;
    rep(j, G[i].size()) {
        if(G[i][j] == p) continue;
        ll d =
            ((j ? s1[j - 1] : 1) * (j + 1 < G[i].size() ? s2[j + 1] : 1) + 1) %
            m;
        dfs2(G[i][j], i, d);
    }
}

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

    cin >> n >> m;
    G.resize(n);
    dp.resize(n);
    x.resize(n);
    pp.assign(n, -1);
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs1(0, -1);
    dfs2(0, -1);
    rep(i, n) cout << dp[i] << endl;

    return 0;
}

Measured memory_bytes: 26880
import sys,math
def prime(m):
  N=range(1,m+2,2)
  r=int(m**.5)
  h=len(N)
  N[0]=0
  for i in range(h):
    x=N[i]
    if x>r:break
    if x and i+x<h:N[i+x:h:x]=[0]*((h-1-i-x)/x+1)
  N[0]=2
  return filter(None,N)
A=map(int,sys.stdin)
n=max(A)
B=[0]*(n+1)
i=0
c=0
for e in prime(n):
  while e>i:
    B[i]=c
    i+=1
  c+=1
  if i==n+1:break
else:
  for i in range(i,n+1):B[i]=c
for e in A:print B[e]

Measured memory_bytes: 47176
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
	double one, two;

	while ( scanf( "%lf %lf", &one, &two ) != EOF ) {
		if ( one < 35.50 && two < 71.00 ) {
			printf( "AAA\n" );
		} else if ( one < 37.50 && two < 77.00 ) {
			printf( "AA\n" );
		} else if ( one < 40.00 && two < 83.00 ) {
			printf( "A\n" );
		} else if ( one < 43.00 && two < 89.00 ) {
			printf( "B\n" );
		} else if ( one < 50.00 && two < 105.00 ) {
			printf( "C\n" );
		} else if ( one < 55.00 && two < 116.00 ) {
			printf( "D\n" );
		} else if ( one < 70 && two < 148.00 ) {
			printf( "E\n" );
		} else {
			printf( "NA\n" );
		}
	}

	return 0;
}



Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
int GCD(int a,int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}
int main(void){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];
    for(int i=0;i<N;i++)cin>>x[i];
    for(int i=0;i<M;i++)cin>>y[i];
    sort(x,x+N);
    sort(y,y+M);
    int max_x = x[N-1];
    int min_y = y[0];
    if(max_x < min_y && max_x < Y && min_y > X){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }
}


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

using namespace std;

int main()
{
  map<char, long long int> ans;
  while(1)
  {
    string s;
    getline(cin, s);
    if(s.size() == 0) break;
    for(long long int i = 0;i < s.size();i++)
    {
      if(s[i] >= 'A'&&s[i] <= 'Z')
      s[i] += 32;
      if(ans.count(s[i])) ans[s[i]]++;
      else ans[s[i]] = 1;
    }
  }
  for (char i = 'a'; i <= 'z'; i++)
  {
    cout << i << " : " << ans[i] << endl;
  }
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char s[24];
    cin.getline(s, 24);
    int n = cin.gcount()-1;
    for(int i=n-1; i>=0; --i) cout<<s[i];
    cout<<'\n';
    return 0;
}

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;
using EDGE = vector<int>;
using GRAPH = vector<EDGE>;

////////////////////////////////
struct unionfind{
    std::vector<int> data;
    unionfind(int n):data(n,-1){};
    int root(int idx){
        return data[idx]<0?idx:data[idx]=root(data[idx]);
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    bool join(int x,int y){
        x = root(x); y = root(y);
        if(x==y)return false;
        if(data[x]>data[y])std::swap(x,y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
};

int main()
{
    int n,q;
    cin >> n >> q;
    unionfind uf(n);
    for(int i=0;i<q;i++){
        int c,x,y;
        cin >> c >> x >> y;
        if(c == 0)uf.join(x,y);
        else cout << (int)uf.same(x,y) << endl;
    }
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    unsigned int k, i, t = 7; cin >> k;
    for (i = 1; i <=  k; i++) {
        if (t % k == 0) {
            cout << i << "\n";
            return EXIT_SUCCESS;
        }
        t = (10 * t + 7) % k;
    }
    cout << -1 << "\n";
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3684
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n;
  cin>>n;
  string s[n];
  int c0=0,c1=0,c2=0,ab_count=0;
  for(int i = 0; i < n; i++) {
    cin>>s[i];
    if(s[i][0]=='B'&&s[i][s[i].length()-1]!='A') c1++;
    if(s[i][0]!='B'&&s[i][s[i].length()-1]=='A') c2++;
    if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A') c0++;
    for(int j = 0; j < s[i].length()-1; j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B') ab_count++;
    }
  }
  if(c0==0) cout<<min(c1,c2)+ab_count<<endl;
  else if(c1+c2>0) cout<<c0+min(c1,c2)+ab_count<<endl;
  else cout<<c0-1+ab_count<<endl;
  // cout<<c0<<" "<<c1<<" "<<c2<<" "<<ab_count<<endl;

  return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> right(n);
	vector<int> left(n);
	for (int i = 0; i < n; ++i) {
		if (i != 0) {
			left[i] = left[i - 1];
		}
		if (s[i] == 'R') {
			left[i] = i;
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (i != n - 1) {
			right[i] = right[i + 1];
		}
		if (s[i] == 'L') {
			right[i] = i;
		}
	}
	vector<int> answer(n);
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'L') {
			int where = left[i];
			int moves = i - where;
			moves %= 2;
			if (moves == 1) {
				++answer[where + 1];
			} else {
				++answer[where];
			}
		} else {
			int where = right[i];
			int moves = where - i;
			moves %= 2;
			if (moves == 1) {
				++answer[where - 1];
			} else {
				++answer[where];
			}
		}
	}
	for (int x : answer) {
		cout << x << ' ';
	}
	cout << '\n';
	
 	return 0;
}


Measured memory_bytes: 1872
#include <iostream>
#include <algorithm>
#include <string>

int main() {
    int N;
    std::string S;
    std::cin >> N >> S;
    int r = std::count(S.begin(), S.end(), 'R');
    int b = std::count(S.begin(), S.end(), 'B');
    std::cout << (r > b ? "Yes" : "No") << std::endl;
    return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  //最後のりんご
  int R = L + N - 1;
  
  /*
  味が全部負であればR
  正負横断してるなら0
  味が全部正ならL(一番小さいもの) を食べる
  */
  
  int eat;
  if(R <= 0)
    eat = R;
  else if(L >= 0)
    eat = L;
  else
    eat = 0;
  
  int ans = (R+L)*N/2-eat;
  cout << ans << endl;
}




Measured memory_bytes: 256