akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define mod (1000000007)
signed main(){
  int n,b,sum=0;
  vector<int> a;
  int c={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    a.push_back(b);
    c+=b;
  }
  for(int i=0;i<n-1;i++){
    sum+=(((c-a[i])%mod)*a[i]);
    c-=a[i];
    sum%=mod;
  }
  cout<<sum<<"\n";
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

#define ll int

const ll MAXK=4e3+10;

ll a[MAXK][MAXK];
ll c[MAXK][MAXK];

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

	ll n , k , ans=0;
	cin>>n>>k;

	for(ll i=1;i<=n;i++)
    {
        ll x , y;
        cin>>x>>y;

        char c;
        cin>>c;

        x%=(2*k);
        y%=(2*k);

        if (c=='W')
        {
            x=2*k-x;
            x%=(2*k);

            y=2*k-y;
            y%=(2*k);
        }

        if (c=='B')
        {
            x=3*k-x;
            x%=(2*k);

            y=2*k-y;
            y%=(2*k);
        }

        a[2*k+x][2*k+y]++;
        a[2*k+x][k+y]--;
        a[k+x][2*k+y]--;
        a[k+x][k+y]++;
    }

    for(ll i=MAXK-1;i>=0;i--)
    {
        for(ll j=MAXK-1;j>=0;j--)
        {
            if (i<MAXK-1)
            {
                a[i][j]+=a[i+1][j];
            }

            if (j<MAXK-1)
            {
                a[i][j]+=a[i][j+1];
            }

            if (i<MAXK-1 && j<MAXK-1)
            {
                a[i][j]-=a[i+1][j+1];
            }

            ll x=i , y=j;

            x%=(2*k);
            y%=(2*k);

            if (x>=k && y>=k)
            {
                x-=k;
                y-=k;
            }

            if (x<k && y>=k)
            {
                x+=k;
                y-=k;
            }

            c[x][y]+=a[i][j];
        }
    }

    for(ll i=0;i<MAXK;i++)
    {
        for(ll j=0;j<MAXK;j++)
        {
            ans=max(ans , c[i][j]);
        }
    }

    cout<<ans;
}


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

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

int main(){
    int N;
    cin >> N;
    vector<pair<ll, int>> p(N);

    rep(i, N){
        int a;
        cin >> a;
        p[i] = make_pair(a, i+1);
    }

    //昇順にソート
    sort(p.begin(), p.end());

    vector<ll> sum(N+1, 0);
    for(int i = 1; i < N+1; i++){
        sum[i] = sum[i-1] + p[i-1].first;
    }

    int val = N-1;
    for(int i = N-1; i >= 1; i--){
        if(sum[i]*2 >= p[i].first) val = i;
        else break;
    }

    int ans = N-val+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5544
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll num(26, 100000000);
  re(i, n){
    string t;std::cin >> t;
    vll tmp(26, 0);
    re(j, t.size()) tmp[t[j]-'a']++;
    re(j, 26) num[j] = min(num[j], tmp[j]);
  }
  string ans = "";
  re(i, 26){
    re(j, num[i]) ans+='a' + i;
  }
  std::cout << ans << '\n';
  return 0;
}


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

typedef long long ll;

 
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> G[n];
  vector<int> d(n, -1);
  d[0] = 0;
  queue<int> que;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
    if(a==0){
      d[b] = 1;
      que.push(b);
    }
    if(b==0){
      d[a] = 1;
      que.push(a);
    }
  }
  while(!que.empty()){
    int next = que.front(); que.pop();
    for(int i=0; i<G[next].size(); i++){
      d[G[next][i]] = 2;
    }
  }
  string ans;
  if(d[n-1] != -1) ans = "POSSIBLE";
  else ans = "IMPOSSIBLE";
  cout << ans << endl;
  return 0;
}


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

int main() {
	vector<int> x(5);
	int ans = 0;
	
	for (int i = 0; i < 5; i++) {
		cin >> x.at(i);
		if (x.at(i) == 0) {
			ans = i + 1;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//temmie_のsnippet

#define N 200009

int main() {
	char s[N], t[N];
	scanf("%s%s", s, t);
	int ans = 0, l = strlen(s);
	rep(i,l)if(s[i]!=t[i])ans++;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 2116
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, k;
  cin >> n >> k;
  if (n%k==0) cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1000050,mo=1e9+7;
int fap(int a,int b){
    int s=1;
    for (; b; b>>=1,a=1ll*a*a%mo)
	if (b&1) s=1ll*s*a%mo;
    return s;
}
int ml[N],np[N],f[N];
int C(int n,int m){
    if (n<m) return 0;
    return 1ll*ml[n]*np[m]%mo*np[n-m]%mo;
}
int main(){
    int n; cin>>n;
    ml[0]=np[0]=1;
    for (int i=1; i<=n; ++i) ml[i]=1ll*i*ml[i-1]%mo;
    np[n]=fap(ml[n],mo-2);
    for (int i=n-1; i>=1; --i) np[i]=1ll*(i+1)*np[i+1]%mo;
    for (int i=1; i<n; ++i) f[i]=1ll*C(i-1,n-i-1)*ml[i]%mo*ml[n-i-1]%mo;
    for (int i=n-1; i>1; --i) f[i]=(mo+f[i]-f[i-1])%mo;
    int ans=0;
    for (int i=1; i<=n; ++i) (ans+=1ll*i*f[i]%mo)%=mo;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11904
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    cout << N*(N+1) / 2 << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut s = vec![0; n];
    for i in 0..k {
        input! {
            d: usize,
            a: [usize; d],
        }
        for p in a.iter() {
            s[p - 1] = 1;
        }
    }

    println!("{}", s.iter().filter(|&c| *c == 0).count());
}


Measured memory_bytes: 2176
package main

import (
        "fmt"
)

type node struct {
        n   int
        cnt int
}

func main() {
        var n int
        fmt.Scan(&n)

        v := []int{1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049}
        q := []node{node{n, 0}}
        m := map[int]int{}
        for len(q) > 0 {
                var nd node
                nd, q = q[0], q[1:]
                if nd.n == 0 {
                        fmt.Println(nd.cnt)
                        return
                }
                for i := range v {
                        if nd.n-v[i] < 0 {
                                continue
                        }
                        if cnt, ok := m[nd.n-v[i]]; ok && cnt == nd.cnt+1 {
                                continue
                        }
                        m[nd.n-v[i]] = nd.cnt + 1
                        q = append(q, node{nd.n - v[i], nd.cnt + 1})
                }
        }
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int N , M;
cin >> N >> M;
vi a(M),b(M);
rep(m,M) cin >> a[m] >> b[m];

rrep(n,N) {
    int cnt = 0;
    rep(m,M) {
        if(n == a[m] || n == b[m]) cnt++;
    }
    cout << cnt << endl;
}

return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(usize, usize); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(usize, usize)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < vw[0].1 { 0 } else { vw[0].0 as u32 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 as u32 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(usize, usize)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 as u32 };
        max(pv1, pv2)
    }
}


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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	Rep(i, n) cin >> a[i];
	sort(All(a));
	cout << a[n-1] << " ";
	int ans = a[0];
	Rep(i, n-1) {
		if ( abs(a[n-1]/2 - ans) >= abs(a[n-1]/2 - a[i]) ) ans = a[i]; 
	}

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


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
const ll N = 1e7 + 10;
const int M = 1e9 + 7;
const double eps = 1e-9;

bool cmp(int a, int b) {
    return abs(a) > abs(b);
}

int main() {
    int n, k;
    cin >> n >> k;
    vll v(n);
    int ng = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        ng += v[i] < 0;
    }
    if (n == k) {   // need to choose everything
        ll ans = 1;
        for (int i = 0; i < n; ++i) {
            ans = (ans * ((v[i] + M) % M)) % M;
        }
        cout << ans << endl;
        return 0;
    }
    if (ng == n) {//all negative
        sort(all(v));
        ll ans = 1;
        if (k % 2)
            reverse(all(v));
        for (int i = 0; i < k; ++i) {
            ans = (ans * (v[i] + M)) % M;
        }
        cout << ans << endl;
        return 0;
    }
    sort(all(v), cmp);
    vll pos, neg;
    for (int i = 0; i < n; ++i) {
        if (v[i] >= 0)
            pos.push_back(v[i]);
        else neg.push_back(v[i] * (-1));
    }
    sort(all(pos), greater<ll>());
    sort(all(neg), greater<ll>());
    ll posPrefix[pos.size()], negPrefix[neg.size()];
    for (int i = 0; i < pos.size(); ++i) {
        posPrefix[i] = (i == 0 ? pos[0] : (posPrefix[i - 1] * pos[i]) % M);
    }
    for (int i = 0; i < neg.size(); ++i) {
        negPrefix[i] = (i == 0 ? neg[0] : (negPrefix[i - 1] * neg[i]) % M);
    }
    ll ans = -1;
    for (int i = 2; i <= neg.size() && i <= k; i += 2) {
        int j = k - i;
        ll nm = neg[i - 1] * neg[i - 2];
        if (j > pos.size())
            continue;
        if (j + 2 > pos.size()) {
            ans = (posPrefix[j - 1] * negPrefix[i - 1]) % M;
            continue;
        }
        ll pm = pos[j] * pos[j + 1];
        if (nm <= pm)
            break;
        if (j)
            ans = (posPrefix[j - 1] * negPrefix[i - 1]) % M;
        else ans = negPrefix[i - 1];
    }
    if (ans == -1)
        ans = posPrefix[k - 1];
    cout << ans << endl;
}


Measured memory_bytes: 7968
count = int(raw_input())
S = []
H = []
C = []
D = []

while count:
  arr = map(str, raw_input().split(" "))
  if arr[0] == "S":
    S.append(int(arr[1]))
  elif arr[0] == "H":
    H.append(int(arr[1]))
  elif arr[0] == "C":
    C.append(int(arr[1]))
  else:
    D.append(int(arr[1]))
  count -= 1

S.sort()
H.sort()
C.sort()
D.sort()

ans_s = []
ans_h = []
ans_c = []
ans_d = []

for x in range(1, 14):
  if not x in S:
    ans_s.append(x)
  if not x in H:
    ans_h.append(x)
  if not x in C:
    ans_c.append(x)
  if not x in D:
    ans_d.append(x)

def answer(arr, value):
  for x in arr:
    print "%s %s" % (value, str(x))

answer(ans_s, 'S')
answer(ans_h, 'H')
answer(ans_c, 'C')
answer(ans_d, 'D')

Measured memory_bytes: 4288
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

static const int MAX_BUCKET = 1000;
vector<int> bucket[MAX_BUCKET];

int compute_dist(int dist,int lhs,int rhs){
  return min(dist-abs(lhs-rhs),abs(lhs-rhs));
}

int main(){
  int total_dist,store_num,order_num;
  while(~scanf("%d",&total_dist)){
    if(total_dist == 0) break;
    scanf("%d",&store_num);
    scanf("%d",&order_num);

    vector<int> store;
    store.push_back(0);
    for(int i=0;i<store_num-1;i++){
      int num;
      scanf("%d",&num);
      store.push_back(num);
    }
    sort(store.begin(),store.end());

    int cost = 0;
    for(int i=0;i<order_num;i++){
      int num;
      scanf("%d",&num);

      int idx = lower_bound(store.begin(),store.end(),num) - store.begin();
      int min_dist = compute_dist(total_dist,store[idx],num);
      
      for(int j=idx-1;j>=0;j--){
	min_dist = min(min_dist,compute_dist(total_dist,store[j],num));
      }
      cost += min_dist;
    }
    printf("%d\n",cost);
  }
}

Measured memory_bytes: 1732
#include<stdio.h>

static const int N = 1000;

void Sort(int *A,int n){

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

int main(){
  int n,i,j=0,key;
  int A[N+1];
  scanf("%d",&n);

  for(i=1; i<=n;i++)
    scanf("%d",&A[i]);

  Sort(A,n);
  

  for(i =2 ; i<=n;i++){
        
    key = A[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1;
    while (j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
      Sort(A,n); 
  }
  return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    ll count = 0;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=0;i<n-1;++i){
        count += a[i]/2;
        a[i] %= 2;
        int num = min(a[i],a[i+1]);
        a[i] -= num;
        a[i+1] -= num;
        count += num;
    }
    count += a[n-1]/2;
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main ()
{
    long long k,n,a,ap,ma=-1,p;
    cin>>k>>n;
    cin>>ap;
    p=ap;
    for (long long i=1;i<n;i++) {
        cin>>a;
        ma=max(ma,a-ap);
        ap=a;
    }
    cout<<k-max(ma,k-a+p);
    return 0;
}
//trpr

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;



int main()
{
    int h,w;
    cin>>h>>w;
    vector< vector<int>> c(10,vector<int>(10));
    vector< vector<int>> a(h,vector<int>(w));
    rep(i,10)
    {
        rep(j,10)
        {
            cin>>c[i][j];
        }
    }
    rep(i,h)
    {
        rep(j,w)
        {
            cin>>a[i][j];
        }
    }
        rep(k,10)rep(i,10)rep(j,10)if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];

    ll ans=0;
    rep(i,h)
    {
        rep(j,w)
        {
            if(a[i][j]==-1)continue;
            if(a[i][j]!=1)
            {
                ans+=c[a[i][j]][1];
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()

using namespace std;

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

  if(A%2==1 && B%2==1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

string s, t, pat;
int ans[10000000];

vector <int> build_fail(const string &p) {
	int len = (int)p.size(), j = -1;
	vector <int> fail(len + 1, 0); fail[0] = -1;
	for (int i = 1; i <= len; fail[i++] = ++j)
		while (j >= 0 && p[j] != p[i - 1]) j = fail[j];
	return fail;
}
vector <int> kmp_match(const string &t, const string &p, const vector <int> &fail) {
	int n = (int)t.size(), m = (int)p.size();
	vector <int> len(n, 0);
	for (int i = 0, j = 0; i < n; ++i) {
		while (j >= 0 && p[j] != t[i]) j = fail[j];
		len[i] = ++j;
	}
	return len;
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s >> t, pat = s;
	int n = (int)s.size(), m = (int)t.size();
	int exsize = n + m << 1;
	while ((int)s.size() < exsize) s += pat;
	s += pat, n = (int)s.size();
	vector <int> len = kmp_match(s, t, build_fail(t));
	for (int i = n - 1; ~i; --i)
		if (len[i] == m) ans[i - m + 1] = max(ans[i - m + 1], ans[i + 1] + 1);
	int res = *max_element(ans, ans + n + 1);
	if (res >= n / m - 2) return puts("-1") & 0;
	cout << res << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
		
		string str;
		cin >> str;
		
		if (str == "ABC")
			cout << "ARC\n";
		else
			cout << "ABC\n";
    
	//code
	return 0;
}


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

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

    for(int i = 0; i < 2 * n + 1; ++i) {
        if (s.substr(i) == t.substr(0, n - i)) {
            cout << n + i << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
    return 0;
}



Measured memory_bytes: 256
def findnumberofTriangles(arr): 
	n = len(arr) 
	arr.sort() 
	count = 0
	for i in range(0, n-2):  
		k = i + 2 
		for j in range(i + 1, n):  
			while (k < n and arr[i] + arr[j] > arr[k]): 
				k += 1
			if(k>j): 
				count += k - j - 1

	return count 

n = int(input())
arr=[int(x) for x in input().split()]
print(findnumberofTriangles(arr))



Measured memory_bytes: 9272
from math import floor
def Main(A, B, N):
    if N < B:
        return floor(A*N/B)-A*floor(N/B)
    else:
        return floor(A*(B-1)/B)-A*floor((B-1)/B)

def main():
    A, B, N =map(int, input().split()) 
    print(Main(A, B, N))

if __name__ == '__main__':
    main()

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

#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

int f(int n)
{
    if (n % 2 == 0)
    {
        return n / 2;
    }
    else
    {
        return 3 * n + 1;
    }
}

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

    int N, tmp, max, total;
    cin >> N;
    max = 0;
    total = 0;
    REP(i, N)
    {
        cin >> tmp;
        if (max < tmp)
        {
            max = tmp;
        }
        total += tmp;
    }
    cout << total - (max / 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<string,int>P;
typedef pair<P,int>Q;
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   Q d[101];
   cin>>n;
   FOR(i,n){
     cin>>d[i].F.F>>d[i].F.S;
     d[i].S=i+1;
   }
   sort(d,d+n);
   FOR(i,n){
     FOR(j,n-1-i){
       if(d[j].F.F==d[j+1].F.F && d[j].F.S<d[j+1].F.S){
         swap(d[j],d[j+1]);
       }
     }
   }
   FOR(i,n){
     cout<<d[i].S<<endl;
   }
   return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

double T, X;

int main() {
    cin >> T >> X;
    cout << T / X << "\n";
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

int main() {
  int H, W, A, B;
  string S[1000];

  cin >> H >> W >> A >> B;
  int sy, sx;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
    for(int j = 0; j < W; j++) {
      if(S[i][j] == 's') {
        sy = i;
        sx = j;
      }
    }
  }
  using pi = pair< int, int >;
  using pii = pair< int64, pi >;
  priority_queue< pii, vector< pii >, greater< pii > > que;
  int64 v[1000][1000];
  fill_n(*v, 1000 * 1000, INF);
  que.emplace(0, pi(sy, sx));
  v[sy][sx] = 0;
  const int vy[] = {0, -1, 0, 1};
  const int vx[] = {1, 0, -1, 0};
  while(que.size()) {
    auto cost = que.top().first;
    auto p = que.top().second;
    que.pop();
    if(v[p.first][p.second] > cost) {
      continue;
    }
    if(S[p.first][p.second] == 'g') {
      cout << cost << endl;
      return 0;
    }
    for(int i = 0; i < 4; i++) {
      int ny = p.first + vy[i], nx = p.second + vx[i];
      if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if(S[ny][nx] == '#') continue;
      if(v[ny][nx] <= cost + A) continue;
      v[ny][nx] = cost + A;
      que.emplace(v[ny][nx], pi(ny, nx));
    }
    bool all = true;
    for(int i = -1; i <= 1; i++) {
      for(int j = -1; j <= 1; j++) {
        int ny = p.first + i, nx = p.second + j;
        if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
        if(S[ny][nx] == '*') all = false;
      }
    }
    if(all) {
      for(int i = -1; i <= 1; i++) {
        for(int j = -1; j <= 1; j++) {
          int ny = p.first + i, nx = p.second + j;
          if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
          int64 nxt_cost = cost + B + (abs(i) + abs(j)) * A;
          if(v[ny][nx] <= nxt_cost) continue;
          v[ny][nx] = nxt_cost;
          que.emplace(v[ny][nx], pi(ny, nx));
        }
      }
    }
  }
  cout << "INF" << endl;
}



Measured memory_bytes: 11912
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

ll d[100001];
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		d[a[i]]++;
		sum+=a[i];
	}
	ll q;
	cin>>q;
	ll b,c;
	for(ll i=0; i<q; i++){
		cin>>b>>c;
		if(d[b]>0){
			ll flag=d[b]*b;
			sum-=flag;
			d[c]+=d[b];
			sum+=c*d[b];
			d[b]=0;
		}
		cout<<sum<<endl;
	}
}


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

const ll INF = 2 * 1e9;

main() {
  int N; cin >> N;
  ll x = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    x += a[i];
  }
  ll y = 0;
  ll diff = INF;
  for (int i = N - 1; i > 0; i--) {
    x -= a[i];
    y += a[i];
    diff = min(diff, abs(x - y));
  }
  cout << diff << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
void solve(){
    long double a,b;
    cin>>a>>b;
    long  double c=a*b;
    ull d=c;
    cout<<d;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


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

int main() {
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  for(int j = 0; j < N; j++){
    cout << S.at(j) << T.at(j);
  }
  return 0;
}


Measured memory_bytes: 3576
def solve():
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    ans = float('inf')
    for i in range(n):
        if i + 1 >= k:
            l = a[i - k + 1]
            r = a[i]
            ans = min(ans, r - l + min(abs(l), abs(r)))
    print(ans)

solve()

"""
5 6
4 7 9 3 4
"""

Measured memory_bytes: 20136
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

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

inline ull min(ull x, ull y) {
	if (x < y) return x;
	return y;
}

ull n, a, b;
int main() {
	cin >> n >> a >> b;
	ull p = a + b;
	cout << n / p * a + min(n % p, a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
struct Edge
{
    int to,next;
}edge[maxn<<1];
int head[maxn],tot;
void init()
{
    memset(head,-1,sizeof(head));
    tot=0;
}
void addedge(int u,int v)
{
    edge[tot].to=v;
    edge[tot].next=head[u];
    head[u]=tot++;
}
int siz[maxn];
bool ok=true;
int n;
void dfs(int u,int pre)
{
    siz[u]=1;
    int cnt=0;
    for(int i=head[u];~i;i=edge[i].next)
    {
        int v=edge[i].to;
        if(v==pre) continue;
        dfs(v,u);
        if(siz[v]&1) ++cnt;
        siz[u]+=siz[v];
    }
    if((n-siz[u])&1) ++cnt;
    if(cnt>1) ok=false;
}
int main()
{
    scanf("%d",&n);
    init();
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    dfs(1,-1);
    if(ok) puts("Second");
    else puts("First");
    return 0;
}


Measured memory_bytes: 2688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        String S = in.next();
        char[] cc = S.toCharArray();
        int Q = in.nextInt();
        ArrayList<TreeSet<Integer>> list = new ArrayList<TreeSet<Integer>>();
        for (int i=0;i<26;i++) {
            TreeSet<Integer> add = new TreeSet<Integer>();
            list.add(add);
        }
        for (int i=0;i<N;i++) {
            list.get((int)cc[i]-97).add(i);
        }
        // System.out.println(list);
        for (int q=0;q<Q;q++) {
            int num = in.nextInt();
            if (num==1) {
                int i = in.nextInt()-1;
                char c = in.next().charAt(0);
                list.get((int)cc[i]-97).remove(i);
                list.get((int)c-97).add(i);
                cc[i] = c;
            } else { // num==2
                int l = in.nextInt()-1;
                int r = in.nextInt()-1;
                int ans = 0;
                for (int i=0;i<26;i++) {
                    if (list.get(i).higher(l-1)!=null && list.get(i).lower(r+1)!=null) {
                        int low = list.get(i).higher(l-1);
                        int high = list.get(i).lower(r+1);
                        // out.println("char, low, high: "+(char)(i+97)+" "+low+" "+high);
                        // if (low==high) ans++;
                        if (l<=low && l<=high && low<=r && high<=r) ans++;
                    }
                }
                out.println(ans);
            }
        }
        // out.println(list);

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 101464
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  string s; cin >> s;
  for(int i=0; i<s.size(); i++) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

// EOF


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int a[5], b[5];
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	bool turn = 1;
	while(a > 0 && c > 0)
	{
		if (turn) c -= b;
		else a -= d;
		turn = !turn;
	}
	if (turn) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

int gcd(int X,int Y){
    int x=min(X,Y);
    int y=max(X,Y);
    int r=y%x;
    while(r!=0){
        y=x;
        x=r;
        r=y%x;
    }
    return x;
}

int main() {
    int N,X; cin>>N>>X;
    if(N==1){
        int c;
        cin>>c;
        cout<<abs(X-c)<<endl;
        return 0;
    }
    vector<int>y(N+1,X);
    rep(i,N) cin>>y[i];
    sort(y.begin(),y.end());
    vector<int>yy(N);
    rep(i,N){
        yy[i]=y[i+1]-y[i];
    }
    sort(yy.begin(),yy.end());
    int a=gcd(yy[0],yy[1]);
    for(int i=2;i<N;i++){
        a =gcd(a,yy[i]);
    }
    cout<<a<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int ctoi(char c){
    switch (c)
    {
    case '0':
        return 0;
        break;
    case '1':
        return 1;
        break;
    case '2':
        return 2;
        break;
    case '3':
        return 3;
        break;
    case '4':
        return 4;
        break;
    case '5':
        return 5;
        break;
    case '6':
        return 6;
        break;
    case '7':
        return 7;
        break;
    case '8':
        return 8;
        break;
    case '9':
        return 9;
        break;

    default:
        return -1;
        break;
    }
}

int main(){

    string n;
    cin>>n;

    int ans=0;
    rep(i,n.length()){
        ans=ans+ctoi(n[i]);
    }

    if(ans%9==0)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

Measured memory_bytes: 3720
#include"bits/stdc++.h"
using namespace std;
int main(){
	string s;
	cin>>s;
	bool ch=false;
	for(int i=0;i!=s.size()-1;++i){
		if(s.substr(i,2)=="AC")
			ch=true;
	}
	cout<<(ch ? "Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main(int argc, char* argv[]) {
    std::string line;
    std::getline(std::cin, line);
    size_t text_size = 0;
    size_t q_size = 0;
    std::istringstream iss(line);
    iss >> text_size;
    iss >> q_size;

    std::string text;
    std::getline(std::cin, text);

    size_t count = 0;
    std::vector<size_t> counts;
    counts.push_back(0);

    for(size_t i=1; i<text_size; ++i) {
        size_t found = !!(text[i-1] == 'A' && text[i] == 'C');
        count += found;
        counts.push_back(count);
    }

    for(size_t i=0; i<q_size; ++i) {
        std::getline(std::cin, line);
        std::istringstream iss(line);
        size_t left = 0;
        size_t right = 0;
        iss >> left;
        iss >> right;
        size_t answer = counts.at(right - 1) - counts.at(left - 1);
        std::cout << answer << "\n";
    }
    return 0;
}


Measured memory_bytes: 1908
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] x = new int[n][d];
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		
		int res = 0;
		
		for(int i = 0; i < n; i++) { //1番目
			for(int j = 0; j < n; j++) { //2番目
				if(i != j && i < j) {
					
					int sum = 0;
					
					for(int a = 0; a < d; a++) {
						sum+=Math.pow(Math.abs(x[i][a] - x[j][a]), 2);
					}

					if(Math.sqrt(sum) % 1 == 0) res++;
					
				}
			}
		}
		
		out.println(res);
		
	}

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

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}

		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22100
'use strict'

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  let line1 = input[0].split(" ");
  console.log(line1[1] + line1[0]);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>

int main(void){
   int n,m,c,i,j;
   static int a[100][100],b[100];

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

   for(i=0;i<n;i++){
      for(j=0;j<m;j++){
         scanf("%d", &a[i][j]);
      }
   }

   for(i=0;i<m;i++){
      scanf("%d", &b[i]);
   }

   for(i=0;i<n;i++){
     c=0;
      for(j=0;j<m;j++){
         c += a[i][j]*b[j];
      }
      printf("%d\n", c);
   }
   return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int mo=1e9+7;
#define rep(i, n) for (int i = 0; i < n; i++)
int u[55];
ll dp[55];
char in[2][55];
vector<int> v;
void solve()
{
    int n,i,j;
    scanf("%d%s%s",&n,in[0],in[1]);
    for(i=0;i<n;)
    {
        if(i+1==n||in[0][i]==in[1][i])
        {
            v.emplace_back(1);
            i++;
        }
        else
        {
            v.emplace_back(2);
            i+=2;
        }
    }
    dp[0]=6;
    if(v[0]==1)dp[0]=3;
    for(i=1;i<v.size();i++)
    {
        if(v[i]==1&&v[i-1]==1)dp[i]=dp[i-1]*2%mo;
        if(v[i]==1&&v[i-1]==2)dp[i]=dp[i-1];
        if(v[i]==2&&v[i-1]==1)dp[i]=dp[i-1]*2%mo;
        if(v[i]==2&&v[i-1]==2)dp[i]=dp[i-1]*3%mo;
    }
    printf("%lld\n",dp[v.size()-1]);
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
MOD=10**9+7

S=input()
old=[0]*13
old[0]=1
n=1
for c in S:
  dp=[0]*13
  if c=='?':
    for j in range(10):
      for i in range(13):
        dp[(i*10+j)%13]+=old[i]
        dp[(i*10+j)%13]%=MOD
  else:
    c=int(c)
    for i in range(13):
      dp[(i*10+c)%13]+=old[i]
      dp[(i*10+c)%13]%=MOD
  old=[i for i in dp]
print(dp[5])

Measured memory_bytes: 74552
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;

	int N; cin >> N;

	long A[10][1000]; for (int i = 0; i <= 1; i++) for (int j = 0; j <= N - 1; j++) cin >> A[i][j];

	long S[10][1000]; S[0][0] = A[0][0]; S[1][0] = A[0][0] + A[1][0];

	for (int i = 1; i <= N - 1; i++) S[0][i] = S[0][i - 1] + A[0][i];
	for (int i = 1; i <= N - 1; i++) S[1][i] = max(S[0][i], S[1][i - 1]) + A[1][i];

	res = S[1][N - 1];

	cout << res << endl;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]
    s.sort(reverse=True)
    al = [False]*(2**n)
    al[0] = True
    for i in range(n):
        usd = deque()
        cnt = 2**i
        for j,sj in enumerate(s):
            if al[j]:
                usd.append(sj)
            elif usd[0] > sj:
                usd.popleft()
                al[j] = True
                cnt -= 1
                if not cnt:
                    break
        if cnt != 0:
            print("No")
            exit()
    print("Yes")



if __name__ == '__main__':
    main()


Measured memory_bytes: 107072
#include <bits/stdc++.h>
using namespace std;
map<string,int> memo;
int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    memo[s]++;
  }
  int max=0;
  for(const auto& x:memo){
    int v =x.second;
    if(v>max)max=v;
  }
  for(auto it=memo.begin();it !=memo.end();it++){
    if(it->second==max){
      cout<< it->first <<endl;
    }
  }
}




Measured memory_bytes: 25216
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,a,b,c,d,e; cin >> n >> a >> b >> c >> d >> e;
  ll mintime = min({a,b,c,d,e});
  
  cout << 4 + (n + mintime-1)/mintime << endl;
  
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n)
	{
		ll tmp;
		cin >> tmp;
		ans += tmp - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256