akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        long[] ans=new long[N];
	        long sum =0;
	        for (int i=0 ; i<N-1; i++) {
	            a[i] = Long.parseLong(sc.next());
	            ans[(int)a[i]-1]++;
	        }
	        
	        for(int i=0;i<N;i++) {
	        	System.out.println(ans[i]);
	        }
	        
	 }

}

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


public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[M];
        String[] S = new String[M];
        for(int i=0;i<M;i++){
            p[i] = sc.nextInt();
            S[i] = sc.next();
        }
        boolean[] ac = new boolean[N];
        int solved = 0;
        int wa[] = new int[N];
        int wrong = 0;
        for(int i=0;i<M;i++){
            if(S[i].equals("AC")){
                if(!ac[p[i]-1]){
                    ac[p[i]-1] = true;
                    solved++;
                }
            }
            else{
                if(!ac[p[i]-1]){
                    wa[p[i]-1]++;
                }
            }
        }
        for(int i=0;i<N;i++){
            if(ac[i]){
                wrong += wa[i];
            }
        }
        out.println(solved + " " + wrong);

        out.flush();
    }

        
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 37604
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk,dd;
   string s;
   cin>>s;
   for(i=0;i<s.size();i++)
   {
   	if(s[i]=='?')
   	s[i]='D';
   }
   cout<<s<<endl;

   
   	
} 

Measured memory_bytes: 3768
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(lli i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
int main(){ _
    string a;
    cin >> a;
    if(a.back()=='s')cout << a << 'e' << 's' <<ENDL;
    else cout << a << 's' <<ENDL;
    return 0;
}


Measured memory_bytes: 3664
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int c,d,x,flag=0,count=0,n,m,y,max=-1000,min=99999;
  vint a(10000,0);
  vint b(10000,0);
  cin>>n>>m>>x>>y;
  int z1=x+1;
  int z2=y;
  rep(i,n){
    cin>>a[i];
    if(max<a[i]){
      max=a[i];
    }
    if(a[i]>=z2){
      cout<<"War"<<'\n';
      return(0);
    }
  }
  rep(i,m){
    cin>>b[i];
    if(max>=b[i] || z1>=b[i]){
      cout<<"War"<<'\n';
      return(0);
    }
  }
  cout<<"No War"<<'\n';
  
  return(0);
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		int Q = scan.nextInt();

		StringBuilder sb = new StringBuilder(S);
		StringBuilder sentou = new StringBuilder("");

		//true そのまま false 反転
		boolean flg = true;

		for (int i = 0; i < Q; i++) {

			if (scan.nextInt() == 1) {
				flg = !flg;
			} else {

				if (scan.nextInt() == 1) {
					if (flg)
						sentou.append(scan.next());
					else
						sb.append(scan.next());
				} else {
					if (flg)
						sb.append(scan.next());
					else
						sentou.append(scan.next());
				}
			}

		}

		S = sb.toString();
		StringBuffer sentousb = new StringBuffer(sentou.toString());
		String sentoustr = sentousb.reverse().toString();

		S = sentoustr + S;

		if (!flg) {
			StringBuffer strb = new StringBuffer(S);
			S = strb.reverse().toString();
		}
		System.out.println(S);
	}

}


Measured memory_bytes: 113716
import sys
input  = sys.stdin.readline

N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

dp = [[0]*N for i in range(2)]
for i,a in enumerate(A1):
  if i==0:
    dp[0][i]=a
  else:
    dp[0][i]=dp[0][i-1]+a

for i,a in enumerate(A2):
  if i==0:
    dp[1][i]=dp[0][i]+a
  else:
    dp[1][i]=max(dp[0][i],dp[1][i-1])+a
print(dp[1][-1])

Measured memory_bytes: 38256
a = list(map(int, input().split()))
a.sort()
ans = a[2]-a[1]
a[0] += ans
if (a[2]-a[0])%2 == 0:
    print(ans+(a[2]-a[0])//2)
else:
    print(ans+(a[2]-a[0])//2+2)


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

using namespace std;
long long arr[1000000];
int main(void)
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    long long temp=0;
    long long q=arr[0];
    for(int i=1;i<=n-1;i++)
    {
        if(q*2<arr[i])
        temp=i;
        q=q+arr[i];
    }
    cout<<n-temp;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


ll int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

ll int h=pow(10,6);

int main(){
	fast;
	
	ll int n,m;
	cin>>n>>m;
	
	ll int cntw[n+1]={0},cntc[n+1]={0};
	map<int,string>mp1;
	
	forr(i,0,m){
		int x;
		cin>>x;
		
		string s;
		cin>>s;
		
		if(!mp1.count(x)){
			if(s=="WA"){
				cntw[x]++;
				mp1[x]=s;
			}
			
			else if(s=="AC"){
				cntc[x]++;
				mp1[x]=s;
			}
		}
		
		else if(mp1[x]=="WA"){
			if(s=="WA")
			cntw[x]++;
			
			else
			cntc[x]++;
			mp1[x]=s;
		}
		
		else if(mp1[x]=="AC"){
			continue;
		}
	}
	
	ll int answ=0,ansc=0;
	for(int i=1;i<=n;i++){
		if(cntc[i]==1){
			answ+=cntw[i];
			ansc++;
		}
	}
	
	cout<<ansc<<" "<<answ;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
 
typedef vector<int> vi;
map<vi,int> cnt;
vi normalize(vi vc){
	vi ret(4,1e9);
	rep(i,4){
		chmin(ret,vc);
		rotate(vc.begin(),vc.begin()+1,vc.end());
	}
	return ret;
}
int coef(vi vc){
	int ret=0;
	vi vco=vc;
	rep(i,4){
		if(vc==vco) ret++;
		rotate(vc.begin(),vc.begin()+1,vc.end());
	}
	return ret;
}
 
vi fs[500];
typedef long long ll;
int main(){
	int N;
	cin>>N;
	rep(i,N){
		vi vc(4);
		rep(j,4) cin>>vc[j];
		fs[i]=normalize(vc);
		cnt[fs[i]]++;
	}
	ll ans=0;
	rep(i,N) for(int j=i+1;j<N;j++){
		rep(dj,4){
			vi x=fs[i];
			vi y=fs[j];
			rotate(y.begin(),y.begin()+dj,y.end());
			map<vi,int> used;
			used[fs[i]]++;
			used[fs[j]]++;
			ll tmp=1;
			rep(d,4){
				vi vc={x[0],y[1],y[0],x[1]};
				vc=normalize(vc);
				if(!cnt.count(vc)) tmp=0;
				else{
					int c=coef(vc);
					tmp*=c*(cnt[vc]-used[vc]);
					used[vc]++;
				}
				rotate(x.begin(),x.begin()+1,x.end());
				rotate(y.begin(),y.begin()+3,y.end());
			}
			ans+=tmp;
		}
	}
	ans/=3;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://atcoder.jp/contests/abc145/submissions/15272310
int dp[2][3005][3005];
void solve() {
    int n, t;
    cin >> n >> t;
    
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    rep(l, 2) { 
        rep(i, n) for (int j = t; j >= 0; --j) { // debuged
            chmax(dp[l][i + 1][j], dp[l][i][j]);
            if (j - a[i] < 1) continue;
            chmax(dp[l][i + 1][j - a[i]], dp[l][i][j] + b[i]);
        }
        reverse(all(a));
        reverse(all(b));
    }
    
    /* dpの中で行われてる
    rep(l, 2) {
        rep(i, n) for (int j = t; j >= 1; --j) chmax(dp[l][i][j - 1], dp[l][i][j]);
    }
     */
    
    /*
    rep(l, 2) {
        rep(i, n + 1) { rep(j, t + 1) cerr << dp[l][i][j] << " "; cerr << endl; }
        cerr << endl;
    }
     */
    
    int ans = 0;
    // i=0, 0, n-1(i=0の分は入れてはいけない)
    // i=1, 1, n-2
    rep(i, n) rep(j, t) { // 使った時間
        int k = t - 1 - j;
        if (chmax(ans, dp[0][i][t - j] + b[i] + dp[1][n - i - 1][t - k])) {
            // cerr << i << " " << t - j << " " << t - k << " " << dp[0][i][t - j] << " " << dp[1][n - i][t - k] << endl;
        }
    }
    cout << ans << endl;
}


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


int main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    
    string T;
    for (int i=0; i<N; i++) {
        char a;
        cin >> a;
        T = T + a;
    }
    
    
    vector<string> G(K);
    
    for (int i=0; i<N; i++) {
        int a = i%K;
        G.at(a) = G.at(a) + T.at(i);
    }
    /*for (int i=0; i<G.at(0).size(); i++) {
        cout << G.at(0).at(i);
    }*/
    
    int cnt = 0;
    for (int i = 0; i<K; i++) {
        
        for (int j=0; j<G.at(i).size();j++) {
            
            if(j != G.at(i).size()-1){
            
            if (G.at(i).at(j)==G.at(i).at(j+1)) {
                if(G.at(i).at(j)=='r') cnt += P;
                if(G.at(i).at(j)=='s') cnt += R;
                if(G.at(i).at(j)=='p') cnt += S;
                
                j++;
            }
            else {
                if(G.at(i).at(j)=='r') cnt += P;
                if(G.at(i).at(j)=='s') cnt += R;
                if(G.at(i).at(j)=='p') cnt += S;
            }
                
            }
            else{
                if(G.at(i).at(j)=='r') cnt += P;
                if(G.at(i).at(j)=='s') cnt += R;
                if(G.at(i).at(j)=='p') cnt += S;
            }
        }
    }
    cout << cnt << endl;
    /*for (int i=0; i<N; i++) {
        cout << T.at(i);
    }*/
}


Measured memory_bytes: 5268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    for(ll i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    ll dp[n+1][W+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(j<w[i])
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][W];
}


Measured memory_bytes: 79104
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF 4e18
using namespace std;
 
typedef tree<ll, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        ll n,i,j,k,cnt=0,ans=0;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>j>>k;
            if(j==k)cnt++;
            else cnt=0;
            ans=max(ans,cnt);
        }
        (ans>=3)?cout<<"Yes\n":cout<<"No\n";
        /*tcitr++;
    }*/
    return 0;
}

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

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

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

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

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


int main(){
    COMinit();
    ll n, m;
    cin >> n >> m;
    auto d = prime_factorize(m);
    
    ll ans = 1;
    for(int i=0; i<d.size(); i++){
        int bi = d[i].second;
        ans *= COM(bi + n - 1, n - 1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12160
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      q: usize,
      stxs: [(i64,i64,i64);n],
      ds: [i64; q]
    }
    let mut ts = vec![];
    for &(s, t, x) in stxs.iter() {
        let l = s-x;
        let r = t-x;
        ts.push((l, 1, x, 0));
        ts.push((r, 0, x, 0));
    }
    for i in 0..q {
        ts.push((ds[i], 2, 0, i));
    }
    ts.sort();
    use std::collections::BTreeSet;
    let mut set = BTreeSet::new();

    let mut ans = vec![0; q];
    for (_, m, x, q) in ts.into_iter() {
        match m {
            0 => {
                set.remove(&x);
            },
            1 => {
                set.insert(x);
            },
            2 => {
                ans[q] = match set.iter().next() {
                    None => -1,
                    Some(&x) => x,
                }
            },
            _ => unreachable!()
        }
    }
    for i in 0..q {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 44148
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=1e6+10;
const int mod=1e9+7;
using namespace std;

void solve(){
    ll n,a,b; cin>>n>>a>>b;
    if(abs(b-a)%2==0) {printf("%lld\n",abs(b-a)/2); return;}
    if(a>b) swap(a,b);
    ll ans=min(b-1, n-a);
    ll an=min(a-1+(b-a+1+1)/2,n-b+(n-(a+n-b)+1)/2);
    printf("%lld\n",min(an,ans)); 
}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
    return 0;
}
/*
*/
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[F = X -> bool] 値 X を評価する関数
// lower:[bool] false にすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X, typename F>
X BinSearch(X l, X r, F judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

struct Point {
    double x, y;
};

struct Data {
    Point p;
    double c;
};

pair<Point, Point> cross_points_of_circles(Point v1, double r1, Point v2, double r2) {
    bool swap_flag = false;
    if(v1.x == v2.x) {
        swap(v1.x, v1.y), swap(v2.x, v2.y);
        swap_flag = true;
    }
    double l1 = v1.x * v1.x + v1.y * v1.y, l2 = v2.x * v2.x + v2.y * v2.y;
    double p = (l1 - l2 - r1 * r1 + r2 * r2) / (2 * (v1.x - v2.x));
    double q = -(v1.y - v2.y) / (v1.x - v2.x);
    // x = p + qy
    double s = 2 * ( (p - v1.x) * q - v1.y) / (1 + q * q);
    double t =((p - v1.x) * (p - v1.x) + v1.y * v1.y - r1 * r1) / (1 + q * q);
    // y^2 + sy + t = 0
    Point p1 = {0, 0}, p2 = {0, 0};
    double d = max(0.0, s * s - 4 * t);
    p1.y = (-s + sqrt(d)) / 2;
    p2.y = (-s - sqrt(d)) / 2;
    p1.x = p + q * p1.y;
    p2.x = p + q * p2.y;
    if(swap_flag) {
        swap(p1.x, p1.y), swap(p2.x, p2.y);
    }
    return make_pair(p1, p2);
}


int main() {
    const double MAX_T = 1e7;
    int N, K;
    cin >> N >> K;
    vector<Data> data(N);
    for(Data &d : data) {
        cin >> d.p.x >> d.p.y >> d.c;
    }
    auto judge = [&](Point p, double T) -> int {
        int k = 0;
        for(int i = 0; i < N; i++) {
            if(data[i].c * hypot(data[i].p.x - p.x, data[i].p.y - p.y) <= T + 1e-6) {
                k++;
            }
        }
        return k;
    };
    double ans = BinSearch(0.0, MAX_T, [&](double T) -> bool {
        // 時間t以内にK枚以上焼けるかどうか

        Point p1, p2;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                // 交点を取得
                tie(p1, p2) = cross_points_of_circles(
                    data[i].p, T / data[i].c,
                    data[j].p, T / data[j].c
                );
                for(int b = 0; b < 2; b++) {
                    if(judge(p1, T) >= K) return true;
                    swap(p1, p2);
                }
            }
        }
        for(int i = 0; i < N; i++) {
            if(judge(data[i].p, T) >= K) return true;
        }
        return false;
    }, true, 1e-8);
    cout << fixprec(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll n,flag=1;cin>>n;
 	ll h[n];rep(i,0,n) cin>>h[i];
 	rep(i,1,n)
 	{
 	  if(h[i]>=h[i-1]+1) h[i]--;	
	}
	rep(i,0,n-1)
	{
		if(h[i]>h[i+1]) 
		{
			flag=0;break;
		}
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	 
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int a=in(),b=in(),c=in();
    long long k=llin();
    print((a-b)*pow(-1,k%2));
    return 0;
}

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

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> b(n);
    int maxa = 0;
    for (int i=0; i<n; i++) {
        int x, y;
        cin >> x >> y;
        maxa = max(maxa, x);
        b[i] = y;
    }
    int cnt = 0;
    int sumb = 0;
    sort(b.begin(), b.end(), greater<int>());
    for (int i=0; i<n; i++) {
        if (sumb >= h) {
            cout << cnt << endl;
            return 0;
        }
        if (maxa >= b[i]) {
            break;
        }
        sumb += b[i];
        cnt++;
    }
    h -= sumb;
    cnt += (h + maxa -1) / maxa;
    cout << cnt << endl;
}

Measured memory_bytes: 768
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {

int H,W,K;
cin>>H>>W>>K;
char table[H][W];
rep(i,H){
  rep(j,W){
    cin>>table[i][j];
  }
}
int count_m=0;
rep(i,1<<H){
  rep(j,1<<W){
    char table_cp[H][W];
    rep(k,H){
      rep(l,W){
        table_cp[k][l]=table[k][l];
      }
    }
    rep(k,H){
      if((i>>k)&1){
        rep(l,W){
          table_cp[k][l]=':';
        }
      }
      
    }
    rep(k,W){
      if((j>>k)&1){
        rep(l,H){
          table_cp[l][k]=':';
        }
      }
    }
    int count=0;
    rep(k,H){
      rep(l,W){
        if(table_cp[k][l]=='#'){
          count++;
        }
      }
    }
    if(count==K){
      count_m++;
    }
  }
}
cout<<count_m<<endl;
return 0;
}

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

ll gcd(ll a, ll b){
    if (b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    ll G = gcd(N, M);
    bool check = true;
    for (int i = 0; i < G; i++) {
        if (S[N/G*i] != T[M/G*i]) check = false;
    }
    if (check) cout << N*M/G << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main(){
	long long int N,W;
	cin >> N >> W;
	long long int w[N]; 
  	long long int v[N];
	for(int i=0;i<N;i++){
      	cin >> w[i] >> v[i];
	}  
  	long long int a[100001];
  	a[0]=0;
  	for(int i=1;i < 100001;i++){
      	a[i] = 100000000000000;
	}  
  	for(int i=0;i < N;i++){
        for(int j=100000;j>=v[i];j--){
          	a[j] = min(a[j-v[i]] + w[i], a[j]);
        }  
	} 
  	long long int c = 0;
  	for(int i=0;i < 100001;i++){
      	if(a[i] <= W){
          c = i;
        }
	}  
  	cout << c << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll dp[200005];
ll cumsum[200005];
#define mod 998244353
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n >> k;
    vector<pair<ll, ll>> segments;
    for (i = 1; i <= k;i++){
        ll u, v;
        cin >> u >> v;
        segments.pb({u, v});
    }
    sort(segments.begin(), segments.end());
    dp[n] = 1;
    cumsum[n] = 1;
    for (i = n - 1; i >= 1;i--){
        ll ans = 0;
        for(auto x:segments){
            ans = (ans + (cumsum[min(n + 1, x.first + i)] - cumsum[min(n + 1, x.second + i + 1)] + mod) % mod) % mod;
        }
        dp[i] = ans;
        cumsum[i] = (cumsum[i + 1] + dp[i]) % mod;
    }
    cout << dp[1] << "\n";
    return 0;
}

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



// Inserted snippets: io, opt, root
#pragma gcc optimize("Ofast")
#pragma gcc target("native")
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int a, b; read(a, b);
	write(a * b);
}


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


int main(void){

  int n;
  double x[4], y[4];
  double ab[2], cd[2];

  
  scanf("%d", &n);
  while(n>0){
    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]);

    ab[0]=x[1]-x[0];
    ab[1]=y[1]-y[0];

    cd[0]=x[3]-x[2];
    cd[1]=y[3]-y[2];


    if(fabs(ab[0]*cd[1]-ab[1]*cd[0])<1e-10){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    

    n--;
  }

  return(0);
}



Measured memory_bytes: 2044
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {

  class UnionFind(n: Int) {
    private val parents: ArrayBuffer[Int] = new ArrayBuffer[Int]
    private val counts: ArrayBuffer[Int] = new ArrayBuffer[Int] // rootに対しては正しい結果を保持している
    for (i <- 0 until n) {
      parents.append(i)
      counts.append(1)
    }

    def root(x: Int): Int = {
      if (parents(x) == x) x
      else {
        parents(x) = root(parents(x))
        parents(x)
      }
    }

    def sameCount(x: Int): Int = counts(root(x))

    def same(x: Int, y: Int): Boolean = root(x) == root(y)


    def unite(x: Int, y: Int): Unit = {
      if (!same(x, y)) {
        val rx = root(x)
        val ry = root(y)
        counts(ry) = counts(rx) + counts(ry)
        parents(rx) = ry
      }
    }

  }

  // A番目の島とB番目の島をつないだ橋
  case class Bridge(a: Int, b: Int)

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val bridges = for (i <- 0 until m) yield {
      // 0-originにする
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      Bridge(a, b)
    }
    (n, m, bridges)
  }

  def solve(n: Int, m: Int, bridges: IndexedSeq[Bridge]): IndexedSeq[Long] = {
    val reverseBridges = bridges.reverse
    val uf = new UnionFind(n)
    val numConnectedPairsDiff = for (bridge <- reverseBridges) yield {
      val diff =
        if (uf.same(bridge.a, bridge.b)) 0.toLong
        else uf.sameCount(bridge.a).toLong * uf.sameCount(bridge.b).toLong
      uf.unite(bridge.a, bridge.b)
      diff
    }
    val numConnectedPairs = numConnectedPairsDiff.scanLeft(0.toLong)(_ + _)
    numConnectedPairs.reverse.tail.map(x => n.toLong * (n.toLong - 1.toLong) / 2.toLong - x)
  }

  def output(result: IndexedSeq[Long]) = {
    for (elem <- result) {
      println(elem)
    }

  }

  def main(args: Array[String]): Unit = {
    val (n, m, bridges) = read()
    val result = solve(n, m, bridges)
    output(result)
  }
}

Measured memory_bytes: 95924
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5;
int n,tot;
int head[maxn],des[maxn<<1],nxt[maxn<<1];
int S[maxn],id[maxn];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
void dfs(int x,int fa){
	int sum=0,common=0;
	Rep(p,x)if(des[p]!=fa){
		dfs(des[p],x);
		common|=S[des[p]]&sum;
		sum|=S[des[p]];
	}
	int k=0;
	for(;(common>>k)||(sum>>k&1);k++);
	id[x]=k;
	S[x]=((sum>>k)|1)<<k;
}
int main(){
	read(n);
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		adde(x,y);adde(y,x);
	}
	dfs(1,0);
	sort(id+1,id+n+1);
	printf("%d\n",id[n]);
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

vector<ll> a;

int f(ll x){
    if(to_string(x).length() > 9) return 0;
    a.emplace_back(10*x+3);
    f(10*x+3);
    a.emplace_back(10*x+5);
    f(10*x+5);
    a.emplace_back(10*x+7);
    f(10*x+7);
    return 0;
}

int main() {
    int n;
    cin >> n;
    f(0);
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, a.size()){
        if(a[i] > n) break;
        string s = to_string(a[i]);
        bool b[3] = {};
        rep(j, s.length()){
            if(s[j] == '3') b[0] = true;
            else if(s[j] == '5') b[1] = true;
            else if(s[j] == '7') b[2] = true;
        }
        bool flag = true;
        rep(k, 3){
            if(!b[k]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d",n%m==0?n/m:n/m+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x; cin >> x;
    
    for(int i=1; ; i++){
        if(i*(i+1)/2>=x){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

int main()
{
    int n;
    cin >> n;
    string str1, str2;
    cin >> str1;
    cin >> str2;
    string fstr="";
    for(int i=0; i<n; i++)
    {
        fstr += str1[i];
        fstr += str2[i];
    }
    cout << fstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;


int solve(multiset<int> a, multiset<int> b){
  int aod = 0, bod = 0;
  for(auto aa: a) {
    //cout <<"a" <<  aa ;
    if(aa % 2 == 1) aod++;
  }
  for(auto bb: b){
    //cout <<"b" <<  bb;
    if(bb % 2 == 1) bod++;
  }
//  cout <<endl;

  if(aod > bod){
    swap(aod, bod); swap(a, b);
  }
  //aod <= bod

  int bipaired = aod;

  multiset<int> ca, cb, ccb;
  for(auto aa : a){
    ca.insert(aa/2*2);
  }

  int suma = 0;
  for(auto aa: ca){
    suma += aa;
  }//cout << endl;

  int tmpb = bipaired;
  //cout <<"B"; for(auto bb:b)cout <<bb <<","; cout << endl;
  for(auto& bb : b){
    if(tmpb > 0 && bb%2==1) {
      cb.insert(bb-1);
      tmpb--;
    }else{
      cb.insert(bb);
    }
  }
  //cout <<"CB"; for(auto bb:cb)cout <<bb <<","; cout << endl;

  int bpar = 0;
  //cout << suma << endl;
  for(auto& bb : cb){
    if(suma > 0 && bb%2==1) {
      ccb.insert(bb-1);
      suma--;
      bpar ++;
    }else{
      ccb.insert(bb);
    }
  }

  //cout <<"CCB"; for(auto bb:ccb)cout <<bb <<","; cout << endl;

  int res = 0;
  for(auto bb: ccb){
    res += bb / 2;
  }

  //cout << bipaired << "," << suma << "B" << bpar << endl;
  //cout << "R" << res << endl;

  return bipaired + (suma / 2) + res + bpar;
}
/*
signed main(){
  int n, m; cin >> n >> m;
  multiset<int> a, b;
  rep(i,n) {int aa; cin >> aa; a.insert(aa);}
  rep(i,m) {int bb; cin >> bb; b.insert(bb);}
  cout << "RES" << solve(a, b) << endl;
  return 0;
}
*/
signed main(){
  int n, m; cin >> n >> m;
  vector<int> x(n);
  vector<map<int,int>> mods(m, map<int,int>());

  rep(i, n){
    int xx; cin >> xx;
    x[i] = xx;
    auto& mm = mods[xx%m];
    if(mm.count(xx) == 0){
      mm[xx] = 1;
    }else{
      mm[xx]++;
    }
  }
  vector<multiset<int>> modn(m, multiset<int>());
  rep(i, m){
    for(auto kv : mods[i]){
      int num, cnt; tie(num, cnt) = kv;
      modn[i].insert(cnt);
    }
  }
  int res = 0;
  {
    int ss = 0;
    for(auto aa: modn[0]) ss += aa;
    res += ss/2;
  }
  if(m % 2 == 0){
    int ss = 0;
    for(auto aa: modn[m/2]) ss += aa;
    res += ss/2;
  }

  //cout << "PRE" << res << endl;

  rep(i, (m - 1) / 2){
    res += solve(modn[i + 1], modn[m - i - 1]);
  }
  cout << res << endl;
}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,m,i,j,a[100005],x,y;
int read(){
	char ch=getchar();
	int xx=0;
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx;
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1);
	if(a[n]-a[1]>=2){
		printf("No\n");
	}
	else if(a[n]-a[1]==1){
		for(i=1;i<n;i++)
			if(a[i]!=a[i+1]){
				x=i;
				break;
			}
		y=n-x;
		if(x+1<=a[n]&&a[n]<=x+y/2)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else{
		if(a[1]==n-1||a[1]<=n/2)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int nums[N];
    for(int i = 0; i < N; i++){
        cin >> nums[i];
    }
    sort(nums, nums + N);
    int ans = 0;
    int serial = 1;
    for(int i = 1; i < N; i++){
        if(nums[i] == nums[i - 1]){
            serial++;
        }else{
            if(serial >= nums[i - 1]){
                ans += serial - nums[i - 1];
            }else{
                ans += serial;
            }
            serial = 1;
        }
    }
    if(serial >= nums[N - 1]){
        ans += serial - nums[N - 1];
    }else{
        ans += serial;
    }
    cout << ans << endl;
}


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

int main(){
  vector<int> a(5);
  for(int i=0; i<5; i++) cin >> a.at(i);
  int k;
  cin >> k;
  for(int i=0; i<5; i++){
    for(int j=0; j<5; j++){
      if(a.at(i)-a.at(j)>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A == 1 && B == 2){
        printf("%d",3);
    }
    if(A == 1 && B == 3){
        printf("%d",2);
    }
    if(A == 2 && B == 1){
        printf("%d",3);
    }
    if(A == 2 && B == 3){
        printf("%d",1);
    }
    if(A == 3 && B == 1){
        printf("%d",2);
    }
    if(A == 3 && B == 2){
        printf("%d",1);
    }
}

Measured memory_bytes: 1728
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
total = []
curtotal = sum(arr)
total.append(curtotal)
for i in range(n):
    curtotal -= arr[i]
    total.append(curtotal)
for i in range(n):
    total[i] = total[i] % 1000000007

for i in range(n - 1):
    curnum = arr[i]
    tempans = curnum * total[i + 1]
    if tempans >= 1000000007:
        tempans = tempans % 1000000007
    ans += tempans

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Measured memory_bytes: 108680
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin >> N;
 vector<int>P(N);
 for (int i = 0; i < N; i++)
 {
    cin >> P.at(i);
 }
 int count=0;
 int minmam=10000000;
 for (int i = 0; i < N; i++){
    minmam=min(minmam,P.at(i));
    if(P.at(i)<=minmam){
        count++;
        
    }
 }
 cout << count << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=4e5+5;

int main()
{
	string s;
	cin>>s;
	if(sz(s)&1){
		cout<<"No\n";
		return 0;
	}
	for(int i = 0;i<sz(s); i += 2){
		if(s[i] =='h' && s[i + 1] == 'i')continue;
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	return 0;
}



Measured memory_bytes: 256