akhauriyash/Code-Regression huggingface dataset:
// 貪欲からランダムにずらしていく
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


// 常に貪欲に選択する

vector<vector<int>> s(400,vector<int>(27));
vector<int> c(27);
int D;

int cal_score(vector<int> t){
  int p(0);
  vector<int> l(27,0);
  for(int i(1);i<=D;i++){
    p += s[i][t[i]];
    l[t[i]] = i;
    for(int j(1);j<=26;j++){
      p -= c[j]*(i-l[j]);
    }
  }
  return p;
}

void input(){
  cin>>D;
  for(int i(1);i<27;i++){
    cin>>c[i];
  }
  for(int i(1);i<=D;i++){
    for(int j(1);j<=26;j++){
      cin>>s[i][j];
    }
  }
}

vector<int> cal_greedy(){
  vector<int> t(D+1);
  int nowp(0);
  vector<int> l(D,0);
  for(int i(1);i<=D;i++){
    int maxj(0),maxp(-1e9);
    for(int j(1);j<=26;j++){
      //i日目がj番目の場合
      int tmp(nowp);
      tmp += s[i][j];
      for(int k(1);k<=26;k++){ //ここ一度和を計算しておけば、何回も引くものを計算しなくても良い
        if(k == j) continue;
        tmp -= c[k]*(i - l[k]);
      }
      if(maxp < tmp) {
        maxj = j;
        maxp = tmp;
      }
    }
    t[i] = maxj;
    // 貪欲的にmaxj番目と決める
    nowp += s[i][maxj];
    l[maxj] = i;
    for(int j(1);j<=26;j++){
      nowp -= c[j]*(i - l[j]);
    }
  }
  return t;
}

//nowpの状態からd日目をqに変更する,btは変更前のt
int cal_score_change(int nowp,int d,int q,vector<int> bt){
  nowp -= s[d][bt[d]];
  nowp += s[d][q];
}

vector<int> cal_beemsearch(){
  // vector<int> t(D+1);
  // int nowp(0);
  // vector<int> l(D,0);
  // for(int i(1);i<=D;i++){
  //   int maxj(0),maxp(-1e9);
  //   for(int j(1);j<=26;j++){
  //     //i日目がj番目の場合
  //     int tmp(nowp);
  //     tmp += s[i][j];
  //     for(int k(1);k<=26;k++){ //ここ一度和を計算しておけば、何回も引くものを計算しなくても良い
  //       if(k == j) continue;
  //       tmp -= c[k]*(i - l[k]);
  //     }
  //     if(maxp < tmp) {
  //       maxj = j;
  //       maxp = tmp;
  //     }
  //   }
  //   t[i] = maxj;
  //   // 貪欲的にmaxj番目と決める
  //   nowp += s[i][maxj];
  //   l[maxj] = i;
  //   for(int j(1);j<=26;j++){
  //     nowp -= c[j]*(i - l[j]);
  //   }
  // }
  //return t;
}

int main(){
  clock_t start = clock(); 
  input();
  vector<int> t = cal_greedy();

  double time;
  int cnt(0);
  int nowp = cal_score(t);
  while(time < 1800){
  // while(true){
    int d = max(rand()%(D+1),1);
    int q = max(rand()%27+1,1);
    // int next_score = cal_score_change(nowp,d,q,t);
    int old = t[d];
    t[d] = q;
    int next_score = cal_score(t);
    if(nowp >= next_score){
      t[d] = old;
    }else{
      nowp = next_score;
    }
    cnt++;
    if(cnt%1000 == 0){
      clock_t now = clock();
      time = static_cast<double>(now - start) / CLOCKS_PER_SEC * 1000.0;
      //cout <<"time:" << time << ",point:" << max(1000000+nowp,0) << ",row_point:" << nowp << endl;
    }
  }
  //cout << "ランダムに変更回数:" << cnt << endl;
  // printf("time %lf[ms]\n", time);

  for(int i(1);i<=D;i++){
    cout << t[i] << endl;
  }
  return 0;
}


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

int main() {
    int W, H, x, y;
    double area;
    int methods = 0;
    
    cin >> W >> H >> x >> y;
    area = (double)W * H / 2;
    
    if (((2 * x) == W) && ((2 * y) == H)) {
        methods = 1;
    }
    
    printf("%.10f %d\n", area, methods);
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, y; cin >> n >> y;
  y /= 1000;
  for (int i = 0; i <= n; i++) {
    if (10 * i > y) break;
    for (int j = 0; j <= n - i; j++) {
      int k = n - i - j;
      if (10 * i + 5 * j + k == y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):  # りストに重複した要素があるか判定（要素にリストがある場合）
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) != len(unique_list)


n = int(input())
w = [None]*n
for i in range(n):
    w[i] = input()
# print(w)

if has_duplicates2(w):
    print('No')
    exit()

for i in range(n-1):
    #print(w[i][-1], w[i+1][0])
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main(){
  //入力に対する処理
  int A,B,ans,c;
  c=0;
  cin>>A;
  cin>>B;
  //処理
  if(A>=13){
    ans=B;
  }
  else if(6<=A && A<=12){
    ans=B/2;
  }
  else{
    ans=c;
  }
  //出力に対する処理
  cout<<ans<<endl;
}

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

int main(){
        map<long, long> agents;
        long long n, a;
        cin >> n;
        long long count = 0;
        for (int i = 1; i <= n ; i++){
			cin >> a;
			count += agents[i-a];
			agents[i+a]++;
			}
		cout << count << endl;
        return 0;
}


Measured memory_bytes: 26272
n, k = gets.rstrip.split.map(&:to_i)
hs = gets.rstrip.split.map(&:to_i)

dp = []
dp[0] = 0

1.upto(n-1) do | i |
  dp[i] = dp[i-1] + (hs[i] - hs[i-1]).abs # 1jumpで来たケースをとりあえず代入しとく.

  [i-k, 0].max.upto(i-2) do | j |
    cost = dp[j] + (hs[i]-hs[j]).abs
    dp[i] = cost if dp[i] > cost
  end
end
p dp[-1]

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

int main()
{

    int n, ans = 0;
    cin >> n;
    vector <int> v(n), c(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    for(int i = 0;i < n;i++){
        cin >> c[i];
    }

    for(int i = 0;i < n;i++){
        if(v[i] - c[i] > 0){
            ans += v[i] - c[i];
        }
    }

    cout << ans;

    return 0;

}

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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
#define endl '\n'

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

void sanjeev(int kkkk)
{
    int n,k;
    cin>>n>>k;
    vector<int>A;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        A.push_back(t);
    }

    int fr[n+1]={0};

    fr[0]=0;
    fr[1]=abs(A[1]-A[0]);

    for(int i=2;i<A.size();i++)
    {
        vector<int>temp;
        for(int j=1;j<=k && i-j>=0;j++)
        {
            int a=abs(A[i]-A[i-j])+fr[i-j];
            temp.push_back(a);
        }
        sort(temp.begin(),temp.end());
        fr[i]=temp[0];
    }

    cout<<fr[n-1];

}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 1144
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdbool.h>
#include<stdlib.h>


int main() {
	int n, p[101], a[101];
	char s[101][12],cmp[12];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
		scanf("%d", &p[i]);
		a[i] = i;
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (strcmp(s[j], s[j - 1]) < 0) {
				int pp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = pp;
				strcpy(cmp, s[j - 1]);
				strcpy(s[j - 1], s[j]);
				strcpy(s[j], cmp);
				int mm = p[j - 1];
				p[j - 1] = p[j];
				p[j] = mm;
			}
			if (strcmp(s[j], s[j - 1]) == 0) {
				if (p[j] > p[j - 1]) {
					int pp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = pp;
					strcpy(cmp, s[j - 1]);
					strcpy(s[j - 1], s[j]);
					strcpy(s[j], cmp);
					int mm = p[j - 1];
					p[j - 1] = p[j];
					p[j] = mm;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d\n", a[i]+1);
	}

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, m; 
	int a, b, c, d, e;
	string s, t;
	
	char c1, c2, c3;
	
	static int x[1000] = {};
	static int y[1000] = {};
	
	vector<int> v, u;
	pair<int,int> p;
	
	int r[30] = {};
	
	
	int N, M;
	
	cin>>N>>M;
	
	vector<string> A(N), B(N);
	
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int i = 0; i < N; i++){
		cin>>B[i];
	}
	
	int con = 0;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M ;j++){
			if(A[i][j] != B[i][j]) con++;
		}
	}
	
	cout<<con<<endl;
	return 0;
}


Measured memory_bytes: 11260
import sys;input=lambda:sys.stdin.readline().rstrip();ints=lambda:list(map(int,input().split()))
import numpy as np;from itertools import combinations

def main():
    n,m,x=ints()
    ca,val=[],[]
    for _ in range(n):
        inp=ints()
        ca.append(inp)
        flg=1
        for i in range(1,m+1):
            if inp[i]<x:
                flg = 0
        val.append(inp[0]) if flg==1 else None
    for num in range(2,n+1):
        for v in combinations(ca,num):
            vnp = np.array(v)
            s=vnp.sum(axis=0)
            flg=1
            for i in range(1,m+1):
                if s[i]<x:
                    flg = 0
            val.append(s[0]) if flg==1 else None
    print(-1 if not val else min(val))

if __name__ == '__main__':
    main()

Measured memory_bytes: 27464
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

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

    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }
    
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += a[i];
    }

    ll ans = INF;
    ll temp = 0;
    for (int i = 0; i < N; i++) {
        temp += a[i];
        if (i+1 < N) {
            ans = std::min(ans, std::abs(sum - 2*temp));
        }
    }

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

Measured memory_bytes: 1024
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]

ans = [0] * n
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        ans[i + 1] = ans[i] + 1
    else:
        ans[i + 1] = ans[i]

for i in lr:
    print(ans[i[1]-1]-ans[i[0]-1])


Measured memory_bytes: 30652
/****************************
 * ×÷Õß£ºzxf
 * ÈÕÆÚ£º
 * ±êÌâ£º
 * ÌâºÅ£º
 * ×öÌâ·½·¨£º
 * ½á¹û£º
 * Time used£º
 * Memory used£º
 ****************************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,k,a,b;
vector<int> nei[2007];
int q[2007];
int qsize;
int juli[2007];

void bfs()
{
	for(int i=0;i<qsize;i++)
	{
		int v=q[i];
		for(int j=0;j<SZ(nei[v]);j++)
		{
			int w=juli[v]+2;
			if(juli[nei[v][j]]<=w)continue;
			juli[nei[v][j]]=w;
			q[qsize++]=nei[v][j];
		}
	}
}

int solvevertex(int what)
{
	FOR(i,n)
		juli[i]=Inf;
	juli[what]=0;
	qsize=0;
	q[qsize++]=what;
	bfs();
	int cnt=0;
	FOR(i,n)
		if(juli[i]>k)
			cnt++;
	return cnt;
}

int solveedge(int what1,int what2)
{
	FOR(i,n)
		juli[i]=Inf;
	juli[what1]=juli[what2]=1;
	qsize=0;
	q[qsize++]=what1;
	q[qsize++]=what2;
	bfs();
	int cnt=0;
	FOR(i,n)
		if(juli[i]>k)
			cnt++;
	return cnt;
}

int minn=Inf;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&a,&b);
		a--,b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	for(int v=0;v<n;v++)
		minn=min(minn,solvevertex(v));
	for(int v=0;v<n;v++)
		for(int u=0;u<SZ(nei[v]);u++)
			minn=min(minn,solveedge(v,nei[v][u]));
	printf("%d\n",minn);
	return 0;
}

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

int bubbleSort(int A[], int N) {
    int cnt = 0, flg = 1;
    while (flg) {
        flg = 0;
        for (int j = N - 1; j >= 1; j--) {
            if (A[j] < A[j-1]) {
              swap(A[j], A[j -1]);
              cnt++;
              flg = 1;
            } 
        }
    }
    return cnt;
}

int main() {
    int A[100], N, output;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    output = bubbleSort(A, N);
  
    for (int i = 0; i < N; i++) {
      if(i) cout << " ";
      cout << A[i];
    }
    cout << endl;
    cout << output << endl;  
}


Measured memory_bytes: 3116
package main

import (
	"fmt"
	"strings"
)

func main() {
	var c1,c2 string
	fmt.Scan(&c1,&c2)

	ss1 := strings.Split(c1,"")
	ss2 := strings.Split(c2,"")

	if ss1[0] == ss2[2] && ss1[1] == ss2[1] && ss1[2] == ss2[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
X = read_ints()


def ret_cost(X, P):
    return sum([(x - P) ** 2 for x in X])


ans = 10**10
for P in range(101):
    ans = min(ret_cost(X, P), ans)
print(ans)


Measured memory_bytes: 39024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    string A, B, C; cin >> A >> B >> C;

    int ans = 0;
    for(int i=0; i<N; i++) {
        bool X = (A[i] != B[i]);
        bool Y = (B[i] != C[i]);
        bool Z = (C[i] != A[i]);

        int sum = X + Y + Z;
        if(sum == 2) ans++;
        if(sum == 3) ans += 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    ll l = s.length();
    vector<int> d[30];
    rep(i,l) d[s[i]-'a'].push_back(i+1);
    ll ans = 0;
    int pos = 0;
    rep(i,t.length()){
        int b = t[i] - 'a';
        if(d[b].size() == 0){
            cout << "-1" << endl;
            return 0;
        }
        int a = upper_bound(d[b].begin(),d[b].end(),pos) - d[b].begin();
        if(a < d[b].size()) ans += d[b][a] - pos;
        else {
            a = upper_bound(d[b].begin(),d[b].end(),0) - d[b].begin();
            ans += l + d[b][a] - pos;
        }
        pos = d[b][a];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int N, M{};
  cin >> N;
  vector<int> a(N+1), b(N+1);

  for (int i = 1; i <= N; ++i) {
    cin >> a[i];
  }
  for (int i = N; i; --i) {
    int s{};
    for (int j = 2*i; j <=N; j += i) s += b[j];
    if (a[i] != s%2) {
      b[i] = 1;
      ++M;
    }
  }

  cout << M << endl;
  if (!M) return 0;
  for (int i = 1; i <= N; i++) {
    if (!b[i]) continue;
    cout << (M?"":" ") << i;
    M = 0;
  }
  cout << endl;
}


Measured memory_bytes: 4772
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <iostream>
#include <cstdlib>
#define sbc __builtin_popcount
#define pb push_back
#define em emplace
#define emb emplace_back
int mod = 1e9+7;
using namespace std;
// template<typename T>
	// T pwm(T a,T b)
    // {
        // T p=1,one=1;
        // while(b)
        // {
            // if(b&one) p=p*a%mod;
            // a=a*a%mod;
            // b >>=1;
        // }
        // return p;
    // }

    void solve() {
		string str;
		cin>>str;
		if(str[0]==str[1]&& str[1]==str[2])
		{
			cout<<"No\n";
		}
		else {
			cout<<"Yes\n";
		}
    }

int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
	
   // int t;
   // cin>>t;
   // while(t--)
	  solve();
  
	
    return 0;
}

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

int main()
{
    int N,W;
    cin >> N >> W;
    int v[101],w[101];
    int V[101][10001];
    for(int i=1;i<=N;i++)
    {
        cin >> v[i] >> w[i];
    }
    int i,j;
    for(i=0;i<=N;i++)
       for(j=0;j<=W;j++)
          V[i][j]=0;
    for(i=1;i<=N;i++)
       for(j=1;j<=W;j++)
       {
           if(j-w[i]<0)
             V[i][j]=V[i-1][j];
           else
           {
              V[i][j]=max(v[i]+V[i][j-w[i]],V[i-1][j]);
           }
       }
    cout << V[N][W] << endl;
}


Measured memory_bytes: 7036
# 164 B
A,B,C,D = list(map(int, input().split()))
j = 0
while A>0 and C>0:
    j += 1
    C -= B
    if C <= 0:
        break
    j += 1
    A -= D
    
print('Yes') if j%2==1 else print('No')

Measured memory_bytes: 9048
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
LL a, b;
void input() {
    scanf("%lld %lld", &a, &b);
}

LL gcd(LL a, LL b) {
    while(b > 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}

void solve() {
    LL g = __gcd(a, b);
    LL cnt = 1;
    for(LL i = 2; i*i <= g; i++) {
        if(g % i == 0) {
            cnt++;
            while(g % i == 0) {
                g /= i;
            }
        }
    }
    if(g > 1) cnt++;
    printf("%lld\n", cnt);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


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

int main(int argc, const char * argv[]) {
    long long int a,b,c,d;
    std::cin>>a>>b>>c>>d;
    if(d%2==0&&abs(a-b)<10000000000000000000){
        std::cout<<a-b<<std::endl;
    }else if(d%2==1 &&abs(a-b)<10000000000000000000){
        std::cout<<b-a<<std::endl;
    }else{
        std::cout<<"Unfair"<<std::endl;
    }
    return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

ll gcd(ll x,ll y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}

int a[4],n;
 
signed main(){
	rep(i,0,4){
	    cin>>a[i];
	}
	cin>>n;
	a[0]*=8;
	a[1]*=4;
	a[2]*=2;
	int x=min({a[0],a[1],a[2]})/2;
	sort(a,a+4);
	int ans=(n/2)*a[0];
	if(n%2==1)ans+=x;
	cout<<ans<<endl;
	
	
	
	
	
	
	
	return 0;
}

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

const int MAX_H = 110;
int H, W;
int mp[MAX_H][MAX_H];
int cp[MAX_H][MAX_H];
char S[MAX_H];
int Base[5][5] = {  {6, 3, 1, 4, 6},
                    {2,-1, 2,-1, 2},
                    {1, 3, 6, 4, 1},
                    {5,-1, 5,-1, 5},
                    {6, 3, 1, 4, 6}};

int dx[4] = {0,1,-1, 0};
int dy[4] = {1,0, 0,-1};
bool visited[MAX_H][MAX_H];

void solve() {
    
    stack<pair<int,int> > task;
    task.push(pair<int,int>(0,0));
    while(!task.empty()) {
        pair<int,int> p = task.top(); task.pop();
        int x = p.first, y = p.second;
        if(visited[x][y]) continue;
        visited[x][y] = true;
        if(x == H-1 && y == W-1) { printf("YES\n"); return;}
        for(int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(mp[nx][ny] == -1 || cp[nx][ny] == -1 || mp[nx][ny] != cp[nx][ny]) continue;
            task.push(pair<int,int>(nx,ny));
        }
    }
    printf("NO\n");
}

int main()
{
    scanf("%d %d", &H, &W);
    for(int i = 0; i < H; ++i) {
        scanf("%s", S);
        for(int j = 0; j < W; ++j) {
            if(S[j] == '#') mp[i][j] = -1;
            else mp[i][j] = S[j] - '0';
        }
    }
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            cp[i][j] = Base[i%4][j%4];
        }
    }
    /*
    printf("cp:\n");
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(cp[i][j] == -1) { printf("#"); }
            else printf("%d",cp[i][j]);
        }
        printf("\n");
    }
    */
    solve();
    return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007
constexpr int mod = 1000000007;
class mint {
 public:
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }
};

istream& operator>>(istream& is, const mint& m) {
  is >> m.x;
  return is;
}

ostream& operator<<(ostream& os, const mint& m) {
  os << m.x;
  return os;
}

mint choose(long long n, long long a) {
  mint x, y;
  x.x = 1;
  y.x = 1;
  for (long long i = (0); i < (a); ++i) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}
int main() {
  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
  } else {
    ll a = (2 * y - x) / 3;
    ll b = (2 * x - y) / 3;
    mint ans;
    if (a >= 0 && b >= 0) {
      ans = choose(a + b, min(a, b));
    } else {
      ans.x = 0;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			int diff = abs(A[i] - A[j]);
			ans = max(ans, diff);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

bc = [0]*n
bc[n-1]=n-bisect.bisect_right(c, b[n-1])

for i in range(0,n-1):
  bc[n-2-i]=bc[n-1-i] + n-bisect.bisect_right(c, b[n-2-i])

ans = 0
for i in range(n):
  temp = bisect.bisect_right(b, a[i])
  if temp != n:  
    ans += bc[temp]
  
print(ans)

Measured memory_bytes: 24180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Console.ReadLine().ToInt();
		
		Console.WriteLine(p + p*p + p*p*p);
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27380
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  int k;
  ve<int> A(5);
  rep(i, 5){
    ci(A.at(i));
  }
  ci(k);
  if(abs(A.at(0) - A.at(4)) > k){
        co(":(");
        rt;
  }
  co("Yay!");
}

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

#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a=(a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    for(ll i = 2;i < MAX; i++)
    {
        if(prime[i-1])
        {
            for(ll j = i*i; j < MAX; j += i)
                prime[j-1] = false;
        }
    }
}

void getfact(vector<ll>&fact, vector<ll>&factinv)
{
    fact[0] = 1;
    factinv[0] = 1;
    
    for(ll i = 1; i < MAX; i++)
        fact[i] = (fact[i-1] * i)%MOD;
    
    for(ll i = 1; i < MAX; i++)
        factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,x;
    cin>>n>>x;
    vector<ll>a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    vector<ll>res;
    map<ll, ll>mp;
    ll ind=a[0];
    res.push_back(ind);
    mp[ind]=0;
    ll k=1;
    ll index;
    while(true)
    {
        ind=a[ind-1];
        if(mp.find(ind)!=mp.end())
        {
            index=mp[ind];
            break;
        }
        res.push_back(ind);
        mp[ind]=k;
        k++;

        //cout<<ind<<" ";
    }
    //cout<<index;
    if(x<index+1)
        cout<<res[x-1];
    else
    {   //cout<<res.size();
        ll y=x-index;
        ll z=res.size()-index;
        x=y%z;
        //cout<<x<<" ";
        if(x==0)
        {   x=(res.size())-1;
            cout<<res[x];
        }
        else
            cout<<res[x-1+index];
    }
    return 0;
}

Measured memory_bytes: 18524
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    sort(begin(A), end(A));
    sort(begin(B), end(B));
    sort(begin(C), end(C));

    vector<ll> cnt1(N + 1);
    for(int i = 1; i <= N; ++i) {
        cnt1[i] = lower_bound(begin(A), end(A), B[i - 1]) - begin(A);
    }
    for(int i = 0; i < N; ++i) {
        cnt1[i + 1] += cnt1[i];
    }
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        int idx = lower_bound(begin(B), end(B), C[i]) - begin(B);
        res += cnt1[idx];
    }
    cout << res << endl;
}


Measured memory_bytes: 2176
#include<stdio.h>

void name_transformation(int year, int month, int day);

int main(void)
{
    int a, b, c;/*aは年、 bは月、cは日*/
    while((scanf("%d %d %d\n",&a, &b, &c)) != EOF){
        name_transformation(a, b, c);
    }
    return 0;
}

void name_transformation(int year, int month, int day)
{
    int gengou;
    if (year >= 1989){
        if( year > 1989){
            gengou = year - 1988;
            printf("heisei %d %d %d\n", gengou, month, day);
        }else {
            if (month >= 1){
                if ( month > 1){
                    printf("heisei 1 %d %d\n", month, day);
                }else {
                    if( day >= 8){
                        printf("heisei 1 1 %d\n", day);
                    }else{
                        printf("showa 64 1 %d\n", day);
                    }
                }
            }
        }        
    }else if(year >= 1926){
        if( year > 1926){
            gengou = year - 1925;
            printf("showa %d %d %d\n", gengou, month, day);
        }else {
            if (month == 12){
                 if ( day >= 25){
                    printf("showa 1 12 %d\n", day);
                }else {
                    printf("taisho 15 12 %d\n", day);
                }
            }
        }            
    }else if (year >= 1912){
        if (year > 1912){
            gengou = year - 1911;
            printf("taisho %d %d %d\n", gengou, month, day);
        }else {
            if (month >= 7){
                 if ( month > 7){
                    printf("taisho 1 %d %d\n", month, day);
                }else {
                    if (day >= 30){
                        printf("taisho 1 7 %d\n", day);
                    }else{
                        printf("meiji 45 7 %d\n", day);
                    }
                }
            }
        }        
    }else if (year >= 1868){
        if (year > 1868){
            gengou = year - 1867;
            printf("meiji %d %d %d\n", gengou, month, day);
        }else {
            if (month >= 9){
                 if ( month > 9){
                    printf("meiji 1 %d %d\n", month, day);
                 }else {
                    if (day >= 8){
                        printf("meiji 1 9 %d\n", day);
                    }else{
                        printf("pre-meiji\n");
                    }
                }
            }
        }        
    }else{
        printf("pre-meiji\n");
    }
}
    
    
    
   

Measured memory_bytes: 1040
n,m,x = list(map(int,input().split()))
b = []
import numpy as np
for i in range(n):
    ca = list(map(int,input().split()))
    b.append(ca)
b = np.array(b)
ans = float('inf')
for i in range(1<<n):
    num = np.array([0 for j in range(m+1)])
    for k in range(n):
        if (i>>k&1)==1:
            num += b[k]
    if (num[1:]>=x).sum()==m:
        ans = min(ans, num[0])
print(ans if ans!=float('inf') else -1)

Measured memory_bytes: 27164
#include <cassert>
#include <iostream>

using namespace std;

typedef long long ll;

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

const int MAX_N = 100000;
const ll MOD = 998244353LL;

ll calc(ll base, ll exponent) {
    assert(base > 0);
    assert(exponent >= 0);

    if (exponent == 0) {
        return 1LL;
    }

    ll answer = base % MOD;
    while (--exponent > 0) {
        answer = (answer * (base % MOD)) % MOD;
    }
    return answer;
}

int n;
int d[MAX_N];
int b[MAX_N];

int main(void) {
    cin >> n;

    int max = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        d[i] = x;
        b[x]++;
        if (x > max) {
            max = x;
        }
    }

    if (d[0] != 0 || b[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    ll answer = 1;
    for (int i = 1; i <= max; i++) {
        if (b[i] == 0) {
            answer = 0;
            break;
        }
        answer = (answer * calc(b[i-1], b[i])) % MOD;
    }

    cout << answer << endl;
    
    return 0;
}


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

int N;
string s;
string patternW = "", patternB = "";
const char unntiW[2] = {'0', '1'};
const char unntiB[2] = {'1', '0'};

int main() {
    cin >> s;
    N = s.size();
    bool flag = 0;
    for (int i = 0; i < N; i++) {
        patternW += unntiW[flag];
        patternB += unntiB[flag];
        flag = !flag;
    }

    int countW = 0, countB = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] != patternW[i]) countW++;
        if (s[i] != patternB[i]) countB++;
    }

    int ans = min(countW, countB);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  int ans = 0;
  int n, a[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  cin >> n;
  REP(i,0,n){
    int inter;
    cin >> inter;
    //cout << inter << " : "; //--debug
    REP(j,1,9){
      //cout << j*400 << " "; //--debug
      if(inter < j*400){
        a[j-1]++;
        //cout <<"=>" << j; //--debug
        break;
      }
    }
    //cout  <<endl; //--debug
    if(inter >= 3200)a[8]++;
  }
  REP(i,0,8){
    if(a[i]>0){
      ans++;
    }
  }
  cout << max(ans,1) << " " << ans + a[8];

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3576
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for k in range(K):
        A_temp=[0]*(N+1)
        for i in range(N):
            A_temp[max(0,i-A[i])]+=1
            if i+A[i]+1<=N-1:
                A_temp[i+A[i]+1]-=1
            
        A[0]=A_temp[0]
        for j in range(1,N):
            A_temp[j]+=A_temp[j-1]
            A[j]=A_temp[j]
        for ai in A:
            if ai != N:
                break
        else:
            break
                
    print(' '.join([str(a) for a in A]))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 148692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
int main(){
	cin>>n;
	repn(i,n){
		cin>>a[i];
	}
	repn(i,n){
		if(i>=2 && a[i-1] >= a[i]);
		else a[i]--;
	}
	bool bad=0;
	repn(i,n-1)if(a[i] > a[i+1])bad=1;
	puts(bad?"No":"Yes");
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int w,h,v[200][200];
char s[200][200];
void func(int y,int x){
	v[y][x]=0;
	if(s[y][x]=='.')
		cout<<x<<' '<<y<<endl;
	else if(s[y][x]=='>'){
		if(v[y][x+1]==1)
			func(y,x+1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='<'){
		if(v[y][x-1]==1)
			func(y,x-1);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='v'){
		if(v[y+1][x]==1)
			func(y+1,x);
		else
		cout<<"LOOP"<<endl;
	}
	else if(s[y][x]=='^'){
		if(v[y-1][x]==1)
			func(y-1,x);
		else
		cout<<"LOOP"<<endl;
	}
	
}

int main(){
	while(cin>>h>>w,w||h){
		for(int i=0;i<h;i++)
		cin>>s[i];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		v[i][j]=1;
		func(0,0);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				boolean[][] gems=new boolean[21][21];
				for(int i=0; i<n; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					gems[a][b]=true;
				}
				int m=sc.nextInt();
				int nowx=10;
				int nowy=10;
				int nextx=0;
				int nexty=0;
				for(int i=0; i<m; i++) {
					String s=sc.next();
					int num=sc.nextInt();
					if(s.equals("N")) {
						nextx=nowx;
						nexty=nowy+num;
					}
					else if(s.equals("E")) {
						nextx=nowx+num;
						nexty=nowy;
					}
					else if(s.equals("S")) {
						nextx=nowx;
						nexty=nowy-num;
					}
					else if(s.equals("W")) {
						nextx=nowx-num;
						nexty=nowy;
					}
					for(int x=Math.min(nowx, nextx); x<=Math.max(nowx, nextx); x++) {
						for(int y=Math.min(nexty, nowy); y<=Math.max(nexty, nowy); y++) {
							if(gems[x][y]) {
								gems[x][y]=false;
							}
						}
					}
					nowx=nextx;
					nowy=nexty;
				}
				int flag=0;
				for(int i=0; i<=20; i++) {
					for(int j=0; j<=20; j++) {
						if(gems[i][j]) {
							flag=1;
						}
					}
				}
				System.out.println((flag==1)? "No":"Yes");
			}
		}
	}
} 


Measured memory_bytes: 42932
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int r, D, x; cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << '\n';
    }
    return 0;
}


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

int main()
{
    int k,a,b,i,j,m,n;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
}


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

int main () {
    int N;
    scanf("%d", &N);
    int *d = malloc((1+N) * sizeof(int));
    for (int i = 1; i <= N; i++) {
        scanf("%d", &d[i]);
    }
    int ans = 0;
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
            ans += (d[i] * d[j]);
        }
    }

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


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

int dp[101][101];
char s[101][101];

void solve()
{
    int H, W;
    cin >> H >> W;
    REP0 (i, H)
    {
        REP0 (j, W)
        {
            cin >> s[i][j];
            dp[i][j] = INTINF;
        }
    }

    dp[0][0] = (s[0][0] == '#');

    REP0 (i, H)
    {
        REP0 (j, W)
        {
            if (i > 0)
                dp[i][j] = min(dp[i - 1][j] + int(s[i - 1][j] == '.' and s[i][j] == '#'), dp[i][j]);
            if (j > 0)
                dp[i][j] = min(dp[i][j - 1] + int(s[i][j - 1] == '.' and s[i][j] == '#'), dp[i][j]);
            // cout << dp[i][j] << ' ';
        }
        // cout << endl;
    }

    cout << dp[H - 1][W - 1] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      r: usize,
    }
    puts!("{}", 3*r*r);
}


Measured memory_bytes: 4352