akhauriyash/Code-Regression huggingface dataset:
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}


char S[1003] = {0};
int main()
{
	scanf("%s", S);

	int len = strlen(S);
	if (S[len-1] == 's') {
		S[len] = 'e';
		S[len+1] = 's';
	} else {
		S[len] = 's';
	}
	printf("%s\n",S);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1624
#include <iostream>

using namespace std;

int main(void)
{

	int n;

	int i1,i2;
	int sum;
	int count;

	while(1){
		cin >> n;
		if (n==0) break;

		count = 0;
		for(i1=1;i1<n;i1++){
			sum = i1;
			for(i2=i1+1;i2<n;i2++){

				sum+=i2;
				if (sum == n) {
					count++;
					break;
				}
				else if (sum > n){
					break;
				}

			}
		}

		cout << count << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  vector<int> sta(26, -1);
  vector<int> gol(26, -1);

  for (int i = 0; i < s.size(); ++i) {
    int s_num = s.at(i) - 'a';
    int g_num = t.at(i) - 'a';

    if (sta.at(s_num) != -1 || gol.at(g_num) != -1) {
      if (sta.at(s_num) != g_num || gol.at(g_num) != s_num) {
        cout << "No" << endl;
        return 0;
      }
    }
    sta.at(s_num) = g_num;
    gol.at(g_num) = s_num;
  }
  cout << "Yes" << endl;
}


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

using namespace std;

int main() {
        cin.sync_with_stdio(0);
      
        int n;
        cin >> n;

        set<string> s;
        for (int i = 0; i < n; ++i) {
                string a;
                cin >> a;
                s.insert(a);
        }

        cout << s.size();

        return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
    string S;
    cin >> S;
    set<char> letters;
    for(char c : S) {
        letters.insert(c);
    }
    bool found = false;
    for(int c = 97; c <= 122; ++c) {
        if(letters.count((char)c) == 0) {
            found = true;
            cout << (char)c << endl;
            break;
        }
    }
    if(!found)
        cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>

int main(void){
    double x1,y1,x2,y2;

    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    printf("%.8f\n",(double)sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    
    cout << (double)(N*2)*3.141592653589;
    return 0;
}

Measured memory_bytes: 3804
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 10005
#define INF 10000005

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

int V;
ll K;

struct edge{int to,cost;};
vector<edge> G[SIZE];
int d[SIZE];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d,d+V,INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first)continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int main()
{
	scanf("%d",&V);
	int u,k,v,c;
	for(int i=0;i<V;i++){
		scanf("%d%d",&u,&k);
		for(int j=0;j<k;j++){
			scanf("%d%d",&v,&c);
			G[u].push_back((edge){v,c});
		}
	}
	dijkstra(0);
	for(int i=0;i<V;i++){
		printf("%d %d\n",i,d[i]);
	}
	return 0;
}



Measured memory_bytes: 7552
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
    if(a[x] == a[y]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;
const long long M=1000000007;

ll m,n,t,ans;

int main(){
  cin >>m>>n;
  ans=1;
  for(int i=0;(1<<i)<=n;i++){
    if((1<<i) & n){
      ans=(ans*m)%M;
    }
    m=(m*m)%M;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=1000000007;
//
int main(){
	int l,r,d;
	cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.*;//115_A
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    if(d==25){
      System.out.println("Christmas");
    }else if(d==24){
      System.out.println("Christmas Eve");
    }else if(d==23){
      System.out.println("Christmas Eve Eve");
    }else if(d==22){
      System.out.println("Christmas Eve Eve Eve");
    }
  }
}


Measured memory_bytes: 21972
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val G = Array(N) { mutableListOf<Pair<Int, Int>>() }
    repeat(M) {
        var (l, r, d) = listOfInt()
        l -= 1; r -= 1
        G[l].add(r to d)
        G[r].add(l to -d)
    }
    val INF = 1000000007
    val X = IntArray(N) { INF }
    fun bfs(n: Int) {
        if (X[n] != INF) return
        X[n] = 0
        val Q = Queue<Int>()
        Q.enqueue(n)
        while (!Q.isEmpty()) {
            val now = Q.dequeue()!!
            for (next in G[now]) {
                if (X[next.first] == INF) {
                    X[next.first] = X[now] + next.second
                    Q.enqueue(next.first)
                }
            }
        }
    }
    repeat(N) { bfs(it) }
    for (n in 0 until N) {
        for (g in G[n]) {
            if (X[g.first] - X[n] != g.second) {
                println("No")
                return
            }
        }
    }
    println("Yes")
}
class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }



Measured memory_bytes: 116372
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()
typedef long double f80;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
    uniform_int_distribution<ll> uid(l, r);
    return uid(rng);
}
 
const int mod = 998244353;
int pwr(int a,int b) {
    int ans = 1;
    while(b) {
        if(b & 1) {
            ans = (ans * 1LL * a) % mod;
        }
        a = (a * 1LL * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int NN = 4e6 + 5;
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    bitset<NN> b;
    int sum = 0;
    b[0] = 1;
    fr(i, 1, n) {
        int x;
        cin >> x;
        sum += x;
        b |= (b << x);
    }
    fr(i, (sum + 1) / 2, NN - 1) {
        if(b[i]) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;

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

    int G[N];
    for(int i = 0; i < N; i++) {
        G[i] = 1;
    }

    int A, B;
    for(int i = 0; i < M; i++) {
        cin >> A >> B;
        if(H[A-1] < H[B-1]) {
            G[A-1] = 0;
        } else if(H[A-1] > H[B-1]) {
            G[B-1] = 0;
        } else if(H[A-1] == H[B-1]) {
            G[A-1] = 0;
            G[B-1] = 0;
        }
    }

    int count = 0;
    for(int i = 0; i < N; i++) {
        count += G[i];
    }

    cout << count << endl;

#if 0
    6 5
    1 2 3 4 5 6
    8 6 9 1 2 1

    1 3 : 0 1 1 1 1 1
    4 2 : 0 1 1 0 1 1
    4 3 : 0 1 1 0 1 1
    4 6 : 0 1 1 0 1 0
    4 6 : 0 1 1 0 1 0
#endif

    return 0;
}

Measured memory_bytes: 4376
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    uint x;
    foreach (i, c; s)
        x |= 1 << (c - 'a');
    // writefln("%b", x);

    if (x == (1 << 26) - 1)
    {
        writeln("None");
        return;
    }

    foreach (c; 'a' .. 'z' + 1)
        if ((x & (1 << (c - 'a'))) == 0)
        {
            writeln(cast(char) c);
            return;
        }

}


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

int getMax(string s, char letter){
  int result = 0;
  s = letter + s + letter;
  int left = 0;
  for(int right=1; right < s.size(); right++){
    if(s[right] == letter){
      result = max(result, right - left - 1);
      left = right;
    }
  }
  return result;
}


int main(){
  string s;
  cin >> s;
  int ans = 1e6;
  for(char letter = 'a'; letter <= 'z'; letter++){
    ans = min(ans, getMax(s, letter));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define endll "\n"

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int c=0,n;
    cin >> n >> s;

    for(int i = 0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')c++;
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n;
  scanf("%d", &n);
  int *A;
  A = (int *)malloc(sizeof(int) * n + 1);
  int max = 0, i;
  for(i = 1; i < n + 1; i++){
    scanf("%d", &A[i]);
    if(A[i] > max)
      max = A[i];
  }
  int *C;
  C = (int *)malloc(sizeof(int) * max + 1);
  for(i = max - 1; i >= 0; i--)
    C[i] = 0;
  for(i = n; i > 0; i--){
    C[A[i]]++;
    //    printf("%d/%d ", A[i], C[A[i]]);
  }
  for(i = 1; i < max + 1; i++){
    //    printf(".%d ", C[i]);
    C[i] += C[i - 1];
    //    printf("_%d ", C[i]);
  }
  int *B;
  B = (int *)malloc(sizeof(int) * n + 1);
  //  for(i = n + 1; i > 0; i--)
  //    B[i] = 0;
  for(i = n; i > 0; i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  for(i = 1; i < n; i++)
    printf("%d ", B[i]);
  printf("%d\n", B[i]);
  free(A), free(B), free(C);
  return 0;
}

Measured memory_bytes: 16124
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    double n;
    cin >> n;
    for( int i = 1; i <= n; ++i ) {
        int tmp = i * 1.08;
        if( tmp == n ) {
            cout << i << endl;
            return 0;

        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(x,y) '(' << x << ',' << y << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll N;
struct P {double x,y;};
vector<P> p;

double dist(P a,P b){
   double dx = a.x - b.x;
   double dy = a.y - b.y;
   return sqrt(dx*dx+dy*dy);
}

double f(double x,double y){
   double res = 0;
   rep(i,N){
      res = max(res,dist(P{x,y},p[i]));
   }
   return res;
}

double g(double x){
   double l = 0,r = 1010;
   rep(i,100){
      double c1 = (l*2+r)/3,c2 = (l+r*2)/3;
      if(f(x,c1) > f(x,c2)) l = c1;
      else r = c2;
   }
   return f(x,l);
}

int main(){
   cin >> N;
   p = vector<P>(N);
   rep(i,N) cin >> p[i].x >> p[i].y;
   double l = 0,r = 1010;
   rep(i,100){
      double c1 = (l*2+r)/3,c2 = (l+r*2)/3;
      if(g(c1) > g(c2)) l = c1;
      else r = c2;
   }

   double ans = g(l);
   cout << setprecision(20) << fixed;
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

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

	int a = (4 * x - y) / 2;
	int b = (y - 2 * x) / 2;

	if ((a + b == x) && (2 * a + 4 * b == y) && a >= 0 && b >= 0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n,k;
    cin>>n>>k;
    bool b[n];
    memset(b,false,sizeof(b));
    int ans=0;
    while(k--){
        int d;
        cin>>d;
        for(int i=0;i<d;i++){
            int x; cin>>x;
            b[x-1]=true;
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]==false) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
vector<pair<int,int>>task;
int main(){
  int n,sum=0;bool able=true;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    task.emplace_back(b,a);
  }
  sort(task.begin(),task.end());
  for(auto& i:task){
    sum+=i.second;
    if(sum>i.first){able=false;break;}
  }
  if(able)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
    int a=0,b=1,c=2;
    int N;
    cin>>N;
    vector<int> A(N+1,0),B(N+1,0),C(N+1,0);
    for(int i=1;i<=N;i++)
    {
        cin>>A[i]>>B[i]>>C[i];
    }

    vector<vector<int> > dp(3,vector<int>(N+1,0));
    dp[a][1]=A[1],dp[b][1]=B[1],dp[c][1]=C[1];
    for(int i=2;i<=N;i++)
    {
        dp[a][i]=A[i]+max(dp[b][i-1],dp[c][i-1]);
        dp[b][i]=B[i]+max(dp[a][i-1],dp[c][i-1]);
        dp[c][i]=C[i]+max(dp[b][i-1],dp[a][i-1]);
    }
    cout<<max(dp[a][N],max(dp[c][N],dp[b][N]))<<endl;

    return 0;
}


Measured memory_bytes: 2944
use std::cmp;
const MAX_D: usize = 13;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut count = vec![0; MAX_D];
    count[0] = 1;
    for _ in 0..n {
        let d: usize = sc.read();
        count[d] += 1;
    }

    for i in 0..MAX_D {
        if count[i] >= 3 {
            println!("0");
            return;
        }
    }

    let mut max = 0;
    for mask in 0..(1 << MAX_D) {
        let mut v = Vec::new();

        // construct
        for i in 0..MAX_D {
            if count[i] == 2 {
                v.push(12 - i);
                v.push(12 + i);
            } else if count[i] == 1 {
                if (mask >> i) & 1 != 0 {
                    v.push(12 - i);
                } else {
                    v.push(12 + i);
                }
            }
        }

        // check
        v.sort();
        let mut min = 30;
        for i in 0..v.len() {
            let from = v[i];
            for j in (i + 1)..v.len() {
                let to = v[j];
                let d = to - from;
                let d = cmp::min(d, 24 - d);
                min = cmp::min(min, d);
            }
        }

        max = cmp::max(max, min);
    }

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

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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


def solve(N: int, M: int, P: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    import numpy as np
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph import bellman_ford, NegativeCycleError

    def to_csr_matrix(X, Y, Z, shape, dtype):
        d = {}
        for x, y, z in zip(X, Y, Z):
            d[(x, y)] = max(d.get((x, y), -float("inf")), z)
        ind, data = zip(*d.items())
        return csr_matrix((data, zip(*ind)), shape=shape, dtype=dtype)

    smat = bellman_ford(csr_matrix((C, (A, B)), shape=(N+1, N+1), dtype=np.int32),
                        directed=True, unweighted=True, indices=1)
    tmat = bellman_ford(csr_matrix((C, (B, A)), shape=(N+1, N+1), dtype=np.int32),
                        directed=True, unweighted=True, indices=N)
    r = set([i for i, v in enumerate(smat + tmat) if not np.isinf(v)])
    A, B, C = zip(*[(a, b, c) for a, b, c in zip(A, B, C) if b in r])
    try:
        csr_mat = to_csr_matrix(A, B, C, (N+1, N+1), np.float64)
        csr_mat.data = P - csr_mat.data
        return -min(int(bellman_ford(csr_mat, directed=True, indices=1)[N]), 0)
    except NegativeCycleError:
        return -1

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    print(solve(N, M, P, A, B, C))

if __name__ == '__main__':
    main()


Measured memory_bytes: 40420
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()

flg = [True for _ in range(10 ** 6 + 1)]
for i in range(n-1):
    if a[i] == a[i+1]:
        flg[a[i]] = False

ans = 0
for x in set(a):
    if flg[x]:
        ans += 1

    tmp = 1
    while tmp * x <= 10 ** 6:
        flg[tmp * x] = False
        tmp += 1

print(ans)

Measured memory_bytes: 167940
n=int(input())
ba=0
b=0
a=0
ans=0
for _ in range(n):
    s=input()
    if s[0]=="B" and s[-1]=="A":
        ba+=1
    elif s[0]=="B":
        b+=1
    elif s[-1]=="A":
        a+=1
    for i in range(0,len(s)-1):
        if s[i]=="A" and s[i+1]=="B":
            ans+=1
if a==0:
    if b==0:
        ans+=max(0,ba-1)
    else:
        ans+=ba
else:
    if b==0:
        ans+=ba
    else:
        if ba==0:
            ans+=min(a,b)
        else:
            ans+=(ba+1)+min(b-1,a-1)
print(ans)


Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string[] i = Console.ReadLine().Split(' ');
        int a = int.Parse(i[0]);
        int b = int.Parse(i[1]);

        int d = a / b;
        int r = a % b;
        double f = (double)a / b;

        Console.WriteLine("{0} {1} {2}", d, r, f.ToString("f5"));
    }
}


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

using namespace std;

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

    string S[60];
    
    for(int i=0;i<N;i++){
        cin >> S[i];
    }

    string ans;

    for(char c='a';c<='z';c++){
        int small = 500;
        for(int i=0;i<N;i++){
            int count = 0;
            for(int j=0;j<S[i].length();j++){
                if(c == S[i][j]){count++;}
            }
            small = min(small, count);
        }
        for(int i=0;i<small;i++){ans+=c;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Card {
    char suit;
    int value;
};

void bubble (struct Card C1[], int N) {
    for ( int i = 0; i < N; i++ ) {
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( C1[j].value < C1[j - 1].value ) {
                Card t = C1[j];
                C1[j] = C1[j - 1];
                C1[j-1] = t;
            }
        }
    }
}

void selection ( struct Card C2[], int N) {
    for ( int i = 0; i < N; i++ ) {
            int minj = i;
        for ( int j = i; j < N; j++) {
            if ( C2[j].value < C2[minj].value )
                minj = j;
        }
        Card t = C2[i];
        C2[i] = C2[minj];
        C2[minj] = t;
    }
}

void printf(struct Card A[], int N) {
    for ( int i = 0; i < N; i++) {
        if ( i > 0)
            cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable (struct Card C1[], struct Card C2[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( C1[i].suit != C2[i].suit)
            return false;
    }
    return true;
}


int main()
{
    Card C1[100], C2[100];
    int N;

    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for ( int i = 0; i < N; i++ ) {
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    printf(C1, N);
    cout << "Stable" << endl;

    printf(C2, N);
    if ( isStable(C1, C2, N))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;

    return 0;

}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(all(d));
  cout << d.at(n/2)-d.at(n/2-1) << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
int n,p[1000],i,max,s;
cin>>n;
s=0;
for(i=0;i<n;i++)
    cin>>p[i];
max=p[0];
for(i=0;i<n;i++)
if(p[i]>max){
    max=p[i];
}

for(i=0;i<n;i++){
    s=s+p[i];

}
s=s-max;
s=s+max/2;
    cout<<s;
    return 0;}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int prime[500000];
int num_prime=2;
int find(int n);
int main(void)
{
  int n,temp;
  
  prime[0]=2;
  prime[1]=3;
  
  while(scanf("%d",&n)!=EOF){
    //printf("###%d###\n",n);
    if(n>prime[num_prime-1]){
      temp=judge(n);
      //print_prime();
      printf("%d\n",temp);
    }
    else if(n==prime[num_prime-1]){
      printf("%d\n",num_prime);
    }
    else{
      temp=find(n);
      printf("%d\n",temp);
    }
  }
  return 0;
}
int judge(int n)
{
  int i,j,flag=0;
  for(j=prime[num_prime-1]+1;j<=n;j++){
    flag=0;
    for(i=0;i<num_prime;i++){
      if(j%prime[i]==0){
	flag=1;
	break;
      }
      if(sqrt(j)<prime[i])
	break;
    }
    if(flag==0){
      prime[num_prime]=j;
      num_prime++;
    }
  }
  return num_prime;
}
int print_prime()
{
  int i;
  
  for(i=0;i<num_prime;i++){
    printf("%2d: %d\n",i,prime[i]);
  }
  return 0;
}
int find(int n)
{
  int i,temp=0;

  for(i=0;i<num_prime;i++){
    if(prime[i]>n){
      return i;
    }
  }
}

Measured memory_bytes: 704
//abc109_c.cpp
//Sat Sep  8 20:56:39 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int gcd (int a, int b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

int main(){
	int n,x;
	cin >> n >> x;

	int ans = 0;
	int city[n];
	for (int i=0;i<n;i++){
		cin >> city[i];
		int dis = abs(x-city[i]);
		if (i==0){
			ans = dis;
		}else {
			ans = gcd(ans,dis);
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
 
int main(){
	ll n, m, k;
    string s, t;
    cin >> s >> t;
    t.erase( --t.end() );
    if(s==t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N){
	cout << (N+1)/2 << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;
int cnt;

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

	ll N;
	cin >> N;

	vector<ll> a(N);
	rep(i,N){
		cin >> a[i];
	}

    sort(a.begin(),a.end(),greater<int>());

    ll x=-1,y=-1;
    rep(i,N-1){
        if(x!=-1){
            if(a[i]==a[i+1]){
                y = a[i];
                break;
            }
        }

        if(x == -1){
            if(a[i]==a[i+1]){
                x = a[i]; 
                i++;
            }
        }
    }

    if(x!=-1 && y!=-1) cout << x*y << endl;
    else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s[3];
int arr[3],cur;
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>s[0]>>s[1]>>s[2];
    while(1)
    {
        if(cur==0)
        {
            if(arr[cur]>=s[cur].length())
            {
                cout<<"A"<<endl;
                break;
            }
            int old=cur;
            if(s[cur][arr[cur]]=='b')
                cur=1;
            else if(s[cur][arr[cur]]=='c')
                cur=2;
            arr[old]++;
        }
        else if(cur==1)
        {

            if(arr[cur]>=s[cur].length())
            {
                cout<<"B"<<endl;
                break;
            }
            int old=cur;
            if(s[cur][arr[cur]]=='a')
                cur=0;
            else if(s[cur][arr[cur]]=='c')
                cur=2;
            arr[old]++;
        }
        else
        {

            if(arr[cur]>=s[cur].length())
            {
                cout<<"C"<<endl;
                break;
            }
            int old=cur;
            if(s[cur][arr[cur]]=='a')
                cur=0;
            else if(s[cur][arr[cur]]=='b')
                cur=1;
            arr[old]++;
        }
    }


    return 0;
}


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

int main()
{
    int n, x;
    cin >> n >> x;
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        d += l;
        if (d <= x) {
            ans++;
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;

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

int N; 
VS S(2);
cin>> N >> S[0] >> S[1];

i64 cnt;
VI tateyoko; //縦ドミノ1つなら0，横ドミノ2つなら1 を記録．
int s; // 左端の縦横をチェックして次の添え字 s から始める．
if (S[0][0] == S[1][0]){
    tateyoko.push_back(0);
    cnt = 3;
    s = 1;
} 
else {
    tateyoko.push_back(1);
    cnt = 6;
    s = 2;
}

rep(i, s, N){
    if (S[0][i] == S[1][i]){
        if (!tateyoko.back()) (cnt *= 2) %= MOD;
        tateyoko.push_back(0);
    }
    else {
        if (tateyoko.back()) (cnt *= 3) %= MOD;
        else (cnt *= 2) %= MOD;
        tateyoko.push_back(1);
        ++i;
    }
}


cout << cnt  << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> a(m),b(m);
    vector<vector<int>> c(m);
    rep(i,m) {
        cin>>a[i]>>b[i];
        c[i].resize(b[i]);
        rep(j,b[i]) cin>>c[i][j], c[i][j]--;
    }

    vector<ll> dp((1<<n),LINF);
    dp[0] = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        rep(i,m) {
            int nv = bit;
            rep(j,b[i]) nv |= (1 << c[i][j]);
            chmin(dp[nv], dp[bit]+a[i]);
        }
    }

    int di = (1<<n)-1;
    if (dp[di] == LINF) cout << -1 << '\n';
    else cout << dp[di] << '\n';
    return 0;
}

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

int main(){
    long long int N,A,B;
    cin >> N >> A >> B;
    long long int memo,memo2,result;
    if(A+B == 0) cout << '0';
    else{
    memo = N % (A+B);
    memo2 = N / (A+B);
    if(memo<A) result = memo2 * A + memo;
    else result = memo2 * A + A;
    cout << result;
    }
}

Measured memory_bytes: 256
#define w 200001
i;x;y;p;main(n,m,j,u){
long int k,a[w],A[w],b[w],B[w];
for(scanf("%d%d%ld",&n,&m,&k);x<n;x++)scanf("%ld",&a[x]),A[x+1]=A[x]+a[x];
for(;y<m;y++)scanf("%ld",&b[y]),B[y+1]=B[y]+b[y];
for(j=u=m;i<=n;i++){if(A[i]>k)break;for(;j+1;j--){if(A[i]+B[j]<=k){if(i+j>p)p=i+j;u=j;break;}}}
printf("%d",p);}

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

using namespace std;

#define ll long long

int main()
{
	ll a, b, x;
	cin >> a >> b >> x;

	ll ans = b / x - a / x;

	if (a % x == 0) {
		ans++;
	}

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


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

A_ = sorted(A)
A_r = list(reversed(A_))

l = []
for i, (x, y) in enumerate(zip(A_[:N//2], A_r[:N//2])):
    if i % 2 == 0:
        l.append(x)
        l.insert(0, y)
    else:
        l.append(y)
        l.insert(0, x)

if N % 2 != 0:
    m = A_[N//2]
    if abs(l[0] - m) > abs(l[-1] - m):
        l.insert(0, m)
    else:
        l.append(m)

def g(L):
    for i, j in zip(L[:-1], L[1:]):
        yield abs(i - j)

print(sum(g(l)))


Measured memory_bytes: 11100
n, k = map(int, input().split())
a = list(map(int,input().split()))

a_p =[]
a_m =[]
for i in a:
    if i >= 0:
        a_p.append(i)
    else :
        a_m.append(i)

a_p.sort()
a_m.sort(reverse=True)


a_select =[]

if n == k:
    a_select = a
elif len(a_p) == 0 and k%2 == 1:
    for i in range(k):
        a_select.append(a_m[i])


while len(a_select) < k:
    if len(a_select) == k - 1:
        a_select.append(a_p[-1])
        break
    if len(a_p) == 1 and (k-len(a_select))%2 == 1:
        a_select.append(a_p.pop(-1))
    elif len(a_p) == 1 and (k-len(a_select))%2 == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_p) == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_m) <= 1:
        a_select.append(a_p.pop(-1))
    elif a_p[-1]*a_p[-2] > a_m[-1]*a_m[-2] :
        a_select.append(a_p.pop(-1))
    else:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))

#print(a_select)
ans = 1
for i in a_select:
    ans = ans*i % (10**9 + 7)

print(ans)


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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 200005;


integer main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int cnt = 1;
    int k = 0;
    while (n > 1) {
        k += cnt;
        cnt *= 2;
        n /= 2;
    }
    cout << cnt + k << endl;
}


Measured memory_bytes: 256
def main():
    data = list(map(int, input().split()))
    Xn = data[0]
    Yn = data[1]
    X = data[2]
    Y = data[3]

    Xs = list(map(int, input().split()))
    Ys = list(map(int, input().split()))

    mergin = list(range(X, Y))
    x_line = min(mergin)
    y_line = max(mergin)

    max_x = max(Xs)
    min_y = min(Ys)

    if (max_x < min_y):
        if ((max_x + min_y) // 2 in mergin):
            print('No War')
        else:
            print('War')
    else:
        print('War')

if __name__ == "__main__":
    main()


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

bool is_palindrome(string s){
  string r = s;
  reverse(r.begin(), r.end());
  return s == r;
}

int main(){
  string s;
  cin >> s;
  int N = s.length();
  if(is_palindrome(s) and is_palindrome(s.substr(0,N/2)) and is_palindrome(s.substr(N/2+1))){
    puts("Yes");
  }else{
    puts("No");
  }
}


Measured memory_bytes: 256
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=200010,mod=1e9+7,inv2=500000004;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,ans,a[maxn],b[maxn],fac[8010],inv[8010],f[4010][4010];
inline int pls(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int dec(int x,int y){return x-y<0?x-y+mod:x-y;}
int power(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=(ll)x*x%mod)
	  if(y&1)
	    res=(ll)res*x%mod;
	return res;
}
inline int c(int n,int m){return m>n?0:(ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	read(n);fac[0]=1;
	for(rg int i=1;i<=n;i++)
	{
		read(a[i]),read(b[i]);
		++f[2000-a[i]][2000-b[i]];
	}
	for(rg int i=1;i<=8000;i++) fac[i]=(ll)fac[i-1]*i%mod;
	inv[8000]=power(fac[8000],mod-2);
	for(rg int i=7999;~i;i--) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	for(rg int i=0;i<=4000;i++)
	  for(rg int j=0;j<=4000;j++)
	    f[i][j]=pls(f[i][j],pls(i?f[i-1][j]:0,j?f[i][j-1]:0));
	for(rg int i=1;i<=n;i++)
	{
		ans=pls(ans,f[2000+a[i]][2000+b[i]]);
		ans=dec(ans,c((a[i]+b[i])<<1,a[i]<<1));
	}
	ans=(ll)ans*inv2%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 64640
#include<stdio.h>
int main()
{
   int t,s,x,a,b;
   while(scanf("%d%d%d",&x,&a,&b)!=EOF){
       t=x-a;s=x-b;
       if(t<0)
       t=-t;
       if(s<0)
       s=-s;
       if(t>s)
       printf("B\n");
       else
       printf("A\n");
     
   }
     return 0;
   
}

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

ll N, K, t, d, sum, ans;
vector<ll> F, S;
vector<pair<ll, ll>> v;
map<ll, ll> mp;

main()
{
    cin >> N >> K;
    for (ll i = 0; i < N; i++)
    {
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    sort(v.rbegin(), v.rend());
    for (ll i = 0; i < v.size(); i++)
    {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0)
            F.push_back(p.second);
        else
            S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll L = F.size(), M = S.size();
    for (ll i = 0; i < min(K, L); i++)
        sum += F[i];
    if (K > L)
    {
        ll check = 0;
        for (ll i = 0; i < K - L; i++)
        {
            sum += S[i];
            check = i;
        }
        check++;
        ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < M; j--)
        {
            sum -= F[j];
            sum += S[check];
            check++;
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else
    {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < M; i++)
        {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
string s;
int ans;
signed main(){
	cin>>s;
	int l=0,r=s.size()-1;
	while(r-l>0){
		if(s[l]==s[r]);
		else if(s[l]=='x')r++,ans++;
		else if(s[r]=='x')l--,ans++;
		else{
			puts("-1");
			return 0;
		}
		l++,r--;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512