akhauriyash/Code-Regression huggingface dataset:
//
//  Created by Ruslan Jankurazov.
//  Copyright © 2018 Ruslan Jankurazov. All rights reserved.
//

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;


int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n >= 3 && m >= 3) {
        ans += (n - 2)*(m - 2);
        cout << ans;
    } else {
        if (n == 1 && m == 1)
            cout << 1;
        else if ((n == 2 && m == 1) || (n == 1 && m == 2))
            cout << 0;
        else if (n == 2 && m == 2)
            cout << 0;
        else if (n == 1)
            cout << m - 2;
        else if (m == 1)
            cout << n - 2;
        else if (n == 2)
            cout << 0;
        else if (m == 2)
            cout << 0;
    }
    return 0;
}


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

void search(int **a, int n, int *d, int u, int t) {
  if(d[u] != 0 && d[u] < t) return;
  d[u] = t;
  int i;
  for (i = 1; i < n; i++) {
    if(a[u][i] == 1) {
      search(a,n,d,i,t+1);
    }
  }
}

int main()
{
  int i,j,n,**a,u,k,v;
  scanf("%d",&n);
  a = (int**)malloc(sizeof(int*) * n);
  for (i = 0; i < n; i++) {
    a[i] = (int*)malloc(sizeof(int) * n);
    for(j = 0; j < n; j++) a[i][j] = 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d",&u);
    scanf("%d", &k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      a[u-1][v-1] = 1;
    }
  }

  int *d;
  d = (int*)calloc(n,sizeof(int));

  search(a,n,d,0,0);
  for (i = 1; i < n; i++) {
    if(d[i] == 0) d[i] = -1;
  }



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

  free(a);
  free(d);
  return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define LL long long
#define MOD 1000000007

using namespace std;

int x,y,X,Y;
long long fac[1000001], finv[1000001], inv[1000001];

void COMinit() {
	fac[0] = fac[1] = 1ll;
	finv[0] = finv[1] = 1ll;
	inv[1] = 1ll;
	for (LL i = 2; i < 1000001; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	cin >> X >> Y;
	if((2*X-Y)%3 != 0 || (2*X-Y < 0))cout << 0 << endl;
	else{
		y=(2*X-Y)/3;
		x=X-2*y;
		COMinit();
		cout << COM(x+y,x) << endl;
	}
	return 0;
}




Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<ll> a(5);
	ll n;cin >> n;
	rep(i,5) cin >> a.at(i);
	sort(a.begin(),a.end());
	cout << (n+a.at(0)-1)/a.at(0)+4 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    std::string S;
    cin >> S;
    switch (S.at(0))
    {
        case 'S' : cout << "Cloudy" << endl; break;
        case 'C' : cout << "Rainy" << endl; break;
        case 'R' : cout << "Sunny" << endl; break;
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ais = []
for _ in range(m):
    ai = int(input())
    ais.append(ai)
dp = [0]*(n+1)
dp[0]=1
if len(ais)>0 and ais[0]==1:
  dp[1]=0
  ais.pop(0)
else:
  dp[1]=1
for i in range(2,n+1):
    if len(ais)>0 and ais[0]==i:
        dp[i] = 0
        ais.pop(0)
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[n]%1000000007)


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

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
priority_queue<long long int> PQ1;

long long int dp[100001] = {0};
long long int hole[100001] = {0};


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

  for(int i = 0;i<M;i++){
      int x;
      cin >>x;
      hole[x] = 1;
  }
  dp[0] = 1;

  for(int i = 0;i<N;i++){
      if(hole[i+1] != 1){
          dp[i+1] += dp[i];
          dp[i+1] = dp[i+1]%((int)(1e9+7));
      }
      if(hole[i+2] != 1){
          dp[i+2] += dp[i];
          dp[i+2] = dp[i+2]%((int)(1e9+7));
      }
}

cout <<dp[N]<<endl;




  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

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

        String str = sc.nextLine();
        int w = sc.nextInt();

        StringBuilder sb = new StringBuilder();
        int cursor = 0;

        while (cursor < str.length()) {
            sb.append(str.charAt(cursor));
            cursor += w;
        }

        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

int main()
{
	int i, j, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int k, n;
	cin >> k >> n;
	int arr[n];
	foro(i, n)
		cin >> arr[i];
	sort(arr, arr+n);
	int mx=0;
	for(i=1; i<n; i++)
		mx = max(mx, abs(arr[i] - arr[i-1]));
	mx = max(mx, k-arr[n-1] + arr[0]);
	cout << k - mx << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, a, b;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>a>>b;
    if(a==1 && b==2) rc("Borys");
    if(a==n && b==n-1) rc("Borys");
    if((a-b)%2==0) rc("Alice");
    rc("Borys");
}

Measured memory_bytes: 256
class UnionFindWithSize
  def initialize(size)
    @rank = Array.new(size) { 0 }
    @parent = Array.new(size) { |id| id }
    @union_size = Array.new(size) { 1 }
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    ary = [@union_size[x_parent], @union_size[y_parent]]
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @union_size[x_parent] += ary[1]
    else
      @parent[x_parent] = y_parent
      @union_size[y_parent] += ary[0]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
    ary
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end
end

n, m = gets.split.map(&:to_i)
bridges = Array.new(m) { Array.new(2) }
uf = UnionFindWithSize.new(n)
m.times do |i|
  bridges[i] = gets.split.map {|j| j.to_i - 1 }
end
ans = []
curr_value = n * (n-1) / 2
ans << curr_value
bridges.reverse_each do |u, v|
  if diff = uf.unite(u, v)
    curr_value -= diff[0] * diff[1]
  end
  ans << curr_value
end

puts ans.reverse[1..-1]

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

int main (){
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int> vec2(n);
    vector<int> vec3(n - 1);
    for (int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    for (int i = 0; i < n; i++){
        cin >> vec2.at(i);
    }
    for (int i = 0; i < n - 1; i++){
        cin >> vec3.at(i);
    }
    int sat = 0;
    for (int i = 0; i < n; i++){
        sat += vec2.at(vec.at(i)-1);
        if (i > 0 && vec.at(i - 1) + 1 == vec.at(i))
            sat += vec3.at(vec.at(i-1)-1);
    }
    printf("%d",sat);
}

Measured memory_bytes: 256
N = int(input())
s = input()

alfa = [chr(i) for i in range(65, 65+26)]

res = ''

for i in range(len(s)):
    if ord(s[i]) + N >= 65 + 26:
        res += chr(ord(s[i]) + N - 26)
    else:
        res += chr(ord(s[i]) + N)

print(res)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int tmp,case_num = 1;
 
        while((tmp = sc.nextInt()) != 0){
            System.out.printf("Case %d: %d\n",case_num++, tmp);
        }
    }
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

vector<int> cnt(13, 0);

int gap(vector<bool> v){
	int ret = IINF;
	rep(i, v.size()){
		REP(j, i+1, v.size()){
			if(v[i] && v[j]){
				int tmp = j - i;
				ret = min(ret, min(tmp, 24 - tmp));
			}
		}
	}
	return ret;
}

int calc(vector<bool> v, int pos){//v 0-23 =>24element
	int ret = 0;
	if(pos == 12){
		if(cnt[pos] == 1) v[12] = true;
		ret = gap(v);
	}
	else{
		if(cnt[pos] == 1){
			v[pos] = true;
			ret = calc(v, pos+1);
			v[pos] = false; v[24-pos] = true;
			ret = max(ret, calc(v, pos+1));
		}
		else if(cnt[pos] == 2){
			v[pos] = v[24-pos] = true;
			ret = calc(v, pos+1);
		}
		else ret = calc(v, pos+1);
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	vector<int> d(n);

	cnt[0]++;
	rep(i, n) {
		cin >> d[i];
		cnt[d[i]]++;
	}

	bool f = true;
	if(cnt[0] > 1 || cnt[12] > 1) f = false;
	REP(i, 1, 12){
		if(cnt[i] > 2) f = false;
	}

	if(!f) cout << 0 << endl;
	else{
		vector<bool> v(24, false);
		v[0] = true;
		cout << calc(v, 1) << endl;
	}


	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Scanner sc = new Scanner();
        int[] ks = sc.ReadIntArray();
        int k = ks[0];
        int s = ks[1];
        int res = 0;
        for (int x = 0; x <= k; x++)
            for (int y = 0; y <= k; y++)
                if (0 <= s - x - y && s - x - y <= k)
                    res++;
        Console.WriteLine(res);
    }
}

class Scanner
{
    public string[] ReadString()
        => Console.ReadLine().Split(' ');
    public int ReadInt()
        => int.Parse(Console.ReadLine());
    public long ReadLong()
        => long.Parse(Console.ReadLine());
    public decimal ReadDecimal()
        => decimal.Parse(Console.ReadLine());
    public int[] ReadIntArray()
        => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    public long[] ReadLongArray()
        => Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
}

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

using namespace std;

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

    if (s == "SUN") cout << 7 << endl;
    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;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rp(p) for(int k = 0; k < p; k++)
#define it(q) for(auto j = q.begin(); j != q.end(); j++)
#define f float
#define s string 
#define vi vector<int>
#define vs vector<string>
#define ll long long
#define pb push_back
using namespace std;
   
int main(){
	ll n, ans=0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		if(n%i != 0){
			ans+=floor(n/i);
		}
		else{
			ans+=floor(n/i)-1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main() {
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        ans=ans+min(2*x,2*abs(k-x));
    }
    cout<<ans;
}



Measured memory_bytes: 3516
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll H, W;
    cin >> H >> W;
    vector<vector<char>> map(H+2, vector<char>(W+2, '#'));
    for (auto &&x: irange(1LL, H+1)){
        for (auto &&y: irange(1LL, W+1)){
            cin >> map.at(x).at(y);
        }
    }
    for (auto &&x: irange(0LL, H+2)){
        for (auto &&y: irange(0LL, W+2)){
            cout << map.at(x).at(y);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N, A, B;
int main(){
	cin >> N >> A >> B;

	cout << min(B, A * N) << endl;

}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383



int main (){
    fast;

	
	int n,x,t;
	cin>>n>>x>>t;
	ll ans;
	int temp = n/x;
	int r = n%x;

	if(r > 0){
		cout<<(temp*t)+t<<endl;
	}else{
		cout<<(temp*t)<<endl;
	}
	
}











Measured memory_bytes: 3632
char r[5],a[5];
hr[10],ha[10],h,b;
main(){
	int i;
	for(;scanf("%s%s",r,a),r[1];){
		h=b=0;
		memset(hr,0,sizeof(hr));
		memset(ha,0,sizeof(ha));
		for(i=0;i<4;i++){
			if(r[i]==a[i])
				h++;
			hr[r[i]-'0']++;
			ha[a[i]-'0']++;
		}
		for(i=0;i<10;i++)
			if(hr[i]&&ha[i])
				b++;
		printf("%d %d\n",h,b-h);
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<double> x(N,0);
    vector<string> u(N);
    for(ll i=0;i<N;i++)cin>>x[i]>>u[i];
    double sum=0;
    for(ll i=0;i<N;i++){
        if(u[i]=="JPY")sum+=x[i];
        else sum+=x[i]*380000;
    }

    cout << fixed << setprecision(10);
    print(sum)

    return 0;
}

Measured memory_bytes: 256
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
    ll x;
    cin>>x;
    cout<<1-x;

}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
char mat[1001][1001];
int n,m;
bool vis[1001][1001];
ll dp[1001][1001];
void dfs(int i,int j)
{
    if(i==(n-1)&&j==(m-1))
    {
        dp[i][j] = 1;
    }
    else
    {
        dp[i][j] = 0;
    }
    vis[i][j] = 1;
    if(i+1 < n && j<m && mat[i+1][j]!='#')
    {
        if(!vis[i+1][j])
        dfs(i+1,j);
        dp[i][j] = (dp[i][j]%mod + dp[i+1][j]%mod)%mod;
    }
    if(i < n && j+1<m && mat[i][j+1]!='#')
    {
        if(!vis[i][j+1])
        dfs(i,j+1);
        dp[i][j] = (dp[i][j]%mod+dp[i][j+1]%mod)%mod;
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    
    cin>>n>>m;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            cin>>mat[i][j];
        }
    }

    dfs(0,0);
    cout<<dp[0][0]%mod<<endl;
    return 0;

}


Measured memory_bytes: 13348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
LL extgcd(LL a, LL b, LL &x, LL &y) {
  if (!b) return x = 1, y = 0, a;
  LL res = extgcd(b, a % b, y, x);
  return y -= a / b * x, res;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL N; cin >> N; N *= 2;
    LL ans = N - 1;
    for (LL k = 2 ; k * k <= N ; k++) {
        if (N % k) continue;
        LL a = k, b = N / k;
        if (__gcd(a, b) != 1)
            continue;
        LL x, y; 
        extgcd(a, -b, x, y);
        LL x1 = a * x;
        LL x2 = b * y;
        ans = min(ans, min(x1, x2));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

int main(){

    long long X, Y;
    long long  tmp;
    int ans = 0;

    cin >> X >> Y;

    tmp = X;

    for(long long i = 0; tmp <= Y; ++i){
        tmp *= 2;
        ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int htoi(char c)
{
	if(isdigit(c))
		return c-'0';
	else
		return c-'a'+10;
}

int main()
{
	int color[8][3]={
		{0,0,0},
		{0,0,255},
		{0,255,0},
		{0,255,255},
		{255,0,0},
		{255,0,255},
		{255,255,0},
		{255,255,255},
	};
	string name[8]={
		"black",
		"blue",
		"lime",
		"aqua",
		"red",
		"fuchsia",
		"yellow",
		"white"
	};
	
	for(string s;cin>>s,s[0]!='0';){
		s=s.substr(1);
		int c[3];
		rep(i,3)
			c[i]=htoi(s[i*2])*16+htoi(s[i*2+1]);
		
		int res=0;
		rep(i,8){
			int ci=(c[0]-color[i][0])*(c[0]-color[i][0])+(c[1]-color[i][1])*(c[1]-color[i][1])+(c[2]-color[i][2])*(c[2]-color[i][2]);
			int cr=(c[0]-color[res][0])*(c[0]-color[res][0])+(c[1]-color[res][1])*(c[1]-color[res][1])+(c[2]-color[res][2])*(c[2]-color[res][2]);
			if(cr>ci)
				res=i;
		}
		cout<<name[res]<<endl;
	}
	
	return 0;
}

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

using namespace std;


long long int dp[2002];


long long int sum (int n)
{
	if(n<0)
	return 0;
	
	if(n==0)
	return 1;
	
	
	if(dp[n]==-1)
	{
	
	long long int i,c;
	
	c=0;
	for(i=3;i<=2002;i++)
	{
		c= (c+ (sum(n-i)%1000000007) )%1000000007 ;
		
	}
	
	return dp[n]=c ;
	
   }
   
   else
   return dp[n];
   
	
}
int main()
{
	int t;
//	cin>>t;
t=1;

	while(t--)
	{
 		long long int n;
	cin>>n;
	
	memset(dp,-1,sizeof(dp));	
	cout<<sum(n)<<endl;
	
	
	
	
	}



}


Measured memory_bytes: 3544
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sum=0
for i in range(N):
    if A[i] <= B[i]:
        sum += A[i]
        B[i] -= A[i]
        if B[i] > 0:
            if A[i+1] <= B[i]:
                sum += A[i+1]
                A[i+1] =0
            else:
                sum += B[i]
                A[i+1] -= B[i]
    else:
        sum += B[i]
print(sum)

Measured memory_bytes: 18624
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll n = SZ(s);
  auto sa = suffix_array(s);
  auto la = lcp_array(s, sa);
  print(n*(n+1)/2-accumulate(ALL(la), 0ll));
}


Measured memory_bytes: 15656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int a;
    cin>>n;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    std::deque<long long int> S(n+1,0);
    for (int i=0;i<n;i++) {
        S[i+1]=S[i]+deq[i];
    }
    long long int sum=0;
    for (int i=1;i<=n;i++) {
        sum+=(deq[i-1]%1000000007*((S[n]-S[i])%1000000007))%1000000007;
    }
    cout<<sum%1000000007<<endl;
}

Measured memory_bytes: 6912
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		int[] a=sc.Ia;
		int m=a.Sum(),ans=int.MaxValue,p=0;
		for(int i = 0;i<n;i++) {
			p+=a[i];
			ans=Min(ans,Abs(m-p-p));
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
import java.util.Scanner;

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

        var k = Integer.parseInt(scanner.nextLine());
        var s = scanner.nextLine();

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}


Measured memory_bytes: 38540
/**
 * Created by hiramekun at 21:58 on 2019-11-01.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    cout << n / 3 << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

inline string slice(string s,int a,int b){
  return s.substr(a,b-a-1);
}
void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  lli N=getint();
  vector<lli> A=getints(N);
  lli c=0;
  FOR(i,N){
    if(A[i]%2==1)c+=1;
  }
  cout<<((c%2==1)?"NO":"YES")<<endl;
  return 0;
}


Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
i=0
cnt=0
while(i<N):
    if(A[i]==i+1):
        if(i!=N-1):
            A[i],A[i+1]=A[i+1],A[i]
        cnt+=1
        i+=2
        continue
    i+=1
print(cnt)

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

int main() {
  int n, k, sum = 0; cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for (int i = 0; i < k; i++) sum += v[i];
  cout << sum;
}

Measured memory_bytes: 3632
/*
 ABC-166
 */
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int N=300005;


void solve()
{
    
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        int z=i-a[i];
        ans=ans+mp[z];
        mp[i+a[i]]++;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS;
    // startTime=clock();
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    // cout<<getCurrentTime()<<endl;
    return 0;
}



Measured memory_bytes: 27916
#include <stdio.h>

int main(void)
{
    int N;
    int A[1001];
    int i,j,k;
    int v;

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

    for (i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
            A[j + 1] = v;
        } 
        printf("%d", A[0]);
        for (k = 1; k < N; k++){
            printf(" %d", A[k]);
        }
        printf("\n");
    }
    return (0);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;


void read() {
  ll a, b;
  cin >> a >> b;

  ll ans = 0;
  ll bon = a;
  a -= b;

  while (true) {
    if (a % b == 0) {
      ll k = a / b;
      ans += (2 * k - 1) * b;
      break;
    }
    ans += 2 * (a / b) * b;
    a %= b;
    swap(a, b);
  }
  cout << bon + ans << endl;
}


void kill() {

}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N,D,X;
	cin >> N >> D >> X;
	int res = X;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		res += (D-1)/A + 1;
	}
	cout << res << endl;
	return 0;
}



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

int main()
{
    int n, a, b, k, count = 0;
    cin >> a >> b >> k;
    n = (a > b) ? b : a;
    for (int i = n; n > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            count++;
            if (count == k) {
                cout << i << endl;
                break;
            }
        }
    }

}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max((b+c)-a,0) << endl;
}


Measured memory_bytes: 256
/* Author: shriamrut
 * Language: C++17
 * Made on:26.01.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	IOS;
	int a,b;
	cin>>a>>b;
	int ans=ceil((float)a/b);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Mujin_2017
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] horizonCnts = new int[n];
            int[] verticalCnts = new int[n];
            var canYs = new HashSet<int>();
            for(int i = 0; i < n; i++)
            {
                string s = Read();
                for(int j = 0; j < n; j++)
                {
                    if (s[j] == '.') continue;

                    horizonCnts[i]++;
                    verticalCnts[j]++;
                    canYs.Add(j);
                }
            }
            if (canYs.Count == 0)
            {
                WriteLine(-1);
                return;
            }

            int minCost = int.MaxValue;
            for(int i = 0; i < n; i++)
            {
                int tmp = 0;
                if (!canYs.Contains(i)) tmp++;
                minCost = Min(minCost, tmp+n - horizonCnts[i]);
            }
            int res = minCost;
            for(int i = 0; i < n; i++)
            {
                if (verticalCnts[i] < n) res++;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    char R[256],S[108];
    scanf("%s\n",R);
    scanf("%s\n",S);
    strncat(R,R,strlen(S));
    if(strstr(R,S)){
        printf("Yes\n");}
    else{
        printf("No\n");}
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;

  bool muri = false;

  for(int i = 0; i < s.size(); i++){
    if(i%2==0){//奇数
      if(!(s[i] == 'R' ||s[i] == 'U' ||s[i] == 'D')){
        muri =true;
      }
    }else{
      if(!(s[i] == 'L' ||s[i] == 'U' ||s[i] == 'D')){
        muri =true;
      }
    }
  }

  if(muri)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
      
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int sm = 0;
  REP(i,9){
      sm += (n / (int) pow(10,i))%10;
  }
  if (n%sm==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	char number[1001];
	int integer, sum;

	while(1){
		sum = 0;

		scanf("%s", number);

		for(int i = 0; number[i] != '\0'; i++){
			integer = number[i] - '0';
			sum += integer;
		}

		if(sum == 0) break;

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

Measured memory_bytes: 964
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int main(){
	cint(n);
	int ans=0;
	string s;
	cin>>s;
	for(int i=1;i<n;i++){
		string s1=s.substr(0,i);
		string s2=s.substr(i,n-i);
		bool f1[26]={};
		bool f2[26]={};
		int size=s1.size();
		REP(j,size){
			f1[(int)(s1[j]-'a')]=true;
			
		}
		size=s2.size();
		REP(j,size){
			f2[(int)(s2[j]-'a')]=true;
		}
		int c=0;
		REP(j,26){
			if(f1[j]&&f2[j]) c++;
		}
		ans=max(c,ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  char C;
  cin >> C;
  for(char alp='a'; alp<'z'; ++alp){
    if(alp==C){
      ++C;
      break;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
import fractions


N = int(input())
A = list(map(int, input().split()))
L, R = [0]*N, [0]*N
for i in range(1, N):
    L[i] = fractions.gcd(L[i-1], A[i-1])
    R[-i-1] = fractions.gcd(R[-i], A[-i])
ans = 0
for l, r in zip(L, R):
    ans = max(ans, fractions.gcd(l, r))
print(ans)

Measured memory_bytes: 16148
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int n,m;
vector<pair<int,int> > p[100005];
//int y[100005];
string num[100005];
int main(int argc,char const* argv[])
{
  cin >> n >> m;
  for(int i=0;i<m;i++)
    {
      int ken,year;
      cin >> ken >> year;
      p[ken].push_back(make_pair(year,i));
    }
  for(int i=0;i<=n;i++)
    {
      sort(p[i].begin(),p[i].end());
    }
  for(int i=1;i<=n;i++)
    {
      for(int j=0;j<(int)p[i].size();j++)
	{
	  string fow=to_string(i);
	  string bac=to_string(j+1);
	  while((int)fow.size()<6)
	    {
	      fow='0'+fow;
	    }
	  while((int)bac.size()<6)
	    {
	      bac='0'+bac;
	    }
	  num[p[i][j].second]=fow+bac;
	}
    }
  for(int i=0;i<m;i++)
    {
      cout << num[i] << endl;
    }
  return 0;
}


Measured memory_bytes: 12416
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 3640
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.List

main :: IO ()
main = do
  n <- readB <$> B.getLine
  as <- map readB . B.words <$> B.getLine
  bs <- map readB . B.words <$> B.getLine
  print $ snd . solve $ zip as bs

readB :: B.ByteString -> Int
readB = fst . fromJust . B.readInt

solve :: [(Int, Int)] -> (Int, Int)
solve = foldl' op (0, 0)

op :: (Int, Int) -> (Int, Int) -> (Int, Int)
op (a, b) (c, d) = (x, y)
  where
    x = a + c
    y = d + max b x


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {
    int p, l, r;
};

Node T[MAX];
int D[MAX];
int H[MAX];
int S[MAX];

/*
void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "sibling = " << S[u] << ", ";
    int deg = 0;
    if (T[u].l != NIL) deg++;
    if (T[u].r != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if (T[u].p == NIL) cout << "root";
    else if (T[u].l == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}
*/

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].p);
    printf("sibling = %d, ", S[u]);
    int deg = 0;
    if (T[u].l != NIL) deg++;
    if (T[u].r != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if (T[u].p == NIL) {
        printf("root\n");
    } else if (T[u].l == NIL && T[u].r == NIL) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}

int setHeight(int u) {
    int h1 = 0;
    int h2 = 0;
    if (T[u].r != NIL) {
        h1 = setHeight(T[u].r) + 1;
    }

    if (T[u].l != NIL) {
        h2 = setHeight(T[u].l) + 1;
    }

    H[u] = max(h1, h2);
    return H[u];
}

void setSibling(int u) {
    if (T[u].p == NIL) {
        S[u] = NIL;
    } else {
        Node p = T[T[u].p];
        if (u == p.l) {
            S[u] = p.r;
        } else {
            S[u] = p.l;
        }
    }

}

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r,d+1);
}

void preOrder(int node) {
    if (node == NIL) {
        return;
    }

    printf(" %d", node);
    preOrder(T[node].l);
    preOrder(T[node].r);
}

void inOrder(int node) {
    if (node == NIL) {
        return;
    }

    inOrder(T[node].l);
    printf(" %d", node);
    inOrder(T[node].r);
}

void postOrder(int node) {
    if (node == NIL) {
        return;
    }

    postOrder(T[node].l);
    postOrder(T[node].r);
    printf(" %d", node);
}

int main() {
    int n;
    cin >> n;
    for (int i=0; i < n; i ++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for (int i=0; i < n; i++) {
        int id_;
        cin >> id_;
        int left, right;
        cin >> left >> right;
        if (left != NIL) {
            T[id_].l = left;
            T[left].p = id_;
        }

        if (right != NIL) {
            T[id_].r = right;
            T[right].p = id_;
        }
    }

    int root = 0;
    for (int i=0; i < n; i++) {
        if (T[i].p == NIL) {
            root = i;
        }
    }

    // 高さの設定をする
    setHeight(root);
    setDepth(root, 0);
    // 兄弟ノードの設定をする
    for (int i=0; i < n; i++) {
        setSibling(i);
    }

    printf("Preorder\n");
    preOrder(root);
    printf("\n");
    printf("Inorder\n");
    inOrder(root);
    printf("\n");
    printf("Postorder\n");
    postOrder(root);
    printf("\n");

    return 0;
}


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

using namespace std;

int main(){
  int R, C;

  while(true){
    cin >> R >> C;

    if( R == 0 && C == 0 ) break;

    int field[R][C];

    for(int y = 0; y < R; y++){
      for(int x = 0; x < C; x++){
        cin >> field[y][x];
      }
    }

    int answer = 0;
    int n = 1 << R;
    int mask[R];
    for(int i = 0; i < n; i++){
      for(int j = 0; j < R; j++){
        mask[j] = i >> j & 1;
      }

      int result = 0;
      for(int x = 0; x < C; x++){
        int cnt = 0;
        for(int y = 0; y < R; y++){
          cnt += field[y][x] ^ mask[y];
        }
        result += max( cnt, R-cnt );
      }

      answer = max( answer, result );
    }

    cout << answer << endl;
  }

  return 0;
}

Measured memory_bytes: 1548
N = int(input())
def adding(s):
    if 'i' not in s:
        if 'h' not in s:
            if 'g' not in s:
                if 'f' not in s:
                    if 'e' not in s:
                        if 'd' not in s:
                            if 'c' not in s:
                                if 'b' not in s:
                                    return [s + 'a',s + 'b']
                                return [s + 'a',s + 'b',s + 'c']
                            return [s + 'a',s + 'b',s + 'c',s + 'd']
                        return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e']
                    return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e',s + 'f']
                return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e',s + 'f',s + 'g']
            return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e',s + 'f',s + 'g',s + 'h']
        return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e',s + 'f',s + 'g',s + 'h',s + 'i']
    return [s + 'a',s + 'b',s + 'c',s + 'd',s + 'e',s + 'f',s + 'g',s + 'h',s + 'i',s + 'j']
def standard(N):
    if N == 1:
        return ['a']
    else:
        A = standard(N-1)
        B = []
        for i in range(0,len(A)):
            B.extend(adding(A[i]))
        return B
A = standard(N)
for i in range(0,len(A)):
    print(A[i])


Measured memory_bytes: 12944
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main() {
  ll dp[100005], h[100005], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1792