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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M; cin >> N >> M;
    vector<vector<ll>> edges(N);
    rep(i, M){
        ll a, b; cin >> a >> b; a--; b--;
        edges.at(a).push_back(b);
        edges.at(b).push_back(a);
    }
    queue<P> q;
    vector<ll> sign(N, INF);
    set<P> used;

    q.push(make_pair(0, 0)); // (from, dest)
    ll cnt = 0;
    while (q.size() > 0){
        P next = q.front();
        ll dest = next.second;
        ll from = next.first;
        q.pop();
        if (sign.at(dest) == INF){sign.at(dest) = from;} // might be visited twice
        for (ll i: edges.at(dest)){
            if (sign.at(i) == INF && used.find(make_pair(dest, i)) == used.end()){
                used.insert(make_pair(dest, i));
                used.insert(make_pair(i, dest));
                q.push(make_pair(dest, i));
            }
        }
        cnt++;
    }
    cout << "Yes" << endl;
    rep(i, N - 1){
        cout << sign.at(i + 1) + 1 << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 38716
s = gets.chomp!
pos=0
len=0
fpos = 0
now_len=-1
now_fpos=-1
s.chars{|c|
    #puts "adflkjasd"
    if (c=="A" || c=="T" || c=="C" || c=="G") then
        if (now_fpos==-1||now_len==-1) then
            now_fpos=pos
            now_len=1
        else
            now_len+=1
        end
    else
        if len<now_len then
            len=now_len
            fpos=now_fpos
        end
        now_fpos = -1
        now_len = -1
    end
    #puts "now_len = #{now_len},len=#{len}"
    pos+=1
}
if len<now_len then len = now_len;fpos=now_fpos; end
puts len


Measured memory_bytes: 1788
i=59,c=100,f[204],m,x,s;main(y){for(;s?++f[y*12+x+";<=0H/1GI:>T$"[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<178?i%12<10?m=fmax(m,f[i]),f[i]?c--:1:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
k = int(input())

flag = 0
temp = 7
for i in range(k):
    if(temp % k == 0):
        flag = 1
        break
    else:
        temp = temp % k
        temp = temp * 10 % k
        temp = temp + 7

if (flag == 0):
    print("-1")
else:
    print(i+1)

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, Y;

signed main(){
	cin >> N >> Y;
	
	if(Y <= (10000 * 2000) && Y % 1000 == 0) {
		REP(i, 0, (N+1)) {
			REP(j, 0, (N - i + 1)) {
			    int k = N - i - j;
				if(Y == (i * 10000 + j * 5000 + k * 1000)) {
					cout << i << " " << j << " " << k;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	
	return 0;
}


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

int main()
{
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2))cout << "Yes" << endl;
  else if(s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1))cout << "Yes" << endl;
  else if(s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1))cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int N;
vector<int> A;
int dp[2][100001];

int dfs(int pre, int n) {
  // cout << pre << " " << n << endl;
  if ( n == N ) return 0;
  if ( dp[pre][n] >= 0 ) return dp[pre][n];

  int ret;
  if ( n == N-1 ) {
    ret = A[n];
    if ( pre ) ret *= -1;
  } else if ( pre ) {
    ret = max(-A[n] + dfs(0, n+1), A[n] + dfs(1, n+1));
  } else {
    ret = max(A[n] + dfs(0, n+1), -A[n] + dfs(1, n+1));
  }

  return dp[pre][n] = ret;
}
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  fill_n(*dp, 2*100001, -1);

  cin >> N;
  A.resize(N);
  REP(i, N) {
    cin >> A[i];
  }

  cout << dfs(0, 0) << endl;

  return 0;
}


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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  if(a == 0) {
    cout << b / x + 1 << endl;
    return 0;
  }
  ll ans = b / x - (a - 1) / x;
  cout << ans << endl;
}

Measured memory_bytes: 256
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int res = 0;
    int count = 0;
    rep(i, s.length()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            count++;
        }
        else {
            count = 0;
        }
        chmax(res, count);
    }

    cout << res << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    int r,c;
    cin>>r>>c;
    int spsheet[r][c];
    
    for(int i=0;i!=r;++i){
        for(int j=0;j!=c;++j){
            cin>>spsheet[i][j];
        }
    }
    
    for(int i=0;i!=r;++i){
        int sum=0;
        for(int j=0;j!=c;++j){
            cout<<spsheet[i][j]<<" ";
            sum+=spsheet[i][j];
        }
        cout<<sum<<endl;
    }
    int sumsum=0;
    for(int j=0;j!=c;++j){
        int sum=0;
        for(int i=0;i!=r;++i){
            sum+=spsheet[i][j];
        }
        cout<<sum<<" ";
        sumsum+=sum;
    }
    cout<<sumsum<<endl;
        
    
    
    return 0;
    
}


Measured memory_bytes: 3128
#include<iostream>

int main(){
    int a;
    int h = 0;
    int m = 0;
    std::cin >> a;
    if(a/3600!=0){
        h = a / 3600;
        a -= 3600 * h;
    }
    if(a/60!=0){
        m = a / 60;
        a -= 60 * m;
    }
    std::cout << h << ":" << m << ":" << a << '\n';
    
    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];
int main() {
	int a,b;
	cin>>a>>b;
	int r=b/(a-1);
	if(b%(a-1)>1)r++;
	if(b==1){
		r=0;
	}else if(a==2){
		r=b-1;
	}
	cout<<r<<endl;	
	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c) {
    vector<long long> v({a, b, c});
    sort(v.begin(), v.end());
    if (v[0] + v[1] == v[2]) {
	cout << YES << endl;
    } else {
	cout << NO << endl;
    }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f(int n) {
    int ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}
int main() {
    int N;
    cin >> N;
    cout << (N % f(N) ? "No" : "Yes") << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  int ans = n;
  rep(i, m) ans -= a[i];

  if (ans < 0) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

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

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, p;
	string s;
	cin >> n >> p >> s;
	if (p == 2 || p == 5) {
		int ans = 0;
		rep(i, n) {
			int d = s[i] - '0';
			if (d%p == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	vector<int> cnt(p);
	cnt[0] = 1;
	int ans = 0;
	int bs = 1;
	int now = 0;
	for (int i = n - 1; i >= 0; i--) {
		int d = s[i] - '0';
		d *= bs; d %= p;
		now += d; now %= p;
		ans += cnt[now];
		cnt[now]++;
		bs *= 10; bs %= p;
		//cout << now << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
import math
N,a, b =list(map(int,input().split(" ")))
case1 = 10 ** 20 # 卓1で戦う場合
case2 = 10 ** 20 # 卓Nで戦う場合
case3 = 10 ** 20 # 卓中間地点で戦う場合

if (b - a ) % 2 == 0:
    case3 = (b-a)//2

else:

# a を 1に置くパターン
    step = (a-1)
    # stepかかった後に、中間地点で合流
    step = step + 1 #一回足踏み
    case1 = step +   (  ((b - step)  - 1 ) //2   )


    # b を N に置くパターン
    step = (N - b)
    step = step + 1  # 一回足踏み

    case2 = step+  (   ( N - (a + step) )//2 )



print(min([case1,case2,case3]))

Measured memory_bytes: 3064
def solve():
    n = int(input())
    work_array = [[a, b] for a, b in zip([int(i) for i in input().split()], [j for j in range(0, n)])]
    ans_list = [0] * n
    work_array.sort(reverse=True)

    last_num = work_array[0][0]
    min_index = work_array[0][1]
    for counter in range(n):
        current_num = work_array[counter][0]
        if last_num != current_num:
            ans_list[min_index] += counter * (last_num - current_num)
            last_num = current_num
        min_index = min(min_index, work_array[counter][1])

    ans_list[min_index] += (counter + 1) * last_num
    print("\n".join([str(c) for c in ans_list]))

if __name__=="__main__":
    solve()


Measured memory_bytes: 83256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

struct UnionFind{
  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(){
  int N, M;
  cin >> N >> M;
  
  UnionFind UF(N);
  for(int i =0; i<M;i++){
    int A ,B;
    cin >> A >> B;
    A -= 1; B -= 1;
    UF.unite(A,B);
  }

  int ans = 0;
  for(int i=0; i<N;i++){
    ans = max(ans, UF.size(i));
  }

  cout << ans << endl;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int A, B, C;
    int X, Y;
    long long min = 5000000000;
    cin >> A >> B >> C >> X >> Y;
    int cmax;
    long long t;
    int a, b, c;
    if(X <= Y) cmax = Y;
    else cmax = X;
    for(c = 0; c <= 2*cmax; c++){
        a = X - (int)(c/2);
        b = Y - (int)(c/2);
        if(a < 0) a = 0;
        if(b < 0) b = 0;
        t = A*a + B*b + C*c;
        if(min > t) min = t;
    }

    cout << min << endl;
    return 0;
}

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

#define MAX 100000
#define INF INT_MAX

int A[MAX+1], B[MAX+1], L[MAX/2+1], R[MAX/2+1];
char C_A[MAX+1], C_B[MAX+1], C_L[MAX/2+1], C_R[MAX/2+1];
int n;

int partition(int l, int r){
  int x;
  int i, j;

  x=A[r];

  for(i=l, j=l; i<r; i++){
    if(A[i]<=x){
      swap(A[i], A[j]);
      swap(C_A[i], C_A[j]);
      j++;
    }
  }
  swap(A[j], A[r]);
  swap(C_A[j], C_A[r]);
  
  return j;
}

void quickSort(int l, int r){
  int p;

  if(l < r){
    p=partition(l, r);
    quickSort(l, p-1);
    quickSort(p+1, r);
  }
}

void merge(int n, int left, int mid, int right){
  int n1=mid-left;
  int n2=right-mid;

  for(int i=0; i<n1; i++){
    L[i]=B[left+i];
    C_L[i]=C_B[left+i];
  }
  for(int i=0; i<n2; i++){
    R[i]=B[mid+i];
    C_R[i]=C_B[mid+i];
  }
  
  L[n1]=INF;
  R[n2]=INF;

  for(int i=0, j=0, k=left; k<right; k++){
    if(L[i]<=R[j]){
      B[k]=L[i];
      C_B[k]=C_L[i];
      i++;
    }else{
      B[k]=R[j];
      C_B[k]=C_R[j];
      j++;
    }
  }
}

void merge_sort(int n, int left, int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    merge_sort(n, left, mid);
    merge_sort(n, mid, right);
    merge(n, left, mid, right);
  }
}

int main(void){
  int i;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf(" %c %d", &C_A[i], &A[i]);
    B[i]=A[i]; C_B[i]=C_A[i];
  }
  
  quickSort(0, n-1);
  merge_sort(n, 0, n);

  for(i=0; i<n; i++){
    if(C_A[i] != C_B[i]){
      printf("Not stable\n");
      break;
    }
  }
  if(i == n) printf("Stable\n");
      
  for(i=0; i<n; i++) printf("%c %d\n", C_A[i], A[i]);
  
  return 0;
}



Measured memory_bytes: 4652
f=True
s=input()
if s[0]!="A":f=False
if s.count("C")==0 or s.count("C")>=2:f=False
else:
    i=s.index("C")
    if i==1 or i==len(s)-1:f=False
    else:
        for x in range(len(s)):
            if x==i or x==0:continue
            if s[x].isupper():f=False
if f:print("AC")
else:print("WA")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  string sc;
  sc = s;
  reverse(sc.begin(),sc.end());
  if(sc == s){
    string mae;
    string ato;
    mae = s.substr(0,(s.size() - 1) / 2);
    string maec = mae;
    reverse(maec.begin(),maec.end());
    ato = s.substr((s.size() + 3) / 2 - 1,s.size() - (s.size() + 3) / 2 + 1);
    string atoc = ato;
    reverse(atoc.begin(),atoc.end());
    if(mae == maec && ato == atoc){
      ans = 1;
    }
  }
  if(ans == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)
S = gets.chomp

acc = Array.new(N, 0)


(N-1).times do |i|
  
   ( S[i] == ?A && S[i+1] == ?C ) ? acc[i+1] = acc[i] + 1 : acc[i+1] = acc[i]
  
end

# p acc


Q.times do |i|
  
  l, r = gets.split.map(&:to_i)
  l -= 1
  r -= 1
  
  puts acc[r] - acc[l]
  
end


Measured memory_bytes: 3324
#include <iostream>
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 10010;
  
int main() {
    ll n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    
    vl v1(n);
    ll i = 0;
    ll num = 1;
    while(i < n && num <= k) {
        if(s[i] == 'o') {
            v1[i] = num;
            i += c;
            num++;
        }
        i++;
    }

    vl v2(n);
    i = n-1;
    num = k;
    while(i >= 0 && num >= 1) {
        if(s[i] == 'o') {
            v2[i] = num;
            i -= c;
            num--;
        }
        i--;
    }

    rep(i, n) {
        if(v1[i] > 0 && v1[i] == v2[i]) {
            out(i+1);
        }
    }

    re0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P[i];

    ll ans = 0;
    rep(i, N) {
        ll p = P[i];
        if (p == i + 1) {
            ans++;
            if (i < N - 1) {
                ll tmp = P[i + 1];
                P[i + 1] = p;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  replicateM n (solve <$> f <*> f) >>= mapM_ putStrLn
  where
    f = map toCard <$> words <$> getLine

solve :: [[Int]] -> [[Int]] -> String
solve [dl0, dl1] pls
  | ipt == [21, 11] = "blackjack"
  | otherwise = f ipt pls
  where
    ipt = calcbj dl0 dl1
    f pt pls
      | null pt = "bust"
      | head pt > 17 || pt == [17] = show . head $ pt
      | otherwise = f (calcbj pt (head pls)) (tail pls)

toCard :: String -> [Int]
toCard x
  | x == "A" = [11, 1]
  | x `elem` ["T", "J", "Q", "K"] = [10]
  | otherwise = [read x]

calcbj :: [Int] -> [Int] -> [Int]
calcbj xs ys = nub $ do
  x <- xs
  y <- ys
  guard $ x + y < 22
  return $ x + y



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

int main(){
    double A,B,ans,thetaa,thetab,thetaab;
    int H,M;
    cin >> A >> B >> H >> M;
    thetaa =30*H +0.5*M;
    thetab =6*M;
    if(fabs(thetaa-thetab)>180)thetaab =360-fabs(thetaa-thetab);
    else thetaab = fabs(thetaa-thetab);

    cout << fixed << setprecision(12) << sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(thetaab*3.141592653589793/180)) << endl;

    //cout << sin(thetaab*3.141592653589793/180) << endl;
}


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

int main(){

    long long N;
    cin >> N;
    vector<long long> FB(N+1,0);
    for(int i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            FB.at(i)=i;
        }
    
        
    }
    long long sum=0;
    for(int j=1; j<=N; j++){
        sum+=FB.at(j);
    }
 
 cout << sum << endl;
 
}


Measured memory_bytes: 11064
s=input()
ans=0
n=len(s)

def dfs(string,cur):
  global ans
  if cur==n:
    ans+=eval(string)
    return
  ret0=dfs(string+"+"+s[cur],cur+1)
  ret1=dfs(string+s[cur],cur+1)
dfs(s[0],1)
print(ans)

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

using namespace std;

const int MAXN=200;

int main()
{
	int n,A[MAXN];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(int i=0;i<n;i++)
	{
		int key=A[i],j=i-1;
		while(j>=0&&A[j]>key)
		{
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=key;
		for(int k=0;k<n;k++)
			printf("%d%c",A[k],k+1==n?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 3164
n, y = [i for i in input().split()]
n = int(n)
y = int(y[:-3])

for a in range(n + 1):
  for b in range(n + 1 - a):
    c = n - a - b
    if 10 * a + 5 * b + c == y:
      print('{} {} {}'.format(a, b, c))
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a>>b>>c>>k;
if(k<=a)
{
  cout<<k;
  return 0;
}
sum+=a;
k-=a;
if(b>=k)
{
  cout<<sum;
  return 0;
}
else
{
  k-=b;
  cout<<sum-k;
}
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
 
const ll N = 105;
const ll INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

pll bags[N];
ll n, m, ans;
ll memo[100005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> bags[i].first >> bags[i].second;
 
    sort(bags, bags + n);
    for(int i = 0; i < 100005; i++)
        memo[i] = INF;

    memo[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 100000; j >= 0; j--)
        {
            if(bags[i].second <= j)
                memo[j] = min(memo[j], memo[j - bags[i].second] + bags[i].first);
        }
    }
    
    for(int i = 0; i < 100005; i++)
        if(memo[i] <= m)
            ans = i;
        
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int L[100000];
	int R[100000];
	int l, r;
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		if (i == 0) {
			l = L[0];
			r = R[0];
		}
		if (l < L[i]) l = L[i];
		if (r > R[i]) r = R[i];
	}
	if (r < l) cout << 0 << endl;
	else cout << r - l + 1 << endl;
	return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto S = A.sum;
    auto md = 1L << 59;
    long x = 0;

    foreach (a; A) {
        x += a;
        auto y = S - x;
        md = min(md, abs(x - y));
    }

    md.writeln;
}




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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	while(1){
		for(int i=1;i<=2;i++){
			if(i==1){
				c-=b;
				if(c<=0){
					cout<<"Yes";
					return 0;
				}
			}
			if(i==2){
				a-=d;
				if(a<=0){
					cout<<"No";
					return 0;;
				}
			}
		}
	}
	
	return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    UnionFind uf(N);
    vector<ll> res;
    
    res.push_back(N * (N-1) / 2);
    for (ll i = M-1; i > 0; i--) {
        if (uf.same(A[i], B[i])) {
            res.push_back(res.back());
        } else {
            ll add = uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]);
            res.push_back(res.back() - add);
        }
    }

    for (ll i = M-1; i >= 0; i--) {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5416
import heapq
from collections import defaultdict

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

jobs = []
cnts = defaultdict(int)
rets = []

for i in range(N):
    a, b = map(int, input().split())

    heapq.heappush(jobs, (a, -b))
    cnts[a] += 1


ans = 0
for i in range(1, M+1):

    cnt = cnts.get(i)

    if cnt:
        while cnt > 0:
            a, b = heapq.heappop(jobs)
            heapq.heappush(rets, b)
            cnt -= 1

    if rets:
        b = heapq.heappop(rets)
        ans -= b

print(ans)

Measured memory_bytes: 24248
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int A,B;
    cin >> A >> B;
    cout << (double)A/B <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
  int n, k;
  scanf("%d %d", &n, &k);
  if( k % 2 != 0) {
    printf("%lld\n", (long long)(n/k) * (long long)(n/k) * (long long)(n/k) );
  }
  else {
    int mod = k/2, i;
    for(i = 0; k*i+mod <= n; ++i) { ; } 
    printf("%lld\n", (long long)(n/k) * (long long)(n/k) * (long long)(n/k) + (long long)i*(long long)i*(long long)i);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
 
int main(){
    long long a,b,x;
 
    cin >> a >> b >> x;
  	
  	if(a%x == 0){
        cout << (b/x - a/x) + 1 << endl;
    }else{
        cout << b/x - a/x << endl;
    }
 
    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n,m;
  cin >> n >> m;
  int food[m] = {};
  
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    int a[k];
    for(int j=0;j<k;j++){
      cin >> a[j];
      a[j]--;
      food[a[j]]++;
    }
  }
  int ans = 0;
  for(int i=0;i<m;i++){
    if(food[i] == n){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#import functools

def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    A.sort(reverse=True)

    if A[-1] == 0:
        print('0')
        exit()
    elif A[0] > 1e18:
        print('-1')
        exit()

    ret = 1
    for x in A:
        ret = ret * x
        if ret > 1e18:
            print('-1')
            exit()
        elif ret == 0:
            print('0')
            exit()

    if ret == 0:
        print('0')
        exit()
    elif ret > 1e18:
        print('-1')
        exit()
    print(f'{ret}')


if __name__ == "__main__":
    main()

Measured memory_bytes: 87384
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int sum = a1 + a2 + a3;
    if (sum >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  ll sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];
  vector<ll> B(N);
  B[0] = A[0];
  for (int i = 1; i < N; i++) B[i] = B[i-1] + A[i];
  int k;
  for (int i = 0; i < N; i++) {
    if (B[i]*2 >= sum) {
      k = i;
      break;
    }
  }
  ll p = min(B[k]*2 - sum,sum - (B[k] - A[k])*2);
  
  cout << p << endl;
}

Measured memory_bytes: 3328
#10^18こえたら-1
n = int(input())
Arr = list(map(int, input().split( )))
Arr = sorted(Arr)
if Arr[0] == 0:
  print(0)
  exit()
s = 1
for i in range(n):
  s *= Arr[i]
  if s > 10**18:
    print(-1)
    exit()
print(s)

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

using namespace std;
int n;
int h[100000];
long long F[100000];

int main()
{
    cin >> n;
    F[0]=0;
    for (int i=0; i<n; i++)
    {
        cin >> h[i];
        if (i==1) F[1]=abs(h[1]-h[0]);
        else if (i>1) F[i]=min(F[i-1]+abs(h[i]-h[i-1]),F[i-2]+abs(h[i]-h[i-2]));
    }
    cout << F[n-1];
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int mx = 0;
        int sum = 0;
        for(int i = 0; i < n; i++){
            int p = sc.nextInt();
            if(p > mx){
                mx = p;
            }
            sum += p;
        }
        System.out.println(sum - mx/2);
    }
}

Measured memory_bytes: 21844
W, H = map(int, raw_input().split())
p = sorted([(i, int(raw_input())) for i in xrange(W)], key=lambda x:-x[1])
q = sorted([(i, int(raw_input())) for i in xrange(H)], key=lambda x:-x[1])
ans = 0
pe, qe, ae = 0, 0, (W+1)*(H+1)-1
while len(p)> 0 or len(q) > 0:
    if len(q) == 0 or (len(p) > 0 and p[-1][1] <= q[-1][1]):
        i, cost = p.pop()
        pe += 1
        ans += cost*(H+1-qe)
    else:
        j, cost = q.pop()
        qe += 1
        ans += cost*(W+1-pe)

print ans


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

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

    map<char, int> letters;
    for (unsigned i=0; i<s.size(); i++) letters[s[i]]++;
    int tmp = 0;
    for (auto itr : letters) tmp += itr.second & 1;
    if (tmp > 1)
    {
        cout << -1 << endl;
        return 0;
    }

    long long ans = 0;
    while (s.size() > 2)
    {
        int pos = s.find(s.back());
        if (pos == s.size()-1)
        {
            reverse(s.begin(), s.end());
        }
        else
        {
            ans += pos;
            s.pop_back();
            s.erase(s.begin()+pos);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int c[1001][1001];
char ren1[1001],ren2[1001];

void LCS(int x,int y){
  int i,j;
  for(i = 1; i <= x; i++) c[i][0] = 0;
  for(j = 0; j <= y; j++) c[0][j] = 0;
  for(i = 1; i <= x; i++){
    for(j = 1; j <= y; j++){
      if(ren1[i-1] == ren2[j-1]) c[i][j] = c[i - 1][j - 1] + 1;
      else if (c[i - 1][j] >= c[i][j - 1]) c[i][j] = c[i - 1][j];
      else c[i][j] = c[i][j - 1];
    }
  }
  printf("%d\n",c[x][y]);
}

int main(){
  int n,i,x,y;
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%s",ren1);
    scanf("%s",ren2);
    x = (int)strlen(ren1);
    y = (int)strlen(ren2);
    LCS(x,y);    
  }
  return 0;
  
}



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

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

    int alph[26] = {};
    for(int i = 0; i < 4; i++) {
        int index = s[i] - 'A';
        alph[index]++;
    }

    int countTwo = 0;

    for(int i = 0; i < 26; i++) {
        if(alph[i] == 2) countTwo++;
    }

    if(countTwo == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

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

int main() {
	
	ull w, h;
	cin >> h >> w;

	vector<string>word(h);

	rep(i, 0, h) {
		cin >> word[i];
	}

	h += 2;
	w += 2;

	rep(i, 0, h) {
		rep(j, 0, w) {

			if (i == 0 || i == h-1) {
				cout << "#";
			}
			else if (j== 0 || j == w - 1) {
				cout << "#";
			}else {
				cout << word[i - 1][j - 1];
			}

		}
		cout << endl;
	}





	return 0;
}

 

Measured memory_bytes: 256
import heapq

n = int(input())
edges = [None] * n
for _ in range(n):
    l = list(map(int, input().split()))
    edges[l[0]] = set((c, j) for j, c in (l[i:i + 2] for i in range(2, l[1] * 2 + 2, 2)))

min_costs = [0] * n
visited = [False] * n
visited[0] = True
queue = list(edges[0])
heapq.heapify(queue)
remains = n - 1

while True:
    total_cost, vertex = heapq.heappop(queue)
    if visited[vertex]:
        continue
    visited[vertex] = True
    min_costs[vertex] = total_cost
    remains -= 1
    if not remains:
        break
    for cost, vertex2 in edges[vertex]:
        if not visited[vertex2]:
            heapq.heappush(queue, (total_cost + cost, vertex2))

for r in enumerate(min_costs):
    print(*r)

Measured memory_bytes: 122308
import ImmutableList.*

fun main(args:Array<String>):Unit {
    val list = LinkList()
    repeat(readLine()!!.toInt()){
        val arg = readLine()!!.split(' ').map(String::toInt)
        when(arg.first()){
            0 -> list.insert(arg.last())
            1 -> list.move(arg.last())
            else -> list.erase()
        }
    }
    println(list)
}
fun <T, A:T> ImmutableList<T>.append(value:A):ImmutableList<T> = Cons(value, this)
sealed class ImmutableList<out T>:Iterable<T>{
    override fun iterator(): Iterator<T> {
        return ListIterator(this)
    }
    object Nil:ImmutableList<Nothing>()
    data class Cons<out T>(val head:T, val tail:ImmutableList<T>):ImmutableList<T>()
}
class ListIterator<out T>(private var list:ImmutableList<T>):Iterator<T> {
    override fun hasNext(): Boolean = list is Cons

    override fun next(): T {
        val next = list as Cons
        list = next.tail
        return next.head
    }

}
class LinkList{
    private var mPrev:ImmutableList<Int> = Nil
    private var mNext:ImmutableList<Int> = Nil
    private fun moveForward():Unit {
        val next = mNext as Cons
        mPrev = Cons(next.head, mPrev)
        mNext = next.tail
    }
    private fun moveBackward():Unit {
        val prev = mPrev as Cons
        mPrev = prev.tail
        mNext = Cons(prev.head, mNext)
    }
    fun insert(value:Int):Unit {
        mNext = Cons(value, mNext)
    }
    fun move(value:Int):Unit {
        if (value >= 0){
            repeat(value){moveForward()}
        }else{
            repeat(-value){moveBackward()}
        }
    }
    fun erase():Unit {
        mNext = (mNext as Cons<Int>).tail
    }

    override fun toString(): String {
        return listOf(mPrev.reversed(), mNext).flatten().joinToString ("\n")
    }
}


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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }
  cin >> n;
  int tmp, tmp2, tmp3;
  rep_i(i, n){
    cin >> tmp;
    if(tmp == 0){
      cin >> tmp2 >> tmp3;
      int min = *min_element(&nums[tmp2], &nums[tmp3]);
      cout << min << endl;
    }else{
      cin >> tmp2 >> tmp3;
      int max = *max_element(&nums[tmp2], &nums[tmp3]);
      cout << max << endl;
    }
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)            int i; std::cin >> i
#define in2(i, j)        int i, j; std::cin >> i >> j
#define in3(i, j, k)     int i, j, k; std::cin >> i >> j >> k
#define in_(i)           std::cin >> i
#define in2_(i, j)       std::cin >> i >> j
#define in3_(i, j, k)    std::cin >> i >> j >> k
#define in_ll(i)         ll i; std::cin >> i
#define in2_ll(i, j)     ll i, j; std::cin >> i >> j
#define in3_ll(i, j, k)  ll i, j, k; std::cin >> i >> j >> k
#define in_ll_(i)        std::cin >> i
#define in2_ll_(i, j)    std::cin >> i >> j
#define in3_ll_(i, j, k) std::cin >> i >> j >> k
#define in_ld(i)         ld i; std::cin >> i
#define in2_ld(i, j)     ld i, j; std::cin >> i >> j
#define in3_ld(i, j, k)  ld i, j, k; std::cin >> i >> j >> k
#define in_ld_(i)        std::cin >> i
#define in2_ld_(i, j)    std::cin >> i >> j
#define in3_ld_(i, j, k) std::cin >> i >> j >> k
#define in_c(i)          char i; std::cin >> i
#define in2_c(i, j)      char i, j; std::cin >> i >> j
#define in3_c(i, j, k)   char i, j, k; std::cin >> i >> j >> k
#define in_c_(i)         std::cin >> i
#define in2_c_(i, j)     std::cin >> i >> j
#define in3_c_(i, j, k)  std::cin >> i >> j >> k
#define in_str(s)        std::string s; std::cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){std::cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){std::cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){std::cin>>x;}

#define print(x)   std::cout << x
#define println(x) std::cout << x << "\n"
#define print_vec(v) for (auto &x:v) { std::cout << x << " ";}
#define println_vec(v) for (auto &x:v) { std::cout << x << " ";} std::cout << "\n";
#define print_long_vec(v) for (auto &x:v) { std::cout << x << "\n";}
#define println_long_vec(v) for (auto &x:v) { std::cout << x << "\n";} std::cout << "\n";

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)

/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())

using namespace std;
/* Code Starts Here*/
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in_ll(N);
    map<ll, int> m;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
            while (N % i == 0) {
                m[i]++;
                N /= i;
                if (N == 0) { break; }
            }
        }
    }
    if (N != 1) { m[N]++; }
    int ans = 0;
    for (auto n : m) {
        int i = 1;
        while (true) {
            if (n.second - i < 0) {
                break;
            }
            n.second -= i;
            ans++;
            i++;
        }
    }
    println(ans);
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> P(N*N);
  rep(i, N*N) {
    cin >> P[i];
    P[i]--;
  }
  vector<bool> done(N*N);
  vector<int> D(N*N);
  rep(i, N) rep(j, N) D[i*N+j] = min({i, N-1-i, j, N-1-j});
  ll ans = 0;
  auto bfs = [&](int s) {
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, 1, 0, -1};
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
      int cur = q.front(); q.pop();
      int x = cur/N;
      int y = cur%N;
      rep(k, 4) {
        int nx = x+dx[k];
        int ny = y+dy[k];
        int ne = nx*N+ny;
        if(nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
        if(D[cur]+(!done[cur]) < D[ne]) {
          q.push(ne);
          D[ne] = D[cur]+(!done[cur]);
        }
      }
    }
  };
  rep(i, N*N) {
    ans += D[P[i]];
    done[P[i]] = true;
    bfs(P[i]);
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;
using ll = long long;

ll sqint(ll num){

    ll l = 0;
    ll r = 1e10;

    while(r - l > 1){
        ll mid = (r + l) / 2;
        (mid * mid <= num ? l : r) = mid;
    }
    return l;
}


int main()
{
    int n;
    cin >> n;
    cout << sqint(n) * sqint(n) << endl;
}

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

li=[0]*n
for i in range(k):
        d=int(input())
        lis = list(map(int,input().split()))
        for j in range(len(lis)):
                li[lis[j]-1]+=1
        lis.clear
cnt=0
for i in range(len(li)):
        if li[i]==0:
                cnt+=1

print(cnt)

Measured memory_bytes: 67716