akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,x=1,i=1,j=0;
scanf("%d%d",&a,&b);
if(a<2||b<1||a>20||b>20)
{
exit(0);
}
/*if(b==1)
{
    printf("%d",0);
    return 0;
}*/
while(x<b)
{
x=a*i-j;
i++;
j++;
}
printf("%d",i-1);
return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long int l,r;
	cin>>l>>r;
	int ans=0;
	while(l<=r){
		ans++;
		l<<=1;
	}
	cout<<ans<<endl;
}


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 = Integer.parseInt(sc.next());
        // String s = sc.next();
        int[] a = new int[n+1];
        int[] b = new int[n+1];

        for (int i = 2; i <= n; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[a[i]]++;
        }
        for (int i = 1; i <= n; i++) {
            System.out.println(b[i]);
        }
        // System.out.println();
        sc.close();
    }

}

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

int main()
{
	int d , n ;
	cin >> d >> n;
	if(d==0)
	{
		if(n==100) cout << 101 << endl;
		else cout << n << endl;
	}
	else if(d==1)
	{
		if(n<100) cout << n << "00\n";
		else cout <<"10100\n";
	}
	else
	{
		if(n<100) cout << n << "0000\n";
		else cout << "1010000\n";
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, m;
    cin >> n >> m;
    int h[n];
    int ok[n];
    rep(i, n) {
        cin >> h[i];
        ok[i] = 1;
    }
    int a[m], b[m];
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    rep(i, m) {
        if(h[a[i]] < h[b[i]]) {
            ok[a[i]] = 0;
        } else if(h[a[i]] == h[b[i]]) {
            ok[a[i]] = 0;
            ok[b[i]] = 0;
        } else {
            ok[b[i]] = 0;
        }
    }
    int ans = 0;
    rep(i, n) {
        if(ok[i] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6756
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var output = [];
  var i = 0;
  while( '-' != data[i] ) {
    var cards = data[i++];  
    var m = data[i++];
    for( var j=0; j<m; j++ ) {
      var h = data[i++];
      var t = cards.substr( 0, h );
      cards = cards.substr( h )+t;
    }
    output.push( cards );
  }
  console.log( output.join( '\n' ) );
});

Measured memory_bytes: 7640
import numpy as np
# from time import time

# t0 = time()
N, K = map(int, input().split())
B = np.zeros((2 * K, 2 * K), np.int32)
W = np.zeros((2 * K, 2 * K), np.int32)
# t1 = time()
# print(t1 - t0)
for _ in range(N):
    x, y, c = input().split()
    if c == "B":
        B[int(x) % (2 * K)][int(y) % (2 * K)] += 1
    else:
        W[int(x) % (2 * K)][int(y) % (2 * K)] += 1
# t2 = time()
# print(t2 - t1)
SB = np.zeros((4 * K + 1, 4 * K + 1), np.int32)
SW = np.zeros((4 * K + 1, 4 * K + 1), np.int32)
# t3 = time()
# print(t3 - t2)
SB[0*K+1:2*K+1, 0*K+1:2*K+1] = B
SB[0*K+1:2*K+1, 2*K+1:4*K+1] = B
SB[2*K+1:4*K+1, 0*K+1:2*K+1] = B
SB[2*K+1:4*K+1, 2*K+1:4*K+1] = B
SW[0*K+1:2*K+1, 0*K+1:2*K+1] = W
SW[0*K+1:2*K+1, 2*K+1:4*K+1] = W
SW[2*K+1:4*K+1, 0*K+1:2*K+1] = W
SW[2*K+1:4*K+1, 2*K+1:4*K+1] = W
# t4 = time()
# print(t4 - t3)
np.cumsum(SB, 0, out=SB)
np.cumsum(SB, 1, out=SB)
np.cumsum(SW, 0, out=SW)
np.cumsum(SW, 1, out=SW)
# t5 = time()
# print(t5 - t4)
ans = 0
cand = SB[1*K:3*K+1, 1*K:3*K+1].copy()
cand -= SB[0*K:2*K+1, 1*K:3*K+1]
cand -= SB[1*K:3*K+1, 0*K:2*K+1]
cand += SB[0*K:2*K+1, 0*K:2*K+1]
cand += SB[2*K:4*K+1, 2*K:4*K+1]
cand -= SB[1*K:3*K+1, 2*K:4*K+1]
cand -= SB[2*K:4*K+1, 1*K:3*K+1]
cand += SB[1*K:3*K+1, 1*K:3*K+1]
cand += SW[2*K:4*K+1, 1*K:3*K+1]
cand -= SW[1*K:3*K+1, 1*K:3*K+1]
cand -= SW[2*K:4*K+1, 0*K:2*K+1]
cand += SW[1*K:3*K+1, 0*K:2*K+1]
cand += SW[1*K:3*K+1, 2*K:4*K+1]
cand -= SW[0*K:2*K+1, 2*K:4*K+1]
cand -= SW[1*K:3*K+1, 1*K:3*K+1]
cand += SW[0*K:2*K+1, 1*K:3*K+1]
ans = np.max(cand)
# t6 = time()
# print(t6 - t5)

print(ans)


Measured memory_bytes: 184368
def main():
    s = input()
    t = input()
    slen = len(s)
    tlen = len(t)

    maxlen = 0
    for i in range(slen):
        curlen = 0
        for j in range(tlen):
            if i+j >= slen:
                curlen = -1
                break
            if s[i+j] == t[j]:
                curlen += 1
        maxlen = max(maxlen, curlen)
    print(tlen-maxlen)


main()


Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
  int n, k;  
  cin >> n >> k;
  if(k == 1)
  {
    cout << 1.0 << endl;
    return 0;
  }
  
  const int dice = n;
  vector<int> vCount;
  while(k != 1)
  {
    int temp = max(n - k + 1, 0);
    vCount.emplace_back(temp);
    
    k = ceil(k / 2.0f);
    n -= temp;
  }
  vCount.emplace_back(1);
  vCount.shrink_to_fit();
  
  size_t result = 0;
  size_t shift = vCount.size() - 1;
  size_t div = 1;
  for(size_t i = 0; i < vCount.size(); ++ i, --shift, div <<= 1)
    result += vCount[i] << shift;
  
  div >>= 1;
  
  printf("%.11f", (double)result / (dice * div));
  
  return 0;
}

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

typedef struct node {
	int key;
	struct node *next;
	struct node *prev;
} Node;

Node *nil;

void init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *x)
{
	if (x == nil) return;
	x->prev->next = x->next;
	x->next->prev = x->prev;
	free(x);
}

void delete(int key)
{
	deleteNode(listSearch(key));
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

void print_node()
{
	Node *cur = nil->next;
	while (cur->next != nil) {
		printf("%d ", cur->key);
		cur = cur->next;
	}
	printf("%d\n", cur->key);
}


int main()
{
	int n, x, i;
	char com[100];
	init();
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d", com, &x);
		if (com[0] == 'i')
			insert(x);
		else if (com[0] = 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					deleteFirst();
				}
				else if (com[6] == 'L') {
					deleteLast();
				}
			}
			else
				delete(x);
		}
	}
	print_node();
	return 0;
}



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

int main(){
    int H, W;
    cin >> H >> W;
    Graph g(H, vector<int>(W));
    int ans = 0;
    rep(i, H){
        rep(j, W){
            char c;
            cin >> c;
            if(c == '.'){
                ans++;
                g[i][j] = 0;
            }else g[i][j] = 1;
        }
    }

    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int, int>> que;
    int dx[] = {0, 0, -1, 1};
    int dy[] = {-1, 1, 0, 0};

    que.push(make_pair(0,0));
    dist[0][0] = 0;
    while(!que.empty()){
        pair<int, int> p = que.front(); que.pop();
        rep(i, 4){
            if(p.first + dy[i] >= 0 && p.first + dy[i] < H && p.second + dx[i] >= 0 && p.second + dx[i] < W){
                if(g[p.first + dy[i]][p.second + dx[i]] == 1) continue;
                if(dist[p.first + dy[i]][p.second + dx[i]] != -1) continue;
                dist[p.first + dy[i]][p.second + dx[i]] = dist[p.first][p.second] + 1;
                que.push(make_pair(p.first + dy[i], p.second + dx[i]));
            }
        }
    }
    if(dist[H - 1][W - 1] == -1) cout << -1 << endl;
    else cout << ans - dist[H - 1][W - 1] - 1 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std; 
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define int long long int
#define vi vector<int>
#define mod 1000000007
int32_t main()
{
		string a;
		cin>>a;
		if(a=="ABC")
		puts("ARC");
		else
		puts("ABC");
	
	
	
}



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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n;
	cin >> n;

	string k;
	cin >> k;

	int cont = 1;
	char u = k[0];

	for(auto c: k){

		if(c != u){

			u = c;
			cont ++;

		}

	}

	cout << cont << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;

int d[10];

bool isOk(int x) {
    while (x) {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}

int main() {
    int n, k, x;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> x;
        d[x]++;
    }
    while (!isOk(n))
        n++;
    cout << n;
}

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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
//int t = 1; int ti;



const int N = 3e3 + 5;
lli a[N], dp[N][N], n;

void solve(){
    cin>>n;

    fori(i, 1, n)
    cin>>a[i];

    // fill(dp, -1);

    ford(l, n, 1){
        fori(r, l, n){
            if(l == r){
                dp[l][r] = a[l];
            }

            dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
        }
    }

    cout<<dp[1][n];
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}



Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans=0;
  int u=0;
  bool t=false;
  rep(i,n) ans+=a[i];
  ll y=INF;
  rep(i,n){
    y=min(y,a[i]);
    if (a[i]!=1) t=true;
    if (a[i]%2==1) u++;
  }
  if (!t) {
    cout << "First" << endl;
    return 0;
  }
  if (n%2==0){
    if (ans%2==0 && y%2==0) cout << "Second" << endl;
    else cout << "First" << endl;
  }
  else {
      if (u%2==0) cout << "Second" << endl;
      else cout << "First" << endl;
  }
}



Measured memory_bytes: 4416
#include<algorithm> // sort,reverse,min,lower_bound
#include<iostream>
#include<vector>
#include<numeric> //iota
using namespace std;
#define df 0
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n,q; cin >>n >>q;
  li a[n];
  for(int i=0,len=n/2;i<len;i++){
    cin >>a[i];
  }

  li large=0,j=(n+1)%2;
  vector<li> v;
  for(int i=n/2;i<n;i++){
    cin >>a[i];
    large+=a[i];
    v.push_back((a[j]+a[i])/2+1);
    j+=2;
  }
  v.pop_back();
  li x[q];
  for(int i=0;i<q;i++){
    cin >>x[i];
  }
  int idx[q];
  iota(idx,idx+q,0);
  sort(idx,idx+q,[&x](const int& a, const int& b){return x[a]<x[b];});
  if(df){
    printf("large:%ld\nv:",large);
    for(const li& p: v){
      printf("%ld ",p);
    }
    printf("\nidx:");
    for(const int& p: idx){
      printf("%d ",p);
    }
    printf("\n");
  }

  li ans[q],small=0;
  j=(n+1)%2;
  for(int i=0;i<q;i++){
    while(j<n && v[j/2]<=x[idx[i]]){
      large-=a[(n+j)/2];
      small+=a[j];
      j+=2;
      if(df)printf("(%ld,%ld) ",large,small);
    }
    ans[idx[i]]=large+small;
  }
  for(li p: ans){
    printf("%ld\n",p);
  }
}

/// confirm df==0 ///

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx = 400005;
vector<ll> segtree(mx);
int n;
ll get(int a, int b)
{
	ll ret = -1;
	a += (n+1);
	b += (n+1);
	while (a <= b)
	{
		if (a % 2 == 1)
		{
			ret = max(ret, segtree[a++]);
		}
		if (b % 2 == 0)
		{
			ret = max(ret, segtree[b--]);
		}
		a /= 2;
		b /= 2;
	}
	return ret;
}

void update(int i, ll val)
{
	i += (n+1);
	segtree[i] = val;
	for (int q = i/2; q >= 1; q /=2)
	{
		segtree[q] = max(segtree[2 * q], segtree[2 * q + 1]);
	}
}

int main()
{
	cin >> n;
	vector<ll> h(n);
	vector<ll> a(n);
	for (int q = 0; q < n; q++)
	{
		cin >> h[q];
	}
	for (int q = 0; q < n; q++)
	{
		cin >> a[q];
	}
	for (int q = 0; q < n; q++)
	{
		ll x = get(0, h[q]-1);
		update(h[q], x + a[q]);
	}
	cout << get(0, n) << "\n";
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
map<int, int> prime_factor(ll n)
{
    map<int, int> res;
    for(int i = 2; i * i <= n; i++)
    {
        while(n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<int, int> mp = prime_factor(n);
    for(auto x : mp)
    {
        n /= x.first;
        n *= x.first - 1;
    }
    cout << n << endl;
    return 0;
}




Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn=110;
char s[maxn][maxn];
int vis[maxn][maxn];
int n,m;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void dfs1(int x,int y)
{
    vis[x][y]=1;
    for(int i=0;i<4;i++)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<n&&0<=ny&&ny<m&&s[nx][ny]=='*'&&!vis[nx][ny])
            dfs1(nx,ny);
    }
}
void dfs2(int x,int y)
{
    vis[x][y]=1;
    for(int i=0;i<4;i++)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<n&&0<=ny&&ny<m&&s[nx][ny]=='@'&&!vis[nx][ny])
            dfs2(nx,ny);
    }
}
void dfs3(int x,int y)
{
    vis[x][y]=1;
    for(int i=0;i<4;i++)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<n&&0<=ny&&ny<m&&s[nx][ny]=='#'&&!vis[nx][ny])
            dfs3(nx,ny);
    }
}
int main()
{
    while(cin>>n>>m)
    {
        if(n==0&&m==0) break;
        for(int i=0;i<n;i++)
        scanf("%s",s[i]);
        memset(vis,0,sizeof(vis));
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(s[i][j]=='*'&&!vis[i][j])
                {
                    dfs1(i,j);
                    cnt++;
                }
            }
        }

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(s[i][j]=='@'&&!vis[i][j])
                {
                    dfs2(i,j);
                    cnt++;
                }
            }
        }

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(s[i][j]=='#'&&!vis[i][j])
                {
                    dfs3(i,j);
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){

    int cases;cin>>cases;
    vector<int> positions;
    fore(i,0,cases){
        int val;cin>>val;
        if(i%2 == 0){
            positions.insert(positions.begin(),val);
        }else{
            positions.insert(positions.end(),val);
        }
    }
    if(cases%2){
        fore(i,0,cases)cout<<positions[i]<<" ";
    }else{
        fore(i,0,cases)cout<<positions[cases-i-1]<<" ";
    }
    
	return 0;
}

Measured memory_bytes: 3060
X,Y,Z,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()
li=[]
for i in range(X):
    for j in range(Y):
        if((i+1)*(j+1)>K): break
        for k in range(Z):
            if((i+1)*(j+1)*(k+1)<=K):
                li.append(A[i]+B[j]+C[k])
li.sort()
li.reverse()
for i in li[:K]:
    print(i)

Measured memory_bytes: 51804
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007; // 1e9 + 7
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

string S;
ll K;
char res = '1';

int main(int argc, char *argv[]){
    cin >> S >> K;
    rep(i, S.size()){
        char tmp = S[i];
        if(tmp == '1' && i == K - 1){
            res = '1';
            break;
        }
        if(tmp != '1'){
            res = S[i];
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
a=list(map(int,input().split()))
s=set()
for i in range(n+1):
    if a[i] not in s:
        s.add(a[i])
    else:
        q=i
p=a.index(a[q])
q=n-q
Mod=10**9+7
M=n+2 #書き換え
fac=[0]*M
finv=[0]*M
inv=[0]*M
#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
for i in range(1,n+2):
    print((COM(n+1,i)-COM(p+q,i-1))%Mod)

Measured memory_bytes: 102280
MOD = 1000000007
n, k = map(int, input().split())

n_li = list(range(n+1))

ans = 0

for i in range(k, n+2):
    p = (k - 1) * k / 2
    q = ((n + n - k + 1) * k) / 2

    ans += q - p + 1
    ans %= MOD
    k += 1

print(int(ans))


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

vector<int> p;

bool isPrime(int x){
	for(int i=0;i<p.size() && p[i]<=sqrt(x);i++){
		if(x % p[i] == 0) return false;
	}
	return true;
}

int main(void){
	int m,a,b;

	p.push_back(2);
	REP(i,3,100000) if(isPrime(i)) p.push_back(i);

	while(cin>>m>>a>>b && (m||a||b)){
		int max = 0;
		int ans_p = 0;
		int ans_q = 0;

		rep(i,p.size())rep(j,i+1){
			if(p[i]*p[j] > m) break;
			if(p[i]*p[j] > max && (double)p[j]/p[i] >= (double)a/b){
				max = p[i]*p[j];
				ans_p = p[j];
				ans_q = p[i];
			}
		}

		cout<<ans_p<<" "<<ans_q<<endl;
	}

	return 0;
}

Measured memory_bytes: 1008
n = int(input())
rt = {}
cs = [0 for i in range(n)]
for i in range(n):
    id, k, *c = list(map(int, input().split()))
    for j in c:
        rt[j] = id
    cs[id] = c

for i in range(n):
    print("node " + str(i) + ": parent = ", end = "")
    p = [i]
    while True:
        try:
            p.append(rt[p[-1]])
        except:
            break
    if len(p) == 1:
        print("-1, depth = 0, root, ", end = "")
        print(cs[i])
    else:
        print(str(p[1]) + ", depth = " + str(len(p) - 1), end = "")
        if cs[i] == []:
            print(", leaf, []")
        else:
            print(", internal node, ",end = "")
            print(cs[i])



Measured memory_bytes: 23708
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


struct SegTree{

  int sz;
  vector<int> seg;
  int M1;

  SegTree(int n,int m1){
    M1 = m1;
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2*sz,M1);
  }

  void update(int i,int x){
    i+= sz;
    seg[i] = x;
    while(i >>= 1){
      seg[i] = min(seg[2*i],seg[2*i+1]);
    }
  }

  int query(int a,int b){
    int l = M1,r = M1;
    for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) l = min(l,seg[a++]);
      if(b&1) r = min(seg[--b],r);
    }
    return min(l,r);
  }
};


signed main(){
  init();

  int n,q;
  cin>>n>>q;

  SegTree seg(n,INT_MAX);
  rep(i,q){
    int c,x,y;
    cin>>c>>x>>y;
    if(!c)
      seg.update(x,y);
    else
      cout<<seg.query(x,y+1)<<endl;
  }
}



Measured memory_bytes: 4892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int ans = pow(3, N);
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp & 1)
        {
            A[i] = 1;
        }
        else
        {
            A[i] = 2;
        }
    }
    int tmp = 1;
    for (int i = 0; i < N; i++)
    {
        tmp *= A[i];
    }
    cout << ans - tmp << endl;

    return 0;
}

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

const int MOD = 1000000007;

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  int cnt = 0;
  while (N > 0)
  {
    N -= max(H, W);
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        static void Main(string[] arg)
        {
            //int n = int.Parse(Console.ReadLine());
            var array = GetIntList(Console.ReadLine());
            int answer = 0;

            int n = array[0];
            int i = array[1];
            int num = 0;
            while(num<n){
                answer++;
                num+=i * 2 + 1;
            }

            Console.WriteLine(answer);
            Console.ReadLine();
 
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

VEC(int) A, B;
int dp[1024][10012];

int f(int i, int h)
{
    if (h <= 0)
        return 0;
    if (i == A.size())
        return 1 << 28;

    int& ans = dp[i][h];
    if (ans >= 0)
        return ans;

    ans = f(i + 1, h);
    ans = min(ans, f(i, h - A[i]) + B[i]);
    return ans;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, H;
    cin >> H >> N;
    A.resize(N);B.resize(N);
    FOR(i, 0, N)
        cin >> A[i] >> B[i];

    memset(dp, -1, sizeof dp);
    cout << f(0, H) << endl;
    return 0;
};

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>aa(n);
  rep(i,n){cin>>a[i];aa[i]=a[i];}
  vector<int>bit(61);
  rep(i,n){
    int count=0;
    while(a[i]>0){
      if(a[i]&1)bit[count]++;
      a[i]/=2;
      count++;
    }
  }
  int ans=0;
  rep(i,n){
    int count=0;
    while(aa[i]>0){
      if(aa[i]&1)ans=(modpow(2,count)*(n-bit[count])%MOD+ans)%MOD;
      aa[i]/=2;
      count++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int2,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
map<int,int> m;
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    m[a]++;
    m[b]++;
    m[c]++;
    if(m.size()==2)cout<<"Yes";
    else cout<<"No";
}
int32_t main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll H, W;
vector<string> S;

bool check() {
  vector<bool> ok(W, false);
  ll cnt = 0;
  REP(i, 0, W) if(!ok[i]) {
    REP(j, i + 1, W) if(!ok[j]) {
      bool f = true;
      REP(k, 0, H) f = f && S[k][i] == S[H - 1 - k][j];
      if(f) {
        ok[i] = ok[j] = true;
        cnt += 2;
        break;
      }
    }
  }

  if(W % 2 == 1) {
    bool x = true;
    REP(i, 0, W) if(!ok[i]) {
      REP(j, 0, H) x = x && S[j][i] == S[H - 1 - j][i];
    }
    return cnt == W - 1 && x;
  }
  return cnt == W;
}

bool dfs(ll l, ll r) {
  if(r - l <= 1) return check();

  bool ret = false;
  REP(i, l + 1, r) {
    swap(S[i], S[r - 1]);
    ret = dfs(l + 1, r - 1) || ret;
    swap(S[i], S[r - 1]);
  }
  return ret;
}

int main(void) {
  cin >> H >> W;
  S.resize(H);
  REP(i, 0, H) cin >> S[i];

  random_device seed_gen;
  mt19937 engine(seed_gen());

  bool ans = false;
  REP(i, 0, 100) {
    shuffle(S.begin(), S.end(), engine);
    ans = ans || dfs(0, H);
  }
  cout << (ans ? "YES" : "NO") << endl;;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

typedef long long i64;

int main()
{
	const int MAX = 1e5;
	vector<vector<int>> g(2 * MAX);
	int n;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x -= 1;
		y -= 1;
		g[x].push_back(MAX + y);
		g[MAX + y].push_back(x);
	}

	i64 ans = 0;
	vector<bool> visited(2 * MAX);

	for(int s = 0; s < 2 * MAX; s++) {

		if(visited[s]) {
			continue;
		}

		queue<int> q;
		int edges = 0;
		int x_vertices = 0, y_vertices = 0;

		q.push(s);

		while(!q.empty()) {

			int v = q.front();
			q.pop();

			if(visited[v]) {
				continue;
			}
			visited[v] = true;
			if(v < MAX) {
				x_vertices += 1;
			} else {
				y_vertices += 1;
			}

			for(auto& w : g[v]) {
				if(!visited[w]) {
					edges += 1;
				}
				q.push(w);
			}
		}

		ans += x_vertices * (i64)y_vertices - edges;
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 8064
N=int(input())
a=[int(x) for x in input().split()]
c=0
e_odd=False
while not e_odd:
	for i in range(N):
		if (a[i]%2==0):
			a[i]=a[i]//2
		else:
			e_odd=True
			break
	else:
		c+=1
print(c)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int max=100001;
  vector<int> a(max,1);
  a[0]=0;
  a[1]=0;
  for(int i=2;i<max;i++){
    for(int j=i*2;j<max;j+=i) a[j]=0;
  }
  
  vector<int> b(max,0);
  for(int i=0;i<max;i++){
    if(a[i]==1&&a[(i+1)/2]==1) b[i]=1;
  }
  
  vector<int> s(max+1,0);
  for(int i=0;i<max;i++) s[i+1]=b[i]+s[i];
  
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    r++;
    
    cout<<s[r]-s[l]<<endl;
  }
   return 0;
}


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


int main(){
ll A,B,K;
  cin >> A >> B >> K;
  
  if(A>K)
    cout << A-K << ' '<<B << endl;
  else if(A+B>=K)
    cout << '0' << ' '<<A+B-K << endl;
  else
    cout << '0' <<' ' << '0' << endl;
    

}



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

int n,k,a;
vector<int> V;
int dp[100005];

int main() {
    cin >> n >> k;
    for (int i=0;i<n;i++) {
        cin >> a;
        V.push_back(a);
    }
    for (int i=1;i<=k;i++) {
        for (auto x : V) {
            if (x>i) {continue;}
            if (dp[i-x]==0) {dp[i]=1; break;}
        }
    }
    if (dp[k]==1) {cout << "First";}
    else {cout << "Second";}
}


Measured memory_bytes: 3996
@even="#."*151
  ar=$stdin.read.split("\n")
  (ar.size-1).times do |n|
    h,w=ar[n].split.map(&:to_i)
    h.times do |i|
      print i.even? ? @even[0..w-1] : @even[1..w]
      print "\n"
    end
    print "\n"
  end


Measured memory_bytes: 6896
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    cout << (100 * (n-m) + (1900 * m)) * (int)pow(2, m) << endl;
    return 0;
}


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

struct day {
	int h[3];
//	int max_i, mid_i;

	day() = default;

	friend decltype(auto)
		operator>>(std::istream&is, day&d) {
		for( auto&e : d.h)
			is >> e;
		return is;
	}
	
};

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

	std::vector<day> v;
	v.resize(n);

	std::vector<std::vector<int>> tab;
	tab.resize(n);
	for (auto&e : tab)
		e.resize(3);

	for (auto&e : v)
		std::cin >> e;

	for (int i{}; i < 3; ++i)
		tab[0][i] = v[0].h[i];
		

	for (int i{1}; i < n;++i) {
		for (int j{};j<3;++j)
			for (int k{}; k < 3; ++k) {
				if (j == k)
					continue;

 
				auto& a = tab[i][j];
				auto b = tab[i - 1][k] + v[i].h[j];
				a = std::max(a, b);
			}
	}
	/*
	for (int i{}; i < n;++i) {
		for (int abc{}; abc < 3; ++abc)
			std::cout << " " << tab[i][abc];

		std::cout << " => " << 
			*std::max_element( std::begin(tab[i]), std::end(tab[i]) )
			<< "\n";
	}*/

	auto it = std::max_element( std::cbegin(tab[n - 1]), std::cend(tab[n - 1]));
	std::cout << *it << "\n";
	return 0;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <map>
using namespace std;
int n, a, s;
map<int,int> mp;
int main() {
	scanf("%d", &n);
	while(n--) {
		scanf("%d", &a);
		(mp[a]^=1) ? ++s : --s;
	}
	printf("%d", s);
	return 0;
}

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

const int maxn = 1e5 + 50;
int num[maxn];

int main(void) {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        num[1] += 1;
        num[l] -= 1;
        num[r + 1] += 1;
        num[n + 1] -= 1;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        num[i] += num[i - 1];
        if (num[i] == 0) ans++;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
typedef long long LL;
const int N=400010;
int a[N],pre[N],nxt[26],to[N][26],n,h,t,q[N];
char s[N];
void pri(int x){
	if (!x) return;
	pri(pre[x]);
	putchar('a'+a[x]);
}
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	rep(i,1,n) a[i]=s[i]-'a';
	rep(i,0,25) nxt[i]=n+1;
	per(i,n,0){
		memcpy(to[i],nxt,sizeof(nxt));
		nxt[a[i]]=i;
	}
	q[h=t=1]=0;
	int fnd=0;
	memset(pre,-1,sizeof(pre));
	while (h<=t){
		rep(i,0,25) if (!fnd){
			int son=to[q[h]][i];
			if (son[pre]!=-1) continue;
			q[++t]=son;
			fnd=son==n+1;
			son[a]=i;
			son[pre]=q[h];
		}
		++h;
	}
	pri(n+1);
	return 0;
}


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

using namespace std;

int main(void){
  char s[100], t[100];
  char tmp;
  int l;  //length of string
  int i;

  scanf("%s", s);
  scanf("%s", t);

  string ss(s);
  string tt(t);
  l = ss.size();
  for(i=0; i<l; i++){
    if(ss == tt){
      printf("Yes\n");
      l = -1;
      break;
    }
    tmp = ss.back();
    ss.pop_back();
    ss = tmp + ss;
  }
  if(l != -1) printf("No\n");
}


Measured memory_bytes: 256
#include <stdio.h>

int  main(void)
{
	int n;
	long l[100];
	
	scanf("%d",&n);
	
	for(int i=0;i<=n;i++){
		if(i==0){
			l[i]=2;
		}else if(i==1){
			l[i]=1;
		}else{
			l[i]=l[i-2]+l[i-1];
		}
	}
	
	printf("%ld\n",l[n]);
	
	return 0;
}

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

int main()
{
  char a,b;
  cin >> a >> b;
  if(a == 'H') cout << b << endl;
  else{
    if(b == 'H') cout << 'D' << endl;
    else cout << 'H' << endl;
  }
}


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

void solve()
{
    long long a,b,x;
    cin>>a>>b>>x;
    long long B=b/x+1;
    long long A=(a-1<0)?0:(a-1)/x+1;
    cout<<B-A<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3588
import sys
import numpy as np
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@numba.njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = np.argmax(S[d])
    return T

def output(T):
    T += 1
    print(*T, sep='\n')

D,C,S = get_input()

T = first_strategy(D,C,S)
output(T)


Measured memory_bytes: 107232
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int m = in.nextInt();
            int a[] = new int[m];
            int b[] = new int[m];
            int c[] = new int[m];
            int x[][] = new int[n][n];
            init(x, 0xffffff);
            for (int i = 0; i < n; ++i) {
                x[i][i] = 0;
            }
            int s[] = new int[n];
            for (int i = 0; i < m; ++i) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt();
                x[a[i]][b[i]] = c[i];
                x[b[i]][a[i]] = c[i];
            }
            for (int k = 0; k < n; ++k) {
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        if (x[i][j] > x[i][k] + x[k][j]) x[i][j] = x[i][k] + x[k][j];
                    }
                }
            }
            int z = 0;
            for (int i = 0; i < m; ++i) {
                if (x[a[i]][b[i]] != c[i]) ++z;
            }
            System.out.println(z);
        }
    }

    void init(Object buf, int value) {
        if (buf instanceof int[]) {
            Arrays.fill((int[]) buf, value);
        } else if (buf instanceof Object[]) {
            for (Object o : (Object[]) buf) init(o, value);
        }
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

Measured memory_bytes: 14712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, k;
  cin >> n >> k;
  vl h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  ll sum = 0;
  rep(i, n-k) sum += h[i];
  cout << sum << newl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

    struct UnionFind{
    //If the vertex is a parent, this value will be the number of vertices that belongs to the set, multiplied by -1
    //Otherwise, this value will be the parent's id
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};

int main()
{
    ios_base::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
 
    //Make friends-sets
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //Find the maximum friends-set
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
        string a;

        while(getline(cin,a)){

            for(int i=0;i<26;i++){
                if(a.find("the")!=string::npos||a.find("this")!=string::npos||a.find("that")!=string::npos){
                    cout<<a<<endl;break;
                }
                else
                    for(int i=0;i<a.length();i++){
                        if(a[i]>='a'&&a[i]<='y')a[i]++;
                        else if(a[i]=='z')a[i]='a';
                    }
            }
        }
    return 0;
}

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)


void calculate(){
    int N;input(N);
    std::vector<int> d(N);
    long long sum = 0;
    inputVector(d);
    for(int i = 0;i < N;i++)
    {
        for(int j = i + 1;j < N;j++)
        {
            sum += (d[i] * d[j]);
        }
    } 
    std::cout << sum << '\n';
}

int main(int,char**){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    calculate();
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,y;
  int kame,turu;
  bool ans = false;
  cin >> x >> y;
  
  for(int i=0;i<=x;i++){
    kame = i * 4;
    turu = (x-i) * 2;
    
    if((kame+turu)==y){
      ans = true;
       break;
    } 
  }
  
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>


using namespace std;
using ll = long long;


int main()
{
    ll N, Y;
    ll x, y, z;
    x = y = z = -1;
    cin >> N >> Y;
    Y /= 1000;
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= N - i; j++) {
            if (9 * i + 4 * j + 1 * N == Y) {
                x = i; y = j;
                break;
            }
        }
    }
    if (x != -1)
        z = N - x - y;
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
using namespace std;

void gcd(int max , int *min, int *count){
int amari;
while(1)
{
*count+=1;
amari=max%*min;
if(amari==0) break;
max=*min;
*min=amari;
}}


int main(){
	int n,m,count=0;
	int a,b;
	while(cin>>n>>m)
	{
		if(n==0 && m==0) break;
		a = max(m,n);
		b = min(m,n);
		gcd( a , &b , &count);
		cout<< b<<' '<<count<<endl;
		count=0;
	}
}

Measured memory_bytes: 1160