akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,j,ans,m;
    cin >> n >> m;
    ans=(n*(n-1))/2;
    ans+=(m*(m-1))/2;
    cout << ans ;
    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    A.append(CA[1:])

INF = 10**10
ans = INF
for x in range(1<<N):
    cost=0
    R=[0]*M
    for i in range(N):
        if (x>>i)&1: continue
        cost+=C[i]
        for m,a in enumerate(A[i]):
            R[m]+=a

    if min(R)>=X:
        ans=min(ans,cost)

print(-1 if ans==INF else ans)


Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u)a--;
  else b--;
  cout<<a<<" "<<b;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    int k;
    cin>>n;
    cin>>k;
    int h[n+1];
    repA(i,1,n) cin>>h[i];
    ll dp[n+1];
    dp[0]=INF;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(ll i=3;i<=n;i++)
    {
        dp[i]=INF;
        for(ll j=1;j<=k && j<i;j++)
        {
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

        }
        //dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<'\n';
    return 0;
}


Measured memory_bytes: 1408
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int x;
    scan(x);

    if (x == 3 || x == 5 || x == 7) {
        writeln("YES");
    }
    else {
        writeln("NO");
    }
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

using namespace std;
const int maxn = 200000 + 10;

int a[maxn], b[maxn];
int n;

int main(int argc, char *argv[])
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n);
    
    for (int i = 0; i < n; ++i)
    {
        if (b[i] == a[n - 1])
        {
            cout << a[n - 2] << endl;
        }
        else
        {
            cout << a[n - 1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(void){
int n[1000],tmp,i,j;

for(i = 1; i<=5; i++){
scanf("%d",&n[i]);
}

for(i=1;i<=5;i++){
for(j=i;j<=5;j++){
if(n[i]<n[j]){
tmp=n[i];
n[i]=n[j];
n[j]=tmp;
}
}
}
for(i = 1; i<=4; i++){
printf("%d ",n[i]);
}
printf("%d\n",n[5]);
return 0;
}



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

int main()
{
	int N, D, X;
	cin >> N >> D >> X;
	while (N--) {
		int A;
		cin >> A;
		X += (D + A - 1) / A;
	}
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

const bool IsEvenString(const std::string &S, const int length)
{
    for (int i = 0; i < length / 2; ++i)
    {
        if (S[i] != S[length / 2 + i]) return false;
    }
    return true;
}

int main()
{
    string S;
    cin >> S;
    for (int length = static_cast<int>(S.size()); length > 0;)
    {
        S.pop_back();
        S.pop_back();
        length -= 2;
        if (IsEvenString(S, length))
        {
            cout << length << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn=5005;
int n;
char s[Maxn],t[Maxn];
int pool1[2*Maxn],pool2[2*Maxn],*a=pool1+Maxn,*b=pool2+Maxn;
int main(){
    cin>>n>>(s+1)>>(t+1);
    int cnta=0,cntb=0,ans=INT_MAX;
    if(s[1]!=t[1])a[++cnta]=0;
    for(int i=1;i<n;i++)
        if(s[i]!=s[i+1])
            a[++cnta]=i;
    for(int i=1;i<n;i++)
        if(t[i]!=t[i+1])
            b[++cntb]=i;
    for(int i=cnta+1;i<=n;i++)a[i]=n;
    for(int i=cntb+1;i<=n;i++)b[i]=n;
    for(int i=-cnta;i<=cntb;i++){
        if(i&1)continue;
        int sum=0;
        for(int delta=-n;delta<=n;delta++){
            int pos=i+delta;
            if(pos>n)sum+=n-b[delta];
            else if(pos<-n)sum+=b[delta];
            else sum+=abs(a[pos]-b[delta]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, a[SIZE], sum = 0;

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", a+i);
    sum += a[i];
  }

  int ans, diff = INF;
  
  for(int i=0;i<n;i++){
    if(diff > abs(sum - a[i]*n)){
      ans = i;
      diff = abs(sum - a[i]*n);
    }
  }

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



Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    a=inpl()
    ans=1
    num=[0,0,0]
    for i in range(n):
        cnt=0
        index=0
        for j in range(3):
            if num[j]==a[i]:
                cnt+=1
                index=j
        num[index]+=1
        if cnt==1:
            ans=ans%mod
            continue
        elif cnt==2:
            ans=(ans*2)%mod
        elif cnt==3:
            ans=(ans*3)%mod
        else:
            print(0)
            return
    print(ans%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 55400
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a-b > 0) System.out.println("a > b");
    else if (a-b == 0) System.out.println("a == b");
    else System.out.println("a < b");
  }
}



Measured memory_bytes: 26356
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    int batu=0;
    REP(i,n){
        if(s[i]=='x') batu++;
    }
    if(batu>=8) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		System.out.println(Math.min(n*a,b));
	}
}


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

typedef long long ll;

ll a, b, c, d, i;
 
int main() {
	cin >> a >> b >> c;
	d = __gcd(a, b);
	for (i = d; i >= 1; --i) {
		if (d % i == 0) if (--c == 0) break;
	}
	cout << i;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int n;cin>>n;
    vi a(n);
    int s=0;
    rep(i,n){
        cin>>a[i];
        s ^= a[i];
    }
    
    rep(i,n){
        printf("%d%s", (s^a[i]), i==n-1?"\n":" ");
    }
    
    return 0;
}

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


using namespace std;


using ll = long long;


int main(void) {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i <= N + 1; i++) {
        ll maximum, minimum;
        maximum = minimum = 0;
        maximum = i * (N + (N - (i - 1))) / 2;
        minimum = i * (0 + i - 1) / 2;
        ans = (ans + (maximum - minimum + 1)) % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 1024 * 8;

/* typedef */

typedef unsigned char uchar;
typedef vector<uchar> vuc;

int gcd(int m, int n);

struct Rhythm {
  int m;
  vuc bytes;

  Rhythm() { m = 1; bytes.push_back(0); }
  Rhythm(string rstr) {
    m = rstr.length() / 2;
    bytes.assign(m, 0);
    for (int i = 0; i < m; i++) {
      uchar c0 = rstr[i * 2], c1 = rstr[i * 2 + 1];
      bytes[i] = ((c0 - '0') << 4) | (c1 - '0');
    }
    normalize();
  }

  void normalize() {
    for (int k = 2; k <= m; k++) {
      if (m % k) continue;

      bool ok = true;
      for (int i = 0; ok && i < m; i++)
	if ((i % k) && bytes[i]) ok = false;
      if (ok) {
	m /= k;
	for (int i = 0; i < m; i++) bytes[i] = bytes[i * k];
	k--;
      }
    }
  }

  void mul(int k) {
    vuc bytes0(bytes);
    bytes.assign(m * k, 0);

    for (int i = 0; i < m; i++) bytes[i * k] = bytes0[i];
    m *= k;
  }

  void merge(Rhythm& r0) {
    int g = __gcd(m, r0.m);
    int lcm = m * r0.m / g;

    mul(lcm / m);
    r0.mul(lcm / r0.m);
    for (int i = 0; i < m; i++) bytes[i] |= r0.bytes[i];

    normalize();
  }
  
  void print(bool flag = false) {
    if (flag) {
      printf("(%d)", m);
      for (int i = 0; i < m; i++)
	if (bytes[i]) printf("%d ", i);
    }
    for (int i = 0; i < m; i++) printf("%02X", (int)bytes[i]);
    putchar('\n');
  }
};

/* global variables */

/* subroutines */

int gcd(int m, int n) {
  if (m < n) swap(m, n);

  while (n > 0) {
    int r = m % n;
    m = n;
    n = r;
  }

  return m;
}

/* main */

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

  for (int cnt = 1; cnt <= tn; cnt++) {
    int n;
    cin >> n;
    //if (cnt == 33) cout << n << endl;
    
    Rhythm rt;
    //rt.print();

    for (int i = 0; i < n; i++) {
      string str;
      cin >> str;

      Rhythm ri(str);
      //if (cnt == 33) ri.print();
      if (false) {
	cout << "rt = ";
	rt.print(true);
	cout << "ri = ";
	ri.print(true);
      }

      if (rt.m < MAX_M) {
	rt.merge(ri);
	//cout << "merged to => "; rt.print(true);
      }
    }

    if (rt.m == 0 || rt.m > 1024)
      cout << "Too complex." << endl;
    else
      rt.print();
  }

  return 0;
}

Measured memory_bytes: 2708
from bisect import *
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
print(sum([bisect_left(a,i)*(n-bisect_right(c,i)) for i in b]))

Measured memory_bytes: 22720
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

int main(void)
{
    int x[5];
    rep(i, 5){
        cin >> x[i];
    }

    rep(i, 5){
        if (x[i] != i+1){
            cout << i + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int ceil(int n, int d) {
	return (n + d - 1) / d;
}

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;

	int ans = min(ceil(n, a)*b, ceil(n, c)*d);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint n, m;
llint x[100005];
vector<llint> vec[100005];

llint calc(vector<llint> &vec)
{
	sort(vec.begin(), vec.end());
	llint ret = 0;
	for(int i = 0; i < vec.size(); i++){
		if(i+1 >= vec.size()) break;
		if(vec[i] == vec[i+1]){
			ret++;
			i++;
		}
	}
	return ret;
}

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> x[i];
		vec[x[i]%m].push_back(x[i]);
	}
	
	llint ans = 0;
	for(int i = 0; i <= m/2; i++){
		llint x = (m-i)%m;
		if(i == x){
			ans += vec[i].size()/2;
			continue;
		}
		if(vec[i].size() > vec[x].size()) swap(vec[i], vec[x]);
		ans += vec[i].size();
		ans += min(((llint)vec[x].size() - (llint)vec[i].size()) / 2, calc(vec[x]));
	}
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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 long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        int n,h,w;
        cin >> n >> h >> w;

        int ans = (n + 1 - h) * (n + 1 - w);

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
bool used[10] = {false};
 
int main(){
    string n;
    int k;
    cin >> n >> k;
    rep(i, k){
        int d;
        cin >> d;
        used[d] = true;
    }
    string ban, ok;
    rep(i, 10){
        if(used[i])ban.push_back('0'+i);
        else ok.push_back('0'+i);
    }
 
    rep(i, n.size())if(ban.find(n[i])!=string::npos){
        char tmp = n[i];
         while(ban.find(n[i])!=string::npos){
             if(n[i]=='9')n[i]='0';
             else n[i]++;
         }
        if(n[i] > tmp){
            for(int j=i+1; j<n.size(); ++j)n[j]=ok.front();
            break;
        }
        else {
            for(int j=i-1; j >=0; --j){
                char tmp = n[j];
                if(n[j] == '9')n[j]='0';
                else n[j]++;

                while(ban.find(n[j])!=string::npos){
                    if(n[j]=='9')n[j]='0';
                    else n[j]++;
                }
                if(n[j] > tmp){
                    for(int l=j+1; l < n.size(); ++l)n[l]=ok.front();
                    break;
                }
            }
            string  ans = "";
            rep(j, n.size()+1)ans+=ok.front();
            if(ans[0] == '0')ans[0] = ok[1];
            cout << ans << endl;
            return  0;
        }
    }
 
    cout << n << endl;
 
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N--) {
    int x; cin >> x;
    ans += min(2*x, abs(2*(K-x)));
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=4010,P=924844033;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,m,i,j,sm,ed[N],f[N][N][2],v[N][2],fac[N],ans;
int dfs(int x,int k){
	v[x][k]=1;
	if(x+m<=n)return dfs(x+m,k^1)+1;
	else return 1;
}
inline void A(int&x,int y){(x+=y)%=P;}
int main(){
	n=read();m=read();
	for(i=1;i<=n;i++)
	for(j=0;j<2;j++)if(!v[i][j])
	sm+=dfs(i,j),ed[sm]=1;
	f[1][0][0]=1;
	for(i=1;i<=sm;i++)
	for(j=0;j<=n;j++){
		A(f[i+1][j][0],f[i][j][0]);
		A(f[i+1][j][0],f[i][j][1]);
		if(!ed[i])A(f[i+1][j+1][1],f[i][j][0]);
	}
	fac[0]=1;
	for(i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%P;ans=fac[n];
	for(i=1;i<=n;i++){
		j=1ll*fac[n-i]*f[sm+1][i][0]%P;
		if(i&1)j=P-j;A(ans,j);
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124672
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
using mint=modint998244353;
struct S{
    ll t,o,l;
};
using P=bool;
S op(S a,S b){
    return {a.t+b.t+a.l*b.o,a.o+b.o,a.l+b.l};
}

S e(){
    return {0,0,0};
}

S mp(P f,S x){
    if(f) return {x.o*x.l-x.t,x.l,x.o};
    return x;
}

P cp(P f,P g){
    return f?!g:g;
}

P id(){
    return false;
}

void solve(){
    int n,q;
    cin>>n>>q;
    vector<S> a;
    a.reserve(n);
    {
        int A;
        fr(i,n){
            cin>>A;
            if(A) a.push_back(S{0,0,1});
            else a.push_back(S{0,1,0});
        }
    }
    lazy_segtree<S,op,e,P,mp,cp,id> sg(a);
    int t,l,r;
    fr(_,q){
        cin>>t>>l>>r;
        if(t-1) cout<<sg.prod(l-1,r).t<<'\n';
        else sg.apply(l-1,r,true);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 20388
#include<iostream>
using namespace std;
int main(){
 int k,s;
 cin>>k>>s;
 int cnt=0;
 for(int i=0;i<=k;i++){
  for(int j=0;j<=k;j++){
   if(s-(i+j)<=k&&s-(i+j)>=0){
    cnt++;
   }
  }
 }
 cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string w; cin >> w;
    map<char, ll> cnt;
    rep(i, w.size()) cnt[w[i]]++;
    bool ans = true;
    for(auto p: cnt) if(p.second&2 != 0) ans = false;
    (ans) ? Yes() : No();
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r; // 旧レーティング
  int g; // 新レーティング;
  int p; // パフォーマンス
  cin >> r >> g;
  
  p = 2 * g - r;
  cout << p << endl;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const int MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  ll H,W;cin>>H>>W;
  vector<vector<int>> gap(H,vector<int>(W,0));
  REP(h,H)REP(w,W) cin>>gap[h][w];
  REP(h,H)REP(w,W) {
    int B;cin>>B;
    gap[h][w] = abs(gap[h][w]-B);
  }

  int max_gap = 160*80;
  vector<vector<vector<bool>>> dp(H,vector<vector<bool>>(W,vector<bool>(max_gap,false)));
  dp[0][0][gap[0][0]] = true;

  FOR(w,1,W) {
    REP(i,max_gap) {
      if (!dp[0][w-1][i]) continue;
      if (abs(i-gap[0][w])<=max_gap) dp[0][w][abs(i-gap[0][w])] = true;
      if (i+gap[0][w]<=max_gap) dp[0][w][i+gap[0][w]] = true;
    }
  }
  FOR(h,1,H) {
    REP(i,max_gap) {
      if (!dp[h-1][0][i]) continue;
      if (abs(i-gap[h][0])<=max_gap) dp[h][0][abs(i-gap[h][0])] = true;
      if (i+gap[h][0]<=max_gap) dp[h][0][i+gap[h][0]] = true;
    }
  }
  FOR(h,1,H)FOR(w,1,W) {
    REP(i,max_gap) {
      if (!dp[h][w-1][i] && !dp[h-1][w][i]) continue;
      if (abs(i-gap[h][w])<=max_gap) dp[h][w][abs(i-gap[h][w])] = true;
      if (i+gap[h][w]<=max_gap) dp[h][w][i+gap[h][w]] = true;
    }
  }

  REP(i,max_gap) {
    if (dp[H-1][W-1][i]) {
      OUT(i);
      break;
    }
  }

  return 0;
}

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

int fld[5005][5];
void put1(int l,int p){
    int curr=5000;
    while(curr>=0){
        bool flag=true;
        for(int j=p;j<p+l;j++){
            if(fld[curr][j])flag=false;
        }
        if(flag)curr--;
        else break;
    }

    for(int j=p;j<p+l;j++)fld[curr+1][j]=1;
}
void put2(int l,int p){
    int curr=5000;
    while(curr>=0){
        bool flag=true;
        for(int i=curr;i<curr+l;i++)if(fld[i][p])flag=false;
        if(flag)curr--;
        else break;
    }
    for(int i=curr+1;i<curr+1+l;i++)fld[i][p]=1;
}

void del(){
    int curr=0;
    for(int i=0;i<5000;i++){
        bool flag=true;
        for(int j=0;j<5;j++)if(fld[i][j]==0)flag=false;
        if(flag){
            for(int j=0;j<5;j++)fld[i][j]=0;
            continue;
        }
        for(int j=0;j<5;j++)fld[curr][j]=fld[i][j];
        curr++;
    }
}

void debug(int h){
    for(int i=h;i>=0;i--){
        for(int j=0;j<5;j++){
            printf("%d",fld[i][j]);
        }
        puts("");
    }
}

int main(){
    int n;
    while(scanf("%d",&n),n){
        fill_n(*fld,5005*5,0);
        while(n--){
            int d,l,p;
            scanf("%d%d%d",&d,&l,&p);
            p--;
            if(d==1)put1(l,p);
            else put2(l,p);

            del();


            //debug(10);
        }


        int ans=0;
        for(int i=0;i<5000;i++){
            for(int j=0;j<5;j++)ans+=fld[i][j];
        }

        printf("%d\n",ans);
    }
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
        cout<<1<<"\n";
    else if(a==b || a==c || b==c)
        cout<<2<<"\n";
    else cout<<3<<"\n";
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  int ans = 0;
  int x;
  REP(i,n){
      cin >> x;
      ans += 2*min(abs(k-x),x);
  }
  cout << ans << endl;
}

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





int main() {
int n ;
scanf("%d",&n);
set<int> s;
int arr[100005],x,cnt=0;
memset(arr,0,sizeof arr);
for(int i=0;i<n;i++){
    scanf("%d",&x);
    if(arr[x]==0){
        arr[x]++;
        s.insert(x);
    }
    else{
cnt++;
    }
}
if(cnt%2==1){
cout<<s.size()-1;
}
else
    cout<<s.size();
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  if(a*b%2==0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

#define REP(i, a, b) for(int i = a; i < b; i++)

const int maxn = 110;

int n, m;
int poc;

vector <int> svi[4];
long long int pref[4][maxn];

long long int rj = 0;

int main()
{
    scanf("%d%d", &n, &m);
    int a, b;
    REP(i, 0, n)
    {
        scanf("%d%d", &a, &b);
        if(i == 0)
        {
            poc = a;
            svi[0].push_back(b);
        }
        else
        {
            svi[a - poc].push_back(b);
        }
    }
    REP(i, 0, 4)
    {
        sort(svi[i].begin(), svi[i].end());
        reverse(svi[i].begin(), svi[i].end());
    }
    REP(koji, 0, 4)
    {
        pref[koji][0] = 0;
        REP(i, 1, (int)svi[koji].size() + 1)
        {
            pref[koji][i] = pref[koji][i - 1] + svi[koji][i - 1];
        }
    }
    int ost;
    REP(i, 0, (int)svi[0].size() + 1)
    {
        REP(j, 0, (int)svi[1].size() + 1)
        {
            REP(k, 0, (int)svi[2].size() + 1)
            {
                if((long long) i * poc + (long long) j * (poc + 1) + (long long) k * (poc + 2) > (long long) m) break;
                ost = m - i * poc - j * (poc + 1) - k * (poc + 2);
                ost /= poc + 3;
                ost = min(ost, (int)svi[3].size());
                rj = max(rj, (long long) pref[0][i] + pref[1][j] + pref[2][k] + pref[3][ost]);
            }
        }
    }
    printf("%lld\n", rj);
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BCountABC {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        string S;
        in>>N>>S;
        int cnt = 0;
        REP(i, N-2){
            if(S[i]=='A' and S[i+1]=='B' and S[i+2]=='C') ++cnt;
        }
        out<<cnt<<'\n';
    }
};


int main() {
	BCountABC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

char buf[109];

bool solve(){
	vector<char> st;
	for(int i=0; buf[i]!='.'; i++){
		char c = buf[i];
		if(c == '(' || c == '['){
			st.push_back(c);
		}
		else if(c == ')' || c == ']'){
			if(st.empty()) return false;
			else if(c == ')' && st.back() == '(') st.pop_back();
			else if(c == ']' && st.back() == '[') st.pop_back();
			else return false;
		}
	}
	return st.empty();
}

int main(){
	while(scanf("%[^\n]%*c", buf), strcmp(buf,".")){
		puts(solve()?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    #define REVERSE(v) reverse(ALL(v))
    #define display(x) trav(a,x) cout<<a<<" ";cout<<endl
    #define debug cerr<<"bhau"<<endl
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        std::cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}
    void amax(int &a,int b){a=max(a,b)%M; }
    void amin(int &a,int b){ a=min(a,b)%M;}
    void inc(int &a,int b){a=(a+b)%M;}
    void dec(int &a,int b){a=(a-b+M)%M;}


    
     int solve()
     {  
        int a,b;cin>>a>>b;
        int ans=max(0,a-2*b);
        cout<<ans;

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

int main(){
	ll n; cin >> n;
	ll ans = 0;
	rep(i,n){
		if((i+1)%3 != 0 && (i+1)%5 != 0)ans+= i+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
import itertools

N = int(input())
lis = [x for x in range(N)]
pos = [list(map(int, input().split())) for _ in range(N)]
dis = []

for p in itertools.permutations(lis):
  dise = 0
  for i in range(N-1):
    #i i+i間の距離を求める
    dise += ((pos[p[i]][0]-pos[p[i+1]][0])**2+(pos[p[i]][1]-pos[p[i+1]][1])**2)**0.5
  dis.append(dise)

print(sum(dis)/len(dis))

Measured memory_bytes: 4376
from collections import deque

n,k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
tree = [list() for i in range(n+1)]
visited = [0] * (n+1)
for a,b in ab:
  tree[a].append(b)
  tree[b].append(a)
visited[1] = 1
queue = deque([(1,0)])
ans = k
mod = 10 ** 9 + 7
while queue:
  vertex, depth = queue.popleft()
  res = k - min(depth+1,2)
  for NEXT in tree[vertex]:
    if not visited[NEXT]:
      visited[NEXT] = 1
      ans *= res
      ans %= mod
      res -= 1
      queue.append((NEXT,depth+1))
print(ans)

Measured memory_bytes: 78296
def main():
    A, B, C, X, Y = map(int, input().split())
    print(min(
        A * X + B * Y,
        2 * C * max(X, Y),
        2 * C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y))
    ))
    return


main()


Measured memory_bytes: 2940
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    set<string >st; // the size of set will be the
    //distinct number of strings

    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();

}


Measured memory_bytes: 19256
// 

#include <vector>
#include <iostream>
#include <queue>
#include <climits>
using namespace std;

#define INF 2000
#define F first
#define S second
typedef pair< int, int > ii;

const int N = 10;

int n, start, finish;
int cost[N][N]; // adjacency matrix
int freq[10]; // number of each digit on the wall

priority_queue< ii, vector< ii >, greater< ii > > pq;

int dist[N];
bool visit[N];

int row, col;

void input ()
{
	cin >> row >> col;
	
	for (int i = 0; i < 10; ++i) 
	for (int j = 0; j < 10; ++j) cin >> cost[j][i]; // reversed
	
	int digit;
	for (int i = 1; i <= row; ++i)
	for (int j = 1; j <= col; ++j) {
		cin >> digit;
		if (digit != -1) ++freq[digit];
	}
}

void init ()
{
	for (int i = 0; i < 10; ++i) dist[i] = INF;
	dist[1] = 0;
	pq.emplace(0, 1);
}

void get_to_every_digit_from_one ()
{
	input();
	init();
	
	int proc;
	while (!pq.empty())
	{
		proc = pq.top().second;
		pq.pop();
		
		if (visit[proc]) continue;
		visit[proc] = true;
		
		int temp;
		int adj;
		for (int i = 0; i < 10; ++i) {
			
			adj = i;
			temp = cost[proc][i] + dist[proc];
			
			if (temp < dist[adj]) {
				dist[adj] = temp;
				pq.emplace(temp, adj);
			}
		}
	}
	
	long long ans = 0;
	for (int i = 0; i < 10; ++i) {
		ans += (long long) dist[i]*freq[i];
	}
	
	cout << ans << "\n";
	
	return;
}

int main ()
{
	get_to_every_digit_from_one();
	return 0;
}

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

int main() {
	// your code goes here
	long long int  N,snuke,arai,min,sum=0;
	long long int a[200001];
	scanf("%lld",&N);
	//printf("%lld\n",N);
	for(int i=0;i<N;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	snuke = a[0];
	arai = sum-a[0];
	//printf("%lld %lld\n",snuke,arai);
	min = abs(sum + 2*a[0]);
	//printf("%lld\n",min);
	for(int i=1;i<N-1;i++){
		snuke += a[i];
		arai -= a[i];
		if(abs(snuke - arai) < min){
			min = abs(snuke - arai);
			//printf("%lld\n",min);
		}
	}
	printf("%lld\n",min);
	
	return 0;
}


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

using namespace std;

const int N = 1000100;

int a[N];
int d[N];

int main() {
	int n;
	cin >> n;
	long long v = (n*1ll*(n+1))/2;
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	if(sum % v == 0) {
		sum/=v;
		for (int i = 0; i < n; ++i) {
			d[i] = a[i] - a[(i+1)%n];
		}

		for (int i = 0; i < n; ++i) {
			d[i] += sum;
		}
		int ok = 1;
		for (int i =0 ; i < n; ++i) {
			if(!(d[i]%n == 0 && d[i] >= 0)) {
				ok = 0;
			}
		}
		if (ok) puts("YES");
		else puts("NO");
	} else {

		puts("NO");

	}

}

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

int h, w;
vector<string> s;
vector<vector<bool>> check;

vector<int> dy = {0, 1, 0, -1};
vector<int> dx = {1, 0, -1, 0};

int dfs(int y, int x) {
	check[y][x] = true;
	int ret = 1;
	rep(i, 4) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
		if (s[ny][nx] == '.' || check[ny][nx]) continue;
		ret += dfs(ny, nx);
	}
	return ret;
}

int main() {
	cin >> h >> w;
	s.assign(h, "");
	rep(i, h) cin >> s[i];
	check.assign(h, vector<bool>(w));
	bool ok = true;
	rep(i, h) rep(j, w) {
		if (s[i][j] == '.' || check[i][j]) continue;
		if (dfs(i, j) < 2) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3784