akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<string.h>

int main(void) {
  char a[3];
  scanf("%s",a);
  int count;
  if(a[0]=='S' && a[1]=='S' && a[2]=='S')
  count=0;
  else
  { count=1;
  for(int i=0;i<3;i++)
  {
    if(a[i]=='R')
    {
      if(a[i+1]=='R' && i!=2)
      count++;
    }

  }}
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1724
import sys
input = sys.stdin.readline

def main():
    a, b = input().split()
    c, d = b.split(".")
    if len(d) == 1:
        d = d + '0'
    
    p, q = int(a), int(c) * 100 + int(d)
    ans = p * q // 100

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


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, ans;
int main () {
	IOS;
	
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += (a[i] * a[j]);
		}
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

int main() {

    int n;
    cin >> n;
    int p[n];
    int c = 1;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int m = p[0];
    for(int i = 1; i < n; i++){
        if(p[i]<m){
            c++;
            m = p[i];
        }
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 4332
N=int(input())
As = list(map(int,input().split()))

MAX=10**18
ans = 1
fover=False
fzero=False
for A in As:
    if A==0:
        fzero=True
        break
    if not fover:
        ans *= A
        if ans > MAX:
            fover=True

if fzero:
    print(0)
elif fover:
    print(-1)
else:
    print(ans)

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

int main(void){
    int n,ans = 0;
    cin >> n;
    vector<int> d(n+1);
    for(int i = 0;i < n;i++)cin >> d[i];
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n+1;j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x,y,z,k = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = map(int, raw_input().split())
s = []
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
for ka in range(x):
    for kb in range(y):
			s.append(a[ka]+b[kb])
s.sort(reverse = True)
p = 3000
if(x * y < 3000):
	p = x * y
t = []
for n in range(p):
	for m in c:
		t.append(s[n] + m)
t.sort(reverse = True)
for n in range(k):
	print(t[n])

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

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

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


void solve(long long N){
    int ans = 1;
    int maxCnt = 1;
    for(int i = 1; i <= N; i++)
    {
        int cnt = 1;
        int temp = i;
        while(temp % 2  == 0){
            cnt++;
            temp /= 2;
        }
        
        if(cnt > maxCnt){
            maxCnt = cnt;
            ans = i;
        }
    }

    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cctype>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
    int counter[26]={0};
    char c;
    while(cin>> c ){
        if(isalpha(static_cast<unsigned char>(c))){
            if (isupper(c)){
                c=tolower(c);
            }
            int num =c- 'a';
            counter[num]++;
        }
    }
    char m;
    for (int i=0,m='a';m<='z',i<26;i++, ++m){
        printf("%c",m);
        cout<<" : "<< counter[i]<<endl; 
    }
    return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

string s,s1,s2;
int n;
int a;
int main() {
    cin >> s1 >> s2;
    s = s1+s2;
    n = atoi(s.c_str());
    rep(i,1,n+1){
        if(i*i == n){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

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

tmp=0
for i in range(n):
    j=i
    tmp=a[i]
    while a[j-1]>tmp and j>0:
        a[j]=a[j-1]
        j-=1
    a[j]=tmp
    print(*a)


Measured memory_bytes: 5976
import Control.Monad
import Data.List
main=do
 n<-readLn :: IO Int
 s<-replicateM n (words<$>getLine)
 let sn=map head s :: [String]
     sv=map read (map last s):: [Int]
     ss=zip sn sv
     sp=zip ss [1..n]
     sq=sortBy(\x y->let p=fst(fst x);q=fst(fst y);pp=snd(fst x);qq=snd(fst y) in if p<q||(p==q&&pp>qq) then LT else if p>q||(p==q&&pp<qq) then GT else EQ)sp
 mapM_ print$map snd sq

Measured memory_bytes: 1020
import sys


class SegTreeMax:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        n2 = 1 << (n - 1).bit_length()
        self.offset = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    @classmethod
    def from_array(cls, arr, INF):
        ins = cls(len(arr), INF)
        ins.tree[ins.offset:ins.offset + len(arr)] = arr
        for i in range(ins.offset - 1, 0, -1):
            l = i << 1
            r = l + 1
            ins.tree[i] = max(ins.tree[l], ins.tree[r])
        return ins

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.offset
        self.tree[i] = x
        while i > 1:
            y = self.tree[i ^ 1]
            if y >= x:
                break
            i >>= 1
            self.tree[i] = x

    def get_max(self, a, b):
        """
        [a, b)の最大値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        l = a + self.offset
        r = b + self.offset
        while l < r:
            if r & 1:
                result = max(result, self.tree[r - 1])
            if l & 1:
                result = max(result, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1

        return result


n, k, *aaa = map(int, sys.stdin.buffer.read().split())

sgt = SegTreeMax(300001, 0)
for a in aaa:
    nxt = sgt.get_max(max(0, a - k), min(a + k + 1, 300001))
    sgt.update(a, nxt + 1)
print(sgt.get_max(0, 300001))


Measured memory_bytes: 137212
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ld A,B;
    cin >> A >> B;
    ll ans = A*B+EPS;

    // resolve

    // output
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_NUM = 1000000000;
 
int main(){
    int N, K, S;
    cin >> N >> K >> S;

    for(int i=0;i<K;i++){
        if(i!=0)
            cout << ' ';
        cout << S;
    }

    for(int i=0;i<N-K;i++){
        if(K!=0 || i!=0)
            cout << ' ';
        if(S == MAX_NUM)
            cout << MAX_NUM - 1;
        else
            cout << MAX_NUM;
    }
    cout << endl;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
using namespace std;
int main(){
    int a,b,c=1,ans=0;
    cin>>a>>b;
    while(c<b){
        c+=(a-1);
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,col1[605][605],col2[605][605];
vector<pair<int,int>>s[2];
void Init(int d,vector<pair<int,int>>&v){
    for(int i=0;i<=d;i++){
        int j=sqrt(d-i*i);
        if(i*i+j*j!=d)continue;
        v.emplace_back(+i,+j);
        v.emplace_back(+i,-j);
        v.emplace_back(-i,+j);
        v.emplace_back(-i,-j);
    }
}
void dfs(int x,int y,int c,vector<pair<int,int>>&v,int col[][605]){
    col[x][y]=c;
    for(auto d:v){
        int dx,dy;tie(dx,dy)=d;
        dx+=x,dy+=y;
        if(dx<0||dy<0||dx>=2*n||dy>=2*n)continue;
        if(!col[dx][dy])
            dfs(dx,dy,-c,v,col);
    }
}
void Solve(vector<pair<int,int>>&v,int col[][605]){
    for(int i=0;i<2*n;i++)
        for(int j=0;j<2*n;j++)
            if(!col[i][j])
                dfs(i,j,1,v,col);
}
int main(){
    int d1,d2;
    cin>>n>>d1>>d2;
    Init(d1,s[0]);
    Init(d2,s[1]);
    Solve(s[0],col1);
    Solve(s[1],col2);
    vector<pair<int,int>>ans;
    for(int i=0;i<2*n;i++)
        for(int j=0;j<2*n;j++)
            if(col1[i][j]==col1[0][0]&&col2[i][j]==col2[0][0])
                ans.emplace_back(i,j);
    for(int i=0;i<n*n;i++)
        cout<<ans[i].first<<" "<<ans[i].second<<"\n";
    return 0;
}

Measured memory_bytes: 33396
#define N 100001 
long p[N],r[N],n,m,i,b[N],a[N][2],c,d;int f(int x){if(p[x]==x)return x;return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y])p[x]=y;else p[y]=x;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){c=a[i][0],d=a[i][1];if(f(c)==f(d))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(c)]*r[f(d)];u(c,d);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
 	int n;
 	cin>>n;
 	int mi;
 	cin>>mi;
 	while(--n)
 	{
 		int d;
 		cin>>d;
 		if(mi>d){mi+=d;d=mi-d;mi-=d;}
 		while(d%mi)
 		{
 			d%=mi;
 			mi+=d;
 			d=mi-d;
 			mi-=d;
		 }
	 }
	 cout<<mi;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int P[N];
    for(int i = 0; i < N; i++){
        cin >> P[i];
    }
    int min = 1e8;
    int count = 0;
    for(int i = 0; i < N; i++){
        if(P[i] < min){
            count++;
            min = P[i];
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    int c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    if((c[0][0]-c[0][1] == c[1][0]-c[1][1] && c[1][0]-c[1][1] == c[2][0]-c[2][1])&&
       (c[0][1]-c[0][2] == c[1][1]-c[1][2] && c[1][1]-c[1][2] == c[2][1]-c[2][2])&&
       (c[0][0]-c[0][2] == c[1][0]-c[1][2] && c[1][0]-c[1][2] == c[2][0]-c[2][2])&&
       (c[0][0]-c[1][0] == c[0][1]-c[1][1] && c[0][1]-c[1][1] == c[0][2]-c[1][2])&&
       (c[1][0]-c[2][0] == c[1][1]-c[2][1] && c[1][1]-c[2][1] == c[1][2]-c[2][2])&&
       (c[0][0]-c[2][0] == c[0][1]-c[2][1] && c[0][1]-c[2][1] == c[0][2]-c[2][2])){
           cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for(int i = 0; i < N; i++){
        std::cin >> A.at(i);
    }

    int cnt = 0;
    for(;;){
        bool flag = true;
        for(int i = 0; i < N; i++){
            if(A.at(i) % 2 == 0){
                A.at(i) = A.at(i) / 2;
            }else{
                flag = false;
                break;
            }
        }
        if(!flag) break;
        cnt++;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
while 1:
        num=map(int,raw_input().split())
        if num==[0,0,0] : break
        hrz=[0 for i in range(num[1])]
        for i in range(num[1]):
                hrz[i]=map(int,raw_input().split())
        pps=[1001,num[2]]
        while pps!=[0,0]:
                lct,pps=pps,[0,0]
                for i in range(num[1]):
                        if pps[0]<hrz[i][0]<lct[0]:
                                if hrz[i][1]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][2]]
                                elif hrz[i][2]==lct[1]:
                                        pps=[hrz[i][0],hrz[i][1]]
        print lct[1]

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

int main() {
    int W, H, N;
    std::cin >> W >> H >> N;

    int x_l = 0;
    int x_r = W;
    int y_d = 0;
    int y_u = H;

    int x, y, a; 
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> y >> a;
        switch (a) {
        case 1: {
            x_l = std::max(x_l, x);
            break;
        }
        case 2: {
            x_r = std::min(x_r, x);
            break;
        }
        case 3: {
            y_d = std::max(y_d, y);
            break;
        }
        case 4: {
            y_u = std::min(y_u, y);
            break;

        }
        default: {
            break;
        }
        }
    }

    std::cout << std::max(0, (x_r - x_l)) * std::max(0, (y_u - y_d)) << std::endl; 

    return 0;
}


Measured memory_bytes: 256
///
// File:  1241.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 24 21:15:52 2017
//

#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    uint32_t val = sqrt(n);
    uint32_t count = 0;
    for (uint32_t i = 1; i <= val; i++) {
      for (uint32_t j = i; j <= val; j++) {
        for (uint32_t k = j; k <= val; k++) {
          for (uint32_t l = k; l <= val; l++) {
            if (n == i * i + j * j + k * k + l * l) {
              count += 1;
            }
          }
        }
      }
    }

    for (uint32_t i = 1; i <= val; i++) {
      for (uint32_t j = i; j <= val; j++) {
        for (uint32_t k = j; k <= val; k++) {
          if (n == i * i + j * j + k * k) {
            count += 1;
          }
        }
      }
    }

    for (uint32_t i = 1; i <= val; i++) {
      for (uint32_t j = i; j <= val; j++) {
        if (n == i * i + j * j) {
          count += 1;
        }
      }
    }

    if (n == val * val) {
      count++;
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int n, d; cin >> n >> d;
	int key = 2 * d + 1;
	if (n%key == 0) {
		cout << n / key << endl;
	}
	else {
		cout << n / key + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, ans = 0; cin >> n;

    for(int i = 1; i <= n; i+=2) {
        int count = 0;
        for(int j = 1; j <= i; ++j) {
            if(i % j == 0) ++count;
        }if(count == 8) ++ans;
    }cout << ans;
}


Measured memory_bytes: 256
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;  typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c))f|=c==45,c=getchar();
	while(isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}

const int maxn=5e5+5;
const int inf=0x3f3f3f3f;
vector<int> e[maxn];
int data[maxn],arc[maxn],dr[maxn],n,k;
int seg[maxn<<2],ans[maxn];
void pp(int pos){seg[pos]=min(seg[pos<<1],seg[pos<<1|1]);}
void add(int fr,int to){
	e[to].push_back(fr);++dr[fr];
	//fprintf(stderr,"<%d %d>\n",fr,to);
}

#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
int que(int L,int R,int l,int r,int pos){
	if(L>r||R<l) return inf;
	if(L<=l&&r<=R) return seg[pos];
	return min(que(L,R,lef),que(L,R,rgt));
}
void upd(int p,int v,int l,int r,int pos){
	if(p<l||p>r) return;
	if(l==r) return seg[pos]=v,void();
	upd(p,v,lef); upd(p,v,rgt);
	pp(pos);
}
#undef mid
#undef lef
#undef rgt

int main(){
	n=qr(); k=qr();
	for(int t=1;t<=n;++t) data[t]=qr(),arc[data[t]]=t;
	memset(seg,0x3f,sizeof seg);
	for(int t=n;t;--t){
		int t1=que(arc[t]-k+1,arc[t]-1,1,n,1);
		int t2=que(arc[t]+1,arc[t]+k-1,1,n,1);
		if(t1<=n) add(arc[t],arc[t1]);
		if(t2<=n) add(arc[t],arc[t2]);
		upd(arc[t],t,1,n,1);
	}
	static priority_queue<int> q;
	for(int t=1;t<=n;++t)
		if(!dr[t]) q.push(t);
	int cnt=0;
	while(q.size()){
		int now=q.top();
		ans[now]=++cnt;
		q.pop();
		for(auto t:e[now])
			if(--dr[t]==0)
				q.push(t);
	}
	for(int t=1;t<=n;++t) printf("%d\n",n-ans[t]+1);
	return 0;
}



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


#define ALL(a) 		(a.begin() , a.end())
#define ll 			long long int
#define ff          first
#define ss          second
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,a,b)   	for(ll i =a;i<=b;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
#define mat 		vector<vector<ll>>

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 //debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
 

const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
 
bool checkp2(ll n){
	return n && !(n & (n-1));
}

ll numsetbit(ll n){
	ll count = 0;
	for(;n;count++){
		n = n & (n-1);
	}
	return count;
}
 
ll power(ll x , ll n , ll mod){
    x = x % mod;
	ll po = 1;
	while(n){
		if(n & 1){
			po = (po*x) % mod;
		}
		n = n>>1;
		x = ((x % mod) * (x % mod)) % mod;
	}
	return po;
}
 
bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}



const ll mod = 1e9 + 7;



void solve(){

		ll n;
		cin>>n;
		vector<ll> a(n+10 , 0);
		ll sum = 0;
		for(ll i = 0;i<n;i++){
			cin>>a[i];
			if(i)
				sum+=a[i];

			sum %= mod;
		}

		ll answer = 0;

		for(ll i = 0;i<n;i++){

			answer += sum * a[i];
			answer %= mod;

			sum -= a[i+1];
			sum %= mod;
			sum += mod;
			sum %= mod;
		}
		cout<<answer<<endl;


}

int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 4732
from collections import deque
import sys

input = sys.stdin.buffer.readline

n, m = map(int, input().split())
graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
infi = 10 ** 10


def bfs(start):
    # res = 頂点数, サイクル最後の頂点、で持つ
    res = (infi, -1)
    dist = [-1] * (n + 1)
    par = [-1] * (n + 1)
    que = deque([])
    que.append(start)
    dist[start] = 0
    while que:
        v = que.popleft()
        for u in graph[v]:
            if dist[u] >= 0:
                continue
            dist[u] = dist[v] + 1
            par[u] = v
            que.append(u)
    for i in range(1, n + 1):
        if i == start:
            continue
        if dist[i] == -1:
            continue
        if start in graph[i]:
            if res[0] > dist[i] + 1:
                res = (dist[i] + 1, i)
    if res[0] == infi:
        return -1, []
    cycle_num = res[0]
    v = res[1]
    CYCLE = deque([])
    while v > 0:
        CYCLE.appendleft(v)
        v = par[v]

    return cycle_num, CYCLE


jisho = {}
ans = (-1, [])
cycle_num = infi
kouho_v = -1
for i in range(1, n + 1):
    temp_num, temp_cycle = bfs(i)
    if temp_num == -1:
        continue
    if cycle_num > temp_num:
        cycle_num = min(cycle_num, temp_num)
        kouho_v = i
        jisho[i] = temp_cycle

if kouho_v == -1:
    print(-1)
    exit()
else:
    ans_num = cycle_num
    ans_list = jisho[kouho_v]
    print(cycle_num)
    print(*ans_list, sep="\n")


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>

#define M_N 1000000

int h_num[M_N + 10];

using namespace std;

int main()
{
	for (int i = 1; i <= M_N; i *= 2){
		for (int j = i; j <= M_N; j *= 3){
			for (int k = j; k <= M_N; k *= 5){
				h_num[k] = 1;
			}
		}
	}
	
	for (int i = 1; i <= M_N; i++){
		h_num[i] += h_num[i - 1];
	}
	
	int n, m;
	while (cin >> m, m){
		cin >> n;
		cout << h_num[n] - h_num[m - 1] << endl;
	}
	
	return (0);
}

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

int main(void)
{
	int len, i;
	char str1[256], str2[] = "ABC";

	scanf("%s", str1);

	len = strlen(str2);

	for (i = 0; i < len + 1; i++) {
		if (str1[i] != str2[i]) break;
	}

	if (i == len + 1) {
		printf("ARC\n");
	}
	else {
		printf("ABC\n");
	}

	return 0;
}

Measured memory_bytes: 1648
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

N = int(input())
a = [int(x) for x in input().split()]
x = lcm(*a)-1
ans = 0
for i in a:
    ans+=x%i

print(ans)


Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, R);
  printf("%.10lf", (double)R * 2 * 3.14159265359);
}


Measured memory_bytes: 3772
#priority_queueで管理
#普通にソートすればいいじゃん
n=int(input())
a=sorted([int(i) for i in input().split()])
#print(a)
while len(a)!=1:
    b=a[0]
    for i in range(1,n):
        a[i]-=b*(a[i]//b)
    a=sorted([i for i in a if i!=0])
    n=len(a)
    #print(a)

print(a[0])


Measured memory_bytes: 14224
#include <iostream>

using namespace std;

int main() {
	int n, W;
	long long take;
	cin >> n >> W;

	long long ans[n][W + 1];
	int w[n], v[n];

	for (int i = 0;i < n;i++) for (int j = 0;j <= W;j++) ans[i][j] = 0;

	for (int i = 0;i < n;i++) cin >> w[i] >> v[i];

	for (int i = w[0];i <= W;i++) ans[0][i] = v[0];

	for (int i = 1;i < n;i++) 
		for (int j = 0;j <= W;j++) {
			if (j - w[i] < 0) take = 0; else take = ans[i - 1][j - w[i]] + v[i];
			ans[i][j] = max(take, ans[i - 1][j]);                              
		}
		
	cout << ans[n - 1][W];
}

Measured memory_bytes: 78336
#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>
#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;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    multiset<int> ms;
    for (int i=0; i<n; i++) cin >> arr[i];
    ms.insert(arr[0]);
    for (int i=1; i<n; i++) {
        auto it = ms.lower_bound(arr[i]);
        if (it != ms.begin()) {
            it--;
            ms.erase(it);
        }
        ms.insert(arr[i]);
    }
    cout << ms.size();
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> M(2),D(2);
  for ( int i =0;i<2;i++){
    cin >> M.at(i) >> D.at(i);
  }


  if (D.at(1) ==1) cout << "1" <<endl;
  else cout<< "0" <<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s %s', $n, $loop);
$a = [];
for ($i = 0; $i < $loop; $i++) {
    fscanf(STDIN, '%s %s', $a[$i]['min'], $a[$i]['max']);
}

$min = null;
$max = null;
for ($j = 0; $j < $loop; $j++) {
    if(is_null($min) || $min < $a[$j]['min']){
        $min = $a[$j]['min'];
    }

    if(is_null($max) || $max > $a[$j]['max']){
        $max = $a[$j]['max'];
    }
}

$b = 0;
for ($i = 0; $i <= $n; $i++) {
    $b += ($min <= $i && $i <= $max);
}
echo $b;


?>


Measured memory_bytes: 55796
import sys
import math
import statistics
import itertools
from collections import deque

n=int(input())
#l,r,d=map(int,input().split())
lis=list(map(int,input().split()))
ans=0
for i in range(n):
    if (i+1)%2==1 and lis[i]%2==1:
        ans+=1
print(ans)

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

#define N 100000

int parent(int);
int left(int);
int right(int);
int n;

int main(){
    int i,A[N],k;
    
    scanf("%d",&n);
    
    for(i = 1;i <= n;i++){
        scanf("%d",&A[i]);
    }
    
    for(i = 1;i <= n;i++){
        printf("node %d: ",i);
        printf("key = %d, ",A[i]);
        k = parent(i);
        
        if(k != -1){
            printf("parent key = %d, ",A[k]);
        }
        if(left(i) != -1){
            printf("left key = %d, ",A[left(i)]);
        }
        if(right(i) != -1){
            printf("right key = %d, ",A[right(i)]);
        }
        printf("\n");
    }
    return 0;
}


int parent(int id){
    static int pid = 0;
    
    if(id % 2 == 0){
        pid++;
    }
    if(pid == 0){
        return -1;
    }
    else{
        return pid;
    }
}

int left(int id){
    int lid;
    
    lid = 2 * id;
    
    if(lid <= n){
        return lid;
    }
    else{
        return -1;
    }
}

int right(int id){
    int rid;
    
    rid = 2 * id + 1;
    
    if(rid <= n){
        return rid;
    }
    else{
        return -1;
    }
}



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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

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

typedef long long ll;

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


int main() {
    ll N, H;
    cin >> N >> H;
    vector<ll> nageAtks(N), a(N);
    REP(i, N) cin >> a[i] >> nageAtks[i];
    ll maxHuruAtk = *max_element(ALL(a));
    ll count = 0;
    sort(nageAtks.rbegin(), nageAtks.rend());
    REP(i, N) {
        if (nageAtks[i] > maxHuruAtk) {
            H -= nageAtks[i];
            count++;
            if (H <= 0) break;
        }
    }
    if (H > 0) {
        count += (H + maxHuruAtk - 1) / maxHuruAtk;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1920
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// マラソン用時間計測
clock_t start_clock;
constexpr double time_limit = 1.919114514; // 実行時間[s]より0.1ms程度余裕をあける
constexpr double CLOCKS_PER_SEC_INV = 1.0 / CLOCKS_PER_SEC;
inline double nowtime() { return CLOCKS_PER_SEC_INV * (clock() - start_clock); }
inline bool intime() { return nowtime() < time_limit; }

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (int i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (int i=(is), i##_end=(ie); i<=i##_end; i++)
#define FOREACH(i, arr) for (auto &i : arr)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using ll = long long;
using namespace std;

// 汎用クラス
struct union_find {
    vector<int> par;
    vector<int> num;
    union_find(int n) : par(n, 0), num(n, 1) { iota(ALL_OF(par), 0); }
    int root(int i) { return par[i] == i ? i : (par[i] = root(par[i])); }
    bool same(int i, int j) { return root(i) == root(j); }
    void unite(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        if (ri != rj) {
            if (num[ri] > num[rj]) swap(ri, rj);
            par[ri] = rj;
            num[rj] += num[ri];
        }
    }
};

// main前実行のためのダミークラス
struct preexec_dummy {
    preexec_dummy() {
        start_clock = clock();
    }
} preexec_dummy_instance;

int main() {
    
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m, 0);
    vector<vector<int>> a(n, vector<int>(m, 0));
    REP(i, m) cin >> b[i];
    REP(i, n) REP(j, m) cin >> a[i][j];

    int ans = 0;
    REP(i, n) {
        int f = c;
        REP(j, m) {
            f += a[i][j] * b[j];
        }
        if (f > 0) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cstdlib>
#define N 3030
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) { c = getchar(); }
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
}
using namespace std;
const int P = 1e9 + 7;
int n, m;
int f[N][N][2];
inline void ADD(int &a, int b) {
  a += b;
  if (a >= P) a -= P;
}
inline void work() {
  for (int i = 0; i <= n; ++i)  f[0][i][0] = 1;
  for (int i = 0; i < m; ++i) {
    ADD(f[i][0][1], f[i][0][0]);
    f[i][0][0] = 0;
    for (int j = 0; j <= n; ++j) {
      for (int t = 0; t < 2; ++t) if (f[i][j][t]) {
        if (j != 0) {
          if (t == 0 && j == 1) ADD(f[i + 1][j][1], f[i][j][0]);
          else  ADD(f[i + 1][j][t], f[i][j][t]);
          ADD(f[i + 1][j - 1][t], f[i][j][t]);
        }
        if (j != n) {
          ADD(f[i + 1][j][t], f[i][j][t]);
          ADD(f[i + 1][j + 1][t], f[i][j][t]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i)  ADD(ans, f[m][i][1]);
  ADD(ans, f[m][0][0]);
  printf("%d\n", ans);
}
int main() {
  read(n), read(m);
  work();
  return 0;
}


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

using namespace std;

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(auto &ss: s)
    cin >> ss;

  sort(s.begin(), s.end());

  string ans = "";
  for(auto ss: s)
    ans += ss;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
ll n,x;
ll all[55] = {};
ll Pa[55]={};

ll dfs(int l, ll k) {
    ll ret = 0;
    if (k >= all[l]) return Pa[l];
    --k;
    if (k>0) {
        ret += dfs(l-1, k);
        k -= all[l-1];
    }
    if (k>0) {
        ++ret;
        --k;
    }
    if (k>0) {
        ret+=dfs(l-1,k);
        k-=all[l-1];
    }

    return ret;
}

int main(int argc, char const *argv[]) {
    cin >> n >> x;
    all[0] = Pa[0] = 1;
    REP(i,51) {
        all[i+1] = all[i]*2+3;
        Pa[i+1] = Pa[i]*2+1;
    }
    
    cout << dfs(n,x) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vvi in(n,vi(m));
	rep(i,n)rep(j,m)cin>>in[i][j];
	if(n<=2||m<=2){
		int out=0;
		rep(i,n)rep(j,m)out+=in[i][j];
		cout<<out<<endl;
		return 0;
	}
	vi dp(40010);
	dp[200]=in[0][0]+in[1][0]+in[0][1]+in[n-1][m-1];
	loop(i,2,n+m-2){
		vi tmp(40010);
		rep(j,40010)if(dp[j]){
			int l=j%200,r=j/200;
			//l=0 r=1
			rep(q1,2)rep(q2,2){
				int L=l+q1,R=r+q2;
				if(i-L==n||L==R||R==m)continue;
				tmp[L+200*R]=max(tmp[L+200*R],dp[j]+in[i-L][L]+in[i-R][R]);
			}
		}
		dp=tmp;
	}
	cout<<dp[(m-2)+(m-1)*200]<<endl;
}









Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

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

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int n;
vector<vector<int>> as(305, vector<int>(305));
vector<vector<bool>> noneed(305, vector<bool>(305));
bool sol = true;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(10); // 浮動小数の表示の精度

    cin>>n;
    rep(i,n){
        rep(j,n){
            int a; cin>>a;
            as[i][j] = a;
        }
    }
    rep(i,n) {
        rep(j,n) {
            rep(k,n) {
                sol = sol && as[i][k] + as[k][j] >= as[i][j];
                noneed[i][j] = noneed[i][j] || (i != k && j != k && as[i][k] + as[k][j] == as[i][j]);
            }
        }
    }
    ll res = 0;
    rep(i,n) {
        for (int j = i+1; j < n; j++) {
            if (!noneed[i][j]) { res += as[i][j]; }
        }
    }
    if (!sol) { res = -1; }
    cout<<res<<'\n';

    return 0;
}


Measured memory_bytes: 4036
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.
   PREFER CODING RATHER THAN MEDITATION !!!*/
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define T ll t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define F first
#define S second
#define I insert
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())
#define pb push_back
#define ppb pop_back

 
const ll maxs = 1e6+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
//MODULO OPEARTIONS
inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
ll fastpow(ll x,ll y)
{ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}
//MODULAR INVERSE
ll inv(ll x){ return pow(x , mod - 2);}


bool vis[maxs];
vector<ll>graph[maxs];


int main()
{
   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  // T{
    string s;
    cin >> s;
    if(s[2] == s[3]  && s[4] == s[5])
        cout << "Yes";
    else
        cout << "No";
    
  // }
       
   
}

Measured memory_bytes: 23680
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int a, b, sum, judge=0, i;

    cin >> a >> b;

    if(b<10){
        sum = a*10+b;
    }
    else if(b<100){
        sum = a*100+b;
    }
    else{
        sum = a*1000+b;
    }

    for(i=1; i<=sqrt(sum)+1; i++){
        if(i*i==sum){
            judge = 1;
        }
    }

    if(judge==1){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin >> s;

  ll ans = 0;
  REP(i, 3){
    if(s[i] == 'o')
      ans++;
  }

  cout << 700+ans*100 << endl;
  
  
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc177_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadLong();
            var A = CIn.ReadIntArray(N);
            var sum = new long[N + 1];
            var sum2 = 0l;
            for(var i = N; i >= 1; i--)
            {
                sum[i - 1] = sum[i] % ((int)1e9 + 7) + A[i - 1] % ((int)1e9 + 7);
                sum2 = (sum2 + A[i - 1] * sum[i] % ((int)1e9 + 7)) % ((int)1e9 + 7);
            }
            Console.WriteLine(sum2);
            
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }
            ;
            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 51712
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = input().rstrip()
    ans = 0
    for i in range(len(N)):
        ans += int(N[i])
    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 69064
N=int(input())
a_list = [int(i) for i in input().split()]
b_list = [abs(i) for i in a_list]
b_list.sort()
minus_number = 0
for i in a_list:
	if i<0:
		minus_number+=1
if minus_number%2==0:
	print(sum(b_list))
else:
	print(sum(b_list)-2*b_list[0])

Measured memory_bytes: 14252
n = int(input())
enemies = list(map(int, input().split()))
powers = list(map(int, input().split()))
powers.append(0)
nokori = 0
cnt = 0


for i in range(n+1):
  cnt += min(enemies[i], powers[i]+nokori)
  if powers[i]+nokori > enemies[i]:
    if nokori >= enemies[i]:
      nokori = powers[i]
    else:
      nokori = powers[i]+nokori-enemies[i]
  else:
    nokori = 0

print(cnt)


Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int H,W;
char S[50][50];
int D[50][50];
int cnt=0;
int DX[4]={-1,0,1,0};
int DY[4]={0,-1,0,1};
int BFS(){
  int sx=0,sy=0;
  int gx=H-1,gy=W-1;
  queue<PA> que;
  que.push(MA(sx,sy));
  FOR(i,0,H){
    FOR(j,0,W){
      D[i][j]=INF;
    }
  }
  D[sx][sy]=0;
  while(que.size()){
    PA P=que.front();
    que.pop();
    if(P.FI==gx&&P.SE==gy){
      break;
    }
    FOR(i,0,4){
      int NX=DX[i]+P.FI;
      int NY=DY[i]+P.SE;
      if(0<=NX&&NX<H&&0<=NY&&NY<W&&D[NX][NY]==INF&&S[NX][NY]=='.'){
        D[NX][NY]=D[P.FI][P.SE]+1;
        que.push(MA(NX,NY));
      }
    }
  }
  return D[gx][gy];
}
int main(){
  cin>>H>>W;
  FOR(i,0,H){
    FOR(j,0,W){
      cin>>S[i][j];
      if(S[i][j]=='.'){
        cnt++;
      }
    }
  }
  if(BFS()==INF){
    cout<<-1<<endl;
  }else{
    cout<<cnt-BFS()-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    long long max,min,a;
    int i,j,k;
    int tmp;
    int n;
    int m;

    scanf("%d",&n);

    scanf("%llu",&a);
    min = a;

    scanf("%llu",&a);
    max = a - min;
    if (min > a)
        min = a;

    for (i = 2; i < n; i++) {
        scanf("%lld",&a);
        if ( a-min > max)
            max = a-min;
        if (a < min)
            min = a;
    }

    printf("%lld\n",max);
    return 0;
}

Measured memory_bytes: 600
index=int(input())
alist=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

index-=1
print(alist[index])

Measured memory_bytes: 2940