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

int main() {
    int N; cin >> N;
    vector<vector<pair<int, int>>> testimony(N);
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        for(int j = 0; j < a; ++j) {
            int x, y; cin >> x >> y;
            testimony[i].push_back({x - 1, y});
        }
    }
    int ans = 0;
    for(int st = 0; st < (1 << N); ++st) {
        bool possible = true;
        for(int i = 0; i < N; ++i) {
            if((st & (1 << i)) > 0) {
                for(auto &t : testimony[i]) {
                    if(t.second != ((st & (1 << t.first)) > 0)) possible = false;
                }
            }
        }
        int cnt = 0;
        for(int i = 0; i < N; ++i) {
            cnt += (st & (1 << i)) > 0;
        }
        if(possible) ans = max(ans, cnt);
    }
    cout << ans << "\n";
}

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

using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<bool> A(N, false);
    REP(i,K){
        int d;
        cin >> d;
        REP(j, d){
            int x;
            cin >> x;
            A[x-1] = true;
        }
    }
    cout << count(A.begin(), A.end(), false) << endl;
    return 0;
}

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

int main(){
  long long x;
  cin >> x;
  for(int i=0; i<=1000; i++){
    for(int j=-1000; j<=1000; j++){
      if(i*i*i*i*i - j*j*j*j*j == x){
	cout << i << " " << j << endl;
	return 0;
      }
    }
  }
}


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

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

  ll X; cin >> X;
  ll ans = 0;
  ll A = 100;
  while (true) {
    ans++;
    A = A + A / 100;
    if (A >= X) break;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3600
import sys
from bisect import bisect_right
from itertools import chain, compress

ub = 50000
is_prime = [0, 0, 1, 1] + [0]*(ub-3)
is_prime[5::6] = is_prime[7::6] = [1]*int(ub/6)
primes = [2, 3]
append = primes.append

for n in chain(range(5, ub, 6), range(7, ub, 6)):
    if is_prime[n]:
        append(n)
        is_prime[n*3::n*2] = [0]*((ub-n)//(n*2))
primes.sort()

for n in map(int, sys.stdin):
    if not n:
        break
    if n%2:
        print(is_prime[n-2])
    else:
        print(len([1 for p in primes[:bisect_right(primes, n/2)] if is_prime[n-p]]))


Measured memory_bytes: 6752
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int N, s0 = 0, s1 = 0, m = 100000, d;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
    s1 += W[i];
  }

  for (int i = 0; i < N; i++) {
    s1 -= W[i];
    s0 += W[i];
    d = abs(s1 - s0);
    m = min(m, d);
  }
  cout << m << endl;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n;
  cin >> n;
  vector <ll> a;
  REP(i,n){
    ll c;
    cin >> c;
    a.pb(c);
  }
  ll d[n];
  d[n-1] = 25000;
  ll c[n];
  c[0] = 25000;
  for(int i = n-2;i >= 0;i--){
    d[i] = d[i+1]+25000;
    c[n-i-1] = d[i]; 
  }
  REP(i,n){
    d[a[i]-1] += i+1;
  }
  REP(i,n){
    cout << c[i] << " ";
  }
  cout << endl;
  REP(i,n){
    cout << d[i] << " " ;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] stones = new int[n];
        for(int i=0; i<n; i++) stones[i] = scanner.nextInt();
        int[] dp = new int[n];
        for(int i=1; i<n; i++) {
            dp[i] = dp[i - 1] + Math.abs(stones[i] - stones[i - 1]);
            for(int j=2; j<=k && i-j >= 0; j++)
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(stones[i] - stones[i - j]));
        }
        System.out.println(dp[n-1]);

    }

}


Measured memory_bytes: 51632
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Union-Find
struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -par[root(x)];
    }
};

// Main Code
int main() {
    int n, m;
    cin >> n >> m;
    
    UnionFind uf1(n), uf2(n * 2);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        uf1.unite(u, v);
        uf2.unite(u + n, v); uf2.unite(u, v + n);
    }
    
    vector<bool> vec(n, true);
    vector<int> siz(n, 0);
    rep(i, n) {
        if (uf2.same(i, i + n)) vec[uf1.root(i)] = false;
        ++siz[uf1.root(i)];
    }
    ll a = 0, b = 0;
    rep(i, n) {
        if (siz[i] > 1) {
            ++b;
            if (vec[i]) ++a;
        }
    }
    ll c = n;
    rep(i, n) {
        if (uf1.size(i) == 1) --c;
    }
    
    cout << (ll)n * n - c * c + b * b + a * a << "\n";
    return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define ll long long int
#define li long int
#define ull unsigned long long int
#define rep(i,a,b) for(i=a;i<b;i++)
#define db double
#define MOD 1000000007
#define MAX 1000001
#define pb push_back
#define mp make_pair
#define nl "\n"
using namespace std;
int main(int argc, char const *argv[]) {
    string str;
    cin>>str;
    int i;
    rep(i,0,3)
    {
        if(str[i]=='7')
        {
            cout<<"Yes"<<nl;
            break;
        }
    }
    if(i==3)
        cout<<"No"<<nl;
}


Measured memory_bytes: 3624
/* ****revpro**** */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,1,n-1){
      ll k=i+1;
      rep(j,0,i){
        while((k<n)&&((a[i]+a[j])>a[k])) k++;
        ans+=k-i-1;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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


int cuts(const vector<vector<int>>& grid, const int& mask,
	const int& h, const int& w, const int& k) {
	vector<int> cuts;//номера строк с разрезами
	for (int i = 0; i < h - 1; ++i)
		if (mask & (1 << i))
			cuts.push_back(i);
	cuts.push_back(10);
	vector<int> pieces(cuts.size());//горизонтальные кусочки
	int c(0);//суммарное число ВЕРТИКАЛЬНЫХ разрезов
	for (int j = 0; j < w; ++j) {//цикл по столбцам
		int x(0);//номер текщего разреза
		for (int i = 0; i < h; ++i) //цикл по строкам
		{
			const bool hasCut = i == cuts[x]; // есть ли разрез в этой строке
			pieces[hasCut ? (x++) : x] += grid[i][j];
		}
		
		for (int n = 0; n < pieces.size(); ++n) {
			if (pieces[n] > k) {
				c++;//делаем разрез
				memset(&pieces[0], 0, 4 * pieces.size());//заполняем pieces нулями
				x = 0;//номер текущего разреза сбрасываем в 0

				//пробегаем по столбцу перед разрезом
				//если накопили k единиц и встречаем очередную - этот уже перебор
				for (int i = 0; i < h; ++i) {
					if (pieces[x] == k && grid[i][j]) return -1;
					const bool hasCut = i == cuts[x];
					pieces[hasCut ? (x++) : x] += grid[i][j];
				}
			}
		}
	}
	return c;
}


int main() {
	int h, w, k;
	char c;
	cin >> h >> w >> k;
	
	
	vector<vector<int>> grid(h, vector<int>(w));
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			cin >> c;
			grid[i][j] = c - '0';
		}

	int hs(1 << (h - 1)), ans(h + w - 2);
	for (int mask = 0; mask < hs; ++mask) {
		int res = cuts(grid, mask, h, w, k);
		if (res >= 0) ans = min(ans, res + static_cast<int>(__builtin_popcount(mask)));
	}
	cout << ans << '\n';
	return 0;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    string a , b;
    cin >> a >> b;
    int n = a.size() , m = b.size();
    vector <int> c;
    int count = 0;
    if(n == m){
        for(int i = 0; i < n; i++){
            if(a[i] != b[i]){
                count++;
            }
        }
        cout << count << endl;
        count = 0;
        return 0;
    }
    for(int i = 0; i < n - m + 1; i++){
        for(int j = 0; j < m; j++){
            if(a[i + j] != b[j]){
                count++;
            }
        }
        c.push_back(count);
        count = 0;
    }
    sort(c.begin() , c.end());
    cout << c[0] << endl;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
	int n,i,count=1;
	cin>>n;
	string s;
	cin>>s;
	for(i=1;i<n;i++) {
		if(s[i]!=s[i-1]) count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 512
function Main(input) { 
  input = input.split("\n"); 
  out = ""; 
  if(parseInt(input[0], 10)<3200){
    out = "red"; 
  }else{
    out = input[1];
  } //出力
  console.log('%s',out); 
} Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
a,b=map(int,input().split())
s=list(input())
c=0
for i in range(a):
  d=s.pop(0)
  if d=='-':c+=1
d=s.pop(0)
if d!='-':c+=1
for i in range(b):
  d=s.pop(0)
  if d=='-':c+=1
if c==0:print('Yes')
else:print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

double func(const double x, const double q) {
	return x - (x * x * x - q) / (3 * x * x);
}

const double epsilon = 0.00001;

int main() {
	for(int N; cin >> N, N != -1;) {
		double x = N / 2.0;
		while(abs(x * x * x - N) >= epsilon * N) {
			// debug(x);
			x = func(x, N);
		}
		printf("%.6f\n", x);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int D;
	cin >> D;
	string ans;
	if (D == 25) ans = "Christmas";
	else if (D == 24) ans = "Christmas Eve";
	else if (D == 23) ans = "Christmas Eve Eve";
	else if (D == 22) ans = "Christmas Eve Eve Eve";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n <= 111) cout << 111 << endl;
  else if(n <= 111) cout << 111 << endl;
  else if(n <= 222) cout << 222 << endl;
  else if(n <= 333) cout << 333 << endl;
  else if(n <= 444) cout << 444 << endl;
  else if(n <= 555) cout << 555 << endl;
  else if(n <= 666) cout << 666 << endl;
  else if(n <= 777) cout << 777 << endl;
  else if(n <= 888) cout << 888 << endl;
  else cout << 999 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, m, c, i, j, po, ans = 0;
    scanf("%d %d %d", &n, &m, &c);
    int b[m];
    for(i=0; i<m; i++) scanf("%d", &b[i]);
    int a[n][m];
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<n; i++){
        po = 0;
        for(j=0; j<m; j++){
            po += a[i][j]*b[j];
        }
        po += c;
        if(po>0) ans++;
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int count = 0;

		for (int i = 0; i < a; i++) {
			if (sc.nextInt() >= b) {
				count++;
			}
		}

		System.out.println(count);

	}
}

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

int main(){

  double x;
  int n,a[10] = {0};
  cin >> n;

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

    if(185 <= x) a[6]++;
    else if(180 <= x) a[5]++;
    else if(175 <= x) a[4]++;
    else if(170 <= x) a[3]++;
    else if(165 <= x) a[2]++;
    else a[1]++;

  }

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

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <numeric>
#include <unordered_map>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;;
	if (a+b < c+d) {
		cout << "Right";
	}
	else if (a+b > c+d) {
		cout << "Left";
	}
	else cout << "Balanced";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MAX 100001
using namespace std;

int A[MAX];
int n;
void add(int x, int y){
    A[x] += y;
}

int getSum(int x, int y){
    if( x <= y ){
        int sum = 0;
        for(int i = x; i <= y; i++){
            sum += A[i];
        }
        return sum;
    }
    else return 0;
}
int main(){
    int q,com,x,y;
    scanf("%d %d",&n,&q);
    for(int i = 1; i <= n; i++) A[i] = 0;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d",&com,&x,&y);
        if(com == 0) add(x,y);
        else if(com == 1) printf("%d\n",getSum(x,y));
        else break;
    }
    return 0;
}


Measured memory_bytes: 3576
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint a[100100];
lint gs[100100],ks[100100],s[100100];
int main()
{
	int n,q;lint x;
	cin>>n>>q;
	rep(i,n) cin>>a[i];
	gs[0]=ks[0]=s[0]=0;
	rep(i,n){
		gs[i+1]=gs[i];
		ks[i+1]=ks[i];
		s[i+1]=s[i]+a[i];
		if(i%2==0) gs[i+1]+=a[i];else ks[i+1]+=a[i];
	}
	rep(i,q){
		cin>>x;
		int lo=0,hi=n;
		while(hi>lo){
			int mi=(hi+lo)/2;
			int it=lower_bound(a,a+n,x*2-a[mi])-a;
			if(mi-it<n-mi-1) lo=mi+1;else hi=mi;
		}
		lint ret=s[n]-s[lo];
		if(n%2==0) ret+=ks[lo*2-n];else ret+=gs[lo*2-n];
		cout<<ret<<endl;
	}
}


Measured memory_bytes: 4864
import sys

sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    N, K = LI()
    T = []
    D = []
    TD = []
    [TD.append(LI()) for i in range(N)]
    TD = sorted(TD, key=lambda l:l[1], reverse=True)
    # 種類のカウントをもつ
    type_count_dict = {}
    base_point = 0
    type_bonus = 0
    remaining_items = []
    for idx, i in enumerate(TD):
        if not type_count_dict.get(i[0]):
            type_count_dict[i[0]] = 0
        if idx < K:
            if type_count_dict[i[0]] == 0:
                type_bonus += 1
            type_count_dict[i[0]] += 1
            base_point += i[1]
        else:
            if type_count_dict[i[0]] == 0:
                remaining_items.append(i[1])
                type_count_dict[i[0]] += 1

    S = TD[:K]
    result = base_point + type_bonus**2
    
    ridx = 0
    for idx, s in enumerate(S[::-1]):
        if len(remaining_items) < ridx + 1:
            break
        if len(remaining_items) == 0:
            break
        if type_count_dict[s[0]] >= 2:
            type_count_dict[s[0]] -= 1
            base_point += remaining_items[ridx] - s[1]
            type_bonus += 1
            ridx += 1
            result = max(type_bonus**2 + base_point, result)
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 80348
def main():
    A, B, K = map(int, input().split())
    if A >= B:
        answer(A, B, B, K)
    else:
        answer(A, B, A, K)


def answer(A, B, n, K):
    K_list = []
    for i in range(n, 0, -1):
        if A % i == 0:

            if B % i == 0:
                K_list.append(i)
    print(K_list[K-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main() {
  char b;
  scanf("%c",&b);
  if (b == 'A'){
    printf("T");
  }else if (b == 'T'){
      printf("A");
  }else if (b == 'C'){
        printf("G");
  }else if (b == 'G'){
      printf("C");
    }
    return 0;
  }

Measured memory_bytes: 128
from functools import lru_cache

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

@lru_cache(maxsize=None)
def size(level):
    return 1 if level == 0 else size(level - 1) * 2 + 3

@lru_cache(maxsize=None)
def calc(level, N):
    if level == 0:
        return 1 if N > 0 else 0

    N = min(N, size(level))

    ret = 0
    N -= 1

    if N >= size(level - 1):
        ret += calc(level - 1, size(level - 1))
        N -= size(level - 1)

        if N >= 1:
            ret += 1
            N -= 1

    return ret + calc(level - 1, N)

print(calc(N, X))


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

int N, T, A[1 << 18], B[1 << 18], minx = (1 << 30);

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		if (B[i] <= T) minx = min(minx, A[i]);
	}
	if (minx == (1 << 30)) cout << "TLE" << endl;
	else cout << minx << endl;
	return 0;
}

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

int main(void) {
    int a[100010] = {0};
    int i, N, c, T;
    scanf("%d", &N);
    for (i=0;i<N;i++) {
        scanf("%d", &c);
        a[c] = 1;
    }
    T = 0;
    for (i=1;i<100001;i++) {
        T += a[i];
    }
    if (T%2 == 0) T--;

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

Measured memory_bytes: 512
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    logging.info(A)
    logging.info(B)

    counter = 0
    for i in range(N):
        if A[i] < B[i]:
            #counter += A[i]
            if (A[i] + A[i + 1]) > B[i]:
                counter += B[i]
                A[i + 1] = A[i + 1] - B[i] + A[i]
                B[i] = 0
            else:
                counter += (A[i] + A[i + 1])
                B[i] = B[i] - A[i] - A[i + 1]
                A[i + 1] = 0
                
        elif A[i] == B[i]:
            counter += A[i]
            B[i] = 0
            A[i] = 0
                
        else:
            counter += B[i]
            B[i] = 0

    if B[N - 1] > A[N]:
        counter += A[N]
    elif B[N - 1] != 0:
        counter += B[N - 1]

    print(counter)
            
    
if __name__ == "__main__":
    main()


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

int main() {
    long long h;
    cin >> h;

    long long x = h;


    int cnt = 0;
     long long ans = 0;
    while (1) {
        ans += pow(2, cnt);
        cnt++;
        x /= 2;
        if (x == 0) break;
    }

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

Measured memory_bytes: 384
class Deck():
    def __init__(self, s):
        self.s = s
    
    def shuffle(self, h):
        self.s = self.s[h:] + self.s[:h]
        
    def get_deck(self) -> str:
        return self.s

decks = []
while True:
    s = input()
    if s == "-":
        break

    deck = Deck(s)

    m = int(input())

    for i in range(m):
        h = int(input())
        deck.shuffle(h)

    decks.append(deck)

for deck in decks:
    print(deck.get_deck())


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, M, Y, P;
vector<pair<int, int>>p[100001];
string res[100000];

int main() {
	cin >> N >> M;
	for (int i = 0; i != M; ++i) {
		cin >> P >> Y;
		p[P].push_back(mkp(Y, i));
	}
	for (int i = 1; i <= N; ++i) {
		sort(p[i].begin(), p[i].end());
		for (int j = 0; j != p[i].size(); ++j) {
			int t = j + 1;
			for (int k = 0; k != 6; ++k) {
				res[p[i][j].second] += t % 10 + '0';
				t /= 10;
			}
			t = i;
			for (int k = 0; k != 6; ++k) {
				res[p[i][j].second] += t % 10 + '0';
				t /= 10;
			}

		}
	}
	for (int i = 0; i != M; ++i) {
		reverse(res[i].begin(), res[i].end());
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 13952
//AtCoder Beginner Contest 083
//B - Some Sums

#include <iostream>
#include <string>

using namespace std;

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

    int count = 0;

    for(int i=1;i<=n;i++){
        string num = to_string(i);
        int sum = 0;
        for(int j=0;j<num.size();j++){
            sum += num[j] - '0';
        }
        if(a<=sum && sum<=b){
            count += i;
        }
    }

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


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

int main(){
  int a[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++)
      cin>>a[i][j];
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if(a[i][j]+a[i+1][j+1]!=a[i+1][j]+a[i][j+1]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
main=readLn>>=putStrLn.unwords.map show.head.f
f n=[[x, y, div p q]|x<-[1..3500], y<-[1..3500],let p=n*x*y, let q=4*x*y-n*(x+y),p>0,q>0,rem p q==0,p >= q]


Measured memory_bytes: 1276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String args[])throws IOException  {
 
	
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		int n=in.nextInt();
		int [] apples = new int[n];
		String win = "second";
		for(int i=0;i<n;i++){
			int y = in.nextInt();
			if(y%2 ==1){
				win = "first";
			}
		}
		


		out.print(win);
		out.close();
	}
	
	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;
 
		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
 
		public long nextLong() {
			return Long.parseLong(nextString());
		}
 
		public double nextDouble() {
			return Double.parseDouble(nextString());
		}
 
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}
 
		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}
 
		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}
 
		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}
 
		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}
 
		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}
 
		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}
 
		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
 
	
}


Measured memory_bytes: 35748
#include<iostream>
using namespace std;
int main()
{
	int a1,b1,a2,b2;
	cin>>a1>>b1>>a2>>b2;
	if(a1<=a2&&b1<=b2&&a2<=b1) cout<<b1-a2<<endl;
	else if(a1<=a2&&b1>=b2) cout<<b2-a2<<endl;
	else if(a2<=a1&&b2<=b1&&a1<=b2) cout<<b2-a1<<endl;
	else if(a2<=a1&&b2>=b1) cout<<b1-a1<<endl;
	else cout<<"0"<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define vi vector<int>
#define pb push_back
#define SZ(x) (int) x.size()
using namespace std;
const int MAXN = 1e5 + 10;
int n;
char s[MAXN];
void work() {
  scanf("%d%s", &n, s + 1);
  int ans = 1;
  char last = s[1];
  for(reg int i = 2; i <= n; ++i) {
    if(last == s[i]) continue;
    else ++ans, last = s[i];
  }
  printf("%d\n", ans);
}
int main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) work();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vector<vl> g(h, vl(w, 0));
  ll k = 0;
  rep(i, h) rep(j, w) {
    g[i][j] = k + 1;
    a[k]--;
    if(a[k] == 0) k++;
  }
  rep(i, h) if(i % 2) reverse(all(g[i]));
  rep(i, h) {
    rep(j, w) cout << g[i][j] << ' ';
    cout << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
  int n, t, i;
  int array[1000];
  int array1[1000];
  cin >> n >> t;
  for(i=0;i<n;i++){
   cin >> array[i] >> array1[i];
   if(array1[i]>t){
      array[i]=1001;
    }
    if(array[0]>=array[i]){
      array[0]=array[i];
    }
  }
  if(array[0]==1001){
    cout << "TLE" << endl;
  }
  else{
  cout << array[0] << endl;
}
  return 0;
}

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

int main()
{

    int N,A;
    cin>>N>>A;

    int L=A;
    int R=A+N-1;

    int eat;
    if(R<=0)
        eat=R;
    else if(L>=0)
        eat=L;
    else
        eat=0;

    int answer=(R+L)*(R-L+1)/2-eat;

    cout<<answer<<endl;

    return 0;
}

Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
  
def main():
    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    
    A.sort()
    B.sort()
    if N%2 == 0:
        L = (A[N//2 - 1] + A[N//2])
        R = (B[N//2 - 1] + B[N//2])
        ans = (R - L + 1)
    else:
        L = A[N//2]
        R = B[N//2]
        ans = R - L + 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 25364
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    k,a,b=map(int, input().split())
    ans=0
    if b-1>a+1 and k>=a+1:
        k-=a+1
        ans+=b
        ans+=max(k//2*(b-a)+k%2,k//(a+2)*b+k%(a+2))
        print(ans)

    else:
        print(1+k)
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  double t, a;
  cin >> t >> a;
  ll tmp = (t-a) * 1000;
  int min_index = 0;
  ll _min = LONG_MAX;
  rep(i, n){
    ll h;
    cin >> h;
    h = abs((h*6)-tmp);
    if(_min > h){
      _min = h;
      min_index = i;
    }
  }
  cout << min_index+1 << endl;
  return 0;
 
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int a,b;
	string s;
	cin >> a >> b;
	cin >> s;
	int n = (int)s.length();
	if (a+b+1 != n) {
		cout << "No\n";
		return;
	}
	for (int i = 0; i < n; ++i) {
		if (i==a) {
			if (s[i] != '-') {
				cout << "No\n";
				return;
			}
		} else {
			if (!isdigit(s[i])) {
				cout << "No\n";
				return;
			}
		}
	}

	cout << "Yes\n";
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

int main() {
    int n; cin >> n;
    int k; cin >> k;
    int mask = 0;
    while (k--) { int i; cin >> i; mask |= 1 << i; }
    for (int b = 0; b < 1 << n; b++) {
        if ((b & mask) != mask) continue;
        cout << b << ":";
        for (int i = 0; i < n; i++) if (b >> i & 1) cout << " " << i;
        cout << endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    rep(i,m) cin >> a[i] >> b[i];
    vector<vector<int>> v(n+1);
    rep(i,m){
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    queue<int> que;
    vector<bool> t(n+1);

    int sum=0;
    int x;
    rep(i,m){
        que.push(1);
        while(!que.empty()){
            x=que.front();
            que.pop();
            t[x]=true;
            rep(j,v[x].size()){
                if(x==a[i] && v[x][j]==b[i]) continue;
                if(x==b[i] && v[x][j]==a[i]) continue;
                if(t[v[x][j]]) continue;
                que.push(v[x][j]);
            }
        }

        bool ans=false;
        rep2(i,1,n+1){
            if(!t[i]) ans=true;
            t[i]=false;
        }
        // cout << endl;
        if(ans) sum++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll dv(ll h, ll w) {
	if (h % 2 == 0 || w % 2 == 0) { return 0; }
	else { return min(h, w); }
}

int main() {

	ll H, W;
	cin >> H >> W;

	ll ans = INF;

	rep(i, H + 1) {
		ll a = W * (H-i);

		ll x = dv(i, W);

		ll b = (i*W + x) / 2;
		ll c = b - x;

		ll t = max(abs(a - b), max(abs(b - c), abs(c - a)));
		ans = min(t, ans);

	}
	
	rep(i, W + 1) {
		ll a = (W - i) * H;

		ll x = dv(H, i);

		ll b = (i*H + x) / 2;
		ll c = b - x;

		ll t = max(abs(a - b), max(abs(b - c), abs(c - a)));
		ans = min(t, ans);

	}

	cout << ans;

	
	system("PAUSE");
}


Measured memory_bytes: 504
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    slen = len(s) - 1
    a = s[0]
    for bit in range(1 << slen): # 間に入る数だけ求めたい
        sum = int(a) # 最初におるやつ
        ans = a # 最初
        # - だったらひいて + だったら足せばいい?
        for i in range(3):
            if bit & (1 << i):
                sum += int(s[i+1])
                ans += "+" + s[i+1]
            else:
                sum -= int(s[i+1])
                ans += "-" + s[i+1]
        if sum == 7:
            print(ans+"=7")
            exit()


if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String data = sc.next();
    int n = data.length();

    String[] s = new String[n];

    for (int i = 0; i < n; i++) {
      s[i] = data.substring(i,i+1);
    }

    long ans = 0;

    for (int i = 0; i < (Math.pow(2,n-1)); i++) {
      long sum = 0;
      String k = "";
      for (int j = 0; j < n; j++) {
        k += s[j];
        sum *= 10;
        sum += k.charAt(j)-'0';
        if ((1&i >> j) != 1) {
          // k += "+";
          ans += sum;
          sum = 0;
        }
      }
      // System.out.println(k);
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 21332
#include<stdio.h>
#include<string.h>
int main()
{
  int N;
  int gokei=0;
  
  scanf("%d",&N);
  
  for(int i=1;i<=N;i++)
    gokei+=i;
  
  printf("%d",gokei);
  
  return 0;
}

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

int main(){
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
	int a, b, c,co=0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	while (a <= b&&c>0) {
		b = b - a;
		co++;
		c--;
	}
	printf("%d\n",co);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
bool palindrome(char arr[],int size){
    char arr_1[size];
    int j=0;
    for(int i=size-1;i>=0;i--){
        arr_1[i]=arr[j];
        j++;
    }
    for(int i=0;i<size;i++){
        if(arr_1[i]!=arr[i]){
            return false;
        }
    }
    return true;
}
int main() {
	string s;
	cin>>s;
	int n=s.length();
	char arr[n];
	for(int i=0;i<n;i++){
	    arr[i]=s[i];
	}
	bool ans=palindrome(arr,n);
	for(int i=0;i<n/2;i++){
	    arr[i]=s[i];
	}
	bool ans_1=palindrome(arr,n/2);
	int j=0;
	for(int i=n/2+1;i<n;i++){
	    arr[j]=s[i];
	    j++;
	}
	bool ans_2=palindrome(arr,n/2);
	if(ans==true && ans_1==true && ans_2==true) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int n[100000], m[100000];

int main()
{
  int cnt;
  int N, M;

  while (cin >> N >> M, N + M){
    cnt = 0;

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

    int i = 0;

    while (cnt < N - 1){
      cnt += m[i];
      cnt += n[cnt];
      i++;
    }
    cout << i << endl;

  }
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st;
		
		
		System.out.println((sc.nextInt() + 1) / 2);
		
	}
}

Measured memory_bytes: 21844
# bit全探索
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -float('inf')
for i in range(2**10):
    if i == 0: # 全く営業しないパターン
        continue
    profit = 0
    pattern = [0]*10
    for j in range(10):
        if 1 << j & i:
            pattern[j] = 1
    #print(pattern)

    for k in range(N):
        #l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
        l = 0
        for m in range(10):
            if pattern[m] == F[k][m] == 1:
                l += 1

        #print(l)
        profit += P[k][l]
    ans = max(ans,profit)
print(ans)





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

int main() {
	int n;
	cin >> n;
	int s[13] = { 0 }, h[13] = { 0 }, c[13] = { 0 }, d[13] = { 0 };
	char ch;
	int m;
	for (int i = 1; i <= n; i++) {
		cin >> ch >> m;
		switch (ch) {
		case 'S': s[m - 1] = m; break;
		case 'H': h[m - 1] = m; break;
		case 'C': c[m - 1] = m; break;
		case 'D': d[m - 1] = m; break;
		}
	}
	for (int i = 0; i < 13; i++)
		if (s[i] == 0)
			cout << "S " << i + 1 << endl;
	for (int i = 0; i < 13; i++)
		if (h[i] == 0)
			cout << "H " << i + 1 << endl;
	for (int i = 0; i < 13; i++)
		if (c[i] == 0)
			cout << "C " << i + 1 << endl;
	for (int i = 0; i < 13; i++)
		if (d[i] == 0)
			cout << "D " << i + 1 << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }
  }
}

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

using namespace std;

typedef long long ll;

ll absr(ll a, ll b){
    return a > b ? a - b : b - a;
}

int main()
{
    ll n;
    cin >> n;
    ll h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    ll dp[n];
    dp[0] = 0;
    dp[1] = h[0] > h[1] ? h[0] - h[1] : h[1] - h[0];
    dp[2] = absr(h[0], h[2]);
    for(int i = 3; i < n; i++){
        dp[i] = min(dp[i - 1] + absr(h[i - 1], h [i]), dp[i - 2] + absr(h[i - 2], h [i]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


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

n = int(input())
cnt = []
memo = 0
a = list(map(int, input().split()))
for i in range(1, n):
    if a[i] <= a[i - 1]:
        memo += 1
    else:
        cnt.append(memo)
        memo = 0
cnt.append(memo)
print(max(cnt))


Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
template <typename T> inline T read() {
	bool f = 1; T x = 0; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = !f;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	return f ? x : -x;
}
#define gi read<int>()
#define gl read<ll>()

const int N = 200000 + 5;
int n, u[N], v[N];
int main() {
	n = gi;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) ans += (ll)i * (i + 1) / 2;
	for (int i = 1; i < n; ++i) {
		int u = gi, v = gi;
		if (u > v) swap(u, v);
		ans -= (ll)u * (n - v + 1);
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int ansQ, N, M, s[200009], s0[200009], dp[200009], b[200009], aint[800009], pref[800009], lzy[800009];
vector < int > v[200009];

void Build (int nod, int st, int dr)
{
    aint[nod] = lzy[nod] = 1e8;
    if (st == dr) return ;
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    Build (f1, st, mij);
    Build (f2, mij + 1, dr);
}

void split (int nod, int f1, int f2)
{
    if (lzy[nod] == 1e8) return;
    lzy[f1] = min (lzy[f1], lzy[nod]), aint[f1] = min (aint[f1], lzy[nod]);
    lzy[f2] = min (lzy[f2], lzy[nod]), aint[f2] = min (aint[f2], lzy[nod]);
    lzy[nod] = 1e8;
}

void UpdateSegm (int nod, int st, int dr, int x, int y, int val)
{
    if (x <= st && dr <= y)
    {
        aint[nod] = min (aint[nod], val), lzy[nod] = min (lzy[nod], val);
        return ;
    }
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    split (nod, f1, f2);
    if (x <= mij) UpdateSegm (f1, st, mij, x, y, val);
    if (mij < y) UpdateSegm (f2, mij + 1, dr, x, y, val);
    aint[nod] = min (aint[f1], aint[f2]);
}

void Query (int nod, int st, int dr, int pos)
{
    if (st == dr)
    {
        ansQ = aint[nod];
        return ;
    }
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    split (nod, f1, f2);
    if (pos <= mij) Query (f1, st, mij, pos);
    else Query (f2, mij + 1, dr, pos);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=2; i<=N + 1; i++)
    scanf ("%d", &b[i]), s[i] = s[i - 1] + b[i], s0[i] = s0[i - 1] + 1 - b[i];
scanf ("%d", &M);
for (int i=1; i<=M; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y), x ++, y ++;
    v[y].push_back (x);
}
Build (1, 1, N + 1);
dp[1] = 0;
for (int i=2; i<=N + 1; i++)
{
    dp[i] = dp[i - 1] + b[i];
    vector < pair < pair < int, int >, int > > updates;
    for (auto lft : v[i])
    {
        int curr = pref[lft - 1] + s[lft - 1] + (s0[i] - s0[lft - 1]);
        ///lft <= j < i, dp[j] + s0[i] - s0[j]
        if (lft < i)
        {
            Query (1, 1, N + 1, lft);
            curr = min (curr, ansQ + s0[i]);
        }
        if (curr < dp[i]) dp[i] = curr;
        updates.push_back ({{lft, i}, curr - s0[i]});
    }
    for (auto u : updates)
        UpdateSegm (1, 1, N + 1, u.first.first, u.first.second, u.second);
    ///
    pref[i] = min (pref[i - 1], dp[i] - s[i]);
}
printf ("%d\n", dp[N + 1]);
return 0;
}


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

#define MAX 500002
#define SENTI 2000000002

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++)L[i]=A[left+i];
  for(int i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=SENTI;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j])A[k]=L[i++];
    else A[k]=R[j++];
  }
}

void mergesort(int A[],int n,int left,int right){
  if(left+1 < right){
    int mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n;
  cnt=0;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  
  mergesort(A,n,0,n);

  for(int i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  
  printf("%d\n",cnt);
  return(0);
}

Measured memory_bytes: 5096