akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    static Boolean[] visited;
    static Boolean[,] con;
    static int N;

    internal static void Main(string[] args) {
        var inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
        N = inp[0];
        var M = inp[1];
        con = new Boolean[N + 1, N + 1];
        var a = new List<int>();
        var b = new List<int>();
        for (int i = 0; i < M;i++) {
            inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            inp[0]--;
            inp[1]--;
            a.Add(inp[0]);
            b.Add(inp[1]);
            con[inp[0], inp[1]] = true;
            con[inp[1], inp[0]] = true;
        }

        int ans = 0;
        for (int i = 0; i < M; i++) {
            Change(a[i], b[i], false);
            visited = new Boolean[N];
            DFS(0);
            if (visited.Any(boo => boo == false)) {
                ans++;
            }
            Change(a[i], b[i], true);
        }
        WriteLine(ans);
    }

    static void DFS(int x) {
        visited[x] = true;
        for (int i = 0; i < N; i++) {
            if (con[x,i] == false) { continue; }
            if (visited[i] == true) { continue; }
            DFS(i);
        }
    }

    static void Change(int a, int b, Boolean boo) {
        con[a, b] = boo;
        con[b, a] = boo;
    }
}

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long A = NextLong();
        long B = NextLong();
        long C = NextLong();
        long D = NextLong();

        long c0 = B / C;
        long c1 = (A - 1) / C;

        long c2 = B / D;
        long c3 = (A - 1) / D;

        long sum = c0 - c1 + c2 - c3;

        long g = LCM(C, D);

        long c5 = B / g;
        long c6 = (A - 1) / g;

        Console.WriteLine((B - A) - sum + (c5 - c6) + 1);

    }
    public static long GCD(long a, long b)
    {
        if (a < b) GCD(b, a);
        long d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(long a, long b)
    {
        return a / GCD(a, b) * b;
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

 
int main (){
  	int N;
  	cin>>N;
    vector<long double> X(N), Y(N);
    for(int i=0; i<N; i++){
        cin>>X.at(i)>>Y.at(i);
    }
    long double Sum=0;
    for(int i=0; i<N; i++){
        for(int j=1+i; j<N; j++){
            long double Z=(X.at(i)-X.at(j))*(X.at(i)-X.at(j))+(Y.at(i)-Y.at(j))*(Y.at(i)-Y.at(j));
          	//cout<<Z<<endl;
            Sum += pow(Z, 0.5);
          	//cout<<pow(Z, 0.5)<<endl;
        }

    }
	cout<<fixed<<setprecision(10)<<Sum*2/N;
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{  
	fast;
	ll R;
	cin>>R;
	cout << fixed << setprecision(12) << 2*pi*R << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <map>
#include <list>
#include <set>

using namespace std;

typedef long long ll;

int main() {

    int n;
    cin >> n;

    vector<int> numbers(n);

    unordered_map<int,int> freq;

    int mayor = -1;
    for(int i = 0; i < n; i++)
    {
        cin >> numbers[i];
        freq[numbers[i]]++;

        if(numbers[i] > mayor)
            mayor = numbers[i];
    }

    vector<int> prefix_sum (mayor+1);
    prefix_sum[0] = freq[0];

    for(int i = 1; i < prefix_sum.size(); i++)
    {
        prefix_sum[i] = freq[i] + prefix_sum[i-1];
    }

    int counter = 0;
    for(int k = 1; k <= mayor; k++)
    {
        if(prefix_sum[k-1] == n/2 )
            counter++;
    }

    cout << counter;

    return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000;

int main()
{
	int N,K;cin >> N >>K;
	long long ans=INF;
	vector<int> building(N),building_fix(N);
	for (int i=0;i<N;i++) cin >> building[i];
	for (int i=0;i<1<<N;i++)
	{
		for (int i=0;i<N;i++) building_fix[i]=building[i];
		long long now=0;
		vector<int> choice;
		for (int r=0;i>>r>0;r++)
		{
			if ((i>>r)&1) choice.push_back(r);
		}
		if (choice.size()!=K) continue;
		choice.insert(choice.begin(),0);
		for (int k=1;k<K+1;k++)
		{
			int height=building_fix[choice[k-1]];
			for (int l=choice[k-1];l<choice[k];l++)
			{
				height=max(height,building_fix[l]);
			}
			if (height>=building[choice[k]] && choice[k-1]!=choice[k]) 
			{
				now+=height-building[choice[k]]+1;
				building_fix[choice[k]]=height+1;
			}
			if (height>=building[choice[k]] && choice[k-1]==choice[k]) 
			{
				now+=height-building[choice[k]];
				building_fix[choice[k]]=height;
			}
			//cout << now << endl;
		}
		ans=min(ans,now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int A,B,C,X;
int ans;


int main() {
  cin >>A>>B>>C>>X;
  for (int a=0; a<=A; a++) {
    for (int b=0; b<=B;b++) {
      for (int c=0;c<=C;c++) {
        if (500*a+100*b+50*c == X) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<vector<char>> S(N, vector<char>(10));
    rep(i, N) rep(j, 10) cin >> S[i][j];
    
    rep(i, N) sort(S[i].begin(), S[i].end());
    map<vector<char>, int> m;
    long long ans = 0;
    rep(i, N) {
        if (m.count(S[i])) {
            ans += m[S[i]];
            ++m[S[i]];
        } else {
            m[S[i]] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define MAX_N 50
int v[MAX_N];
int n;
int k;

int favour_left[MAX_N][MAX_N + 1];
int favour_right[MAX_N][MAX_N + 1];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    int i;
    for(i = 0; i < n; ++i){
        cin >> v[i];
    }
    int j;
    for(i = 1; i <= n; ++i){
        priority_queue<int, vector<int>, greater<int> > q;
        int max_sum = 0;
        for(j = 0; j < i; ++j){
            max_sum += v[j];
            q.push(v[j]);
        }
        favour_left[i - 1][i] = max_sum;
        for(j = i; j < n; ++j){
            if(v[j] > q.top()){
                max_sum -= q.top();
                q.pop();
                max_sum += v[j];
                q.push(v[j]);
            }
            favour_left[j][i] = max_sum;
        }
    }
    for(i = 1; i <= n; ++i){
        priority_queue<int, vector<int>, greater<int> > q;
        int max_sum = 0;
        for(j = 0; j < i; ++j){
            max_sum += v[n - 1 - j];
            q.push(v[n - 1 - j]);
        }
        favour_right[i - 1][i] = max_sum;
        for(j = i; j < n; ++j){
            if(v[n - 1 - j] > q.top()){
                max_sum -= q.top();
                q.pop();
                max_sum += v[n - 1 - j];
                q.push(v[n - 1 - j]);
            }
            favour_right[j][i] = max_sum;
        }
    }
    int max_favour = 0;
    int p, q;
    for(i = 0; i < n; ++i){
        for(p = i + 1; p >= 0; --p){
            int op_left = i + 1 + (i + 1 - p);
            if(op_left > k){
                break;
            }
            max_favour = max(max_favour, favour_left[i][p]);
        }
    }
    for(j = 0; j < n; ++j){
        for(q = j + 1; q >= 0; --q){
            int op_right = j + 1 + (j + 1 - q);
            if(op_right > k){
                break;
            }
            max_favour = max(max_favour, favour_right[j][q]);
        }
    }
    for(i = 0; i < n; ++i){
        for(j = 0; j < n && i + j + 1 < n; ++j){
            for(p = i + 1; p >= 0; --p){
                int op_left = i + 1 + (i + 1 - p);
                if(op_left > k){
                    break;
                }
                for(q = j + 1; q >= 0; --q){
                    int op_right = j + 1 + (j + 1 - q);
                    if(op_left + op_right > k){
                        break;
                    }
                    max_favour = max(max_favour, favour_left[i][p] + favour_right[j][q]);
                }
            }
        }
    }
    cout << max_favour << '\n';
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,a;
	cin>>h>>a;
	cout<<(h/a + (h%a!=0))<<endl;
	return 0;
}

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

#define F first
#define S second
#define eb emplace_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,s=0;
    cin>>n>>m;
    fr(i,0,m)
    {
        int x;
        cin>>x;
        s+=x;
    }
    if(s<=n)
    {
        cout<<n-s<<"\n";
        return 0;
    }
    cout<<-1<<"\n";
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  stack<long long int> hoge;
  while(true){
    string x;
    cin>>x;
    if(x==""){
      break;
    }
    if(x=="+"){
      long long int a=hoge.top();
      hoge.pop();
      long long int b=hoge.top();
      hoge.pop();
      hoge.push(a+b);
    }else if(x=="-"){
      long long int a=hoge.top();
      hoge.pop();
      long long int b=hoge.top();
      hoge.pop();
      hoge.push(b-a);
    }else if(x=="*"){
      long long int a=hoge.top();
      hoge.pop();
      long long int b=hoge.top();
      hoge.pop();
      hoge.push(a*b);
    }else{
      long long int a=stoi(x);
      hoge.push(a);
    }
  }
  cout<<hoge.top()<<endl;
}


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

using namespace std;
	
const int maxn=1e5*3+20;
int b[maxn];

int main()
{
	int a,d,c;
	cin >> a >> d >> c;
	int aa,dd,cc,ans=0;
	
	while(1)
	{
		if(a%2==1 || d%2==1 || c%2==1)
			break;
		else if(a==d && d==c)
		{
			cout << -1;
			return 0;
		}
		
		aa=a/2;
		dd=d/2;
		cc=c/2;
		a=dd+cc;
		d=aa+cc;
		c=aa+dd;
		ans++;
	}
	cout << ans;
}

 



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

void unite(long *affiliation, long *group, long p, long q) {
  long i,j;
  j = 0;
  for (i = 0; j < group[q]; i++) {
    if(affiliation[i] == q) {
      affiliation[i] = p;
      j++;
    }
  }
  group[p] += group[q];
}

int main()
{
  long n,m,i,s,t,p,q;
  long *affiliation,*group;
  scanf("%ld %ld",&n,&m);
  affiliation = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) affiliation[i] = -1;
  group = (long*)malloc(sizeof(long) * m);
  for (i = 0; i < m; i++) group[i] = 0;
  p = 0;
  for (i = 0; i < m; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == -1 && affiliation[t] == -1) {
      affiliation[s] = p;
      affiliation[t] = p;
      group[p] += 2;
      p++;
    }
    else if(affiliation[s] != -1 && affiliation[t] == -1) {
      affiliation[t] = affiliation[s];
      group[affiliation[s]]++;
    }
    else if(affiliation[s] == -1 && affiliation[t] != -1) {
      affiliation[s] = affiliation[t];
      group[affiliation[t]]++;
    }
    else if(affiliation[s] != affiliation[t]){
      (affiliation[s] < affiliation[t]) ? unite(affiliation,group,affiliation[s],affiliation[t]):unite(affiliation,group,affiliation[t],affiliation[s]);
    }
  }
  scanf("%ld",&q);
  for (i = 0; i < q; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == affiliation[t] && affiliation[s] != -1) printf("yes\n");
    else printf("no\n");
  }
  free(affiliation);
  free(group);
  
  return 0;
}

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

int main() {

  int n;
  cin >> n;
  int ans = 0;

  for(int i = 0; i < 10e10; i++) {
    if(i * i > n){
      break;
    }else if (i * i <= n) {
      ans = i * i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,M = map(int,input().split())
LRA = [[int(x) for x in row.split()] for row in sys.stdin.readlines()]

R_to_LA = [[] for _ in range(N+1)]
for L,R,A in LRA:
    R_to_LA[R].append((L,A))

INF = 10 ** 18

size = 1<<18
data = [0] * (2*size)
lazy = [0] * (2*size)
left_end = [None] * (2*size)
right_end = [None] * (2*size)
left_end[1] = 0
right_end[1] = size
for n in range(1,size):
    L,R = left_end[n],right_end[n]
    M = (L+R)//2
    left_end[2*n] = L
    right_end[2*n] = M
    left_end[2*n+1] = M
    right_end[2*n+1] = R

def add(L,R,x):
    q = [1]
    q1 = []
    while q:
        qq = []
        for i in q:
            iL = left_end[i]
            iR = right_end[i]
            if L <= iL and iR <= R:
                # 完全に含まれている
                lazy[i] += x
            elif iR<=L or R<=iL:
                pass
            else:
                # 部分的に交わっている
                q1.append(i)
                j = i<<1; k = j+1
                lazy[j] += lazy[i]; lazy[k] += lazy[i]
                lazy[i] = 0
                qq.append(j)
                qq.append(k)
        q = qq
    for i in reversed(q1):
        j = i<<1; k = j+1
        data[i] = max(data[j]+lazy[j],data[k]+lazy[k])

for R in range(1,N+1):
    x = data[1] + lazy[1]
    add(R,R+1,x)
    for L,A in R_to_LA[R]:
        add(L,R+1,A)

for n in range(size):
    lazy[2*n] += lazy[n]
    lazy[2*n+1] += lazy[n]

answer = max(lazy[size:])
print(answer)

Measured memory_bytes: 123740
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int M;
    cin >> M;
    cout << 24 + (24-M) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int n,k;
    cin >> n >> k;
    if(n%k == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
from math import cos, sqrt, pi
a, b, h, m = map(int, input().split())
#時針の角度
ang_a = pi * h / 6 + pi * m / 360
#分針の角度
ang_b = pi * m / 30
#角度差
ang = abs(ang_a-ang_b)
#余弦定理
c = sqrt(a**2 + b**2 - 2*a*b*cos(ang))
print(c)

Measured memory_bytes: 9420
import sys
N, M = [int(x) for x in input().split()]

s = 1
e = 2 * -(-M // 2)
for _ in range(M):
    if s >= e:
        s = N - 2 * (M // 2)
        e = N
    print(s, e)
    s += 1
    e -= 1

Measured memory_bytes: 9272
// Problem : B - Painting Balls with AtCoDeer
// Contest : AtCoder - AtCoder Beginner Contest 046
// URL : https://atcoder.jp/contests/abc046/tasks/abc046_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	long long ans = k;
	for(int i = 0; i < n; i++){
	    if(i==0) continue;
	    ans*=k-1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] s = new int[M];
            int[] c = new int[M];
            for (int i = 0; i < M; i++) {
                s[i] = sc.nextInt() - 1;
                c[i] = sc.nextInt();
            }

            for (int n = 0; n < 1000; n++) {
                if (isValid(n, N, s, c)) {
                    System.out.println(n);
                    return;
                }
            }

            System.out.println(-1);
        }
    }

    private static boolean isValid(int n, int N, int[] s, int[] c) {
        String S = "" + n;
        if (S.length() != N) {
            return false;
        }
        for (int i = 0; i < c.length; i++) {
            if (S.charAt(s[i]) - '0' != c[i]) {
                return false;
            }
        }
        return true;
    }

}

Measured memory_bytes: 27100
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    char C;
    cin >> C;

    cout << char(C + 1) << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
using namespace std;

long long int pow(int n, int k);

int main() {
    int n, k;
    long long int ans;
    cin >> n >> k;
    ans = k * pow(k-1, n-1);
    
    cout << ans << endl;
}

long long int pow(int n, int k){
    if(k == 0){
        return 1;
    }else if(k%2 == 1){
        return n * pow(n, k-1);
    }else{
        return pow(n*n, k/2);
    }
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
table=[[0,0]]

m=10**9+7

ans=pow(2,N//2,m)
A.sort()

if N%2==0:
    if A[0]!=1:
        ans=0
    else:
        for i in range(N):
            if A[i]!=i+1-i%2:
                ans=0
else:
    if A[0]!=0:
        ans=0
    else:
        for i in range(1,N):
            if A[i]!=i+i%2:
                ans=0

print(ans)

Measured memory_bytes: 13880
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 1;
    rep(i, N) {
        if (ans * 2 > ans + K) {
            ans += K;
        } else {
            ans *= 2;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  string s;
  cin >> s;
  auto can_go = [&] (int from, int to) {
    while (from < to) {
      if (s[from + 1] == '.') {
        from++;
      } else {
        if (s[from + 2] == '.') {
          from += 2;
        } else {
          return false;
        }
      }
    }
    return true;
  };
  auto has_good_pos = [&] (int from, int to) {
    for (int i = from; i <= to; i++) {
      if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') {
        return true;
      }
    }
    return false;
  };
  if (can_go(a, c) && can_go(b, d)) {
    if (c < d || has_good_pos(b, d)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vvl cnt(N,vl(N));
    bool use[N][N];
    rep(i,N){
        rep(j,N){
            cnt[i][j]=min({i,j,N-1-i,N-1-j});
            use[i][j]=false;
        }
    }
    vl A(N*N);
    rep(i,N*N){
        cin >> A[i];
        A[i]--;
    }
    ll ans=0;
    int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
    rep(i,N*N){
        //cout << ans << endl;
        ans+=cnt[A[i]/N][A[i]%N];
        use[A[i]/N][A[i]%N]=true;
        queue<P> que;
        que.push({A[i]/N,A[i]%N});
        if(min({A[i]/N,A[i]%N})==0||max({A[i]/N,A[i]%N})==N-1){
            cnt[A[i]/N][A[i]%N]=0;
        }
        while(!que.empty()){
            P p=que.front();
            que.pop();
            ll x=p.first,y=p.second;
            rep(j,4){
                int nx=x+dx[j],ny=y+dy[j];
                if(0<=nx&&nx<N&&0<=ny&&ny<N){
                    if(use[x][y]){
                        if(chmin(cnt[nx][ny],cnt[x][y])){
                            que.push({nx,ny});
                        }
                    }
                    else{
                        if(chmin(cnt[nx][ny],cnt[x][y]+1)){
                            que.push({nx,ny});
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 7404
#include <iostream>
using namespace std;
int main() {
	while (1) {
		int n, k, a[100005] = { 0 }, m = -9999999, dp[100005] = { 0 };
		cin >> n >> k;
		if (n == 0 && k == 0) return 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < k; i++) {
			dp[0] += a[i];
		}
		for (int i = 1; i < n - k + 2; i++) {
			dp[i] = dp[i - 1] - a[i - 1] + a[i + k - 1];
		}
		for (int i = 0; i < n - k + 1; i++) {
			//cout << dp[i] << endl;
			if (m < dp[i]) m = dp[i];
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int main() {
	int n;
	cin >> n;
	int a=0, b=0, c=0;
	rep(i, n) {
		ll k;
		cin >> k;
		if (k % 4 == 0) {
			c++;
		}
		else if (k % 2 == 0) {
			b++;
		}
		else a++;
	}
	if (c >= a) {
		cout << "Yes" << endl;
		return 0;
	}
	if (c == a - 1 && b == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


int main() {
	ll N, K;
	cin >> N >> K;
	pi visited = {N};
	ll result = N;
	N = N % K;
	if(N % K == 0){
		cout << 0 << "\n";
		exit(0);
	}
	while(N > 0){
		N = abs(N-K);
		if(result < N){
			N = 0;
		 }
		 else{
			 result = N;
		 }
		 
	}
	cout << result << "\n";
}


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

    int main()
    {
        int a,b;
        scanf("%d%d",&a,&b);
        string aa[a];
        for(int i=0;i<a;i++)
        {
            cin >> aa[i];
        }
        for(int i=0;i<a;i++)
        {
            cout << aa[i] << "\n" << aa[i] << endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL t[505];
LL n,m;
vector<LL> v1;

LL check(LL p){
	v1.clear();
	int i,j,k;
	LL a,b,c;
	b=0;
	for(i=0;i<n;i++){
		a=t[i]%p;
		b+=a;
		v1.push_back(a);
	}
	sort(v1.rbegin(),v1.rend());
	c=b;
	b/=p;
	for(i=0;i<b;i++){
		c+=p-2*v1[i];
	}
	return c/2;
}

int main(){
	LL i,j,k;
	LL a,b,c;
	cin>>n>>m;
	a=0,b=0,c=0;
	for(i=0;i<n;i++){
		cin>>t[i];
		a+=t[i];
		if(b<t[i])b=t[i];
	}
	b+=m;
	for(i=1;i<=1e8;i++){
		if(i>b)break;
		if(a%i!=0)continue;
		if(check(a/i)<=m){
			c=a/i;break;
		}
		if(check(i)<=m)c=i;
	}
	cout<<c<<endl;
}
		
	


Measured memory_bytes: 384
# vim: set fileencoding=utf-8:
from collections import Counter


def main():
    N = input()
    a = [int(ele) for ele in raw_input().split()]
    a_plus = [ele + 1 for ele in a]
    a_minus = [ele - 1 for ele in a]
    ct = Counter(a)
    ct_plus = Counter(a_plus)
    ct_minus = Counter(a_minus)

    for k, v in ct_plus.items():
        ct[k] += v

    for k, v in ct_minus.items():
        ct[k] += v

    print(ct.most_common()[0][1])


if __name__ == "__main__":
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
map<string,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>s;
		M[s]++;
	}
	
	cout<<"AC x "<<M["AC"]<<endl;
	cout<<"WA x "<<M["WA"]<<endl;
	cout<<"TLE x "<<M["TLE"]<<endl;
	cout<<"RE x "<<M["RE"]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
	long long a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long divc = b / c - (a - 1) / c;
	long long divd = b / d - (a - 1) / d;
	long long lcm;
	long long e = max(c, d);
	long long f = min(c, d);
	while(true) {
		if(e % f == 0) {
			break;
		}
		long long g = f;
		f = e % f;
		e = g;
	}
	lcm = c * d / f;
	long long divlcm = b / lcm - (a - 1) / lcm;
	printf("%lld\n", b - a + 1 - (divc + divd - divlcm));
 }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

list.sort(a, reverse = True)
#print(a)

i = 0
tmp = []
while True:
    if a[i] == a[i + 1]:
        tmp.append(a[i])
        if i != n - 1:
            i += 2
        if i == n - 1:
            break
    else:
        i += 1
    if i == n - 2:
        break
if a[n-2] == a[n-1]:
    tmp.append(a[n-2])

list.sort(tmp, reverse = True)
#print(tmp2)
#print(tmp)
if len(tmp) >= 2:
    print(tmp[0] * tmp[1])
else:
    print(0)


Measured memory_bytes: 14244
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#define ll long long int
#define pb push_back
using namespace std;
int g[2222][2222];
int ten[2222][2222];
int henx[2222][2222];
int heny[2222][2222];
int n,m,q;

int main(void){
  int i,j;
  int x1,x2,y1,y2;
  int res1,res2;
  char c;
  cin>>n>>m>>q;
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      cin>>c;
      g[i][j]=c-'0';
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      ten[i][j]=g[i][j]+ten[i-1][j]+ten[i][j-1]-ten[i-1][j-1];
      henx[i][j]=g[i][j]*g[i-1][j]+henx[i-1][j]+henx[i][j-1]-henx[i-1][j-1];
      heny[i][j]=g[i][j]*g[i][j-1]+heny[i-1][j]+heny[i][j-1]-heny[i-1][j-1];
    }
  }
  for(i=0;i<q;i++){
    cin>>x1>>y1>>x2>>y2;
    res1=ten[x2][y2]-ten[x2][y1-1]-ten[x1-1][y2]+ten[x1-1][y1-1];
    res2=henx[x2][y2]-henx[x2][y1-1]-henx[x1][y2]+henx[x1][y1-1];
    res2+=heny[x2][y2]-heny[x2][y1]-heny[x1-1][y2]+heny[x1-1][y1];
    cout<<res1-res2<<endl;
  }
  return 0;
}

Measured memory_bytes: 77568
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long K, long long S){
    int ans = 0;
    REP(i, K + 1) REP(j, K + 1) {
        int z = S - i - j;
        if (z >= 0 && z <= K) ans++;
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(K, S);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
	}
	vector<int> sum(N + 1);
	rep(i, 0, N) {
		sum[i + 1] = sum[i] + A[i];
		sum[i + 1] %= M;
	}
	map<int, int> c;
	rep(i, 0, N + 1) {
		c[sum[i]]++;
	}
	int ans = 0;
	for (auto p : c) {
		int k = p.second;
		ans += k * (k - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using vi = vector<int>;

int main(void)
{
    int n, m, xi, yi;
    vi  red, cnt;
    cin >> n >> m;

    cnt.resize(n, 1), red.resize(n, false);
    red[0] = true;

    for (int i = 0; i < m; ++i)
    {
        cin >> xi >> yi, xi--, yi--;

        red[yi] |= red[xi];

        if (cnt[xi] == 1)
            red[xi] = false;
        cnt[xi] -= 1;
        cnt[yi] += 1;
    }

    cout << accumulate(red.begin(), red.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005,inf=0x3f3f3f3f;
int n,js,a[N],s[N],c[N];LL res,num;
void msort(int l,int r) {
	int mid=(l+r)>>1;
	for(RI k=l,i=l,j=mid+1;k<=r;++k)
		if(j>r||(i<=mid&&s[i]<=s[j])) c[k]=s[i++];
		else c[k]=s[j++];
	for(RI k=l;k<=r;++k) s[k]=c[k];
}
void work(int l,int r) {
	if(l==r) return;
	int mid=(l+r)>>1;
	work(l,mid),work(mid+1,r);
	for(RI i=l,j=mid+1;j<=r;++j) {
		while(i<=mid&&s[i]<=s[j]) ++i;
		res+=i-l;
	}
	msort(l,r);
}
int check(int x) {
	for(RI i=1;i<=n;++i) s[i]=s[i-1]+(a[i]>=x?1:-1);
	res=0,work(0,n);
	return res>=(num+1)/2;
}
int main()
{
	//freopen("median.in","r",stdin);
	//freopen("median.out","w",stdout);
	int l=inf,r=0,ans;
	n=read();num=1LL*n*(n-1)/2+n;
	for(RI i=1;i<=n;++i)
		a[i]=read(),l=min(a[i],l),r=max(a[i],r);
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

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


int main() 
{
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;
    if (A1+A2+A3 >= 22) {
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

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

main(){
    string r, a;
    while(1){
	cin >> r >> a;
	if ( a == "0" ) break;
	int hit = 0, blow = 0;
	for ( int i = 0; i < 4; i++ ){
	    for ( int j = 0; j < 4; j++ ){
		if ( r[i] != a[j] ) continue;
		if ( i == j ) hit++;
		else blow++;
	    }
	}
	cout << hit << " " << blow << endl;
    }
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std;
int main() {
  int r, d, x;
  cin >> r >> d >> x;
  int xp = (r * x) - d;
  for (int i = 0; i < 10; i++) {
    cout << xp << endl;
    xp = (r * xp) - d;
  }
}


Measured memory_bytes: 256
void main()
{
    string s = rdStr;

    string t;
    foreach (x; s)
    {
        if (x == 'B')
        {
            if (t.length) t = t[0..$-1];
        }
        else
        {
            t ~= x;
        }
    }

    t.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

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

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public String[] inputMountain = new String[10];
	public int[] mountain = new int[10];
	
	public static void main(String args[])throws IOException{
		int i;
		Main app = new Main();
		
		app.input();
		app.stringToInteger();
		app.sortMountain();
		app.output();
	}
	
	public void input()throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		int i;
		for(i=0;i<10;i++)
			inputMountain[i] = br.readLine();
	}
	
	public void stringToInteger(){
		int i;
		for(i=0;i<10;i++)
			mountain[i] = Integer.parseInt(inputMountain[i]);
	}
	
	public void sortMountain(){
		int i,j,t;
		
		for(i=0;i<9;i++){
			for(j=9;j>i;j--){
				if(mountain[j]<mountain[j-1]){
					t = mountain[j];
					mountain[j] = mountain[j-1];
					mountain[j-1] = t;
				}
			}
		}
	}
	
	public void output(){
		int i;
		for(i=9;i>6;i--)
			System.out.println(mountain[i]);
	}
}

Measured memory_bytes: 17028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[50][3010];
const int mod=100000;
int main(){
	while(true){
		int n,m,s;	cin>>n>>m>>s;
		if(n==0)	return 0;
		int a=n*n;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=1;i<=a;i++){
			for(int j=0;j<=s;j++){
				if(j-(a-i+1)>=0){
					(dp[i][j]+=dp[i-1][j-(a-i+1)])%=mod;
					(dp[i][j]+=dp[i][j-(a-i+1)])%=mod;
				}
				if(j>m)	(dp[i][j]+=mod-dp[i-1][j-m-1])%=mod;
			}	
		}
		cout<<dp[a][s]<<endl;
	}
}

Measured memory_bytes: 1756
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
string X = "";
int daytoBeg = 0;
ll cnt = 0;

int main() {
	cin >> X;
	if(X == "SUN") {
		printf("7\n");
		return 0;
	}
	for(int i = 0; i < 7; i++) {
		if(X == S[i]) {
			daytoBeg = i;
		}
	}

	for(int i = daytoBeg; i < 7; i++) {
		if(S[i] == "SUN") {
			break;
		}
		cnt++;
	}
	printf("%lld\n", cnt);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 1e9 + 7; const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
const ll mx = 1e9;
const ll mmx = 1e18;
signed main() {
	ll x, y, s;
	cin >> s;
	if (s == mmx) {
		cout << 0 << " " << 0 << " " << 0 << " " << mx << " " << mx << " " << mx << endl;
		return 0;
	}
	cout << 0 << " " << 0 << " " << 1 << " " << mx << " ";
	ll a = s / mx;
	ll b = s % mx;
	cout << a + 1 << " " << mx - b << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
 
#define VMAX 100000
 
 
int main()
{
 
  int i, j, n, C[VMAX+1];
 
  scanf("%d", &n);
   
  short *A, *B;
 
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
 
 
  for(i = 1; i < n + 1; i++)
  	scanf("%hd",&A[i]);
   
  for(i = 0; i <= VMAX; i++)
  	C[i] = 0;
   
  for(j = 1; j <= n; j++)
  	C[A[j]]++;
 
  for(i = 1; i <= VMAX; i++)
  	C[i] = C[i] + C[i-1];
 
  for(j = 1; j <= n; j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
 
   
  for(i = 1; i < n; i++)
  	printf("%hd ", B[i]);
  printf("%d\n", B[n]);
  return 0;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int w, d;
    cin >> w >> d;
    if (w == 0 && d == 0){
      break;
    }
    vector<int> h(w);
    for (int i = 0; i < w; i++){
      cin >> h[i];
    }
    vector<int> h2(d);
    for (int i = 0; i < d; i++){
      cin >> h2[i];
    }
    vector<int> cnt1(21, 0);
    for (int i = 0; i < w; i++){
      cnt1[h[i]]++;
    }
    vector<int> cnt2(21, 0);
    for (int i = 0; i < d; i++){
      cnt2[h2[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= 20; i++){
      ans += i * max(cnt1[i], cnt2[i]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
  // freopen("input.txt","r",stdin);
    long long int n1,m1,t;
 //   cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=1,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m,l=0,r=0,k,min1=10000000000000,max2=-100;
 cin>>n>>m>>k;
 long long int a[m];
 for(i=0;i<m;i++)
 cin>>a[i];
 sort(a,a+m);
 for(i=0;i<m;i++)
 if(a[i]>k)
 break;
 if(i==0&&i==n)
 cout<<0;
 else
 {
 	p=i;
 	l=i;
 	for(i=k-1;i>=0;i--)
 	{
 		if(p-1>=0&&i==a[p-1])
 		{
 			c=c+1;
 			p--;
		 }
 		
	 }
	 min1=min(min1,c);
	 c=0;
	 for(i=k+1;i<=n;i++)
	 {
	 	if(l<m&&i==a[l])
	 	{
	 		c=c+1;
	 		l++;
		 }
	 	
	 }
	 min1=min(min1,c);
 
 cout<<min1;
 }
 
 //vector<pair<long long int,long long int>>v;
 
    }
 return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	if(x>=400 && x<=599)
		cout<<8;
	if(x>=600 && x<=799)
		cout<<7;
	if(x>=800 && x<=999)
		cout<<6;
	if(x>=1000 && x<=1199)
		cout<<5;
	if(x>=1200 && x<=1399)
		cout<<4;
	if(x>=1400 && x<=1599)
		cout<<3;
	if(x>=1600 && x<=1799)
		cout<<2;
	else if(x>=1800 && x<=1999)
		cout<<1;


    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int dp[100001];

int solve(int n,vector<int>v)
{
  dp[0] = 0;
  dp[1] = abs(v[1]-v[0]);
  for(int i=2;i<=n;i++)
  {
    dp[i] = min((dp[i-1]+abs(v[i]-v[i-1])),(dp[i-2]+abs(v[i]-v[i-2])));
  }
  return dp[n-1];
}
int main()
{
  int n;
  cin>>n;
  vector<int>v;
  int x;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  memset(dp,-1,sizeof(dp));
  int ans = solve(n,v);
  cout<<ans;
}


Measured memory_bytes: 1528
#define M 100
char m[M][M],s[M][M][M],r[M],*z;
cmp(char *p,char *q){
  int r=0;
  for(;*p=='0';p++);
  for(;*q=='0';q++);
  if(r=strlen(p)-strlen(q))return r;
  return strcmp(p,q);
}
main(w,h,i,j,k,l){
	for(;scanf("%d%d",&w,&h),w;puts(z)){
		memset(m,0xff,sizeof(m));
		memset(s,0,sizeof(s));
		memset(r,0,sizeof(r));
		for(j=1;j<=h;j++)scanf("%s",m[j]+1);
		for(i=1;i<=w+1;i++)for(j=1;j<=h;j++)if(!isdigit(m[j][i]))m[j][i]=-1;
		for(i=1;i<=w;i++)
			for(j=1;j<=h;j++){
				if(m[j][i]==-1)continue;
				if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
				else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
				if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
			}
		for(z=r;*z=='0';z++);
	}
return 0;}

Measured memory_bytes: 0
n,m=[int(j) for j in input().split()]
x=[int(j) for j in input().split()]
y=[int(j) for j in input().split()]
mod=10**9+7
sx=0
sy=0
for i in range(n):
    sx+=(2*i-n+1)*x[i]
    sx=sx%mod
for i in range(m):
    sy+=(2*i-m+1)*y[i]
    sy=sy%mod

print((sx*sy)%mod)





Measured memory_bytes: 19452
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var sum1 = 0;
        var sum2 = ary.Sum();

        var min = int.MaxValue;

        for(int i=0; i<n; i++) {
            sum1 += ary[i];
            sum2 -= ary[i];
            min = Math.Min(min, Math.Abs(sum1-sum2));
        }

        return min;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268