akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

long long int h[100000];
int main(void){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >>h[i];
    
    for (int i = N-1; i > 0; i--) {
        if (h[i] <= h[i-1]-2) {
            cout << "No" << endl;
            exit(0);
        }
        else if (h[i] == h[i-1]-1)
            h[i-1]--;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val h = sc.nextInt()
        val w = sc.nextInt()

        val src = sc.asSequence().take(h).map { it.toCharArray() }.toList()
        for (x in 0 until w) {
            for (y in 0 until h) {
                if (src[y][x] == '#') {
                    if (listOf(0 to 1, 0 to -1, 1 to 0, -1 to 0).none { entry ->
                            val (xd, yd) = entry
                            y + yd in 0 until h && x + xd in 0 until w && src[y + yd][x + xd] == '#'
                    }) {
                        println("No")
                        return
                    }
                }
            }
        }
        println("Yes")
    }
}

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

using namespace std;

int main() {
  int n;
  unordered_map<string, long long> mp;
  vector<string> v;
  
  cin >> n;
  
  string tmp;
  for (int i = 0; i < n; i++) {
  	cin >> tmp;
    sort(tmp.begin(), tmp.end());
    mp[tmp]++;
  }
  
  long long ans = 0;
  for(auto e: mp) {    
    if (e.second > 1) {
      long long np = 1;
      long long rp = 1;
      for (int i = 0; i < 2; i++){
        np *= (e.second - i);
      }
      ans += np / 2;
    }
  }
    
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<int> a; a.resize(n);
	for (int i=0; i<n; i++) cin>>a[i];
	multiset<int> s;
	for (int i:a) s.insert(i);
	vector<ii> moves;
	while (s.size()>1) {
		auto first=s.begin();
		auto last=--s.end();
		auto secondLast=--(--s.end());
		if (s.size()==2) {
			moves.emplace_back(*last, *first);
			int res=(*last)-(*first);
			s.erase(first);
			s.erase(last);
			s.insert(res);
		}
		else if (*secondLast>0) {
			int res=(*first)-(*secondLast);
			moves.emplace_back(*first, *secondLast);
			s.erase(first);
			s.erase(secondLast);
			s.insert(res);
		}
		else {
			moves.emplace_back(*last, *first);
			int res=(*last)-(*first);
			s.erase(first);
			s.erase(last);
			s.insert(res);
		}
	}
	cout<<(*s.begin())<<'\n';
	for (ii m:moves)
		cout<<m.first<<" "<<m.second<<'\n';
	return 0;
}


Measured memory_bytes: 7800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if (d > t*s) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 35676
n = gets.to_i
list = []

n.times do
	command = gets.chomp!.to_s
	
	if command == "deleteFirst"
		list.shift
	elsif command == "deleteLast"
		list.pop
		
	else
		command , key = command.split
		if command.to_s == "insert"
			list.unshift key.to_i
		elsif command.to_s == "delete"
			num = list.find_index{ |v| v == key.to_i}
			if num
				list.delete_at(num)
			end
		end
	end
end


puts list.join(" ")

Measured memory_bytes: 23188
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,m;
ll f[2*MAX];
int main(){FAST;
  cin>>n;
for(ll i=2;i<=n;++i){
  ll x;cin>>x;
  ++f[x];
}
for(ll i=1;i<=n;++i)cout<<f[i]<<'\n';
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  S=S+'#';
  vector<int> a(S.size(), 0);
  int i, j, J;
  int b;
  char c=S.at(0);
  for (i=j=0; i<S.size(); i++) {
    if (S.at(i)!=c) {
      c=S.at(i);
      j++;
    }
    if (c=='.') a.at(j)++;
    else a.at(j)--;
  }
  J=j+1;
  //for (i=0; i<J; i++) cout <<a.at(i) <<endl;////
  b=0;
  for (i=0; i<J; i++) {
    if (a.at(i)>0) b+=a.at(i);
  }
  //cout << "b=" << b << endl;////////////////
  if (a.at(0)<0) {
    i=0;
  } else {
    i=1;
    b-=a.at(0);
  }
  //cout << "b=" << b << endl;////////////////
  int B=b;
  for (; i<J-1; i+=2) {
    //cout << "Before " << a.at(i) << ':' << a.at(i+1) << ':' << b << endl;
    b=b-a.at(i)-a.at(i+1);
    //cout << "After  " << a.at(i) << ':' << a.at(i+1) << ':' << b << endl;
    B=min(B, b);
  }
  cout << B << endl;
}


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

#define F first
#define S second

using ll = long long;
using pii = pair <int, int>;

const int oo = 1e9 + 4;
const int SZ = 2e3 + 4;

int n, m;
bool g[SZ][SZ];

void read() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
            g[i][j] = s[j] == '#';
    }
}

int dp[SZ][SZ];

void solve() {
    for (int i = 0; i < n; i++)
        fill(dp[i], dp[i] + m, oo);
    dp[0][0] = g[0][0];
    deque <pii> q;
    q.push_back({0, 0});
    while (!q.empty()) {
        int x, y;
        tie(x, y) = q.front();
        q.pop_front();

        if (y + 1 < m && dp[x][y + 1] == oo) {
            if (g[x][y + 1] != g[x][y]) {
                dp[x][y + 1] = dp[x][y] + 1;
                q.push_back({x, y + 1});
            } else {
                dp[x][y + 1] = dp[x][y];
                q.push_front({x, y + 1});
            }
        }
        if (x + 1 < n && dp[x + 1][y] == oo) {
            if (g[x + 1][y] != g[x][y]) {
                dp[x + 1][y] = dp[x][y] + 1;
                q.push_back({x + 1, y});
            } else {
                dp[x + 1][y] = dp[x][y];
                q.push_front({x + 1, y});
            }
        }
    }
    cout << (dp[n - 1][m - 1] + 1) / 2 << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 998244353;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
long long a[6005], b[2005][2005];
long long ans = 0, x = 0;



signed main()
{
	cin >> n >> x;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		ans += a[i];
		b[i][0] = a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			b[i][j] = 1e9 + 8;
		}
	}
	for(int i = 1; i <= n - 1; i++)
	{
		for(int j = n; j >= 1; j--)
		{
			int temp = (j - i + n) % n;
			if(temp == 0)
			{
				temp += n;
			}
			b[j][i] = min(b[j][i - 1], a[temp]);
		}
	}
	for(int i = 0; i < n; i++)
	{
		long long temp = i * x;
		for(int j = n; j >= 1; j--)
		{
			temp += b[j][i];
		}
		ans = min(ans, temp);
	}
	cout << ans;
}

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

using namespace std;

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    printf("%.12f\n",w*h/2);
    if(w==2*x && h==2*y){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

int n, m, a[15], stat[15], ans = 0;

bool valid (int mask) {
  for (int i = 0; i < m; i++) {
    int c = 0;
    for (int j = 0; j <= n; j++) {
      c += (mask >> j & 1) & (a[i] >> j & 1);
    }
    if (c % 2 != stat[i]) return false;
  }
  return true;
}

int solve (int p, int mask) {
  if (p > n) return (valid (mask) == 1);
  return solve (p + 1, mask) + solve (p + 1, mask | (1 << p));
}

int main () {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int mask = 0, k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      mask |= (1 << p);
    }
    a[i] = mask;
  }
  for (int i = 0; i < m; i++) {
    cin >> stat[i];
  }
  cout << solve (1, 0) << '\n';
  return 0;
}


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

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import heapq
A = readInts()
heapq.heapify(A)
ans = 0
for i in range(2):
    ans += heapq.heappop(A)
print(ans)


Measured memory_bytes: 5276
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int M1 = Integer.parseInt(sc.next());
    	int D1 = Integer.parseInt(sc.next());
    	int M2 = Integer.parseInt(sc.next());
    	int D2 = Integer.parseInt(sc.next());
   		out.println(M1 != M2 ? 1 : 0);
    }
    // ==================================================================
}
class PP{
	public int key, val;
	public PP(int key, int val) {
		this.key = key;
		this.val = val;
	}
	public int getKey() {
		return key;
	}
	public int getVal() {
		return val;
	}
}


Measured memory_bytes: 23124
n = gets.to_i
numbers = gets.split.map(&:to_i)
new_numbers = []

(0...numbers.size).each do |i|
  if n % 2 == i % 2
    new_numbers << numbers[i]
  else
    new_numbers.unshift(numbers[i])
  end
end

puts new_numbers.join(' ')

Measured memory_bytes: 25440
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long f[10][10],res;
string ss;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	//get f[i,j]:begin with i,end with j
	for(int i=1;i<=n;i++){
		ss=to_string(i);
		f[ss[0]-'0'][ss[ss.size()-1]-'0']+=1LL;
	}
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			res+=f[i][j]*f[j][i];
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
m, n = map(int, input().split())
a = [input().strip() for i in range(m)]
b = [input().strip() for i in range(n)]

found = False
for x in range(m-n+1):
  for y in range(m-n+1):
    for k in range(n):
      if a[x+k][y:y+n] != b[k]:
        break
    else:
      found = True
      break
  if found: break    
if found:
  print("Yes")
else:
  print("No")
  
  

Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int sum = 0;
    foreach(int i; 0..5) {
        sum += max(40, readln.chomp.to!int);
    }
    writeln(sum/5);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  vector<vector<int>> res(H);
  int h = 0, w = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < A[i]; j++) {
      res[h].push_back(i + 1);
      w++;
      if (w == W) {
        w = 0;
        h++;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    if (i % 2 == 1) reverse(res[i].begin(), res[i].end());
    for (int j = 0; j < W; j++) {
      cout << res[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}


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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fileio          freopen('input.txt', 'r', stdin); freopen('output.txt', 'w', stdout);
#define int             long long
#define float           long double
#define test            int T; cin>>T; for(int i=1; i<=T; ++i)
#define in(a,n)         for(int i=0; i<(n); ++i)  cin>>a[i]
#define r0              return 0
#define E               '\n'
#define S               ' '
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int n,m,sum=0;	cin>>n>>m;
    fi(i,0,m)
    {
    	int x;	cin>>x;
    	sum+=x;
    }
    if(sum>n)	cout<<-1;
    else		cout<<n-sum;
    r0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb push_back

typedef long long ll;

const int N = 20010;
int array[N],tmp[N];

void div(int n,int *a,int k){
  int now=1;
  rep(i,k+1){
    a[i]=now/n;
    now=(now%n)*10;
  }
}

void add(int k){
  int carry=0;
  for(int i=k;i>=0;i--){
    array[i]=(array[i]+carry+tmp[i]);
    carry=array[i]/10;
    array[i]%=10;
  }
}

void output(int *a,int k){
  rep(i,k+1){
    cout << a[i];
    if (i==0)cout <<".";
  }
  cout << endl;
}

void solve(int n,int m,int k){
  div(n,array,2*k);
  if (m == 1){
    REP(i,1,n){
      div(i*n,tmp,2*k);
      //output(tmp,2*k);
      add(2*k);
    }
  }
  output(array,k);
}

main(){
  int n,k,m,r;
  while(cin>> n >> k >> m >> r && n){
    solve(n,m,r);
  }
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int ans = 0;
	for(int i = 0; i < n; i++)
		ans += s[i] != t[i];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll n,k;
  cin>>n>>k;
  ll a[n];
  rep(i,n) cin>>a[i];
  ll cnt[100] = {};
  ll last = 0;
  for(ll i = 0; (ll)pow(2,i) <= k; i++) {
    ll t = (ll)pow(2,i);
    ll sum = 0;
    for(ll j = 0; j < n; j++) {
      sum += t & a[j];
    }
    if(sum <= n * t / 2) {
      cnt[i] = 1;
    }
    last = i;
  }
  for(ll i = last; i >= 0; i--) {
    ll p = k >> i & 1;
    if(p == 1 && cnt[i] == 0) {
      break;
    } else if(p == 0 && cnt[i] == 1) {
      cnt[i] = 0;
    }
    // debug(i);debug(cnt[i]);
  }
  ll tmp = 0;
  for(ll i = 0; i <= last; i++) {
    tmp += (ll)pow(2,i) * cnt[i];
  }
  ll ans = 0;
  rep(i,n) {
    ans += tmp ^ a[i];
  }
  cout << ans << endl;


  return 0;
}


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

int main()
{
	double x,y,z;
	while(cin >> x >> y >> z){
		double r = min(sqrt(x*x+y*y),min(sqrt(y*y+z*z),sqrt(z*z+y*y)));
		if(!r)
			break;
		int n;
		cin >> n;
		for(int i=0;i<n;i++){
			double R;
			cin >> R;
			R += R;
			if(R > r)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*(N)

for i in range(1,N):
    now = h[i]
    dp[i] = min([abs(now-h[j])+dp[j] for j in range(max(i-K,0),i)])

print(dp[N-1])

Measured memory_bytes: 52444
fun main(args: Array<String>) {
    val s = readLine()!!.withIndex()
    var patternA = s.filter {(it.index % 2 == 0 && it.value == '0') || (it.index % 2 == 1 && it.value == '1')}.size
    var patternB = s.filter {(it.index % 2 == 1 && it.value == '0') || (it.index % 2 == 0 && it.value == '1')}.size
    println(Math.min(patternA, patternB))
}


Measured memory_bytes: 39284
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		long S = cin.nextLong();
		long C = cin.nextLong();
		
		long count = 0;
		if (C >= S * 2) {
			count += S;
			C -= S * 2;
			count += C / 4;
		} else {
			count += C / 2;
		}
		
		System.out.println(count);
	}
}




Measured memory_bytes: 22868
n = int(input())
ss = ["".join(sorted(list(input()))) for _ in range(n)]
ss.sort()

ans = 0
cnt = 0
tmp = ss.pop(0)
for s in ss:
    if tmp == s:
        cnt+=1
    elif cnt > 0:
        tmp = s
        ans+=((cnt+1) * cnt // 2)
        cnt = 0
    else:
        tmp = s
        cnt = 0
print(ans + ((cnt+1) * cnt // 2))

Measured memory_bytes: 57048
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    using P = tuple<ll,ll,ll>;

    set<P> st;
    int cnt=0;
    while(1){
        if(a%2==1 or b%2==1 or c%2==1) break;
        cnt++;
        ll na = (b+c)/2;
        ll nb = (a+c)/2;
        ll nc = (a+b)/2;
        P t = make_tuple(na,nb,nc);
        if(st.count(t)){
            cout << -1 << endl;
            return 0;
        }
        st.insert(t);
        a = na;
        b = nb;
        c = nc;
    }
    cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

	ll N, res = 0;
	cin >> N;
	for(ll a = 2; a*a <= N; ++a) {
		ll b = a;
		while(N % b == 0) {
			++ res;
			N /= b;
			b *= a;
		}
		while(N % a == 0) N /= a;
	}
	if(N != 1) ++res;
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string S){
	bool flg = true;
	rep(i, S.length()) {
		if ((i+1)%2 == 0 && S[i] == 'R') flg = false;
		if ((i+1)%2 == 1 && S[i] == 'L') flg = false;
	}
	if (flg) cout << "Yes" << endl; else  cout << "No" << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

N, K = map(int, input().split())
A = list(map(int, input().split()))

G = gcd(*A)
M = max(A)

if K % G == 0 and M >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0)break;
        int ans = 0;
        for(int i = 1; i <= n; i++){
            int cnt = 1;
            int temp = i;
            for(int j = 1; temp < n; j++){
                temp += i+j;
                cnt++;
            }
            if(temp == n && cnt != 1)ans++;
        }
        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int N,A;
  cin >> N >> A;
  int Al = N%500;
  if(Al<=A){
    cout << "Yes" << endl;
  }else{
    cout << " No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
  int n, tmp1=0, tmp2=0, tmp3=0;
  int *x, *y;
  double sum1=0, sum2=0, sum3=0, max=-1;

  scanf("%d", &n);
  x = malloc(sizeof(int)*n);
  y = malloc(sizeof(int)*n);
  for(int i=0;i<n;i++) scanf("%d", (x+i));
  for(int i=0;i<n;i++) scanf("%d", (y+i));
  for(int i=0;i<n;i++){
    tmp1 = x[i]-y[i];
    if(tmp1 < 0) tmp1 *= -1;
    if(max < tmp1) max = tmp1;
    tmp2 = tmp1*tmp1;
    tmp3 = tmp2*tmp1;
    sum1 += tmp1;
    sum2 += tmp2;
    sum3 += tmp3;
  }
  sum2 = sqrt(sum2);
  sum3 = cbrt(sum3);
  printf("%f\n%f\n%f\n%f\n", sum1, sum2, sum3, max);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int main()
{
	int bangou;
	float weight, height, bmi;
	
	while (~scanf("%d,%f,%f", &bangou, &weight, &height))
	{
		//cout << "bangou = " << bangou << " : weight = " << weight << " : height = " << height << endl;
		bmi = weight / height / height;
		//cout << "bmi = " << bmi << endl;
		if (bmi >= 25.0)
		{
			cout << bangou << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;


bool solve()
{
	string S;
	cin >> S;
	if (S == "#")return false;

	mat cell(10, vec(10, 0));

	int num = 0;
	int x = 0, y = 0;
	int W, H = 1;
	for (int i = 0; i < S.length();++i)
	{
		if (S[i] == '/')
		{
			W = x;
			H++;
			++y;
			x = 0;
		}
		else if(S[i]  == 'b')
		{
			cell[x][y] = 1;
			++x;
		}
		else
		{
			x += (int)(S[i] - '0');
		}
	}
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cell[--b][--a] = 0;
	cell[--d][--c] = 1;
	

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (cell[j][i])
			{
				if(num!=0)
				{
					cout << num;
					num = 0;
				}
				cout << 'b';
			}
			else
			{
				++num;
			}
		}
		if (num != 0)
		{
			cout << num;
			num = 0;
		}
		if (i == H - 1)continue;
		cout << "/";
	}
	cout << endl;
	return true;
}


int main()
{
	while(solve())
	{

	}

	return 0;
}


Measured memory_bytes: 3192
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	HashSet<Character> set = new HashSet<Character>();
	char[] a = sc.next().toCharArray();
	for(int i = 0; i<a.length; i++) {
	    set.add(a[i]);
	}
	if(set.size() == a.length) {
	    System.out.println("yes");
	}else {
	    System.out.println("no");
	}
    }
}

Measured memory_bytes: 23380
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define ALL(v) begin(v),end(v)

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> as(n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &as[i]);
	}
	vector<int> acc;
	for(int i = 0; i < k && *min_element(ALL(as)) < n; ++i){
		acc.assign(n + 1, 0);
		for(int j = 0; j < n; ++j){
			++acc[max(j - as[j], 0)];
			--acc[min(j + as[j] + 1, n + 1)];
		}
		partial_sum(ALL(acc), acc.begin());
		acc.pop_back();
		as = acc;
	}
	for(int i = 0; i < n; ++i){
		printf("%d%c", as[i], i + 1 == n ? '\n' : ' ');
	}
}


Measured memory_bytes: 4408
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];

            if ((a + b) % 2 == 0)
            {
                Console.WriteLine((a + b) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


Measured memory_bytes: 28228
#include<stdio.h>
int main(void){
	
int a,b;
scanf("%d %d",&a,&b);
if(a < b){
	printf("a < b\n");
	}
else if(a > b){
	printf("a > b\n");
	}
else{
	printf("a == b\n");
	}
return 0;
}


Measured memory_bytes: 1976
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	multiset<int> st;
	rep(i, n) {
		auto itr = st.lower_bound(a[i]);
		if (itr != st.begin()) st.erase(--itr);
		st.insert(a[i]);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 5376
import sys

a, b, c = sys.stdin.readline().rstrip().split()

a = int(a)
b = int(b)
c = int(c)

d = a % b
e = d
while True:
    e = (e + d) % b
    if e == c:
        print('YES')
        break
    if e == d:
        print('NO')
        break


Measured memory_bytes: 3316
#include<stdio.h>

int main(void)
{
	int x, i;
	
	for(i=1;;i++)
	{
		scanf("%d\n", &x);
		
		if(x==0)
		{
			break;
		}
		
		printf("Case %d: %d\n", i, x);
	}
	
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if(a < c && c < b) cout << "Yes" << endl;
    else if(b < c && c < a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a,b = [0]*m,[0]*m
c,d = set(),set()
for i in range(m):
    a[i],b[i] = map(int,input().split())
    if a[i] == 1:
        c.add(b[i])
    elif b[i] == n:
        d.add(a[i])
if c & d:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 24932
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
        while(true){
            c-=b;
            if(c<=0){
                System.out.println("Yes");
                break;
            }
            a-=d;
            if(a<=0){
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 35752
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

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



Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int n;
    cin>>n;
    if(n>=30) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3644
#include<iostream>

using namespace std;

int main(){
	int n,d;
	cin >> d >> n;
	
	int ans = n;
	int tolerance = 1;
	for(int i = 0;i < d;i++){
		tolerance *= 100;
	}
	if(n == 100){
		ans = ans * tolerance + tolerance;
	}else{
		ans = ans * tolerance;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] stones = new int[n];
        for (int i = 0; i < n; ++i) {
            stones[i] = sc.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(stones[1] - stones[0]);
        for (int i = 2; i < stones.length; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(stones[i] - stones[i - 1]), dp[i - 2] + Math.abs(stones[i] - stones[i - 2]));
        }
        System.out.print(dp[n - 1]);
    }
}


Measured memory_bytes: 50440
a,b,c = map(int, input().split())

if a<b:
    if b<c:
        print(a, b, c)
    elif a<c:
        print(a, c, b)
    else:
        print(c, a, b)
else:
    if b>c:
        print(c, b, a)
    elif c>a:
        print(b, a, c)
    else:
        print(b, c, a)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll x1=(a*c);
   ll x2=(b*c);
   ll x3=(a*d);
   ll x4=(b*d);
   cout<<max(max(max(x1,x2),x3),x4)<<endl;

}


Measured memory_bytes: 3668
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
max, p1, p2, p3 = 0, 0, 0, 0;
n.times do |i|
  q = (x[i] - y[i]).abs
  max = q if q > max
  p1 += q
  p2 += q ** 2
  p3 += q ** 3
end
puts p1
puts Math.sqrt(p2)
puts p3 ** Rational(1, 3)
puts max

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

int main() {
string S;
 cin>>S;
  string divide[4]={"dream", "dreamer", "erase", "eraser"};
  
   // 後ろから解くかわりにすべての文字列を「左右反転」する
  reverse(S.begin(), S.end());
  for (int i=0; i<4; i++){
    reverse(divide[i].begin(), divide[i].end());
  }

    // 端から切っていく
    bool can=true;
    for (int i=0; i<S.size(); ){
        bool can2=false; // 4 個の文字列たちどれかで divide できるか
        for (int j=0; j<4; j++){
          string d=divide[j];
          if(S.substr(i, d.size())==d){ // d で divide できるか
              can2=true;
              i+=d.size(); // divide できたら i を進める
          }
        }
        if(!can2){ // divide できなかったら
          can=false;
          break;
        }
    }

 if(can){cout<<"YES";}
 else{cout<<"NO";}
}

Measured memory_bytes: 512
use std::io;

fn main() {
  let mut input = String::new();
  if let Ok(_) = io::stdin().read_line(&mut input) {
    let v: Vec<i32> = input.trim().split(' ').map(|x| x.parse().unwrap()).collect();
    let o = (1..1001).find(|x| *x * 8 / 100 == v[0] && *x / 10 == v[1]).unwrap_or(-1);
    println!("{}", o);
  }
}

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

int main() {
  int N;
  cin >> N;
  int f = 0;
  int M ;
  M = N;
  int q = 100000000;
  
  for (int i = 8; i >= 0; i--){
    
    f += M / q;
    M -= (M / q) * q;
    q /= 10;

  }
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


Measured memory_bytes: 256
s = input()
n = len(s)

res = 0
for i in range(n):
    for j in range(i, n):
        sub = s[i: j+1]

        flg = True
        for c in sub:
            if(c not in ['A', 'G', 'C', 'T']): flg = False

        if(flg): res = max(res, len(sub))

print(res)

Measured memory_bytes: 9052
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, n1=0, n2=0;
	scanf("%d", &n);
	long long int a1[500], a2[500], a[1000];
	for(int i=0; i<n; i++){
		if(i%2==0){
			scanf("%lld", &a2[i/2]);
			a[i]=a2[i/2];
			n2++;
		}else{
			scanf("%lld", &a1[(i-1)/2]);
			a[i]=a1[(i-1)/2];
			n1++;
		}
	}
	long long int s1=0, s2=0;
	vector<int> p1, p2;
	for(int i=0; i<n1; i++){
		if(a1[i]>0){
			s1=s1+a1[i];
			p1.push_back(2*i+1);
		}
	}
	for(int i=0; i<n2; i++){
		if(a2[i]>0){
			s2=s2+a2[i];
			p2.push_back(2*i);
		}
	}
	if(p1.empty() && p2.empty()){
		long long int amax, imax;
		for(int i=0; i<n; i++){
			if(i==0){
				amax=a[0];
				imax=0;
			}else if(amax<a[i]){
				amax=a[i];
				imax=i;
			}
		}
		printf("%lld\n", amax);
		printf("%d\n", n-1);
		for(int i=0; i<imax; i++){
			printf("%d\n", 1);
		}
		for(int i=0; i<n-imax-1; i++){
			printf("%d\n", n-imax-i);
		}
	}else if(s1>s2){
		printf("%lld\n", s1);
		int k=(int)p1.size();
		int m=0;
		m=(p1[k-1]-p1[0])/2+p1[0]+n-p1[k-1]-1;
		printf("%d\n", m);
		for(int i=0; i<p1[0]; i++){
			printf("%d\n", 1);
		}
		for(int j=0; j<k-1; j++){
			for(int i=0; i<(p1[j+1]-p1[j])/2; i++){
				printf("%d\n", (p1[j+1]-p1[j])/2+1-i);
			}
		}
		for(int i=0; i<n-p1[k-1]-1; i++){
			printf("%d\n", n-p1[k-1]-i);
		}
	}else{
		printf("%lld\n", s2);
		int k=(int)p2.size();
		int m=0;
		m=(p2[k-1]-p2[0])/2+p2[0]+n-p2[k-1]-1;
		printf("%d\n", m);
		for(int i=0; i<p2[0]; i++){
			printf("%d\n", 1);
		}
		for(int j=0; j<k-1; j++){
			for(int i=0; i<(p2[j+1]-p2[j])/2; i++){
				printf("%d\n", (p2[j+1]-p2[j])/2+1-i);
			}
		}
		for(int i=0; i<n-p2[k-1]-1; i++){
			printf("%d\n", n-p2[k-1]-i);
		}
	}

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
ll n, k;
ii a[N];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        auto [v, c] = a[i];
        if (c >= k) {
            cout << v << endl;
            exit(0);
        }
        k -= c;
    }
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;

int n;

void dfs(string s, char mc){
    if(s.size() == n){
        cout << s << endl;
    }else{
        for(char c = 'a'; c <= mc; c++){
            char nc = c == mc ? (char)(mc + 1) : mc;
            dfs(s + c, nc);
        }
    }
}

int main() {
    cin >> n;
    dfs("", 'a');

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if (a+b<c+d){
    cout << "Right" << endl;
  }else if(a+b == c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Left" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

void printArray(int *array, int arraySize) {
    for (int i = 0; i < arraySize; i++) {
        std::cout << array[i] << " ";
    }
    std::cout << std::endl;
}

int countZero(int *array, int arraySize) {
    int count = 0;

    for (int i = 0; i < arraySize; i++) {
        if (array[i] == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int N, K;
    int d, idx;

    std::cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) {
        A[i] = 0;
    }
    for (int i = 0; i < K; i++) {
        std::cin >> d;
        for (int j = 0; j < d; j++) {
            std::cin >> idx;
            A[idx - 1]++;
        }
    }
    std::cout << countZero(A, N) << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3196
#include <cstdio>
#include <cmath>

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  int div=1<<M;
  double res=0.0;
  double p=1.0/div, acc=p;
  for (int i=1; i<=509; ++i) {
    res += i * acc;
    acc *= (1.0-p);
  }

  printf("%d\n", int(ceil((1900*M+100*(N-M))*res)));
  return 0;
}


Measured memory_bytes: 128
from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p) * (-1)
    SP.append([i, s, p])

SP.sort(key=itemgetter(1, 2))
for x in SP:
    print(x[0] + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int B[1000];
int A[1000][1000];

int main() {
  int N,M,C;
  cin >> N >> M >> C;
  
  for(int j = 0;j < M;j++){
    cin >> B[j];
  }
  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      cin >> A[i][j];
    }
  }
  
  
  int count = 0;
  for(int i = 0;i < N;i++){
     int sum = 0;
    for(int j = 0;j < M;j++){
     
      sum += A[i][j] * B[j];
    }
    if(sum + C > 0){
      count++;
    }
  }
  
  cout << count << endl;
  
}
  

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

int main()
{
   char str[21];
   int length;
   int i;
   scanf("%s",str);
   length=strlen(str);
   for(i=length-1;i>=0;i--)printf("%c",str[i]);
   printf("\n");
   return 0;
}

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

int main() {
    //入力
    int n;
    int a[101];
    cin >> n;
    rep(i,n) cin >> a[i];
    int ans = 0;
    for (int i=0; i < n; i += 2) {
        if (a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := n / 1000
	b := n % 1000 / 100
	c := n % 1000 % 100 / 10
	d := n % 1000 % 100 % 10
	if (a == b && b == c) || b == c && c == d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200009];
int main()
{
    ll n,t,m,x,i,j,k,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0,sum1=0;
    vector<ll>vi;
    cin>>n;
    for(i = 0 ;i<n; i++)
    {
        cin>>x;
        if(x% 4==0)
            sum++;
        else if(x%4 == 2)
            sum1++;
    }
    n--;
    if(sum1>0){
            sum1--;
    n-=sum1;
    }
    n-=sum*2;
   // cout<<n<<endl;
    if(n<=0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector< lli > A(N);
  vector< lli > B(N);
  lli sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  lli val = 0;
  REP(i, N) {
    val += 2 * (A[(2 * i) % N] - A[(2 * i + 1) % N]);
    B[(2 * (i + 1)) % N] = -val;
  }
  lli diff = 0;
  REP(i, N) {
    diff += B[i];
    // cout << B[i] << endl;
  }
  lli a0 = (sum - diff) / N;
  REP(i, N) { cout << a0 + B[i] << " "; }
  cout << endl;
}

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

int main() {
  long N, M;
  cin >> N >> M;
  vector<pair<long, long>> AB(N);
  for (long i = 0; i < N; i++) {
    long a, b;
    cin >> a >> b;
    AB[i] = make_pair(a, b);
  }
  sort(AB.begin(), AB.end());
  long ret = 0;
  for (long i = 0; i < N; i++) {
    long a, b;
    a = AB[i].first;
    b = AB[i].second;
    ret += a * min(b, M);
    M -= b;
    if (M <= 0) break;
  }
  cout << ret << endl;
}


Measured memory_bytes: 1792