akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    string A,B; cin >> A >> B;
    if(A.size() > B.size()) cout << "GREATER" << endl;
    else if(A.size() < B.size()) cout << "LESS" << endl;
    else{
        if(A > B) cout << "GREATER" << endl;
        else if(A<B) cout << "LESS" << endl;
        else if(A==B) cout << "EQUAL" << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int h, w, i, j;
	while (1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			return 0;
		}
		else {
			for (i = 1;i <= h;i++) {
				for (j = 1;j <= w;j++) {
					if (i % 2 != 0) {
						if (j % 2 != 0) {
							printf("#");
						}
						else {
							printf(".");
						}
					}
					else {
						if (j % 2 != 0) {
							printf(".");
						}
						else {
							printf("#");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2572
Q,H,S,D=map(int,input().split())
N=int(input())

N*=4
T=[[1,4*Q,4*Q],[2,4*H,2*H],[4,4*S,S],[8,4*D,D/2]]
T.sort(key=lambda x: x[2])

ans=0
for t in T:
  ans+=N//t[0]*t[1]
  N%=t[0]
print(ans//4)

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


S = input().split()
S = list(S[0].split("/"))
Flag = False
if int(S[0]) < 2019:
    Flag = True
elif int(S[1]) <= 4:
    Flag = True
if Flag:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int a[3];
	for(int i=0;i<3;i++) cin>>a[i];
	sort(a,a+3,greater<int>());
	cout<<a[1]+10*(a[0])+a[2];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;
int main(){
long int a,i,n,m,d,e,f,g,h;
cin>>a;
long int b[a];
for(i=0;i<a;i++){
    cin>>b[i];
}
    for(n=0;n<a-1;n++){
        for(m=n+1;m<a;m++){
         if(b[n]<b[m]){
            d=b[n];
            b[n]=b[m];
            b[m]=d;
         }
        }
    }
    g=0;
    for(f=0;f<a;f++){
        g=g+b[f];
        }
    cout<<b[a-1]<<" "<<b[0]<<" "<<g<<endl;
    return 0;
    }

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int temp=0;
	char le;
	while(cin>>le)
	{
		if(le=='C') temp=1;
		if(temp==1&&le=='F') temp=2;
		if(temp==2) 
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
    cout<<"No"<<endl;
	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()

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, M;
ll k[20];
std::vector<ll> s[20];
ll p[20], ans;

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

  rep( i, M )
  {
    std::cin >> k[i];

    rep( j, k[i] )
    {
      ll x;
      std::cin >> x;
      --x;

      s[i].emplace_back( x );
    }
  }

  rep( i, M )
    std::cin >> p[i];

  rep( i, 1<<N )
  {
    bool fl = true;

    rep( j, M )
    {
      ll sum = 0;

      for( auto v : s[j] )
        sum += i>>v&1;

      fl &= sum%2 == p[j];
    }

    if( fl )
      ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


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

using namespace std;
int h,w;
vector<int> v1;
vector<int> v2;
char ban[150][150];

int main(){
  cin >> h >> w;
  REP(i,h){
    REP(j,w){
      cin >> ban[i][j];
    }
  }
  REP(i,h){
    int f = 0;
    REP(j,w){
      if(ban[i][j]=='#') f = 1;
    }
    if(f==1) v1.push_back(i);
  }
  REP(j,w){
    int f = 0;
    REP(i,h){
      if(ban[i][j]=='#') f = 1;
    }
    if(f==1) v2.push_back(j);
  }
  REP(i,v1.size()){
    REP(j,v2.size()){
      cout << ban[v1[i]][v2[j]];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

    int a,b;
    while(cin>>a>>b)
    {
        if(a<0&&b>0)
            cout<<"Zero"<<endl;
        else if(a>0&&b>0)
            cout<<"Positive"<<endl;
        else if(a==0||b==0)
            cout<<"Zero"<<endl;
        else
        {
            if((b-a)%2==0)
                cout<<"Negative"<<endl;
            else
                cout<<"Positive"<<endl;
        }
    }
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    int k=1;
    while(k!=2)
    {
        if(counter>1e5)break;
        counter++;
        k=arr[k-1];
    }
    if(counter>1e5)cout<<"-1"<<endl;
    else cout<<counter<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int m[11][11],n,i,j,t;
	for(;scanf("%d",&n)&&n!=0;)
	{
		memset(m,0,sizeof(m));
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=n;j++)
			{
				if(i<n&&j<n)
				{
					scanf("%d",&t);
					m[i][j]=t;
					m[i][n]+=t;
					m[n][j]+=t;
					m[n][n]+=t;
				}
				printf("%5d",m[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 616
s=input()
def che(s):
  for c in s:
    if c=='A' or c=='C' or c=='G' or c=='T':
      pass
    else:
      return 0
  return 1
mx=""
for i in range(0,len(s)+1):
  for j in range(0, len(s)+1):
    com=s[i:j]
    if len(com)==0:
      continue
    if len(mx)<len(com) and che(com):
      mx=com
print(len(mx))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 85;

int n, a[N];

int32_t main(){_
   
   cin>>n;

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

   int money = 1000;

// public int maxProfit(int[] prices) {
//     int profit = 0, i = 0;
//     while (i < prices.length) {
        
//         while (i < prices.length-1 && prices[i+1] <= prices[i]) i++;
//         int min = prices[i++]; 
        
//         while (i < prices.length-1 && prices[i+1] >= prices[i]) i++;
//         profit += i < prices.length ? prices[i++] - min : 0;
//     }
//     return profit;
// }

   int profit = 0, i = 0;
   while(i < n){
      while(i < n-1 and a[i+1] <= a[i]){
         ++i;
      }
      int min = a[i++];
      while(i < n-1 and a[i+1] >= a[i]){
         ++i;
      }
      if (i < n){
         int stocks = money / min;
         money -= stocks * min;
         money += stocks * a[i];
         ++i;
      }
   }

   cout<<money;

   return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> c = new ArrayList<>();
        List<Integer> s = new ArrayList<>();
        List<Integer> f = new ArrayList<>();
        for(int i = 0;i < n-1;i++){
            c.add(sc.nextInt());
            s.add(sc.nextInt());
            f.add(sc.nextInt());
        }
        for(int i = 0;i < n;i++){
            int t = 0;
            for(int j = i;j < n-1;j++){
                if(t <= s.get(j)){
                    t = s.get(j);
                }
                else if(t % f.get(j) == 0){
                }
                else{
                    t = t + f.get(j) - t % f.get(j);
                }
                t += c.get(j);
            }
            System.out.println(t);
        }
    }
}


Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ll n,m;
	cin>>n>>m;ll sum=0;
	vtr<ll> a(n+1);ll i;for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}ll cnt=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]*4*m>=sum)cnt++;
	}
	if(cnt>=m)cout<<"Yes";else cout<<"No";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
p = A[0]
ok = -1
v = []
for i in range(N):
    if len(v) == 2:
        break
    if ok == 1:
        v.append(A[i-1])
        ok = -1
    if A[i] == p:
        ok += 1
    else:
        p = A[i]
        ok = 0
if ok == 1:
    v.append(A[i-1])
if len(v) <=1:
    print(0)
else:
    print(v[0]*v[1])

Measured memory_bytes: 62704
#include <bits/stdc++.h>
const int N = 1e5 + 54;
int n, m;
namespace Tree {
	struct node { int u, v; } edge[N << 1];
	int head[N], v[N], col[N], cnt;
	long long sum, ans;
	inline void add(int x, int y) { edge[cnt].u = head[x], edge[cnt].v = y, head[x] = cnt++; }
	void dfs(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			col[y] = 1 - col[x], dfs(y, x);
		}
	}
	void solve(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			solve(y, x);
			v[x] += v[y];
		}
	}
	void SOLVE() {
		int x, y, i;
		memset(head, -1, sizeof head);
		for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), add(x, y), add(y, x);
		col[1] = 1, dfs(1, 0);
		for (i = 1; i <= n; ++i) {
			if (col[i]) v[i] = 1;
			else v[i] = -1;
			sum += v[i];
		}
		if (sum) {
			puts("-1");
			return;
		}
		solve(1, 0);
		for (i = 1; i <= n; ++i) ans += abs(v[i]);
		printf("%lld\n", ans);
	}
}

namespace BRT {
	struct Edge { int id, x, y; } E;
	struct node { int u, v; } edge[N << 1];
	int head[N], v[N], col[N], cnt, tot, p[N], vis[N], f[N];
	long long sum, ans;
	inline void add(int x, int y) { edge[cnt].u = head[x], edge[cnt].v = y, head[x] = cnt++; }
	void dfs(int x, int fa) {
		int i;
		vis[x] = 1;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			if (vis[y]) E.id = i, E.x = x, E.y = y;
			else col[y] = 1 - col[x], dfs(y, x);
		}
	}
	void solve(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa || i == E.id || (i ^ 1) == E.id) continue;
			solve(y, x), v[x] += v[y], f[x] += f[y];
		}
	}
	void SOLVE() {
		memset(head, -1, sizeof head);
		int x, y, i;
		for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), add(x, y), add(y, x);
		col[1] = 1, dfs(1, 0);
		for (i = 1; i <= n; ++i) {
			if (col[i]) v[i] = 1;
			else v[i] = -1;
			sum += v[i];
		}
		if (col[E.x] == col[E.y]) {
			if (abs(sum) & 1) {
				puts("-1");
				return;
			}
			v[E.x] -= sum / 2, v[E.y] -= sum / 2, ans += abs(sum / 2);
		} else {
			if (sum) {
				puts("-1");
				return;
			}
			f[E.x] = 1, f[E.y] = -1;
		}
		solve(1, 0);
		if (col[E.x] == col[E.y]) {
			for (i = 1; i <= n; ++i) ans += abs(v[i]);
			printf("%lld\n", ans);
			return;
		}
		for (i = 1; i <= n; ++i)
			if (f[i] == 0) ans += abs(v[i]);
			else p[++tot] = -v[i];
		p[++tot] = 0;
		std::sort(p + 1, p + tot + 1);
		int mid = p[(tot + 1) >> 1];
		for (i = 1; i <= tot; ++i) ans += abs(p[i] - mid);
		printf("%lld\n", ans);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	if (m == n - 1) Tree::SOLVE();
	else BRT::SOLVE();
}


Measured memory_bytes: 9344
N, M = map(int, input().split())
H = list(map(int, input().split()))
L = [1] * N
for i in range(M):
  A, B = map(int, input().split())
  if H[A-1] > H[B-1]:
    L[B-1] = 0
  elif H[A-1] < H[B-1]:
    L[A-1] = 0
  else:
    L[A-1] = 0
    L[B-1] = 0
print(len([i for i in L if i > 0]))

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

int main(){
    std::string S, T;
    std::cin >> S >> T;
    
    for(int i=0; i<S.size(); i++){
        if(S[i] != T[i]){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    std::cout << "Yes" << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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 pair<ll,ll> Pll;

int main(){
    int n,m,q; cin >> n >> m >> q;
    int a[q],b[q],c[q],d[q];
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    queue<vector<int>> que;
    for(int i=1;i<=m;i++){
        vector<int> v={i};
        que.push(v);
    }
    rep(i,n){
        int sz=que.size();
        rep(num,sz){
            vector<int> v=que.front(); que.pop();
            for(int j=v[v.size()-1];j<=m;j++){
                vector<int> v2=v;
                v2.pb(j);
                que.push(v2);
            }
        }
    }
    //vector<int> v=que.front();for(auto u:v)cout<<u<<" ";
    int ans=0;
    while(!que.empty()){
        vector<int> v=que.front(); que.pop();
        int res=0;
        rep(i,q){
            if(v[b[i]]-v[a[i]]==c[i]) res+=d[i];
        }
        chmax(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 18268
/* AtCoder Beginner Contest abc132
 * Problem C
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector <int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	return 0;
}


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


ll c(int n, vector<ll> a) {
  for(int i =0;i<n;i++) {
    a[i] -= i + 1;
  }

  sort(a.begin(), a.end());
  /*
  for(int i =0;i<n;i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  */

  int mid = n / 2;
  ll ans = 0;
  for(int i=0;i<n;i++) {
    ans += abs(a[i] - a[mid]);
  }

  return ans;
  
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0; i< n;i++) {
    cin >> a[i];
  }
  cout << c(n, a);
} 

Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 5000010
#define MOD 1000000007
typedef long long  ll;
 
using namespace std;
 
 
ll fac[MAX], finv[MAX], inv[MAX];
 
 
// n!を先に計算しておく
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
int main() {
	//ll X = 71, Y = 64;
	// ll X=4, Y=2;
	ll X, Y;
	cin >> X >> Y;
 
	ll k, l;
 
	k = (-X + (2 * Y % MOD)) % MOD;
	l = ((2 * X % MOD) - Y) % MOD;
 
  	if (((k) % 3 != 0) || ((l) % 3 != 0) || k < 0 || l < 0) {
		cout << 0 << endl;
		return 0;
	}
 
	k /= 3;
	l /= 3;
 
	COMinit();
	ll ans = fac[k + l] * (finv[k] * finv[l] % MOD) % MOD;
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 117376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s = S.length();
  int sc = s/2;
  int c = 0;
  for(int i = 0; i < sc; i++){
    string c1 = S.substr(i, 1);
    string c2 = S.substr(s-i-1, 1);
	if(c1 != c2){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);

    vector<pair<int, int>> pv;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }

    for (int i = 0; i < n; i++) {
        pv.push_back(make_pair(v[i] - c[i], i));
    }
    sort(pv.begin(), pv.end());

    int mx = 0;
    for (int i = 0 ; i < n; i++) {
        mx = max(mx, mx + pv[i].first);
    }
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 256
/* ex 7_1
   B30095   */

#include <stdio.h>

/* a 2d point */
typedef struct{
    int x;
    int y;
}Point;

Point next_square_point(Point p1, Point p2);

int main(void){

    Point p1, p2, p3, p4;

    scanf("%d %d %d %d", &p1.x, &p1.y, &p2.x, &p2.y);
    
    p3 = next_square_point(p1, p2);
    p4 = next_square_point(p2, p3);

    printf("%d %d %d %d", p3.x, p3.y, p4.x, p4.y);

    return 0;
}

/* get next point of a sqaure in counterclockwise */
Point next_square_point(Point p1, Point p2){
    Point p3, vect;

    // vector from p1 to p2
    vect.x = p2.x - p1.x;
    vect.y = p2.y - p1.y;

    // rotate the vector 90 degrees and add it to p2
    p3.x = p2.x - vect.y ;
    p3.y = p2.y + vect.x;

    return p3;
}


Measured memory_bytes: 1712
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		var x = 1;
		while (true)
		{
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var a = input[0];
			var b = input[1];

			if (a == 0 && b == 0) break;
			if (a > b)
			{
				var tmp = a;
				a = b;
				b = tmp;
			}
			System.Console.WriteLine(a + " " + b);
		}
	}
}


Measured memory_bytes: 18376
# ABC141 D -Powerful Discount Tickets

import heapq
import math

N, M = map(int,input().split())

A = [-int(n) for n in input().split()]

heapq.heapify(A)


for i in range(M):
    heapq.heappush(A, math.ceil(heapq.heappop(A)/2))

print(-sum(A))

Measured memory_bytes: 14536
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string S, T;
  cin >> S >> T;
  if (S.size() < T.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  set<string> ans;
  for (int i = 0; i < S.size() - T.size() + 1; i++) {
    bool ok = true;
    for(int j = 0; j < T.size(); j++) {
      if (S[i + j] != '?' && S[i + j] != T[j]) {
        ok = false;
      }
    }
    if (ok) {
      string s_ = S;
      for(int j = 0; j < T.size(); j++) {
        s_[i + j] = T[j];
      }
      for(int j = 0; j < s_.size(); j++) {
        if (s_[j] == '?') s_[j] = 'a';
      }
      ans.insert(s_);
    }
  }
  if (ans.empty()) {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << *ans.begin() << endl;
  }
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long N;
    cin >> N;
    long long mx = 0;
    long long temp, answer;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            if (i <= (N / i)) {
                temp = mx;
                mx = max(to_string(N / i).length(), to_string(i).length());
                if (temp == 0) {
                    answer = mx;
                } else {
                    answer = min(mx, answer);
                }
            } else {
                break;
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
  ll a,b;
  cin >> a >> b;
  ll m=min(a,b);
  ll M=max(a,b);
  if(m==1){
    cout<<1<<endl;
    return 0;
  }
  if(m==2){
    if(M%2==0){
      cout<<2<<endl;
      return 0;
    }
    else{
      cout<<1<<endl;
      return 0;
    }
  }
  if(m==3){
    if(M%3==0){
      cout<<2<<endl;
      return 0;
    }
    else{
      cout<<1<<endl;
      return 0;
    }
  }
  
  vector< ll > vec;
  for(ll i = 1; i * i <= m; i++) {
    if(m % i == 0) {
      vec.push_back(i);
      if(i * i != m) vec.push_back(m / i);
    }
  }
  sort(begin(vec), end(vec));
  
 
  int cnt=0;
  rep(i,vec.size()){
    if(IsPrime(vec[i])){
      if(M%vec[i]==0)cnt++;
    }
  }
  cnt++;
  cout<<cnt<<endl;
}
  



Measured memory_bytes: 384
import collections
N = int(input())

a = collections.Counter(list(map(int,input().split())))
#a = sorted(a.items(), key=lambda x: -x[0],reverse=True)
#for k, v in sorted(a.items(), key=lambda x: -x[0]):pass
a = sorted(a.items(), key=lambda x:x[0],reverse=True)

#print(a)

cnt = 0
num = []
n = 0
for i,v in a:
    if 4 <= v:
        n = max(n,(i*i))
    if 2 <= v:
        num.append(i)
        cnt += 1
    if 2 == cnt:
        break
if cnt == 2:
    print(max(num[0]*num[1],n))
else:
    print(n)

Measured memory_bytes: 26300
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

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

class Dice{
    public:
    int num[6];
    void role(int a){
        if(a==1){
                int temp = num[0];
                num[0] = num[3];
                num[3] = num[5];
                num[5] = num[1];
                num[1] = temp;
        }
        if(a==2){
                int temp = num[0];
                num[0] = num[4];
                num[4] = num[5];
                num[5] = num[2];
                num[2] = temp;
        }
        if(a==3){
                int temp = num[0];
                num[0] = num[1];
                num[1] = num[5];
                num[5] = num[3];
                num[3] = temp;
        }
        if(a==4){
                int temp = num[0];
                num[0] = num[2];
                num[2] = num[5];
                num[5] = num[4];
                num[4] = temp;
        }
    }
};

int getright(int a,int b){
    int t[10][10];
    t[3][5]=1;
    t[5][4]=1;
    t[4][2]=1;
    t[2][3]=1;

    t[6][3]=2;
    t[3][1]=2;
    t[1][4]=2;
    t[4][6]=2;

    t[2][6]=3;
    t[6][5]=3;
    t[5][1]=3;
    t[1][2]=3;

    t[1][5]=4;
    t[5][6]=4;
    t[6][2]=4;
    t[2][1]=4;

    t[3][6]=5;
    t[6][4]=5;
    t[4][1]=5;
    t[1][3]=5;

    t[5][3]=6;
    t[3][2]=6;
    t[2][4]=6;
    t[4][5]=6;

    return t[a][b];
}

int main(){

    TOP:;

    Dice c[111];

    int n;
    cin>>n;

    if(n==0)return 0;

    rep(i,n){
        int a,b;
        cin>>a>>b;

        c[i].num[0]=a;
        c[i].num[1]=b;
        c[i].num[2]=getright(a,b);
        c[i].num[3]=(7-c[i].num[1]);
        c[i].num[4]=(7-c[i].num[2]);
        c[i].num[5]=(7-c[i].num[0]);
    }

    int height[400][400]={0};
    int face[400][400]={0};

    rep(i,400)rep(j,400)face[i][j]=-1;

    rep(i,n){
        int posx=200,posy=200;

        while(1){
            int act[6]={0};

            int maxi=-1;
            int maxp=-1;

            reps(j,1,4+1){
                int dnum = c[i].num[j];
                int nx = posx+dx[j];
                int ny = posy+dy[j];

                if(dnum>maxi && dnum>=4 && height[posx][posy]>height[nx][ny]){
                    maxi=dnum;
                    maxp=j;
                }
            }
            if(maxp==-1)break;

            c[i].role(maxp);
            posx+=dx[maxp];
            posy+=dy[maxp];
        }

        height[posx][posy]++;
        face[posx][posy]=c[i].num[0];
    }

/*
    reps(i,-10,10+1){
        reps(j,-10,10+1){
            printf("%2d ",height[i+200][j+200]);
        }puts("");
    }puts("");

    reps(i,-10,10+1){
        reps(j,-10,10+1){
            printf("%2d ",face[i+200][j+200]);
        }puts("");
    }puts("");
*/

    int ans[7]={0};
    rep(i,400){
        rep(j,400){
            if(face[i][j]!=-1)ans[face[i][j]]++;
        }
    }

    reps(i,1,6+1){
        printf("%d",ans[i]);
        if(i!=6)printf(" ");
    }puts("");


    goto TOP;
}

Measured memory_bytes: 2412
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int k;
  int a[5];
  vector<int> r;
  for(int i=0;i<5;i++){
    cin >> a[i];
    if(a[i]%10!=0) r.push_back(a[i]%10); 
  }
  
  int ans = 0;
  for(int i=0;i<5;i++){
    if(a[i]%10!=0) ans += (a[i]/10)*10 + 10;
    else ans += a[i];
  }

  if(!r.empty() ){
    ans -= (10 - *min_element(r.begin(), r.end()));
  }

  cout << ans <<endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 3010, mod = 998244353;
int n, s, a[maxn];
long long dp[maxn][maxn];
int main()
{
	scanf("%d%d", &n, &s);
	for(int i = 1; i <= n; i++)
		scanf("%d", a + i);
	dp[0][0] = 1ll;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= s; j++)
			dp[i][j] = dp[i - 1][j] * 2ll % (long long)mod;
		for(int j = s; j >= a[i]; j--)
			dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % (long long)mod;
	}
	printf("%d\n", dp[n][s]);
	return 0;
}

Measured memory_bytes: 74404
# D - Knight

MOD = 10 ** 9 + 7
x, y = map(int, input().split())

n, r1 = divmod(2 * y - x, 3)
m, r2 = divmod(2 * x - y, 3)

def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n - r < r:
        r = n - r
    for i in range(1, r + 1):
        Y = Y * i % MOD
        X = X * (n - i + 1) % MOD
    Y = pow(Y, MOD - 2, MOD)
    return X * Y

if r1 != 0 or r2 != 0:
    print(0)
else:
    print(com(n + m, n) % MOD)


Measured memory_bytes: 9068
# E - Gluttony

import numpy as np

# np.arrayに変換する場合はsortedを使うよりnp.sortを使う方が少し速い
N, K = map(int, input().split())
A = np.sort(np.array((list(map(int, input().split())))))
F = np.sort(np.array(((list(map(int, input().split()))))))[::-1]

lower = 0
upper = A[-1] * F[0]

# 達成可能な最高成績を二分探索する
while lower <= upper:
    result = (lower + upper) // 2
    # resultを達成可能なAと実際のAの差異の総和が必要な修行コスト
    # np.arrayの和を求める場合、sum(array)よりarray.sum()の方が速い(使わないとTLE)
    if np.clip(A - result//F, 0, None).sum() <= K:
        ans = result
        upper = result - 1
    else:
        lower = result + 1

print(ans)

Measured memory_bytes: 38840
def main():

    N = int(input())
    A = list(map(int, input().split()))
    tot = sum(A)

    ans = float('inf')
    l, r = 0, tot
    for i in range(N):
        l += A[i]
        r -= A[i]
        ans = min(ans, abs(l-r))
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 26764
N, M = map(int, input().split())
src = [list(map(int, input().split())) for _ in range(M)]


lst_city = [[] for _ in range(N+1)]
for i, (p, y) in enumerate(src):
    lst_city[p].append((y, i))


ans = [None] * M
for pi, cities in enumerate(lst_city):
    for order, (y, i) in enumerate(sorted(cities)):
        ans[i] = str(pi).zfill(6) + str(order + 1).zfill(6)
print(*ans, sep="\n")

Measured memory_bytes: 92248
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=1000005, inf=1e18;
void solve(){
	string s;
	cin>>s;
	if(s[1]=='B')s[1]='R';
	else
		s[1]='B';
	cout<<s;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
int n,a[100010][3];
int dp[100010][3];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		rep(j,3){
			rep(k,3){
				if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	return 0;
}


Measured memory_bytes: 4992
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

int n, a[100], dp[100001], k;

int fn (int s) {
	if (dp[s] != -1) return dp[s];
	dp[s] = 0;
	for (int i=0; i<n; ++i)
		if (s >= a[i] && !fn(s-a[i])) {
			dp[s] = 1;
			break;
		}
	return dp[s];
}

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> k;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	if (fn(k))
		cout << "First\n";
	else cout << "Second\n";
	return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<stdlib.h>
long X, K, D;
int main(){
	scanf("%ld%ld%ld", &X, &K, &D);
	X = labs(X);
	if(X/D >= K){
		printf("%ld\n", X - K*D);
		return 0;
	}
	K = (K - (X/D)) % 2;
	X -= X / D * D;
	if(K)X = labs(X - D);
	printf("%ld\n", X);
	return 0;
}


Measured memory_bytes: 1704
a,b = input().split()
a = int(a)
b = int(b)


S = a*(a-1)/2
F = b*(b-1)/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))
        


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int F = 9;

int main()
{
    int s, g, n;  cin >> n;
    rep(k, n)
    {
        vector<int> ans;
        cin >> s >> g;
        if(s <= 5 && g <= 5)//OK
        {
            if( s < g)for(int j = s;j <= g;j++) ans.push_back(j);

            if(s > g)for(int j = s; j >= g;j--) ans.push_back(j);
        }
        if( s>5 && g <= 5)
        {
            for(int j = s; j<= F;j++) ans.push_back(j);

            for(int j = 5; j >= g;j--) ans.push_back(j);
        }
        if(s <= 5 && g> 5)//OK
            for(int j = s; j<=g;j++) ans.push_back(j);

        if(s >5 && g > 5)
        {
            if( s < g)for(int j = s; j<=g;j++) ans.push_back(j);
            if( s > g )
            {
                for(int j = s; j<=F;j++) ans.push_back(j);
                for(int j = 5; j>0;j--) ans.push_back(j);
                for(int j = 0;j <=g;j++) ans.push_back(j);
            }
        }

        rep(j,ans.size()){ cout << ans[j]; if(j == ans.size()-1) break; cout << " ";}
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#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; }

const int MAX_N = 200005;
const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
};

istream& operator>>(istream& is, const mint& a){return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP{
    mint dp;
    int t;
    DP(mint dp = 1, int t = 0):dp(dp), t(t){}
    DP& operator+=(const DP& a){
        dp *= a.dp;
        dp *= comb(t+a.t, t);
        t += a.t;
        return *this;
    }
    DP operator-(const DP& a) const{
        DP res(*this);
        res.t -= a.t;
        res.dp /= comb(res.t+a.t, res.t);
        res.dp /= a.dp;
        return res;
    }
    DP addRoot() const{
        DP res(*this);
        res.t++;
        return res;
    }
};

DP dp[MAX_N];

void dfs(int v, int p = -1){
    for(int u : to[v]){
        if(u == p) continue;
        dfs(u, v);
        dp[v] += dp[u].addRoot();
    }
}

void bfs(int v, int p = -1){
    for(int u : to[v]){
        if(u == p) continue;
        DP d = dp[v] - dp[u].addRoot();
        dp[u] += d.addRoot();
        bfs(u, v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    bfs(0);
    rep(i,n){
        cout << dp[i].addRoot().dp << endl;
    }
    return 0;
}

Measured memory_bytes: 20224
import math
n, p, *a = map(int, open(0).read().split())


def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


memo = [0, 0]
for i in range(n):
    memo[a[i] % 2] += 1
# p == 0


ans = 0
if p == 0:
    for i in range(0, memo[1] + 1, 2):
        ans += c(memo[1], i) * pow(2, memo[0])
else:
    for i in range(1, memo[1] + 1, 2):
        ans += c(memo[1], i) * pow(2, memo[0])
# p == 1
print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N,M;
int X[100100];
int cnt[100100];
int sz[100100];
int sol[100100];
int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> X[i];
    cnt[X[i]]++;
  }
  for(int i=0;i<=100000;i++){
    sz[i%M] += cnt[i];
    sol[i%M] += (cnt[i]%2);
  }
  int ans = 0;
  for(int i=1;i<(M+1)/2;i++){
    // cout << i << ' ' << M-i << endl;
    if(sz[i]>sz[M-i]){
      swap(sz[i],sz[M-i]);
      swap(sol[i],sol[M-i]);
    }
    ans += sz[i];
    int w = max(0,sol[M-i]-sz[i]);
    ans += (sz[M-i]-sz[i]-w)/2;
  }
  ans += sz[0]/2;
  if(M%2==0)ans += sz[M/2]/2;
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    long N, M;
    cin >> N >> M;
    long ans = 0;
    if(N == 1 && M > 1){
        ans = M-2;
    }else if(N > 1 && M == 1){
        ans = N-2;
    }else if(N > 1 && M > 1){
        ans = (N-2) * (M-2);
    }else{
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,*xyh = map(int,open(0).read().split())
a = sorted([(xyh[i*3],xyh[i*3+1],xyh[i*3+2]) for i in range(n)],key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    dh = abs(a[0][0]-i)+abs(a[0][1]-j)+a[0][2]
    for x,y,h in a[1:]:
      if h != max(dh-abs(x-i)-abs(y-j),0):
        break
    else:
      print(i,j,dh)
      exit()

Measured memory_bytes: 9148
N,M,K = gets.chomp.split.map(&:to_i)
MOD = 998244353

# nCk 前処理メモ化（N:nの最大値,MOD が必要）
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]

(2..N).each do |i|
  @fac[i] = @fac[i - 1] * i % MOD
  @inv[i] = MOD - @inv[MOD % i] * (MOD / i) % MOD
  @finv[i] = @finv[i - 1] * @inv[i] % MOD
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

ans = 0
0.upto(K) do |k|
  ans += (M * (M-1).pow(N-1-k, MOD) * nCk(N-1, k)) % MOD
end
p ans % MOD


Measured memory_bytes: 19148
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=set(a)
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in b:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))

Measured memory_bytes: 13192
s = input()
l = input()
     
count = 0
ind = -1
if set(l).issubset(set(s)):
    for i in range(len(l)):
        ind = s.find(l[i], ind+1)
        if ind == -1:
            count += 1
            ind = s.find(l[i], ind+1)
    print(count*len(s) + ind+1)
 
else:
    print(-1)

Measured memory_bytes: 3316
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        while (true) {
            if (isPrime(x)) {
                System.out.println(x);
                return;
            }
            x++;
        }
    }
    public static boolean isPrime(int x) {
        for (int i = 2; i * i <= x; i++) {
            if (x % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  if (n == 1) {
    cout << k << '\n';
    return 0;
  } else if (n == 2) {
    cout << (long long)k * (k - 1) % MOD << '\n';
    return 0;
  }
  if (k <= 2) {
    cout << 0 << '\n';
    return 0;
  }
  vector<vector<int> > graph(n);
  REP(i, n - 1) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  long long ans = 1;
  function<void(int, int, int, int)> dfs = [&](int par, int ver, int two, int one) {
    if (k - (two + 1) <= 0) {
      cout << 0 << '\n';
      exit(0);
    }
    (ans *= k - (two + one)) %= MOD;
    int plus = 0;
    for (int v : graph[ver]) if (v != par) {
      dfs(ver, v, one + plus, 1);
      ++plus;
    }
  };
  dfs(-1, 0, 0, 0);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int num;
	int cnt=0;
	for(int i=0; i<N; i++){
		cin >> num;
		if(num%2){
			cnt++;
		}
	}

	if(cnt%2==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long sum = 0;
		int N = sc.nextInt();
		long A[] = new long[N+1];
		long result[] = new long[N+1];
		for (int i=0;i<=N;i++) {
			A[i] = sc.nextLong();
		}
		result[N]= A[N];
		for (int i=N;i>=1;i--) {
			result[i-1]= A[i-1]+result[i];
		}
		long tempPoint=1;
		for (int i=0;i<=N;i++) {
			if (tempPoint<A[i]) {
				System.out.println(-1);
				return ;
			}
			if (tempPoint<result[i]) {
				sum +=tempPoint;
			} else {
				sum +=result[i];
			}
			tempPoint-=A[i];
			if (tempPoint<Long.MAX_VALUE/4) {
				tempPoint*=2;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 61820
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    int n,k;
    R(n,k);
    W(n-k+1);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3788
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextLong()
    val y = sc.nextLong()
    println(problem008a(x, y))
}

fun problem008a(x: Long, y: Long): Long {
    var min = Long.MAX_VALUE
    if (x <= y) min = Math.min(min, y - x)
    if (-x <= y) min = Math.min(min, y + x + 1)
    if (x <= -y) min = Math.min(min, -y - x + 1)
    if (-x <= -y) min = Math.min(min, -y + x + 2)
    return min
}

Measured memory_bytes: 36352