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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string ans = "CODEFESTIVAL2016";

int main() {
    string s;
    cin >> s;
    bool c = false, f = false;
    li first_c = INF, last_f = -1;
    rep(i, sz(s)) {
        if (s[i] == 'C') {
            first_c = min(first_c, i);
        } else if (s[i] == 'F') {
            last_f = i;
        }
    }
    if (first_c == INF || last_f < 0) {
        puts("No");
        return 0;
    }
    if (first_c > last_f) {
        puts("No");
        return 0;
    }
    puts("Yes");

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    reverse(s.begin(), s.end());
    while(s.size()!=0){
        if(s.substr(0,6)=="resare") s=s.substr(6);
        else if(s.substr(0,5)=="esare") s=s.substr(5);
        else if(s.substr(0,7)=="remaerd") s=s.substr(7);
        else if(s.substr(0,5)=="maerd") s=s.substr(5);
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3764
#include <stdio.h>
#define N 500001

int A[N];

void maxHeapify(int i, int h) {
  int l, r, largest, tmp;

  while(1) {
    l = 2*i;
    r = 2*i+1;
    if(l <= h && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= h && A[r] > A[largest]) largest = r;
    if(largest != i) {
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      i = largest;
    }
    else break;
  }
}

void buildMaxHeap(int h) {
  int i;
  for(i = h/2; i > 0; i--) {
    maxHeapify(i, h);
  }
}

int main() {
  int i, h;

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

  buildMaxHeap(h);

  for(i = 1; i <= h; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,ans=0;
    cin >>n;
    x = n;
    while(x>0){
        ans+=x%10;
        x/=10;
    }
    if(n%ans==0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
cards = list(map(int,input().split()))
 
cards.sort(reverse=True)
 
sum_A = 0
sum_B = 0
 
for i in range(N):
    if i % 2 == 0:
        sum_A += cards[i]
    else:
        sum_B += cards[i]
print(sum_A - sum_B)

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  
  for(int i=0; i<m; i++){
    cin >> a.at(i) >> b.at(i);
  }
  for(int i=0; i<n; i++){
    int sum=0;	
    for(int j=0; j<m; j++){
      if((i+1)==a.at(j))sum++;
      if((i+1)==b.at(j))sum++;
    }
    cout << sum << endl;
  }
}




Measured memory_bytes: 256
n = int(input())
c = []
s = []
f = []
for _ in range(n-1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)

for i in range(n-1):
    now = i
    time = s[i]
    while now < n-1:
        time += c[now]
        now += 1
        if now == n-1:
            break
        x = time % f[now]
        if time < s[now]:
            time = s[now]
        elif x == 0:
            pass
        else:
            time += f[now] - x
    print(time)
print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int x,a,b;
  cin >> a >> b;
  if((a*b)%2)cout <<"Odd\n";
  else  cout <<"Even\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	string S;
	cin >> S;
	string ans = "Yes";
	for (int i = 0; i < S.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (S[i] == 'L')
			{
				ans = "No";
				break;
			}
		}
		else if (S[i] == 'R')
		{
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int[] A = new int[n];

        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }

        shellSort(A, n);
    }

    static int insertionSort(int[] A, int n, int g) {
        int cnt = 0;
        for (int i = g; i < n; i++) {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v) {
                A[j+g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j+g] = v;
        }

        return cnt;
    }

    static void shellSort(int[] A, int n) {
        PrintWriter pw = new PrintWriter(System.out);

        long cnt = 0;
        int m = 1;
        for (int i = n-1; i > 2; i /= 2) {
            m++;
            pw.print(i + " ");
            cnt += insertionSort(A, n, i);
        }
        pw.println(1);
        cnt += insertionSort(A, n, 1);

        System.out.println(m);
        pw.flush();

        pw.println(cnt);
        for (int i = 0; i < n; i++) {
            pw.println(A[i]);
        }

        pw.flush();
    }
}


Measured memory_bytes: 298868
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    if(n%2 == 0) {
        if(k <= n/2) {
            cout << "YES";
        }
        else {
            cout << "NO";
        }
    }
    else {
        if(k <= n/2+1) {
            cout << "YES";
        }
        else {
            cout << "NO";
        }
    }

    cout << 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() {
    bool p, w, g, y;
    p = false;
    w = false;
    g = false;
    y = false;
    string s;
    int n;
    cin >> n;
    rep(i, n) {
        cin >> s;
        if(s == "P") p = true;
        else if(s == "W") w = true;
        else if(s == "G") g = true;
        else if(s == "Y") y = true;
    }
    if(p && w && g && y) cout << "Four" << endl;
    else cout << "Three" << endl;
}

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

struct f {
    lli a, b;
    f(lli a, lli b)
    {
        if (b == 0)
            assert(false);
        lli g = __gcd(a, b);
        a /= g, b /= g;
        this->a = a;
        this->b = b;
    }
};
f add(f l, f r)
{
    return f(l.a * r.b + l.b * r.a, r.b * l.b);
}
int main()
{
    lli n;
    cin >> n;
    f nn = f(4, n);
    for (int i = 1; i <= 3500; i++) {
        auto gg = add(nn, f(-1, i));
        for (int j = 1; j <= 3500; j++) {
            auto s = add(gg, f(-1, j));
            if (s.a == 1 and s.b > 0) {
                cout << i << " " << j << " " << s.b << endl;
                return 0;
            }
        }
    }
}


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

int gcd(int p,int q){
  if(p%q==0) return q;
  return gcd(q,p%q);
}

int main() {
  int K,x,count=0;
  cin>>K;
   for(int a=1;a<=K;a++){
      for(int b=1;b<=K;b++){
         for(int c=1;c<=K;c++){
           x=gcd(a,gcd(b,c));
           count+=x;
         }
      }
   }
  cout<<count<<endl;
}

Measured memory_bytes: 3628
#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;

struct SWAG{
	llint size;
	stack<P> head, tail;
	SWAG(){init();}
	
	llint getElement(){ //単位元e
		return -inf;
	}
	llint ope(llint x, llint y){  //作用素(x * y)
		return max(x, y);
	}
	void init(){
		size = 0;
		while(head.size()) head.pop();
		while(tail.size()) tail.pop();
	}
	void push(llint x){
		size++;
		if(tail.size() == 0){
			tail.push(P(x, x));
			return;
		}
		tail.push(P(x, ope(tail.top().second, x)));
	}
	void pop(){
		if(size == 0) return;
		if(head.size() == 0){
			llint sum = getElement();
			while(tail.size()){
				llint x = tail.top().first;
				sum = ope(x, sum);
				head.push(P(x, ope(x, sum)));
				tail.pop();
			}
		}
		head.pop();
		size--;
	}
	llint query(){
		llint ret = getElement();
		if(head.size()) ret = ope(ret, head.top().second);
		if(tail.size()) ret = ope(ret, tail.top().second);
		return ret;
	}
};

llint n, m, k;
llint a[100005];
llint dp[305][100005];
SWAG sw;

int main(void)
{
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int j = 1; j <= n; j++) dp[1][j] = a[j];
	for(int i = 2; i <= k; i++){
		sw.init();
		for(int j = 1; j <= n; j++){
			dp[i][j] = sw.query() + a[j] * i;
			sw.push(dp[i-1][j]);
			if(j > m) sw.pop();
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans = max(ans, dp[k][i]);
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 237404
#include<stdio.h>
#include<algorithm>
using namespace std;
long long int xx[200000];
int main(){
	int h,a;
	scanf("%d %d",&h,&a);
	for(int i=0;i<h;i++){
		scanf("%d",&xx[i]);
	}
	sort(xx,xx+h);
	long long int sum=0;
	for(int i=0;i<h-a;i++){
//		printf("xxi=%d\n",xx[i]);
		sum+=xx[i];
	}
	printf("%lld",sum);
}

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

struct Store {
	int size, price;
	bool operator<(const Store &rhs) const {
		return price < rhs.price;
	}
}s[100010];
int main() {
	int n, m;
	cin>>n>>m;
	for (int i=0; i<n; i++)
		cin>>s[i].price>>s[i].size;
	sort(s, s+n);
	long long ans = 0;
	for (int i=0; i<n && m>0; i++) {
		int need = min(m, s[i].size);
		s[i].size -= need;
		m -= need;
		ans += (long long)need*(long long)s[i].price;
	}
	cout<<ans<<endl;
	return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;

void Main() {
  ll n, k;
  cin >> n >> k;
  
  ll total = 0;
  FOR(i, k, n + 1) {
    ll min_ans = i * (i - 1) / 2;
    ll max_ans = i * (2 * n - i + 1) / 2;

    total = (total + max_ans - min_ans + 1) % MOD;
  }
  COUT(total);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3656
#include <iostream>
#include <set>

using namespace std;

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

    set<char> s;
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        s.insert(c);
    }

    if (s.size() < 4)
        cout << "Three\n";
    else
        cout << "Four\n";
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;

  if(atoi((s.substr(5,2)).c_str()) <= 4 && atoi((s.substr(8,2)).c_str()) <= 30){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int
main
(){int n,m,a=1,   b=        1;     scanf      (    "%d"
"%d"               ,&      n,    &       m    );a=   n*
(n-                 1)    /2     ; b = m *    (m-    1)
/2;                  printf      (            "%d"   ,a
+b-88-8-8+8+8+88)      ;          return      0      ;}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
	}
	int M;	cin >> M;
	vector<string> t(M);
	for (int i = 0; i < M; ++i) {
		cin >> t[i];
	}

	auto calc = [&](string _s) {
		int num = 0;
		for (string _t : s) {
			if (_t == _s) {
				++num;
			}
		}
		for (string _t : t) {
			if (_t == _s) {
				--num;
			}
		}
		return num;
	};

	int answer = 0;
	for (string _s : s) {
		answer = max(answer, calc(_s));
	}
	cout << answer << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

bool cmp(ll a,ll b){
    if(a>b){
        return 1;
    }
    return 0;
}

int main(){
    int n;
    cin>>n;
    ll a[200005];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    sort(a,a+n,cmp);
    int f=0;
    for(int i=1,j=0;i<n;i++){
        if(i%2==0){
            j++;
        }
        ans+=a[j];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int f[114514];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	int cnt = 1;
	int ccnt = m + 2;
	for (int i = m; i >= 1; i -= 2) {
		cout << cnt << " " << cnt + i << endl;
		cnt++;
	}
	for (int i = m - 1; i >= 1; i -= 2) {
		cout << ccnt << " " << ccnt + i << endl;
		ccnt++;
	}
	ggr
}

Measured memory_bytes: 3704
//1:23
#include<iostream>
#include<algorithm>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
#define T 150010
ll n,m,a[N],b[N],last;
vector<ll> g[T];
ll dfs(int x,ll lim){
    if(x<n){
	if(a[x]==0)return 1;
	if(a[x]>=lim)return 0;
	return mod;
    }
    ll sum=0,maxi=0;
    for(auto y:g[x]){
	ll t=dfs(y,lim);
	sum+=t,maxi=max(maxi,t);
    }
    return sum-maxi;
}
bool DP(ll lim){
    ll cnt=0;
    lol(i,n-m)if(b[i]>=lim)cnt++;
    return (cnt>=dfs(last-1,lim));
}
int main(){
    cin>>n>>m;
    lol(i,n)a[i]=0;
    lol(i,m){
	int x,y;
	cin>>x>>y;y--;
	a[y]=x;
    }
    lol(i,n-m)cin>>b[i];
    queue<int> Q;
    lol(i,n)Q.push(i);
    last=n;
    while(Q.size()>=3){
	lol(i,3){
	    g[last].push_back(Q.front());
	    Q.pop();
	}
	Q.push(last);
	last++;
    }
    ll l=0,r=mod,mid;
    while(l<r-1){
	mid=(l+r)/2;
	if(DP(mid))l=mid;
	else r=mid;
    }
    cout<<l<<endl;
    return 0;
}



Measured memory_bytes: 10588
def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    RSP = list(map(int, input().split()))
    T = list(input().rsplit()[0])

    win_hand = ['s', 'p', 'r']

    ans = 0
    hand = [0]*N
    for i in range(N):
        for j in range(3):
            if T[i] == win_hand[j]:
                if i >= K:
                    if T[i] == T[i-K] and T[i] == hand[i-K]:
                        continue
                hand[i] = win_hand[j]
                ans += RSP[j]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4792
#include<iostream>
#include<cstdio>
#include<deque>
#include<algorithm>
#define LL long long
#define reint register int
using namespace std;
const int N=100005;
deque<LL>que;
LL b,s[N],cot[N],ans[N];int n,m,cnt;
void push(LL x){
    while(!que.empty()&&que.back()>=x)que.pop_back();
    que.push_back(x);return;
}
int main(){
    scanf("%d%d",&n,&m);push(n);
    for(reint i=1;i<=m;i++)
    scanf("%lld",&b),push(b);
    while(!que.empty())
        s[++cnt]=que.front(),que.pop_front();
    cot[cnt]=1;
    for(reint i=cnt-1;~i;i--){
        LL len=s[i+1];
        while(len>s[1]){
            reint pos=upper_bound(s+1,s+i+1,len)-s-1;
            cot[pos]+=len/s[pos]*cot[i+1];
            len%=s[pos];
        }ans[len]+=cot[i+1];
    }
    for(reint i=s[1];i;i--)ans[i]+=ans[i+1];
    for(reint i=1;i<=n;i++)printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 4864
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		int N = I[0], M = I[1];
		WriteLine(Calc(N) * Calc(M) % MOD);
	}
	long Calc(int N)
	{
		var x = G();
		var s = new long[N + 1];
		for (var i = 0; i < N; i++) s[i + 1] = s[i] + x[i];
		var ans = 0L;
		for (var i = 0; i < N; i++) ans = (ans + (long)i * x[i] - s[i]) % MOD;
		if (ans < 0) ans += MOD;
		return ans;
	}
}

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

int main () {
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    }

    else {
        cout << "win" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

int main() {
    int n;
    cin >> n;
    VI cnt(100006,0);
    int in;
    REP(i,0,n) {
        cin >> in;
        cnt[in]++;
        if (in) cnt[in-1]++;
        cnt[in+1]++;
    }
    int ans = 0;
    REP(i,0,100006) {
        ans = max(ans,cnt[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
const int N=55;
int n;
pair<int,int>a[N];
map<pair<int,int>,bool>book;
int calc(int p,int q)
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int x=a[i].first,y=a[i].second;
		if(!book[make_pair(x-p,y-q)]) ans++;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[i]=make_pair(x,y);
		book[a[i]]=true;
	}
	sort(a+1,a+n+1);
	int ans=n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(i==j) continue;
			int x=a[i].first-a[j].first,y=a[i].second-a[j].second;
			ans=min(ans,calc(x,y));
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 7572
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    int num[3];
    int a[11] = { 0 };
    rep(i, 3){
         scanf("%d", &num[i]);
         a[num[i]] += 1;
    }
    if(a[5] == 2 && a[7] == 1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

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

Measured memory_bytes: 256
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: u64 = 1000_000_007;

fn main() {
    let s: String = read();
    let n = s.len();
    let m = 13;

    let mut dp = vec![vec![0; m]; n + 1];
    dp[0][0] = 1;

    for i in 0..n {
        let c = s.as_bytes()[i];
        if c as char != '?' {
            // 数字の場合
            for j in 0..m {
                let digit = (c - ('0' as u8)) as usize;
                dp[i + 1][(10 * j + digit) % m] += dp[i][j];
                dp[i + 1][(10 * j + digit) % m] %= MOD;
            }
        } else {
            // `?` の場合
            for j in 0..m {
                for digit in 0..10 {
                    dp[i + 1][(10 * j + digit) % m] += dp[i][j];
                    dp[i + 1][(10 * j + digit) % m] %= MOD;
                }
            }
        }
    }

    println!("{}", dp[n][5]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

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

	long long n, m;
	cin >> n >> m;

	long long f[m + 1] = {0};

	for (int i = 0; i < n; i++)
	{
		long long k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			long long temp = 0;
			cin >> temp;
			f[temp]++;
		}
	}
	long long ans = 0;
	for (int i = 1; i <= m; i++)
	{
		if (f[i] == n)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	cin >> N;
	SINT32 ans = 0;
	
	rep(i,0,N) {
		SINT32 A,B;
		cin >> A;
		cin >> B;
		ans += B-A+1;
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

S = int(input())
s = 10**9+7
result = 0

for i in range(1,(S//3)+1) : # 1 ~ maxで666
    kou = i
    samu = S - 3 * i
    result += comb((samu+kou-1),(kou-1)) % s
    result = result % s
    #print("i")
    #print(i)
    #print("kou")
    #print(kou)
    #print("samu")
    #print(samu)
    #print("comb")
    #print(comb((samu+kou-1),(kou-1)))

print(result)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

bool sec_do(pair<double, int> a, pair<double, int> b) {
  if (a.first != b.first) {
    return a.first > b.first;
  } else {
    return a.second < b.second;
  }
}




int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }

  int oriH = H;
  H += 1e4;
  vector<vector<int>> dp(N+1, vector<int>(H+1));
  rep(i,N+1) {
    rep(j,H+1) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;


  rep(i, N) {
    for (int j = 0; j <= H; j++) {
      if (j < A[i]) {
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i]);
      }
    }
  }

  int ans = INF;
  for (int ih = oriH; ih < H+1; ih++) {
    ans = min(ans, dp[N][ih]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 78592
e = 0
s = 0
n = int(input())
a = list(map(int,input().split()))

for i in range(n): 
    s += a[i]
    if i % 2 == 1:
        e += a[i]

b = []
for i in range(n):
    if (i == 0):
        b.append(s-2*e)
    else:
        b.append(2*a[i-1]-b[i-1])

print(" ".join(map(str,b)))

Measured memory_bytes: 25088
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
S = input()

lis = [0]*(N+1)

for i in range(N-1):
	if S[i] == "A" and S[i+1] == "C":
		lis[i+1] += 1

lis = list(accumulate(lis))

for _ in range(Q):
	l, r = MAP()
	print(lis[r-1]-lis[l-1])


Measured memory_bytes: 10324
#include<stdio.h>
#define N 100
#define INF 10000000
#define NIL -1
void initializeSingleSource(void);
void dijkstra(void);
int n,G[N][N],d[N],p[N],color[N];

int main(){
  int i,j,u,k,v,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=INF;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      G[u][v]=c;
    }
  }
  dijkstra();
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}
void initializeSingleSource(void){
  int v;
  for(v=0;v<n;v++){
    d[v]=INF;
    p[v]=NIL;
    color[v]=0;
  }
  d[0]=0;
}
void dijkstra(){
  int i,u,v,min;

  initializeSingleSource();

  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(color[i] != 1 && d[i] < min){
        min=d[i];
        u=i;
      }
    }
    if(min==INF){
      break;
    }
    color[u]=1;
    for(v=0;v<n;v++){
      if(d[u]+G[u][v] < d[v]){
        p[v]=u;
        d[v]=G[u][v]+d[u];
      }
    }
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll n; cin >> n;
  ll a[n], sum = 0;
  REP(i,n) { cin >> a[i]; sum+=a[i]; }

  ll ans = LINF, left=0;
  REP(i,n-1) {
    left+=a[i];
    ans = min(ans, abs(left * 2 - sum));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long N = sc.nextInt();
		long M = sc.nextInt();

		if (N == 1 && M == 1)
			System.out.println(1);
		else if (N == 1 || M == 1)
			System.out.println(N * M - 2);
		else
			System.out.println(N * M - (2 * N + 2 * M - 4));

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
N,M=map(int,input().split())
P=[-1 for _ in range(N)]
S=[-1 for _ in range(N)]
# 負，暫定のペナルティー数，　正，確定したペナルティー数
ans_num = 0
for i in range(M):
    p,s = input().split()
    p = int(p) - 1
    # 初めて正解した場合．
    if S[p] < 0 and s=='AC':
        S[p] = -S[p] - 1 # 最初は-1だから
        ans_num+=1
    # 正解してないのに間違っていた場合
    elif S[p] < 0 and s=='WA':
        S[p] -= 1
penalty_num=0
for s in S:
    if s<0:
        continue
    penalty_num += s
print(ans_num, penalty_num)


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s,t;
    cin>>s>>t;
    if(s[2]==t[0]&&s[0]==t[2]&&s[1]==t[1]){
        YES;
    }
    else{
        NO;
    }
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<ll>> dp(45, vector<ll>(2, -1));
    dp[44][0] = 0;
    for (int i = 43; i >= 0; --i) {
        ll cnt = 0;
        rep(j, n) if ((a[j]>>i)&1LL) ++cnt;
        if (k & (1LL<<i)) {
            dp[i][0] = max(dp[i][0], dp[i+1][0] + (n- cnt) * (1LL<<i));
            dp[i][1] = max(dp[i][1], dp[i+1][0] + cnt * (1LL<<i));
        }
        else {
            dp[i][0] = max(dp[i][0], dp[i+1][0] + cnt * (1LL<<i));
        }
        if (dp[i+1][1] >= 0) {
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(cnt, n - cnt) * (1LL<<i));
        }
    }
    cout << max(dp[0][1], dp[0][0]) << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j;
    int n,m;
    cin >> n >> m;
    int tmp1,tmp2;
    if(n == 0){
        tmp1 = 0;
    }else{
        tmp1 = n*(n-1)/2;
    }
    if(m == 0){
        tmp2 = 0;
    }else{
        tmp2 = m*(m-1)/2;
    }
    cout << tmp1 + tmp2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>

using namespace std;

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


Measured memory_bytes: 19188
n = int(input())
a = list(map(int,input().split()))

ans = [0 for i in range(n)]

for i in range(n, 0, -1):
    k = n // i

    an = a[i-1]

    for j in range(2,k+1):
        an = an ^ ans[j*i-1]

    ans[i-1] = an

print(sum(ans))
ans_l = [i+1 for i,x in enumerate(ans) if x == 1]
print(" ".join(map(str,ans_l)))


Measured memory_bytes: 19892
n = 10**5
is_prime = [True]*(n+1)
is_prime[0] = False
is_prime[1] = False

for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
        continue
    for j in range(i*2,n+1,i):
        is_prime[j]=False

num_li = [0]*(n+1)
cnt = 0
for i in range(n+1):
    if is_prime[i] and (i+1)//2>0 and is_prime[(i+1)//2]:
        cnt+=1
    num_li[i]=cnt

ans = []
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    ans.append(num_li[r]-num_li[l-1])

print('\n'.join(map(str,ans)))

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

int main() {
	int b, f, r,v1;
	int v[4][3][10] = { 0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v1;
		v[b - 1][f - 1][r - 1] += v1;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << v[i][j][k];
			}
			cout << endl;
		}
		if(i!=3) cout << "####################" << endl;
	}
}


Measured memory_bytes: 3104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var go = 0;
        var siti = 0;
        for(var i = 0; i < 3; i++)
        {
            var input = r.nextInt();
            if (input == 5)
            {
                go++;
            } else if(input == 7)
            {
                siti++;
            }

        }

        if (go == 2 && siti == 1)
        {
            Console.WriteLine("YES");
        } else
        {
            Console.WriteLine("NO");
        }

    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

    public Reader()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length)
            return s[i++];
        var input = Console.ReadLine();
        while (input == "")
            input = Console.ReadLine();
        s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}


Measured memory_bytes: 2648
#include<iostream>
#include<queue>
#include<utility>
#include<string>

int main()
{
    int n, q ;
    std::cin >> n >> q ;

    using process = std::pair<std::string, int> ;

    std::queue<process> que;

    process a ;
    for(int i = 0 ; i != n ; ++i)
    {
        std::cin >> a.first >> a.second ;
        que.push( a ) ;
    }

    int time{} ;
    std::queue<process> timetable ;

    while(!que.empty())
    {
        a = que.front() ;
        que.pop() ;
        if(q < a.second)
        {
            time += q ;
            a.second -= q ;
            que.push(a) ;

        }
        else
        {
            time += a.second ;
            a.second = time ;
            timetable.push(a) ;
        }
    }

    while(!timetable.empty())
    {
        std::cout << timetable.front().first << " " << timetable.front().second << std::endl ;
        timetable.pop();
    }

}


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

int main()
{
    string a,b;
    cin>>a>>b;
    int n=a.size(),sum=0;
    for(int i =0;i<=n;i++){
        if(a[i] != b[i]){
            sum++;
            }
        }
        cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3916
d, g = map(int, input().split())
pc = [[int(_) for _ in input().split()] for i in range(d)]

min_problem = 1100
for i_num in range(2 ** d):
    score = 0
    num_problem = 0
    for i_pos in range(d):
        if (i_num >> i_pos) & 1 == 0:
            continue
        score += pc[d-i_pos-1][1] + (d-i_pos)*100*pc[d-i_pos-1][0]
        num_problem += pc[d-i_pos-1][0]
    
    if score < g:
        for j_pos in range(d):
            if (i_num >> j_pos) & 1 == 0:
                add_position = d-j_pos-1
                break
        for j_problem_ammount in range(1, pc[add_position][0]):
            add_score = score + (add_position+1)*100*j_problem_ammount
            if add_score >= g:
                min_problem = min(min_problem, num_problem+j_problem_ammount)
                break
    else:
        min_problem = min(min_problem, num_problem)

print(min_problem)

Measured memory_bytes: 42096