akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i, n, m;
	int answer = -1e9;
	int *input;

	scanf("%d", &n);
	input = (int *)malloc(sizeof(int) * n);

	for (i = 0; i < n; i++) {
		scanf("%d", &input[i]);
	}

	m = input[0];

	for (i = 1; i < n; i++) {

		if (answer < (input[i] - m)) {
			answer = input[i] - m;
		}

		if (input[i] < m) {
			m = input[i];
		}

	}

	printf("%d\n", answer);

	return 0;
}

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

int main()
{
    ifstream fin("date.in");
    int n, *dp, inaltime;
    vector<int> Pietre;
    cin >> n;
    dp = new int[n+1]();
    for(int i = 1 ; i <= n ; i++){
        cin >> inaltime;
        Pietre.push_back(inaltime);
    }
    dp[0] = 0;
    dp[1] = abs(Pietre[0] - Pietre[1]);
    for(int i = 2 ; i < n ; i++)
            dp[i] = min(dp[i-1] + abs(Pietre[i - 1] - Pietre[i]), dp[i-2] + abs(Pietre[i - 2] - Pietre[i]));
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}

	Scanner cin;

	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-8;
	const double PI = 3.1415926536;
	int[,] dir8;
	int[,] dir4;



	void prog()
	{
		cin = new Scanner();
		dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int[] T = new int[N];
		long sum = 0;
		for (int i = 0; i < N; i++)
		{
			T[i] = cin.nextInt();
			sum += T[i];
		}
		int M = cin.nextInt();
		int P, X;
		int[] diff = new int[N];
		for (int i = 0; i < M; i++)
		{
			P = cin.nextInt() - 1;
			X = cin.nextInt();
			Console.WriteLine(sum - T[P] + X);
		}

	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class apc001_c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        cin >> N;
        string s;
        cout << 0 << endl;
        cin >> s;
        if (s == "Vacant") {
            return;
        }
        int male = (s == "Female");
        int low = 1, high = N - 1, ans = low;
        while (low <= high) {
            int mid = (low + high) / 2;
            cout << mid << endl;
            cin >> s;
            if (s == "Vacant") {
                return;
            } else if (s == "Female") {
                if (mid % 2 == male) {
                    high = mid - 1;
                } else {
                    ans = mid;
                    low = mid + 1;
                }
            } else {
                if (mid % 2 == male) {
                    ans = mid;
                    low = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
        }
        cout << ans << endl;
        cin >> s;
        assert(s == "Vacant");
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	apc001_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 852
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

int SaB(){

	string s;

	cin >> s;

	if(s.find("A") != -1 && s.find("B") != -1)
		printf("Yes");
	else
		printf("No");

	return 0;

}

int CB(){
	LL N,A,B;

	cin >> N >> A >> B;

	LL answer = A * (N/(A+B));

	if(N%(A+B) >= A)
		answer += A;
	else
		answer += N%(A+B);

	loutp(answer);

	return 0;
}

int TI(){
	LL A,B;

	cin >> A >> B;

	double minx = max(100.0*A/8.0,100.0*B/10.0);
	double maxx = min(100.0*(A+1)/8.0, 100.0*(B+1)/10.0);

	for(LL x = (LL)minx; x <= maxx; x++){
		if((8*x)/100 == A && (10*x)/100 == B){
			loutp(x);
			return 0;
		}

	}

	loutp(-1);

	return 0;
}

signed main() {

	// SaB();
	//CB();
	TI();
	return 0;
}



Measured memory_bytes: 256
n = int(input())

p = [[] for _ in range(n)]
for i in range(n - 1):
    x, y = map(int, input().split())
    p[x - 1].append(y - 1)
    p[y - 1].append(x - 1)

f = [n for _ in range(n)]
s = [n for _ in range(n)]

f[0] = 0
after = [] + p[0]
before = set()
dist = 0
while 1:
    dist += 1
    check = 0
    temp = []
    for x in after:
        if f[x] == n:
            f[x] = dist
            temp += p[x]
            check = 1
    if check == 0:
        break
    t2 = set(temp) - before
    before = set(after)
    after = list(t2)

s[n - 1] = 0
after = [] + p[n - 1]
before = set()
dist = 0
while 1:
    dist += 1
    check = 0
    temp = []
    for x in after:
        if s[x] == n:
            s[x] = dist
            temp += p[x]
            check = 1
    if check == 0:
        break
    t2 = set(temp) - before
    before = set(after)
    after = list(t2)

score_f = 0
for i in range(n):
    if f[i] <= s[i]:
        score_f += 1

if score_f > n - score_f:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 29164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s; i < n; i++)
const int maxn = 100005;
const int INF = INT_MAX;
int N;
int h[maxn];
int d[maxn];

int dp(int a){
	if(d[a]!=-1) return d[a];
	int ans = INF;
	if(a>=2)ans = min(ans, dp(a-1)+abs(h[a-1]-h[a]));
	if(a>=3)ans =min(ans, dp(a-2)+abs(h[a-2]-h[a]));
	return d[a] = ans;
}

int main(){
	cin>>N;
	rep(i,0,N) {
		cin>>h[i+1];
	}
	memset(d,-1,sizeof d);
	d[1] = 0;
		cout<<dp(N)<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;


int main(){
    ll N;
    cin>>N;
    vector<vector<ll>> A(2, vector<ll>(N));
    rep(i, 2){
        rep(j, N){
            cin>>A[i][j];
        }
    }
    ll MAX=-1;
    rep(i, N){
        ll Num=0;
        rep(j, i+1){
            Num+=A[0][j];
        }
        for(ll j=i; j<N; j++){
            Num+=A[1][j];
        }
        MAX=max(MAX, Num);
    }
    cout<<MAX<<endl;
}
    

Measured memory_bytes: 256
import sys
import math
import itertools
from collections import deque

N=200005
inf=(1<<30)

def solve():
    n,m=map(int,input().split())
    ans1=n*(n-1)//2
    ans2=m*(m-1)//2
    print(ans1+ans2)
t=1
#t=int(input())
for case in range(t):
    solve()

Measured memory_bytes: 3572
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);
        
        int a=stdIn.nextInt();
        int b=stdIn.nextInt();
        int c=stdIn.nextInt();

        int t=a;
        a=b;
        b=t;
        t=a;
        a=c;
        c=t;

        System.out.println(a);
        System.out.println(b);
        System.out.print(c);
        
        
        
    }

}

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

int main(){
    int a,b; cin >> a >> b;
    if(a<b) swap(a,b);
    int d = abs(a-b);
    if(d%2==0){
        cout << a - d/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine("{0}",(s[0]*(s[0]-1)/2)+(s[1]*(s[1]-1)/2));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll s, w;
    cin >> s >> w;

    if(w >= s) {
        out("unsafe");
    }
    else {
        out("safe");
    }

    re0;
}

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

int main(){
    string s, t, r;
    cin >> s >> t;
    r = s;
    bool flag = false;
    while(1){
        string tail = string() + r[r.size()-1];
        r.erase(r.end()-1);
        reverse(r.begin(), r.end());
        r += tail;
        reverse(r.begin(), r.end());
        if(r == t) flag = true;
        if(s == r) break;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

/*const int N = 100000008;
bool isprime[N];*/

bool isprime(int x)
{
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return x > 1;
}

int main()
{
    /*for (int i = 0; i < N; i++) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for (int i = 2; i * i < N; i++)
    {
        if (isprime[i])
        {
            for (int j = i * i; j < N; j += i)
            {
                isprime[j] = false;
            }
        }
    }
    return 0;*/
    int n, res = 0;
    scanf("%d", &n);
    while (n--)
    {
        int x;
        scanf("%d", &x);
        res += isprime(x);
    }
    printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 3208
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		long ans = 0;
		
		if(n % 2 == 0) {
			int m = (n-2)/2;
			for(int i = 0 ; i < m ;i++) {
				ans += (long)(2 *(a[n-1-i] - a[i]));
				//System.out.println(ans);
			}
			ans += a[m+1] - a[m];
			System.out.println(ans);
		}
		else {
			
			int m = (n-1)/2;
			long temp = (long)((a[m+1] + a[m-1]) - 2 * a[m]);
			for(int i = 0 ; i < m-1 ;i++) {
				ans += (long)(2 *(a[n-1-i] - a[i]));
				//System.out.println(ans);
			}
			if(temp >= 0) {
				ans += (long)(2 *a[m+1] - a[m-1] - a[m]);
			}
			else {
				ans += (long)(a[m+1] + a[m] - (a[m-1] * 2));
			}
			System.out.println(ans);
		}
		

	}

}


Measured memory_bytes: 54716
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

# DP
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if wv[i][0] <= j:
            dp[i+1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 217844
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int is_prime_num(int n) {
	if (n < 2) {
		return -1;
	} else if (n == 2) {
		return 1;
	} else if (n % 2 == 0) {
		return -1;
	}
	
	int i;
	for (i = 3; i <= n / i; i+=2) {
		if (n % i == 0) {
			return -1;
		}
	}
	return 1;
}

int memoized_map[999999] = {};

bool memoized_prime_num(int n) {
	int res = memoized_map[n];
	if (res == 0) {
		res = is_prime_num(n);
		memoized_map[n] = res;
	}
	if (res == 1) {
		return true;
	} else {
		return false;
	}
}

int count_prime_num(int n) {
	int acc = 0;
	int i;
	for (i = 2; i <= n; i++) {
		if (memoized_prime_num(i)) {
			acc++;
		}
	}
	return acc;
}

int main() {
	char line[256];
	while (fgets(line, 256, stdin)) {
		printf("%d\n", count_prime_num(atoi(line)));
	}
}

Measured memory_bytes: 4428
using System;

public class Hello
{
    public static void Main()
    {
        Console.WriteLine(getAns() ? "YES" : "NO");
    }
    static bool getAns()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        for (int i = 0; i < n - 1; i++)
            if (a[i] == a[i + 1]) return false;
        return true;
    }
}


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

int main()
{
  char str[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1,
                  2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2,
                  5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << (int)str[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 6/14/2018
 
 15:30-15:40, 18:55-
 
 */

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL A[MAX_N];
void solve() {
  LL res=0;
  int prev=0;
  REP(i,N) {
    if(A[i]==0) {
      prev=0;
    } else {
      LL x=prev+A[i];
      res+=x/2;
      prev=x%2;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 1400
N = gets.to_i
As = gets.split.map(&:to_i)

l,r = 0,0
xor,sum =As[0],As[0]
tmp = 1
ans = 0
flag = false

loop do
    break if (r == N) or (l == N)
    if (r != 0)
        if flag
            xor ^= As[r]
            sum += As[r]
        else
            xor ^= As[l-1]
            sum -= As[l-1]
        end
    end

    if xor == sum
        if !flag
            flag = true
        end
        ans += r - l + 1
        r = r + 1
    else
        flag = false
        l = l + 1
    end
end

puts ans


Measured memory_bytes: 15372
#include <cstdio>
#include <queue>
#include <iostream>
using namespace std;
int dis[200001],r[400001],nn[400001],l[200001]={0},n,tot=0;
bool ch[200001];
void spfa()
{
	int i,x,y,t;
	queue<int> q;
	for(i=1;i<=n;i++){
		dis[i]=666666;
		ch[i]=false;
	}
	ch[1]=true;
	dis[1]=0;
	q.push(1);
	while(!q.empty())
	{
		x=q.front();
		q.pop();
		ch[x]=false;
		t=l[x];
		while(t!=0)
		{
			y=r[t];
			if(dis[x]+1<dis[y])
			{
				dis[y]=dis[x]+1;
				if(!ch[y])
				{
					ch[y]=true;
					q.push(y);
				}
			}
			t=nn[t];
		}
	}
}
void add(int x,int y)
{
	++tot;
	r[tot]=y;
	nn[tot]=l[x];
	l[x]=tot;
}
int main()
{
	int i,x,m,y;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	spfa();
	if(dis[n]<=2)printf("POSSIBLE");
	else printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();

            var max = 10000;
            for (int i = 0; i < max; i++)
            {
                for (int j = 0; j < max; j++)
                {
                    if (Math.Pow(i, 5) - Math.Pow(j, 5) == X)
                    {
                        return $"{i} {j}";
                    }
                    if (Math.Pow(i, 5) + Math.Pow(j, 5) == X)
                    {
                        return $"{i} {-1 * j}";
                    }
                    if (-1 * Math.Pow(i, 5) - Math.Pow(j, 5) == X)
                    {
                        return $"{-1 * i} {j}";
                    }
                    if (-1 * Math.Pow(i, 5) + Math.Pow(j, 5) == X)
                    {
                        return $"{-1 * i} {-1 * j}";
                    }
                }
            }

            throw new Exception();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * )
	let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v
	let labs p = if p < 0L then -1L*p else p
	let (~|) p = Int64.to_int p
	let (~~|) p = Int64.of_int p

	let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
	let get_i64 () = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 () = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 () = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
	let print_i64_endline n = n |> Int64.to_string |> print_endline
	
	let (mod) m n = m - (m/n) * n let (%) = (mod)
	let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
	let lcm m n = (m*n) / gcd m n
	let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do match fbod !i with | `Ok -> i := !i +$ 1; | `Ng -> f := false done
	let repi64 from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do match fbod ~~| !i with | `Ok -> i := !i +$ 1; | `Ng -> f := false done
end

(* open MyInt64 *)
let () =
	let k = scanf "%d" (fun v -> v)
	in
	let p = k/2 in
	(if k mod 2 = 0 then (
		p * p
	) else (
		p * (p+1)
	))
	|> printf "%d\n"

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int a[4], b[4], i, j, k, hit, bro;
	
	while(scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3])!=EOF){
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		hit=0;
		bro=0;
		
		for(i=0;i<4;i++){
			if(a[i]==b[i])
			hit++;
			
			for(j=0;j<4;j++){
				for(k=0;k<4;k++){
				if(a[k]==b[j])
			bro++;
				}
			}
		}
		
		printf("%d %d\n", hit, bro/4-hit);
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string a, b;
    cin >> a;
    cin >> b;

    if (a.size() + 1 != b.size())
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] != b[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];

		for(int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		for(int i = 0; i < M; i++) {
			B[i] = sc.next();
		}

		String result = Serch(N,M,A,B);
		System.out.println(result);
	}

	private static String Serch(int N,int M,String[] A,String[] B) {
		int count = 0;
		for(int i = 0; i < N-M+1; i++) {
			for(int j = 0; j < N-M+1; j++) {
				for(int k = 0; k < M; k++) {
					if(A[i+k].substring(j,j+M).equals(B[k].substring(0))) {
						count++;
					}else {
						count = 0;
						break;
					}
					if(count == M) {
						return "Yes";
					}
				}
			}
		}
		return "No";
	}
}


Measured memory_bytes: 27436
from collections import defaultdict
import heapq
n, m = map(int, input().split())
d = defaultdict(list)
for i in range(n):
    a, b = map(int, input().split())
    d[a-1].append(-b)
cnt = 0
a = []
heapq.heapify(a)
for i in range(m):
    for j in d[i]:
        heapq.heappush(a, j)
    if a:
        cnt += -heapq.heappop(a)
print(cnt)

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

#define MAX 100000
#define SENTINEL 2000000000


typedef struct card {
  char ch;
  int num;
}Card;

int n;
Card A[MAX],B[MAX];
Card L[MAX / 2 + 2],R[MAX / 2 + 2];

void merge(Card A[],int left,int mid,int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1;i++) {
      L[i] = A[left + i];
    }
    for(int i = 0; i < n2;i++) {
      R[i] = A[mid + i];
    }

    L[n1].num = R[n2].num = SENTINEL;
    int i = 0,j = 0;
    for(int k = left; k < right; k++) {
      if(L[i].num <= R[j].num) {
        A[k] = L[i++];
      }else {
        A[k] = R[j++];
      }
    }
  }

  void mergesort(Card A[],int left,int right) {
    if(left + 1 < right) {
      int mid = (right + left) / 2;
      mergesort(A,left,mid);
      mergesort(A,mid,right);
      merge(A,left,mid,right);
    }
  }
    


int partition(Card A[],int p,int r) {
  int i = p - 1;
  Card t,x = A[r];
  for(int j = p; j < r; j++) {
    if(A[j].num <= x.num) {
      i++;
      t = A[i]; A[i] = A[j];A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quicksort(Card A[],int p,int r) {
  int q;
  if(p < r) {
  q = partition(A,p,r);
  quicksort(A,p,q - 1);
  quicksort(A,q + 1,r);
  }
}


int main() {

 
  cin >> n;
  string ans = "Stable";
  
  for(int i = 0; i < n; i++) {
    cin >> A[i].ch >> A[i].num;
    B[i].ch = A[i].ch;
    B[i].num = A[i].num;
  }

  quicksort(A,0,n - 1);
  mergesort(B,0,n);

  for(int i = 0;i < n; i++) {
    if(A[i].ch != B[i].ch) {
      ans = "Not stable";
    }
  }
  
  cout << ans << endl;
  for(int i = 0;i < n; i++) {
    cout << A[i].ch << " " << A[i].num << endl;
  }

}


Measured memory_bytes: 5520
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();
        final long m = scanner.nextLong();
        scanner.nextLine();
        final String s = scanner.nextLine();
        final String t = scanner.nextLine();

        final long gcd = getGCD(n, m);

        for (int i = 0; i < gcd; i++) {
            final char a = s.charAt((int)(i * n / gcd));
            final char b = t.charAt((int)(i * m / gcd));

            if (a != b) {
                System.out.println(-1);
                return;
            }
        }

        final long lcm = n * m / gcd;
        System.out.println(lcm);
    }

    private static long getGCD(final long a, final long b) {
        if (b > a) {
            return getGCD(b, a);
        }

        if (b == 0) {
            return a;
        }

        return getGCD(b, a % b);
    }
}


Measured memory_bytes: 26572
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto nm=readln.split.map!(to!int).array;
    auto n=nm[0];
    auto m=nm[1];
    int[][] abs;
    foreach(i;0..m)abs~=readln.split.map!(to!int).array;
    int[][] routes;
    routes~=[1];
    foreach(i;0..n-1){
        int[][] newRoutes;
        foreach(x;1..n+1){
            foreach(r;routes){
                if(r.find(x).empty)newRoutes~=(r~x);
            }
        }
        routes=newRoutes;
    }
    long res=0;
outer:foreach(r;routes){
          foreach(i;0..n-1){
            if(abs.find(r[i..i+2]).empty && abs.find([r[i+1],r[i]]).empty)continue outer;
          }
          ++res;
    }
      writeln(res);
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
 
using graph = vector<vector<ll>>;

int main(){
    string n;
    cin >> n;
    int keta;
    for(int i = 0; i < n.size(); i++){
        keta = keta + (n[i] - '0');
        keta %= 9;
    }
    if(keta % 9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3716
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int s=scanner.nextInt();
    int flg1=0;
    int flg2=0;

    int sl=s/100;
    int sr=s%100;
    //YYMM
    if(sr>0&&sr<13){
      flg1=1;
    }
    //MMYY
    if(sl>0&&sl<13){
      flg2=1;
    }

    if(flg1==0){
      if(flg2==0) System.out.println("NA");
      else System.out.println("MMYY");
    }
    else{
      if(flg2==0) System.out.println("YYMM");
      else System.out.println("AMBIGUOUS");
    }
    //System.out.println(ans);
  }
}


Measured memory_bytes: 21716
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func pow(x int, y int) int {
	//_, _ = fmt.Printf("pow: %v, %v\n", x,y)
	z := x
	if y == 0 {
		return 1
	}
	var i int
	for i = 1; i < y; i++ {
		z = z * x
	}
	return z
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	l := make([][]int, m)
	p := make([]int, m)
	for i := 0; i < m; i++ {
		k := nextInt()
		l[i] = make([]int, k)
		for j := 0; j < k; j++ {
			l[i][j] = nextInt() - 1
		}
	}
	for i := 0; i < m; i++ {
		p[i] = nextInt()
	}

	a := make([]int, 10)
	for i := 0; i < 10; i++ {
		a[i] = pow(2, i)
	}

	//fmt.Printf("%v\n", l)

	count := 0
	for i := 0; i < pow(2, n); i++ {
		lit := true
		for j := 0; j < m; j++ {
			c := 0
			for k := 0; k < len(l[j]); k++ {
				//fmt.Printf("i:%v, j:%v, k:%v, l:%v, a:%v\n", i, j, k, l[j][k], a[l[j][k]])
				if a[l[j][k]]&i != 0 {
					c++
				}
			}
			//fmt.Printf("i:%v, j:%v, c:%v\n", i, j, c)
			if c%2 != p[j] {
				//fmt.Print("not lit!\n")
				lit = false
				break
			}
		}
		if lit == true {
			//fmt.Print("lit!\n")
			count++
		}
	}
	//fmt.Printf("%v\n", count)

	_, _ = fmt.Fprintf(writer, "%d", count)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
using namespace std;
#define int long long
#define inf 1e9+7
typedef pair<int, int> P;
int d[114],s[114];

signed main() {
	int n;
	cin >> n ;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		s[d[i]]++;
	}
	int ans = 0;
	for (int i = 0; i < 114; i++)if (s[i])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
	while a%b != 0:
		a, b = b, a%b
	return b

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

if n==2:
	print(max(A))
	quit()

l_GCD = [0] * (n)
l_GCD[0] = A[0]
for i in range(1, n):
	l_GCD[i] = gcd(l_GCD[i-1], A[i])

r_GCD = [0]*n
r_GCD[-1] = A[-1]
for i in range(n-2, -1, -1):
	r_GCD[i] = gcd(r_GCD[i+1], A[i])

max_gcd = r_GCD[1]
for i in range(1, n-1):
	left = l_GCD[i-1]
	right = r_GCD[i+1]
	max_gcd = max(max_gcd, gcd(left, right))
max_gcd = max(max_gcd, l_GCD[-2])

print(max_gcd)

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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

int main() {
	LL n, m, k;
	LL t, s;
	cin >> n >> m >> k;
	for(int i=0; i<=n; i++) {
		for (int j = 0; j <= m; j++) {
			t = m*i + n*j - 2 * i*j;
			if (t == k || n*m - t ==k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define PI 3.1415926535898
using namespace std;
long long  gcd (long long n1, long long  n2) {
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int main(int argc, char const *argv[]) {

    int dp[3011][3011];
    memset(dp, 0, sizeof dp);
    string a, b,ans="";
    cin >> a >> b;
    a = " " + a;
    b = " " + b;
    int n = a.size(), m = b.size();
    for(int j = 1; j <= m; j++) {
        for(int i = 1; i <= n; i++) {
            dp[i][j] = max({dp[i - 1][j-1] + (a[i] == b[j]), dp[i][j - 1],dp[i-1][j]});
        }
    }
    // for(int j=1;j<m;j++) {
    //     for(int i=1;i<n;i++) {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    n--,m--;
    while(n>0&&m>0) {
        if(a[n]==b[m]&&dp[n-1][m]==dp[n][m]-1) {
            ans+=a[n];
            n--;
        } else if(dp[n-1][m]>dp[n][m-1]) {
            n--;
        } else if(dp[n-1][m]<dp[n][m-1]){
            m--;
        } else m--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 35712
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void)
{
 char s[256];
 char first, last;
 int n;
 scanf("%s", s);
 n = strlen(s) - 2;
 first = s[0];
 last = s[n+1];
 printf("%c%d%c", first, n, last);
 return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = getLine >> solve <$> f <*> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: [Int] -> [Int] -> Int
solve as = f 0
  where
    f ln []  = ln
    f ln xs = f (max ln (search as xs)) (tail xs)

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')

search :: [Int] -> [Int] -> Int
search xs ys = f 0 xs ys
  where
    f ln [] _ = ln
    f ln _ [] = ln
    f ln (x:xs) (y:ys)
      | x == y = f (ln + 1) xs ys
      | otherwise = f ln xs (y:ys)



Measured memory_bytes: 6080
S = list(input())
flag = False
if S[0]=="A":
    S.remove("A")
    if S[1:-1].count("C")==1:
        tmp = S[1:-1]+list(S[-1])
        tmp.remove("C")
        S = S[0:1] + tmp
        if "".join(S).islower():
            flag = True
print("AC" if flag else "WA")





Measured memory_bytes: 3060
a, b = map(int,input().split())
a = min(a,b)
b = max(a,b)
if a != abs(a):
  if b == abs(b): print("Zero")
  elif (b - a) % 2 == 0: print("Negative")
  else: print("Positive")
elif a == 0: print("Zero")
else: print("Positive")  

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    vector<int > v;
   cin>>n;
   n=n*2;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       v.push_back(x);
   }
   int sum=0;
   sort(v.begin(),v.end());
   for(int i=n-1;i>=0;i--)
   {
       //cout<<v[i]<<" ";
       if(i%2==0)
       sum+=v[i];
   }
   cout<<sum<<endl;
   return 0;
}


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

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

  int n,l; cin >> n >> l;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  bool judge = false;
  int p;
  for(int i = 0; i < n-1; i++){
    if(a[i]+a[i+1] >= l){
      judge = true;
      p = i;
    }
  }

  if(!judge) cout << "Impossible" << endl;
  else {
    cout << "Possible" << endl;
    for(int i = 1; i <= p; i++){
      cout << i << endl;
    }
    for(int i = n-1; i > p+1; i--){
      cout << i << endl;
    }
    cout << p+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x;
    cin>>x;
    vector<int> dp(x+1);
    dp[0] = 1;
    for(int i=0;i<=5;++i){
        for(int j=0;j<=x;++j){
            if(j+100+i <= x)dp[j+100+i] |= dp[j];
        }
    }
    cout << dp[x] << endl;
    return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n; cin>>n;  
  ll minT = 10000000000000000;
  
  rep(i,5) {
    ll input; cin>>input;    
    minT = min(minT, input);
  }
  
  ll count = 1;
  if(minT>=n) {
    
  } else {
    // 詰まる場合
    double d = double(n)/double(minT);
    count = ceil(d);    
  }
  
  // cout<<count<<endl;
  
  ll res = 4 + count;
  cout<<res;
  
  return 0;
}

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

string S;

bool pal(int l,int r){
	bool ret=true;
	for(int i=l;i<r;i++)if(S[i]!=S[r-i+l-1])ret=false;
	return ret;
}

int main(){
	cin >> S;
	int N=S.size();
	if(pal(0,N) && pal(0,N/2) && pal(N/2+1,N))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
positive = []
negative = []
for a, b in zip(A,B):
    now = a - b
    if now > 0:
        positive.append(now)
    elif now < 0:
        negative.append(-now)
if not negative:
    print(0)
    exit()
if sum(positive) < sum(negative):
    print(-1)
    exit()
positive.sort(reverse=True)
n_sum = sum(negative)
ans = 0
for p in positive:
    ans += 1
    n_sum -= p
    if n_sum <= 0:
        break
print(ans + len(negative))




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

int main() {
	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (a > b)swap(a, b);
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
        string inp;
        int cnt = 0;
        cin >> inp;
        for (int i = 0; i < 6; i++) {
                if (int(inp[i]) == 49) {
                        cnt++;
                }
        }
        cout << cnt << endl;
        return 0;
}


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

struct Mo {
    vector<int> left, right, index; // offline query
    int window; // bucket width
    int nl, nr, ptr; // [nl,nr)

    vector<int> a; // input
    vector<int> res; // output
    // add,delで書き換えていく
    vector<int> count;
    int sum;
    
    
    Mo(int n, vector<int> aa) : window((int)sqrt(n)), nl(0), nr(0), ptr(0), count(n,0), sum(0) { a = aa; }
    
    /* query [l,r) 0-indexed */
    void push(int l, int r) { left.push_back(l), right.push_back(r); }
    
    /* query sort */
    void build() {
        index.resize(left.size());
        res.resize(left.size());
        iota(index.begin(), index.end(), 0);
        sort(index.begin(), index.end(), [&](int a, int b) {
            if (left[a] / window != left[b] / window) return left[a] < left[b];
            if((left[a] / window) % 2) return right[a] > right[b];
            return right[a] < right[b];
        } );
    }

    /* 問題ごとに書き換える */
    void add(int id) { if(count[a[id]]++ == 0) sum++; return; }
    void del(int id) { if(--count[a[id]] == 0) sum--; return; }
    
    /* 区間を次のquery用に伸縮させる */
    void next() {
        int i = index[ptr++];
        while (left[i] < nl ) add(--nl);
        while (nr < right[i]) add(nr++);
        while (nl < left[i] ) del(nl++);
        while (right[i] < nr) del(--nr);
        res[i] = sum;
    } // 返り値はquery-index
};

int n, q, l, r;

int main() {
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; }
    Mo mo(n,a);
    for (int i = 0; i < q; i++) { cin >> l >> r; mo.push(--l, r); }

    mo.build();
    for (int i = 0; i < q; i++) mo.next();
    for (int i = 0; i < q; i++) cout << mo.res[i] << "\n";
    return 0;
}

Measured memory_bytes: 18496
import java.util.*;

class Main{
	static int a;
	static int b;
	static int c;
	static int d;
	static int e;
	static int p;
	static double f;
	static int g;
	static int h;
	static int i;
	static int j;
	static int k;
	static int l;
	static int m;
	static int o;
	static int q;
	static double r;
	static int s;
	static int t;
	static int u;
	static double x;
	static double y;
	private static Scanner sc;
	public static void main(String[]agrs){
		sc=new Scanner(System.in);
		a=sc.nextInt();
		String op=sc.next();
		b=sc.nextInt();
		int ans=0;
		while(true){
			if(op.equals("+"))ans=a+b;
			if(op.equals("-"))ans=a-b;
			else if(op.equals("*"))ans= a*b;
			else if(op.equals("/"))ans=a/b;
			else if(op.equals("?"))break;
			System.out.println(ans);
			a=sc.nextInt();
			op=sc.next();
			b=sc.nextInt();
			
			
		}
		
		
		
		
	}
}

Measured memory_bytes: 18052
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 int a  = in.nextInt();
		 int b  = in.nextInt();
		 int c  = in.nextInt();
		 int d  = in.nextInt();
		 
		 int x = c - a;
		 int y = d - b;
		 
		 System.out.print(c-y);
		 System.out.print(" ");
		 System.out.print(d+x);
		 System.out.print(" ");
		 System.out.print(a-y);
		 System.out.print(" ");
		 System.out.print(b+x);
	}
}

Measured memory_bytes: 20564
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	int n;
	double a;
	scanf("%d", &n);
	repr(i, n) {
		a = sqrt(i);
		if (a == int(sqrt(i))) {
			printf("%d\n", i);
				break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[81][81][6400 * 2 + 2];
int find_it(int dif_sum , int i , int j , int &n , int &m , vector<vector<pair<int , int>>> & matrix){
    if(i == n - 1 && j == m - 1){
        return min(abs(dif_sum + matrix[i][j].first - matrix[i][j].second) , abs(dif_sum + matrix[i][j].second - matrix[i][j].first));
    }
    if(dp[i][j][dif_sum] != -1){
        return dp[i][j][dif_sum];
    }
    int minvalue = INT_MAX;
    int ff = abs(dif_sum + matrix[i][j].first - matrix[i][j].second);
    int ss = abs(dif_sum + matrix[i][j].second - matrix[i][j].first);
    if(i + 1 < n){
        minvalue = min(minvalue , find_it(ff , i + 1 , j , n , m , matrix));
        minvalue = min(minvalue , find_it(ss , i + 1 , j , n , m , matrix));

    }
    if(j + 1 < m){
        minvalue = min(minvalue , find_it(ff , i , j + 1 , n , m , matrix));
        minvalue = min(minvalue , find_it(ss , i , j + 1 , n , m , matrix));
    }
    return dp[i][j][dif_sum] = minvalue;

}
int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n , m;
    cin >> n >> m;
    vector<vector<pair<int , int> > > matrix(n , vector<pair<int , int>> (m));

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> matrix[i][j].first;
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> matrix[i][j].second;
        }
    }
    memset(dp , -1 , sizeof(dp));
    cout << find_it(0 , 0 , 0 , n , m , matrix);


return 0;
}


Measured memory_bytes: 328448
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int height(int H, int cx, int cy, int x, int y) {
  return max(H - abs(x - cx) - abs(y - cy), 0);
}

int main() {
  int N;
  cin >> N;
  vector<tuple<int, int, int>> v;
  for (int i = 0; i != N; ++i) {
    int x, y, h;
    cin >> x >> y >> h;
    v.emplace_back(x, y, h);
  }

  auto &[x, y, h] =
      *find_if(begin(v), end(v), [](auto &t) { return get<2>(t); });
  for (int cx = 0; cx <= 100; ++cx) {
    for (int cy = 0; cy <= 100; ++cy) {
      for (int i : {1, -1}) {
        for (int j : {1, -1}) {
          auto H = h + i * abs(x - cx) + j * abs(y - cy);
          if (H < 1) continue;
          if (all_of(begin(v), end(v), [&](auto &t) {
                return get<2>(t) == height(H, cx, cy, get<0>(t), get<1>(t));
              })) {
            cout << cx << " " << cy << " " << H << endl;
            return 0;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a<=b&&b<=c){
		cout << a <<" "<< b <<" "<< c << endl;
	}
	else if(a<=c&&c<=b){
		cout << a <<" "<< c <<" "<< b << endl;
	}
	else if(b<=c&&c<=a){
		cout << b <<" "<< c <<" "<< a << endl;
	}
	else if(b<=a&&a<=c){
		cout << b <<" "<< a <<" "<< c << endl;
	}
	else if(c<=a&&a<=b){
		cout << c <<" "<< a <<" "<< b << endl;
	}
	else{
		cout << c <<" "<< b <<" "<< a << endl;
	}
}


Measured memory_bytes: 3088