akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000050
#define ll long long
#define MOD 1000000007
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()

unordered_map<int,unordered_set<int> >mp;
int arr[MAX], mx;
vector<int>divis[MAX];

void sieve(int n)
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = i; j <= n; j += i)
        {
            divis[j].push_back(i);
        }
    }
}

int main()
{
    int n, v;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &v);
        arr[i] = v;
        mx = max(mx, v);
        mp[v].insert(i);
    }
    sieve(mx);
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        bool fnd = 0;
        for(int v : divis[arr[i]])
        {
            if(mp.find(v) != mp.end())
            {
                if(mp[v].size() > 1 || (mp[v].count(i) != 1)) fnd = 1;
            }
        }
        if(fnd == 0) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 148188
#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;
typedef pair<int,int>P;

int main()
{
    int x;
    cin>>x;
    if(x<100)
    {
        cout<<0;
        return 0;
    }

    int mod=x%100;
    int least=200*(mod/10)+(mod%10>5?200:100);
    least+=mod;
    if(x==210)least-=100;
    if(least<=x)
    {
        cout<<1;
    }
    else
    {
        cout<<0;
    }
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
        int a,b;
        scanf("%d",&a);
        scanf("%d",&b);
        if(a>b) {
                printf("a > b\n");
        }else if(a<b){
                printf("a < b\n");
        }else{
                printf("a == b\n");
        }return 0;
}

Measured memory_bytes: 2600
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N, M;
int A[50], B[50], X[50], Y[50];


void Sub(int i) {
	int mnval = INF;
	int mnidx = 0;
	REP(j, 0, M) {
		int dist = abs(X[j] - A[i]) + abs(Y[j] - B[i]);
		if (dist < mnval) {
			mnval = dist;
			mnidx = j;
		}
	}
	cout << mnidx + 1 << endl;
}

int main() {
	cin >> N >> M;
	REP(i, 0, N) {
		cin >> A[i] >> B[i];
	}
	REP(j, 0, M) {
		cin >> X[j] >> Y[j];
	}

	REP(i, 0, N) {
		Sub(i);
	}
	return 0;
}

Measured memory_bytes: 256
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce

MOD = 10**9 + 7
INF = float('inf')

ans = 0

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

T = [[] for i in range(N)]

H = list(map(int, input().split()))

for _ in range(M):
    a, b = list(map(int, input().split()))
    T[a-1].append(b-1)
    T[b-1].append(a-1)

for i in range(N):
    if len(T[i]) == 0:
        ans += 1
    else:
        if H[i] > max(list(map(lambda x: H[x], T[i]))):
            ans += 1

print(ans)


Measured memory_bytes: 30720
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() 
{
    off;
    ll N,W;
    cin>>N>>W;
    ll w[N+1],v[N+1];
    ll V=0;
    for(ll i=1;i<=N;i++)
    {
        cin>>w[i]>>v[i];
        V+=v[i];
    }
    ll dp[N+1][V+1];
    for(ll i=0;i<=N;i++)
        for(ll j=0;j<=V;j++)
            dp[i][j]=1e18L+5;
    dp[0][0]=0;
    for(ll i=1;i<=N;i++)
    {
        for(ll k=0;k<=V;k++)
        {
            ll x=dp[i-1][k];
            if(k-v[i]>=0&&dp[i-1][k-v[i]]+w[i]<=W)
                x=min(x,dp[i-1][k-v[i]]+w[i]);
            dp[i][k]=x;
        }
    }
    ll ans=0;
    for(ll i=V;i>=0;i--)
    {
        if(dp[N][i]<1e18L+5)
        {
            ans=i;
            break;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 79232
#include <stdio.h>
int cnt[105],tot;
int main(){
	int n,k,m,i,j,a;
	scanf("%d%d",&n,&k);
	for(i=1;i<=k;i++)
    {
		scanf("%d",&m);
		for(j=1;j<=m;j++)
        {
			scanf("%d",&a);
			cnt[a]++;
		}
	}	
	for(i=1;i<=n;i++)
		if(cnt[i])tot++;
	printf("%d\n",n-tot);
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
      lint N,M;
      cin>>N>>M;
      lint a[N];
      fill(a,a+N,-1);
      bool x=true;
      rep(i,M){
          lint s,c;
          cin>>s>>c;
          --s;
          if(a[s]==-1||a[s]==c)a[s]=c;
          else x=false;
      }
      bool t=false;
      bool v=false;
        if(N==1&&a[0]==0){
         cout<<0;
         return 0;
     }
      rep(i,N){
          if(a[i]!=0)v=true;
          if(a[i]==0&&!v){
              cout<<-1;
              return 0;
          }
      }
     if(N==1&&a[0]==-1){
         cout<<0;
         return 0;
     }
      if(x){
          rep(i,N){
              if(i==0&&a[i]==-1)a[i]=1;
              if(a[i]==-1)a[i]=0;
              if(a[i]==0&&t==false)continue;
              else {
                  t=true;
                  cout<<a[i];
              }
             
          }
      }else cout<<-1;
  }
     
  


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

int main() {
    string s,t;
    cin>>s;
    cin>>t;
    if(t.size()<=s.size())
    cout<<"No";
    else 
    {
        if(s.substr(0,s.size())==t.substr(0,s.size()))
        cout<<"Yes";
        else cout<<"No";
    }
}

Measured memory_bytes: 3592
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n = int(input())
  la = list(map(int, input().split()))
  la = [a-i for i, a in enumerate(la, 1)]
  la.sort()
  if len(la) == 1:
    print(0)
  else:
    ix = (len(la)-1) // 2
    print(min([sum(map(lambda x: abs(x-la[ix+i]), la)) for i in range(2)]))

if __name__=='__main__':
  main()



Measured memory_bytes: 26832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n, W;
vector<int> v, w;
vector<int> memo;
int dp(int x) {
    if (x < 0) return -INF;
    if (memo[x] != -1) return memo[x];
    int ret = 0;
    rep(i, n) chmax(ret, dp(x - w[i]) + v[i]);
    return memo[x] = ret;
}
int main() {
    cin >> n >> W;
    v.resize(n);
    w.resize(n);
    memo.assign(W + 10, -1);
    rep(i, n) cin >> v[i] >> w[i];
    int ans = 0;
    rep(i, W + 1) chmax(ans, dp(i));
    cout << ans << endl;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool isRainy = false;
  int ans = 0;
  if(s == "RRS" || s == "SRR"){
    cout << 2 << endl;
  }else if(s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR"){
    cout << 1 << endl;

  }else if(s == "RRR"){
    cout << 3 << endl;
  }else{
    cout << 0 << endl;
  }
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c;
	A = a + b;
	if (A >= c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    s, t = input().split()

    for i, j in zip(s, t):
        print(i, j, sep='', end='')
    print()


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29420
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll pow2[61];

ll dfs(ll x, ll n) {
    ll l = pow2[n + 1] - 3;
    ll p = pow2[n] - 1;
    if(x == 1) return 0;
    else if(x < l + 1) return dfs(x - 1, n - 1);
    else if(x == l + 1) return p;
    else if(x == l + 2) return p + 1;
    else if(x < l * 2 + 2) return p + 1 + dfs(x - (l + 2), n - 1);
    else return p * 2 + 1;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    pow2[0] = 1;
    FOR(i, 1, 60) pow2[i] = pow2[i - 1] * 2; 
    ll n, x;
    cin >> n >> x;
    cout << dfs(x, n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
  cin>>s;
  if(s.find('S')!=string::npos&&s.find('N')==string::npos||
    s.find('N')!=string::npos&&s.find('S')==string::npos||
    s.find('W')!=string::npos&&s.find('E')==string::npos||
    s.find('E')!=string::npos&&s.find('W')==string::npos){
      cout<<"No";
  }else cout<<"Yes";
}

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

using ll = long long;
const int inf = 1e8;
using namespace std;
struct DSU{
	vector<int> par;
	vector<int> sz;
	DSU(int n){
		par.resize(n);
		iota(par.begin(),par.end(),0);
		sz.assign(n,1);
	}
	int find(int a){
		return (a == par[a] ? a : par[a] = find(par[a]));
	}
	void unite(int a,int b){
		a = find(a);
		b = find(b);
		if(a != b){
			if(sz[a] < sz[b]) swap(a,b);
			par[b] = a;
			sz[a] += sz[b];
		}
	}
};

const int di[] = {1,-1,0,0};
const int dj[] ={0,0,-1,1};

int main(){
	int n,m;
	cin >> n >> m;
	vector<string> g(n);
	int si,sj,ei,ej;
	cin >> si >> sj >> ei >> ej;
	si--,sj--,ei--,ej--;
	for(int i = 0; i < n; i++){
		cin >> g[i];
	}
	auto ok = [&](int i,int j){
		return 0 <= i && 0 <= j && i < n && j < m && g[i][j] == '.';
	};
	auto f = [&](int i,int j){
		return i * m + j;
	};
	DSU ds = DSU(n*m);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(g[i][j] == '.'){
				for(int k = 0; k < 4; k++){
					int ni = i + di[k], nj = j + dj[k];
					if(ok(ni,nj)) ds.unite(f(i,j),f(ni,nj));
				}
			}
		}
	}
     //   assert(false);
	vector<vector<int>> dist(n,vector<int>(m,inf));
	set<tuple<int,int,int>> s;
	s.insert({dist[si][sj] = 0,si,sj});
	//cout<<"@8";
	int ans = inf;
	while(!s.empty()){
		int _,i,j;
		tie(_,i,j) = *s.begin();
		s.erase(s.begin());
		if(ds.find(f(i,j)) == ds.find(f(ei,ej))){
			ans = min(ans,dist[i][j]);
			continue;
		}
		for(int ii = -2; ii <= 2; ii++){
			for(int jj = -2; jj <= 2; jj++){
				int ni = i+ii;
				int nj = j+jj;
				if(!ok(ni,nj)) continue;
				int d = ds.find(f(ni,nj)) != ds.find(f(i,j));
				if(dist[i][j] + d < dist[ni][nj]){
					s.erase({dist[ni][nj],ni,nj});
					dist[ni][nj] = dist[i][j] + d;
					s.insert({dist[ni][nj],ni,nj});
				}
			}
		}
	}
        cout << (ans == inf ? -1 : ans);
}

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

int abs(int x, int y) {
  if (x < y) {
    return y-x;
  }
  else{
    return x-y;
  }
}
int main(){
  int r,D,x;
  cin >>r>>D>>x;
  int i=0;
  while(i<10){
    cout<< r*x-D <<endl;
    i++;
    x= r*x-D;
  }

}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
    int H,W,i,j;
    scanf("%d %d",&H,&W);
    if( H == 0 && W == 0){
    	return 0;
    }
    while(!(H == 0 && W == 0)){
    	for(i=0; i<H; i++){
        	for(j=0; j<W ;j++){
        		if(j > 0 && W-1 > j && i > 0 && H-1 > i){
            	    printf(".");
        		}else{
        			printf("#");
        		}
        	}
        	printf("\n");
    	}
    	printf("\n");
    	scanf("%d %d",&H,&W);
    }
    return 0;
}

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

int main(void){
    string s;
    cin>>s;
    int n = (int)s.size()+1;
    
    vi a(n, 0);
    
    for(int i=0; i<n-1; i++){
        if(s[i]=='<')
            a[i+1] = max(a[i+1], a[i]+1);
    }
    for(int i=n-2; i>=0; i--){
        if(s[i]=='>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    
    cout << accumulate(a.begin(), a.end(), ll(0)) << endl;
    return 0;
}


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

int main() {

	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	
}

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

using namespace std;

int main(){

	vector<queue<char>>Q(3);

	for (int i = 0; i < 3; i++){
		string s;
		cin >> s;
		for (int j = 0; j < s.size(); j++)
			Q[i].push(s[j]);
	}

	int next = 0;
	int now = 0;
	int ans;
	while (1){
		now = next;
		next = Q[now].front() - 'a';
		Q[now].pop();

		if (Q[next].empty()){
			ans = next;
			break;
		}
	}

	cout << char('A'+ans) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, K;
    cin >> N >> K;
    cout << ( N % K == 0 ? 0 : 1 ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  int res = 0;
  repz(i,1, n+1) {
    int temp = 0;
    int tempn = i;
    while (tempn != 0) {
      tempn /= 10;
      temp++;
    }
    if (temp % 2) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int h,w;
    while(true) {
        std::cin >> h >> w;
        if((h|w) == 0) break;
        std::string s1(w, '#');
        std::string s2(s1);
        if(w>2) s2.replace(1, w-2, w-2, '.');
        for(auto i=0; i<h; i++) {
            std::cout << ((i==0 || i==(h-1)) ? s1 : s2) << std::endl;
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vl a(n), b(m), sa(n + 1, 0), sb(m + 1, 0);
  rep(i, n) {
    cin >> a[i];
    sa[i + 1] = sa[i] + a[i];
  }
  rep(i, m) {
    cin >> b[i];
    sb[i + 1] = sb[i] + b[i];
  }
  ll ans = 0;
  rep(i, n + 1) {
    ll in = upper_bound(all(sb), k - sa[i]) - sb.begin();
    if(k - sa[i] >= 0) ans = max(ans, i + in - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9540
#include <stdio.h>

int main(void){
	int N, cnt = 0;;
  	scanf("%d", &N);

  	int A[N], B[N-1];
  	for (int i = 0; i < N; i++) {
      	scanf("%d", &B[i]);
    }

	A[0] = B[0];
  	for (int i = 0; i < N - 2; i++) {
    	if(B[i] >= B[i + 1]) {
        	A[i + 1] = B[i + 1];
        }else{
        	A[i + 1] = B[i];
        }
    }

  	A[N - 1] = B[N - 2];
    for (int i = 0; i < N; i++) {
    	cnt += A[i];
    }

  	printf("%d\n", cnt);
}


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

int main(void) {
  int N; cin >> N;
  int n = N/2;
  int m = (n*2)*(n*2)/2-(n*2);
  if (N%2 == 0) cout << m << endl;
  else cout << m + N-1 << endl;

  for (int i = 1; i <= n; i++) {
    for (int k = i+1; k < n*2-i+1; k++) {
      cout << i << ' ' << k << endl;
      cout << n*2-i+1 << ' ' << k << endl;
    }
  }

  if (N%2 == 1) {
    for (int i = 1; i < N; i++) cout << i << ' ' << N << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return i*2;}
int right(int i) {return 2*i+1;}

int main () {
  int H, i, A[MAX+1];
  scanf("%d",&H);

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

  for (i = 1; i <= H; i++) {
    printf("node %d: key = %d, ",i,A[i]);
    if (parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if (left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if (right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



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

namespace TestApp2
{
    class Program
    {
        static void Main()
        {
            var x = int.Parse(Console.ReadLine());
            var str = Console.ReadLine()
                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine(str.Count(_ => _ == "Y") > 0 ? "Four" : "Three");
        }
    }

}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n, a; cin >> n >> a;
    n %= 500;
    if (n <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
 
int main(){
    ll a,b;cin >> a >> b;
    //(i*j)mod2019 = i mod2019 * j mod 2019
    //最小値　2019の倍数が含まれるなら０
    long long ans = 1e18;
    for(long long i = a;i<=min(b,a+2019);i++){
        for(long long j = i+1;j<=min(b,a+2019);j++){
            long long x = (i*j)%2019;
            ans = min(ans,x);
            //cout << i << " "<< j << endl;
        }
        if(ans == 0) break;
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>

using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;

#define mp make_pair
#define pb push_back

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

int in(){int a; scanf("%d",&a); return a;}

string c[510];

int main(){
	int m,n,i,j;
	cin>>m>>n;
	for(j=0;j<m;j++){
		cin>>c[j];
//cout<<c[j]<<endl;
	}
	bool update=true;
	int result=0;
	while(update){
		update=false;
		for(j=0;j<m;j++){
			for(i=0;i<n;i++){
				if(c[j][i]!='.')continue;
				char r=0,l=0,d=0,u=0;
				int k;
				for(k=1;i+k<n&&c[j][i+k]=='.';k++);
				if(i+k<n)r=c[j][i+k];
				for(k=1;i-k>=0&&c[j][i-k]=='.';k++);
				if(i-k>=0)l=c[j][i-k];
				for(k=1;j+k<m&&c[j+k][i]=='.';k++);
				if(j+k<m)d=c[j+k][i];
				for(k=1;j-k>=0&&c[j-k][i]=='.';k++);
				if(j-k>=0)u=c[j-k][i];
//cout<<(int)r<<" "<<(int)l<<" "<<(int)d<<" "<<(int)u<<endl;
//cout<<(char)46<<endl;
				if(r==l&&r!=0){
					for(k=1;c[j][i+k]=='.'&&i+k<n;k++);
					c[j][i+k]='.';
					for(k=1;c[j][i-k]=='.'&&i-k>=0;k++);
					c[j][i-k]='.';
					result+=2;
					update=true;
				}
				if(r==d&&r!=0){
					for(k=1;c[j][i+k]=='.'&&i+k<n;k++);
					c[j][i+k]='.';
					for(k=1;c[j+k][i]=='.'&&j+k<m;k++);
					c[j+k][i]='.';
					result+=2;
					update=true;
				}
				if(r==u&&r!=0){
					for(k=1;c[j][i+k]=='.'&&i+k<n;k++);
					c[j][i+k]='.';
					for(k=1;c[j-k][i]=='.'&&j-k>=0;k++);
					c[j-k][i]='.';
					result+=2;
					update=true;
				}
				if(l==d&&l!=0){
					for(k=1;c[j][i-k]=='.'&&i-k>=0;k++);
					c[j][i-k]='.';
					for(k=1;c[j+k][i]=='.'&&j+k<m;k++);
					c[j+k][i]='.';
					result+=2;
					update=true;
				}
				if(l==u&&l!=0){
					for(k=1;c[j][i-k]=='.'&&i-k>=0;k++);
					c[j][i-k]='.';
					for(k=1;c[j-k][i]=='.'&&j-k>=0;k++);
					c[j-k][i]='.';
					result+=2;
					update=true;
				}
				if(d==u&&d!=0){
					for(k=1;c[j+k][i]=='.'&&j+k<m;k++);
					c[j+k][i]='.';
					for(k=1;c[j-k][i]=='.'&&j-k>=0;k++);
					c[j-k][i]='.';
					result+=2;
					update=true;
				}
			}
		}
	}
	cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e4;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int A[N];
	rep(i,0,N){
		cin>>A[i];
		if(A[i]%2==0){
			if(A[i]%3==0||A[i]%5==0) continue;
			else{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int i,n,x;
	for(;scanf("%d",&n),n;){
		vector<int>v,u;
		for(i=0;i<n;i++)scanf("%d",&x),v.push_back(x);
		for(x=0;;x++){
			u.clear();
			map<int,int>m;
			for(i=0;i<n;i++)m[v[i]]++;
			for(i=0;i<n;i++)u.push_back(m[v[i]]);
			if(v==u)break;
			v=u;
		}
		printf("%d\n%d",x,u[0]);
		for(i=1;i<n;i++)printf(" %d",u[i]);
		puts("");
	}
}

Measured memory_bytes: 1084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	const int x = a.back();
	const int k = upper_bound(a.begin(), a.end(), x / 2) - a.begin();
	if(k == n - 1){
		cout << x << " " << a[k - 1] << endl;
	}else if(k == 0){
		cout << x << " " << a[k] << endl;
	}else if(llabs(a[k] * 2 - x) < llabs(a[k - 1] * 2 - x)){
		cout << x << " " << a[k] << endl;
	}else{
		cout << x << " " << a[k - 1] << endl;
	}
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll d[201][201];// d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする) 
int V;// 頂点数
void warshall_floyd() {
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0;j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}



int main(){
	int m,r;cin>>V>>m>>r;
	vector<int> q(r);
	for(int i = 0; i < r; i++) {
		cin>>q[i];
	}
	for(int i = 0; i < V; i++) {
		for(int j = 0; j < V; j++) {
			if (i != j){
				d[i][j] = LINF;
			}
			else{
				d[i][j] = 0LL;
			}
		}
	}
	int x,y;
	ll z;
	for(int i = 0; i < m; i++) {
		cin>>x>>y>>z;
		if (d[x - 1][y - 1] > z){
			d[x-1][y-1] = z;
			d[y-1][x-1] = z;
		}
	}
	warshall_floyd();
	ll ans = LINF;
	sort(ALL(q));
	do {
		ll tmp = 0LL;
		for(int i = 0; i < r - 1; i++) {
			tmp += d[q[i] - 1][q[i + 1] - 1];
		}
		ans = min(ans,tmp);
  	} while (next_permutation(ALL(q)));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

int main(void){
	int n, i;
	char s[200002];
	int a[200001];
	scanf("%d%s", &n, s+1);

	a[0]=0;
	for(i=1; i<=n; i++){
		a[i]=a[i-1]+(s[i]=='#');
	}
	int min=INT_MAX;
	for(i=0; i<=n; i++){
		int now = a[i]+(n-i-a[n]+a[i]);
		if(now<min) min=now;
	}
	printf("%d\n", min);
}


Measured memory_bytes: 1152
N=int(input())
S=input()
count_M=0
for i in range(N):
	SR=S[(i+1):]
	SL=S[:(i+1)]
	count = 0
	for j in range(len(SL)):
		for k in range(len(SR)):
			if(SL[j] == SR[k]):
				count+=1
				SR=SR.replace(SR[k],' ')
	
	if(count_M < count):
		count_M=count

print(count_M)
   


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[85];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	a[n+1]=0;
	long long money=1000, shares=0;
	for(int i=1;i<=n;i++){
		if(a[i]<a[i+1]){
			shares+=money/a[i];
			money%=a[i];
		}
		else{
			money+=shares*a[i];
			shares=0;
		}
		//cout<<shares<<" "<<money<<endl;
	}
	cout<<money;
}

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

bool is_prime[10001];
int prime[10001];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i <= 10000; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j <= 10000; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (scanf("%d", &n), n) {
		int a = upper_bound(prime, prime + p, n) - prime - 1;
		for (int i = a; i > 0; i--) {
			if (prime[i] - prime[i - 1] == 2) {
				printf("%d %d\n", prime[i - 1], prime[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 3224
#include<stdio.h>
int flg[1000000];
int main(void)
{

	int a,i,j,cnt;
	while(scanf("%d",&a)!=EOF){	
		for(i=2;i<=a;i++){
		flg[i]=1;
		}
		for(i=2;i*i<=a;i++){
			if(flg[i]==1){
				j=2;
				while(i*j<=a){
				flg[i*j]=0;
//				printf("i=%d j=%d a=%d\n",i,j,a);
				j++;
				}
			}
		}
//		for(i=2;i<=10;i++)	printf("flg=%d\n",flg[i]);
		cnt=0;
		for(i=2;i<=a;i++){
//		printf("i=%d\n",i);
			if(flg[i]==1){
//			printf("i=%d\n",i);			
			cnt++;
			}
		}
		printf("%d\n",cnt);
	}	
	return 0;
}

Measured memory_bytes: 4928
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

#define PIE acos(-1);

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

    ld a,b,x;
    cin >> a >> b >> x;
    ld half=(pow(a,2)*b)/2;

    ld ans;
    if (x<half)
    {
        ans=atan2(a*pow(b,2),2*x);
    }
    else
    {
        ld alpha=(pow(a,2)*b)-x;
        ans=atan2(2*alpha,pow(a,3));
    }
    ans=(ans*180.0)/PIE;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3888
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;


int main()
{
	migmig ;
	int n  , k;
	cin>>n>>k ; 
	 int cnt = 0 ; 
	 while(n > 0)
	 {
	 	n /= k ; 
	 	cnt++ ; 
	 }
	 cout<<cnt ; 
}
//////
////////
///////////




Measured memory_bytes: 256
/****************************************

			LostMartian

****************************************/
//#pragma GCC optimize("Ofast")  
//#pragma GCC target("avx,avx2,fma") 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
#define mod 1000000007
ll cmp (ll a, ll b) {
	return ((a%mod)+(b%mod))%mod;
}
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n) {
		cin>>a[i];
	}

	ll sum[n+1];
	ini(sum, 0);

	for(ll i=n-1; i>=0; i--) {
		sum[i]=(sum[i+1]%mod+a[i]%mod)%mod;
	}

	// rep(i,0,n) {
	// 	ps(sum[i]);
	// }

	ll ans=0;
	for(ll i=0; i<n-1; i++) {
		ans+=((sum[i+1]%mod)*(a[i]%mod))%mod, ans%=mod;
	}

	pn(ans);


















	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}


Measured memory_bytes: 6892
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    pre_P = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247 ]
    pre_total = [1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]
    
    n,x=inpm()
    ans=0
    for i in range(n,0,-1):
        if x>=pre_total[i]-1:
            ans+=pre_P[i]
            break
        if x>=pre_total[i-1]+2:
            x-=pre_total[i-1]+2
            ans+=pre_P[i-1]+1
        elif x==pre_total[i-1]+1:
            ans+=pre_P[i-1]
            break
        else:
            x-=1
    print(ans)
        
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
k,s = map(int,input().split())
count = 0

for i in range(0,k+1):
    for j in range(0,k+1):
        x = i
        y = j
        z = s-i-j
        ##print("X=" + str(x),"Y=" + str(y),"Z="+ str(z))
        if 0<= z <= k:
          count+=1
print(count)

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#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> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


class UnionFind
{
	//par[i]：ノードiの親
	//count[i]：iが親の時、iが属するグループのノード数
	vector<int> par;
	vector<int> count;

	int m_groupCount = 0;

public:
	UnionFind(int N)
	{
		m_groupCount = N;

		for (int i = 0; i < N; i++)
		{
			//最初は全てが根であるとして初期化
			par.push_back(i);
			count.push_back(1);
		}
	}

	//データxが属する木の根を再帰で得る：root(x) = {xの木の根}
	int root(int x)
	{
		if (par[x] == x) return x;

		//ついでに親を張り替え
		return par[x] = root(par[x]);
	}

	//xとyの木を併合
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		//xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		par[rx] = ry;

		//要素数の変更
		count[ry] += count[rx];
		count[rx] = 0;

		//木の併合によってグループが1つ減る
		m_groupCount--;
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}

	//指定したデータxが属するグループの要素数を返す
	int size(int x)
	{
		return count[root(x)];
	}

	//UnionFindのグループの個数を返す
	int groupCount()
	{
		return m_groupCount;
	}
};



int main()
{
	int N, M;
	cin >> N >> M;

	vector<int> p(N);
	rep(i, N)
	{
		cin >> p[i];
		p[i]--;
	}

	UnionFind uf(N);

	rep(i, M)
	{
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		uf.unite(x, y);
	}

	int count = 0;

	rep(i, N)
	{
		if (uf.same(i, p[i])) count++;
	}

	cout << count << endl;

	return 0;
}

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    long long x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y) {
        ans += 1;
        x *= 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    h, n = get_list()
    li = get_list()
    if sum(li)>=h:
        print("Yes")
    else: print("No")
 
 
 
''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Measured memory_bytes: 59556
p = 10**9 + 7
n,m = list(map(int, input().split()))
a = set()
for _ in  range(m):
    a.add(int(input()))

dp = [0 for i in range(n+2)]
dp[0] = 1

for i in range(n):
    if i+2 not in a:
        dp[i+2] += dp[i]%p
    if i+1 not in a:
        dp[i+1] += dp[i]%p

print(dp[-2]%p)

Measured memory_bytes: 56536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        List<String> lists = Arrays.asList(br.readLine().split(" "));
        lists.sort((e1, e2) -> e1.compareTo(e2));
        System.out.println(String.join(" ", lists));
    }
}

Measured memory_bytes: 30388
from collections import defaultdict
s = input()
t = input()

ds = defaultdict(int)
for i in range(len(s)):
    ds[s[i]] += 1
dt = defaultdict(int)
for i in range(len(t)):
    dt[t[i]] += 1

possible = True
for ti in dt:
    if ti not in ds:
        possible = False
        break


if possible:
    n = len(s)
    pos = defaultdict(list)
    for i in range(n*2):
        pos[s[i%n]].append(i)

    edge = defaultdict(list)
    for c in pos:
        x = 0
        for i in range(n):
            if i >= pos[c][x]:
                x += 1
            edge[c].append(pos[c][x])

    # print(pos)
    # print(edge)
    ans = 0
    x = 0
    for i in range(n):
        if s[i] == t[0]:
            ans = i + 1
            x = i
            break

    # print(ans)
    for i in range(1, len(t)):
        ans += edge[t[i]][x%n] - x
        x = edge[t[i]][x%n] % n
        # print(ans, t[i])

else:
    ans = -1

print(ans)


Measured memory_bytes: 95196
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        s:Chars,
    }
    let ans=700+s.iter().filter(|x|**x=='o').count()*100;
    println!("{}",ans);
}

Measured memory_bytes: 2140