akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
 ll n ;
 cin >> n;
 ll res = n *(n-1 ) /2;
 cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,flag;
    double sum,t;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%lf",&t);
        sum=0;
        flag=0;
        for(i=0; i<n; ++i)
        {
            sum+=500;
            if(sum>=t)
            {
                flag=1;

                break;
            }
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(M * 2);
  
  for (int i = 0;i < M * 2;i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0;i < N;i++) {
    int x = 0;
    for (int j = 0;j < M * 2;j++) {
      if (vec.at(j) == i + 1) {
        x++;
      }
    }
    
    cout << x << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
ans=0
mod=int((1e+9)+7)
def cmb(n,r):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g[n]*gg[r]*gg[n-r]%mod
g=[1,1]
gg=[1,1] 
inv=[0,1] 
for i in range(2,n+1):
  g.append((g[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  gg.append((gg[-1]*inv[-1])%mod)

for i in range(n//3):
  x=n-(3*(i+1))
  ans+=cmb(x+i,i)

  ans%=mod
  
print(ans)
  

Measured memory_bytes: 9360
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
#define INF (1 << 29)
bool prime(int x){
  if(x == 1)return false;
  for(int i = 2;i * i <= x;i++){
    if(x % i == 0)return false;
  }
  return true;
}

class E{
public:
  int to, lim, inv;
  E(int a, int b, int c){
    to = a;
    lim = b;
    inv = c;
  }
};

vector<E> edge[300];
int n, x;
map<int, int> cnt;
vector<int> odd, even;

void add_edge(int u, int v, int f){
  edge[u].push_back(E(v, f, edge[v].size()));
  edge[v].push_back(E(u, 0, edge[u].size() - 1));
}


bool come[300];
int flow(int s, int t, int f){
  if(come[s])return 0;
  come[s] = true;
  if(s == t)return f;
  for(int i = 0;i < edge[s].size();i++){
    E &e = edge[s][i];
    if(e.lim == 0)continue;
    int tmp = flow(e.to, t, min(f, e.lim));
    if(tmp == 0)continue;
    e.lim -= tmp;
    edge[e.to][e.inv].lim += tmp;
    return tmp;
  }
  return 0;
}

int max_flow(int s, int t){
  int res = 0;
  while(true){
    for(int i = 0;i < 300;i++)come[i] = false;
    int tmp = flow(s, t, INF);
    if(tmp == 0)return res;
    res += tmp;
  }
}


int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> x;
    cnt[x]^=1;
    cnt[x-1]^=1;
  }
  map<int, int>::iterator it;
  for(it = cnt.begin();it != cnt.end();it++){
    if(it->second == 0)continue;
    x = it->first;
    if(x % 2 == 0)even.push_back(x);
    if(x % 2 == 1)odd.push_back(x);
  }
  int s = even.size() + odd.size() + 1;
  int t = s + 1;
  for(int i = 0;i < even.size();i++)add_edge(s, i, 1);
  for(int i = 0;i < odd.size();i++)add_edge(even.size() + i, t, 1);
  
  for(int i = 0;i < even.size();i++){
    for(int j = 0;j < odd.size();j++){
      int dif = abs(even[i] - odd[j]);
      if(prime(dif))add_edge(i, even.size() + j, 1);
    }
  }

  int mxf = max_flow(s, t);
  cout << mxf + (even.size() - mxf) / 2 * 2 + (odd.size() - mxf) / 2 * 2 + (even.size() - mxf) % 2 * 3 << endl;
  return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <stdio.h>
#include <sstream>
#include <cstdlib>


using namespace std;

int n, m;
int s[10][10];
vector<int> p;
vector<int> k;
map<string, int> state;
int ans = 0;

void subBin(string str, int l)
{
    if (l == 0){
        int ok = 1;
        // cout << str << endl;
        for(int i = 0; i < m; i++){
            int v = 0;
            for(int j = 0; j < k[i]; j++){
                
                string substr = str.substr(s[i][j]-1, 1);
                // cout << substr << endl;
                // int v = atoi(substr.c_str());

                // sscanf(c, "%d", &v);
                // cout << v << " " << p[i] << endl;
                if(substr == "1"){
                    v++;
                }
            }
            if(v % 2 != p[i]){
                ok = 0;
                break;
            }
        }
        if(ok){
            ans++;
        }
    }
    if (l > 0) {
        subBin(str + "0", l - 1);
        subBin(str + "1", l - 1);
    }
}

int main(void){
    string str = "";

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int q;
        cin >> q;
        k.push_back(q);
        for(int j = 0; j < q; j++){
            cin >> s[i][j];
        }
    }
    
    for(int i = 0; i < m; i++){
        int q;
        cin >> q;
        p.push_back(q);
    }

    /*

    for(int i = 0; i < m; i++){
        cout << k[i] << " ";
        for(int j = 0; j < k[i]; j++){
            cout << s[i][j] << " ";
        }
        cout << endl;
    }

    for(int i = 0; i < m; i++){
        cout << p[i] << " ";
    }
    */

    subBin(str, n);

    // int ans = 0;
    /*
    for(int i = 0; i < m; i++){
        for(int j = 0; j < k[i]; j++){
            cout << s[i][j] << " ";
        }
    }
    */

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
X,Y = map(int, input().split())

ans = 0

#つるをi

for i in range(Y):
  for j in range(Y):
      if 2*i + 4*j == Y and i + j == X:
          ans +=1
        
    
if ans > 0:
  print('Yes') 
else:
  print('No')

Measured memory_bytes: 9176
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return string(str)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

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

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	defer out.Flush()
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	sunuke := make(map[int]bool, n)
	for i := 1; i <= n; i++ {
		sunuke[i] = false
	}
	for i := 0; i < k; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			a := nextInt()
			sunuke[a] = true
		}
	}
	count := 0
	for _, v := range sunuke {
		if !v {
			count++
		}
	}
	fmt.Fprintln(out, count)

}


Measured memory_bytes: 1764
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define Mod 1000000007
using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    // return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}
vector<ll> value, weight;
vector<vector<ll> > dp;
ll n,w, ans, V_Max;
ll solve(int index, ll c)
{
	if(c<=0)
		return 0;
	if(index==n)
		return (ll)1e9;

	if(dp[index][c]!=-1)
		return dp[index][c];
	
	dp[index][c]=min(solve(index+1,c),weight[index]+solve(index+1,c-value[index]));
	
	return dp[index][c];
}

ll getMax()
{
	for(int i=V_Max; i>=0; i--)
	{
		// cout<<solve(0,i)<<" "<<w<<endl;
		if(solve(0,i)<=w)
			return i;
	}
}

int main()	
{
	#ifdef SANS
		freopen("ongoingin.txt","r",stdin);
		freopen("ongoingout.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		cin>>n>>w;
		dp.resize(n);
		weight.resize(n);
		value.resize(n);
		V_Max=0;
		for(int i=0; i<n; i++)
		{
			cin>>weight[i]>>value[i];
			V_Max+=value[i];
		}
		for(int i=0; i<n; i++)
			dp[i].resize(V_Max+1,-1);
		cout<<getMax()<<endl;
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

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

typedef long long ll;
typedef long double ld;

int mat[1005][1005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m, k;
    cin >> n >> m >> k;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        for(int j=0; j<m; j++){
            if(s[j] == '#') mat[i][j] = 1;
        }
    }
    ll res = 0;
    for(int mask1=0; mask1<(1<<n); mask1++){
        for(int mask2=0; mask2<(1<<m); mask2++){
            ll tren = 0;
            for(int i=0; i<n; i++){
                for(int j=0; j<m; j++){
                    if((1<<i) & mask1) continue;
                    if((1<<j) & mask2) continue;
                    tren += mat[i][j];
                }
            }
            res += (tren == k);
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())

g = {}
n_path = 0
for i in range(N):
    g[i] = []
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)


def advance(v, passed):

    global n_path
    passed.append(v)
    if len(passed) == N:
        n_path += 1

    for n in g[v]:
        if n not in passed:
            advance(n, passed)

    passed.remove(v)


advance(0, [])
print(n_path)


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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  int A, B, K;
  cin >> A >> B >> K;

  int R = A % B;
  vector<int> result_queue;
  for (int i = 1; i <= 100; i++) {
    if ((A%i == 0)
        && (B%i == 0)) {
      result_queue.push_back(i);
    }
  }

  reverse(result_queue.begin(), result_queue.end());
  cout << result_queue[K-1] << endl;

  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input().strip())
K = int(input().strip())
x_list = list(map(int, input().rstrip().split()))
#-----

sum = 0
for x in x_list:
    dist_0 = abs(x)
    dist_K = abs(x-K)
    sum += min(dist_0 , dist_K) * 2

print(sum)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define type(a) typeid(a).name();
#define pop() pop_back()
#define push(n) push_back(n)
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl

int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s;
  getline(cin,s);
  int counting = 0;
  if(n==1){
	  cout << 1;
  }else{
  for(int i=0;i<n-1;++i){
	  if(i==n-2){
	    if(s[n-1] != s[n-2]){
		  counting += 2;
	    }else{
			counting++;
		}
	  }else if(s[i]!=s[i+1]){
		  counting ++;
	  }
  }
  cout << counting;
  }
}  

















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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int INF = 1e9 + 1;

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= k + i; j++) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    cout << dp[n - 1] << "\n";

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v)    \
  {                          \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                     \
  cerr << #v ":" << endl;            \
  for (auto macro_row : v)           \
  {                                  \
    cerr << "[";                     \
    for (auto macro__vi : macro_row) \
    {                                \
      cerr << macro__vi << " ";      \
    }                                \
    cerr << "]" << endl;             \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m)                                       \
  {                                                               \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v, i) macro_v.begin() + i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

double dist(int from, int to, vector<pair<int, int>> &P)
{
  int dx = P[from].first - P[to].first;
  int dy = P[from].second - P[to].second;
  return pow(dx * dx + dy * dy, 0.5);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> P(n, make_pair(0, 0));
  rep(i, n)
  {
    cin >> P[i].first >> P[i].second;
  }
  vector<int> N(n, 0);
  rep(i, n)
  {
    N[i] = i;
  }

  double sum = 0.0;
  do
  {
    // dump(N);
    double path_dist = 0.0;
    for (int i = 0; i < n - 1; i++)
    {
      path_dist += dist(N[i], N[i + 1], P);
    }
    // d(path_dist);
    sum += path_dist;
  } while (next_permutation(all(N)));

  int fact = 1;
  while (n != 1)
  {
    fact *= n;
    n--;
  }
  cout << setprecision(10) << sum / fact << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

using namespace std;

const long long INF = (1LL << 60);

int main(){
    int N, M, L;
    while(cin >> N >> M >> L){
        vector<vector<long long>> dist(N, vector<long long>(N, INF));
        vector<vector<long long>> res(N, vector<long long>(N, INF));
        for(int i=0;i<M;i++){
            int a, b, c; cin >> a >> b >> c;
            --a; --b;
            dist[a][b] = dist[b][a] = c;
        }
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(dist[i][j] <= L) res[i][j] = 1;
            }
        }
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    res[i][j] = min(res[i][j], res[i][k]+res[k][j]);
                }
            }
        }
        int Q; cin >> Q;
        for(int i=0;i<Q;i++){
            int s, t; cin >> s >> t;
            --s; --t;
            cout << (res[s][t] == INF ? -1 : res[s][t] - 1) << endl;
        }
    }
}

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

using namespace std;

const int N = 3e2+7;
const int INT_INF = 0x3f3f3f3f;
const long long LL_INF = 1e18;

int n, m, l, q;
int e[N][N], res[N][N];
long long dis[N][N];

int main()
{
    cin >> n >> m >> l;
    for (int i = 1, a, b, c; i <= m; ++i) {
        cin >> a >> b >> c;
        e[a][b] = e[b][a] = c;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i == j) dis[i][j] = 0;
            else dis[i][j] = (e[i][j] ? e[i][j] : LL_INF);
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i == j) res[i][j] = 0;
            else res[i][j] = (dis[i][j] <= l ? 0 : INT_INF);
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                res[i][j] = min(res[i][j], res[i][k]+res[k][j]+1);
            }
        }
    }

    int s, t;
    cin >> q;
    while (q--) {
        cin >> s >> t;
        cout << (res[s][t] >= INT_INF ? -1 : res[s][t]) << endl;
    }
    return 0;
}


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

int main() {
  int n, countOdd = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
    if (a.at(i) % 2 == 1) {
      countOdd ++;
    }
  }

  string ans;
  if (countOdd % 2 == 0) {
    ans = "YES";
  } else {
    ans = "NO";
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
H, W = map(int, input().split())
cost = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
            
ans = 0
for i in range(H):
    for j in range(W):
        now = A[i][j]
        if now != -1:
            ans += cost[now][1]
            
print(ans)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int S, W;
  cin >> S >> W;
  if(S > W) cout << "safe\n";
  else cout << "unsafe\n";
}


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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,t; cin >> n >> t;
  int minv = 1 << 30, maxdiff = -(1 << 29), c = 0;

  rep(i,n){
    int a; cin >> a;
    minv = min(minv, a);
    if(a - minv == maxdiff) c++;
    else if(a - minv > maxdiff){
      maxdiff = a - minv;
      c = 1;
    }
  }

  cout << c << endl;
}


Measured memory_bytes: 256
/// Geometry INT

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

inline int sign(const LL x) {
	if (x < 0) {
		return -1;
	}
	if (x > 0) {
		return 1;
	}
	return 0;
}

struct point {
	LL x, y;
	point() {}
	point(LL _x, LL _y) : x(_x), y(_y) {}
};

void normalize(point &P) {
	assert(P.x != 0 || P.y != 0);
	LL g = __gcd(P.x, P.y);
	P.x /= g;
	P.y /= g;
}

point operator + (const point &P, const point &Q) {
	return point(P.x + Q.x, P.y + Q.y);
}

point operator - (const point &P, const point &Q) {
	return point (P.x - Q.x, P.y - Q.y);
}

point operator * (const point &P, const LL k) {
	return point(P.x * k, P.y * k);
}

point operator / (const point &P, const LL k) {
	assert(k != 0 && P.x % k == 0 && P.y % k == 0);
	return point(P.x / k, P.y / k);
}

inline LL dot(const point &P, const point &Q) {
	return P.x * Q.x + P.y * Q.y;
}

inline LL cross(const point &P, const point &Q) {
	return P.x * Q.y - P.y * Q.x;
}

inline bool is_in(LL x, LL a, LL b) {
	if (a > b) {
		swap(a, b);
	}
	return (a <= x && x <= b);
}

inline bool is_in(const point &P, const point &A, const point &B) {
	if (cross(B - A, P - A) != 0) {
		return false;
	}
	return (is_in(P.x, A.x, B.x) && is_in(P.y, A.y, B.y));
}

inline bool segment_segment_intersect(const point &A, const point &B, const point &C, const point &D) {
	if (cross(B - A, D - C) == 0) { // lines are parallel
		return (is_in(A, C, D) || is_in(B, C, D) || is_in(C, A, B) || is_in(D, A, B));
	}
	if (sign(cross(C - A, B - A)) * sign(cross(D - A, B - A)) > 0) {
		return false;
	}
	if (sign(cross(A - C, D - C)) * sign(cross(B - C, D - C)) > 0) {
		return false;
	}
	return true;
}

inline bool is_convex(const vector <point> &polygon) {
	int n = polygon.size();
	assert(n >= 3);
	for (int i = 0; i < n; i++) {
		int j = (i + 1) % n;
		int k = (i + 2) % n;
		if (sign(cross(polygon[j] - polygon[i], polygon[k] - polygon[i])) < 0) {
			return false;
		}
	}
	return true;
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B
// test OK
void test_segment_segment_intersection() {
	int q;
	cin >> q;
	while (q--) {
		point A, B, C, D;
		cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
		cout << (segment_segment_intersect(A, B, C, D) ? "1" : "0") << "\n";
	}
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B
// test ???
void test_is_convex() {
	int n;
	cin >> n;
	vector <point> polygon(n);
	for (int i = 0; i < n; i++) {
		cin >> polygon[i].x >> polygon[i].y;
	}
	cout << (is_convex(polygon) ? "1" : "0") << "\n";
}

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

	// test_segment_segment_intersection();
	test_is_convex();
}

Measured memory_bytes: 3108
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double[] sequence;	
	static  int i;
	static double Sum = 0.0;
	public static void main(String[] args) {
		
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNextDouble())return false;
		
		sequence = new double[11];
		sequence[0] = 0.0;
		sequence[1] = 0.0;
		sequence[1] = sc.nextDouble();
		return true;
	}
	static void slove(){
		
		for(i = 2; i <= 10; i++){
			if(i%2 == 0){
				sequence[i] = 2*sequence[i-1];
			}else{
				sequence[i] = sequence[i-1]/3;
			}
			//System.out.println(sequence[i]);
		}
		for(i = 1; i <= 10; i++){
			Sum = Sum + sequence[i];
		}
		for(i = 1; i <= 10; i++){
			sequence[i] = 0.0;
		}
		System.out.println(Sum);
		Sum = 0.0;
	}
}

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

using namespace std;

int main()
{
	char c;

	cin >> c;

	if(c=='A') cout << 'T' << endl;
	else  if(c=='T') cout << 'A' << endl;
	else  if(c=='C') cout << 'G' << endl;
	else  if(c=='G') cout << 'C' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;
const int mod = 1e9 + 7;

void	solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int ans = 0;
	int x = 0;
	rep(i, n) {
		ans = (ans + (ll)v[i] * x) % mod;
		x = (x + v[i]) % mod;
	}
	cout << ans << endl;
}

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

	solve();
}



Measured memory_bytes: 3936
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t av, bv, cv;
int32_t func(int a, int b, int c, int32_t min = 0)
{
	if (a == 0 && b == 0 && c == 0) {
		return 1;
	}
	int32_t res = 0;
	for (int32_t i = 0, aa = 1; i <= a && aa <= N; i++, aa*= av)
		for (int32_t j = 0, bb = 1; j <= b && bb <= N; j++, bb *= bv)
			for (int32_t k = 0, cc = 1; k <= c && cc <= N; k++, cc *= cv) {
		auto vv = aa * bb*cc;
		if (min >= vv) { continue; }
		if (vv > N) { break; }
		res += func(a - i, b - j, c - k, vv);
	}
	return res;
}

int num[200];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	bool prime[500] = {};
	for (int32_t i = 2; i <= N; i++)
	{
		bool ng = false;
		for (int32_t j = 2; j*j <= i; j++)
		{
			ng |= ((i%j) == 0);
		}
		prime[i] = !ng;
	}
	prime[1] = false;

	for (int32_t i = 1; i <= N; i++)
	{
		int tmp = i;
		for (int32_t j = 2; j <= N && tmp > 1; j++)
		{
			if (!prime[j]) { continue; }
			while (tmp % j == 0) {
				tmp /= j;
				++num[j];
			}
		}
	}

	int32_t res = 0;
	for (int32_t i = 1; i <= N; i++)
	{
		if (!prime[i]) { continue; }
		if (num[i] >= 74) { ++res; }
		for (int32_t j = 1; j <= N; j++)
		{
			if (i == j) { continue; }
			if (!prime[j]) { continue; }
			if (num[i] >= 3 - 1 && num[j] >= 25 - 1) { ++res; }
			if (num[i] >= 5 - 1 && num[j] >= 15 - 1) { ++res; }
			for (int32_t k = 1; k <= N; k++)
			{
				if (i == k) { continue; }
				if (k == j) { continue; }
				if (!prime[k]) { continue; }
				if (i < j && num[k] >= 3 - 1 && num[i] >= 5 - 1 && num[j] >= 5 - 1) { ++res; }
			}
		}
	}

	out << res << endl;

	return 0;
}
#endif




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n, d;
    cin >> n >> d;
    int x[15][15];
    REP(i,n){
        REP(j,d){
            cin >> x[i][j];
        }
    }
    int ABS = 0;
    int sum = 0;
    REP(i,n-1){
        FOR(j,i+1,n){
            ABS = 0;
            REP(k,d){
                ABS += abs(x[j][k] - x[i][k]) * abs(x[j][k] - x[i][k]);        
            }
            bool flag = false;
            REP(l,ABS+1){
                if(l * l == ABS) flag = true;
            }
            if(flag == true) sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
 // 	freopen("input.txt","r",stdin);
 // 	freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int k , n;
		cin >> k >> n;
		int ans=0;
		for(int i =0 ;i < n ;i++){
		int x ;
		cin >> x;
		ans+=x;
		}
		cout << (ans >=k ? "Yes" : "No"); 
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

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

  vector<int> b(n);
  for (int i = 0; i < n; ++i)
    cin >> b[i];

  vector<int> ans;
  vector<bool> used(n);
  for (int i = 0; i < n; ++i) {
    int curr = 1;
    int last = -1;
    for (int j = 0; j < n; ++j) {
      if (used[j])
        continue;
      if (b[j] == curr)
        last = j;
      ++curr;
    }
    if (last > -1) {
      used[last] = true;
      ans.push_back(b[last]);
      continue;
    }
    cout << -1 << endl;
    return 0;
  }

  reverse(ans.begin(), ans.end());

  for (auto i : ans)
    cout << i << endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;

    auto dfs = [&](auto self, string s, int num) {  // num:文字の種類
        if (s.size() == N) {
            cout << s << endl;
            return;
        }
        rep(i, num) {
            string t = s;
            t += i + 'a';
            // cout << t << endl;
            self(self, t, num);
        };
        string t = s;
        t += num + 'a';
        self(self, t, num + 1);
    };
    string s = "a";
    dfs(dfs, s, 1);
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
#include <random>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll ng = 0, ok = 1e9+1;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        ll cost = 0;
        rep(i,n){
            ll x = (h[i] - b*mid + a - b - 1) / (a - b);
            chmax(x, 0LL);
            cost += x;
        }
        if(cost <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}


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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    // long x = A.reduce!lcm - 1;
    // A.map!(y => x % y).writeln();
    A.map!"a-1"().sum().writeln();
}

T lcm(T)(T a, T b)
{
    return (a * b) / gcd(a, b);
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(type, i, a, b) for (type i = (a); i <= (b); ++i)
#define Ford(type, i, a, b) for (type i = (a); i >= (b); --i)
#define Rep(type, i, a, b) for (type i = (a); i < (b); ++i)
#define Repd(type, i, a, b) for(type i = (a); i > (b); --i)
#define endl '\n'
using namespace std;

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

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;

const ll limit = 1e3 + 5;
const ll limit1 = 1e4 + 5;
const ll limit2 = 2e5 + 5;
const ll limit3 = 1e6 + 5;


ll test;
ll n, m, k, x, y, z, u, v;
ll res = 0, sum = 0, ans = 0, kd, hkd, answer;
bool ok = false;
ll a[limit3], b[limit3], c[limit3], dp[101][limit2 / 2];
string s;

void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void ReadIn(){

    cin >> n >> k;
    For(ll, i, 1, n)
        cin >> a[i] >> b[i];
    For(ll, i, 1, n){
        For(ll, j, 1, k){
            if(j - a[i] < 0)
                dp[i][j] = dp[i - 1][j];
            else{
                dp[i][j] = max(dp[i - 1][j - a[i]] + b[i], dp[i - 1][j]);
            }
        }
    }
    cout << dp[n][k];
}

int main(){
    FastIn();
    ReadIn();
}



Measured memory_bytes: 81760
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var n = Number(p.shift());
  for (var i = 0; i < n; i++) {
    var args = p.shift().split(' ').map(Number);
    var xa = args.shift();
    var ya = args.shift();
    var ra = args.shift();
    var xb = args.shift();
    var yb = args.shift();
    var rb = args.shift();
    var d = Math.sqrt(Math.pow(xb - xa, 2) + Math.pow(yb - ya, 2));

    if (d <= ra + rb) {
      if (d < rb - ra) {
        console.log(-2);
      } else if (d < ra - rb) {
        console.log(2);
      } else {
        console.log(1);
      }
    } else {
      console.log(0);
    }
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7640
N = int(input())
A = list(map(int, input().split()))

amax = max(A)
sieve = [False] * (amax+1)
exist = [0] * (amax+1)

for a in A:
    if exist[a] > 0:
        exist[a] += 1
        continue
    exist[a] += 1
    for i in range(a*2, amax+1, a):
        sieve[i] = True

ans = 0
for a in A:
    if not sieve[a] and exist[a] == 1:
        ans += 1

print(ans)


Measured memory_bytes: 145112
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<ll,ll>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a,lia[100010],lib[100010];

int main(){
	cin >> n >> m;
	REP(i,0,n) cin >> a,lia[a]++,lib[a%m]++;
	
	int s=lib[0]/2+(!(m%2)?lib[m/2]/2:0);
	for(int i=1;i*2<m;i++){
		int pos=min(lib[i], lib[m-i]);
		lib[i]-=pos;
		lib[m-i]-=pos;
		s+=pos;
	}
	
	REP(i,1,100010){
		if(!(i%m) or (i%m)*2==m) continue;
		int pos=min(lib[i%m]/2, lia[i]/2);
		s+=pos;
		lib[i%m]-=pos*2;
	}
	
	cout << s << endl;
	return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

struct Edge{
    int to,w;
};
struct Node{
    bool Color;
    vector<Edge> out;
    int top;
};

void expnode(int from,Edge arrow,vector<Node> &tree){
    tree[arrow.to].Color =(arrow.w %2) ? !tree[from].Color : tree[from].Color;

    rep(i,tree[arrow.to].out.size()){
        if(tree[arrow.to].out[i].to==from)continue;
        expnode(arrow.to,tree[arrow.to].out[i],tree);
    }
    return;
}

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

    vector<Node> tree(N);
    rep(i,N)tree[i]={false,{},-1};
    rep(i,N-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        tree[u].out.push_back({v,w});
        tree[v].out.push_back({u,w});
    }
    /* この木に上下関係は無い */
    tree[0].Color=true;
    rep(i,tree[0].out.size()) expnode(0,tree[0].out[i],tree);

    rep(i,N){
        cout<<tree[i].Color<<endl;
    }

    return (0);
}

Measured memory_bytes: 9344
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

int MAX = 10000;
vci S;

void shutainer() {
	S.assign(MAX  + 1, 1);
	for_(i, 1, MAX + 1) S[i] = S[i-1] + i;
}

int main() {
	shutainer();	
	
	int n;
	
	while (cin>>n) {
		cout << S[n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
    #include<string.h>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main(){
        int a,b,d=0;
        cin>>a>>b;
        char c[a+1][b+1];
        for(int i=1;i<=a;i++){
            for(int j=1;j<=b;j++){
                cin>>c[i][j];
            }
        }
        for(int i=1;i<=a;i++){
            for(int j=1;j<=b;j++){
                d=0;
                for(int k=0;k<3;k++){
                        for(int l=0;l<3;l++){
                            if(c[i-1+l][j-1+k]=='#') d++;
                        }
                }
                if(c[i][j]=='#') cout<<'#';
                else cout<<d;
            }
            cout<<endl;
        }
    }


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0; //, min_v = 1000000001;
    for (int i = 0; i < N; i++) {
        cin >>A.at(i);
        //sum += A.at(i);
        //min_v = min(min_v, A.at(i));
    }
    sort(A.begin(), A.end(), greater<ll>());
    sum += A.at(0);
    for (int i = 1; i < N - 1; i++) {
        //cout << (i + 1) / 2 << endl;
        sum += A.at( (i + 1) / 2);
    }
    //sum -= A.at(N - 1);
    //sum -= min_v;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4772
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#define MAX_V 112345 //??????????????°????????§

struct edge
{
  int to;
  int cost;
};

int V; // ???????????°(???????????£??\??????)
vector<edge> G[MAX_V]; // ?????????
int d[MAX_V]; // ??¨?????????????????????????????????

void dijkstra(int s)
{
  int i;
  priority_queue<i_i,vector<i_i>,greater<i_i>> que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(i_i(0,s));
  while(!que.empty())
    {
      i_i p=que.top();
      que.pop();
      int v=p.second;
      if(d[v]<p.first) continue;
      int n=G[v].size();
      for(i=0;i<n;i++)
	{
	  edge e=G[v][i];
	  if(d[e.to]>d[v]+e.cost)
	    {
	      d[e.to]=d[v]+e.cost;
	      que.push(i_i(d[e.to],e.to));
	    }	  
	}
    }
}

signed main(void)
{
  cin>>V;
  in(int,E,r);
  int i;
  int s,t,c;
  rep(i,E)
    {
      cin>>s>>t>>c;
      G[s].pb((edge){t,c});
    }
  dijkstra(r);
  for(i=0;i<V;i++)
    d[i]==INF?cout<<"INF"<<endl:putv(d[i]);
  return 0;
}

Measured memory_bytes: 13324