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

using namespace std;

typedef long long ll;
typedef vector<ll> v1;


template<class T>
class segment_tree {
private:
  ll n;
  T d;
  vector<T>* v;
  T _query(ll a,ll b,ll k,ll l,ll r){
    if(r <= a || b <= l) return d;
    if(a <= l && r <= b) return this->v->at(k);
    else {
      T vl = _query(a,b,k*2+1,l,(l+r)/2);
      T vr = _query(a,b,k*2+2,(l+r)/2,r);
      return func(vl,vr);
    }
  }
public:
  segment_tree (){}
  segment_tree(ll n,T d = 0){
    this->n = 1;
    while(n > this->n) this->n <<= 1;
    v = new vector<T>(this->n*2,d);
    this->d = d;
  }
  void update(ll i,T x){
    assert(x < this->d);
    i += n-1;
    this->v->at(i) = x;
    while(i > 0){
      i = (i-1)/2;
      this->v->at(i) = func(this->v->at(i*2+1),this->v->at(i*2+2));
    }
  }
  T query(ll a,ll b){
    return _query(a,b,0,0,n);
  }
  T func(T a,T b){
    return min(a,b);
  }
};

ll n;
v1 lr[1 << 20];
segment_tree<ll> sg(1 << 20, 1 << 30);
map<ll,ll> m;
unordered_map<ll,ll> zip;
ll ans = 0;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++){
    ll l,r;
    cin >> l >> r;
    lr[i] = v1({l,r});
  }
  sort(lr,lr+n);
  for(ll i = 0;i < n;i++){
    lr[i].push_back(i);
  }
  for(ll i = 0;i < n;i++){
    ans = max(ans,lr[i][1]-lr[i][0]+1);
  }
  ll mem = 0;
  for(ll i = 0;i < n;i++){
    if(ans == lr[i][1]-lr[i][0]+1){
      ll r = 1 << 30;
      ll l = 0;
      for(ll j = 0;j < n;j++){
        if(i == j) continue;
        l = max(lr[j][0],l);
        r = min(lr[j][1],r);
      }
      mem = max(mem,max(0ll, r-l+1));
    }
  }
  ans += mem;

  for(ll i = 0;i < n;i++){
    sg.update(i,lr[i][1]);
  }
  for(ll i = 1;i < n;i++){
    ll mem = 0;
    mem += max(0ll, sg.query(0,i)-lr[i-1][0]+1);
    mem += max(0ll, sg.query(i,n)-lr[n-1][0]+1);
    ans = max(ans,mem);
  }
  cout << ans << endl;


}


Measured memory_bytes: 46848
;; ABC 082 C
(let* ((n (read))
       (c (make-hash-table :size (expt 10 5)))
       (ans 0))
  (loop :for i :from 1 :to n
        :for a := (read)
        :do (if (gethash a c)
                (incf (gethash a c))
                (setf (gethash a c) 1)))
  (maphash (lambda (key value)
             (if (> key value)
                 (incf ans value)
                 (incf ans (- value key))))
           c)
  (format t "~A~%" ans))


Measured memory_bytes: 76912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct box{
	int ball = 1;
	bool flag = false;
};

int main(){
	int n,m,x,y,result = 0;
	cin >> n >> m;
	box B[100001];
	B[1].flag = true;
	for(int i = 0;i < m;i++){
		cin >> x >> y;
		if(B[x].ball > 0){
			B[x].ball--;
			B[y].ball++;
		}
		if(B[x].flag){
			B[y].flag = true;
		}
		if(B[x].ball == 0)B[x].flag = false;
	}

	for(int i = 1;i <= n;i++){
		if(B[i].flag)result++;
	}
	cout << result << endl;
	return 0;
}

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

int g;
bool f;
vector<int> ans, ans2;

int dfs(int b, int k){
    if(k == 0){
        if((b ^ g) == 1) f = true;
        if(f){
            ans.push_back(b);
            ans2.push_back(b ^ 1);
        }
        else{
            ans.push_back(b);
            ans.push_back(b ^ 1);
            b = b ^ 1;
        }
    }
    else{
        b = dfs(b, k - 1);
        b ^= (1 << k);
        b = dfs(b, k - 1);
    }
    return b;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    g = (b ^ a);
    int l = 0;
    for(int i = 0; i < n; i++) if((g >> i) & 1) l++;
    if(l % 2 == 0){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    dfs(0, n - 1);
    for(int i = 0; i < (int)ans.size(); i++) cout << (ans[i] ^ a) << " ";
    for(int i = (int)ans2.size() - 1; i >= 0; i--) cout << (ans2[i] ^ a) << " ";
    cout << endl;
}

Measured memory_bytes: 1784
s = input()
t = s[::-1]
mod = 10**9 + 7

digit = [0] * (10**5+10)
digit[0] = 1  # digit[i] := 10**iのあまり
for i in range(1, 10**5+10):
    digit[i] = (digit[i-1] * 10) % 13

dp = [[0 for _ in range(13)] for i in range(10**5+10)]
dp[0][0] = 1

for i in range(1, len(s)+1):
    for j in range(13):
        if t[i-1] != '?':
            num = int(t[i-1])
            dp[i][(j+(num*digit[i-1])%13)%13] += dp[i-1][j]
            dp[i][(j + (num * digit[i - 1]) % 13) % 13] %= mod
        else:
            for k in range(10):
                dp[i][(j + (k * digit[i - 1]) % 13) % 13] += dp[i-1][j]
                dp[i][(j + (k * digit[i - 1]) % 13) % 13] %= mod

print(dp[len(s)][5] % mod)

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

int main(int argc, const char * argv[]) {
    int W,H,x,y,r;
    string str;
   
    cin >> W >> H >> x >> y >> r;
    
    if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
        str = "Yes";
    }else{
        str = "No";
    }
        
        cout << str << endl;
return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<math.h>
using namespace::std;
int main(){

int a[3];

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

if(a[0]>a[1]){
	if(a[0]>a[2]){
		cout<<(a[0]*10+a[1]+a[2]);
	}else{
		cout<<(a[2]*10+a[0]+a[1]);
	}
}else if(a[1]>a[2]){
		cout<<(a[1]*10+a[0]+a[2]);
	}else{
		cout<<(a[2]*10+a[1]+a[0]);
}



}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc139/tasks/abc139_e
//#include <bits/stdc++.h>

//#if __cplusplus >= 201103L
//#endif

// C++
#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>

//#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    //vector<deque<ll>> ain(N+1);
    ll ain[1000+1][1000+1]={};
    ll aidx[1000+1]={};
    FOR(i,1,N+1){
        FOR(j,1,N){
            ll aij; cin>>aij;
            //ain[i].push_back(aij);
            ain[i][j] = aij;
        }
    }
    ll day=0;

    auto get_front=[&](ll i){
        ll p=aidx[i]+1;
        if (p>N-1) return (ll)-1;
        //if (ain[i].size()<=0) return (ll)-1;
        ll ret = ain[i][p];//.front();
        return ret;
    };
    auto pop_front=[&](ll i){
        //ain[i].pop_front();
        aidx[i]++;
    };
    ll all = N*(N-1)/2;
    vector<int> flag(N+1,-1);

    deque<ll> candidate[2];
    FOR(i,1,N+1){ //初回は全部つむ
        candidate[day].push_back(i);
    }

    while(all>0){
        ll siai=0;

        //FOR(i,1,N+1){
        for(const auto& i:candidate[day%2]){
            if (flag.at(i)==day) continue;
            auto e = get_front(i); //eと戦いたい
            if (e>0){
                if (flag.at(e)==day) continue;
                //if(e>0 && get_front(e) == i) {
                if(get_front(e) == i) {
                    pop_front(i);
                    pop_front(e);
                    flag.at(e)=day;
				    flag.at(i)=day;
				    ++siai;
                    auto nx_candi_id=(day+1)%2;
                    candidate[nx_candi_id].push_back(i);
                    candidate[nx_candi_id].push_back(e);
                }
            }
        }
        candidate[day%2].clear();
        ++day;
        all -= siai;
        if(siai==0){
            cout<<-1<<endl;
            return 0; //終わり
        }
    }
    cout<<day<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n,c[3][MAXN],dp[3][MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> c[0][i] >> c[1][i] >> c[2][i];
    }
    

    MEM(dp,0);

    REP (i,3) {
        dp[i][0] = c[i][0];
    }

    REP1 (i,n-1) {
        REP (j,3) {
            REP (k,3) {
                if (j != k) {
                    dp[j][i] = max(dp[j][i],dp[k][i-1]+c[j][i]);
                }
            }
        }
    }

    ll ans = -1;
    REP (i,3) {
        ans = max(ans,dp[i][n-1]);
    }

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


Measured memory_bytes: 4992
import bisect
INF=10**18
n=int(input())
s=sorted(list(map(int,input().split())))+[INF]
q=int(input())
t=list(map(int,input().split()))
cnt=0
for i in t:
  if s[bisect.bisect_left(s,i)]==i:cnt+=1
print(cnt)


Measured memory_bytes: 16740
#include <bits/stdc++.h>
#define fly ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

const int mxm = 100010;
using namespace std;

int ara[mxm];
int dp[mxm];
int n;

int fnc(int i){
  if(i == n-1){
    return 0;
  }
  if(i >= n){
    return 99999999;
  }
  if(dp[i] != -1)return dp[i];

  int res1 = abs(ara[i+1]-ara[i]) + fnc(i+1);
  int res2 = abs(ara[i+2]-ara[i]) + fnc(i+2);
  dp[i] = min(res1,res2);
  return dp[i];
}

int main(int argc, char const *argv[]) {
  fly;
  memset(dp,-1,sizeof(dp));
  cin >> n;
  for(int i = 0;i<n;i++){std::cin >> ara[i];}
  ara[n] = 999999;
  cout << fnc(0) << endl;
  return 0;
}


Measured memory_bytes: 9080
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	int x=nextpint();
	int y=nextpint();
	int z=nextpint();
	printf("%d %d %d\n", z, x, y);
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, r;
  cin >> n >> r;
  if (n >= 10)
    cout << r << endl;
  else
    cout << r + 100 * (10 - n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, O = 0;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {cin >> p.at(i);}
  for (int i = 0; i < N; i++) {
    if (i + 1 != p.at(i)) {O++;}
  }
  if (O == 2 || O == 0) {cout << "YES" << endl;}
  else {cout << "NO" << endl;}
}


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

int main() {
    int a,b,c,i=0,j=0;
    cin >> a >> b >> c;
    while (1) {
        if (c % (a + i )== 0) j++;
        if (a+i==b) break;
        i++;
    }
    cout << j << endl;
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


struct osak{
    vector<int> d;
    osak(int n) :d(n+1, 1) {
        for(int i = 2; i <= n; i++){
            if (d[i] != 1) continue;
            for(int j = i; j <= n; j += i){
                if (d[j] == 1) d[j] = i;
            }
        }
    }
    vector<P> factorize(int x){
        vector<P> res;
        int y = d[x];
        int cnt = 1;
        while(x != 1){
            x /= y;
            if (d[x] != y){
                res.push_back(P(y, cnt));
                cnt = 0;
            }
            y = d[x];
            cnt++;
        }
        return res;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    osak o(1e6);
    set<int> st;
    bool pw = true;
    rep(i,n){
        if (a[i] == 1) continue;
        auto res = o.factorize(a[i]);
        for(P p: res){
            if (st.find(p.first) != st.end()){
                pw = false;
                break;
            }
            st.insert(p.first);
        }
        if (!pw) break;
    }

    if (pw){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = a[0];
    for(int i = 1; i < n; i++){
        g = __gcd(g, a[i]);
    }

    if (g == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 11144
import math

n = list(map(int, input().split()))
n = n[0]

v1 = [0,0]

if(n<10**18):
    v2 = [1,0]
    v3 = [10**9,0]
    v2[1] = n//(10**9)+1
    a = n % (10**9)
    v3[1] = 10**9 - a
else:
    v2=[0,10**9]
    v3=[10**9,0]

print(v1[0],v1[1],v2[0],v2[1],v3[0],v3[1])


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
   string s,t;cin>>s>>t;
   int a,b;cin>>a>>b;
   string u;cin>>u;
   if(u==s)
   cout<<a-1<<' '<<b;
   else
   cout<<a<<' '<<b-1<<endl;
}

Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])

if a+b>=10:
    
    print("error")
    
else:
    
    print(a+b)


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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }
  long long ans0 = 0;
  long long ans1 = 0;
  long long sum = 0;
  bool pos = true;
  for (int i = 0; i < N; ++i) {
    sum += a[i];
    if (pos && sum <= 0) {
      ans0 += 1 - sum;
      sum = 1;
    } else if (!pos && sum >= 0) {
      ans0 += sum - (-1);
      sum = -1;
    }
    pos = !pos;
  }
  sum = 0;
  pos = false;
  for (int i = 0; i < N; ++i) {
    sum += a[i];
    if (pos && sum <= 0) {
      ans1 += 1 - sum;
      sum = 1;
    } else if (!pos && sum >= 0) {
      ans1 += sum - (-1);
      sum = -1;
    }
    pos = !pos;
  }
  std::cout << std::min(ans0, ans1);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

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

	long long ans=0;
	for(int i=0;i<n;i++)
		ans+=(a[i]-1);
	
	cout << ans << endl;




}

Measured memory_bytes: 256
#encoding:utf-8
numbers = []

while gets
 number = $_.to_i
 numbers.push number.to_i
end

def count_pattern integer
 count = 0
 a = 0
 while a < 10
  b = 0
  while b < 10
   c = 0
   while c < 10
    d = 0
    while d < 10
     if a + b + c + d == integer
      count += 1
     end
     d += 1
    end
    c += 1
   end
   b += 1
  end
  a += 1
 end
 puts count
end

i = 0
while i < numbers.length
 count_pattern numbers[i]
 i += 1
end

Measured memory_bytes: 6100
#include<stdio.h>
const int size=10000;
int isprime(int n){
  int i;
  for(i=2;i*i<=n;i++){
    if(n%i==0)return 0;
  }
  return 1;
}
int main(){
  int i,n;
  int data[size]={1};
  for(i=2;i<size;i++){
    data[i]=isprime(i);
    //printf("%d %d\n",i,data[i]);
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=n;i>=0;i--){
      if(data[i]==1 && data[i-2]==1){
        break;
      }
    }
    printf("%d %d\n",i-2,i);
  }
  return 0;
}

Measured memory_bytes: 2608
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))

X = 0
Y = 0
for a in A:
    X += a
    Y += a * a
X = (X * X) % mod
Y = Y % mod
Z = (X - Y + mod) % mod
ans = 0
if Z % 2 == 0:
    ans = Z / 2
else:
    ans = (Z + mod) / 2
print(int(ans))


Measured memory_bytes: 31008
#include <iostream>
using namespace std;
int main(){
	int h=0 , m , s;
	cin >> s;
	m=s/60;
	h=m/60;
	if (m>=60) m%=60;
	s %= 60;
	cout << h << ':' << m << ':' << s << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
string str;
vector<int> G[26];
bool used[26];
int main()
{
	cin>>str;
	n=str.size();
	for(int i=0;i<n;i++)
		G[str[i]-'a'].push_back(i);
	for(int i=0;i<26;i++)
		if(G[i].size()==0)
		{
			str+=(char)('a'+i);
			cout<<str<<endl;
			return 0;
		}
	memset(used,true,sizeof(used));
	for(int i=25;i>=0;i--)
	{
		used[str[i]-'a']=false;
		for(int j=str[i]+1;j<='z';j++)
		{
			if(!used[j-'a'])
			{
				str[i]=j;
				str=str.substr(0,i+1);
				cout<<str<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000009
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double l;
    cin >> l;
    cout << fixed << setprecision(12) << (l / 3.0) * (l / 3.0) * (l / 3.0) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    int a=scn.nextInt();
    int b=scn.nextInt();
     int c=scn.nextInt();
    
    int t1=a;
    a=b;
    b=t1;
    
    int t2=a;
    a=c;
    c=t2;
    
    System.out.print(a+" "+b+" "+c);
  }
}

Measured memory_bytes: 21844
n = int(input())
masks = [1 << x for x in range(n)]

for i in range(1 << n):
    sub = [idx for idx, mask in enumerate(masks) if i & mask != 0b00]
    print('{}: {}'.format(i, ' '.join(map(str, sub)))) if len(sub) != 0 else print(f'{i}:')


Measured memory_bytes: 5708
#include <cstdio>
#include <algorithm>
#include <stdint.h>

int64_t gcd(int64_t a,int64_t b){
  return b?gcd(b,a%b):a;
}

bool solve(){
  int64_t A,B,C,D;
  scanf("%ld %ld %ld %ld",&A,&B,&C,&D);
  if(A<B||D<B){
    return false;
  }
  int64_t g=gcd(B,D);
  A%=g;
  A+=std::max<int64_t>(0,C-A+g)/g*g;
  return A>=B;
}

int main(){
  int64_t T;
  scanf("%ld",&T);
  while(T--){
    if(solve()){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}


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

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

    int n = s.length();
    int m = t.length();

    // cumulative sum
    vector<int> sa(n+1), sb(n+1), ta(m+1), tb(m+1);
    for(int i=0; i<n; i++){
        if(s[i] == 'A') sa[i+1] = 1;
        if(s[i] == 'B') sb[i+1] = 1;
        sa[i+1] += sa[i];
        sb[i+1] += sb[i];
    }
    for(int i=0; i<m; i++){
        if(t[i] == 'A') ta[i+1] = 1;
        if(t[i] == 'B') tb[i+1] = 1;
        ta[i+1] += ta[i];
        tb[i+1] += tb[i];
    }

    for(int i=0; i<q; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        int x = (sa[b] - sa[a-1]) - (sb[b] - sb[a-1]);
        x = (x % 3 + 3) % 3;
        int y = (ta[d] - ta[c-1]) - (tb[d] - tb[c-1]);
        y = (y % 3 + 3) % 3;

        if(x == y) cout << "YES" << endl;
        if(x != y) cout << "NO"  << endl;
    }
    return 0;
}

Measured memory_bytes: 5112
n, q = list(map(int, input().split()))
s = input()

#def f(i):
#    cnt = 0
#    for j in range(i-1):
#        #print(s[j:j+2])
#        if s[j:j+2] == 'AC':
#            cnt += 1
#    return cnt

ftab = [0]*(n+1)
cnt = 0

for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ftab[i+2] = cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(ftab[r] - ftab[l])


Measured memory_bytes: 6188
/* C */
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	map<ll, ll> m;
	ll sum = 0;
	rep(i, N) {
		cin >> A[i];
		m[A[i]]++;
		sum += A[i];
	}

	ll Q;
	cin >> Q;
	rep(i, Q) {
		ll b, c;
		cin >> b >> c;
		ll sa = 0;

		// cout << "ans : ";
		if (m.count(b)) {
			sa = (b - c) * m[b];
			m[c] += m[b];
			m[b] = 0;
		}
		sum -= sa;

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 9152
#include <stdio.h>
#include <limits.h>

int n,t,a;
int h[1000];

double abs(double x){return x>0?x:-x;}

int main()
{
    scanf("%d%d%d",&n,&t,&a);
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    int ans;
    double min=INT_MAX;
    for(int i=0;i<n;i++)
    {
        // printf("%lf\n",abs(t-h[i]*0.006-a));
        if(min>abs(t-h[i]*0.006-a))
        {
            min=abs(t-h[i]*0.006-a);
            ans=i+1;
        }
    }
    printf("%d\n",ans);
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = int.Parse(inputs[0]);
        var B = int.Parse(inputs[1]);
        var H = int.Parse(inputs[2]);
        var M = int.Parse(inputs[3]);

        var time = H * 60 + M;

        var n = (time * 5.5 ) % 360;
        if(n > 180)
        {
            n = 360 - n;
        }

        var ans = A * A + B * B - 2 * A * B * Math.Cos(n * (Math.PI / 180));


        Console.WriteLine(Math.Sqrt(ans));
        Console.ReadLine();
    }


}



Measured memory_bytes: 18728
#include <iostream>
using namespace std;
 
int main()
{
    int V,D;
    while(cin >> V >> D)
    {
        int s=0,f[2];
        f[0]=f[1]=1;
         
        bool t[1024]={0};
        for(int i=0; i<V; i++)
        {
            f[s]+=f[1-s];
            f[s]%=1001;
            t[f[s]]=1;
            s=1-s;
        }
 
 
        int p=-1,c=0;
        for(int i=0; i<1001; i++)
        {
            if(t[i])
            {
                if(i-p>=D && p!=-1)
                {
                    c++;
                }
                p=i;
            }
        }
        cout << c+1 << endl;
    }


































}

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

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

using namespace std;

int main() {
  while(1){
    int h,w;
    cin>>h>>w;
    if(!h)break;
    vector<string> t(h);
    REP(i,h)cin>>t[i];
    string s=">v<^.";
    int di[]={0,1,0,-1,0};
    int dj[]={1,0,-1,0,0};
    set<pair<int,int>> st;
    int i=0,j=0;
    bool loop = false;
    while(t[i][j] != '.') {
      if (st.find(make_pair(i,j))!=end(st)) {
        loop=true;
        break;
      }
      st.insert(make_pair(i,j));
      int id=find(begin(s),end(s),t[i][j])-begin(s);
      tie(i,j)=make_pair(i+di[id],j+dj[id]);
    }
    if(loop)
      cout << "LOOP" << endl;
    else
      cout << j << ' '<<i<<endl;
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a = 200000, z = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' && i < a) a = i;
    if (s[i] == 'Z') z = i;
  }
  cout << z - a + 1 << endl;
  return 0;
}

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

int main(){
    int n,m;
    double s=0;
    int a[105];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    s=s/(4*m);
    int cou=0;
    for(int i=0;i<n;i++){
        if(a[i]>=s)cou++;
    }
    if(cou>=m)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
import sys
def ov(l):
    if (abs(l[0]+l[2]-l[4]-l[6])<=(l[2]-l[0]+l[6]-l[4]) and abs(l[1]+l[3]-l[5]-l[7])<=(l[3]-l[1]+l[7]-l[5])): return True
    return False
[print(l) for l in ["YES" if ov(i) else "NO" for i in [list(map(float,j.split())) for j in sys.stdin]]]



Measured memory_bytes: 5592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

const int QMAX = 5*1e5;

// 1-indexed
int n;
int dat[QMAX+1];

// a[i]
int sum(int i)
{
	int s = 0;
	while (i > 0) {
		s += dat[i];
		i -= i & -i;
	}
	return s;
}

// add x to a[l]..a[r-1]
void add(int l, int r, int x)
{
	while (l <= n) {
		dat[l] += x;
		l += l & -l;
	}
	while (r <= n) {
		dat[r] -= x;
		r += r & -r;
	}
}

const int NMAX = 5*1e5;

int N, Q;
int c[NMAX+1];
vector<P> tm_st, tm_end;

int ans[QMAX+1];
int tm_corres[QMAX+1];

int prv[NMAX+1];

int main()
{
	scanf("%d%d", &N, &Q);
	tm_st.resize(Q);
	tm_end.resize(Q);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &c[i+1]);
	}
	for (int i = 0; i < Q; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		tm_st[i] = make_pair(l, i+1);
		tm_end[i] = make_pair(r, i+1);
	}
	sort(tm_st.begin(), tm_st.end());
	sort(tm_end.begin(), tm_end.end());
	int st_index = 0; // i ha [0,st_index-1) ni eikyou suru
	int end_index = 0;

	for (auto ite = tm_st.begin(); ite != tm_st.end(); ++ite) {
		tm_corres[ite->second] = ite - tm_st.begin() + 1;
	}

	memset(prv, -1, sizeof(prv));
	n = Q;

	for (int i = 1; i <= N+1; ++i) {
		while (end_index < Q && tm_end[end_index].first < i) {
			ans[tm_end[end_index].second]
				= sum(tm_corres[tm_end[end_index].second]);
			//printf("write %d %d\n", tm_end[end_index].second, ans[tm_end[end_index].second]);
			++end_index;
		}

		if (i == N+1) break;

		while (st_index < Q && tm_st[st_index].first <= i) {
			++st_index;
		}

		int l = 1;
		if (prv[c[i]] != -1) {
			l = lower_bound(tm_st.begin(), tm_st.end(),
					make_pair(prv[c[i]]+1,0))-tm_st.begin()+1;
			//printf("prv: %d\n", prv[c[i]]);
			//fflush(stdout);
		}
		prv[c[i]] = i;

		add(l, st_index + 1, 1);
		//printf("add [%d,%d)\n", l, st_index);
		//fflush(stdout);

		/*
		printf("i: %d, ", i);
		for (int j = 1; j <= Q; ++j)
			printf("\t%d: %d\n", j, sum(j));
		fflush(stdout);
		*/
	}

	for (int i = 1; i <= Q; ++i) {
		printf("%d\n", ans[i]);
	}

	return 0;
}



Measured memory_bytes: 21344
#include<stdio.h>
int main(void)
{
	int a,b,i,j;
	scanf("%d %d",&a,&b);
	while(a!=0 || b!=0){
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
				}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 1000
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
const int MAX_V=1e3+5;
const int INF=1e9;
vector< vector<int> > board(25,vector<int>(25,0) );
int w,h;
int sy,sx,gy,gx;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int goal=100;
bool outofrange(int y,int x)
{
  if(y<0 || y>=h || x<0 || x>=w) return true;
  else return false;
}

void bfs(int y,int x,int num,vector< vector<int> > &nowboard)
{
  if(num>=11) return;
  vector< vector<int> > save;
  save=nowboard;
  for (int k = 0; k < 4; ++k)
    {
      nowboard=save;
      int ny=y+dy[k];
      int nx=x+dx[k];
      int nny,nnx;
      if(outofrange(ny,nx) || nowboard[ny][nx]==1) continue;
      if(nowboard[ny][nx]==3)
	{
	  goal=min(goal,num);
	  continue;
	}
      else
	{
	  bool ok=true;
	  bool getgoal=false;
	  while(1)
	    {
	      nny=ny+dy[k];
	      nnx=nx+dx[k];
	      if(outofrange(nny,nnx))
		{
		  ok=false;
		  break;
		}
	      if(nowboard[nny][nnx]==3)
		{
		  goal=min(goal,num);
		  getgoal=true;
		  break;
		}
	      if(nowboard[nny][nnx]==1)
		{
		  nowboard[nny][nnx]=0;
		  break;
		}
	      ny=nny;
	      nx=nnx;
	    }
	  if(ok)
	    {
	      if(getgoal) continue;
	      bfs(ny,nx,num+1,nowboard);
	    }
	  else continue;
	      
	}      
    }
  return;
}

int main(void)
{
  while(cin >> w >> h && w)
    {
      goal=100;
      for (int i = 0; i < h; ++i)
	{
	  for (int j = 0; j < w; ++j)
	    {
	      cin >> board[i][j];
	      if(board[i][j]==2)
		{
		  sx=j;
		  sy=i;
		}
	      else if(board[i][j]==3)
		{
		  gx=j;
		  gy=i;
		}
	    }
	}
      //cout << sy << ' ' << sx << ' ' << gy << ' ' << gx << endl;
      bfs(sy,sx,1,board);
      if(goal==100)
	{
	  cout << -1 << endl;
	}
      else
	{
	  cout << goal << endl;
	}
    }
  return 0;
 
}



Measured memory_bytes: 3196
#include <stdio.h>

int main( int argc, char *argv[] )
{
	char S[25];
	scanf("%s",S);
	for(int i=0; i<19; i++){
		if(i==5 || i==13)printf(" ");
		else printf("%c",S[i]);
	}
	printf("\n");
	return 0;
}


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

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

int main() {
	long long A, B; cin >> A >> B;
	long long C = gcd(A, B), cnt = 0;

	for (long long i = 2; i*i <= C; i++) {
		if (C%i != 0) continue;
		cnt++;
		while (C%i == 0) C /= i;
	}
	if (C >= 2) cnt++;
	cout << cnt + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n,m,cnt,ans;
int main()
{
	ll i,s,a,b,j,k;
	scanf("%lld%lld",&n,&m);ans=1;
	while(n*(ll)2<=m)ans++,n*=2;
	printf("%lld",ans);
	return 0;
}

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

int map[50][50];

typedef pair<int, int> pxy;

int h, w, ans = 0;

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

void bfs(int sx, int sy)
{
  queue<pxy> q;
  q.push(pxy(sx, sy)); 
  while(!q.empty()){
    int x, y;
    x = q.front().first;
    y = q.front().second;
    q.pop();
    if(map[x][y]){
      map[x][y] = 0;
      for(int i = 0; i < 8; i++){
	int next_x = x + dx[i], next_y = y + dy[i];
	if(map[next_x][next_y] && next_x < w && next_x >= 0 && next_y < h && next_y >= 0){
	  q.push(pxy(next_x, next_y));
	}
      }
    }
  }
}

int main()
{
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0){
      break;
    }else{
      for(int i = 0; i < h; i++)
	for(int j = 0; j < w; j++)
	  cin >> map[j][i];
      for(int i = 0; i < h; i++)
	for(int j = 0; j < w; j++)
	  if(map[j][i]){
	    ans++;
	    bfs(j, i);
	  }
      cout << ans << endl;
      ans = 0;
    }
  }
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int low, high;
    low = max(A, C);
    high = min(B, D);

    cout << max(0,high - low) << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int num[n+1];
    int q;
    for(q=0;q<=n-1;q++) scanf("%d",&num[q]);
    int ans=0;
    int i,j;
    for(i=0;i<=n-1;i++){
        
        for(j=n-1;j>=i+1;j--){
            if(num[j-1]>num[j]){
                int a;
                a=num[j-1];
                num[j-1]=num[j];
                num[j]=a;
                ans++;
            }
        }
        
    }
    int b;
    for(b=0;b<=n-2;b++)printf("%d ",num[b]);
    printf("%d\n",num[n-1]);
    printf("%d\n",ans);
    
    return 0;
}

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

int main(void){
    
    int N,ans=0,x=0;
    string s;
    cin >> N >> s;

    for(int i=0;i<N;i++){
        if(s[i] == 'I'){
            x++;
        }
        else{
            x--;
        }
        
        if(ans < x) ans = x;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3616
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a)
max_a = sorted_a[-1]
max_a_r = sorted_a[-2]

for i in range(n):
  if a[i] == max_a:
    print(max_a_r)
  else:
    print(max_a)



Measured memory_bytes: 14112
N,K = map(int,input().split())

start = 0
end = N

ans = float('inf')
while start <= end:
	mid = start + (end - start) //2
	ans = min(abs(mid*K-N),ans)
	if mid*K == N:
		break
	elif mid*K>N:
		end = mid-1
	else:
		start = mid+1
		
print(ans)
	


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll N,K,C;

vc<bool> work(string& S){
    ll rest = 0, cnt = 0;
    vc<bool> B(N);
    rep(i,N){
        if(S[i]=='o' and rest==0){
            cnt++;
            rest = C;
            B[i] = true;
        }
        else if(rest>0)
            rest--;

        if (cnt == K) break;
    }
    return B;
}
int main() {
    init();
    cin >> N >> K >> C;
    string S;
    cin >> S;
    string RS = S;
    reverse(all(RS));
    vc<bool> gl = work(S), gr = work(RS);
    reverse(all(gr));

    vl ans;
    ll l = 0, r = 0;
    rep(i, N){
        if (gl[i]) l++;
        if (gr[i]) r++;
        if (gl[i] and gr[i] and l == r) ans.eb(i + 1);
    }

    for (auto &a : ans) cout << a << "\n";
}

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	double v;
	int f;
	while(scanf("%lf",&v)!=EOF){
		f=v*v/98+2;
		cout<<f<<endl;
	}
}

Measured memory_bytes: 0
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, t) = readLine.trim.split(' ').map(_.toInt)
  val func = readLine.trim.toList match {
    case p Poly Nil ⇒ p
    case _ ⇒ ???
  }

  println(
    func(n).map(_ * t).filter(_ <= 1000000000L).getOrElse("TLE")
  )

  def digit(number: Long): Int = {
    number match {
      case _ if number < 10 ⇒ 0
      case _ ⇒ digit(number / 10) + 1
    }
  }
  def exponent(base: Long, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ exponent(base, exp / 2).let{it ⇒ it * it * exponent(base, exp % 2)}
    }
  }
  object Poly{
    def unapply(arg: List[Char]): Option[(Long ⇒ Option[Long], List[Char])] = {
      arg match {
        case m Mono '+'::(p Poly t) ⇒ Some({n ⇒
          (m(n), p(n)) match {
            case (Some(a), Some(b)) if a + b > 1000000000 ⇒ None
            case (Some(a), Some(b)) ⇒ Some(a + b)
            case _ ⇒ None
          }
        }, t)
        case m Mono t ⇒ Some(m, t)
        case _ ⇒ None
      }
    }
  }
  object Mono{
    def unapply(arg: List[Char]): Option[(Long ⇒ Option[Long], List[Char])] = {
      arg match {
        case 'n'::'^'::(e Num t) ⇒ Some({ n ⇒
          if (digit(n) * e > 9) None
          else exponent(n, e).let{it ⇒
            if (it > 1000000000) None
            else Some(it)
          }
        }, t)
        case _ ⇒ None
      }
    }
  }
  object Num{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case h::t if h.isDigit ⇒ Some(h.asDigit, t)
        case _ ⇒ None
      }
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44308
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N;
  cin>>N;
  vi A(N);
  int total=0;
  rep(i,0,N){
    cin>>A[i];
    total+=A[i];
  }
  int ans;
  int sum=0;
  rep(i,0,N){
    sum+=A[i];
    if(sum>=total/2){
      ans=min(sum*2-total,total-(sum-A[i])*2);
      break;
    }
  }
  cout<<ans;
  }


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;

int main(void){
    string input_line;
    input_line.reserve(1200);
    getline(cin,input_line);

    string output_line;
    output_line.reserve(1200);

    for(auto str : input_line){
        if(isalpha(str)){
            if(isupper(str))
                output_line += tolower(str);
            else
                output_line += toupper(str);
            continue;
        }
        output_line += str;
    }

    cout << output_line << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   LL n, m; cin >> n >> m;
   vector<LL> A(n);
   for (int i = 0; i < n; ++i) {
      cin >> A[i];
   }

   vector<LL> B(m), C(m);
   for (int i = 0; i < m; ++i) {
      cin >> B[i] >> C[i];
   }

   map<LL,LL> cnt;
   for (int i = 0; i < n; ++i) {
      ++cnt[A[i]];
   }
   for (int i = 0; i < m; ++i) {
      cnt[C[i]] += B[i];
   }

   LL ans = 0;
   for (auto it = cnt.rbegin(); it != cnt.rend(); ++it) {
      if (n == 0) {
         break;
      }
      ans += it->first * min(it->second, n);
      n -= min(it->second, n);
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    long long A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    rep(i, A) cin >> a.at(i);
    rep(i, B) cin >> b.at(i);
    int min_a = 9999999;
    int min_b = 9999999;
    for (int i = 0; i < A;i++){
        if(a.at(i)<min_a)
            min_a = a.at(i);
    }
    for (int i = 0; i < B;i++){
        if(b.at(i)<min_b)
            min_b = b.at(i);
    }
    int min = min_a + min_b;
    for (int i = 0; i < M;i++){
        int x, y, c;
        cin >> x;
        cin >> y ;
        cin >> c;
        int x_a = a.at(x-1) ;
        int y_b = b.at(y-1) ;
        if(x_a+y_b-c<min){
            min = x_a + y_b - c;
        }
    }
        cout << min<< endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	char a[500];
	char b[500];
	scanf("%s%s",a,b);
	int x;
	int y;
	x=strlen(a);
	y=strlen(b);
	sort(a,a+x);
	sort(b,b+y,cmp);
	//cout<<a<<endl<<b<<endl;
	for(int i=0;i<(x>y?y:x);i++)
	{
		if(a[i]>b[i])
		{
			printf("No\n");
			return 0;
		}
		else
			if(a[i]<b[i])
			{
				printf("Yes\n");
				return 0;
			}
		
	}
		if(x>=y)
			printf("No\n");
		else
		{
			printf("Yes\n");
		}
	
	return 0;
}

Measured memory_bytes: 256