akhauriyash/Code-Regression huggingface dataset:
import java.awt.Point;
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    static class Solver {
        public void solve(MyReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = in.nextIntArray(n);

            Map<Integer,Integer> map = new HashMap<>();
            for(int i:arr){
                map.put(i,map.getOrDefault(i,0) + 1);
            }

            long sum = 0;

            for(int i : map.values()){
                if (i < 2)continue;
                sum += (long)i*(i-1)/2;
            }

            for (int i : arr){
                out.println(sum - (map.get(i) - 1));
            }

        }


    }

    public static void main(String[] args) {
        MyReader mr = new MyReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        new Solver().solve(mr, out);
        out.close();
    }

    //    static int[][] dir = {{0,1}, {1,0},{-1,0}, {0,-1}};
//    static int[][] dir = {{0,1}, {1,0},{-1,0}, {0,-1}, {-1,-1},{-1,1}, {1,1}, {1,-1}};
    static class MyReader {
        BufferedReader br;
        StringTokenizer st;

        MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String res = "";
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return res;
        }

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }

            return arr;
        }

        Integer[] nextIntegerArray(int n) {
            Integer[] arr = new Integer[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }

            return arr;
        }

        Long[] nextLongArray(int n) {
            Long[] arr = new Long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }

            return arr;
        }

        String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }

    static void swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

}




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


int main() {
    long long int n, k;
    cin >> n >> k;
    long long int h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    std::sort(h, h + n, std::greater<>());
    long long int ans = 0;
    for(int i=k; i<n;i++) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


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

public class Hello
{
    public static void Main()
    {
        Console.WriteLine(program(new string[] { Console.ReadLine(), Console.ReadLine() }));
    }

    private static string program(string[] args)
    {
        var n = int.Parse(args[0]);
        var s = args[1].ToCharArray();

        var animalPattern = new List<Tuple<char, char>>() { Tuple.Create('S', 'S'), Tuple.Create('S', 'W'), Tuple.Create('W', 'S'), Tuple.Create('W', 'W') };

        return animalPattern.Select(animals =>
            s.Aggregate(new StringBuilder().Append(animals.Item2).Append(animals.Item1),
                (t, elem) => t.Append(isXor(t[t.Length - 1], elem) ? not(t[t.Length - 2]) : t[t.Length - 2]))
        )
        .FirstOrDefault(result => result.ToString().Substring(0, 2) == result.ToString().Substring(result.Length - 2, 2))?.ToString().Substring(1, n) ?? "-1";
    }

    private static bool isXor(char animal, char ans) => animal == 'S' && ans == 'x' || animal == 'W' && ans == 'o';

    private static char not(char animal) => animal == 'S' ? 'W' : 'S';
}


Measured memory_bytes: 16864
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = Is()
if K <= (N+1)/2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,p = mi()
s = input()
srev = s[::-1]

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i +1
    print(ans)
    exit()

acum = []
from collections import defaultdict
d = defaultdict(lambda :0)
d = [0] * p
num = 0
tenpow = 1
for i in range(0,n):
    a = int(srev[i])
    a = num + a *tenpow 
    tenpow = tenpow * 10 % p
    modd = a % p
    num = modd
    d[modd] += 1
    acum.append((modd,d[modd]))
ans = d[0]
for i in range(n):
    ans += d[acum[i][0]] - acum[i][1]
print(ans)



Measured memory_bytes: 24544
#include<bits/stdc++.h>
using namespace std;
int g=0,p=0,gg,pp;
char s[100005];
int main()
{
	scanf("%s",s);
	for(int i=0;s[i];i++)
	{
		if(s[i]=='g')
		{
			++g;
		}else
		{
			++p;
		}
	}
	pp=strlen(s)/2;
	gg=strlen(s)-(strlen(s)/2);
	//printf("%d %d %d %d\n",p,g,pp,gg);
	if(pp<g)
	{
		printf("%d\n",pp-p);
	}else
	{
		printf("%d\n",g-gg);
	}
}

Measured memory_bytes: 3928
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	int q;
	scanf("%d",&n);
	int a[n];
	int i;
	for(i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	
	scanf("%d",&q);
	int b[q];
	int j;
	for(j = 0; j < q; j++){
		scanf("%d",&b[j]);
	}
	
	qsort(b, q, sizeof(int), compare_int);
	
	int k = 0;
	int l = 0;
	int r = 0;
	while(k < n){
		if(a[k] == b[l]){
			k = k + 1;
			l = l + 1;
			r = r + 1;
		}
		else if(a[k] > b[l]){
			if(l < q){
				l = l + 1;
			}
			else if(l == q){
				break;
			}
		}
		else{
			k = k + 1;
		}
	}

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

	return 0;
	}

Measured memory_bytes: 2332
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m; cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; ++i) {
    	int x; cin >> x;
    	pq.push(x);
    }
    while (!pq.empty() && m) {
    	int x = pq.top();
    	pq.pop();
    	--m;
    	if (x / 2 > 0) pq.push(x / 2);
    }
    ll ans = 0;
    while (!pq.empty()) {
    	ans += (ll)pq.top();
    	pq.pop();
    }
    cout << ans << '\n';
}

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


int main()
{
  ll n;
  cin >> n;
  ll n1 = n;
  ll sum = 0;
  while(n!=0){
    sum += n % 10;
    n = n / 10;
  }
  if(n1%sum == 0) cout << "Yes" << endl;
  else if(n1%sum != 0) cout << "No" << endl;
  return 0;
}


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


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] mountains = new int[10];
		for(int i = 0; i < 10; i++){
			mountains[i] = sc.nextInt();
		}
		Arrays.sort(mountains);
		System.out.println(mountains[9]);
		System.out.println(mountains[8]);
		System.out.println(mountains[7]);

		
	}

}

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

int n;
std::vector<long long int> vec;

int main() {
    std::cin >> n;
    vec.assign(n+1, 0);
    vec[0] = 2;
    vec[1] = 1;
    
    for (int i = 2; i <= n; i++) {
        vec[i] = vec[i-1]+vec[i-2];
    }
    std::cout << vec[n] << std::endl;
}


Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#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 ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n];
	rep(i, 0, n)
	cin >> a[i];
	ll ans = 1, max = a[0];
	rep(i, 1, n)
	{
		if (a[i] >= max)
			ans += 1, max = a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	vector<bool> isused(26, false);
	for(int i = 0; i < s.length(); i++){
		isused[s[i] - 'a'] = true;
	}
	if(s.length() < 26){
		for(int i = 0; i < 26; i++){
			if(!isused[i]){
				cout << s << (char)('a' + i) << endl;
				return 0;
			}
		}
	} else {
		isused[s[s.length() - 1] - 'a'] = false;
		for(int i = s.length() - 2; i >= 0; i--){
			for(int j = s[i] - 'a'; j < 26; j++){
				if(!isused[j]){
					cout << s.substr(0, i) << (char)('a' + j) << endl;
					return 0;
				}
				isused[s[i] - 'a'] = false;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    string s, t;
    cin >> s >> t;
    for(int i=0; i<s.length(); i++){
        if(s[i] != t[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n;
int main () {
	scanf("%d", &n);
	if (n & 1) printf("%lf\n", (1.0 * n + 1) / (2.0 * n));
	else printf("%lf\n", 0.5);
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	if(n < 10){
		cout << n << endl;
	}
	else if(n < 100){
		cout << 9 << endl;
	}
	else if(n < 1000){
		cout << n - 99 + 9 << endl;
	}
	else if(n < 10000){
		cout << 900 + 9 << endl;
	}
	else if(n < 100000){
		cout << (n - 9999 + 9 + 900) << endl;
	}
	else cout << 90909 << endl;
    return 0;
}

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

#define pb push_back
#define ll long long
#define mp make_pair

int main()
{	
	// #ifndef ONLINE__JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	ll n;
	cin >> n;
	vector <ll> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	vector <ll> dp(n, 0);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);

	for(int i = 2; i < n; i++)
		dp[i] = min(abs(a[i] - a[i -2]) + dp[i - 2], abs(a[i] - a[i - 1]) + dp[i - 1]);
	cout << dp[n - 1];
}

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

int main(){
  int k,s;
  cin >> k >> s;
  int ans = 0;
  for (int x=0; x<=k; x++){
    for (int y=0; y<=k; y++){
      if (s-x-y <= k && x+y <= s) ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "6", "2 3 3 1 3 1" ].parse.expand.solve == 3 );
	assert( [ "6", "5 2 4 2 8 8" ].parse.expand.solve == 0 );
	assert( [ "32", "3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5" ].parse.expand.solve == 22 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto bs = new long[ as.length ];
	long[ long ] cs;
	foreach( i, a; as )
	{
		bs[ i ] = i - as[ i ];
		cs[ i - as[ i ] ]++;
	}
	
	foreach( i, ref a; as )
	{
		a = i + as[ i ];
	}
	
	auto ans = 0L;
	foreach( a, b; lockstep( as, bs ) )
	{
		cs[ b ]--;
		if( a in cs ) ans += cs[ a ];
	}
	return ans;
}


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

class AB{

public:
  void division1(int a,int b){
    int ans_d,ans_r;
    double ans_f;
    ans_d = a/b;
    ans_r = a%b;
    ans_f = (double)a/b;
    cout << ans_d << " " << ans_r << " " << fixed << setprecision(6) << ans_f << "\n";
    };
};

int main(){

  AB ab;
  int a,b;
  cin >> a >> b;

  ab.division1(a,b);


}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,c=0;
   while(cin>>n)
   {
       long long int ar[n+10];
       for(i=0;i<n;i++)
       {
           cin>>ar[i];
       }
       c=0;
       sort(ar,ar+n);
       for(i=0;i<n;i++)
       {
           for(j=i+1;j<n;j++)
           {
               for(int k = j+1;k<n;k++)
               {
                 if((ar[i]+ar[j]>ar[k])&& (ar[j]+ar[k]>ar[i])&&(ar[i]+ar[k]>ar[j])&& (ar[i]!=ar[j] && ar[j]!=ar[k]))
                    c++;
               }
           }
       }
       cout<<c<<endl;
   }

}


Measured memory_bytes: 3640
import string

s = input()

if s[0] != "A":
    print("WA")
    exit()

l_case = string.ascii_lowercase
if s[2:-1].count('C') == 1:
    c_index = s[2:].index('C') + 2
    if all(map(lambda x: x in l_case, s[1:c_index] + s[c_index + 1:])):
        print("AC")
    else:
        print("WA")
else:
    print("WA")




Measured memory_bytes: 3772
n = int(input())
a = list(map(int, input().split()))
M = max(a)
counts = [0 for _ in range(100000+1)]
s = sum(a)
for i in range(n):
  counts[a[i]] += 1
for i in range(int(input())):
  b, c = map(int, input().split())
  move = counts[b]
  counts[b] = 0
  counts[c] += move
  s += (c - b)*move
  print(s)

Measured memory_bytes: 21016
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int pt = 0;
    int px = 0;
    int py = 0;
    for (int i = 0; i < N; i++) {
      int t = scanner.nextInt();
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      int dist = Math.abs(x - px) + Math.abs(y - py);
      int dt = t - pt;
      if (dist > dt || (dt - dist) % 2 != 0) {
        System.out.println("No");
        return;
      }
      pt = t;
      px = x;
      py = y;
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 89064
#include<stdio.h>
#include<math.h>
 
int main(){
    unsigned int a,b;
    while(~scanf("%u%u",&a,&b)){
        unsigned int c=a,d=b;
        while(a>0&&b>0){
            if(a>b)a=a%b;
            else b=b%a;
        }
        printf("%u %u\n",a+b,c/(a+b)*d);
    }
}


Measured memory_bytes: 2572
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	string S,T;
	cin>>S>>T;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==S) a--;
	if(u==T) b--;
	printf("%d %d\n",a,b);
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
from itertools import product

N, K = map(int, input().split())
D = [int(x) for x in input().split()]


def check(x):
    for s in str(x):
        if int(s) in D:
            return False
    return True


for i in range(N, 10 * N):
    if check(i):
        print(i)
        break


Measured memory_bytes: 3060
#!/usr/bin/ruby
gets.to_i.times{
	x1,y1,x2,y2,x3,y3=gets.split.map(&:to_f)
	a1=2*x2-2*x1
	b1=2*y2-2*y1
	c1=x1*x1-x2*x2+y1*y1-y2*y2
	a2=2*x3-2*x1
	b2=2*y3-2*y1
	c2=x1*x1-x3*x3+y1*y1-y3*y3
	x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
	y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
	puts '%.3f %.3f %.3f'%[x,y,Math.hypot(x1-x,y1-y)]
}

Measured memory_bytes: 6164
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		int total = 0;
		int a[] = new int[n];
		
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
			total += a[i];
		}
		
		double border = (double)total/(double)(4*m);
		Arrays.sort(a);
		
		for(int i=n-1;i>n-1-m;i--) {
			if(a[i] < border) {
				System.out.println("No");
				System.exit(0);
			}else {
				continue;
			}
		}
		
		System.out.println("Yes");
		
	}	
}


Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi A(N), B(N); F0R(i, N) cin >> A[i] >> B[i];
    sort(all(A));
    sort(all(B));
    ll X, Y; 
    if (N % 2 == 1) {
        X = A[N/2];
        Y = B[N/2];
    } else {
        X = A[N/2 - 1] + A[N/2];
        Y = B[N/2 - 1] + B[N/2];
    }

    cout << Y-X+1 << nl;
	
	return 0;
}
 



Measured memory_bytes: 4784
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll x; cin >> x;
    ll a = x/11 * 2;
    int b = x%11;
    if(b >= 1 && b <= 6) a++;
    else if(b >= 7) a += 2;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N,M=MI()
Ten=[1 for _ in range(N)]
Michi=[[] for _ in range(N)]
H=LI()
for i in range(M):
  a,b=MI()
  a-=1
  b-=1
  Michi[a].append(b)
  Michi[b].append(a)  
for i in range(N):
  for j in Michi[i]:
    if H[i]<=H[j]:
      Ten[i]=0
      break
ans=sum(Ten)
print(ans)

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

using namespace std;

const long long MOD = 1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> iii;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef priority_queue<pii, vector<pii>, greater<pii>> fila_prioridade;
typedef priority_queue<iii, vector<iii>, greater<iii>> fila_prioridade_grids;

#define nl '\n'
#define INF 1000000000
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

float x,n;

int main() {
        NeedForSpeed

        cin >> n;

        x = (n * 100) / 108;
        x = ceil(x);

        if (floor(x * 1.08) == n) {
                cout << floor(x) << nl;
        } else {
                cout << ":(" << nl;
        }

        return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;

int main(){

  int n;cin>>n;
  int a[n+10],b[n+10];
  vector<vector<int> >v(n+1);
  int k=0;
  rep(i,0,n-1){
    cin>>a[i]>>b[i];
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
    if(k<v[a[i]].size())k=v[a[i]].size();
    if(k<v[b[i]].size())k=v[b[i]].size();
  }

  out(k);

  vector<vector<int> >alr(n+1);
  map<P,int>mp;
  rep(i,1,n){
    int cn=1;
    rep(j,0,v[i].size()){
      if(alr[i].size()!=0&&alr[i][0]==cn){cn++;alr[i].erase(alr[i].begin());}
      if(i>v[i][j])continue;
      alr[v[i][j]].push_back(cn);

      mp[P(i,v[i][j])]=cn;
      cn++;
    }
  }
  rep(i,0,n-1){
    out(mp[P(a[i],b[i])]);
  }

  return 0;
}


Measured memory_bytes: 18560
class BIT:
    def __init__(self, n):
        self.node = [ 0 for _ in range(n+1) ]

    def add(self, idx, w):
        i = idx
        while i < len(self.node) - 1:
            self.node[i] += w
            i |= (i + 1)

    def sum_(self, idx):
        ret, i = 0, idx-1
        while i >= 0:
            ret += self.node[i]
            i = (i & (i + 1)) - 1
        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


n, k = map(int, input().split())
tree = BIT(n)
p = [ int(x) for x in input().split() ]

for i in range(n):
    tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, tree.sum(i, i+k))

print(ans)

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

stack<int> s ;

int solve(string op)
{
  int b = s.top() ; s.pop() ;
  int a = s.top() ; s.pop() ;
  if(op == "+") {
    return a + b ;
  }else if(op == "-") {
    return a - b ;
  }else if(op == "*") {
    return a * b ;
  }else if(op == "/") {
    return a / b ;
  }
}
int main()
{
  string str ;
  while(cin >> str) {
    if(str == "+" || str == "-" || str == "*" || str == "/"){
      s.push( solve(str) ) ;
    }else{
      s.push( atoi( str.c_str() ) ) ;
    }
    if (getchar() == '\n' ) {
      break ;
    }
  }
  cout << s.top() << endl ;

  return 0 ;
}


Measured memory_bytes: 3204
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N=Integer.parseInt(sc.next());
		List<String> S = new ArrayList();
		Set<String> ss= new HashSet();
		for(int i=0; i<N; i++) {
			String word = sc.next();
			S.add(word);
			ss.add(word);
		}
		Map<String, Integer> ans = new HashMap();
		for(String a:S) {
			if(ss.contains(a)) {
				if(ans.containsKey(a)) {
					int v = ans.get(a);
					ans.put(a,++v);
				} else {
					ans.put(a, 0);
				}
			}
		}
		int m = 0;
		for(int aa : ans.values()) {
			m= Math.max(m, aa);
		}
		List<String> aaa =new ArrayList();
		for(String a : ans.keySet()) {
			if(ans.get(a) == m) {
				aaa.add(a);
			}
		}
		Collections.sort(aaa);
		for(String aa: aaa) {
			System.out.println(aa);
		}
	}
}


Measured memory_bytes: 103432
#include <stdio.h>
int main(){
	int N;
	int L;
	scanf("%d",&N);
	scanf("%d",&L);
	int i;
	int ans;
	ans=0;
	int aji[300];
	for(i=1;i<=N;i++){
		aji[i]=L+i-1;
	}
	for(i=1;i<=N;i++){
		ans=ans+aji[i];
	}
	for(i=1;i<=N;i++){
		if(aji[i]==0){
			printf("%d",ans);
			return 0;
		}
	}
	if(aji[N]<0){
		printf("%d",ans-aji[N]);
		return 0;
	}
	printf("%d",ans-aji[1]);
}

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

int main(){
  int H,N;cin >> H >> N;
  int maxA=0;
  vector<pair<int,int>> AB(N);
  for(int i=0; i<N; i++){
    cin >> AB[i].first >> AB[i].second;
    if(maxA<AB[i].first) maxA=AB[i].first;
  }
  vector<int> A(H+maxA,0);
  for(int i=maxA; i<H+maxA; i++) A[i]=1000000000;
  for(int i=maxA; i<H+maxA; i++){
    for(int j=0; j<N; j++){
      A[i]=min(A[i],A[i-AB[j].first]+AB[j].second);
    }
  }
  cout << A[maxA+H-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    rep(i, 100000){
        if(i % 2 == 0){
            c -= b;
            if(c <= 0){
                cout << "Yes";
                return 0;
            }
        }
        else {
            a -= d;
            if(a <= 0){
                cout << "No";
                return 0;
            }
        }
    }
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;
}

bool f[100010];
int cnt[100010];

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

  for(int i=2; i<=100000; i++){
    f[i]=isprime(i);
  }

  for(int i=1; i<=100000; i++){
    if(f[i] && f[(i+1)/2] ) cnt[i]=1;
  }

  vector<int> s(100010,0);

  for(int i=0; i<=100000; i++){
    s[i+1]=s[i]+cnt[i];
  }

  while(Q--){
    int l,r;
    cin >> l >> r;
    int ans = s[r+1] - s[l];
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
n,x,y=map(int,input().split())
x-=1; y-=1
C=[0]*(n-1)

for i in range(n):
  for j in range(i+1,n):
    d=min(j-i,abs(x-i)+abs(y-j)+1)
    C[d-1]+=1

print(*C)


Measured memory_bytes: 45404
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		ll x = n / i;
		ans += x * (x + 1) / 2 * i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3672
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  vector<string> cards(3);
  cin >> cards[0] >> cards[1] >> cards[2];
  vector<int> positions(3, 0);
  int player = 0;
  while (true) {
    if (cards[player].size() == positions[player]) {
      cout << (char)('A' + player) << endl;
      return;
    }
    positions[player]++;
    player = cards[player][positions[player] - 1] - 'a';
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

#define ll long long
#define MAXN 110
#define MAXV 100010
#define INF 9e18

using namespace std;

ll dp[MAXN][MAXV];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, w;
    cin >> n >> w;

    int weight[n];
    ll value[n];
    for(int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    
    for(int i = 1; i < MAXV; i++)
        dp[0][i] = INF;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j < MAXV; j++) {
            dp[i][j] = dp[i - 1][j];

            if(j >= value[i - 1])
                dp[i][j] = min(dp[i][j], dp[i - 1][j - value[i - 1]] + weight[i - 1]);
        }
    }

    for(int i = MAXV - 1; i >= 0; i--) {
        if(dp[n][i] <= w) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 82508
#include<stdio.h>
int main(void){
	double x[4],y[4];
	int i;
	while( scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF ){
		for(i=1; i<4; i++){
			x[i]-=x[0];
			y[i]-=y[0];
		}
		x[0]=(x[3]*y[2]-y[3]*x[2])/(x[1]*y[2]-y[1]*x[2]);
		y[0]=(x[3]*y[1]-y[3]*x[1])/(x[2]*y[1]-y[2]*x[1]);
		if( x[0]>0 && y[0]>0 && (x[0]+y[0])<1 ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	s := readString()
	w := readInt()

	var ans string
	for i := 0; i < len(s); i += w {
		ans += s[i : i+1]
	}
	println(ans)

}


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

bool pc (string str) {
    size_t l = str.length();
    for (int i = 0; i <= (int) l / 2 + 1; i++){
        if (str[i] != str[l - 1 - i]) {
            return false;
        }
    }
    return true;
}

int main () {
    string s;
    cin >> s;
    size_t l = s.length();
    string stra = s.substr(0, (unsigned int) l / 2);
    string strb = s.substr((unsigned int)l / 2 + 1, l + 1);
    if (pc(s) && pc(stra) && pc(strb)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    }

Measured memory_bytes: 384
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    intmax_t N; cin >> N;

    constexpr int MOD = int(1e9) + 7;
    intmax_t fact = 1;
    for (intmax_t i = 1; i <= N; ++i) {
        fact *= i;
        fact %= MOD;
    }

    cout << fact << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

char str[9];
int is_snuke(void) {
	if(str[0]!='s') return 0;
	if(str[1]!='n') return 0;
	if(str[2]!='u') return 0;
	if(str[3]!='k') return 0;
	if(str[4]!='e') return 0;
	if(str[5]!='\0') return 0;
	return 1;
}
int main() {
	int x,y;
	scanf("%d%d",&x,&y);
	for(int i=1;i<=x;i++) {
		for(int j=0;j<y;j++) {
			scanf("%s",str);
			if(is_snuke()) printf("%c%d\n",'A'+j,i);
		}
	}
	return 0;
}


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

void bubbleSort(int a[],int n)
{
    int flag = 1;
    int work;
    while(flag){
        flag = 0;
        for(int j=n-1; j>=1; j--){
            if(a[j]>a[j-1]){
                work = a[j];
                a[j] = a[j-1];
                a[j-1] = work;
                flag = 1;
            }
        }
    }
}

int main()
{
    int N,a[100],alice=0,bob=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    bubbleSort(a,N);
    for(int i=0; i<N; i++){
        if(i%2 == 0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    for (int i = K; i < N; i++) {
        if (A[i-K] >= A[i]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	int a,b;
	cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
	return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

template <class T>
struct vec2: vector<vector<T>> {
    vector<int> shape;
    vec2(int n0, int n1, T value = 0) : vector<vector<T>>(n0, vector<T>(n1, value)), shape{n0, n1} { }
};

template <class T>
struct vec3: vector<vector<vector<T>>> {
    vector<int> shape;
    vec3(int n0, int n1, int n2, T value = 0) : vector<vector<vector<T>>>(n0, vector<vector<T>>(n1, vector<T>(n2, value))), shape{n0, n1, n2} { }
};


int main() {
    constexpr int D_MAX = 80;
    constexpr int UNDEFINED = -1;
    int H, W;
    cin >> H >> W;
    vec2<int> A(H, W), B(H, W), D(H, W);
    REP(i, H) REP(j, W) cin >> A[i][j];
    REP(i, H) REP(j, W) cin >> B[i][j];
    REP(i, H) REP(j, W) D[i][j] = abs(A[i][j] - B[i][j]);

    vec3<int> dp(H, W, (H + W - 1) * D_MAX + 1);
    dp[0][0][D[0][0]] = true;

    REP(i, H) REP(j, W) REP(k, dp.shape[2]) {
        if (dp[i][j][k]) {
            if (i + 1 < H) {
                dp[i + 1][j][k + D[i + 1][j]] = true;
                dp[i + 1][j][abs(k - D[i + 1][j])] = true;
            }
            if (j + 1 < W) {
                dp[i][j + 1][k + D[i][j + 1]] = true;
                dp[i][j + 1][abs(k - D[i][j + 1])] = true;
            }
        }
    }

    REP(k, dp.shape[2]) {
        if (dp[H - 1][W - 1][k]) {
            cout << k << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int arr[200005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int i = 0; i < n; ++i){
        int j; cin >> j;
        arr[j] = i + 1;
    }

    int best = 0, cur = 0;

    for(int i = 1; i <= n; ++i){
        if(i == 1 || arr[i] > arr[i - 1]){
            ++cur;
        } else {
            cur = 1;
        }
        best = max(best, cur);
    }

    cout << n - best << "\n";

    return 0;

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題_07
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int hoge = int.Parse(str);
            if (hoge == 25) Console.WriteLine("Christmas");
            if (hoge == 24) Console.WriteLine("Christmas Eve");
            if (hoge == 23) Console.WriteLine("Christmas Eve Eve");
            if (hoge == 22) Console.WriteLine("Christmas Eve Eve Eve");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   float t,n,a[101],l,m,s=0,c=0;
   cin>>n>>m;
   for(long long int i=0;i<n;i++)
   {
      cin>>a[i];
      s=s+a[i];
   }
   l=s/(4*m);
   //cout<<l<<endl;
   for(long long int i=0;i<n;i++)
   {
      if(a[i]>=l)
      {
         c++;
      }
   }
   if(c>=m)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
   return 0;
}


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

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null; }
        String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try { tokenizer = new StringTokenizer(reader.readLine()); } 
                catch (IOException e) { throw new RuntimeException(e);} }
            return tokenizer.nextToken(); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        
        int a = r.nextInt();
        int b = r.nextInt();
        pw.println(Math.max(0, a - 2 * b));

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

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

int main() {
  int N; cin >> N;
  vector<int> a(N + 1); for (int i = 1; i <= N; i++) cin >> a[i];
  vector<int> number(100001);
  for (int i = 1; i <= N; i++) number[a[i]]++;
  int num = 0, ans = 0;
  for (int X = 1; X < 100000; X++) {
    num = number[X - 1] + number[X] + number[X + 1];
    ans = max(num, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

#define YES printf("Yes\n")
#define NO printf("No\n")

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[105][105];
    ll h,w;
    scanf("%lld%lld",&h,&w);
    ll cnt[26]={};
    rep(i,0,h){
        scanf("%s",s[i]);
        rep(j,0,w){
            cnt[(ll)s[i][j]-97]++;
        }
    }

    ll a=0,b=0;
    rep(i,0,26){
        if(cnt[i]%4==1){a++;}
        if(cnt[i]%4==2){b++;}
        if(cnt[i]%4==3){a++;}
    }
    
    if(h%2==0&&w%2==0){
        if(a==0&&b==0){
            YES;
        }else{
            NO;
        }
    }


    if(h*w%2==1){
        
        if(a==1){
            if( b <= h/2+w/2 ){
                YES;
            }else{
                NO;
            }
        }else{
            NO;
        }
    }


    if( h*w%2==0  && (h+w)%2==1 ){
        // printf("b%lld\n",b);
        if(a!=0){
            NO;
        }else{
            if(b > ( (h%2) ? (w/2) : (h/2) ) ){
                NO;
            }else{
                YES;
            }
        }
    }
    // rep(i,0,26){
    //     printf("%c%lld ",(char)i+97,cnt[i]);
    // }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int c[505][505];
int pre[3][30];

int main(){
    int n,C;
    cin>>n>>C;
    int d[C][C];
    rep(i,C) rep(j,C) cin>>d[i][j];

    vector<vector<int>> cnt(3);
    rep(i,n){
        rep(j,n){
            cin>>c[i][j];
            c[i][j]--;
        }
    }

    rep(col,C) rep(i,n) rep(j,n) pre[(i+j)%3][col]+=d[c[i][j]][col];

    int ans=INF;
    rep(i,C){
        rep(j,C){
            rep(k,C){
                if(i==j) continue;
                if(j==k) continue;
                if(k==i) continue;
                ans=min(ans,pre[0][i]+pre[1][j]+pre[2][k]);
            }
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 4564
#include<stdio.h>
int main()
{
	int n,a[111111],t=1,i,c=0,f=0;

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

	for(i=0;i<n;i++)
		if(a[i]==2)
			f=1;
	if(f==0){
		puts("-1");
		return 0;
	}
	while(n>=0){
		t=a[t-1];
		c++;
		if(t==2){
			printf("%d",c);
			return 0;
		}
		n--;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll cnt = 1;
    ll bb = 0;
    rep(i, n) {
        if (a[i] == cnt) cnt++;
        else bb++;
    }

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

Measured memory_bytes: 1792