akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<char> inputStr;

    bool isSimilar = false;

    for (int i = 0; i < 6; ++i)
    {
        char input;
        cin >> input;
        inputStr.push_back(input);

        if (i == 3 && inputStr.at(2) == inputStr.at(3))
        {
            isSimilar = true;
        }
        else if (isSimilar && i == 5 && inputStr.at(4) != inputStr.at(5))
        {
            isSimilar = false;
        }
    }

    cout << (isSimilar ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def f(s,n):
    res = 0
    flg = False
    for i in range(1,n):
        if flg:
            flg = False
            continue
        if S[i] == S[i-1]:
            flg = True
            res += 1
    return res
S = input()
K = int(input())
if len(set(list(S))) == 1:
    print(len(S)*K//2)
    exit()
ans = f(S,len(S))
S = S * 2
print(ans + (f(S,len(S)) - ans) * (K-1))

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

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<char>> vec(H, vector<char>(W));

    vector<vector<int>> black_hw(2);
    

    bool insert_h;
    bool insert_w;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> vec.at(i).at(j);
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (j == 0)
                insert_h = false;
            
            if (vec.at(i).at(j) == '#')
                insert_h = true;

            if (j == W - 1 && insert_h){
                black_hw.at(0).push_back(i);
            }
        }
        
    }
    

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if (j == 0)
                insert_w = false;
            
            if (vec.at(j).at(i) == '#')
                insert_w = true;

            if (j == H - 1 && insert_w){
                black_hw.at(1).push_back(i);
            }
        }
        
    } 
    
    for (int i : black_hw.at(0)){
        
        for (int j : black_hw.at(1)){
            
            cout << vec.at(i).at(j);

            if (j == black_hw.at(1).at(black_hw.at(1).size() - 1)){
                cout << "" << endl;
            }
        }
    } 



    
    
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<utility>
#include<cctype>
#include<bitset>
#include<time.h>
#define ll long long
#define mp make_pair
using namespace std;
/*--------main part---------*/
int n,q,k;
int a[100005];
int dis[30][100005];
int dat[30];
set<pair<int,int> > s;
int main()
{

	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(mp(a[i],i));
	}
	dat[0]=1;
	for(int i=1;i<20;i++)
	{
		dat[i]=dat[i-1]*2;
	}
	cin>>k;
	for(int i=0;i<n;i++)
	{
		s.insert(mp(a[i]+k,n));
		set<pair<int,int> >::iterator it=s.find(mp(a[i]+k,n));
		it--;
		dis[0][i]=it->second;
		it++;
		s.erase(it);
	}
	for(int i=1;i<20;i++)
	{
		for(int j=0;j<n;j++)
		{
			dis[i][j]=dis[i-1][dis[i-1][j]];
		}
	}
	cin>>q;
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		l--;r--;
		if(l>r)
		{
			swap(l,r);
		}
		int ans=0;
		for(int i=19;i>=0;i--)
		{
			if(dis[i][l]<r)
			{
				l=dis[i][l];
				ans+=dat[i];
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 16060
a = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
b = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
c = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
d = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]

n = int(input())
value = [input() for i in range(n)]

for x in value:
    tower,flore,memo,num = x.split()
    tower = int(tower)
    flore = int(flore)
    memo = int(memo)
    num = int(num)
    if tower == 1:
        a[flore -1][memo -1] += num
    elif tower == 2:
        b[flore -1][memo -1] += num
    elif tower == 3:
        c[flore -1][memo -1] += num
    elif tower == 4:
        d[flore -1][memo -1] += num

for i in a: 
    print(" "+" ".join(map(str,i)))
print("####################")
for i in b:
    print(" "+" ".join(map(str,i)))
print("####################")
for i in c:
    print(" "+" ".join(map(str,i)))
print("####################")
for i in d:
    print(" "+" ".join(map(str,i)))



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

int main() {
  int64_t n, d;
  cin >> n >> d;
  vector<int64_t> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    int64_t x = a.at(i) * a.at(i) + b.at(i) * b.at(i);
    if (x <= d * d) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 6312
#include<stdio.h>

int main(){
int x, y, min, max, rem;

scanf("%d %d", &x, &y);

if(x == y){
printf("%d\n", x);
return 0;
}

if(x < y){
min = x;
max = y;
}else{
min = y;
max = x;
}

while(min > 0){
rem = max%min;
max = min;
min = rem;
}

printf("%d\n", max);

return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;
const ll inf = 1LL << 60;

struct edge {
    ll to;
    ll cost;
};

ll K;
vector<vector<edge>> graph(K, vector<edge>());
vector<ll> dist(K);

void dijkstra (ll s) {
    priority_queue<pair<ll, ll>> p;
    Rep (i, K) dist[i] = inf;
    dist[s] = 0;
    p.push(make_pair(0, s));

    while (!p.empty()) {
        auto next = p.top();
        p.pop();
        ll v = next.second;
        if (dist[v] < next.first) continue;
        for (auto e : graph[v]) {
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                p.push(make_pair(-dist[e.to], e.to));
            }
        }
    }
}

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

    ll K;
    cin >> K;
    vector<vector<pair<ll, ll>>> graph(K, vector<pair<ll, ll>>());
    Rep (i, K) {
        graph[i].push_back(make_pair((i+1)%K, 1));
        graph[i].push_back(make_pair(i*10%K, 0));
    }

    vector<ll> dist(K, inf);
    dist[1] = 0;
    priority_queue<pair<ll, ll>> p;
    p.push(make_pair(0, 1));

    while(!p.empty()) {
        auto next = p.top();
        p.pop();
        ll v = next.second;
        ll d = next.first;
        if (dist[v] < d) continue;
        for (auto e : graph[v]) {
            ll ev = e.first;
            ll cost = e.second;
            if (dist[ev] > dist[v] + cost) {
                dist[ev] = dist[v] + cost;
                p.push(make_pair(-dist[ev], ev));
            }
        }
    }

    cout << dist[0] + 1 << endl;
}

Measured memory_bytes: 9212
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

int main()
{
	string S;
	ll K;

	cin >> S >> K;

	char ans = '1';
	for (int i = 0; i < S.size() && i < K; ++i)
	{
		if (S[i] != '1')
		{
			ans = S[i];
			break;
		}
	}

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

Measured memory_bytes: 3604
#include<stdio.h>
int main(){
int x,y,z;
scanf("%d %d %d",&x,&y,&z);
if(x+y<y+z){
    if(x+y<x+z)printf("%d",x+y);
    else printf("%d",x+z);
}
else{
    if(y+z<x+z)printf("%d",z+y);
    else printf("%d",x+z);
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdexcept>
#include <cstring>

using namespace std;

template<class T>
class Node {
public:
    Node(T v) : Node(v, nullptr, nullptr) {};
    Node(T v, Node<T>* p) : Node(v, p, nullptr) {};
    Node(T v, Node<T>* p, Node<T>* n) : value {v}, prev {p}, next {n} {};
    T get_value(){
        return value;
    };
    Node<T>* get_next(){
        return next;
    };
    Node<T>* get_prev(){
        return prev;
    };
    void set_prev(Node<T>* p){
        prev = p;
    };
    void set_next(Node<T>* p){
        next = p;
    };
private:
    T value;
    Node<T>* prev;
    Node<T>* next;
};

template<class T>
class linkedlist {
public:
    linkedlist<T>() : head_ptr {nullptr}, last_ptr {nullptr} {};
    void insert(T v){
        auto node = new Node<T>(v, nullptr, head_ptr);
        if(head_ptr){
            head_ptr->set_prev(node);
            head_ptr = node;
        } else {
            head_ptr = node;
            last_ptr = node;
        }
    };
    void delete_key(T v){
        auto ptr = head_ptr;
        while(ptr){
            if(ptr->get_value() == v){
                Node<T>* prev = ptr->get_prev();
                Node<T>* next = ptr->get_next();
                if(prev){
                    prev->set_next(next);
                } else {
                    head_ptr = next;
                }
                if(next){
                    next->set_prev(prev);
                } else {
                    last_ptr = prev;
                }
                delete ptr;
                return;
            }
            ptr = ptr->get_next();
        }
    };
    void deleteFirst(){
        if(head_ptr){
            head_ptr = head_ptr->get_next();
            if(head_ptr){
                delete head_ptr->get_prev();
                head_ptr->set_prev(nullptr);
            } else {
                last_ptr = nullptr;
            }
        }
    };
    void deleteLast(){
        if(last_ptr){
            last_ptr = last_ptr->get_prev();
            if(last_ptr){
                delete last_ptr->get_next();
                last_ptr->set_next(nullptr);
            } else {
                head_ptr = nullptr;
            }
        }
    };
    void print(){
        auto ptr = head_ptr;
        while(ptr){
            if(ptr != head_ptr) cout << ' ';
            cout << ptr->get_value();
            ptr = ptr->get_next();
        }
        cout << '\n';
    };
private:
    Node<T>* head_ptr;
    Node<T>* last_ptr;
};

int main(){
    int n;
    cin >> n;
    char command[20];
    int k;
    auto linkedl = linkedlist<int>();
    while(n--){
        scanf("%s", command);
        if(!strcmp(command, "insert")){
            scanf("%d", &k);
            linkedl.insert(k);
        } else if(!strcmp(command, "delete")){
            scanf("%d", &k);
            linkedl.delete_key(k);
        } else if(!strcmp(command, "deleteFirst")){
            linkedl.deleteFirst();
        } else if(!strcmp(command, "deleteLast")){
            linkedl.deleteLast();
        } else {
            throw invalid_argument("illegal command");
        }
    }
    linkedl.print();
}

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

int64_t solve() {
    int K; cin >> K;
    if(K % 2 == 0) return -1;
    int r = 0;
    for(int i = 0; i <= 10 * K; ++i) {
        r = (10 * r + 7) % K;
        if(r == 0) return i + 1;
    }
    return -1;
}

int main() {
    cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
          int i,j,m,f,r;
          for(i=0;;i++)
          {
                    scanf("%d %d %d",&m,&f,&r);
                    if((m==-1)&&(f==-1)&&(r==-1))
                    {
                              break;
                    }
                    else
                    {
                              if((m==-1)||(f==-1))
                              {
                                        printf("F\n");
                              }
                              else if(m+f>=80)
                              {
                                        printf("A\n");

                              }
                              else if(m+f>=65)
                              {
                                        printf("B\n");
                              }
                              else if(m+f>=50)
                              {
                                        printf("C\n");
                              }
                              else if((m+f>=30))
                              {
                                   if(r<50)
                                   {
                                             printf("D\n");
                                   }
                                   else
                                   {
                                             printf("C\n");
                                   }
                              }
                              else if(m+f<30)
                              {
                                        printf("F\n");
                              }
                    }
          }


}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    deque<int> b;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (n % 2 == (i + 1) % 2)
        {
            b.push_front(a);
        }
        else
        {
            b.push_back(a);
        }
    }
    for (auto it : b)
    {
        cout << it << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main(){
    int n,k; cin>>n>>k;
    int l[60];
    rep(0,i,n) cin>>l[i];
    sort(l,l+n,greater<int>());
    int res = 0;
    rep(0,i,k){
        res += l[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = '-' + sr()
T = '-' + sr()
Q = ir()
cnt_S = np.array([[0, 0] for _ in range(len(S))])
cnt_T = np.array([[0, 0] for _ in range(len(S))])
for i, s in enumerate(S[1:], 1):
    if s == 'A':
        cnt_S[i][0] = 1
    else:
        cnt_S[i][1] = 1

for i, t in enumerate(T[1:], 1):
    if t == 'A':
        cnt_T[i][0] = 1
    else:
        cnt_T[i][1] = 1

np.add.accumulate(cnt_S, axis=0, out=cnt_S)
np.add.accumulate(cnt_T, axis=0, out=cnt_T)

for _ in range(Q):
    a, b, c, d = lr()
    num_S = cnt_S[b][0] - cnt_S[b][1] - (cnt_S[a-1][0] - cnt_S[a-1][1])
    num_T = cnt_T[d][0] - cnt_T[d][1] - (cnt_T[c-1][0] - cnt_T[c-1][1])
    if (num_S - num_T) % 3 == 0:
        print('YES')
    else:
        print('NO')

# 58

Measured memory_bytes: 25464
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean judge = false;

        for(int i=0;i<3;i++){
            double a = N/Math.pow(10.0,2.0-i);
            int n = (int)Math.floor(a);
            if(n==7){
                judge = true;
                break;
            }else{
                N -= n*Math.pow(10.0,2.0-i);
            }
        }
        if(judge==true){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, x; cin >> n >> x;
    int d = 0, res = 1;
    for (int i = 0; i < n; i++) {
        int l; cin >> l;
        d += l;
        res += (d <= x);
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int n, x, res;
    while(true) {
        cin >> n >> x;
        if(n == 0 && x == 0) {
            break;
        }
        res = 0;
        rep(i, n) {
            rep(j, n) {
                rep(k, n) {
                    if(i != j && j != k && i != k && i + j + k + 3 == x) {
                        res++;
                    }
                }
            }
        }
        res /= 6;
        cout << res << endl;
    }
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll a,b,ans=0;
    cin >> a >> b;
    for(ll i=1;i<sqrt(b)+1;i++){
        if(b%i==0){
            ll c=b/i;
            if(c<=b/a){
                ans = max(c,ans);
            }
            else{
                if(i<=b/a){
                    ans = max(i,ans);
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
	int n;
	cin >> n;
	bool ans = false;
	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			if(4*i + 7*j == n){
				ans = true;
			}
		}
	}
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MOD = 1e9 + 7;
int sum(int a, int b) { return (a + b) % MOD; }
int prod(int a, int b) { return a * 1ll * b % MOD; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N, K;
    cin >> N >> K;
    N *= 2;

    vi partner(N, -1);
    for (int i = 0; i < K; i++) {
        int u, v;
        cin >> u >> v;
        partner[u-1] = v-1;
        partner[v-1] = u-1;
    }

    vvi unpaired(N, vi(N));
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            if (j > i) unpaired[i][j] = unpaired[i][j-1];
            unpaired[i][j] += partner[j] == -1;
        }
    }

    vi ways(N + 1);
    ways[0] = 1;
    for (int w = 2; w <= N; w += 2)
        ways[w] = prod(w - 1, ways[w-2]);

    vvi dp(N, vi(N));
    for (int jmi = 1; jmi < N; jmi++) {
        for (int i = 0; i + jmi < N; i++) {
            int j = i + jmi;
            bool can = true;
            for (int k = i; k <= j; k++) {
                if (partner[k] != -1 && (partner[k] < i || partner[k] > j))
                    can = false;
            }
            if (unpaired[i][j]&1)
                can = false;
            if (can) {
                dp[i][j] = ways[unpaired[i][j]];
                for (int k = i; k < j; k++)
                    dp[i][j] = sum(dp[i][j], MOD - prod(dp[i][k],
                                ways[unpaired[k+1][j]]));
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            ans = sum(ans, prod(dp[i][j], ways[N - 2 * K - unpaired[i][j]]));
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>s;
    if (s=="A") {
        cout<<"T"<<endl;
    }
    if (s=="T") {
        cout<<"A"<<endl;
    }
    if (s=="C") {
        cout<<"G"<<endl;
    }
    if (s=="G") {
        cout<<"C"<<endl;
    }
}



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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int c = 1;
    rep(i,1,n){
        if(a[i]!=a[i-1]){c++;}
    }
    int ans = (c%2?c:c-1);
    cout<<ans<<endl;
}

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

#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


void solve() {

    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    ll sum = 0;
    ll cnt = 0;
    sum = a[n - 1];
    cnt++;
    ll i = n - 2;

    while (cnt < n-1) {
        if (n-1 - cnt > 1) {
            cnt = cnt + 2;
            sum = sum + (2*a[i]);
            i--;

        }else{
            cnt++;
            sum =sum + a[i];
        }
        //cout << cnt << " " << sum << endl;

    }
    cout << sum << endl;




}


int32_t main()
{

    IOS

    int T;
    T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }




}


Measured memory_bytes: 5264
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int t[n+1],x[n+1],y[n+1];
    t[0]=x[0]=y[0]=0;
    for(int i=0;i<n;i++)
    {
        cin>>t[i+1]>>x[i+1]>>y[i+1];
    }
     for(int i=0;i<n;i++)
    {
        int dt=t[i+1]-i[t];
        int d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if((d+dt)%2==0&&d<=dt)
        {}
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    int n;cin>>n;
    vector<ll>f(n);
    vector<vector<int> >p(n,vector<int>(11));
    rep(i,n){
        ll a=0;
        rep(j,10){
            int b;cin>>b;
            a=a*2+b;
        }
        f[i]=a;
    }
    rep(i,n)rep(j,11)cin>>p[i][j];
    ll ma=-1000000000;
    REP(i,1,1024){
        ll cntp=0;
        rep(j,n){
            int cnt=0;
            rep(k,10){
                if((i&(1<<k))&&(f[j]&(1<<k)))cnt++;
            }
            cntp+=p[j][cnt];
        }
        ma=max(cntp,ma);
    }
    cout<<ma<<endl;
}

Measured memory_bytes: 256
open Scanf
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)
let () =
  let h, w, d = scanf "%d %d %d" (fun a b c -> a, b, c) in
  let pos = Array.make (h*w+1) (-1, -1) in
  let steps = Array.make (h*w+1) (h*w) in

  for_iter_ 0 h (fun i -> for_iter_ 0 w (fun j -> scanf " %d" (fun v -> pos.(v) <- (i, j))));

  for_iter_ 0 d (fun i -> steps.(i) <- 0);
  for_iter_ d (h*w+1) (fun i ->
    let (x', y'), (x, y) = pos.(i-d), pos.(i) in
    steps.(i) <- steps.(i-d) + abs (x-x') + abs (y-y'));

  scanf " %d" (fun q -> for_iter_ 0 q (fun _ ->
    scanf " %d %d" (fun x y -> steps.(y) - steps.(x))
    |> Printf.printf "%d\n"))

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

ll modP(ll x, ll y, ll MOD)
{
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll x; 
    cin>>x; 
    if(x>=30) 
    cout<<"Yes\n"; 
    else 
    cout<<"No\n";
    //cout<<ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//    cin >> t;

    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}





Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 405;
ll dp[N][N], pre[N];
int main() {
    int n; cin>>n; int a[n+1];
    ll m = 1e18;
    for(int i = 1; i <= n; ++i) cin>>a[i];
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j)
            dp[i][j] = 1e18;
    for(int i = 1; i <= n; ++i)
        dp[i][i] = 0, pre[i] = pre[i-1] + a[i];
    for(int len = 2; len <= n; ++len) {
        for(int i = 1; i+len-1 <= n; ++i) {
            int k = i+len-1;
            for(int j = i; j < k; ++j)
                dp[i][k] = min(dp[i][k], dp[i][j] + dp[j+1][k]);
            dp[i][k] += pre[k] - pre[i-1];
        }
    }
    cout<<dp[1][n]<<"\n";
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL A,B,C,K;cin >> A >> B >> C >> K;
    LL ans = A-B;
    if(K % 2 != 0)cout << ans * -1 << endl;
    else cout << ans << endl;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

ll calc(ll n) {
    ll t = 1;
    for (int i = 2; i <= n; i++) {
        t = (t * i) % MOD;
    }
    return t;
}

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

    if (abs(a - b) == 1) {
        cout << ((calc(a) * calc(b)) % MOD) << endl;
    } else if (a == b) {
        cout << ((((calc(a) * calc(b)) % MOD) * 2) % MOD) << endl;
    } else {
        cout << 0 << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll l,r,d,i,j;
    cin>>l>>r>>d;
    ll q1 = l/d;
    ll r1 =l%d;
    ll r2 = r%d;
    ll q2 = r/d;
    if(r1==0 && r2==0) cout<<(q2-q1+1);
    else if(r1!=0 && r2==0) cout<<q2-q1;
    else if(r1==0 && r2!=0) cout<<q2-q1+1;
    else cout<<q2-q1;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<sstream>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
#define PA pair<int,int>
#define asd signed QP;scanf("%d",&QP);while(QP--)
typedef pair<int,int> PI;
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;}
int lowbit(int x){return x&-x;}
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
//
const double eps=1e-6;
const int mod=1e9+7;
const int modd=mod-1;
//
const int maxm=1e5+5;


void solve(){
    int a=re,b=re;
    if(b>=a){
        puts("unsafe");
    }else puts("safe");

}
signed main(){
//    while(1)
//    asd
        solve();
    return 0;
}
/*

*/


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> lltpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = LLONG_MAX;
constexpr ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }



int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	ll ans = 1;
	if (n > k) {
		ans = 0;
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			ans *= k;
			ans %= MOD;
			k--;
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	string s;
	cin >> n >> s;
	bool lb=0;
	bool rb=0;
	int cnt=0;
	int ans=0;
	REP(i,n){
		for(char c='a';c<='z';c++){
			lb=0;rb=0;
			REP(j,i){
				if(s[j]==c) lb=1;
			}
			for(int k=i;k<n;k++){
				if(s[k]==c) rb=1;
			}
			if(lb&&rb) cnt++;
		}
		ans=max(ans,cnt);
		cnt=0;
	}
	cout << ans << endl;

/////////////////////////////////////////////
}


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


def swap(A,i,j):
  tmp = A[i]
  A[i] = A[j]
  A[j] = tmp

def partition(A, p, r):
  x = A[r]
  i = p - 1
  for j in range(p, r):
    if A[j] <= x:
      i += 1
      swap(A, i, j)
  swap(A, i + 1, r)
  return i + 1  
  
idx = partition(A, 0, n-1)

def tostr(x,i):
  if i == idx :
    return "[{}]".format(x)
  return str(x)

print(" ".join([tostr(x,i) for i,x in enumerate(A)]))


Measured memory_bytes: 16388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

vs pat = { "###.", "#.#.", "###.", "...." };

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int aa, bb; cin >> aa >> bb;
	vs ans(100);
	REP(i, 100)
	{
		REP(j, 25)
		{
			ans[i] += pat[i % 4];
		}
	}
	vector<pii> hh, ww;
	REP(i, 25)REP(j, 25)
	{
		hh.emplace_back(i * 4 + 1, j * 4 + 1);
		if(j != 24) ww.emplace_back(i * 4, j * 4 + 3);
	}
	REP(i, 24)
	{
		ww.emplace_back(i * 4 + 3, 0);
	}
	int w = 626 - aa;
	int b = 625 - bb;
	REP(i, w)
	{
		int x = hh[i].first;
		int y = hh[i].second;
		ans[x][y] = '#';
	}
	REP(i, b)
	{
		int x = ww[i].first;
		int y = ww[i].second;
		ans[x][y] = '#';
	}
	cout << "100 100" << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        
        int sum = 0;
        for (int i = 0; i < n; i++) {
        	sum += Math.abs(sc.nextInt() - sc.nextInt()) + 1;
		}
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 24148
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans =0
for a in A:
    b = 2**(a.bit_length())-a
    if b in d:
        if d[b] >=1 and d[a] >= 1:
          if a == b and d[b] ==1:
            continue
          ans += 1 
          d[b]-= 1
          d[a]-= 1

print(ans)
            

Measured memory_bytes: 33072
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int dp[21000][300];

void f(int n,int m){

  rep(i,n+1){
    rep(j,300){
      dp[i][j] = inf;
    }
  }
  int c[1000];
  rep(i,m){
    cin>>c[i];
  }

  dp[0][128]=0;

  FOR(i,1,n+1){
    int x;
    cin>>x;
    rep(j,256){
      rep(k,m){
        int a = j+c[k];
        a = min(255,a);
        a = max(0,a);
        int d = (a-x)*(a-x);
        dp[i][a] = min(dp[i][a],dp[i-1][j]+d);
      }
    }

  }
  int ans = inf;
  rep(i,256){
    ans = min(ans,dp[n][i]);
  }

  cout<<ans<<endl;

}

int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0) break;
    f(n,m);
  }

  return 0;
}


Measured memory_bytes: 26448
n = int(input())
b=[[0]*9 for i in range(9)]
count = 0

def get_first(num):
    log = 1
    k=num
    while True:
        if k < 10:
            break
        k = k//10
        log+=1
    #print(k,log)
    return (k,log)

for i in range(1,n+1):
    f,_ = get_first(i)
    l   = i%10
    if l==0:
        continue
    b[f-1][l-1] +=1
#print(b)

for i in range(9):
    for j in range(9):
        count+=b[i][j]*b[j][i]


print(count)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, k, m;
    ArrayList<String> stones;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    k = sc.nextInt();
	    m = sc.nextInt();
	    if(n!=0){
		stones = new ArrayList<String>();
		for(int i=0; i<n; i++)
		    stones.add(i, Integer.toString(i+1));
		solve();
	    }
	}
    }

    void solve(){
	int place = (m-1)%n;
	stones.remove(place);
	int count = stones.size();
	while(count>1){
	    place = (place+k-1)%count;
	    if(place<0) place = count-1;
	    stones.remove(place);
	    count = stones.size();
	}
	System.out.println(stones.get(0));
    }
}

Measured memory_bytes: 55328
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var ans = 0;
            for (var i = 0; i <= 999; i++) {
                var v = string.Format("{0:D3}", i);
                var count = 0;
                for (var j = 0; j < S.Length; j++) {
                    if (S[j] == v[count]) count++;
                    if (count == 3) {
                        ans++;
                        break;
                    }
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}


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

double A,B,C,D,E,F,Ai,Bi,tan,sum,kefan;
int main() {
	cin>>A>>B>>C>>D>>E>>F;
	Ai=A*E,Bi=B*E;
	double max1=-1,max2=1;
	for(int a = 0;a*A*100<=F;a++)
    for(int b = 0;b*B*100<=F-a*A*100;b++)
    for(int c = 0;c*C<=F-a*A*100-b*B*100;c++)
    for(int d = 0;d*D<=F-a*A*100-b*B*100-c*C;d++)
    {
        tan = c*C+d*D;
        sum = A*a*100+B*b*100+tan;
        kefan = Ai*a+Bi*b;
        if(kefan<tan||sum>F)continue;
 
        if(sum!=0&&tan/sum>max2/max1){
            max1 = sum;
            max2 = tan;
        }
    }
    cout<<(int)max1<<" "<<(int)max2<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = []
for i in range(1,n+1):
    if i%3 == 0:
        x.append(i)
        continue
    if i%10 == 3:
        x.append(i)
        continue
    i = str(i)
    if '3' in list(map(str,i)):
        x.append(int(i))
print(' '+' '.join(map(str,x)))


Measured memory_bytes: 6100
#include<stdio.h>
int a,b,n;
int main(){
  int a,b,n;
  while(scanf("%d %d %d",&a,&b,&n)!=EOF){
    int i=0,s=0;
    for(i=0;i<n;i++){
      a*=10;
      s+=(a/b)%10;
      a%=b;
    }
    printf("%d\n",s);
  }
  return 0;
}
    

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

long long int gcd(long long int n,long long int m)
{
  long long int r;
  if(n>m) swap(n,m);
  while((r=m%n)!=0)
  {
    m=n;
    n=r;
    r=m%n;
  }
  return n;
}

long long int lcm(long long int n,long long int m)
{
  long long int r=gcd(n,m);
  return max(n,m)/r*min(n,m);
}

int main()
{
  int n;
  cin>>n;
  vector<long long int> t(n+1),tim(n+1);
  for(int i=1;i<=n;i++) cin>>t.at(i);


  tim.at(1)=t.at(1);
  for(int i=2;i<=n;i++)
  {
    tim.at(i)=lcm(tim.at(i-1),t.at(i));
  }

  cout<<tim.at(n)<<endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())

weight = [None] * N
value  = [None] * N

for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i]  = v

dp = [[None] * (W+1) for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0
for v in range(N):
    for w in range(W+1):
        if w >= weight[v]:
            dp[v+1][w] = max(dp[v][w-weight[v]] + value[v], dp[v][w])
        else:
            dp[v+1][w] = dp[v][w]
print(dp[N][W])


Measured memory_bytes: 257416
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(all(a));
    
    ll med = a[n/2];
    ll ans = 0;
    rep(i, n) {
        ans += abs(a[i] - med);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792
S_p=raw_input()
T=raw_input()

def match(s,t):
  r=[]
  for i in range(len(s)-len(t)+1):
    c=0
    for j in range(len(t)):
      if s[i+j]==t[j] or s[i+j]=='?':
        c+=1
      if c==len(t):
        r.append(i)

  return r

ps=match(S_p,T)

if len(ps)==0:
  print 'UNRESTORABLE'
else:
  p=ps[-1]
  S_p=S_p.replace('?','a')
  print S_p[0:p]+T+S_p[p+len(T):]


Measured memory_bytes: 2568
#include <iostream>
using namespace std;
int main(){
    int k,x; cin >> k >> x;
    long long int i, bgn = max(x-k+1,-1000000), end = min(x+k-1,1000000);
    for (i=bgn; i<end+1; i++){
        cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
int main() {
  for(int i=1;i<=5;i++){
    int a; cin>>a;
    if(a==0) cout<<i;
  }
}



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

int main() {
  using query= tuple<int, int, int, int>;
  const int Nbits= 19;

  int Alen,Amax,Q;
  cin >> Alen >> Amax >> Q;
  vector<query> data(Q);
  int i1,i2,diff,reward;
  for(int q=0; q<Q; q++){
    cin >> i1 >> i2 >> diff >> reward;
    i1--; i2--; // 1-indexed -> 0-indexed
    data.at(q)= make_tuple(i1, i2, diff, reward);
  }

  vector<int> A(Alen);
  int ans= 0;
  for(int tmp=0; tmp<(1<<Nbits); tmp++){
    bitset<Nbits> bits(tmp);
    if(bits.count()==Alen){
      int i_buf= 0;
      int a_buf= 1;
      for(int i=0; i<Nbits; i++){
        if(bits.test(i)){
          A.at(i_buf)= a_buf;
          i_buf++;
        }
        else{
          a_buf++;
        }
      }

      if(A.back() > Amax){ continue; }
      else{
        int score= 0;
        for(auto elem:data){
          tie(i1, i2, diff, reward)= elem;
          if(A.at(i2)- A.at(i1)==diff){
            score+= reward;
          }
        }
        ans= max(ans, score);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3544
//struct cmp {bool operator()(const pair<int, char> &a, const pair<int, char> &b) {if (a.first == b.first) {return a.second > b.second;} else {return a.first > b.first;}}};
#include<bits/stdc++.h>
#define endl "\n"
#define _  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define min_heap priority_queue <int, vector<int>, greater<int> >
#define max_heap priority_queue <int>
#define ll long long
//#define int long long
#define MOD 1000000007
#define DEBUG cout<<"Hello1\n";
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << "=" << x << "\t\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout << #x << "=" << x << "\t"<<#y<<"="<<y<< "\t"<<#z<<"="<<z<<endl;
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
const int N = 1e5 + 5;
using namespace std;
template<class T>
void print_container(T &container) {for (auto &t : container) {cout << t << " ";} cout << endl;}

int32_t main() {
	_
	int n;
	cin >> n;
	int a[n][3];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}

	int dp[3], temp[3];
	for (int i = 0; i < 3; i++) {
		dp[i] = a[0][i];
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			temp[j] = a[i][j] + max(dp[(j + 1) % 3] , dp[(j + 2) % 3] );
		}
		for (int j = 0; j < 3; j++)dp[j] = temp[j];
	}

	cout << *max_element(dp, dp + 3) << endl;

}



Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n;
            n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = in.nextInt();
            }
            if ((n & 1) == 0) {
                for (int i = n - 1; i > 0; i -= 2) {
                    out.print(arr[i] + " ");
                }
                for (int i = 0; i < n - 1; i += 2) {
                    if (i != n - 2) {
                        out.print(arr[i] + " ");
                    } else {
                        out.println(arr[i]);
                    }
                }
            } else {
                for (int i = n - 1; i >= 0; i -= 2) {
                    out.print(arr[i] + " ");
                }
                for (int i = 1; i < n - 1; i += 2) {
                    if (i != n - 2) {
                        out.print(arr[i] + " ");
                    } else {
                        out.println(arr[i]);
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 86680
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    int n;
    cin>>n;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(a[i] + a[j] > a[k] && a[k] + a[i] > a[j] && a[j] + a[k] > a[i]){
                    if(a[i] != a[j] && a[k] != a[j] && a[i] != a[k]){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;   
}

Measured memory_bytes: 3652