akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> count(N);
	for (int i = 0;i < N;++i) {
		count[i] = 0;
	}
	vector<pair<int, int>> city(M);
	for (int i = 0;i < M;++i) {
		cin >> city[i].first >> city[i].second;
		count[city[i].first - 1] += 1;
		count[city[i].second - 1] += 1;
	}
	for (int i = 0;i < N;++i) {
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def digit_len(n):
    result = 0
    while n > 0:
        result += 1
        n //= 10
    return result

result = 10 * 2
N = int(input())
for d in range(1, N + 1):
    if d * d > N:
        break
    if N % d == 0:
        result = min(result, max(digit_len(d), digit_len(N // d)))
print(result)

Measured memory_bytes: 3060
import math

n, a, b= map(int, input().split())
#n, x  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))

tot = 0

for i in range(n+1):
  string = list(str(i))
  integ  = [int(s) for s in string]
  summation = sum(integ)
  if (a <= summation and b >= summation):
    tot = tot + i
    
print(tot)

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    println(problem152a(n, m))
}

fun problem152a(n: Int, m: Int): String {
    return if (n == m) "Yes" else "No"
}

Measured memory_bytes: 31260
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int W, H; 
  cin >> W >> H;

  int A;
  priority_queue<int, vector<int>, greater<int>> p, q;
  REP(i, W){
    cin >> A;
    p.push(A);
  }
  REP(i, H){
    cin >> A;
    q.push(A);
  }

  int ans = 0;
  int cp = H+1, cq = W+1;
  while(!p.empty() && !q.empty()){
    int np = p.top();
    int nq = q.top();
    if(np <= nq){
      ans += cp*np;
      cq--; p.pop();
    }else{
      ans += cq*nq;
      cp--; q.pop();
    }
  }
  while(!p.empty()){
    ans += p.top(); p.pop();
  }
  while(!q.empty()){
    ans += q.top(); q.pop();
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 2548
/* Author: Mrigank
Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair < ll , ll > PLL;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < int , int > > vpi;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 1e5 + 10;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    string s;
    cin >> s;
    int ans;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
    else if((s[2] == 'R' && s[1] == 'R') || (s[0] == 'R' && s[1] == 'R')) ans = 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;
    else ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 3592
N,K = list(map(int,input().split()))
array = list(map(int,input().split()))
# N=1000
# K=8
# array = [1,3,4,5,6,7,8,9]

# Farray = [0,1,2,3,4,5,6,7,8,9]
# array = set(Farray)-set(array)
# array = list(map(int,array))
i=0
result=[]

#桁上がり未考慮だった。
# while i<len(str(N)):
#     j=0
#     for j in range(len(array)):
#         if int(str(N)[i]) <= array[j]:
#             result.append(array[j])
#             break
#     i+=1
flag=False
while flag == False :
    # print(N)
    for i in range(len(str(N))):
        if int(str(N)[i]) in array:
            break
    else:
        flag=True

    N+=1

print(N-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF  = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> res[3];
bool cycle[MAXN]; int x[MAXN], y[MAXN], c[MAXN];
int n, m, ind[MAXN], oud[MAXN], f[MAXN], s[MAXN];
int find(int x) {
	if (f[x] == x) return x;
	else return f[x] = find(f[x]);
}
void merge(int x, int y) {
	x = find(x), y = find(y);
	if (x != y) {
		f[y] = x;
		cycle[y] = false;
		s[x] += s[y];
	}
}
bool cmp(int x, int y) {
	return x > y;
}
int work(ll cnt, bool mode) {
	sort(res[0].begin(), res[0].end(), cmp);
	sort(res[1].begin(), res[1].end(), cmp);
	sort(res[2].begin(), res[2].end(), cmp);
	for (auto x : res[0]) cnt -= x;
	int ans = INF;
	if (mode == false) {
		if (res[1].empty()) return INF;
		cnt -= res[1][0];
		res[1].erase(res[1].begin());
		int cur = res[2].size(); ll sum = 0;
		for (auto x : res[2]) sum += x;
		while (cur >= 1 && sum - res[2][cur - 1] >= cnt)
			sum -= res[2][--cur];
		if (sum >= cnt) chkmin(ans, 1 + cur * 2);
		for (int i = 0; i < res[1].size(); i++) {
			cnt -= res[1][i];
			while (cur >= 1 && sum - res[2][cur - 1] >= cnt)
				sum -= res[2][--cur];
			if (sum >= cnt) chkmin(ans, 1 + (i + 1) + cur * 2);
		}
		return ans;
	} else {
		if (cnt <= 0) return 0;
		int cur = res[2].size(); ll sum = 0;
		for (auto x : res[2]) sum += x;
		while (cur >= 1 && sum - res[2][cur - 1] >= cnt)
			sum -= res[2][--cur];
		if (sum >= cnt) chkmin(ans, cur * 2);
		for (int i = 0; i < res[1].size(); i++) {
			cnt -= res[1][i];
			while (cur >= 1 && sum - res[2][cur - 1] >= cnt)
				sum -= res[2][--cur];
			if (sum >= cnt) chkmin(ans, (i + 1) + cur * 2);
		}
		return ans;
	}
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		f[i] = i, s[i] = 1, cycle[i] = true;
	for (int i = 1; i <= m; i++) {
		read(x[i]), read(y[i]), read(c[i]);
		merge(x[i], y[i]), oud[x[i]]++, ind[y[i]]++;
	}
	for (int i = 1; i <= n; i++)
		if (ind[i] != 1 || oud[i] != 1) cycle[find(i)] = false;
	int cnt = 0, ans = 0;
	for (int i = 1; i <= n; i++)
		if (f[i] == i) cnt += cycle[i] && s[i] >= 2;
	ll lft = cnt; bool key = false;
	for (int i = 1; i <= m; i++) {
		ans += x[i] != y[i];
		if (c[i] >= 2) {
			if (cycle[find(x[i])]) {
				if (s[find(x[i])] == 1) res[2].push_back(c[i] - 2);
				else res[0].push_back(c[i] - 1);
			} else {
				if (x[i] == y[i]) res[1].push_back(c[i] - 1);
				else {
					lft -= c[i] - 1;
					key = true;
				}
			}
		}
	}
	if (cnt == 0) {
		cout << ans << endl;
		return 0;
	} else {
		int tmp = work(lft, key);
		if (tmp == INF) cout << -1 << endl;
		else cout << ans + cnt + tmp << endl;
	}
	return 0;
}


Measured memory_bytes: 6532
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''



N, M = map(int, input().split())
PYn = []

for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    PYn.append((x1, y1, i))

PYn.sort()

past = [1]*(N+1)
ans = [0]*M # p*1000000+n
for pyn in PYn:

    ans[pyn[2]] = pyn[0]*1000000 + past[pyn[0]]
    past[pyn[0]] += 1


final = []
for a in ans:
    final.append(str(a).zfill(12))

for f in final:
    print(f)




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

int main() {
  int A, B, C, K, S;
  cin >> A >> B >> C >> K;
  /**
  A：1の枚数
  B：0の枚数
  C：-1の枚数
  K：選ぶカードの枚数
  **/
  
  if (K - A >= 0) {
    S = 1 * A;
    if (K - A - B >= 0) {
      S = S - 1 * (K - A - B);
    }
  }
  else {
    S = 1 * K;
  }
  
  cout << S;  

}

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      int c = int.Parse(input[2]);
      int d = int.Parse(input[3]);
      int ans = 0;
      for (int i=0;i<=101;i++)
      {
         if ((a<i && i<=b)&&(c<i && i<=d))
         {
           ans+=1;
         }
      }
      Console.WriteLine(ans);
    }
}


Measured memory_bytes: 27308
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll simulate(int l, int r, int k, deque<ll> dq) {
    vector<ll> hand;
    int sz = dq.size();
    l = min(sz,l);
    for (int i = 0; i < l; ++i) {
        hand.push_back(dq.front());
        dq.pop_front();
    }
    r = min({sz,r,k-l});
    for (int i = 0; i < r; ++i) {
        hand.push_back(dq.back());
        dq.pop_back();
    }
    sort(hand.begin(), hand.end());
    int trush = k-(l+r);
    ll ret = 0;
    for (int i = 0; i < hand.size(); ++i) {
        if (hand[i]<0) {
            if (trush>0) {
                trush--;
                continue;
            }
        }
        ret += hand[i];
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    deque<ll> dq;
    rep(i,n) {
        int v;
        cin>>v;
        dq.push_back(v);
    }
    ll ans = -LINF;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k-i; ++j) {
            if (i+j>n) continue;
            chmax(ans, simulate(i,j,k,dq));
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
//from PKU1125
double dist[1001][1001],d;
next[1001][1001],x[1001],y[1001];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.01?d:9999;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>9990)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

Measured memory_bytes: 5108
n = int(input())
p_list = input().split(' ')

p_i_0 = int(p_list[0])
p_i_1 = int(p_list[1])
p_i_2 = int(p_list[2])

counter = 0

for i in range(n - 3):
    if ((p_i_0 - p_i_1) * (p_i_2 - p_i_1) <= 0):
        counter += 1
    p_i_0 = p_i_1
    p_i_1 = p_i_2
    p_i_2 = int(p_list[i + 3])

if ((p_i_0 - p_i_1) * (p_i_2 - p_i_1) <= 0):
    counter += 1
print(counter)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s;
    cin >> s;
    int YY=(s[0]-'0')*10+s[1]-'0';
    int MM=(s[2]-'0')*10+s[3]-'0';
    bool yymm=false;
    bool mmyy=false;
    if(YY<=99 && 0<=YY && MM<=12 && 1<=MM){
        yymm=true;
    }
    if(YY<=12 && 1<=YY && MM<=99 && 0<=MM){
        mmyy=true;
    }
    if(yymm && mmyy){
        puts("AMBIGUOUS");
    }else if(yymm){
        puts("YYMM");
    }else if(mmyy){
        puts("MMYY");
    }else{
        puts("NA");
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll H[100010];

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

  rep( i, N )
    std::cin >> H[i];

  ll ans = 0, cnt = 0;

  rep( i, N-1 ) {
    if( H[i] >= H[i+1] )
      ++cnt;
    else {
      cnt = 0;
    }

    chmax( ans, cnt );
  }

  std::cout << ans << endl;

  return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

bool f1[200001], f2[200001];

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

  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    
    if(a == 1) f1[b] = true;
    if(b == 1) f1[a] = true;
    if(a == n) f2[b] = true;
    if(b == n) f2[a] = true;
  }

  for(int i = 1; i <= n; i++){
    if(f1[i] and f2[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    float ans;
    cin>>n;
    ans = 2.0 * M_PI * (float)n;
    cout<<fixed<<setprecision(2)<<ans<<endl;
    return 0;
}
  

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    double xa, ya, xb, yb, xc, yc, xd, yd, S, Sa, Sb, Sc, Sd;
	    while((st = sc.readLine())!=null){
		String[] c = st.split(",");
		xa = Double.valueOf(c[0]);
		ya = Double.valueOf(c[1]);
		xb = Double.valueOf(c[2])-xa;
		yb = Double.valueOf(c[3])-ya;
		xc = Double.valueOf(c[4])-xa;
		yc = Double.valueOf(c[5])-ya;
		xd = Double.valueOf(c[6])-xa;
		yd = Double.valueOf(c[7])-ya;
		xa = 0.0;
		ya = 0.0;
		S = Math.abs(xb*yc+xc*yd-yb*xc-yc*xd);
		Sa = Math.abs(xb*yc+xc*yd+xd*yb-yb*xc-yc*xd-yd*xb);
		Sb = Math.abs(xc*yd-yc*xd);
		Sc = Math.abs(xb*yd-yb*xd);
		Sd = Math.abs(xb*yc-yb*xc);
		if(S>Sa && S>Sb && S>Sc&& S>Sd)
		    System.out.println("YES");
		else
		    System.out.println("NO");
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9780
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll h,w;cin>>h>>w;
    ll cnt=0;
    rep(i,h*w){
        char c;cin>>c;
        if(c=='#')cnt++;
    }
    if(cnt==h+w-1)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

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

typedef long long ll;

ll a,b,x;

int main(){
	cin >> a >> b >> x;
	ll ans = 0;
	if(a==0) ans++,a++;
	a--;
	cout << ans+(b/x) - (a/x) << endl;
	return 0;
}


Measured memory_bytes: 256
// 2013/12/02 Tazoe

#include <iostream>
using namespace std;

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

	int K;
	cin >> K;

	for(int i=0; i<K; i++){
		int a, b;
		cin >> a >> b;

		int c = a;
		if(c>N-a+1){
			c = N-a+1;
		}
		if(c>b){
			c = b;
		}
		if(c>N-b+1){
			c = N-b+1;
		}

		int d = c%3;
		if(d==0){
			d = 3;
		}

		cout << d << '\n';
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(){
    int n;
    int a[55];
    int b[5637];
    cin >> n;
    a[0]=2;
    b[0]=2;
    int num=1;
    int cnta=0;
    for(int cnt=1;cnt<5637;num+=2){
        if (num<3)continue;
        b[cnt]=num;
        bool flag=true;
        for (int i=0;i<cnt;i++){
            if(b[i]*b[i]>b[cnt])break;
            if(b[cnt]%b[i]==0){
                flag=false;
            }
        }
        if(flag){
            if(b[cnt]%5==1 && cnta<55){
                a[cnta]=b[cnt];
                cnta++;
            }
            cnt++;
        }
    }
    for(int i=0;i<n;i++){
        cout << a[i];
        if (i<n-1){
            cout <<" ";
        }
    }
        cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int from,to,cost;};
vector<edge> G;
vector<int> O[10];
P sg[10];
int d[1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];
int n,m;
bool in=false;
signed main(){
 cin>>n>>m;
    rep(i,m){
        int a,b,c;cin>>a>>b>>c;
        G.push_back(edge{a,b,c});
    }
    rep(i,n+5)d[i]=-inf;
    d[1]=0;
    rep(j,n){
        rep(i,m){
            edge e=G[i];
            if(d[e.from]!=-inf&&d[e.to]<d[e.from]+e.cost) {
                d[e.to]=d[e.from]+e.cost;
                if(e.to==n&&j==n-1)in=true;
            }
        }
    }

    if(in)cout<<"inf"<<endl;
        else cout<<d[n]<<endl;
        return 0;
}


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

int main()
{
  int64_t n;
  cin >> n;
  string ans;
  if (n == 0)
  {
    cout << "0\n";
    return 0;
  }

  while (n != 0)
  {
    int r = n % 2;
    if (r < 0)
      r += 2;
    n = (n - r) / (-2);
    ans = to_string(r) + ans;
  }
  cout << ans << "\n";
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
double a;
int n;
double m;
while(1){
cin>>n;
if(n==0)break;
double s[n];
m=0;
a=0;
REP(i,n)cin>>s[i];
REP(i,n){
    m+=s[i];
}
m=m/n;
REP(i,n){
    a+=(s[i]-m)*(s[i]-m);
}
a=a/n;
cout FIX sqrt(a)<<endl;
}

}


Measured memory_bytes: 3268
#include <stdio.h>
int main(void){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//

using namespace std;

signed main() {
      string str; cin>>str;
      cout<<string(str.length(),'x');
      return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b;
	int sum=0;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(a>=b){
	    sum=sum+a;
	    a=a-1;
	}else{
	    sum=sum+b;
	    b=b-1;
	}
	
	if(a>=b){
	    sum=sum+a;
	    a=a-1;
	}else{
	    sum=sum+b;
	    b=b-1;
	}
	
	printf("%d",sum);
	
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a;i<=b;++i)
#define UF(i,a,b) for(register int i=a;i>=b;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
typedef unsigned long long ull;
inline int r(int &x)
{
    int f=1;x=0;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
    return x*=f;
}
inline ll r(ll &x)
{
    ll f=1ll;x=0ll;
    char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1ll;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ll)(c-'0');
    return x*=f;
}
inline ull r(ull &x)
{
    x=0ull;
    char c=getchar();
    for(;!isdigit(c);c=getchar());
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(ull)(c-'0');
    return x;
}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define mp(a,b) make_pair(a,b)
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int prime_have[10];
int prime_num[10];
int primes=0;
ll ni[100020];
int nownum=0;
const ll mod=1000000007ll;
ll qp(ll a,ll b)
{
	if(b==1ll) return a;
	ll w=qp(a,b/2);
	if(b&1) return ((w*w)%mod)*a%mod;
	else return (w*w)%mod;
}
ll _ni(ll a){return qp(a,mod-2);}
void prework()
{
	ni[0]=1;
	ll a=1;
	F(i,1,100010)
	{
		a=a*i%mod;
		ni[i]=_ni(a);
	}
	return;
}
int m,n;
void solve()
{
	F(i,2,100000)
	{
		nownum=0;
		while(m%i==0) {m/=i;++nownum;}
		if(nownum!=0) {prime_have[++primes]=i;prime_num[primes]=nownum;}
	}
	if(m!=1) {prime_have[++primes]=m;prime_num[primes]=1;}
	ll ans=1;
	F(i,1,primes)
	{
		F(j,1,n-1) ans=ans*(prime_num[i]+j)%mod;
		ans=ans*ni[n-1]%mod;
	}
	printf("%lld\n",ans);
	return;
}
int main()
{
	prework();
	r(n),r(m);
	solve();//ok2333
	return 0;//ok2333
}

Measured memory_bytes: 1024
while(h,w=gets.split.map &:to_i)!=(x,y=[0,0]);m=[];f=[];h.times{f.push [1]*w;m.push gets};b=1;while(?.<c=m[y][x])&&0<b=f[y][x] do;f[y][x]=0;(c[?v])?(y+=1):(c[?^])?(y-=1):(c[?<])?(x-=1):x+=1;end;puts ["LOOP","#{x} #{y}"][b]end

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

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

    vector<int> A(N);
    vector<ll> B(N+1, 0); //累積和
    ll mod = 1e9+7;

    for(int i=0; i<N; i++){
        cin >> A[i];
        B[i+1] = B[i] + A[i];
    }

    ll ans = 0;

    for(int i=0; i<N; i++){
        ll sum = (B[N] - B[i+1])%mod;


        ans += A[i]*sum;
        ans %= mod;
    }

    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 5604
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;





int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	vector<int> a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1];
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = Math.max(A+B, A-B);

    System.out.println(Math.max(ans, A*B));
  }
}


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

int main(){
  string s; cin >> s;
  int ret=0;
  for(int i=0; i<s.size()/2;i++){
    if(s[i] != s[s.size()-i-1]){
      ret++;
    }
  }
  
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define SORT(x) sort(x.begin(),x.end())

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin >> N >> M;
  vector<int> count(N+1,0);
  
  
  rep(i,M){
    int L,R;
    cin >> L >> R;
    L--;
    count.at(L)++;
    count.at(R)--;
  }
  
  int ans = 0;
  rep(i,N){
    if(count.at(i)==M) ans++;
    count.at(i+1) += count.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
string s[1010];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int vis[1010][1010],n,m;
int dfs(int x,int y,int j)
{
	vis[x][y]=j;
	for(int i=0;i<4;i++)
	{
		if(dx[i]+x>=0&&dx[i]+x<n&&dy[i]+y>=0&&dy[i]+y<m&&s[x+dx[i]][y+dy[i]]=='.'&&!vis[x+dx[i]][y+dy[i]])
		{
			dfs(x+dx[i],y+dy[i],j);
		}
	}
	return 0;
}
map<pii,int> ma;
int main()
{
	int i,j,k,x,y,z,t,l,c1,c2,d1,d2;
	scanf("%d%d",&n,&m);
	scanf("%d%d%d%d",&c1,&c2,&d1,&d2);
	c1--;
	c2--;
	d1--;
	d2--;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	x=1;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(s[i][j]=='.'&&!vis[i][j])
			{
				dfs(i,j,x);
				x++;
			}
		}
	}
	vector<vector<int> > ve(x);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(s[i][j]=='.')
			{
				for(k=max(0,i-2);k<=min(i+2,n-1);k++)
				{
					for(l=max(0,j-2);l<=min(j+2,m-1);l++)
					{
						if(vis[k][l]!=vis[i][j]&&vis[k][l])
						{
							if(!ma.count(mp(vis[k][l],vis[i][j]))&&!
							ma.count(mp(vis[i][j],vis[k][l])))
							{
								ve[vis[k][l]].push_back(vis[i][j]);
								ve[vis[i][j]].push_back(vis[k][l]);
								ma[mp(vis[i][j],vis[k][l])]=1;
							}
						}
					}
				}
			}
		}
	}
	queue<int> q;
	vector<int> vi(x);
	vector<int> d(x,1e8);
	q.push(vis[c1][c2]);
	vi[vis[c1][c2]]=1;
	d[vis[c1][c2]]=0;
	while(!q.empty())
	{
		x=q.front();
		q.pop();
		vi[x]=0;
		if(x==vis[d1][d2])
		{
			printf("%d",d[x]);
			return 0;
		}
		for(i=0;i<ve[x].size();i++)
		{
			if(d[x]+1<d[ve[x][i]])
			{
				d[ve[x][i]]=d[x]+1;
				if(!vi[ve[x][i]])
				{
					vi[ve[x][i]]=1;
					q.push(ve[x][i]);
				}
			}
		}
	}
	printf("-1");
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll a,b;cin >>a>>b;
    ll ans=0;
    ans+=a-1;
    if(a<=b)ans++;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <climits>
#include <complex>
#include <cmath>
#define fi first
#define se second
#define th second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, int> di;
typedef vector<int> vi;
typedef multiset<ll, greater<ll>>::iterator iit;
typedef pair<iit, iit> pvi;
typedef complex<double> cd;

const int maxN = 1e3 + 3, MOD = 1e9 + 9, LG = 21;
//NOTE: maxN>2^LG must be held, remember maxN is twice ur biggest polynom
/*
 HAB
 G C
 FED*/


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    string st;
    cin >> st;
    int tot = 700;
    for(char el: st){
        if(el != 'x') tot += 100;
    }
    cout << tot << '\n';
    
}


Measured memory_bytes: 256
def gcd(x, y):
  if y == 0:
    return x;
  else:
    return gcd(y, x % y)

N = int(input())

ans = 0

for a in range(1, N+1):
  for b in range(1, N+1):
    d = gcd(a,b)
    for c in range(1, N+1):
      ans += gcd(d,c)
      
print(ans)

Measured memory_bytes: 70808
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: [Int] -> Int
solve (x:xs) = snd $ foldl' go (x, 1) xs where
    go (currentMin, sum) num
        | currentMin < num =(currentMin, sum)
        | otherwise = (num, sum + 1)

main = do
    _ <- getLine
    nums <- readInts
    print $ solve nums


Measured memory_bytes: 4348
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
		int N, K;
		string S;
		cin >> N >> K >> S;
		for (int i = 0; i < N; i++) {
				if (i+1 == K) printf("%c", S[i] + 32);
				else printf("%c", S[i]);
		}
		printf("\n");
		return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var K int
	var S string
	fmt.Scan(&K, &S)
	if len(S) <= K {
		fmt.Println(S)
	} else {
		T := ""
		for i, c := range []rune(S) {
			if i < K {
				T += string(c)
			}
		}
		fmt.Println(T + "...")
	}
}


Measured memory_bytes: 1760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

typedef long long ll;
using namespace std;
 
 
ll GreatestCommonDivisor(ll p, ll q)
{
  if ( p < q ) swap( p, q);
  while ( true )
  {
    long long yo = p % q;
    if ( yo == 0 ) return q;
    p = q;
    q = yo;
  }
  return 1;
}
 
//最小公倍数
long long LeastCommonMultiple(ll a, ll b)
{
  return a / GreatestCommonDivisor(a,b) * b;
}
 
 
ll f(ll a)
{
  ll c = 0;
  while ( a % 2 == 0 && a > 0 )
  {
    ++c;
    a = a / 2;
  }
  return c;
}
 
int main()
{
  ll n, m;
  cin >> n >> m;
  
  vector<ll> a(n);
  for ( auto& ai : a) {
    cin >> ai;
    ai /= 2;
  }
 
 
  //ai に 含まれる2の数を計算（同じでないと半公倍数は存在せず）
  ll c = f( a[0] );
  for ( int i = 1; i < n; ++i )
  {
    if ( c != f(a[i])) { 
      cout << 0;
      return 0;
    }
  }
 
  //a の最小公倍数を計算
  ll lcm = a[0];
  for ( ll i = 1; i < n; ++i )
    lcm = LeastCommonMultiple(lcm, a[i]);
 
  // lcm * (2 p - 1) <= M を満たす最大のp
  cout << (m + lcm ) / lcm / 2;
  
  return 0;
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
   if ( (( max(a,b) - min(a,b) ) <=d && ( max(b,c) - min(b,c) ) <= d ) || (max(a,c)-min(a,c) <=d) ){
    cout << "Yes"  << endl;
   }
  else{
    cout << "No"  << endl;
  }

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

int cnt[100010], d_cnt[100010];
int N, M;
int r_cnt[100010];
int X[100010];
void solve() {
	cin >> N >> M;
	REP(i, N) {
		cin >> X[i];
		cnt[X[i]]++;
		r_cnt[X[i] % M]++;
	}
	REP(i, 100001) {
		int r = i % M;
		d_cnt[r] += cnt[i] / 2;
	}
	ll ans = 0;
	FOR(r, 1, M) {
		ans += min(r_cnt[r], r_cnt[M - r]);
		int mx = r, mn = M - r;
		if (r_cnt[r] < r_cnt[M - r])swap(mx, mn);
		int rem = max(r_cnt[r], r_cnt[M - r]) - min(r_cnt[r], r_cnt[M - r]);
		ans += min(rem / 2, d_cnt[mx]);
	}
	ans /= 2;
	ans += r_cnt[0] / 2;
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

const char NL = '\n';
const char SP = ' ';
#define loop(i, a, b) for (int i = a; i < b; i++)

int main () {
  ios_base::sync_with_stdio(false);
  int c = 0;
  string s;
  cin >> s;
  loop (i, 0, 3) {
    if (s[i] == 'R') {
      c++;
    }
  }
  if (c == 2 && s[1] == 'S') {
    cout << 1 << NL;
  }
  else {
    cout << c << NL;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;


long gcp(long a, long b){
    long tmp;
    if( b > a ){
        tmp = b;
        b = a;
        a = tmp;
    }
    while(1) {
        if( a % b == 0){
            return b;
            break;
        }
        tmp = b;
        b = a % b;
        a = tmp;
    }
}


int main(void) {

    long a, b, c, d;

    cin >> a >> b >> c >> d;

    long g = gcp(c, d);
    long l = d/g * c;
//  cout << "a:" << a << ", b:" << b << ", c:" << c << ", d:" << d << endl;
//  cout << "g:" << g << ", l:" << l << endl;

    long a1 = (a-1) - (a-1)/c - (a-1)/d + (a-1)/l;
    long b1 = b - b/c - b/d + b/l;

//  cout << a1 << " " << b1 << endl;
    cout << (b1 - a1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
#define mp make_pair

int n,m,a[1000005],ans,tmp,tmp2,tmp3;

int main() {
scanf("%d",&n);
FOR(i,0,n) scanf("%d",&a[i]);
sort(a,a+n);
FOD(i,n-2,0) {
  if (a[i]==a[i+1]) {
tmp=i-1; tmp2=a[i];
break;
}
}
FOD(i,tmp-1,0){
  if (a[i]==a[i+1]) {
tmp3=a[i];
break;
}
}
//printf("%d %d\n",tmp2,tmp);
printf("%lld\n",(LL)tmp2*tmp3);
return 0;
}

Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import qualified Data.Vector.Unboxed as UV

tmain=do
    let h = 1000
    let w = 1000
    let bx = replicate 1000 $ UV.replicate 1000 '.'
    print $ f w bx

main=do
    [h,w] <- map read.words<$>getLine
    bx <- map (UV.fromListN w.B.unpack).B.lines <$> B.getContents
    print $ f w bx

f w !bx = UV.last $ foldl' p (UV.cons 1 $ UV.replicate (w-1) (0::Int)) bx where
    p !v0 bl = UV.tail $ UV.scanl' m 0 $ UV.zip v0 bl
        where
            m b (u, f)
                | f == '#' = 0
                | otherwise = (b+u) `mod` (10^9+7)


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

int gcm(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcm(a%b,b);
}
signed main(){
  int n;
  cin >> n;
  vint D(n);
  rep(i,n) cin >> D[i];
  vint A(n);
  vint B(n);
  int nowa = D[0];
  int nowb = D[n-1];
  rep(i,n){
    nowa = gcm(nowa,D[i]);
    A[i] = nowa;
  }
  for(int i = n-1;i >= 0;i--){
    nowb = gcm(nowb,D[i]);
    B[i] = nowb;
  }
  int ans = 0;
  rep(i,n-2){
    ans = max(ans,gcm(A[i],B[i + 2]));
  }
  ans = max(ans,A[n-2]);
  ans = max(ans,B[1]);
  if(n == 2){
    cout << max(D[0],D[1]) << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 2560
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-17 22:47:46
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N;

bool ok(ll x)
{
  return (x * x <= N);
}

int main()
{
  cin >> N;
  ll ub = 1000000;
  ll lb = 1;
  while (ub - lb > 1)
  {
    ll t = (ub + lb) / 2;
    if (ok(t))
    {
      lb = t;
    }
    else
    {
      ub = t;
    }
  }
  cout << lb * lb << endl;
}

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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    REP(i,N) cin >> p[i];

    sort(ALL(p));

    int ans = 0;

    REP(i,K){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    string a,b;
    cin>>a>>b;

    ll n,sum=0;
    n=a.length();
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3856
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            decimal res = 0m;
            for (int i = 0; i < n; ++i)
            {
                var line = Console.ReadLine().Split();

                decimal c = decimal.Parse(line[0]);
                if (line[1] == "BTC")
                    c *= 380000.0M;

                res += c;
            }

            Console.WriteLine(res);
        }
    }

    public static class InputPlus
    {
        //整数型のリストに変換。
        public static List<T> ToList<T>(this string s)
        {
            var parseMethod = typeof(T).GetMethod("Parse", new[] { typeof(string) });
            var Parse = (Func<string, T>)Delegate.CreateDelegate(typeof(Func<string, T>), null, parseMethod);

            return s.Split(' ').Select(Parse).ToList();
        }

        //整数型に変換。
        public static T To<T>(this string s)
        {
            var parseMethod = typeof(T).GetMethod("Parse", new[] { typeof(string) });

            return (T)parseMethod.Invoke(null, new[] { s });
        }

        //出力文字列に変換。
        public static string MkString<T>(this IEnumerable<T> list)
        {
            return list.Aggregate(
                new System.Text.StringBuilder(),
                (a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b)
                ).ToString();
        }

    }
}


Measured memory_bytes: 13268
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        int ans = 0;

        for (int i = 0; i < a.Length; i++)
        {
            while (a[i] % 2 == 0)
            {
                a[i] /= 2;
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 12128