akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	char a[100][100];
	char b[100][100];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++)
			cin>>b[i][j];
	}
	int flag;
	for(int i=0;i<=n-m;i++)
	{
		for(int j=0;j<=n-m;j++)
		{
			flag=1;
			for(int x=0;x<m;x++)
			{
				for(int y=0;y<m;y++)
				{
					if(a[i+x][j+y]!=b[x][y])
					{
						flag=0;
						break;
					}
				}
				if(flag==0) break;
			}
			if(flag==1){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, ll exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;
void iluzn(){
int n;
cin>>n;
int a[n][n];
int i,j;
fo(i,n){
  fo(j,2)
    cin>>a[i][j];
}
fo(i,n-2){
  if((a[i][0]==a[i][1])&&(a[i+1][0]==a[i+1][1])&&(a[i+2][0]==a[i+2][1])){
    cout<<"Yes";
    return;
  }
}
cout<<"No";

}


 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("af.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, ll exp) {
  base %=mod ;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10708
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	string s;
	cin >> s;
	cin >> s;
	cout << "A" << s[0] << "C" << endl;
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

bool rck[8];
int a, b, c, n, m, r, mn, twr[8], cnt, mem, rr[8][8], mem3;
vector<pair<int, int>>gp[200];
pair<int, bool>djk[200];
pair<int, int>mem2;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/

int dfs(int x,int y) {
	rck[y] = true;
	if (x == 1) {
		mn = min(cnt, mn);
//		cout << cnt << endl;
		return 0;
	}
	lp(r) {
		if (rck[i] == false) {
			cnt += rr[y][i];
			dfs(x - 1, i);
			cnt -= rr[y][i];
			rck[i] = false;
		}
	}
	return 0;
}

int main(){
	cin >> n >> m >> r;
	lp(r) {
		cin >> twr[i];
		twr[i]--;
	}
	lp(m) {
		cin >> a >> b >> c;
		gp[a - 1].push_back(make_pair(b - 1, c));
		gp[b - 1].push_back(make_pair(a - 1, c));
	}
	mn = intmax;
	lp(r) {
		LP(200,j)
			djk[j] = make_pair(intmax,false);
		djk[twr[i]] = make_pair(0, true);
		cnt = 1;
		mem = twr[i];
		while (cnt != n) {
			cnt++;
			LP(gp[mem].size(), j)
				djk[gp[mem][j].first].first = min(djk[gp[mem][j].first].first, djk[mem].first + gp[mem][j].second);
			mem2 = make_pair(intmax, intmax);
			LP(n, j)
				if (!djk[j].second&&djk[j].first < mem2.first)
					mem2 = make_pair(djk[j].first, j);
			djk[mem2.second].second = true;
			mem = mem2.second;
		}
		LP(r, j)
			rr[i][j] = djk[twr[j]].first;
	}
	mn = intmax;
	cnt = 0;
	mem3 = 0;
	lp(r) {
		lp(8)
			rck[i] = false;
		cnt = 0;
		dfs(r, i);
	}
	cout << mn << endl;
	return 0;
}

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

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> d(n);

    rep(i,n){
        d[i]=(i+1)%k;
    }

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

    int m0=upper_bound(d.begin(),d.end(),0)-lower_bound(d.begin(),d.end(),0);
    ll ans=pow(m0,3);
    if(k%2==0){
        int t=upper_bound(d.begin(),d.end(),k/2)-lower_bound(d.begin(),d.end(),k/2);
        ans+=pow(t,3);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  vector<char> Answer;

  for(int i = 0; i < N; i++)
  cin >> S.at(i);
  
  for(int i = 0; i < N; i++){
    if(i == 0)
    Answer.push_back(S.at(i));
    else if(i > 0){
      if(S.at(i) != S.at(i - 1))
        Answer.push_back(S.at(i));  
    }
  }
  cout << Answer.size() << endl;
}

Measured memory_bytes: 512
from collections import Counter
from itertools import permutations

n, c = map(int, input().split())

a = []
b = []

for _ in range(c):
    array = list(map(int, input().split()))
    a.append(array)

for _ in range(n):
    array = list(map(int, input().split()))
    b.append(array)


group1 = []
group2 = []
group3 = []

for i in range(n):
    for j in range(n):
        if (i + j) % 3 == 0:
            group1.append(b[i][j])
        elif (i + j) % 3 == 1:
            group2.append(b[i][j])
        else:
            group3.append(b[i][j])

g1 = Counter(group1)
g2 = Counter(group2)
g3 = Counter(group3)

sum1 = []
sum2 = []
sum3 = []


def cal(l, output):
    for i in range(c):
        s = 0
        for j in l.items():
            s += a[j[0]-1][i-1] * j[1]
        output.append(s)


li = [g1, g2, g3]
li2 = [sum1, sum2, sum3]

for i in range(3):
    cal(li[i], li2[i])

cc = list(range(c))

min_sum = 10**10
for i, j, k in permutations(cc, 3):
    sum = sum1[i] + sum2[j] + sum3[k]
    if sum < min_sum:
        min_sum = sum

print(min_sum)

Measured memory_bytes: 7920
use proconio::input;
#[allow(unused_assignments)]
#[allow(unused_variables)]
#[allow(non_snake_case)]
fn main() {
    input! {
        mut X: i64,
        mut K: i64,
        D: i64,
    }

    if X < 0 {
        X *= -1;
    }

    let mut ans = 0;

    if K <= X / D {
        ans = X - D * K;
    } else {
        K -= X / D;
        X -= (X / D) * D;
        if K % 2 == 0 {
            ans = X;
        } else {
            ans = -X + D;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

signed main(){
  string s;
  REP(i,3){
    cin>>s;
    cout<<s[i];
  }
  cout<<endl;


  return 0;
}


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

int main()
{
	//?????°???????????????
	char s[201];
	char p[101];
	int s_long = 0;
	int p_long = 0;
	int flag;

	//?????????s??¨?????????p?????????
	cin.getline(s, sizeof(s));
	cin.getline(p, sizeof(p));

	//?????????s??¨?????????p??????????????????
	for (int si = 0; s[si] != '\0'; si++)
	{
		s_long++;
	}

	for (int pi = 0; p[pi] != '\0' ; pi++)
	{
		p_long++;
	}


	//s????????????????????????????????????
	for (int i = 0; i < s_long;i++)
	{
		s[s_long + i] = s[i];
	}

	//?????????s???????????????p???????´¢
	for (int i1 = 0; i1 < s_long * 2 - p_long; i1++)
	{
		flag = 0;
		for (int i2 = 0; i2 < p_long; i2++)
		{
			if (s[i1+i2] != p[i2])
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0)
		{
			break;
		}
	}

	//???????????¨???
	if (flag == 0)
	{
		cout << "Yes" << endl;
	}
	else if (flag == 1)
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
#include<cstdio>
#include<algorithm>
#include<cstring>

#define maxn 200050
#define add(u,v)(to[++top]=head[u],head[u]=top,w[top]=v)
#define For(x) for (int h=head[x],o=w[h];h;o=w[h=to[h]])

using namespace std;

int n,m,to[maxn],head[maxn],w[maxn],u,v,top;
int a[maxn],b[maxn],c[maxn],co[maxn],r[maxn],q,i;

void dfs(int x,int rg,int col){
	if (rg<=r[x]||rg<=0) return;
	r[x]=rg;
	if (co[x]==0) co[x]=col;
	For(x) dfs(o,rg-1,col);
}

int main(){
	scanf("%d%d",&n,&m);
	while (m--){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	scanf("%d",&q);
	for (i=1;i<=q;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
	memset(co,0,sizeof(co));memset(r,0,sizeof(r));
	for (i=q;i>=1;i--) dfs(a[i],b[i]+1,c[i]);
	for (i=1;i<=n;i++) printf("%d\n",co[i]);
	return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	char x, y;
	cin >> x >> y;
	if (x == y) {
		cout << "=" << endl;
	}
	else if (x > y) {
		cout << ">" << endl;
	}
	else {
		cout << "<" << endl;
	}
	return 0;
}

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

goto = [[0] for _ in range(n)]

cnt = 0

for i in range(m):
    a,b = map(int,input().split())
    goto[a-1] += [h[b-1]]
    goto[b-1] += [h[a-1]]

for j in range(n):
    if max(goto[j])< h[j]:
        cnt += 1

print(cnt)


Measured memory_bytes: 25908
n=int(input())
hlist = list(map(int, input().split()))

record=0
now=0
before=0

for i in range(n):
    if hlist[i]<=before:
        now+=1
        if now>record:
            record=now
        before=hlist[i]
    else:
        now=0
        before=hlist[i]

print(record)

Measured memory_bytes: 63984
// コンパレータを定義したクラスを利用する方法
// 参考 -> #4526040

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        V[] ab = new V[n];

        for (int i = 0; i < n; i++) {
            ab[i] = new V(sc.nextInt(), sc.nextInt());
        }

        Arrays.sort(ab);

        long totalPrice = 0;
        int totalCnt = 0;
        for (int i = 0; i < n; i++) {
            long price = ab[i].a;
            int count = ab[i].b;

            if (count >= m - totalCnt) {
                totalPrice += (m - totalCnt) * price;
                break;
            } else {
                totalPrice += count * price;
                totalCnt += count;
            }
        }

        System.out.println(totalPrice);
    }

    static class V implements Comparable<V> {
        int a, b;

        V (int a, int b) {
            this.a = a;
            this.b = b;
        }

        // aの値でソート
        public int compareTo(V o) {
            return a - o.a;
        }
    }
}


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

using namespace std;

int row[102] , col[102] ;

int main()
{
    int n , m ;
    cin>>n>>m ;
    char arr[n+1][m+1] ;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j = 1 ; j <= m ; ++j)
        {
             cin>>arr[i][j] ;
             row[i] += (arr[i][j] == '.');
             col[j] += (arr[i][j] == '.');
        }
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        if(row[i] == m)
            continue;
        int cnt = 0 ;
        for(int j = 1 ; j <= m ; ++j)
        {
             if(col[j] ==n)
             {
                 cnt++;
                 continue;
             }
             cout<<arr[i][j];
        }
        if(cnt != m)
            cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    s+=(s[s.length()-1]=='s')?("es"):("s");
    cout<<s;
}


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


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; i++){
		cin >> a.at(i);
	}
	int sum_A = 0;
	int sum_B = 0;
	while(a.size() > 0){
		int max = a.at(0);
		int index = 0;
		for(int i = 1; i < a.size(); i++){
			if(a.at(i) >= max){
				max = a.at(i);
				index = i;
			}
		}
		sum_A += max;
		a.erase(a.begin() + index);
		if(a.size() == 0){
			break;
		}
		max = a.at(0);
		index = 0;
		for(int i = 1; i < a.size(); i++){
			if(a.at(i) >= max){
				max = a.at(i);
				index = i;
			}
		}
		sum_B += max;
		a.erase(a.begin() + index);
	}
	cout << sum_A - sum_B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int n, a, b;
bool f = 0;
ll suma = 0;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
 	cin >> n;
 	a = 15000;

 	if (n == 19999) {
 		f = 1;
 		n -= 12;
 	}

 	if (n == 3) {
 		cout << "2 5 63" << endl;
 		return 0;
 	}
 	if (n == 4) {
 		cout << "2 5 20 63" << endl;
 		return 0;
 	}
 	if (n == 6) {
 		cout << "2 5 20 63 30 60" << endl;
 		return 0;
 	}

 	while (a) {
 		if (a < n) {
 			b = n - a;

 			if (b % 2 == 0 && b * 6 - 3 <= 30000)
 				break;
 		}

 		a -= 3;
 	}

 	assert(a > 0 && b > 0 && b * 6 - 3 <= 30000);

 	int x = 2, y = 3;
 	while (a--) {
 		assert(x <= 30000);
 		cout << x << " ";
 		suma += x;
 		x += 2;
 	}

 	while (b--) {
 		assert(y <= 30000);
 		cout << y << " ";
 		suma += y;
 		y += 6;
 	}

 	if (f) {
	 	a = 12, x = 17;
	 	while (a--) {
	 		assert(x <= 30000 && x % 2 && x % 3);
	 		cout << x << " ";
	 		suma += x;
	 		x += 17 * 6;
	 	}
 	}

 	cout << endl;
 	//cout << suma << endl;

    return 0;
}

Measured memory_bytes: 384
H, W, K = map(int,input().split())
s = [input() for k in range(H)]
t = []
for h in range(H):
    temp = 0
    for w in range(W):
        if s[h][w] == "#":
            temp += 1
    t.append(temp)
ans = [[0]*W for k in range(H)]
c = 1
for h in range(H):
    f = 0
    if t[h] > 0:
        for w in range(W):
            if s[h][w] == "#":
                if f == 0:
                    f = 1
                else:
                    c += 1
            ans[h][w] = c
        c += 1
for h in range(1,H):
    if t[h] == 0:
        for w in range(W):
            ans[h][w] = ans[h-1][w]
for h in range(H-2,-1,-1):
    if t[h] == 0:
        for w in range(W):
            ans[h][w] = ans[h+1][w]

for e in ans:
    print(*e)


Measured memory_bytes: 74912
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class Combination {
    int powmod(int a, int p) {
        int ans = 1;
        int mul = a;

        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

signed main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    auto comb = new Combination(1e6 * 5, MOD);
    int ret = 0;
    for (int r = r1; r <= r2; r++) {
        ret += comb->get(r + c2 + 1, r + 1);
        ret %= MOD;
        ret += MOD - comb->get(r + c1, r + 1);
        ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 78336
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = 0;
        double A = 0;

        if (N % 2 == 1) {
            X = (N / 2) + 1;
        }
        else {
            X = (N / 2);
        }
        A = (double)X / N;
        System.out.println(A);
    }
}

Measured memory_bytes: 21844
/// !(i love you) && !( i hate programming)
#include<bits/stdc++.h>

#define fread freopen("in.txt","r",stdin)
#define PI acos(-1)
#define ll long long
#define MAX 100005
using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s == "SUN")
    {
        cout<<"7"<<endl;
    }
    else if(s == "MON")
    {
        cout<<"6"<<endl;
    }
    else if(s == "TUE")
    {
        cout<<"5"<<endl;
    }
    else if(s == "WED")
    {
        cout<<"4"<<endl;
    }
     else if(s == "THU")
    {
        cout<<"3"<<endl;
    }
    else if(s == "FRI")
    {
        cout<<"2"<<endl;
    }
    else if(s == "SAT")
    {
        cout<<"1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def divisors(m: int):
    i = 1
    div = []
    while i*i <= m:
        if m%i == 0:
            div.append(i)
            div.append(m//i)
        i += 1
        
    return list(set(div))

n,m = li()

divs = divisors(m)

ans = 1
for di in divs:
    if n*di <= m:
        ans = max(ans, di)

print(ans)

Measured memory_bytes: 3064
a,b,c,d = map(int, input().split())

import fractions
lcmcd = c * d // fractions.gcd(c,d)
bc = b // c
ac = a // c
bd = b // d
ad = a // d
blcmcd = b // lcmcd
alcmcd = a // lcmcd

if a % c != 0:
    ac += 1
if a % d != 0:
    ad += 1
if a % lcmcd != 0:
    alcmcd += 1

print((b - a + 1) - ((bc - ac + 1) + (bd - ad + 1) - (blcmcd -alcmcd + 1)))

Measured memory_bytes: 64620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint X, A, B;
    cin >> X >> A >> B;
    string res;
    if (B - A <= 0) res = "delicious";
    else if (B - A <= X) res = "safe";
    else res = "dangerous";
    cout << res << "\n";
}

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

#正負正負正…と展開する場合
S=0
counta=0
for i in range(n):
  if i%2 == 0:
    if S+a[i] < 1:
      counta += (1-S-a[i])
      S = 1
    else:
      S+= a[i]
  else:
    if S+a[i] > -1:
      counta += (S+a[i]+1)
      S = -1
    else:
      S+=a[i]

#負正負正負…と展開する場合
T=0
countb=0
for i in range(n):
  if i%2 == 1:
    if T+a[i] < 1:
      countb += (1-T-a[i])
      T = 1
    else:
      T+= a[i]
  else:
    if T+a[i] > -1:
      countb += (T+a[i]+1)
      T = -1
    else:
      T+=a[i]
      
print(min(counta,countb))  

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

#define lli long long int
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

int main(void)
{
	lli n;
	scanf("%lld", &n);
	lli sign = n%2;
	lli *a;
	a = (lli *)malloc(sizeof(lli)*(n+1));

	lli i,j,k;
	i = 0;
	j = 0;
	k = 0;
	
	while (i < n)
	{
		scanf("%lld",&(a[i]));
		i++;
	}
	lli **dp;
	i = 0;
	j = 0;
	dp = (lli **)malloc(sizeof(lli *)*(n + 1));
	while (i <= n)
	{
		dp[i] = (lli *)malloc(sizeof(lli)*(n+1));
		j = 0;
		while (j <= n)
		{
			dp[i][j] = 0;
			j++;
		}
		i++;
	}

	i =1;
	j =0;
	k =0;

	while (i <= n)//length
	{
		j = 0;
		while (j <= n-i)//start
		{
			if ((sign + i)%2 == 0)
			{
				dp[i][j] = MAX(dp[i-1][j]+a[j+i-1],dp[i-1][j+1]+a[j]);
				//printf("debug00100\n");
			}
			else
			{
				dp[i][j] = MIN(dp[i-1][j]-a[j+i-1],dp[i-1][j+1]-a[j]);
				//printf("debug00200\n");
			}
			j++;
		}
		i++;
	}

	printf("%lld\n",dp[n][0]);


	return (0);
}


Measured memory_bytes: 70656
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


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

  if(a+b == c || a+c == b || b+c == a){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]
ans = A[0] - 1
d = 2
for i in xrange(1, N):
    k = (A[i] - 1)/d
    if A[i] == d:
        d += 1
    ans += k
print ans


Measured memory_bytes: 7076
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int five = 0,seven = 0;
  switch (a) {
    case 5:five++; break;
    case 7:seven++; break;
    default : break;
  }
  switch (b) {
    case 5:five++; break;
    case 7:seven++; break;
    default : break;
  }
  switch (c) {
    case 5:five++; break;
    case 7:seven++; break;
    default : break;
  }
  if(five == 2 && seven == 1){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

int N;
void dfs(string s, char nextc)
{
    if (s.length() == N)
    {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= nextc; c++)
    {
        dfs(s + c, c < nextc ? nextc : nextc + 1);
    }
}

void solveD()
{
    cin >> N;
    dfs("", 'a');
}


int main()
{
    solveD();
    return 0;
}


Measured memory_bytes: 1536
s = int(input())
count = 1
if s == 4 or s == 2 or s == 1:
    print(4)
    exit()

while s != 4:
    if s % 2 == 0:
        s = s//2
    else:
        s = s*3+1
    count += 1
print(count + 3)


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

using namespace std;

using Weight=int;
struct Edge{
    int src,dst;
    Weight weight;
    int com;
    Edge(int src,int dst,Weight weight,int com):
    src(src),dst(dst),weight(weight),com(com){}
};

using Edges=vector<Edge>;
using Graph=vector<Edges>;

template<typename T>
struct UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,int>kruskal(const Graph &g,const int h,const int c){
    int n=g.size();
    UnionFind<int> uf(n);
    auto compare = [c](const Edge &a,const Edge &b) {return a.weight != b.weight ? a.weight>b.weight : a.com == c; };
    priority_queue<Edge,Edges,decltype(compare)>q(compare);
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst){
                if(e.com==c)q.emplace(e.src,e.dst,e.weight+h,e.com);
                else q.push(e);
            }
        }
    }
    int res=0,res1=0;
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
            if(e.com==c){
                ++res;
            }else{
                ++res1;
            }
        }
    }
    if(res+res1 != n-1)total=-1;
    return pair<Weight, int>(total,res);
}

int main(){
    int v,e,k;
    while (cin >> v >> e >> k, v)
    {
        Graph g(v);
        for (int i = 0; i < e; ++i)
        {
            int s, t, w, l;
            char c;
            cin >> s >> t >> w >> c;
            --s;
            --t;
            l = c;
            g[s].emplace_back(s, t, w, l);
            g[t].emplace_back(t, s, w, l);
        }
        int c;
        if (kruskal(g, 0, 'A').second > k){
            c = 'A';
        }else{
            c = 'B';
        }
        //cout<<c<<endl;
        for (int h = 0; h < 1000; ++h)
        {
            pair<Weight, int> p = kruskal(g, h, c);
            if(p.first == -1){
                cout<<"-1"<<endl;
                break;
            }
            if (p.second <= k && c == 'A')
            {
                cout << p.first-k*h << endl;
                break;
            }
            else if (p.second <= v - k - 1 && c == 'B')
            {
                cout << p.first-(v-k-1)*h << endl;
                break;
            }
            if (h == 999){
                cout << "-1" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>

int main(void) {
  int height[10];
  int i, j, k;

  for (i = 0; i < 10; i++)
    scanf("%d", &height[i]);

  k = 9;
  while (k) {
    for (i = 1, j = 0; i <= k; i++){
      if (height[i - 1] > height[i]) {
	j = i - 1;
	int t = height[i];
	height[i] = height[j];
	height[j] = t;
      }
    }
    k = j;
  }

    printf("%d\n", height[9]);
    printf("%d\n", height[8]);
    printf("%d\n", height[7]);

    return 0;
}

Measured memory_bytes: 600
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(long[]), h = rd[0], w = rd[1];
  writeln(min(calc(h, w), calc(w, h)));
}

auto calc(long h, long w)
{
  auto calc2(long h, long w, long w1)
  {
    auto wr = w-w1;

    auto w2 = wr/2, w3 = wr-w2;
    auto s1 = [w1*h, w2*h, w3*h];
    s1.sort();

    auto h1 = h/2, h2 = h-h1;
    auto s2 = [w1*h, wr*h1, wr*h2];
    s2.sort();

    return min(s1[2]-s1[0], s2[2]-s2[0]);
  }

  return min(calc2(h, w, w/3), calc2(h, w, (w+2)/3));
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
ans = 0
for i in range(1000):
  s = str(i).zfill(3)
  idx = -1
  Count = True
  for j in range(3):
    idx = S.find(s[j], idx+1)
    if idx==-1:
      Count = False
      break
  if Count:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll ans=0;
  for(ll i=0;i<n;i++) {
    while(a[i]%2==0) {
      a[i]/=2;
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define ri register int
#define de double
#define mod 998244353
#define sid 205

int n, ans;
de x[sid], y[sid];

inline int fp(int a, int k) {
    int ret = 1;
    for( ; k; k >>= 1, a = 1ll * a * a % mod)
    if(k & 1) ret = 1ll * ret * a % mod;
    return ret;
}

inline bool in(int a, int b, int o) {
    de p1 = (y[o] - y[a]) * (x[o] - x[b]);
    de p2 = (y[o] - y[b]) * (x[o] - x[a]);
    return fabs(p1 - p2) < 1e-9;
}

int main() {
    cin >> n;
    for(ri i = 1; i <= n; i ++) cin >> x[i] >> y[i];
    ans = fp(2, n);
    ans = (ans - 1 + mod) % mod;
    ans = (ans - n + mod) % mod;
    for(ri i = 1; i <= n; i ++)
    for(ri j = i + 1;  j <= n; j ++) {
        int ret = 0;
        for(ri k = j + 1; k <= n; k ++)
        if(in(i, j, k)) ret ++;
        ans = (ans - fp(2, ret) + mod) % mod;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int N, E[300001], W[300001]; string S;
int main() {
  cin >> N >> S;
  for(int i = 0; i < N; ++i) {
    if(S.at(i) == 'E') {
      E[i+1] = E[i]+1, W[i+1] = W[i];
    } else {
      E[i+1] = E[i], W[i+1] = W[i]+1;
    }
  }
  int ans = 1e9;
  for(int i = 1; i <= N; ++i) {
    ans = min(ans, W[i-1]+E[N]-E[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
import sys

input = sys.stdin.readline


def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    x.append(X)
    y.append(Y)

    if max(x) < min(y):
        ans = "No War"
    else:
        ans = "War"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#!/usr/bin/env python3


def main() -> None:
    X = ri()
    balance = 100
    for y in range(1, 10 ** 7):
        balance = int(balance * 1.01)
        if X <= balance:
            w(y)
            return


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**9)
    main()


Measured memory_bytes: 9216
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int n = inint();
		if (n < 1000) out.println("ABC");
		else out.println("ABD");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a && b) {
    cout << "Open" << endl;
  } else if(c) {
    cout << "Open" << endl;
  } else {
    cout << "Close" << endl;
  }
  return 0;
}


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

int n;
int a[100010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int index;
		cin>>index;
		a[index]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";	
	} 
	cout<<endl;
}

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

int main(){
    long long a,b,x;
    cin >> a >> b >> x;
    //cout << b/x << endl;
    //cout << a/x << endl;
    if(a%x == 0)cout << b/x - a/x + 1 << endl;
    else cout << b/x - a/x << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<pair<int ,int>> v(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        v[i].first = a;
        v[i].second = i+1;
    }   
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++) {
        cout << v[i].second;
        if(i < n-1) cout << " ";
        else cout  << "\n";
    }
}

Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static boolean check(long a, long b, long c){
        return a < b+c && b < a+c && c < a+b;
    }
    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        String[] s = sc.nextLine().split("\\s");
        long[] arr = Arrays.stream(s).mapToLong(Long::parseLong).toArray();
        Map<Long, Integer> count = new HashMap<>(); 
        for (long a: arr){
            count.put(a, count.getOrDefault(a, 0) + 1);
        }
        Long[] keys = count.keySet().stream().sorted().toArray(Long[]::new);
        long a, b, c, ans = 0;
        for (int i=0; i<keys.length; i++){
            a = keys[i];
            for (int ii=i+1; ii<keys.length; ii++){
                b = keys[ii];
                for (int iii=ii+1; iii<keys.length; iii++){
                    c = keys[iii]; 
                    if (check(a, b, c)){
                        ans += count.get(a)*count.get(b)*count.get(c);
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
l =[ list(map(int,input().split())) for i in range(m)]
l1 = set([i[1] for i in l if i[0]==1])
l2 = set([i[0] for i in l if i[1]==n])
l3 = l1&l2
if len(l3)>=1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")


Measured memory_bytes: 60272
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	long long N, ans = 0;
	string s;
	cin >> s;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;
	if (s == "SUN")cout << 7 << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**10

for i in range(n):
    if i + k - 1 > n-1:
        break
    l = x[i]
    r = x[i+k-1]
    temp1 = abs(r) + abs(r - l)
    temp2 = abs(l) + abs(r - l)
    temp = min(temp1, temp2)
    if temp < ans:
        ans = temp

print(ans)

Measured memory_bytes: 62576
//| #######################|
//|  ADARSH SINGH KUSHWAHA |
//| ###################### | 
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define Bahut_tej ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frb(i, a, b) for(ll i = a - 1; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define mp map<ll,ll>
#define v vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define mod 1000000007 
#define max 1000001
bool prime[max];
void seive(){
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(int i=2;i*i<=max;i++){
        if(prime[i]){
            for(int j=i*i;j<=max;j+=i){
                prime[j]=false;
            }
        }
    }
}
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    ll b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    ll c=0;
    for(ll i=1;i<n;i++){
        if(a[i]<a[i-1]){
            a[i]+=abs(a[i]-a[i-1]);
        }
    }
    for(ll i=0;i<n;i++){
        if(a[i]!=b[i]){
            c+=abs(a[i]-b[i]);
        }
    }
    cout<<c<<endl;
}
int main() {
    Bahut_tej;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif  
        //int t;
        //cin>>t;
        //while(t--){
            solve();
        //}
        return 0;
    }

Measured memory_bytes: 6772
using System;
class aizu{
    public static int Main(){
        int i;
        double[] n = new double[100];
        string[] str = new string[100];
        str = Console.ReadLine().Split(' ');
        for(i=0;i<2;i++)
            n[i] = double.Parse(str[i]);
        Console.WriteLine("{0} {1} {2:f8}",(int)(n[0]/n[1]),(int)(n[0]%n[1]),(n[0]/n[1]));
        return 0;
    }
}

Measured memory_bytes: 9256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class EThisMessageWillSelfDestructIn5s {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.readIntArray(n);

            HashMap<Integer, Integer> count = new HashMap<>();

            long answer = 0;
            for (int i = 0; i < n; i++) {
                int right = i - a[i];
                int left = i + a[i];
                answer += count.getOrDefault(right, 0);
                count.merge(left, 1, Integer::sum);
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



Measured memory_bytes: 58656
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	string s; cin >> s;
	//vector<vector<int> > list(30);
	//rep(i, s.length()) list[s[i]-'a'].push_back(i);
	vector<set<int> > list(30);
	rep(i, s.length()) list[s[i]-'a'].insert(i);

	int q; cin >> q;
	rep(i, q){
		int type; cin >> type;
		if(type == 1){
			int ii; char cc; cin >> ii >> cc;
			ii--;
			if(s[ii] == cc) continue;
			list[cc-'a'].insert(ii);
			list[s[ii]-'a'].erase(ii);
			s[ii] = cc;
		} else{
			int left, right; cin >> left >> right;
			left--; right--;
			int count = 0;
			rep(i, 26){
				auto mi = list[i].lower_bound(left);
				if(mi != list[i].end() && *mi <= right){
					count++;
				}
			}
			cout << count << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 24196
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = (ll)1e30;
const int MOD = 1000000007;

ll xs[MAX], ys[MAX];
vector <llP> ps;

void solve(void){
    int N, K;
    cin >> N >> K;
    rep(N, i) {
        scanf("%lld %lld\n", &xs[i], &ys[i]);
        ps.pb(intP(xs[i], ys[i]));
    }
    sort(xs, xs+N);
    sort(ys, ys+N);
    ll mini = (xs[N-1]-xs[0])*(ys[N-1]-ys[0]);
    rep(N-1, lx) Rep(lx+1, N-1, rx) rep(N-1, ly) Rep(ly+1, N-1, ry) {
        ll x = xs[rx]-xs[lx], y = ys[ry]-ys[ly], cnt = 0;
        rep(N, i) {
            if (xs[lx] <= ps[i].first && xs[rx] >= ps[i].first && ys[ly] <= ps[i].second && ys[ry] >= ps[i].second) cnt++;
        }
        if (cnt >= K) mini = min(mini, x*y);
    }
    cout << mini << '\n';
}

int main(void){
  solve();
  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 c = 0;
        String w = sc.next();
        while(true){
            String t = sc.next();
            if(t.equalsIgnoreCase(w)) c++;
            else if(t.equals("END_OF_TEXT")) break;
        }
        System.out.println(c);
        sc.close();
    }
}


Measured memory_bytes: 26072
// https://atcoder.jp/contests/abc063/tasks/abc063_b

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

int main()
{
    string s;
    cin >> s;

    vector<bool> used(26, false);

    for (int i = 0; i < s.size(); i++)
    {
        int j = s[i] - 'a';
        if (used[j])
        {
            cout << "no" << endl;
            return 0;
        }
        used[j] = true;
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 3540
S = input()

ans = 0
memo = []
for i in range(1 << len(S)-1):
  tmp = S[0]
  for j in range(len(S)-1):
    if ((i >> j) & 1) == 1:
      tmp += "+"
    tmp += S[j+1]
  if tmp not in memo:
    ans += eval(tmp)
    memo.append(tmp)
print(ans)

Measured memory_bytes: 3060