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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
// 今回は残念ながら写経する　本当にわからん

struct BIT{

  const ll UNITY_SUM = 0;
  vector<ll> dat;

  BIT(int n) : dat(n+1, UNITY_SUM){}
  void init(int n) {
    dat.assign(n+1, UNITY_SUM);
  }

  inline void add(int a, ll x){
    for(int i = a; i < (int)dat.size(); i+=i & -i){
      dat[i] = dat[i] + x;
    }
  }

  inline ll sum(int a){
    ll res = UNITY_SUM;
    for(int i = a; i > 0; i -= i & -i){
      res = res + dat[i];
    }
    return res;
  }

  inline ll sum(int a, int b){
    return sum(b - 1) - sum(a - 1);
  }
};


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

  ll N;
  cin >> N;
  vector<ll> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  int low = 0, high = 1<<30;
  const int geta = N+1;
  while (high - low > 1){
    int mid = (low + high) / 2;
    ll num = 0;
    BIT bit(N*2+10);
    int sum = 0;
    bit.add(sum+geta, 1);
    for(int i = 0; i < N; i++){
      int val;
      if(a[i] <= mid ) val = 1; else val = -1;
      sum += val;
      num += bit.sum(1, sum+geta);
      bit.add(sum+geta, 1);
    }
    if(num > (N+1)*N/2/2) high = mid;
    else low = mid;
  }
  cout << high << endl;

  return 0;
}



Measured memory_bytes: 2664
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int time;
        int[][] A;
        A = new int[H][W];
        for(int i=0; i<H; i++){
            char[] JOI = sc.next().toCharArray();
            time = -1;
            for(int j=0; j<W; j++){
                if(JOI[j] == 'c') time = 0;
                A[i][j] = time;
                if(time>=0) time++;
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                System.out.print(A[i][j]);
                if(j<W-1) System.out.print(" ");
                else System.out.println();
            }
        }
    }
 
}

Measured memory_bytes: 36204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
const ll LINF = ((ll)1<<60);

signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	string ans;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	while(n){
		if(n % 2 != 0){
			ans = '1' + ans;
			--n;
		}
		else ans = '0' + ans;
		n /= -2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 998244353;

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

    li n;
    cin >> n;
    map<string, li> counts;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        counts[s] += 1;
    }

    li ans = 0;
    for (auto& item  : counts) {
        ans += item.second * (item.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

void solve(){
    int N, W;
    int w[100];
    ll v[100];
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    ll dp[N+1][W];
    rep(i, N+1){
        rep(j, W){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    ll res=0;
    rep(i, W+1) res = max(res, dp[N][i]);
    cout << res << endl;
}

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

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

public class Hello{
    public static void Main(){
        string[]array=Console.ReadLine().Split(' ');
        var N=int.Parse(array[0]);
        var L=int.Parse(array[1]);
        
        var num1=L;
        var num2=L+N-1;
        var list=new List<int>();
        var sum=0;
        var count=0;
        if(num1>=0){
            for(var i=2;i<=N;i++){
                sum=sum+(L+i-1);
            }
        }else if(num1<0&&num2>=0){
            for(var i=1;i<=N;i++){
                sum=sum+(L+i-1);
                if(count==0&&(L+i-1)>=0){
                    sum=sum-(L+i-1);
                    count=1;
                }
            }
        }else{
            for(var i=1;i<N;i++){
                sum=sum+(L+i-1);
            }
        }
        Console.WriteLine(sum);
    }
}


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

typedef long long ll;
const int N = 1e5 + 100;

ll a, b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a >> b;
  	cout << max(a + b, max(2 * a - 1, 2 * b - 1));
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main() {
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(n, n +3);
	if(n[0] == 5 && n[1] == 5 && n[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

struct unionfind {
  vector<int> group;
  vector<int> rank;

  unionfind() {
    unionfind(0);
  }

  unionfind(int n) {
    group = vector<int>(n);
    rank = vector<int>(n);
    for (int i = 0; i < n; i++) group[i] = i;
  }

  int root(int x) {
    if (group[x] == x) return x;
    return group[x] = root(group[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rank[rx] > rank[ry]) group[ry] = rx;
    else if (rank[ry] > rank[rx]) group[rx] = ry;
    else if (rx != ry) {
      group[ry] = rx;
      rank[rx]++;
    }
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<int> t(q), u(q), v(q);
  for (int i = 0; i < q; i++) cin >> t[i] >> u[i] >> v[i];

  unionfind uf(n);

  vector<int> ans;
  for (int i = 0; i < q; i++) {
    if (t[i] == 0) {
      uf.unite(u[i], v[i]);
    }
    else if (t[i] == 1) {
      if (uf.same(u[i], v[i])) ans.push_back(1);
      else ans.push_back(0);
    }
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 6732
#include<stdio.h>
#include<string.h>
main()
{
  char S[5];
  scanf("%s",S);
  char s[7][5]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  int x,num;
  x=0; num=0;
  for(x=0;x<7;x++){
    if(strcmp(S,s[x])==0){
      num=x+1;
  printf("%d",num);}
  }
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;
    int table[30000];
    int a[20000];
int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    */
    /*
    ios::sync_with_stdio(0);
    */
    int n;
    cin>>n;
    if (n==3)
    {
        cout<<"2 5 63";
        re 0;
    }
    int m=n;
    int q=0;
    int i=2;
    int s=0;
    while(n>3&&i+2<30000)
    {
        a[q++]=i;
        a[q++]=i+2;
        s+=2*i+2;
        i+=6;
        n-=2;
    }
    i=3;
    while(n>1&&i+6<30000)
    {
        a[q++]=i;
        a[q++]=i+6;
        s+=2*i+6;
        i+=12;
        n-=2;
    }
    i=6;
    while(n)
    {
        a[q++]=i;
        s+=i;
        i+=6;
        n--;
    }
    fo(i,m)
    {
        printf("%d ",a[i]);
    }
}


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

int main(){
 string s;
 cin >> s;
 int ans = 700;
 for(int i = 0;i < 3; i++){
 if(s[i] =='o'){
     ans += 100;
 } 
 }
 cout << ans << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000009;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
ll l[51];
ll p[51];
void init() {
	l[0] = 1;
	rep1(i, 50) {
		l[i] = l[i - 1] * 2 + 3;
	}
	p[0] = 1;
	rep1(i, 50) {
		p[i] = p[i - 1] * 2 + 1;
	}
}
ll dfs(int n, ll x) {
	if (x == 0)return 0;
	if (n == 0)return 1;
	ll res = 0;
	if (x <= l[n - 1] + 1) {
		res += dfs(n - 1, x-1);
	}
	else if (x == l[n - 1] + 2) {
		res += dfs(n - 1, x-2) + 1;
	}
	else {
		res += p[n - 1]+1;
		if (x == l[n])x--;
		res += dfs(n - 1, x - (l[n - 1] + 2));
	}
	return res;
}
int main() {
	init();
	int n; ll x; cin >> n >> x;
	cout << dfs(n, x) << endl;
	return 0;
}


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

int n, p, Res;

int M(int x, int y)
{
    if ((x) && (!y)) return 0;
    return 1;
}

int main()
{
    scanf("%d", &n); getchar();
    for (int i=1; i<=n; i++)
    {
        char c;
        scanf("%c", &c); getchar();
        if (c == 'T') p = 1; else p = 0;
        if (i == 1) Res = p;
        if (i >= 2)
            Res = M(Res, p);
    }
    puts((Res)?("T"):("F"));
}



Measured memory_bytes: 3160
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static long[] layer, patty;

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        long X = Long.parseLong(scanner.next());
        layer = new long[N + 1];
        layer[0] = 1;
        patty = new long[N + 1];
        patty[0] = 1;
        for (int i = 1; i <= N; i++) {
            layer[i] = layer[i - 1] * 2 + 3;
            patty[i] = patty[i - 1] * 2 + 1;
        }

        System.out.println(dfs(N, X));
    }

    private static long dfs(int N, long X) {
        long L = layer[N];
        if (X == 0) {
            return 0;
        }
        if (L <= X) {
            return patty[N];
        }
        if (X <= L / 2) {
            return dfs(N - 1, X - 1);
        } else if (X == L / 2 + 1) {
            return dfs(N - 1, X - 2) + 1;
        } else { // if (X > L / 2 + 1) {
            return patty[N - 1] + 1 + dfs(N - 1, X - L / 2 - 1);
        }
    }

}



Measured memory_bytes: 22996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var s string

	s = readString()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1784
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    if n==1:
        print('Hello World')
    else:
        a=INT()
        b=INT()
        print(a+b)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#define rep(i,beg,end) for(int i=(beg);i<(end);i++)
using namespace std;

int main(){
	long long n,k;
	long long nums[200002];
	cin>>n>>k;
	long long tot=0;
	rep(i,0,n){
		cin>>nums[i];
		tot+=nums[i];
	}
	sort(nums,nums+n);
	long long cnt=0;
	for(int i=n-1;i>=0;i--){
		if(cnt==k)break;
		tot-=nums[i];
		cnt++;
	}
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
	string s;cin>>s;
	int Min=s.size();
	rep(i,s.size()-1){
		if(s[i]!=s[i+1]){
			Min=min(Min,max(i+1,(int)s.size()-i-1));
		}
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 512
//#include<bits/stdc++.h>
#include<iostream>
//#include<map>
//#include<set>
//#include<vector>
//#include<cstring>
//#include<iterator>
//#include<algorithm>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int t;
    cin>>t;
    if(t>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
  
    


    return 0;
}


Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    while 1:
        n=int(input())
        if n==0:break
        ans=[]
        for _ in range(n):
            l,*num=input().split()
            p,a,b,c,d,e,f,s,m=map(int,num)
            ans.append([(f*s*m-p)/(a+b+c+(d+e)*m),l])
        ans.sort(key=lambda x:(-x[0],x[1]))
        for _,l in ans:
            print(l)
        print("#")

main()



Measured memory_bytes: 5632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a>=k){
        printf("%d",k);
    }else if(a<k&&k<=a+b){
        k=a;
        printf("%d",k);
    }else{
        k=a-(k-(a+b));
        printf("%d",k);
    }
    
    return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
#endif

	string s,t;
	cin>>s>>t;
	int sz=s.size();
	string temp=t.substr(0,sz);
	if(temp==s)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

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


 int gcd( int x, int y)
  {
      if ( x % y == 0 )
      {
          return(y);
      }
      else
      {
          return(gcd(y, x%y));
      }
      
  }

  int gcd(int a, int b, int c) 
    {
    return gcd(gcd(a, b), c);
    }



int main()
{
    int K;
    ll n = 0;
    int a = 1, b = 1, c = 1;

    cin >> K;

    for( int i = 1; i <= K; i++ )
    {
        for( int j = 1; j <= K; j++ )
        {
            for(int k = 1; k <=K; k++ )
            {
                n += gcd(i, j, k);
            }
        }
    }

    cout << n << endl;



    
    
}

Measured memory_bytes: 3640
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= N; i += 2) {
			if (f(i))
				++ans;
		}
		System.out.println(ans);
	}

	boolean f(int n) {
		int cnt = 0;
		for (int i = 1; i <= n; ++i) {
			if (n % i == 0)
				++cnt;
		}
		return cnt == 8;
	}
}

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

int main() {
  int n;
  cin >> n;
  
  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 if (n<=999) cout<<999<<endl;

}


Measured memory_bytes: 256
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

// auto mod int

const i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 K;
  cin >> K;
  string S;
  cin >> S;
  int N = S.size();
  mint ans = 0;
  combination comb(N + K);
  for (int r = N - 1; r <= N + K - 1; ++r) {
    ans +=
        comb(r, N - 1) * mint(25).pow(r + 1 - N) * mint(26).pow(N + K - 1 - r);
  }
  cout << ans << endl;
}


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

using namespace std;

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

	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h.at(i);
	}

	int count = 0;
	int maxCount = 0;
	for (int i = 0; i < n - 1; i++)
	{
		if (h.at(i) >= h.at(i + 1))
		{
			count++;
			if (maxCount < count)
			{
				maxCount = count;
			}
		}
		else
		{
			count = 0;
		}
	}
	cout << maxCount << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#define ll long long
#define maxn 1000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char s[maxn];
int n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	if(n&1){
		puts("No"); return 0;
	}
	for(int i=0;i<n;i++)
		if(i&1){
			if(s[i]!='i'){
				puts("No"); return 0;
			}
		}
		else if(s[i]!='h'){
			puts("No"); return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int h[2], k[2], a, b, c, d;
int main()
{
	for(int i = 0; i < 2; i++)
	cin >> h[i];
	for(int i = 0; i < 2; i++)
	cin >> k[i];
	cin >> a >> b >> c >> d;
	if(h[0] * a + h[1] * b + h[0] / 10 * c + h[1] / 20 * d > k[0] * a + k[1] * b + k[0] / 10 * c + k[1] / 20 * d)
	{
		cout << "hiroshi" << endl;
	}
	else if(h[0] * a + h[1] * b + h[0] / 10 * c + h[1] / 20 * d == k[0] * a + k[1] * b + k[0] / 10 * c + k[1] / 20 * d)
	{
		cout << "even" << endl;
	}
	else
	{
		cout << "kenjiro" << endl;
	}
	return 0;
}

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

using namespace std;

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

    int A, B;
    cin >> A >> B;
    int cur = 1, res = 0;
    while (cur < B) {
        cur += A - 1;
        ++res;
    }
    cout << res << "\n";

    return 0;
}

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

typedef struct Point{
    double x;
    double y;
} Point;

typedef struct Vertex{
    Point p;
    struct Vertex* next;
} Vertex;

Vertex* head = NULL;
Vertex* tail = NULL;

Point vertex(Point p1, Point p2){
  double s60 = sin(60 * M_PI / 180.0);    
  double c60 = cos(60 * M_PI / 180.0);

  Point v = {
    c60 * (p1.x - p2.x) - s60 * (p1.y - p2.y) + p2.x,
    s60 * (p1.x - p2.x) + c60 * (p1.y - p2.y) + p2.y
  };

  return v;
}

void KochCurve(Vertex* A, Vertex* B){
    Vertex* a = (Vertex*) malloc(sizeof(Vertex));
    a -> p.x = A -> p.x + (B->p.x - A->p.x)/3;
    a -> p.y = A -> p.y + (B->p.y - A->p.y)/3;
    
    Vertex* b = (Vertex*) malloc(sizeof(Vertex));
    b -> p.x = A -> p.x + 2*(B->p.x - A->p.x)/3;
    b -> p.y = A -> p.y + 2*(B->p.y - A->p.y)/3;

    Vertex* c = (Vertex*) malloc(sizeof(Vertex));
    c -> p = vertex(b->p,a->p);

    A->next = a;
    a->next = c;
    c->next = b;
    b->next = B;

    if(B->next != NULL)
        KochCurve(B,B->next);
}

void printCurve(){
    Vertex* tmp = head;
    while(tmp!=NULL){
        printf("%f %f\n",tmp->p.x,tmp->p.y);
        tmp = tmp->next;
    }
}

int main(){
    head = (Vertex*) malloc(sizeof(Vertex));
    head -> p.x = 0;
    head -> p.y = 0;

    tail = (Vertex*) malloc(sizeof(Vertex));
    tail -> p.x = 100;
    tail -> p.y = 0;

    head -> next = tail;
    tail -> next = NULL;

    int n;
    scanf("%d",&n);

    for(int i=1; i<=n; i++)
        KochCurve(head,head->next);
    printCurve();

    return 0;
}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii2(n, x); n = 2*n-1;
    if(x == n || x == 1){
        out("No"); return 0;
    }

    out("Yes");
    if(n == 3 && x == 2){
        out(1); out(2); out(3); return 0;
    }

    vector<int> a, b, c;
    int l = (n-4)/2; int r = l+1;
    if(x == 2){
        b.push_back(4); b.push_back(1);
        b.push_back(2); b.push_back(3);
        int k = 5;
        rep(i, l){
            a.push_back(k); k++;
        }
        rep(i, r){
            c.push_back(k); k++;
        }
    }
    else{
        b.push_back(x-1); b.push_back(x);
        b.push_back(x+1); b.push_back(1);
        int k = 2;
        rep(i, l){
            if(k == x-1) k = x+2;
            a.push_back(k); k++;
        }
        rep(i, r){
            if(k == x-1) k = x+2;
            c.push_back(k); k++;
        }
    }

    rep(i, l) out(a[i]);
    rep(i, 4) out(b[i]);
    rep(i, r) out(c[i]);
}


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

int main()
{
	int a,b,c,d,e,f=0,g;
	cin>>a;
	b=a;
	while(a!=0)
	{
		e=a%10;
		f=f+e;
		a=a/10;
		
	}
	if(b%f==0)
		cout<<"Yes";
	else
		cout<<"No";
	
} 

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	string s=readString();
	int ans=1;
	vi freq(26,0);
	REP(i,s.size())
		ans+=i-freq[s[i]-'a']++;
	cout<<ans<<endl;
}

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

vector<int> unknown;
int sum;
int m;
int solve(int even, int odd){
  int res = sum;
  for(int i = 0; i < even; i++){
    int v = 2 * unknown[i];
    int adding = 0;
    if(v >= 10){
      adding += v%10;
      v /= 10;
      adding  += v%10;
      res += adding;
    }else{
      res+=v;
    }

    res %= 10;
  }
  for(int i = even; i < odd+even; i++){
    res += unknown[i];
    res %= 10;
  }
  return res%10 == 0;
}

int main(void){
  int n;
  cin >> n;
  int odd = 0, even = 0;
  string str;
  cin >> str;

  sum = 0;

  for(int i = 1; i <= n; i++){
    char c = str[n-i];
    if(c == '*'){
      if(i % 2 == 0) even++;
      if(i % 2 == 1) odd++;
    }else{
      int v = c - '0';
      if(i % 2 == 1)
        sum += v;
      else{
        v *= 2;
        if(v >= 10){
          sum += v%10;
          v /= 10;
          sum += v%10;
        }else{
          sum += v;
        }
      }
      sum %= 10;
    }
  }

  unknown = vector<int>(even + odd);

  cin >> m;
  vector<int> a(m);
  for(int i = 0; i < m; i++) cin >> a[i];

  int cnt = even + odd;
  int ans = 0;


  for(int i1 = 0; i1 < m; i1++){
    unknown[0] = a[i1];
    if(cnt == 1){
      ans += solve( even, odd);
      continue;
    }
    for(int i2 = 0; i2 < m; i2++){
      unknown[1] = a[i2];
      if(cnt == 2){

        ans += solve( even, odd);
        continue;
      }
      for(int i3 = 0; i3 < m; i3++){
        unknown[2] = a[i3];
        if(cnt == 3){
          ans += solve( even, odd);
          continue;

        }
        for(int i4 = 0; i4 < m; i4++){
          unknown[3] = a[i4];
          if(cnt == 4){
            ans += solve( even, odd);
            continue;

          }
          for(int i5 = 0; i5 < m; i5++){
            unknown[4] = a[i5];
            if(cnt == 5){
              ans += solve( even, odd);
              continue;

            }
            for(int i6 = 0; i6 < m; i6++){
              unknown[5] = a[i6];
              if(cnt == 6){
                ans += solve( even, odd);
                continue;

              }
              for(int i7 = 0; i7 < m; i7++){
                unknown[6] = a[i7];
                ans += solve( even, odd);
              }
            }
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
vector<vector<int>>edge(110);
int find_time[110]={};
int end_time[110];
bool reached[110]={};
int now_time=0;

void search(int now,int before){
    if(reached[now]){
        //cout<<now+1<<"already finished"<<endl;
        return;
    }
    reached[now]=true;

    //if(now==before)return;
    now_time++;
    //cout<<now_time<<"time "<<now+1<<"p "<<before+1<<"before"<<endl;
    if(find_time[now]==0){
        find_time[now]=now_time;
    }
    
    for(auto next:edge[now]){
        if(next==before||end_time[now]!=0)continue;
        search(next,now);
    }
    now_time++;
    end_time[now]=now_time;
    return;
}
int main(){


    int n;
    cin>>n;
    rep(i,n){
        int u,k;
        cin>>u>>k;
        u--;
        rep(l,k){
            int next;
            cin>>next;
            next--;
            edge[u].emplace_back(next);
        }
    }
    rep(i,n)search(i,-1);
    //cout<<endl;
    rep(i,n){
        cout<<i+1<<" "<<find_time[i]<<" "<<end_time[i]<<endl;;
        //if(i!=n-1)cout<<endl;
    }
    return 0;

}
/*


*/



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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  int cnt = 0;
  for (int i = 1; i < n - 1; ++i)
    if ((p[i - 1] < p[i] && p[i] <= p[i + 1]) || (p[i - 1] >= p[i] && p[i] > p[i + 1])) cnt++;
  cout << cnt << endl;
}


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

a1 = list(a)
s1 = 0
for i in range(n):
    if i % 2 == 0:
        if s1 + a1[i] >= 0:
            a1[i] = -1 - s1
    else:
        if s1 + a1[i] <= 0:
            a1[i] =  1 - s1
    s1 += a1[i]


a2 = list(a)
s2 = 0
for i in range(n):
    if i % 2 == 0:
        if s2 + a2[i] <= 0:
            a2[i] =  1 - s2
    else:
        if s2 + a2[i] >= 0:
            a2[i] = -1 - s2
    s2 += a2[i]

t1 = sum(abs(x - y) for x, y in zip(a, a1))
t2 = sum(abs(x - y) for x, y in zip(a, a2))
t = min(t1, t2)
print(t)

Measured memory_bytes: 14500
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string S, T;
    int N;
    cin >> N >> S >> T;
    rep(i, 0, N) {
        cout << S[i];
        cout << T[i];
    }
    cout << endl;
    return 0;
}

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

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

  c = a * b;

  if(0 == (c % 2)){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#写経 #16303645
#dequeはリストよりも高速に両端の値にアクセスできる
import sys
from collections import deque
h,w = map(int, input().split())#hは表の高さ、wは表の幅
ch, cw = map(int, input().split())#スタート地点のh座標,w座標
dh, dw = map(int, input().split())#ゴール地点のh座標、w座標

#s;迷路。枠外にワープしないよう周りを＃＃で囲む
s = ["#"*(w+4)]#上側の＃
s.append("#"*(w+4))#上側の＃
for i in range(h):
    s.append("##"+input()+"##")#左右の＃＃
s.append("#"*(w+4))#下側の＃
s.append("#"*(w+4))#下側の＃
#print(s)
"""
s
['######',
 '######', 
 '##..##', 
 '##..##', 
 '######', 
 '######']
"""  
ans = [[-1]*(w+4) for i in range(h+4)]#全要素−1
#print(ans)
"""
ans
[
	[-1, -1, -1, -1, -1, -1], 
	[-1, -1, -1, -1, -1, -1], 
	[-1, -1, -1, -1, -1, -1], 
	[-1, -1, -1, -1, -1, -1], 
	[-1, -1, -1, -1, -1, -1], 
	[-1, -1, -1, -1, -1, -1]]
"""
#壁＃の部分を−2にする。移動可能位置は−1
for i in range(h+4):
    for j in range(w+4):
        if s[i][j] == "#":
        	ans[i][j] = -2
#print(ans)
"""
ans
[
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2, -1, -1, -2, -2], 
	[-2, -2, -1, -1, -2, -2], 
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2, -2, -2, -2, -2]]
"""
#壁で囲った表でスタート、ゴール位置を正しく指定出来るようcとsのh座標、w座標を1ずつ増やす
ch += 1
cw += 1
dh += 1
dw += 1
#ansのスタート位置を0にする。魔法を使った回数。
ans[ch][cw] = 0
#print(ans)
"""
ans
[
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2,  0, -1, -2, -2], 
	[-2, -2, -1, -1, -2, -2], 
	[-2, -2, -2, -2, -2, -2], 
	[-2, -2, -2, -2, -2, -2]]
"""
move = [[1,0],[-1,0],[0,1],[0,-1]]#移動変位。下、上、右、左
"""
l = []
for i in range(-2,3):
	for j in range(-2,3):
		l.append([i,j])
lの中身が魔法の移動変位。magicにコピペ    
"""
magic = [[-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]

mylist = deque([[ch,cw]])#dequeの生成。移動元の座標リスト。初期値はスタート位置。
mylist2 = deque([])#徒歩で通った座標のリスト。

#徒歩、魔法両方で行ける場所を全て探す
while len(mylist) > 0:
    y,x = mylist.popleft()#mylistの左端の座標を取り出す。初期値はスタート位置。
    mylist2.append([y, x])#mylist2の右端に取り出した座標を追加。
    #これまで通ったことがなく、徒歩で移動できる座標を見つける。これまで魔法を使った回数をその座標の値にする。
    for p,q in move:#移動変位を一つずつ取り出す
        vy,vx = y+p, x+q#移動先のh座標、w座標移動可能な場合
        if ans[vy][vx]== -1:#まだ行ったことが無く、移動可能=移動先が−1の場合
            mylist.append([vy,vx])#移動元の座標リストに追加
            ans[vy][vx] =ans[y][x]#移動先の値を移動元の値と同じにする。これまで魔法を使った回数。
            #移動先がゴールなら終了
            if vy == dh and vx == dw:
                print(ans[vy][vx])
                sys.exit()
    #print(ans)
    #徒歩で移動できなくなったら、魔法を使って移動出来る座標を探す。魔法を使った回数が+1になる。
    if len(mylist) == 0:#移動出来なくなった場合
        while len(mylist2) >0:
            y2, x2 = mylist2.popleft()#移動先リストから座標を取り出す
            for v1,v2 in magic:
                i,j = y2+v1, x2+v2#取り出した座標にmagic移動変位を加える
                if ans[i][j] == -1:
                    mylist.append([i,j])
                    ans[i][j] = ans[y2][x2] + 1#魔法を使って移動したので、移動先の値は移動元の値+1になる。
                    #移動先がゴールなら終了
                    if i == dh and j == dw:
                        print(ans[i][j])
                        sys.exit()
    #print(ans)
    #魔法を使って移動出来る座標がみつかったら、徒歩で移動可能な座標を探すループに戻る
#全て通った、もしくは徒歩でも魔法でも移動できない座標のみになったら終わり
print(ans[dh][dw])#全探索した表のゴール位置の値が答え。移動できなかったら−1

Measured memory_bytes: 106808
import sys
input = sys.stdin.readline
def solve():
  n  = int(input())
  a = [list(int(i) for i in input().split()) for _ in range(n)]
  a2 = []
  #warshall
  for k in range(n):
    for i in range(n):
      for j in range(i+1,n):
        if not k in [i,j]:
         if a[i][j] > a[i][k] + a[k][j]:
          #距離短縮可能
           print(-1)
           exit()
         elif a[i][j] ==  a[i][k] + a[k][j]:
          a2.append((i,j))
  for i,j in a2:
    a[i][j] = 0
  ans = 0
  for i in range(n):
    for j in range(i+1,n):
        ans += a[i][j]
  print(ans)
solve()

Measured memory_bytes: 143940
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000006;

int n;

int q(int x)
{
    int u = 2;
    int ans = 0;
    while (u <= x)
    {
        ans += (x / u);
        u *= 2;
    }
    return ans;
}

char b[N];
int solvv()
{
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (b[i] == 1 && q(n - 1) - q((n - 1) - (i - 1)) == q((i - 1)))
            ans ^= 1;
    }
    return ans;
}

char a[N];

/*int dp[N][N];

int solv0()
{
    for (int i = 1; i <= n; ++i)
        dp[1][i] = a[i];
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 1; j <= n - i + 1; ++j)
            dp[i][j] = abs(dp[i - 1][j] - dp[i - 1][j + 1]);
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < i - 1; ++j)
            printf(" ");
        for (int j = 1; j <= n - i + 1; ++j)
            printf("%d ", dp[i][j]);
        printf("\n");
    }
    return dp[n][1];
}*/

int solv()
{
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] == 1)
            b[i] = 1;
        else
            b[i] = 0;
    }
    if (solvv() == 1)
        return 1;
    bool z = false;
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] == 1)
        {
            z = true;
            break;
        }
    }
    if (z)
        return 0;
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] == 0)
            b[i] = 0;
        else
            b[i] = 1;
    }
    if (solvv() == 1)
        return 2;
    return 0;
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    scanf("%d", &n);
    scanf(" %s", (a + 1));
    for (int i = 1; i <= n; ++i)
        a[i] -= '1';
    printf("%d\n", solv());
    return 0;
    while (1)
    {
        n = rnf() % 15 + 1;
        for (int i = 1; i <= n; ++i)
        {
            a[i] = rnf() % 3 + 1 + '0';
        }
    }
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 2176
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

l.sort(key=lambda x: x[2], reverse=True)
#print(l)

for cx in range(0, 101):
  for cy in range(0, 101):
    x = l[0][0]
    y = l[0][1]
    h = l[0][2]
    H = h+abs(x-cx)+abs(y-cy)
    #print(cx, cy, H)
    for i in range(1, n):
      x = l[i][0]
      y = l[i][1]
      h = l[i][2]
      if h != max(H-abs(x-cx)-abs(y-cy), 0):
        break
    else:
      print(cx, cy, H)
      exit()

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

int main(){
    int N; cin >> N; 
    vector<ll> A(N);
    ll sum = 0;
    for(int i = 1; i <= N; i++){
        ll a; cin >> a;
        A[i-1] = a - i;
        sum += A[i-1];
    }
    sort(A.begin(), A.end());
    ll sumb = 0, sumc = 0;
    for(int i = 0; i < N; i++){
        sumb += abs(A[i] - A[N/2]);
        sumc += abs(A[i] - A[N/2 + 1]);
    }
    cout << min(sumb, sumc) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(10, 0);
    for (int i = 0; i < k; i++) {
        int t;
        cin >> t;
        v[t]++;
    }
    for (int i = n; ; i++) {
        string s = to_string(i);
        int flag = 1;
        for (auto ss : s) {
            if (v[ss - '0'] == 1) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3696
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

# def bfs(si, sj, str_list, dist, h, w):
#     q = deque([[si, sj]])
#     dist[si][sj] = 0
#     max_tmp = 0
#     while len(q) != 0:
#         i, j = q.popleft()
#         for dx, dy in ([1, 0], [-1, 0], [0, 1], [0, -1]):
#             ni = i + dx
#             nj = j + dy
#             if ni < 0 or ni >= h or nj < 0 or nj >= w:
#                 continue
#             if str_list[ni][0][nj] != '.':
#                 continue
#             if dist[ni][nj] != inf:
#                 continue
#             dist[ni][nj] = dist[i][j] + 1
#             q.append([ni, nj])
#             max_tmp = max(max_tmp, dist[ni][nj])
#     return max_tmp

def create_graph(n: int, l: list) -> list:
    graph = [[] for _ in range(n)]
    for a, b in l:
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    return graph

def main():
    n, m = i_map()
    num_list = i_row_list(m)

    graph = create_graph(n, num_list)

    q = deque([0])

    visited = [INF] * n
    visited[0] = 1

    ans = [0] * n

    while len(q) != 0:
        node = q.popleft()
        for leaf in graph[node]:
            if visited[leaf] != INF:
                continue
            ans[leaf] = node + 1
            visited[leaf] = 1
            q.append(leaf)

    Yes()
    for a in ans[1:]:
        print(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 126424
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;
 


int main() {
	int n;
	cin >> n;
	ll a = 1;
	for (int i = 1; i <= n; i++) {
		a = (a * i) % MOD;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
void main(){
	
	auto ABCK = readLine!long();
	auto A = ABCK[0];
	auto B = ABCK[1];
	auto C = ABCK[2];
	auto K = ABCK[3];
	
	
	if( K <= A ){
		K.writeln();
	} else if( K <= A+B ) {
		A.writeln();
	} else {
		(A - (K-(A+B))).writeln();
	}
	
	return;
}



import std;


string readStr(){
	return readln().chomp();
}
T[] readLine( T = long )(){
	return readln().split().to!(T[])();
}


Measured memory_bytes: 3644
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N, K;
    cin >> N >> K;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    sort(ALL(A), greater<ll>());

    ll sum = 0;
    FOR(i, 0, K){
        sum += A[i];
    }

    p(sum);
    
    return 0;
}

Measured memory_bytes: 256