akhauriyash/Code-Regression huggingface dataset:
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

void add_self(int& a, int b)
{
    a += b;
    if(a >= mod)
        a -= mod;
}

void sub_self(int& a, int b)
{
    a -= b;
    if(a < 0)
        a += mod;
}

int dp[102][N];
// dp[i][j] - No. of ways to distribute j candies among first i childs 
void solve()
{
    int n, k;
    scn(n); scn(k);

    vi child(n);

    rep(i, 0, n) {
        scn(child[i]);
    }

    dp[0][0] = 1;

    rep(i, 0, n) {

        if(i > 0)
        rep(j, 1, k+1)
            add_self(dp[i][j], dp[i][j-1]);

        for(int used = 0; used <= k; used ++) {
            int l = used, r = used + min(k - used, child[i]);
            add_self(dp[i+1][l], dp[i][used]);
            sub_self(dp[i+1][r+1], dp[i][used]);
        }
    }

    rep(j, 1, k+1)
    add_self(dp[n][j], dp[n][j-1]);

    prin(dp[n][k]);
} 

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 43120
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<30

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dr[] = { -1, 0, 1, 0  };
const int dc[] = {  0, 1, 0, -1 };
int grid[8][8];
int tmin[8][8][7];

struct Ant{
	int hp, row, col;
	Ant (int hp, int row, int col ):hp(hp), row(row), col(col){}
	bool operator<(const Ant &a ) const{return true; }
};

int main()
{
//	cut here before submit 
//	freopen ("testcase.WA", "r", stdin );
	int w, h;

	while (scanf ("%d %d", &w, &h ), w, h ){
		int srow, scol;
		rep (i, h ) rep (j, w ){
			scanf (" %d", &grid[i][j] );
			if (grid[i][j] == 2 ){
				srow = i, scol = j;
			} // end if
		} // end rep
		rep (i, h ) rep (j, w ) rep (h, 7 ) tmin[i][j][h] = INF;
		int res = -1;
		priority_queue< pair<int,Ant> > que;
		que.push (make_pair (0, Ant(6, srow, scol ) ) );
		while (!que.empty() ){
			pair<int, Ant> curr = que.top(); que.pop();
			int t = -curr.first;
			int hp = curr.second.hp;
			int cr = curr.second.row;
			int cc = curr.second.col;
			if (hp == 0 ) continue;
			if (grid[cr][cc] == 3 ){ res = t; break; }
			if (tmin[cr][cc][hp] < t ) continue;
			if (grid[cr][cc] == 4 ) hp = 6;
			
			rep (k, 4 ){
				int nr = cr + dr[k];
				int nc = cc + dc[k];
				if (nr < 0 || nr >= h || nc < 0 || nc >= w ) continue;
				if (grid[nr][nc] == 0 ) continue;
				if (tmin[nr][nc][hp-1] <= t + 1 ) continue;
				que.push (make_pair(-(t+1), Ant (hp-1, nr, nc ) ) );
				tmin[nr][nc][hp-1] = t+1;
			} // end rep
		} // end while

		printf ("%d\n", res );
	} // end while

	return 0;
}

Measured memory_bytes: 1192
n = int(input())
a = list(map(int, input().split()))
c1 = c2 = 0
for x in a:
    if x % 4 == 0:
        c1 += 1
    elif x % 2 == 0:
        c2 += 1
print(("Yes" if c1 + int(c2 / 2) >= int(n / 2) else "No"))

Measured memory_bytes: 15020
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
#define qwq 500007
int n,m,k;
struct p{
	int x,y;
}a[qwq];
struct tree{
	int l,r;
	int maxn;
}tr[qwq<<2];
void pushup(int cnt){
	tr[cnt].maxn=std::max(tr[cnt<<1].maxn,tr[cnt<<1|1].maxn);
}
void build(int l,int r,int cnt){
	tr[cnt].l=l,tr[cnt].r=r;
//	printf("in%d %d %d\n",cnt,l,r);
	if(l==r){
		tr[cnt].maxn=0;
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,cnt<<1);
	build(mid+1,r,cnt<<1|1);
	return ;
}
void add(int x,int v,int cnt){
	int l=tr[cnt].l,r=tr[cnt].r;
	if(l==r){
		tr[cnt].maxn+=v;
		return ;
	}
	int mid=(l+r)>>1;
	if(x<=mid)add(x,v,cnt<<1);
	if(mid+1<=x)add(x,v,cnt<<1|1);
	pushup(cnt);
	return ;
}
int find(int l1,int r1,int cnt){
	int l=tr[cnt].l,r=tr[cnt].r;
//	printf("in %d %d\n",l,r);
	if(l1<=l&&r<=r1){
		return tr[cnt].maxn;
	}
	int ans=0;
	int mid=(l+r)>>1;
	if(l1<=mid)ans=std::max(ans,find(l1,r1,cnt<<1));
	if(mid+1<=r1)ans=std::max(ans,find(l1,r1,cnt<<1|1));
	return ans;
}
bool cmp(p a,p b){
	return a.x<b.x;
}
int ans;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	build(1,m,1);
	for(int i=1;i<=k;++i){
		scanf("%d%d",&a[i].x,&a[i].y);
		add(a[i].y,1,1);
	}
	std::sort(a+1,a+k+1,cmp);
	int now_=1;
	int last_now=1;
	for(int i=1;i<=n;++i){
		for(int j=last_now;j<now_;++j){
			add(a[j].y,1,1);
		}
		last_now=now_;
		int Sum=0;
		while(a[now_].x==i){
			add(a[now_].y,-1,1);
			++now_;
			++Sum;
		}
	//	printf("i:%d ans:%d\n",i,tr[1].maxn);
		ans=std::max(ans,Sum+find(1,m,1));
	//	for(int j=1;j<=m;++j)printf("i:%d %d ",i,find(j,j,1));
	//	putchar('\n');
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16332
N=gets.to_i
sum = 0
N.times do |nA|
  nA += 1
  N.times do |nB|
    nB += 1
      N.times do |nC|
        nC += 1
        sum += nA.gcd(nB).gcd(nC)
      end    
  end
end
puts sum

Measured memory_bytes: 14296
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int p=1000000007;
int log2_p_MAX=32;
typedef long long ll;
ll felmer(ll a)
{
  // a^(2^i) mod p
  ll rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  ll res = 1;
  ll expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  int n,i,t,x;
  int c[N_MAX];
  ll tt,res;
  ll f[N_MAX],r[N_MAX];
  cin >> n;
  fill(c,c+n,-1);
  for(i=0;i<=n;i++){
    cin >> t;
    if(c[t-1]<0){
      c[t-1]=i;
    }else{
      x=i-c[t-1]-1;
      break;
    }
  }
  r[0]=1;
  tt=1;
  for(i=1;i<=n+1;i++){
    if(i<n){
      r[i]=(r[i-1]*(n-i))%p;
      f[i]=felmer(i);
      r[i]*=f[i];
      r[i]%=p;
    }
    if(i>1&&i<=n-x){
      tt*=n-x+1-i;
      tt%=p;
      tt*=f[i-1];
      tt%=p;
    }
    res=0;
    if(i<n)
      res+=r[i];
    if(i<n+1)
      res+=2*r[i-1];
    if(i<=n-x)
      res-=tt;
    if(i>1)
      res+=r[i-2];
    res%=p;
    if(res<0)
      res+=p;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 5408
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int h,w,ans;
typedef pair<int,int> pii;
queue<pii> coord;
char a[101][101];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int main(){
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",a[i]);
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]=='.') ans++;
    if(a[0][0]=='.') coord.push(make_pair(0,0));
    for(int i=1;!coord.empty();i++){
        int s=coord.size();
        for(int j=0;j<s;j++){
            pii t=coord.front();
            if(t.first==h-1&&t.second==w-1){
                printf("%d\n",ans-i);
                return 0;
            }
            coord.pop();
            for(int k=0;k<4;k++){
                int tx=t.first+dx[k],ty=t.second+dy[k];
                if(0<=tx&&tx<h&&0<=ty&&ty<w) if(a[tx][ty]=='.'){
                    a[tx][ty]='#';
                    coord.push(make_pair(tx,ty));
                }
            }
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <complex>

using namespace std;
using ll=long long int;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int vx = x2 - x1;
    int vy = y2 - y1;

    int x3 = x2 - vy;
    int y3 = y2 + vx;
    int x4 = x1 - vy;
    int y4 = y1 + vx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;


vector<ll> prime_numbers;
void getPrimeNumbers(ll n_max){
    bool is_prime[n_max+1];
    for( ll ni = 0 ; ni <=n_max ; ni++ ){
        is_prime[ni]=true;
    }
   is_prime[0]=is_prime[1]=false;
    for( ll number = 2 ; number <=n_max ; number++ ){
        if(is_prime[number]){
            prime_numbers.push_back(number);
            for( ll ni = number*2 ; ni <=n_max ; ni+=number ){
                is_prime[ni]=false;
            }
        }
    }
}

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/
map<ll,ll> count_map;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
        count_map[ltmp]++;
        
    }

    sort(A.begin(),A.end());
    getPrimeNumbers(A[N-1]+1);   
    


    ll cnt_max=0;
    //cout << prime_numbers.size() << endl;
    rep(pi,prime_numbers.size()){
        ll cnt = 0;
        ll p0 = prime_numbers[pi];
        for( ll pval = p0 ; pval <=A[N-1] ; pval+=p0 ){
            cnt += count_map[pval];
        }

        cnt_max = llmax(cnt_max,cnt);
        if(cnt_max==N) break;
        else if(cnt_max>1 && p0>A[0]) break;
    }

    if(cnt_max==N) cout << "not coprime" << endl;
    else if(cnt_max>1) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;


}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> c(m);
    int b, x;
    REP(i, m) {
        cin >> a[i] >> b;
        REP(j, b) {
            cin >> x;
            x--;
            // bitDP
            c[i] |= (1 << x);
        }
    }

    vector<vector<int>> dp(m + 1, vector<int>(1 << n, INF));
    dp[0][0] = 0;

    // bitDP
    REP(i, m) {
        REP(j, 1 << n) {
            // With the target key[j]...
            //   - The number of boxes that can be opened does not increase
            chmin(dp[i + 1][j], dp[i][j]);
            //   - More boxes can be opened
            chmin(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    int ans = dp[m][(1 << n) - 1];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


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

int main(){
    string Sp,T,S;
    cin >> Sp >> T;
    string Stmp;
    int imax;

    imax=-1;
    for(int i=0; i<Sp.size()-T.size()+1; i++){
        Stmp=Sp.substr(i,T.size());
        bool flag=true;
        for(int j=0; j<Stmp.size(); j++){
            if( Stmp[j]=='?' || Stmp[j]==T[j] ){
                continue;
            }else{
                flag=false;
            }
        }
        if(flag){
            imax=i;
            //cout << "imax = " << imax << endl;
        }
    }

    if(imax<0){
        cout << "UNRESTORABLE" << endl;
    }else{
        S=Sp;
        S.replace(imax,T.size(),T);
        for(int i=0; i<S.size(); i++){
            if(S[i]=='?'){
                S[i]='a';
            }
        }
        cout << S << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
  N = int(input())
  S = input()

  sum = S.count('R') * S.count('G') * S.count('B')

  for i in range(N-2):
    for j in range(i+1, N-1):
      k = j+(j-i)
      if k < N:
        if S[i] == S[j] or S[i] == S[k] or S[k] == S[j]:
          continue
        sum -= 1
  print(sum)

if __name__ == '__main__':
  main()

Measured memory_bytes: 9204
/*input
9999 10
540 7550
691 9680
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, n; cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    vector<int> dp(h + 1, INT_MAX);
	dp[0] = 0;
	for(int i = 1; i < h + 1; i++) for(int j = 0; j < n; j++) dp[i] = min(dp[i], dp[max(i - a[j], 0)] + b[j]);
	cout << dp[h];

    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if((a+b)==c||(a+c)==b||(c+b)==a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	int id = 0;
	for (int i = 0; i < N; i++) {
		if (abs(a[i] * N - sum) < abs(a[id] * N - sum)) {
			id = i;
		}
	}
	cout << id << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define re register
#define N 501000
#define pb push_back
using namespace std;

struct edge{
	int dis,to,next;
}e[N<<1];
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
int n,ans,a[N],b[N];
inline bool check(int x){
	for (int i=1;i<=(n<<1)-1;++i)b[i]=a[i]>=x;
	for (int i=1;i<n;++i){
		if (b[n+i-1]==b[n+i])return b[n+i];
		if (b[n-i+1]==b[n-i])return b[n-i];
	}
	return b[1];
}
signed main(){
	n=read();
	for (int i=1;i<=(n<<1)-1;++i)a[i]=read();
	int l=1,r=(n<<1)-1;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int d; cin >> d;
    string s = "Christmas";
    string a = " Eve";
    string ans;
    if(d == 25) ans = s;
    else if(d == 24) ans = s + a;
    else if(d == 23) ans = s + a + a;
    else if(d == 22) ans = s + a + a + a;
    cout << ans << endl; 
	return 0;
} 

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

vector<ll> min_eratosthenes(ll n){
    vector<ll> min_prime(n+1, -1);
    min_prime[0] = 0;
    min_prime[1] = 1;
    for(ll i = 2; i*i <= n; i++){
        if(min_prime[i] == -1){
            for(ll j = 1; i*j <= n; j++) min_prime[i*j] = i;
        }
    }
    for(ll i = 0; i <= n; i++){
        if(min_prime[i] == -1) min_prime[i] = i;
    }
    return min_prime;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    ll max_a = 0;
    REP(i, n) max_a = max(max_a, a[i]);
    vector<ll> min_prime = min_eratosthenes(max_a);
    vector<ll> num(max_a+1, 0);
    REP(i, n){
        set<ll> st;
        while(a[i] != 1){
            st.insert(min_prime[a[i]]);
            a[i] /= min_prime[a[i]];
        }
        for(auto x: st){
            num[x]++;
        }
    }
    ll ans = 0;
    REP(i, max_a+1) ans = max(ans, num[i]);
    if(ans <= 1) cout << "pairwise coprime";
    else if(ans == n) cout << "not coprime";
    else cout << "setwise coprime";
    return 0;
}

Measured memory_bytes: 26748
#include<cstdio>

int main(){
  char num[1001];
  int total = 0;
  
  while(1){
  	scanf("%s", num);
  	if ( num[0] == '0' ) break;

    total = 0;
    for ( int i = 0; num[i] != '\0'; i++ ){
      total += num[i] - '0';
    }
    printf("%d\n", total);
  }

  return 0;
}


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

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

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

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


int main(){
  ll a,b,c; cin >> a >> b >> c;
  
  ll d,e,f; d = abs(a-b); e = abs(b-c); f = abs(c-a);
  
  cout << min(d+e,min(e+f,f+d)) << endl;
  
  
}


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

int main() {
    string a, b; cin >> a >> b; string str = a + b; long long x = strtoll(str.c_str(), nullptr, 10);
    int root = lrint(ceill(sqrtl(x)));
    cout << (root*root == x ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int DP[60000];

int main(){
	
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < 60000; i++){
		DP[i] = i;
	}
	
	for(int i = 0; i < m; i++){
		int num;
		cin >> num;
		for(int j = num; j <= n; j++){
			DP[j] = min(DP[j], DP[j - num] + 1);
		}
	}
	
	cout << DP[n] << endl;
	
	return 0;
}


Measured memory_bytes: 3352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000007

int main() {
	int n, m,cnt=0;
	cin >> n >> m;
	//vector<vector<int> >node(n,vector<int>(n));
	vector<vector<int> >costB(n, vector<int>(n));
	vector<pair<int, int>>list(m);
	rep(i, n)
		rep(j, n)
		costB[i][j] = INF;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		costB[a][b] = 1;
		costB[b][a] = 1;
		list[i] = pair<int,int>(a, b);
	}
	rep(l, m) {
	vector<vector<int>>cost(costB);
	cost[list[l].first][list[l].second] = INF;
	cost[list[l].second][list[l].first] = INF;
	rep(k, n)
		rep(i, n)
		rep(j, n)
		cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	
	bool flg = false;
	for (int i = 0; i < n; i++) {
		int tmp2 = 0;
		for (int j = 0; j < n; j++)
			tmp2 = max(tmp2, cost[j][i]);
		if (tmp2 == INF)
			flg=true;
	}
	if (flg)
		cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B;
    cin >> A >> B;
    printf("%lld\n", A * B - A - B + 1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<sstream>
#include<cstring>
#include<queue>
#include<string>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define INF 100000000
using namespace std;
map<vector<int> ,int> mp;
void compute(vector<int> s){
	queue<vector<int> > que;
	que.push(s);
	mp[s]=0;
	while(!que.empty()){
		vector<int> t=que.front();
		que.pop();
		vector<int> now;
		for(int i=0;i<8;i++){
			if(t[i]==0){
				if(i<=3){
					now=t;
					swap(now[i],now[i+4]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
				}else{
					now=t;
					swap(now[i],now[i-4]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
				}
				if(i==0||i==4){
					now=t;
					swap(now[i],now[i+1]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
				}else if(i==3||i==7){
					now=t;
					swap(now[i],now[i-1]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
				}else{
					now=t;
					swap(now[i],now[i-1]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
					now=t;
					swap(now[i],now[i+1]);
					if(mp[now]>mp[t]+1){
						mp[now]=mp[t]+1;
						que.push(now);
					}
				}
				break;
			}
		}
	}
}
int main(){
	vector<int> s(8);
	vector<int> c(8);
	for(int i=0;i<8;i++){
		s[i]=i;
		c[i]=i;
	}
	do{
		mp[c]=INF;
	}while(next_permutation(all(c)));
	compute(s);
	string z;
	while(getline(cin,z)){
		stringstream ss(z);
		vector<int> v(8);
		for(int i=0;i<8;i++){
			ss>>v[i];
		}
		cout<<mp[v]<<endl;
	}
	return 0;
}

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


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

    bool isAll3or5 = true;
    rep(i,n){
        if((a[i]%2 == 0) && (a[i]%3 != 0) && (a[i]%5 != 0)) isAll3or5 = false;
        }
    

    if(isAll3or5) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

S1 = [0] * N
S2 = [0] * (N+1)

S1[0] = A1[0]
S2[N-1] = A2[N-1]
for i in range(1, N):
    S1[i] = S1[i-1] + A1[i]
    S2[N-i-1] = S2[N-i] + A2[N-i-1]

#print(S1)
#print(S2)

ans = 0
for i in range(N):
    ans = max(ans, S1[i] + S2[i])

print(ans)


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


ll i,n,ans=0;
void dfs(ll);

int main(){
    cin>>n;
    
    dfs(3);
    dfs(5);
    dfs(7);

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

void dfs(ll k){
    ll dis=0,div=1;

    if(k>n){//与えられたnを超えたら加算終了
        return;
    }

    bool d3,d5,d7;d3=d5=d7=false;//753数かどうか判定

    for(i=1;i<10;i++){
        int dis=k/div;
        dis%=10;
        if(dis==3){d3=true;}
        if(dis==5){d5=true;}
        if(dis==7){d7=true;}
        div*=10;
    }
    if(d3==true && d5== true && d7==true){ans++;}//753数なら加算

    dfs(k*10+3);
    dfs(k*10+5);
    dfs(k*10+7);
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
now = x[0]
sc = 0
for i in range(1, n):
    if abs(now - x[i])*a < b:
        sc += abs(now - x[i])*a
    else:
        sc += b
    now = x[i]
print(sc)

Measured memory_bytes: 62704
#include<iostream>

const int BUILDING = 4;
const int ROOM = 10;
const int FLOOR = 3;

void print_stete(int** a){
  for(int b = 0; b < BUILDING; b++){
    if(b != 0){
      std::cout << "####################" << std::endl;
    }
    for(int f = 0; f < FLOOR; f++){
      for(int r = 0; r < ROOM; r++){
	std::cout << " " << a[b][f * ROOM + r];
      }
      std::cout << std::endl;
    }
  }
}

int main(){
  int** build = new int*[BUILDING];
  for(int i = 0; i < BUILDING; i++){
    build[i] = new int[ROOM * FLOOR];
    for(int k = 0; k < ROOM * FLOOR; k++){
      build[i][k] = 0;
    }
  }

  int n;
  std::cin >> n;

  for(int i = 0; i < n; i++){
    int b, f, r, v;
    std::cin >> b;
    std::cin >> f;
    std::cin >> r;
    std::cin >> v;

    build[b - 1][(f - 1) * ROOM + (r - 1)] += v;
  }
  print_stete(build);
  
  return 0;
}



Measured memory_bytes: 3100
// 最小全域木 ( プリム法 )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

#define MAX_N 100
// 値の定義
const int INV = -1;
const int MAX_W = 2000;

// グラフ情報を保持する配列
int ary_graph[MAX_N + 1][MAX_N + 1];

// 入力された頂点を保持するキュー
queue<int> Base_Queue;

int n = 0;

// プリム法で最小全域木を求める
int MinimumSpanningTree(void);

int main(void)
{
    int sum = 0;

    for(int i = 0; i < MAX_N + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = INV;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        // グラフを構成する頂点の格納
        Base_Queue.push(i);

        for(int j = 0; j < n; j++)
        {
            // 隣接行列の設定
            cin >> ary_graph[i][j];
        }
    }

    // 頂点１から最小全域木を探索する
    sum = MinimumSpanningTree();

    // 結果の表示
    printf("%d\n", sum);

    return 0;
}

// 最小全域木を探索する関数
int MinimumSpanningTree(void)
{

    int q_size_1, q_size_2, min_val, min_ele, s, t, tmp;
    // 辺の和を保持する変数
    int sum = 0;

    // 最小全域木を構成する頂点を保持するキュー
    queue<int> Prim_Queue;

    // 検索する頂点の初期値の設定
    s = Base_Queue.front();
    Base_Queue.pop();
    Prim_Queue.push(s);

    while( !Base_Queue.empty() )
    {
        // ----------------------------------------------
        // Prim_Queueの頂点 から Base_Queueの頂点への辺の中で
        // 最小コストの辺を検索する方針で進める
        // ----------------------------------------------

        min_val = MAX_W;
        min_ele = INV;
        q_size_1 = Base_Queue.size();
        q_size_2 = Prim_Queue.size();

        for( int i = q_size_2; i > 0; i-- )
        {
            // --- s から t に向かう辺の重みを探索する ---
            s = Prim_Queue.front();
            Prim_Queue.pop();
            // Prim_Queue の要素が減らないように, 取り出したものを元に戻す
            Prim_Queue.push(s);

            for( int i = q_size_1; i > 0; i-- )
            {
                t = Base_Queue.front();
                Base_Queue.pop();

                if( ary_graph[s][t] != INV && min_val > ary_graph[s][t] )
                {
                    // 最小のコストを持つ辺を保存する
                    min_val = ary_graph[s][t];
                    min_ele = t;
                }

                // 取り出したものを, 一旦, 元に戻す
                Base_Queue.push(t);
            }
        }

        // 最小のコストを持つ辺の頂点を追加して
        // 最小全域木を構成する
        for(int i = 0; i < Base_Queue.size(); i++)
        {
            tmp = Base_Queue.front();
            Base_Queue.pop();

            if( tmp == min_ele )
            {
                // 最小コストの辺を持つ頂点を追加する
                Prim_Queue.push(tmp);
                break;
            }
            else
            {
                Base_Queue.push(tmp);
            }
        }

        // 辺の和を求める
        sum += min_val;
    }

    return sum;
}



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

int main() {
    int64_t n, a, ans = 1, cnt = 0;
    cin >> n;
    map<int64_t, int> m;
    for (auto i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
    }
    for (auto itr = m.rbegin(); itr != m.rend(); itr++) {
        for (auto i = 0; i < itr->second / 2; i++) {
            ans *= itr->first, cnt++;
            if (cnt == 2) break;
        }
        if (cnt == 2) break;
    }
    if (cnt == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;

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

    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  // ll ans = 0;
  // bool ok = false;

  // cout << ans << endl;
  cout << (N==1?"0":"1") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3676
import sys
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
hugo = [1, -1]
for b in hugo:
    AB = A+b*B
    for c in hugo:
        ABC = AB+c*C
        for d in hugo:
            ABCD = ABC+d*D
            if ABCD == 7:
                if b == 1:
                    b = "+"
                else:
                    b = "-"
                if c == 1:
                    c = "+"
                else:
                    c = "-"
                if d == 1:
                    d = "+"
                else:
                    d = "-"
                print(A, b, B, c, C, d, D, "=7", sep="")
                sys.exit()


Measured memory_bytes: 9104
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[100006];


class BIT {
public:
	vector<int>bit;
	int N;
	void init(int n) {
		N = n;
		bit.resize(n + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= N) {
			bit[i] += x;
			i += i&-i;
		}
	}
};
BIT bit;

signed main() {
	int n, k; cin >> n >> k;
	rep(i, n) {
		cin >> a[i+1]; a[i+1] -= k;
	}
	rep(i, n)a[i + 1] += a[i];
	vector<P>V;
	rep(i, n + 1)V.push_back(P(a[i], i));
	sort(V.begin(), V.end());
	bit.init(n+1);
	int cnt = 0;
	rep(i, V.size()) {
		bit.add(V[i].second + 1, 1);
		cnt += bit.sum(V[i].second);
	}
	cout << cnt << endl;
}



Measured memory_bytes: 5856
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9
#define mod 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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;
}

string s;
int dp [110000][13];

int main () {
  cin >> s;

  int n = s.size();

  if (s[0] == '?') {
    Rep(k, 10) dp[1][k] = 1;
  } else {
    dp[1][s[0] - '0'] = 1;
  }

  for (int i=2;i<=n;++i) {
    char tmp_char = s[i-1];
    if (tmp_char == '?') {
      Rep(j, 13) {
        Rep(k, 10) {
          dp[i][(j * 10 + k) % 13] = (dp[i][(j * 10 + k) % 13] + dp[i-1][j]) % mod;
        } 
      }
    } else {
      int m = tmp_char - '0';
      Rep(j, 13) {
        dp[i][(j * 10 + m) % 13] += (dp[i][(j * 10 + m) % 13] + dp[i-1][j]) % mod;
      }
    }
  }

  cout << dp[n][5] << "\n";
}

Measured memory_bytes: 5504
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN printf("\n")
#define LL long long
inline int read(){
	int x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=-1;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return x*y;
}
int n;
int h[200006];
int main(){
	n=read();int k=read();
	for(R int i=1;i<=n;i++) h[i]=read();
	std::sort(h+1,h+1+n);
	LL ans=0;
	for(R int i=1;i<=n-k;i++) ans+=h[i];
	std::printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

bool arr[100010];

int main() {
	int N;
	cin >> N;
	for (int i = 0;i < 100010;i++)arr[i] = 0;
	for (int i = 100;i < 106;i++)arr[i] = 1;
	for (int i = 106;i <= N;i++) {
		if (arr[i - 100]) {
			arr[i] = 1;
		}
		if (arr[i - 101]) {
			arr[i] = 1;
		}
		if (arr[i - 102]) {
			arr[i] = 1;
		}
		if (arr[i - 103]) {
			arr[i] = 1;
		}
		if (arr[i - 104]) {
			arr[i] = 1;
		}
		if (arr[i - 105]) {
			arr[i] = 1;
		}
	}
	if (arr[N])cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int c[3][3];
int main() {
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    rep(a1, 101) rep(a2, 101) rep(a3, 101) {
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        if (c[1][0] == a2 + b1 && c[2][0] == a3 + b1 && c[1][1] == a2 + b2 && c[2][1] == a3 + b2 && c[1][2] == a2 + b3 &&
            c[2][2] == a3 + b3) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------

int main() {
    CIN(N);
    vector<int> v(N);
    rep(i,N)cin>>v[i];
    int num = INF,ans = 0;
    rep(i,N){
        if(num>v[i]){
            ans++;
            num=v[i];
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::string S;
  std::cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    std::cout << "Yes" << '\n';
  }
  else {
    std::cout << "No" << '\n';
  }
}


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

string str;
int main(){
    cin >> str;
    bool is_first_end_equal;
    bool is_length_even;
    if(str.length() % 2 == 0){
        is_length_even = true; 
    }else{
        is_length_even = false;
    }

    if(str[0] == str[str.length()-1]){
        is_first_end_equal = true;
    }else{
        is_first_end_equal = false;
    }

//    cout << "is_length_even:" << is_length_even << endl;
 //   cout << "is_first_end_equal:" << is_first_end_equal << endl;


    if(is_first_end_equal ^ is_length_even){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  vector<int> ans(n);
  for(int i = 0; i < n; i++){
    ans.at(a.at(i) - 1) = i + 1;
  }
  
  for(int i = 0; i < n; i++) cout << ans.at(i) << ' ';
}

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

int N;
vector<int> arr;

int main() {
    scanf("%d", &N);
    arr.resize(3*N);
    for(int i = 0; i < 3*N; i++) {
        scanf("%d", &arr[i]);
    }
    sort(arr.begin(), arr.end());
    long long ans = 0;
    for(int i = N; i < 3*N; i += 2) {
        ans += arr[i];
    }
    printf("%lld", ans);
}


Measured memory_bytes: 1408
while True:
    m, f, r = map(int, raw_input().split())

    if (m+f+r) == -3:
        break

    if (m * f) < 0:
        print "F"
    elif (m + f) >= 80:
        print 'A'
    elif 65 <= (m + f) < 80:
        print 'B'
    elif 50 <= (m + f) < 65:
        print 'C'
    elif 30 <= (m + f) < 50:
        if r < 50:
            print 'D'
        else:
            print 'C'
    elif (m + f) < 30:
        print 'F'

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n, l; cin >> n >> l;

	int val = 0;
	FOR_LT(i, 0, n) {
		val += l + i;
	}

	if (0 < l) {
		cout << val - l << endl;
	}
	else if (n + l - 1 < 0) {
		cout << val - (n + l - 1) << endl;
	}
	else {
		cout << val << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int mo,i,j,ur;
    
    scanf("%d",&mo);
    
    i = mo / 500;
    mo -= 500 * i;
    j =mo / 5;
    
    ur = 1000 * i + 5 * j;
    printf("%d",ur);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] a = new int[n][2];
		int[][] c = new int[m][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			c[i][0] = sc.nextInt();
			c[i][1] = sc.nextInt();
		}
		StringBuilder sb = new StringBuilder();
		int num = 0, min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			num = 0; min = Integer.MAX_VALUE;
			for (int j = 0; j < m; j++) {
				if(Math.abs(c[j][0]-a[i][0])+Math.abs(c[j][1]-a[i][1])<min) {
					min = Math.abs(c[j][0]-a[i][0])+Math.abs(c[j][1]-a[i][1]);
					num = j;
				}
			}
			sb.append(num+1);
			sb.append("\n");
		}
		System.out.println(new String(sb));
		sc.close();
	}
}

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

int main(void) {
    string s;
    char c;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
        if (!isalpha(s[i]))  cout << s[i];
        else {
            if (isupper(s[i]))  c = tolower(s[i]);
            else c = toupper(s[i]);
            cout << c;
        }
    }
    cout << endl;
    return 0;
}

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

 int counter = 0;   //count???????´???????????????¨???

void bubbleSort(int A[], int N) {

	int flag = 1;
	int tmp;
	while (flag) {
		flag = 0;
		for(int j=N-1;j>=1;j--)
			if (A[j] < A[j - 1]) {
				tmp = A[j - 1];
				A[j - 1] = A[j];
				A[j] = tmp;
		     	flag = 1;
		     	counter++;
			}
	}
}

int main() {
	int A[100];
	int N;
	cin >> N;
	for (int i = 0;i < N;i++) cin >> A[i];

	bubbleSort(A, N);

	for (int i = 0;i < N;i++) {
		cout << A[i];
		if(i<N-1) cout<<' ';
	}
	cout<<'\n';
	cout<<counter<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>

#define H 500001

int A[H],h;

void maxHeapify(int he){
  int l,r,i,j,greatest;

  l = 2*he;
  r = 2*he+1;

  if(l<=h && A[l] > A[he]) greatest = l;
  else greatest = he;

  if(r<=h && A[r]> A[greatest]) greatest = r;


  if(greatest != he){
    j = A[greatest];
    A[greatest] = A[he];
    A[he] = j;
    maxHeapify(greatest);
  }
}
  
void buildMaxHeap(){
  int i;
 
  for(i=h/2;i>=1;i--) {
    maxHeapify(i);
 
  }
}

int main(){

  int i,j,k;

  scanf("%d",&h);

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


  buildMaxHeap();

  for(i=1;i<=h;i++){
   printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}



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

int N;
long long A[100010] = {2,1};

int main()
{
    scanf("%d",&N);
    for(int i = 2; i <= N; i++)
    {
        A[i] = A[i - 1] + A[i - 2];
    }printf("%lld\n",A[N]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node {

  int key;
  struct Node *prev, *next;

};

struct Node *nil;

int insert( int key ){

  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

  return 0;

}

int delete( int key ){

  struct Node *cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }

  if ( cur != nil) {
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    free(cur);
  }

  return 0;

}

int deleteFirst(){

  struct Node *cur = nil->next;

  nil->next = cur->next;
  cur->next->prev = nil;
  free(cur);

  return 0;
  
}

int deleteLast(){

  struct Node *cur = nil->prev;
  
  cur->prev->next = nil;
  nil->prev = cur->prev;
  free(cur);

  return 0;

}

int printList(){

  struct Node *cur = nil->next;
  int cnt;
  cnt = 0;

  while(1){

    if ( cur == nil ) break;
    if ( cnt++ > 0 ) printf(" ");
    printf("%d", cur->key );
    cur = cur->next;
  }

  printf("\n");

  return 0;

}

int main(){

  int i,n,key,len;
  char S[12];

  scanf("%d", &n );
  
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
  

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

    scanf("%s", S );

    len = strlen(S);

    if ( S[0] == 'i' ) {
      scanf("%d", &key );
      insert( key );
    } else if ( len == 6 ) {
      scanf("%d", &key );
      delete( key );
    } else if ( len == 11 ) {
      deleteFirst();	
    } else {
      deleteLast();
    }
    
  }

  printList();
  
  return 0;

}

Measured memory_bytes: 31788
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
double dp[13][11][1<<13];
double calc(vector<int>&v, int s, int n, int p, int b)
{
  if(n == 0) return p;
  if(dp[n][p][b] != 0) return dp[n][p][b];
  double m = 300.0;
  for(int i=0; i<s; i++){
    if(!(b & (1 << i))){
      double d;
      if(p == 0) d = v[i];
      else {
	double q = p - v[i];
	double r = p + v[i];
	double cos = sqrt(1.0 - q * q / (r * r));
	d = r * cos;
      }
      d += calc(v,s,n-1,v[i],(b | (1 << i)));
      m = min(m, d);
    }
  }
  dp[n][p][b] = m;
  return m;
}
int main()
{
  string s;
  while(getline(cin, s)){
    istringstream in(s);
    int n=0, i;
    double w;
    vector<int> v;
    in >> w;
    while(in >> i){
      v.push_back(i);
      n++;
    }
    memset(dp,0,sizeof(dp));
    double r = calc(v,n,n,0,0);
    if(w < r) cout << "NA" << endl;
    else cout << "OK" << endl;
  }
  return 0;
}

Measured memory_bytes: 9000
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){




int n;
cin>>n;
vector<  ll > arr(n);

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

vector < ll > sum ( n+1 , 0LL );

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

ll ans =0 ;

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


cout<<ans<<endl;





return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 6364