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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;

    return 0;
}


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

int main(){
	int n,f[100][100],p[100][11];

	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++)cin>>f[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++)cin>>p[i][j];
	}

	int ans=-(1<<30);
	for(int b=1;b<(1<<10);b++){
		int cc=0;
		for(int i=0;i<n;i++){
			int c=0;
			for(int j=0;j<10;j++)
				if(((b>>j))&1&&f[i][j])c++;
			cc+=p[i][c];
		}
		if(ans<cc)ans=cc;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else
        cout << c << " " << a << " " << b << endl;
}
    


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

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

  int h[100001];

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

  int bucket[100001] = {0};
  for (int i = 0; i < m; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    if (h[tmp1-1] > h[tmp2-1]) {
      bucket[tmp2-1] = -1;
    } else if (h[tmp1-1] < h[tmp2-1]) {
      bucket[tmp1-1] = -1;
    } else {
      bucket[tmp1-1] = -1;
      bucket[tmp2-1] = -1;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (bucket[i] >= 0) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3944
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        n:usize,
        mut a:[isize;n],
        mut b:[isize;n]
    }

    let mut ba = 0;
    let mut bb = 0;
    for i in 0..n {
        if a[i] > b[i] {
            ba += a[i] - b[i];
        }
        if a[i] < b[i] {
            bb += (b[i] - a[i]) / 2;
        }
    }
    if bb >= ba {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2496
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 45

struct Edge{
	Edge(){

		to = 0;
		loc = 0;
	}
	Edge(int arg_to,int arg_loc){
		to = arg_to;
		loc = arg_loc;
	}
	int to,loc;
};

int DIST,N,len_T,len_P;
int num_ans;
int dp[SIZE][SIZE];
string T;
vector<string> P,ANS;
map<string,bool> MAP;
vector<Edge> G[SIZE];


bool is_OK(string line,int head,int tail){

	int cost;
	int minimum;

	for(int row = head; row <= tail; row++){

		minimum = BIG_NUM;

		for(int col = max(1,row-DIST); col <= min(len_T,row+DIST); col++){
			if(T[col-1] == line[row-1]){
				cost = 0;
			}else{
				cost = 1;
			}
			dp[row][col] = min(dp[row-1][col-1]+cost,min(dp[row-1][col]+1,dp[row][col-1]+1));
			minimum = min(minimum,dp[row][col]);
		}
		if(minimum > DIST){

			return false;
		}
	}
	return true;
}

void recursive(string line,int index){

	auto at = MAP.find(line);
	if(at != MAP.end())return;

	MAP[line] = true;

	if(dp[line.length()][len_T] <= DIST){

		num_ans++;
		if(num_ans <= 5){

			ANS.push_back(line);
		}
	}

	for(int i = 0; i < G[index].size(); i++){
		int next = G[index][i].to;
		int loc = G[index][i].loc;

		if(line.length()+(len_P-loc) > len_T+DIST){

			break;
		}
		string next_line = line+P[next].substr(loc);

		if(is_OK(next_line,line.length()+1,next_line.length())){

			recursive(next_line,next);
		}
	}
}

void func(){

	MAP.clear();
	P.clear();
	ANS.clear();
	for(int i = 0; i < N; i++){

		G[i].clear();
	}

	cin >> T;
	len_T = T.length();

	for(int loop = 0; loop < N; loop++){

		string tmp_str;
		cin >> tmp_str;
		P.push_back(tmp_str);
	}
	len_P = P[0].length();

	sort(P.begin(),P.end());
	P.erase(unique(P.begin(),P.end()),P.end());

	bool FLG;

	for(int i = 0; i < P.size(); i++){
		string from = P[i];
		for(int len = len_P-1; len >= 0; len--){ //一致長
			for(int k = 0; k < P.size(); k++){
				string to = P[k];

				FLG = true;
				for(int k = 0; k < len; k++){
					if(from[len_P-len+k] != to[k]){
						FLG = false;
						break;
					}
				}
				if(FLG){

					G[i].push_back(Edge(k,len));
				}
			}
		}
	}

	for(int row = 0; row <= len_T+DIST; row++){
		for(int col = 0; col <= len_T; col++){

			dp[row][col] = BIG_NUM;
		}
	}

	for(int row = 1; row <= len_T+DIST; row++){
		dp[row][0] = row;
	}

	for(int col = 0; col <= len_T; col++){
		dp[0][col] = col;
	}

	num_ans = 0;

	for(int i = 0; i < P.size(); i++){

		if(is_OK(P[i],1,len_P)){

			recursive(P[i],i);
		}
	}

	printf("%d\n",num_ans);

	if(num_ans <= 5){

		sort(ANS.begin(),ANS.end());

		for(int i = 0; i < ANS.size(); i++){

			printf("%s\n",ANS[i].c_str());
		}
	}
}

int main(){

	while(true){

		scanf("%d %d",&DIST,&N);
		if(DIST == 0 && N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 22340
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

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

using namespace std;

int main(void) {
  int x;
  cin >> x;

  string s[7] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};
  cout << s[(x - 9 + 49) % 7] << endl;

  return 0;
}


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

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

  sort(a.begin() , a.end());
  //int init = 3*n/2;
  long long sum = 0;
  int cnt = n;
  for(int i = 3*n - 2; i >= 0; i-= 2) {
    sum += (long long)a[i];
    cnt--;
    if(cnt <= 0) break;
  }
  cout << sum << endl;
}


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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B;
  cin >> A >> B;
  string ans = (!(A % 2 == 0 || B % 2 == 0)) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


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

#define int long long

using namespace std;

signed main()
{
	int n;
	int a[200000];
	int sum[200001] = { 0 };

	cin >> n;

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

	sort(a, a + n);

	// [)
	for(int i = 1; i <= n; ++i)
	{
		sum[i] = sum[i - 1] + a[i - 1];
	}

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

	for(int i = 0; i <= n; ++i)
	{
		cout << sum[i] << " ";
	}
	cout << endl;
	*/
	
	//cout << sum[n] - sum[3] << endl;
	//cout << sum[n] - sum[4] << endl;

	//cout << "ans" << endl;

	int d = 1LL << 60LL;

	//cout << d << endl;

	for(int i = 0; i < n; ++i)
	{
		int b = a[i];
		int leftD = (i * b) - (sum[i]);
		int rightD = (sum[n] - sum[i + 1]) - (n - 1 - i) * b;
		/*
		if(d > leftD + rightD)
		{
			cout << i << " : " << leftD << " " << rightD << endl;
		}
		*/
		d = min(d, leftD + rightD);
	}

	cout << d << endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int w,h;
  
  while(true){
    cin >> h >> w;
    if(w==0&&h==0) break;
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
  }
 
  return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")



int main() {
	int n;
	cin >> n;
	if (n >= 64)cout << 64 << endl;
	else if (n >= 32)cout << 32 << endl;
	else if (n >= 16)cout << 16 << endl;
	else if (n >= 8)cout << 8 << endl;
	else if (n >= 4)cout << 4 << endl;
	else if (n >= 2)cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3620
#D
n = int(input())
a = list(map(int, input().split()))

ans = -1
subst = 0
nxtid = 1
for i in range(n):
    if a[i] == nxtid:
        subst += 1
        nxtid += 1
if subst > 0:
    ans = n - subst
print(ans)


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n = s.size();
  int res = 0;
  for(int i = 0; i < n / 2; ++i){
    if(s[i] != s[n - i - 1])res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
ll dp[105][100005];
ll cap;
ll w[1001];
ll val[1001];
ll a;
ll cal(ll ind, ll v )
{
    if(v==0)
        return 0 ;
    if(ind==a)
        return 100000000000000;

    if(dp[ind][v]!=-1)
        return dp[ind][v];
    ll pick =0,leave=0;

    pick =  w[ind]+cal(ind+1,v-val[ind]);
    leave = cal(ind+1,v);
    return dp[ind][v]=min(leave,pick);


}
int main()
{


    memset(dp,-1,sizeof dp);
    cin>>a>>cap;
    for(int i = 0 ; i< a ; i++)
    {

        cin>>w[i]>>val[i];

    }
     for(int i=100000;i>0;i--)
    {
        if(cal(0,i)<=cap)
           {

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

    return  0 ;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string s,t; cin >> s >> t;

  s += s;
  auto it = s.find(t, 0);
  
  cout << (it != s.npos ? "Yes" : "No") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
def main():
    #import sys
    #input = sys.stdin.readline
    A,B = map(int, input().split())
    m = B-A
    a = A%2
    b = B%2
    
    if a == 0:
        if b ==0:
            ans =B^(m//2%2)
        else:
            ans = (m+1)//2%2
    else:
        if b ==0:
            ans = A^((m-1)//2%2)^B
        else:
            ans = A^(m//2%2)
    
    print(ans)
    
    
main()

Measured memory_bytes: 38460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll uint64_t
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
// add and sum O(logn)
template <class T> struct fenwick_tree {

  public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    // add x to pos p i.e. a[p] += x
    void add(int p, T x) {
        p++;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }

    // sum a[l] till a[r-1]
    T sum(int l, int r) {
        return sum(r) - sum(l);
    }

  private:
    int _n;
    std::vector<T> data;

    T sum(int r) {
        T s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};



void solve(){
    int n,q; cin >> n >> q;
    fenwick_tree<ll> fw(n);
    FOR(n){
        int x; cin >> x;
        fw.add(i,x);
    }
    FOR(q){
        int t,u,v; cin >> t >> u >> v;
        if(t) cout << fw.sum(u,v) << '\n';
        else fw.add(u,v);
    }
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 8224
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string a, b, c;
  cin >> a >> b >> c;

  char dif = 'A' - 'a';
  cout << char(a.at(0) + dif) << char(b.at(0) + dif) << char(c.at(0) + dif) << endl;
}


Measured memory_bytes: 3556
import copy

n, m, q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

ans = 0

def dfs(al):
    global ans
    if len(al) == n:
        test = 0
        for i in range(q):
            if al[b[i]-1] - al[a[i]-1] == c[i]:
                test += d[i]
        ans = max(ans, test)
        return
    
    al.append(al[-1])
    i = len(al)
    while True:
        if al[i-1] > m:
            break
        dfs(copy.deepcopy(al))
        al[i-1] += 1

dfs([1])
print(ans)


Measured memory_bytes: 83556
n=int(input())
w=[int(i) for i in input().split()]
ans_list=[]
for x in range(n):
    g_1=w[0:x+1]
    g_2=w[x+1:n]
    s_1=sum(g_1)
    s_2=sum(g_2)
    ans=abs(s_1-s_2)
    ans_list.append(ans)
print(min(ans_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,m;
pair<int,int> qujian[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	pair<int,int> common=make_pair(1,n);
	for(int i=1;i<=m;i++)
	{
		cin>>qujian[i].first>>qujian[i].second;
	}
	sort(qujian+1,qujian+m+1);
	for(int i=1;i<=m;i++){
		common.first=max(common.first,qujian[i].first);
		common.second=min(common.second,qujian[i].second);
	}
	if(common.second>=common.first)
		cout<<common.second-common.first+1<<endl;
	else
		cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
	int N;
	Scanner scan = new Scanner(System.in);

	N = scan.nextInt();
	List<Long> A = new ArrayList<>(N);
	for (int i = 0; i < N; i++) {
	    A.add(scan.nextLong());
	}

	Collections.sort(A);

	for (int i = 0; i < N-1; i++) {
	    if (A.get(i) + A.get(i+1) < 0) {
		A.set(i, A.get(i) * -1);
		A.set(i+1, A.get(i+1) * -1);
	    }
	}

	long sum = 0;
	for (int i = 0; i < N; i++) {
	    sum += A.get(i);
	}
	System.out.println(sum);
	return;
    }
}

Measured memory_bytes: 62256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; //4桁
  cin >> n;
  int num1 = n / 1000;
  int num2 = (n - (num1*1000))/100;
  int num3 = (n - ((num1*1000)+(num2*100)))/10;
  int num4 = n % 10;
  
  if(num1==num2 && num2==num3){
    cout << "Yes" << endl;
  }else if(num2==num3 && num3==num4){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
ALPHA_BET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

def solve():
	H, W = list(map(int, input().split()))
	for i in range(H):
		line = input().split()
		for j, s in enumerate(line):
			if s == "snuke":
				print(ALPHA_BET[j] + str(i+1))
				return
		
solve()

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int A, B, C;

int main()
{
    cin >> A >> B >> C;
    cout << ((A + B >= C) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(),(c).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define debug2(x,y) cerr<<"("<<#x<<","<<#y<<") = ("<<x<<","<<y<<")\n";
#define debugM(x,n,m) rep(i,0,n){ rep(j,0,m) cerr<<x[i][j]<<" ";cerr<<endl;}
#define debugV(x,n) rep(i,0,n){cerr<<x[i]<<" ";}cerr<<endl; 
#define pi 3.14159265358979323846264338
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const int MOD = 1e9+7;

int main(){
	int n,aux,a,b;
	while(cin>>n){
		cin>>a>>b;
		vector<int> me, en,ma;
		rep(i,0,n){
			cin>>aux;
			if(aux<=a)
				me.pb(aux);
			else if(aux<=b)
				en.pb(aux);
			else ma.pb(aux);
		}
		cout<<min(me.size(),min(ma.size(),en.size()))<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<string,int> p;
// ll lcm(ll a ,ll b)
// {
//     return (a*b)/__gcd(a,b);
// }
int main()
{
    FastRead;
    ll n,mx=0;
    cin>>n;
    ll a[n];
    rep2(i,n)
    {
        cin>>a[i];
    }
    bool p[n][n]={0};
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(i==j) continue;
            else
            {
                if(!p[i][j])
                {
                    mx+=a[i]*a[j];
                    p[i][j]=1;
                    p[j][i]=1;
                }
            }
        }
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

ll X, Y;

int main(){
	cin >> X >> Y;

	int cnt = 1;
	ll A = X;
	while(1){
		A *= 2;
		if(A <= Y) cnt++; 
		else break;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
if N < 10:
    print(N)
    exit()

while N%10 == 0:
    N = N//10

if N == 1:
    print(10)
    exit()

str_n = str(N)
int_n = map(int, str_n)
ans = sum(int_n)
print(ans)


Measured memory_bytes: 3060
def add(a):
	if int(a)>n:
		return 0
	else:
		ans = 0
		a = '' if int(a)==0 else a
		if a.find('3')>-1 and a.find('5')>-1 and a.find('7')>-1:
			ans+=1
		for i in [3,5,7]:
			ans+=add(a+str(i))
		return ans

n = int(input())
print(add('0'))


Measured memory_bytes: 3060
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
/**
 * snuke code
**/
fn main() {
    input! {
            h:usize,
            w:usize,
            k:usize,
        s:[Chars;h],
    }
    // dbg!(&s);
    let mut ans = INF;
    // 横に切る方法を全探索
    for div in 0..(1usize << (h - 1)) {
        let mut g: usize = 0;
        let mut id = vec![0usize; h + 1];
        for i in 0..h {
            id[i] = g;
            if (((div >> i) & 1) == 1) {
                g += 1;
            }
        }
        g += 1;
        let mut c = vec![vec![0usize; w]; g];
        for i in 0..h {
            for j in 0..w {
                c[id[i]][j] += (s[i][j] as u8 - b'0') as usize;
            }
        }

        // dbg!(&c);
        let mut num: usize = g - 1;
        // 各グループで何個のホワイトチョコがあるか
        let mut now = vec![0usize; g];
        for j in 0..w {
            if !add(&mut now, j, g, k, &c) {
                num += 1;
                now = vec![0usize; g];
                if !add(&mut now, j, g, k, &c) {
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    println!("{}", ans);
}
// j列目をnowに加算
fn add(now: &mut Vec<usize>, j: usize, g: usize, k: usize, c: &Vec<Vec<usize>>) -> bool {
    for i in 0..g {
        now[i] += c[i][j];
    }
    for i in 0..g {
        if now[i] > k {
            return false;
        }
    }
    return true;
}
const INF: usize = 1 << 62;

pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 2216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

main(){
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a*(a-1)/2 + b*(b-1)/2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 = 1e16;

int n;

int main(){
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    multiset<ll>ms;
    rep(i,n){
        ll now = a[i];
        auto itr = ms.lower_bound(now);
        if(itr==ms.begin()){
            ms.emplace(now);
        }
        if (itr!=ms.begin()){
            itr--;
            ms.erase(itr);
            ms.emplace(now);
        }
    }
    cout << ms.size() << endl;
    return 0;
}



Measured memory_bytes: 5760
#include<iostream>
#include <cstdio>
#include <map>
using namespace std;
map<char,int> arrs;
char arr[5];
int main(){
	scanf("%s",&arr);
	int s=1;
	for(int i=1;i<4;i++){
		if(arr[i]==arr[i-1]){
			s=0;
			break;
		}
	}
	if(s){
		cout<<"Good"<<endl;
	}else{
		cout<<"Bad"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define A 0
#define X 1
#define Y 2
#define Z 3
#define W 4
#define B 5
#define NOT -1

int main()
{
    string inp;
    int map[6][2];

    map[A][0] =  X;
    map[A][1] =  Y;
    map[X][0] =  NOT;
    map[X][1] =  Z;
    map[Y][0] =  X;
    map[Y][1] =  NOT;
    map[Z][0] =  W;
    map[Z][1] =  B;
    map[W][0] =  B;
    map[W][1] =  Y;
    map[B][0] =  Y;
    map[B][1] =  X;

    while (cin >> inp, inp != "#") {
        int nxt = A;
        bool flag = true;

        for (int i = 0; i < inp.size(); i++) {
            nxt = map[nxt][inp[i] - '0'];

            if (nxt == NOT) {
                flag = false;
                break;
            }
        }
        if (nxt == B && flag)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  
  int64_t a, b; cin >> a >> b;
  
  if (0 < a) {
    cout << "Positive" << endl;
    return 0;
  }
  
  if (a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }
  
  int64_t dif = abs(a - b);
  
  if (dif % 2 == 0) cout << "Negative" << endl;
  
  else cout << "Positive" << endl;
  
}

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

typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    if(k==0){
        cout<<n*n;
        return 0;
    }
    for(int i=1;i<=n;i++){
        ll locans=0;
        ll s=n/i;
        ll r=n%i;
        if(k<i){
            locans+=s*(i-k);
            if(r>=k){
                locans+=r-k+1;
            }
        }
     //   cout<<locans<<" "<<i<<endl;
        ans+=locans;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    INF = 10**12
    dp = [INF] * (N+1)
    dp[1] = 0
    for i in range(1,N):
        for j in range(1,K+1):
            if i+j > N:
                break
            else:
                dp[i+j] = min(dp[i+j],dp[i]+abs(h[i-1]-h[i+j-1]))
    print(dp[N])

if __name__ == "__main__":
    main()

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

vector<vector<int>> v;
vector<int> res;
long long n, x, y;

void solve();

int main() {
  cin >> n;
  int x, y;
  v.resize(n);
  for(int i = 0; i < n - 1; ++i) {
    v[i].push_back(i + 1);
    v[i + 1].push_back(i);
  }
  cin >> x >> y;
  v[--x].push_back(--y);
  v[y].push_back(x);
  res.assign(n, 0);
  solve();
  for(int i = 1; i < n; ++i) cout << res[i] / 2 << endl;
  return 0;
}

void solve() {
  for(int i = 0; i < n; ++i) {
    vector<int> dis(n, -1);
    queue<int> qu;
    qu.push(i);
    dis[i] = 0;
    while(!qu.empty()) {
      int now = qu.front();
      qu.pop();
      for(auto to : v[now])
        if(dis[to] == -1) {
          dis[to] = dis[now] + 1;
          ++res[dis[to]];
          qu.push(to);
        }
    }
  }
}

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

int main() {
	int n;
	cin>>n;
	vector<ll> A(n);
	rep(i,n)cin>>A[i];
	//累積和
	vector<ll> s(n+1,0);
	rep(i,n)s[i+1]=s[i]+A[i];
	
	//sort(s.begin(),s.end());
	
	map<ll,ll> hindo;
	rep(i,n+1){
		if(hindo.count(s[i]))hindo[s[i]]++;
		else hindo[s[i]]=1;
	}
	
	ll sum=0;
	for(auto p:hindo){
		ll n=p.second;
		sum+=n*(n-1)/2;
	}
	
	cout<<sum<<endl;
}

//RE

Measured memory_bytes: 15872
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i=0; i<n; i++) {
			list.add(in.nextInt());
		}
		int count = 1;
		int k = 0;
		for(int i=0; i<n; i++){
			if(list.get(i)==count) {
				count+=1;
			}else {
				k+=1;
			}
		}
		if(count ==1) System.out.println("-1");
		else System.out.println(k);
	}
}


Measured memory_bytes: 83148
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using ll = long long;
//typedef long long ll;

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

#define INF ((1LL << 31) - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD (ll)(1e9+7)
#define EPS 1e-10
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[4] = {-1, 0, 1, 0}, vy[4] = {0, -1, 0, 1};
//int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

// [sx, se), [sy, ey)であることに注意
inline bool check(int sx, int ex, int sy, int ey, int x, int y) {
  return (sx <= x and x < ex and sy <= y and y < ey);
}

inline bool check(int ex, int ey, int x, int y) {
  return check(0, ex, 0, ey, x, y);
}

std::vector<std::string> split(const std::string& s, char delim) {
  std::vector<std::string> ret;
  std::stringstream ss(s);
  std::string tmp;

  while (std::getline(ss, tmp, delim)) {
    ret.push_back(tmp);
  }

  return ret;
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

#define int long long

int n;
std::vector<int> c, f, s;

signed main() {
  init();

  cin >> n;
  c.resize(n);
  f.resize(n);
  s.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n - 1; ++i) {
    int ans = 0;
    for (int j = i; j < n - 1; ++j) {
      if (j == i) {
        ans += s[j] + c[j];
      } else {
        if (s[j] >= ans) {
          ans += ((s[j] - ans) + c[j]);
        } else {
          //ans += ((ans % f[j]) + c[j]);
          int l = 0, r = 1000000000, m;
          while (r - l > 1) {
            m = (l + r) / 2;
            if (s[j] + m * f[j] >= ans) {
              r = m;
            } else {
              l = m;
            }
          }
          ans += (s[j] + r * f[j] - ans) + c[j];          
        }
      }
    }
    cout << ans << endl;
  }
  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

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

	// Lを求めつつ、Nのいらない部分をカット
	int L = 0;
	for (ll p = 1; N >= p; L++, p *= 26) { N -= p; }

	// 名前を'a'埋め文字列として生成
	char* name = (char*)malloc((L + 1) * sizeof(char));
	name[L] = '\0';
	memset(name, 'a', L);

	// 下の桁から順に置き換えていく
	for (int i = L; N > 0;) {
		name[--i] = (char) ('a' + N % 26);
		N /= 26;
	}

	printf("%s\n", name);
	return 0;
}


Measured memory_bytes: 1664
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,w,a[110],b[110],dp[110][10010],i,j;
  scanf("%d %d\n",&n,&w);
  for(i=1;i<=n;i++){
    scanf("%d %d\n",&a[i],&b[i]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=w;j++){
      dp[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    for(j=0;j<=w;j++){
      dp[i][j]=max(dp[i][j],dp[i-1][j]);
      if(j-b[i]>=0){
        dp[i][j]=max(dp[i][j],dp[i][j-b[i]]+a[i]);
      }
    }
  }
  int ans=0;
  for(i=0;i<=w;i++){
    ans=max(ans,dp[n][i]);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 7144
n=int(input())
c=str(input())
#c=c[::-1]
#print(c)
black=c.count('#')
white=n-black
left=0#左は黒を消す
right=white#右はしろを消す
#print(white,black)
ans=right
for i in range(n):
    if c[i]=='#':
        left+=1
    else:
        right-=1
    
    ans=min(ans,left+right)
print(ans)

Measured memory_bytes: 3500
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int K,T;
  in(K,T);
  vector<int> a(T);
  rep(i,T)in(a[i]);
  int t=*max_element(all(a));
  out(max(t-1-(K-t),0));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	puts(b-a==c-b?"YES":"NO");
	return 0;
}

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

typedef long long ll;

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


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

    ll n; cin >> n;
    map<ll, int> mp;
    rep(i, n) {
        ll a; cin >> a;
        if(mp[a] == 0) mp[a]++;
        else mp[a] = 0;
    }
    int ans = 0;
    for(auto e : mp) {
        if(e.second > 0) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
vecint a;
vec2int dp;
int n, k;
bool rec(int p, int q) {
  // if (p <= 0) return false;
  if (dp[p][q] != -1) return dp[p][q] == 1 ? true : false;
  int r = 0;
  if (q == 0) r = 1;
  REP(i, n) {
    if (p >= a[i]) {
      if (!rec(p - a[i], r)) {
        dp[p][q] = 1;
        return true;
      }
    }
  }
  dp[p][q] = 0;
  return false;
}
int main() {
  init();
  cin >> n >> k;
  a.resize(n);
  for (auto& e : a) cin >> e;
  dp = vector<vector<int> >(k + 1, vecint(2, -1));
  REP(i, a[0]) dp[i][0] = dp[i][1] = 0;
  for (const auto& e : a) dp[e][0] = dp[e][1] = 1;
  // // REP(i, k + 1) { cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
  // }
  cout << (rec(k, 0) ? "First" : "Second") << endl;
  // REP(i, k + 1) { cout << "i: " << dp[i][0] << " " << dp[i][1] << endl; }
}



Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<cstring>
#include<deque>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    
    deque<char> ans;
    for(int i=0;i<s.size();i++){
        ans.push_back(s[i]);
    }
    
    int rvtime=0;
    int qr;
    cin>>qr;
    
    char t,f;
    char c;
    while(qr--){
        cin>>t;
        if(t=='1') rvtime++;
        else{
            cin>>f>>c;
            if((f=='1'&&rvtime%2==0)||(f=='2'&&rvtime%2)) ans.push_front(c);
            else ans.push_back(c);
        }
    }
    
    if(rvtime%2==0) {
        for(auto it=ans.begin();it!=ans.end();it++){
            cout<<*it;
        }
        cout<<endl;
    }else{
        for(auto it=ans.end()-1;it!=ans.begin()-1;it--){
            cout<<*it;
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <memory>
#include <algorithm>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <functional>
#include <cassert>
using namespace std;

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

int main(int argn, char **argc) {

	cin >> n;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	long long sol = 0;
	for (int i = 1; i <= n; ++i) {
		if (b[i] >= a[i]) {
			sol += a[i];
			b[i] -= a[i];
		} else {
			a[i] -= b[i];
			sol += b[i];
			b[i] = 0;
		}
		if (b[i] >= a[i+1]) {
			sol += a[i+1];
			b[i] -= a[i+1];
			a[i+1] = 0;
		} else {
			a[i+1] -= b[i];
			sol += b[i];
			b[i] = 0;
		}
	}
	cout << sol << endl;

    return 0;
}

Measured memory_bytes: 1024
#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(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        mp[x]++;
    }
    if (mp.size() > 2) {
        cout << "No" << endl;
        return 0;
    }
    if (mp.size() == 2) {
        int l = inf, r = -1;
        for (P p : mp) {
            chmax(r,p.first);
            chmin(l,p.first);
        }
        if (r - l != 1 || mp[l] >= r) {
            cout << "No" << endl;
        } else {
            if (n + mp[l] >= 2 * r) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
    if (mp.size() == 1) {
        int k;
        for (P p : mp) k = p.first;
        if (k + 1 == n || n >= 2 * k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 8288
sss = input()
while not sss == '0 0':
	n,x = map(int, sss.split(' '))
	counter = 0
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if i+j+k == x: counter += 1
	print(counter)
	sss = input()


Measured memory_bytes: 7680
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n;
	while(cin>>n&&n!=0){
		int a[86400]={};
		for(int i=0;i<n;i++){
			string s,t;
			cin>>s;
			int from= ((s[0]-'0')*10+ (s[1]-'0'))*3600
					+ ((s[3]-'0')*10+ (s[4]-'0'))*60
					+ ((s[6]-'0')*10+ (s[7]-'0'));
			cin>>t;
			int to= ((t[0]-'0')*10+ (t[1]-'0'))*3600
					+ ((t[3]-'0')*10+ (t[4]-'0'))*60
					+ ((t[6]-'0')*10+ (t[7]-'0'));
			for(int j=from;j<to;j++){
				a[j]++;
			}
		}
		
		sort(a,a+86400);
		cout<<a[86399]<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1564
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
        ce("ARC");
    else
        ce("ABC");
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll yuan=100;//然后0.01每年涨
	int t = 0;
	while(yuan<n){
		t++;//年数 
		yuan=yuan*(1+0.01);
		//cout << yuan << endl;
	} 
	cout << t;
	return 0;
} 

Measured memory_bytes: 3632
use std::collections::HashSet;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let (a, b): (usize, usize) = parse!(it, 2);
        g[a - 1].push(b - 1);
    }

    for start in 0..std::cmp::min(n, 2) {
        let mut cycles = vec![];
        let mut parents = vec![std::usize::MAX; n];
        let mut seen = vec![Unseen; n];
        seen[start] = Seen;
        dfs(&g, start, &mut seen, &mut parents, &mut cycles);
        'outer: for cycle in cycles {
            for &i in cycle.iter() {
                let mut count = 0;
                for j in g[i].iter() {
                    if cycle.contains(j) {
                        count += 1;
                    }
                }
                if count > 1 {
                    continue 'outer;
                }
            }
            println!("{}", cycle.len());
            for i in cycle {
                println!("{}", i + 1);
            }
            return;
        }
    }
    println!("{}", -1);
}

fn get_cycle(parents: &Vec<usize>, start: usize, end: usize) -> HashSet<usize> {
    let mut ret = HashSet::new();
    let mut cur = end;
    while cur != start {
        ret.insert(cur);
        cur = parents[cur];
    }
    ret.insert(start);
    ret
}

fn dfs(
    g: &Vec<Vec<usize>>,
    u: usize,
    seen: &mut Vec<State>,
    parents: &mut Vec<usize>,
    cycles: &mut Vec<HashSet<usize>>,
) {
    for &v in g[u].iter() {
        match seen[v] {
            Unseen => {
                seen[v] = Seen;
                parents[v] = u;
                dfs(g, v, seen, parents, cycles);
            }
            Seen => {
                cycles.push(get_cycle(parents, v, u));
            }
            _ => (),
        }
    }
    seen[u] = Checked;
}

#[derive(Clone, Copy, Debug)]
enum State {
    Unseen,
    Seen,
    Checked,
}
use State::*;

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4476
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[111];
int main()
{
	int n;
	int ans=214748364,now;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=-100;i<=100;i++)
	{
		now=0;
		for(int j=1;j<=n;j++)
			now+=(a[j]-i)*(a[j]-i);
		ans=min(ans,now);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
str_num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(str_num[int(input())-1])

Measured memory_bytes: 3060