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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL mp[100];
const LL mod=(1e9)+7;
int main()
{

    LL n;
    cin>>n;
    for(LL i=0; i<n; i++)
    {
        LL x;
        cin>>x;
        for(LL i=0;i<62;i++)
        {
            if(x&(1LL<<i))
                mp[i]++;
        }
    }
    LL ans=0;
    for(LL i=0;i<60;i++)
    {
        LL x=mp[i];
        LL y=n-x;
        LL z=1LL<<i;

        ans+=(((x*y)%mod)*(z%mod))%mod;
//        cout<<ans<<" "<<x<<" "<<y<<" "<<z<<" "<<i<<endl;
        ans=ans%mod;
    }
    cout<<ans;
}


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

template <typename T>
class BinaryIndexedTree
{
    vector<T> arr;
    T initial_value;
    long long size;
    function<T(T, T)> operation;

public:
    BinaryIndexedTree(const long long N, function<T(T, T)> func, T init)
    {
        set_size(N);
        set_initial_value(init);
        initialize_array();
        set_operation(func);
    }

    void set_size(const long long N)
    {
        this->size = N + 1;
    }

    void set_initial_value(const T init)
    {
        this->initial_value = init;
    }

    void initialize_array()
    {
        this->arr = vector<T>(size, initial_value);
    }

    void initialize_array(const T init)
    {
        set_initial_value(init);
        initialize_array();
    }

    void set_operation(const function<T(T, T)> func)
    {
        this->operation = func;
    }

    void update(long long idx, T value)
    {
        while (idx <= this->size)
        {
            this->arr[idx] = this->operation(this->arr[idx], value);
            idx += (idx & -idx);
        }
    }

    T query(long long idx)
    {
        T ret = this->initial_value;
        while (idx > 0)
        {
            ret = this->operation(ret, this->arr[idx]);
            idx -= (idx & -idx);
        }
        return ret;
    }
};

int main()
{
    int N;
    string S;
    cin >> N >> S;
    S = " " + S;

    BinaryIndexedTree<int> bit(26 * N, [](int a, int b) { return a + b; }, 0);
    for (int i = 1; i <= N; i++)
    {
        bit.update(N * (S[i] - 'a') + i, 1);
    }

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i;
            char c;
            cin >> i >> c;

            bit.update(N * (S[i] - 'a') + i, -1);
            bit.update(N * (c - 'a') + i, 1);
            S[i] = c;
        }
        if (t == 2)
        {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for (int i = 0; i < 26; i++)
            {
                if (bit.query(i * N + r) - bit.query(i * N + l - 1) > 0)
                {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}


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

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

  ll N; cin >> N;
  if(N % 2 == 1) {
    cout << 0 << endl;
  } else {
    ll ans = 0;
    N /= 2;
    while(N > 0) {
      ans += N / 5;
      N /= 5;
    }
    cout << ans << endl;
  }
}


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

int main()
{
	int n, l; cin >> n >> l;
	
	vector<int> c(n + 1);

	int absMinIndex;
	int tmp = 10000;

	for (int i = 1; i <= n ; i++) {		
		c[i] = l + i - 1;
		if (abs(c[i]) <= tmp) {
			tmp = abs(c[i]);
			absMinIndex = i;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
	
		if (i != absMinIndex) ans += c[i];

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		int d = Integer.parseInt(nums[0]);
		int n = Integer.parseInt(nums[1]);

		System.out.println((int) Math.pow(100, d) * (n == 100 ? n + 1 : n));

	}

}


Measured memory_bytes: 23252
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(A >= B){
            System.out.println("delicious");
        }else if((B-A) <= X){
            System.out.println("safe");
        }else if((B-A) > X){
            System.out.println("dangerous");
        }
    }   
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int H, W;
char field[110][110];

int main(){
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> field[i][j];
    }
  }
  vector<vector<int> > dp(110, vector<int> (110, 0));
  for(int i = 1; i < H; i++){
    dp[i][0] = dp[i - 1][0] + (field[i][0] != field[i - 1][0]);
  }
  for(int j = 1; j < W; j++){
    dp[0][j] = dp[0][j - 1] + (field[0][j] != field[0][j - 1]);
  }
  for(int i = 1; i < H; i++){
    for(int j = 1; j < W; j++){
      int x, y;
      x = dp[i][j - 1] + (field[i][j - 1] != field[i][j]);
      y = dp[i - 1][j] + (field[i - 1][j] != field[i][j]);
      dp[i][j] = min(x, y);
    }
  }
  int ans = dp[H - 1][W - 1];
  if(field[0][0] == '.' && field[H - 1][W - 1] == '.') ans /= 2;
  if(field[0][0] == '#' && field[H - 1][W - 1] == '#') ans = ans/2 + 1;
  if(field[0][0] != field[H - 1][W - 1]) ans = (ans + 1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    count = 0
    for _ in range(n):
        x,y=map(int,input().split())
        if x == y:
            count += 1
            if count == 3:
                print("Yes")
                return
        else:
            count = 0

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

Measured memory_bytes: 9180
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] h = new int[n];
        for (int i = 0; i< n; i++) {
            h[i] = scan.nextInt();
        }
        int ans = 0;
        int len = 0;
        for (int i = 0; i< n-1; i++) {
            if (h[i] >= h[i+1]) {
                len++;
            } else {
                ans = Math.max(ans, len);
                len = 0;
            }
        }
        ans = Math.max(ans, len);

        System.out.println(ans);
    }

}

Measured memory_bytes: 50296
n,k = map(int,input().split())
su = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        su[a[j]-1] = 1
count = 0
for i in range(n):
    if su[i]==0:
        count+=1
print(count)

Measured memory_bytes: 9148
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
map<int,string> mp;
int main(){
    int n; cin>>n;
    mp[2] = mp[4] = mp[5] = mp[7] = mp[9] = "hon";
    mp[0] = mp[1] = mp[6] = mp[8] = "pon";
    mp[3] = "bon";
    cout<<mp[n%10]<<endl;
    return 0;
}



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

int main(){
	int n,x=0,k=0;
  	cin >> n;
  	string s;
  	cin >> s;
  	for(int i=0;i<n;i++){
    	if (s[i]=='I')x++;
      	else if (s[i]=='D')x--;
      	if (x>=k) k=x;
    }
  	cout << k << endl;
}

Measured memory_bytes: 256
// Last Change: 01/10/2020 21:23:26.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> P(N), Q(N), S(N);

  for (auto &&e : P) {
    cin >> e;
  }
  for (auto &&e : Q) {
    cin >> e;
  }
  for (int i = 0; i < N; ++i) {
    S[i] = i + 1;
  }

  ll p, q, cnt = 0;
  do {
    int i;
    for (i = 0; i < N; ++i) {
      if (S[i] != P[i]) {
        break;
      }
    }
    if (i == N) {
      p = cnt;
    }
    for (i = 0; i < N; ++i) {
      if (S[i] != Q[i]) {
        break;
      }
    }
    if (i == N) {
      q = cnt;
    }
    ++cnt;
  } while (next_permutation(S.begin(), S.end()));

  cout << abs(p - q) << endl;
}


Measured memory_bytes: 888
from numpy import array
student=[]
point=[]
N,M=map(int,input().split())
for z in range(N):
    a,b=map(int,input().split())
    A=array([a,b])
    student.append(A)
for y in range(M):
    c,d=map(int,input().split())
    C=array([c,d])
    point.append(C)
for e in student:
    list=[]
    for f in point:
        g=e-f
        i=0
        for h in g:
            i+=abs(h)
        list.append(i)
    j=min(list)
    count=0
    for k in list:
        if  k==j:
            print(count+1)
            break
        else:
            count+=1
            

Measured memory_bytes: 20880
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll dp[41][(1<<18)];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

int main(){
  int N,X,Y,Z;
  cin>>N>>X>>Y>>Z;

  int mask=(1<<(X+Y+Z+1))-1;
  int ng=0;
  ng|=(1<<(Z-1));
  ng|=(1<<(Z+Y-1));
  ng|=(1<<(Z+Y+X-1));

  dp[0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=mask;j++){
          for(int k=1;k<=10;k++){
              int ns=(j<<1)&mask;
              ns++;
              ns=(ns<<(k-1))&mask;
              if((ns&ng)==ng) continue;

              add(dp[i+1][ns],dp[i][j]);
          }
      }
  }

  ll ans=1;
  for(int i=1;i<=N;i++) ans=ans*10%MOD;

  for(int j=0;j<=mask;j++){
      ans=(ans-dp[N][j])%MOD;
      add(ans,MOD);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 82176
s = str(input())
l = list(s)
a = 1
result = 0
first_s = l[0]
tmp_s = first_s
count = 0
conseq = []
for item in l:
    if item == tmp_s:
        count += 1
    else:
        conseq.append(count)
        count = 1
        tmp_s = item
conseq.append(count)

def my_sum(n, m):
    if n == m:
        return n
    else:
        tmp = 0
        for i in range(n, m+1):
            tmp += i
        return tmp

if first_s == '>':
    result = conseq[0]
tmp_s = first_s
for i in range(len(conseq)):
    if i+1 == len(conseq):
        if tmp_s =='<':
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i]-1)
        break
    if tmp_s == '<':
        if conseq[i] >= conseq[i+1]:
            result += my_sum(0, conseq[i])
        else:
            result += my_sum(0, conseq[i])
            result += conseq[i+1]-conseq[i]
        tmp_s = '>'
    else:
        result += my_sum(0,conseq[i]-1)
        tmp_s = '<'
print(result)


Measured memory_bytes: 10268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp1
{
    public class node {
        public int parent = -1;
        public int depth = 0;
        public string nodeType;
        public List<int> children = new List<int>();
    }
    class Program
    {
        static void SetDepth(node[] A, int id)
        {
            for (int i = 0; i < A[id].children.Count; i++)
            {
                A[A[id].children[i]].depth = A[id].depth + 1;
                SetDepth(A, A[id].children[i]);
            }
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            node[] A = new node[n];
            for (int i = 0; i < n; i++) A[i] = new node();
            for (int i = 0; i < n; i++)
            {
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var id = a[0];
                var k = a[1];
                for (int j = 0; j < k; j++)
                {
                    var u = a[j + 2];
                    A[u].parent = id;
                    A[id].children.Add(u);
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (A[i].parent == -1)
                {
                    A[i].nodeType = "root";
                    SetDepth(A, i);
                }
                else if (A[i].children.Count != 0)
                {
                    A[i].nodeType = "internal node";
                }
                else
                {
                    A[i].nodeType = "leaf";
                }
            }
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < n; i++)
            {
                sb.Append(string.Format("node {0}: parent = {1}, depth = {2}, {3}, [", i, A[i].parent, A[i].depth, A[i].nodeType));
                for (int j = 0; j < A[i].children.Count; j++)
                {
                    if (j != A[i].children.Count - 1)
                    {
                        sb.Append(A[i].children[j] + ", ");
                    }
                    else
                    {
                        sb.Append(A[i].children[j]);
                    }
                }
                sb.AppendLine("]");
            }
            Console.Write(sb);
        }
    }
}



Measured memory_bytes: 55716
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	int n, t;
	long long int sum = 0;
	cin >> n >> t;
	v.resize(n);
	REP(i, n) cin >> v[i];
	REP(i, n - 1)
	{
		if (v[i + 1] - v[i] < t) sum += v[i + 1] - v[i];
		else sum += t;
	}
	sum += t;
	cout << sum << endl;
}

Measured memory_bytes: 1792
import collections
h,w = map(int,input().split())
s=[list(input()) for _ in range(h)]
deq = collections.deque([[0,0,0]])

while deq:
    i,j,k = deq.popleft()
    if not((i in range(h)) and (j in range(w))):
        continue
    if s[i][j] != '.':
        continue
    s[i][j]=k
    if i==h-1 and j == w-1:
        break
    deq.append([i + 1, j, k + 1])
    deq.append([i - 1, j, k + 1])
    deq.append([i, j + 1, k + 1])
    deq.append([i, j - 1, k + 1])
if s[h-1][w-1] == '#'or s[h-1][w-1] =='.':
    print(-1)
else:
    black = sum([y.count('#') for y in s])
    print(h*w-black-s[h-1][w-1]-1)

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

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

  one_num = n%500;
  if (one_num==0) cout << "Yes" << endl;
  else if (one_num <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)

using namespace std;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, t, ans = 0, x;
	cin >> num >> t;
	vector<vector<int>> dp(num + 1, vector<int>(t, 0));
	vector<pp> a(num);
	rep(i, num)
		cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	rep(i, num) {
		rep(j, t) {
			x = j + a[i].first;
			if (x < t)
				dp[i + 1][x] = dp[i][j] + a[i].second;
			chmax(dp[i + 1][j], dp[i][j]);
		}
		chmax(ans, dp[i][t - 1] + a[i].second);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 35584
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 13:45:00 2019

@author: adachi-lab
"""

input_code = input()

list_1 = []

if input_code == 'A' or input_code == 'T':
    list_1 = ['A','T']
    list_1.remove(str(input_code))
    print(list_1[0])
    
else:
    list_1 = ['C','G']
    list_1.remove(str(input_code))
    print(list_1[0])
    
    


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
 
int main(){
	string s;
	cin>>s;
	int l=(int)s.length();
	int a=0,b=0,c=0,d=0;
	rep(i,l){
		if(s[i]=='N')a++;
		if(s[i]=='S')b++;
		if(s[i]=='E')c++;
		if(s[i]=='W')d++;
	}
	bool ab=false,cd=false;
	if((a==0&&b==0)||(a>0&&b>0))ab=true;
	if((c==0&&d==0)||(c>0&&d>0))cd=true;
	if(ab&&cd)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
h = np.array([0] + list(map(int, input().split()))) # index調整
dp = np.zeros(n+1,dtype=np.int)

for i in range(2,n+1):
    start = 1 if i - k < 1 else i - k
    dp[i] = min((dp[start:i]+np.abs(h[i]-h[start:i])))            
print(dp[n])

Measured memory_bytes: 23024
N=io.read"*n"
A={}
for i=1,N do A[i]=io.read"*n"end
B={}
for i=1,N do B[i]=io.read"*n"end
as=0
bs=0
D={}
for i=1,N do
as=as+A[i]
bs=bs+B[i]
D[i]=A[i]-B[i]
end
if(as<bs)then print(-1)return end

table.sort(D)

dms=0
for i=1,N do if(D[i]>=0)then break end dms=dms+D[i] end

i=1
while(D[i]<0)do
	i=i+1
end

j=N
while(dms<0 and j>0)do
	dms=dms+D[j]
	j=j-1
end

print(i+N-j-1)

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

using namespace std;

string s;
int n;
	
int main()
{
	cin >> s;
	n = s.size();
	
	for (int i = 0; i < n - 1; i ++)
	{
		if (s[i] == 'S' && s[i + 1] == 'T')
		{
			s.erase(s.begin() + i);
			s.erase(s.begin() + i);
			i -= 2;
			n -= 2;
		}
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >>n;
  bool ans=false;

  for(int i=0; i<n;i++){
    char s;
    cin>>s;
    if(s=='Y') ans=true;
  }
  if(ans) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  }


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

using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;

	vector<vector<int> > mp(26);

	for(int i=0;i<s.size();i++)
	{
		int id=s[i]-'a';
		mp[id].push_back(i);
	}

	int now=-1;
	int loop=0;

	for(int i=0;i<t.size();i++)
	{
		int id=t[i]-'a';
		if(mp[id].size()==0)
		{
			cout << -1 << endl;
			return 0;
		}

		if(mp[id][mp[id].size()-1]<=now)
		{
			now=mp[id][0];
			loop++;
		}
		else
		{
			auto itr=lower_bound(mp[id].begin(),mp[id].end(),now+1);
			now=*itr;
		}
	}


	cout << loop*s.size()+now+1 << endl;





}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class SegTree:
    """
    セグメント木
    1.update:  i番目の値をxに更新する
    2.query: 区間[l, r)の値を得る
    """

    def __init__(self, n, func, intv, A=[]):
        """
        :param n: 要素数(0-indexed)
        :param func: 値の操作に使う関数(min, max, add, gcdなど)
        :param intv: 要素の初期値(単位元)
        :param A: 初期化に使うリスト(オプション)
        """
        self.n = n
        self.func = func
        self.intv = intv
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [self.intv] * (n2 << 1)
        # 初期化の値が決まっている場合
        if A:
            # 1段目(最下段)の初期化
            for i in range(n):
                self.tree[n2+i] = A[i]
            # 2段目以降の初期化
            for i in range(n2-1, -1, -1):
                self.tree[i] = self.func(self.tree[i*2], self.tree[i*2+1])

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 0:
            i >>= 1
            self.tree[i] = self.func(self.tree[i*2], self.tree[i*2+1])

    def query(self, a, b):
        """
        [a, b)の値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        l = a + self.n2
        r = b + self.n2
        s = self.intv
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.tree[r])
            if l & 1:
                s = self.func(s, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1
        return s

    def get(self, i):
        """ 一点取得 """
        return self.tree[i+self.n2]

    def all(self):
        """ 全区間[0, n)の取得 """
        return self.tree[1]

N, M = MAP()
S = input()

dp = SegTree(N+1, min, INF)
dp.update(N, 0)
for i in range(N-1, -1, -1):
    # ゲームオーバーマスには遷移できない
    if S[i] == '1':
        continue
    mn = dp.query(i+1, min(N+1, i+M+1))
    if mn != INF:
        dp.update(i, mn+1)

# 辿り着けない
if dp.get(0) == INF:
    print(-1)
    exit()

cnt = dp.get(0)
cur = 0
prev = -1
ans = []
for i in range(1, N+1):
    if dp.get(i) == INF:
        continue
    # 手数が変わる場所でなるべく手前に飛ぶ
    if dp.get(i) != cnt:
        prev = cur
        cur = i
        ans.append(cur-prev)
        cnt = dp.get(i)
print(*ans)


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


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

int main() {
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[2] - A[1] + A[1] - A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = 1
t = 99
arr = Array.new((10 ** 4)*6,0)
(s..t).each do |x|
    (s..t).each do |y|
        (s..t).each do |z|
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z
            if ans <= 10 ** 4
            arr[ans+1] += 1
            end
        end
    end
end
#p arr[1..20]
arr.shift
#p arr[1..20]
i = 1
#p n
while true
    if i <= n
    puts arr[i]
    elsif i > n
        break
    end
    i += 1
end

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

int main()
{
    int n, k;
    cin >> n >> k;
    unordered_map<int, int> st;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        st[a]++;
    }
    vector<int> v;
    for (auto kv : st) {
        v.push_back(kv.second);
    }
    sort(v.begin(), v.end(), greater<int>());
    for (int i = 0; i < k && i < v.size(); i++) {
        n -= v[i];
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 10312
def solve(N, A):
    money = 1000
    stock = 0
    for i in range(1, N+1):
        if i < N:
            if A[i+1] > A[i]:
                stock += money // A[i]
                money = money % A[i]
            elif A[i+1] < A[i]:
                money += stock * A[i]
                stock = 0
        else:
            money += stock * A[i]
    return money
N = int(input())
A = [0] + list(map(int, input().split()))
print(solve(N, A))

Measured memory_bytes: 9204
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int H,W,N;
    cin >> H >> W >> N;
    map<pair<int,int>,int> mp;
    REP(i,0,N){
        int a,b;
        cin >> a >> b;
        for(int da = -1; da <= 1; ++da){
            for(int db = -1; db <= 1; ++db){
                mp[make_pair(a+da,b+db)]++;
            }
        }
    }
    vector<ll> ans(10,0L);
    for(auto it = mp.begin(); it != mp.end(); it++){
        if( it->first.first >= 2 && it->first.first <= H - 1 && it->first.second >= 2 && it->first.second <= W - 1 ){
            ans[it->second]++;
        }
    }
    ans[0] = 1LL*(H-2)*(W-2);
    REP(j,1,10){
        ans[0] -= ans[j];
    }
    REP(j,0,10){
        cout << ans[j] << endl;
    }
    return 0;
}


Measured memory_bytes: 56448
#include <stdio.h>

int main(){
    int i, j, k, loop, arr[4][3][10];
    int bill, floor, room, value;

    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                arr[i][j][k] = 0;
            }
        }
    }

    scanf("%d", &loop);
    for(i = 0; i < loop; i++){
        getchar();
        scanf("%d %d %d %d", &bill, &floor, &room, &value);

        arr[bill - 1][floor - 1][room - 1] += value;
    }

    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                printf(" %d", arr[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3)printf("####################\n");
    }
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n;
char ans[5];
int main(){
	scanf("%d", &n); n%=10;
	switch (n){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		puts("hon");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		puts("pon");
		break;
	default:
		puts("bon");
		break;
	}
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll n,a,b;
	cin>>n>>a>>b;
	if(a==0){cout<<0;}
	else{
		ll ans=(n/(a+b))*a;
		ll m=n%(a+b);
		if(m<=a && m!=0){ans+=m;}
		else if(m!=0){ans+=a;}
		cout<<ans;
	}
}


Measured memory_bytes: 256
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

ans s =
  let [m,n] = map read $ splitBy ':' s :: [Double]
      ang_s = 360 / 12 * m + 360 / 12 / 60 * n
      ang_l = 6 * n
      diff = abs (ang_s - ang_l)
      d'   = if diff < 180 then diff else (360-diff)
  in
    if d' < 30
    then "alert"
    else if d' < 90
         then "warning"
         else "safe"

main = do
  n <- getLine
  c <- getContents
  let n' = read n :: Int
      i  = lines c
      o  = map ans i
  mapM_ putStrLn o



Measured memory_bytes: 4316
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

from collections import deque

N,X,Y=MI()
l = []
for i in range(N):
    if i!=0 and i!=N-1:
        n = [i-1,i+1]
    elif i==0:
        n = [1]
    else:
        n = [N-2]
    if i==X-1:
        n += [Y-1]
    if i==Y-1:
        n += [X-1]
    l.append(n)
ans = [0]*(N-1)
for i in range(N):
    dist = [-1]*N
    q=deque()
    q.append(i)
    dist[i]=0
    while q:
        u = q.popleft()
        for next in l[u]:
            if dist[next]==-1:
                dist[next]=dist[u]+1
                ans[dist[u]] += 1
                q.append(next)

[print(x//2) for x in ans]


Measured memory_bytes: 67288
while True:
    s = str(input())
    if s == '-':
        break
    n = int(input())
    h = [input() for i in range(n)]
    for num in h:
        num = int(num)
        x = s[0:num]
        y = s[num:]
        z = y + x
        s = z
    print(s)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    //変数length, sideを宣言
    int length, side, area, circum;
    
    //変数length, sideに値を入力する
    length = sc.nextInt();    
    side = sc.nextInt();
    
    //area(面積)とcircum(周の長さ)を計算する
    area = length * side;
    circum = ( length + side ) * 2;
    
    ////area(面積)とcircum(周の長さ)を出力する
    System.out.println(area + " " + circum);
    
    }
}


/*覚えよう！！

・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける

・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;

・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
  
  
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！


*/


/*前回の内容！！

・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要

・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku

・println・・・画面に出力するときに使用

・文字列の表示・・・"〇〇〇の間に入力"ことが約束

*/


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int x;
    cin >> x;
    cout << (x ^ 1);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
lol x,y;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol d=0,e=0,f=0;
  lol ans=0;
  string s;
  cin >>x>>y;
  cin >>a>>b>>c>>d;
  e=(a-c)*x,f=(b-d)*y;
  if(e==-f){
    cout <<"infinity\n";
    return 0;
  }
  if(e<0) e=-e,f=-f;
  if(e+f>0){
    cout <<0<<'\n';
    return 0;
  }
  c=-e/(e+f);
  if(-e%(e+f)==0)
    cout <<c*2<<'\n';
  else cout <<c*2+1<<'\n';
  return 0;
}


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

using namespace std;

// 整数の入力
long long N,i,k,minValue,total,a,b;


long long minPath(long long now,long long before,set<long long>* path ,long long value ){
    int i,j;
    if (now == N){
        return value;
    }else{
        int minValue = N + 1;
        int removePath = -1;
        for (auto it = path[now].begin(); it != path[now].end(); ++it) {
            if (*it != before){
                int temp = minPath(*it,now,path,value + 1);
                if (temp < minValue) {
                    minValue = temp;
                    if (minValue/2 == value){
                        removePath = *it;
                    }
                }
            }
        }
        if (removePath != -1){
            path[now].erase(removePath);
            path[removePath].erase(now);
        }
        return minValue;
    }
}

long long FennecTileCount(long long now,long long before,set<long long>* path){
    int j;
    long long count = 1;
    for (auto it = path[now].begin(); it != path[now].end(); ++it) {
        if (*it != before){
            count += FennecTileCount(*it,now,path);
        }
    }
    return count;
}

int main()
{
    string s;
    cin >> N;
    set<long long>* path = new set<long long>[N+1];
    for (i=0;i< N - 1;i++){
        cin >> a >> b;
        path[a].insert(b);
        path[b].insert(a);
    }
    minPath(1,-1,path,0);
    if (FennecTileCount(1,-1,path) > N/2){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}

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

int main() {
  	int n, a, b, c, d;
  	cin >> n;
  	a = n / 1000; // 7777 / 1000 = 7 
  	b = n % 1000 / 100;
  	c = n % 1000 % 100 / 10;
    d = n % 1000 % 100 % 10;
    /* 1118  1125
       8111
       1111
       それ以外　*/
  	if (a == b) {
      if (b == c) {
      cout << "Yes" << endl;
      }
      else {
      cout << "No" << endl;
      }
    }
 	 else if (b == c) {
       if (c == d) {
       cout << "Yes" << endl;
       }
       else {
       cout << "No" << endl;
       }
	}
  	else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { double a, b;
  cin >> a >> b;
  cout << (int)ceil(a / 2 + b / 2) << endl;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll 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(ll 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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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(0);

    int a,b,c,k; cin >> a >> b >> c >> k;

    ll ans = 0;
    ans += min(a,k);
    k -= a;
    k -= b;
    if (k > 0) ans -= min(c,k);

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


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,a[100001];
	scan(N);
	rep(i,N){
		scan(a[i]);
		a[i]--;
	}
	int ans=0;
	rep(i,N){
		if(a[a[i]]==i) ans++;
	}
	prin(ans/2);
	return 0;
}


Measured memory_bytes: 640
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())%10
if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9464
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  int bi, bii;
  int sum = 0;
  cin >> bi;
  sum += bi;
  for (int i = 0; i < n-1; i++){
      if(i==n-2){
          sum +=bi;
          break;
      }
      cin >> bii;
      sum += min(bi,bii);
      bi = bii;
  }
  cout << sum << endl;
}

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

const int inf = 1e8;
int main(){
  int n,d;
  cin >> n >> d;

  vector<vec> p(n,vec(d));

  vec min_p(d,inf);
  rep(i,n){
    rep(j,d){
      cin >> p[i][j];
      min_p[j] = min(min_p[j], p[i][j]);
    }
  }

  int cost = 0;
  rep(i,d){
    cost += min_p[i];
  }

  vector< vector< pair<int,vec> > > dp(d+1, vector< pair<int,vec> >(n, make_pair(inf, vec(d,n)) ));
  rep(i,n)dp[0][i] = make_pair(0,vec(0));

  rep(i,d){
    rep(j,n){
      rep(k,n){
	if(p[k][i] != min_p[i])continue;

	pair<int,vec> nxt = dp[i][k];
	nxt.second.push_back(k);
	if(j!=k)nxt.first++;

	dp[i+1][j] = min(dp[i+1][j], nxt);
      }
    }
  }

  pair<int,vec> ans = make_pair(inf, vec(d,n));
  rep(i,n){
    ans = min(ans, dp[d][i]);
  }

  cout << cost << " " << ans.first << endl;
  rep(i,ans.second.size()){
    cout << ans.second[i]+1 << endl;
  }
}

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

using namespace std;

const int MAX_B = 101;

typedef struct{
  int price;
  int cal;
}Top;

int numtop,price;
Top base;
int item[MAX_B];

int solve(){
  Top now = base;
  int i = 0;
  sort(item,item+MAX_B);
  reverse(item,item+MAX_B);
  
  while(1){
    if(now.cal/now.price <= (now.cal+item[i])/(now.price+price)){
      now.cal += item[i];
      now.price += price;
    }
    i++;
    if(i == numtop) break;
  }
  return now.cal/now.price;
}

int main(){
  cin >> numtop;
  cin >> base.price >> price;
  cin >> base.cal;
  for(int i = 0; i < numtop; i++){
    cin >> item[i];
  }
 
  cout << solve() << endl;
  return 0;
}

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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll d,t,s;
    cin>>d>>t>>s;
    cout<<(s*t>=d?"Yes":"No");
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3608
from fractions import gcd
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
test = a[0]
count = 0
while test%2 ==0:
    test = test//2
    count += 1
for i in range(N):
    if (a[i]//2**count)%2 == 0:
        print(0)
        exit()
print((M+lcm//2)//lcm)

Measured memory_bytes: 89580
#include <iostream>
#include <cstdio>
#include <queue>
#include <stdlib.h>
#include <stack>
#include <string.h>
#include <set>
#include <iomanip>
#include <ctime>
#include <map>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <cstring>
#define eps 1e-15
#define ull unsigned long long
//priority_queue<int,vector<int>,greater<int> > q;
//priority_queue<int,vector<int>,less<int> > q;
//#define ls l, mid, rt << 1
//#define rs mid + 1, r, rt << 1 | 1
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const long long mod1 = 1e16;
//int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
//int Find(int x){return x == p[x] ? x : p[x] = Find(p[x]);}
//#define lson 1<<rt
//#define rson 1<<rt|1
const int maxn=1e5+7;
#define pi 3.1415926535898
#define PI atan(1.0)*4
int dx[4]= {0,1,0,-1},dy[4]= {1,0,-1,0};
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int dir1[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
//int d[]= {1,-1,4,-4}; //八数码问题
//----------------------------------------

int n,ans=1;
ll a[maxn],s;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        a[i]+=a[i-1];
    for(int i=n-1;i;--i)
        if(a[i]*2>=a[i+1]-a[i])
            ++ans;
        else
            break;
    cout<<ans<<endl;
    return 0;
}


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

long long F[100];

int fiv(long long N){
  if(N==0){
    return 1;
  }
  if(N==1){
    return 1;
  }
  if(F[N]!=0){
    return F[N];
  }
  return F[N]=fiv(N-1)+fiv(N-2);
}

  
int main(){
  long long N;
  cin>>N;
  for (int i=0;i<100;i++){
    F[i]=0;
  }
  cout<<setprecision(20)<<fiv(N)<<endl;
  return 0;
 }
 



Measured memory_bytes: 3084