akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

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

    long long P = 0;
    long long S = 0;

    for (auto x : A) {
        P += x * x;
        S += x;
    }

    long long res = 1LL << 60;

    auto mm = minmax_element(A.begin(), A.end());
    int l = *mm.first;
    int r = *mm.second;

    for (int i = l; i <= r; ++i) {
        long long ans = P + n * 1LL * i * i - 2LL * S * i;
        res = min(res, ans);
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3664
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int a, b;
	scanf("%d%d", &a, &b);
	const uint n = 100;
	char[n][n] s;
	foreach (i; 0..n) {
		foreach (j; 0..n) {
			s[i][j] = ".#"[i < n/2];
		}
	}
	foreach (i; 0..n/2) {
		if (i%2 == 1) continue;
		foreach (j; 0..n) {
			if (j%2 == 1) continue;
			if (a == 1) break;
			a--;
			s[i][j] = '.';
		}
	}
	foreach (i; 0..n/2) {
		if (i%2 == 0) continue;
		foreach (j; 0..n) {
			if (j%2 == 1) continue;
			if (b == 1) break;
			b--;
			s[n/2+i][j] = '#';
		}
	}
	writefln("%d %d", n, n);
	foreach (i; 0..n) {
		writeln(s[i]);
	}
}



Measured memory_bytes: 256
const input=require("fs").readFileSync("/dev/stdin","utf8"),lines=input.trim().split("\n");for(;line=lines.shift();){const[i,e]=line.split(" ").map(Number);if(0===i&&0===e)break;const t=lines.shift().split(" ").map(Number);let n=0;for(let s=0;s<=i;s++)for(let l=0;l<=i;l++){if(!t[s]||!t[l]||s===l)continue;const i=t[s]+t[l];i<=e&&i>n&&(n=i)}console.log(`${n||"NONE"}`)}


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

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

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		pair<double, string> plants[64];
		rep(i, n) {
			double p, a, b, c, d, e, f, s, m;
			string str;
			cin >> str >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			double eff = -(m * s * f - p) / (a + b + c + (e + d) * m);
			plants[i] = make_pair(eff, str);
		}
		sort(plants, plants+n);
		rep(i, n) {
			cout << plants[i].second << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


string s;
int ind;

int number(){
    int ret = s[ind] - '0';
    ind++;
    return ret;
}

int term(){
    int ret = number();
    while(1){
        if(s[ind] == '*'){
            ind++;
            ret *= number();
        }else{
            break;
        }
    }
    return ret;
}

int expression(){
    int ret = term();
    while(1){
        if(s[ind] == '+'){
            ind++;
            ret += term();
        }else{
            break;
        }
    }
    return ret;
}
int f(){
    int ret = number();
    while(1){
        if(s[ind] == '+'){
            ind++;
            ret += number();
        }else if(s[ind] == '*'){
            ind++;
            ret *= number();
        }else{
            break;
        }
    }
    return ret;
}
int main(void) {
    int i,j;
    cin >> s;
    int x;
    cin >> x;
    ind = 0;
    int ans1 = expression();
    ind = 0;
    int ans2 = f();
    if(ans1 == x && ans2 == x){
        cout << "U" << endl;
    }else if(ans1 == x){
        cout << "M" << endl;
    }else if(ans2 == x){
        cout << "L" << endl;
    }else{
        cout << "I" << endl;
    }

}



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

using namespace std;

const long long N = 1e5 + 5;
long long n;
map < long long , long long > a;

int main()
{
    scanf("%lld" , &n);

    for(int i = 0 ; i < n ; i++) {
        long long c;
        scanf("%lld" , &c);
        a[c]++;
    }

    long long fi = -1;
    long long se = -1;
    long long sq = -1;

    for(auto i : a) {
        if(i.second >= 4) {
            sq = i.first;
        }

        if(i.second >= 2) {
            fi = i.first;
        }
    }

    for(auto i : a) {
        if(i.second >= 2 && i.first != fi) {
            se = i.first;
        }
    }

    if(sq == -1 && (fi == -1 || se == -1)) {
        cout << 0 << endl;
        return 0;
    }

    if(sq == -1) {
        cout << fi * se << endl;
        return 0;
    }

    if(fi == -1 || se == -1) {
        cout << sq * sq << endl;
        return 0;
    }

    if(sq != -1 && fi != -1 && se != -1) {
        cout << max(sq * sq , fi * se) << endl;
        return 0;
    }

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


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int x = 0, max = 0, i;
	for(i = 0; i < N; i++) {
		if(S[i] == 'I') {
			x++;
		}
		else x--;
		
		if(x > max) max = x;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  ll n = 10;

  vector<vector<ll>> v(n, vector<ll>(n));

  rep(i, n) rep(j, n) cin >> v.at(i).at(j);
  ll inf = 1000000000000000000;
  vector<ll> dp(n, inf);
  rep(i, n) dp.at(i) = v.at(i).at(1);

  rep(_, n) {
    rep(i, n) {
      rep(j, n) {
        if (j != 1 and j != i) dp.at(i) = min(dp.at(i), v.at(i).at(j) + dp.at(j));
      }
    }
  }
  ll cnt = 0;
  rep(i, h) {
    rep(j, w) {
      ll a;
      cin >> a;
      if (a == -1) continue;
      else cnt += dp.at(a);
    }
  }
  cout << cnt << endl;

  return 0;
}

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

int main() {

    int a = -1, b = -1;
    while(true){
    
        // 1. input end check.
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        
        // 2. output answer.
        if(a <= b) cout << a << " " << b << endl;
        else       cout << b << " " << a << endl;
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<char> c = {'3', '5', '7'};
long long N;
long long ans;
void dfs(string s){
    if(!s.empty() && atoll(s.c_str()) > N) return;
    int flag = 0;
    for(int i = 0; i < 3; i++){
        if(s.find(c[i]) == string::npos) flag = 1;
    }
    if(flag == 0) {
        ans++;
    }
    for(int i = 0; i < 3; i++){
        dfs(s + c[i]);
    }
}
int main(){
    cin >> N;
    ans = 0;
    string s;
    ans = 0;
    dfs(s);
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e15;

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll jump = x / d;
	ll ans = 0;
	if (jump < k) {
		ans = x;
		if ((1e15 / jump) < d) {
			if (jump >= d) {
				rep(i,jump)ans -= d;
				if ((k - jump) % 2 == 1)ans -= d;
			}
			else {
				rep(i, d)ans -= jump;
				if ((k - jump) % 2 == 1)ans -= d;

			}
		}
		else {
			ans = x - (jump * d);
			if ((k - jump) % 2 == 1)ans -= d;
		}
	}else{
		if ((1e15 / jump) < d) {
			if (jump >= d) {
				rep(i, jump)ans = min(ans, abs(x - (d * (i + 1))));
			}
			else {
				rep(i, d)ans -= jump;
			}
		}else ans = (abs(x - (k * d)));
	}
	cout << abs(ans) << endl;
	return 0;
}



Measured memory_bytes: 3604
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

s = '7' * len(str(K))
if int(s) < K:
    s += '7'
ans = len(s)
s = int(s)

while True:
    s = s % K
    if s == 0:
        print(ans)
        exit()
    s = s * 10 + 7
    ans += 1


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
# define ulli unsigned long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define MOD 1000000007
using namespace std;
// ll prime[10000000];
// //Modular Exponentiation
//     ll fastExpo(ll x,ll n){
//         if(n==0) return 1;
//         if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
//         return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
//     }
//   //Euclidean Algorithm
//      ll gcd(ll a,ll b){
//       return (b==0)?a:gcd(b,a%b);
//     } 
//  // Extended Euclidean Algorithm
//   ll exgcd(ll a,ll b,ll &x, ll &y){
//   if(b==0){
//     x=1,y=0;
//     return a;
//   }
//    ll x1,y1;
//     ll d=exgcd(b,a%b,x1,y1);
//    x=y1;
//    y=x1-y1*(a/b);
//    return d;    
//  }    
  //sieve
//   void sieve(){
//   prime[0]=0;
//   prime[1]=0;
//   for(int i=2;i<10000000;i++){
//     prime[i]=1;
//   }
//   for(int i=2;i*i<10000000;i++){
//     if(prime[i]==1){
//       for(int j=i*i;j<10000000;j+=i){
//         prime[j]=0;
//       }
//     }
//   }
// }  
    bool compare(const pair<int,double>&p1,const pair<int,double>&p2)
    {
       if(p1.second>p2.second)
        return true;
       else if(p1.second==p2.second)
        return p1.first<p2.first;
       return false;

    }
     int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
     // cout << fixed;
      //cout.precision(2);
         
             int h,w,k;
             cin>>h>>w>>k;
             string s[h];
             for(int i=0;i<h;i++)
              cin>>s[i];
             int ans=0;
             for(int r=0;r<(1<<h);r++)
             {
               for(int c=0;c<(1<<w);c++)
               {   int cc=0;
                  for(int i=0;i<h;i++)
                  {
                     for(int j=0;j<w;j++)
                     {
                       if(r&(1<<i) || c&(1<<j))
                        continue;
                       if(s[i][j]=='#')cc++;
                     }
                  }
                  if(cc==k)ans++;
               }
             }
             cout<<ans;
             return 0;
            }

Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MAXY = 10100;

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

    int a, b;
    cin >> a >> b;

    for (int i = 1; i < MAXY; i++) {
        const int aa = i * 0.08, bb = i * 0.1;
        if (aa == a && bb == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


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

int main() {
	int k, s;
	cin >> k >> s;
	int count = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k)
				count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))

l = list(range(-1,102))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)



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

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

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

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

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

const string YES = "Yes";
const string NO = "No";

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vi m(n, k-q);
    vi a(q);
    rep(i, q) {
        cin >> a[i];
        --a[i];
    }
    rep(i, q) m[a[i]]++;
    rep(i, n) cout << (m[i]>0?YES:NO) << endl;
    return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
using vll = vector<long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> c){
    vector< vll > row(3, vll(3, 0)), col(3, vll(3,0));
    rep(i, 3){
        rep(j, 3){
            row[i][j] = c[i][j] - c[(i+1)%3][j];
            col[i][j] = c[i][j] - c[i][(j+1)%3];
        }
    } 
    rep(i, 3){
        if(row[i][0]!=row[i][1] || row[i][1]!=row[i][2]){
            cout << NO << endl;
            return;
        }
    }
    rep(j, 3){
        if(col[0][j]!=col[1][j] ||col[1][j] != col[2][j]){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
    
}

int main(){
    std::vector<std::vector<long long>> c(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&c[i][j]);
        }
    }
    solve(std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>

#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, MOD = 1e9 + 7;

int N, M, dp[3005][3005];
string s, t, lcs;

int main() {
    cin >> s >> t;
    N = s.size(), M = t.size();
    s = " " + s, t = " " + t;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int x = N, y = M;
    while (x && y) {
        if (s[x] == t[y]) lcs += s[x], x--, y--;
        else if (dp[x][y] == dp[x - 1][y]) x--;
        else y--;
    }
    reverse(lcs.begin(), lcs.end());
    cout << lcs << '\n';
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  vll log2(n);
  rep(i, 0, n){
    while(a.at(i) % 2 == 0){
      log2.at(i)++;
      a.at(i) /= 2;
    }
  }
  cout << *min_element(all(log2)) << endl;
}

Measured memory_bytes: 256
#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())
#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;
//typedef tuple<ll, ll, ll> T;

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);
    ll N,C;
    cin>>N>>C;
    vector<ll> x(N+2),v(N+2);
    for(ll i=1;i<=N;i++){
        cin>>x[i]>>v[i];
    }
    x[0]=0;
    x[N+1]=C;
    
    ll cal=0;
    vector<vector<ll>> dp(2,vector<ll>(100010,0));
    
    for(ll i=1;i<=N;i++){
        cal -= x[i] - x[i-1];
        cal += v[i];
        dp[0][i] = max(dp[0][i-1],cal);
    }
    cal = 0;
    for(ll i=N;i>=1;i--){
        cal -= x[i+1] - x[i];
        cal += v[i];
        dp[1][i] = max(dp[1][i+1],cal);
    }

    ll maxcal=0;
    for(ll i=0;i<=N;i++){
        cal = dp[0][i] + dp[1][i+1] - x[i];
        chmax(maxcal,cal);
        cal = dp[0][i] + dp[1][i+1] - C + x[i+1];
        chmax(maxcal,cal);
    }
    cout<<maxcal<<endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int* dp=new int[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=INT_MAX;
		int count=0;
		for(int j=i-1;j>=0 && count<k;j--,count++)
		dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9,maxn=2e5+5,mod=1e9+7;
int n,m,a[maxn],bit[maxn],dp[25][maxn],c[maxn],fac[maxn],inv[maxn];
int pw(int x,int y){if(y==0)return 1;if(y==1)return x;int mid=pw(x,y>>1);if(y&1)return 1ll*mid*mid%mod*x%mod;return 1ll*mid*mid%mod;}
int C(int x,int y){return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;}
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);reverse(a+1,a+m+1);
	for(int i=0;i<=n-1;i++)bit[i] = 1<<i;
	int cnt = 1<<n;
	
	fac[0]=inv[0]=1;for(int i=1;i<=cnt;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[cnt] = pw(fac[cnt],mod-2);
	for(int i=cnt-1;i>=0;i--)inv[i] = 1ll*inv[i+1]*(i+1)%mod;
	
//	printf("%d\n",cnt);
//	printf("%d\n",C(5,3));
	dp[0][0] = 1;
	for(int i=1;i<=m;i++)
		for(int S=0;S<=(1<<n)-1;S++){
			int lft=cnt-a[i]+1-S;
			(dp[i][S] += dp[i-1][S]) %= mod;
			for(int j=0;j<=n-1;j++){
				if(lft < bit[j])break;
				if(bit[j] & S)continue;
				(dp[i][S^(bit[j])] += 1ll*dp[i-1][S]*C(lft-1,bit[j]-1)%mod*fac[bit[j]]%mod) %= mod;
//				printf("%d\n",dp[i][S^bit[j]]);
			}
		}
	int ans=fac[cnt-1];c[0] = 1;
//	printf("%d %d\n",cnt,ans);
//	p
	for(int S=1;S<=(1<<n)-1;S++){
		c[S] = -c[S - (S&(-S))];
		(ans += 1ll*c[S]*dp[m][S]%mod*fac[cnt-1-S]%mod) %= mod;
//		printf("q %d\n",ans);
	}
	ans = (1ll*ans*cnt%mod+mod)%mod;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 32000
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int cnt = 0;
        int tmp = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        tmp = h[0];
        for (int i = 1; i < h.length; i++) {
            if (tmp >= h[i]) {
                cnt++;
            } else {
                cnt = 0;
            }
            tmp = h[i];
            max = Math.max(max, cnt);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 50100
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

int n;
int m;
int q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A){
    if(A.size() == n + 1){
        int now = 0;
        for(int i = 0; i < q; i++){
            if(A[b[i]] - A[a[i]] == c[i]){
                now = now + d[i];
            }
            ans = max(ans, now);
        }
        /*
        for (int i = 1; i < A.size(); i++){
         printf("%d", A[i]);
        }
        printf("\n");
        */
        return;
    }

    A.push_back(A.back());
    //printf("%d\n", A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
   
    int max = 0;
    

    

    cin >> n >> m >> q;

    a = b = c = d = vector<int>(q);
    //printf("%d\n", a[0]);
    
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(1, 1));
    printf("%d\n", ans);

    return 0;
    
    
}

Measured memory_bytes: 3732
d,m=1e9+7,p[10001][200]={1};i,j,k,x,I;char s[11111];main(L){for(scanf("%s%d",s,&d);s[i];i+=j^=1)for(x=L=j?9:s[i]-48,k=0;~x;x-=++k/d,k%=d)p[i+1][I=(j|x<L)*d+(k+x)%d]+=p[i][j*d+k],p[i+1][I]%=m;printf("%d",(*p[i]+p[i][d]-1+m)%m);}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  int fee = b;
  if (a>=6 && a<=12) {
    fee /= 2;
  } else if(a<=5) {
  	fee = 0;
  }
  
  cout << fee << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long Com(long long a, long long b){
    long long L = 1;
    long long c = max(a-b,b);
    long long d = min(a-b,b);
    for(long long i = c+1; i <= a; i++) L *= i;
    for(long long i = 2; i <= d; i++) L /= i;
    return L;
}

int main(void){
    long long N,P;
    cin >> N >> P;
    vector<long long> A(N),O,E;
    for(long long i = 0; i < N; i++){
        cin >> A[i];
        if(A[i]%2 == 1) O.push_back(A[i]);
        else E.push_back(A[i]);
    }
    long long o = O.size(),e = E.size(),ans = 0;
    long long F = 1;
    for(long long i = 0; i < e; i++) F *= 2;
    if(P == 1){
        long long i = 1;
        while(i <= o){
            long long C = Com(o,i);
            ans += C * F;
            i += 2;
        }
        cout << ans << endl;
    }
    if(P == 0){
        long long i = 2;
        ans += F;
        while(i <= o){
            long long C = Com(o,i);
            ans += C * F;
            i += 2;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

int a[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (w*h)/2 << ' ';
    cout << (x*2==w&&y*2==h) ? 1 : 0;
}

//TODO: 56
//come back to 50D, 55D, DP-J



Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    long long int n;
    cin >> n;
    vector<vector<long long int>> v(3);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < n; j++){
            long long int x;
            cin >> x;
            v[i].push_back(x);
        }
        sort(v[i].begin(), v[i].end());
    }
    vector<long long int> ans(n, 0);
    long long int in1 = 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            while(1){
                if(in1 == n){
                    break;
                }
                if(v[1][i] > v[0][in1]){
                    ans[i]++;
                    in1++;
                }else{
                    break;
                }
            }
        }else{
            if(in1 == n){
                ans[i] = ans[i - 1];
            }else{
                ans[i] = ans[i - 1];
                while(1){
                    if(in1 == n){
                        break;
                    }
                    if(v[1][i] > v[0][in1]){
                        ans[i]++;
                        in1++;
                    }else{
                        break;
                    }
                }
            }
        }
    }
    long long int ind = 0;
    vector<long long int> ans2(n, 0);
    for(int i = 0; i < n; i++){
        if(i == 0){
            while(1){
                if(ind == n){
                    break;
                }
                if(v[2][i] > v[1][ind]){
                    ans2[i] += ans[ind];
                    ind++;
                }else{
                    break;
                }
            }
        }else{
            if(ind == n){
                ans2[i] = ans2[i - 1];
            }else{
                ans2[i] = ans2[i - 1];
                while(1){
                    if(ind == n){
                        break;
                    }
                    if(v[2][i] > v[1][ind]){
                        ans2[i] += ans[ind];
                        ind++;
                    }else{
                        break;
                    }
                }
            }
        }
    }
    
    long long int sum = 0;
    for(int i = 0; i < n; i++){
        sum += ans2[i];
    }
    
    cout << sum;
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


void solve()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);

    for(auto &i: x)
        cin >> i;

    ll ans = 0;
    for(auto i: x)
    {
        ans += min(i, abs(i-k))*2;
    }
    cout << ans;
}

int main()
{
   

    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3696
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let _: usize = itr.next().unwrap().parse().unwrap();

    let mut pos = vec![0; 100010];
    for _ in 0..n {
        let s: usize = itr.next().unwrap().parse().unwrap();
        let t: usize = itr.next().unwrap().parse().unwrap();
        let c: usize = itr.next().unwrap().parse().unwrap();

        let d = 1 << c - 1;
        pos[s] ^= d;
        pos[t + 1] ^= d;
    }

    let mut ans = 0;
    for i in 0..100001 {
        ans = max(ans, (pos[i] as u32).count_ones());
        pos[i + 1] ^= pos[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
PROGRAM-ID.                      ABC_105_D.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA                             DIVISION.
FILE                             SECTION.
    FD  SYSIN.
        01 INDATA PIC X(1100000).

WORKING-STORAGE                  SECTION.
    01 NM      PIC X(17).
    01 N       PIC 9(6).
    01 M       PIC 9(10).
    01 INP     PIC X(1100000).

    01 X1.
        03 X11 OCCURS 100000.
            05 X PIC 9(15).

    01 xd      PIC 9(15).
    01 sx      PIC 9(15).

    01 Y1.
        03 Y11 OCCURS 100000 DEPENDING N ASCENDING Y.
            05 Y PIC 9(15).

    01 bk      PIC 9(10).

    01 Z1.
        03 ZNUM PIC 9(6) VALUE ZERO.
        03 Z11 OCCURS 100000 DEPENDING ZNUM ASCENDING Z INDEXED BY K.
            05 Z PIC 9(15).
            05 ZCNT PIC 9(6) VALUE ZERO.

    01 flg     PIC 9(1).
    01 ky      PIC 9(15).

    01 tmp     PIC 9(10).
    01 r       PIC 9(10).
    01 sm      PIC 9(24).

    01 zc      PIC 9(12).

    01 maxlen  PIC 9(7).
    01 cur     PIC 9(7) VALUE 1.
    01 i       PIC 9(7) VALUE 1.
    01 j       PIC 9(7).
    01 len     PIC 9(7).

    01 ans     PIC X(24).

    01 ZS      PIC Z(24)9.
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT NM.

    UNSTRING NM
    DELIMITED BY SPACE
    INTO N M.

    OPEN INPUT SYSIN.

    READ SYSIN INTO INP.

    CLOSE SYSIN.

*>    DISPLAY FUNCTION STORED-CHAR-LENGTH(INP)

    MOVE N TO maxlen.

    MOVE ZERO TO sx.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO tmp

        ADD tmp TO sx

        MOVE sx TO X(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL maxlen < i

*>        COMPUTE ky = FUNCTION MOD(X(i), M)
        DIVIDE M INTO X(i) GIVING xd REMAINDER ky

        MOVE ky TO Y(i)

    END-PERFORM.

    SORT Y11 ASCENDING Y.

    MOVE 9999999999 TO bk.

    PERFORM VARYING i FROM 1 BY 1 UNTIL maxlen < i

        IF bk = Y(i) THEN
            ADD 1 TO ZCNT(ZNUM)
        ELSE
            MOVE Y(i) TO bk
            ADD 1 TO ZNUM
            MOVE Y(i) TO Z(ZNUM)
            ADD 1 TO ZCNT(ZNUM)
        END-IF

    END-PERFORM.

    MOVE ZERO TO sm.

    PERFORM VARYING i FROM 1 BY 1 UNTIL ZNUM < i
*> pair
        SUBTRACT 1 FROM ZCNT(i) GIVING zc
        COMPUTE zc = ZCNT(i) * zc
        DIVIDE 2 INTO zc
        COMPUTE sm = sm + zc
        IF ZERO = Z(i)
*> alone
            COMPUTE sm = sm + ZCNT(i)
        END-IF
    END-PERFORM.

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 8956
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

class DATA{
public:
	string name;
	int win;
	int lose;
	int draw;
	DATA() : win(0),lose(0),draw(0){}
};

class mycmp{
public:
	bool operator()(const DATA d1, const DATA d2){
		if(d1.win > d2.win) return true;
		if(d1.win == d2.win && d1.lose < d2.lose) return true;
		return false;
	}
};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<DATA> teams;
		for(int i=0;i<n;i++){
			char name[32];
			scanf("%s",&name);
			DATA data;
			data.name = name;
			for(int j=0;j<n-1;j++){
				int result;
				scanf("%d",&result);
				if(result==0) data.win++;
				else if(result==1) data.lose++;
				else if(result==2) data.draw++;
			}

			teams.push_back(data);
		}

		sort(teams.begin(),teams.end(),mycmp());

		for(int i=0;i<teams.size();i++){
			printf("%s\n",teams[i].name.c_str());
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N;
    cin >> N;
    map<ll, ll> cnt;//key:Ai  value:counts

    rep(i, N) {
        ll a;
        cin >> a;
        //find key
        if(cnt.find(a) == cnt.end()){//There are not key.
            cnt.insert({a, 1LL});
        }
        else cnt[a]++;//value++
    }

    ll ans=0;
    for(auto x:cnt){
       ll t = x.S - x.F;
       if(t>0) ans += t;
       if(t<0) ans += x.S;
    }

    cout << ans << nl;
}


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

typedef long long int ll;
ll n;
string s;

int main() {
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    for(ll i = 0; i < s.length(); ++i) {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }

    ll ans = r * g * b;
    for(ll i = 1; i <= n/2; ++i) {
        for(ll j = 0; j < n - 2 * i; ++j) {
            if(s[j] != s[j + i] && s[j + i] != s[j + 2 * i] && s[j] != s[j + 2 * i]) ans--;
        }
    }

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

Measured memory_bytes: 3612
n, m = map(int,input().split(' '))

import math

if n >= 2:
    cn = math.factorial(n) / math.factorial(2) / math.factorial(n - 2)
else:
    cn = 0
if m >= 2:
    cm = math.factorial(m) / math.factorial(2) / math.factorial(m - 2)
else:
    cm = 0

print(int(cn + cm))


Measured memory_bytes: 3060
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))

x.append(X)
x=sorted(x)
gcd=x[1]-x[0]

for i in range(1,N+1):
    gcd=fractions.gcd(gcd,x[i]-x[i-1])
print(gcd)

Measured memory_bytes: 16240
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


ll A, B, C, D, E, F;

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> A >> B >> C >> D >> E >> F;

    vector<ll> W;
    rep (a, 30) {
        rep (b, 30) {
            if (a == 0 && b == 0) continue;
            ll s = 100 * A * a + 100 * B * b;
            if (s > 3000) continue;
            W.pb(s);
        }
    }
    sort(all(W));
    vector<ll> S;
    rep (x, 1500) {
        rep (y, 1500) {
            ll s = C * x + D * y;
            if (s > 1500) continue;
            S.pb(s);
        }
    }
    sort(all(S));
    double ans1 = 0;
    ll ans2 = 0, ans3 = 0;
    for (ll w : W) {
        if (w > F) break;
        for (ll s : S) {
            if (w + s > F) break;
            if (w / 100 * E < s) break;
            double tmp = (double)s / (w + s);
            if (tmp >= ans1) {
                ans1 = tmp;
                ans2 = w + s;
                ans3 = s;
            }
        }
    }
    cout << ans2 << " " << ans3 << endl;
}


Measured memory_bytes: 8940
n = int(input())
l = list(map(int, input().split()))
even = []
odd = []

for i in range(n):
  if i % 2 == 0:
    even.append(l[i])
  else:
    odd.append(l[i])

if n % 2 == 0:
  print(" ".join(map(str, odd[::-1]+even)))
else:
  print(" ".join(map(str, even[::-1]+odd)))

Measured memory_bytes: 31480
import java.util.*;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();
    int a[] = new int[n];
    int x = 0;
 
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int answer1[] = new int[h*w];
    for(int i=0;i<n;i++){
      for(int j=0;j<a[i];j++){
        answer1[x] = i+1;
        x = x + 1;
      }
    }
    x = 0;
    int answer2[][] = new int[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i%2==0){
          answer2[i][j] = answer1[x];
          x = x + 1;
        }else{
          answer2[i][w-1-j] = answer1[x];
          x = x + 1;
        }
      }
    }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          System.out.print(answer2[i][j] + " ");
        }
        System.out.println("");
      }
 
  }
}

Measured memory_bytes: 32116
# -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b

"""
import sys
from sys import stdin


def solve(ashiba, N, K):
    dp = [float('inf')] * N
    dp[0] = 0
    for i in range(1, len(ashiba)):
        paths = [dp[j]+abs(ashiba[j]-ashiba[i]) for j in range(max(0, i-K), i)]
        dp[i] = min(paths)
    return dp[-1]


def main(args):
    N, K = map(int, input().split())
    ashiba = [int(i) for i in input().split()]
    ans = solve(ashiba, N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 14016
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,k,q,win,i;
	cin>>n>>k>>q;
	ll freq[n+1];
	memset(freq,0,sizeof freq);
	ll points[n+1];
	for(i=0;i<q;i++){
		cin>>win;
		freq[win]++;
	}
	for(i=1;i<=n;i++)
	points[i] = k-q;
	for(i=1;i<=n;i++){
		//cout<<points[i]<<" ";
		points[i]+=freq[i];
		points[i]>0?cout<<"Yes\n":cout<<"No\n";
	}
 	return 0;
}


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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n; cin >> n;
	map<int, int> mp;
	rep(i, n) {
		int a; cin >> a;
		mp[a]++;
	}
	int ki = 0, gu = 0;
	for (P p : mp) {
		if (p.second % 2) ki++;
		else gu++;
	}
	cout << ki + gu - gu % 2 << endl;
	system("pause");
}

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  vector<int> cnt(1 << 17);
  for (int a : A) ++cnt[a];

  int64_t sum = 0;
  for (int a : A) sum += a;

  int Q;
  cin >> Q;

  while (Q--) {
    int B, C;
    cin >> B >> C;

    int t = cnt[B];
    sum += (int64_t) t * (C - B);

    cnt[B] -= t;
    cnt[C] += t;

    cout << sum << "\n";
  }

  return 0;
}



Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
string s[maxn];
int n;
map<string,ll >m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        m[s[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll t=m[s[i]];m[s[i]]=0;
        ans=ans+t*(t-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 18176
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))
    A.sort()
    print(A[0] + A[1] + A[2] * 10)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    
    int sum = 100 * r + 10 * g + b;
    
    if ( sum % 4 == 0 ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define M 10000001
#define MAX 10000000000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
	ll n,r=0;
	cin>>n>>r;
	ll ans = 0,cnt=0,temp = 1;
	while(ans<n)
	{
		ans += (r-1)*temp;
		temp *= r;
		cnt++;
		// cout<<ans<<" ";
	}
	cout<<cnt<<endl;

	return 0;
}

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

int main(void){
    int d;
    cin >> d;
    string s;
    
    if(d==25) s = "Christmas";
    if(d==24) s = "Christmas Eve";
    if(d==23) s = "Christmas Eve Eve";
    if(d==22) s = "Christmas Eve Eve Eve";

    cout << s << endl;
    return 0;
}

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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
    if (N == M) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;
//
int main() {
    bool reversed = false;
    list<char> ls;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) { ls.push_back(S[i]); }
    int Q;
    cin >> Q;
    //vector<int> A(N);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            if (!reversed)reversed = true;
            else reversed = false;
        }
        else if (a == 2) {
            int b;
            cin >> b;
            if (b == 1) {
                char c;
                cin >> c;
                if (reversed)ls.push_back(c);
                else ls.push_front(c);
            }
            else {
                char c;
                cin >> c;
                if (reversed)ls.push_front(c);
                else ls.push_back(c);
            }
        }
    }
        if (reversed)ls.reverse();
        for (const char& x : ls) {
            std::cout << x;
        }
        cout <<endl;
    
}


Measured memory_bytes: 9984
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int smax(int* list,int n)
{ 
  int max, sec,maxreal,i;//maxreal is output.
  max=sec=maxreal=0;
  for(i=0;i<n;i++)
    if(list[i]==1){
      max++;
      sec++;
    }
    else if(list[i]==0)
      if(max>=maxreal)
	{
	  maxreal=max;
	  max=sec+1;
	  sec=0;
	}
      else{
	max=sec+1;
	sec=0;
      }
  
  if(max>maxreal)
    maxreal=max; 
  return maxreal;
}
int nmax(int* list,int n){
  int max, sec,maxreal,i;
  max=sec=0;
  for(i=0;i<n;i++){
    if(list[i]==1){
      sec++;
    }
    else{
      if(max<sec) max=sec;
      sec=0;
      
    }
  }
  if(max<sec)
    max=sec;
  return max;
}
int main(){
  
  int list[100000];
  int i,n,k,flag,tmp,max,j;

 
    while(1){
      flag=0;
      scanf("%d %d",&n,&k);
   
      if(n==0&&k==0) break;
      for(i=0;i<100000;i++)
	list[i]=0;

      for(i=0;i<k;i++){

	scanf("%d",&tmp);
	
	if(tmp==EOF)
	  break;
	if(tmp>0)
	  list[tmp-1]=1;
	else flag=1;
	/*	for(j=0;j<n;j++)
	  printf("%d\n",list[j]);
	printf("--------\n");    
	*/
      }
      if(flag==1)
	printf("%d\n",smax(list,n));
      else 	printf("%d\n",nmax(list,n));
    }
    return 0;
}

Measured memory_bytes: 988