akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc075/tasks/abc075_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    // 集合xとyを併合する. 併合済のときfalse, 未併合のときtrueが返される
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    // 要素kが属する集合を求める
    int find(int k) {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    // 要素kが属する集合の要素の数を求める
    int size(int k) { return (-data[find(k)]); }
};

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);
    for (auto &x : v) {
        cin >> x.first >> x.second;
        x.first--, x.second--;
    }
    int ans = 0;
    REP(i, M) {
        UnionFind uf(N);
        REP(j, M) {
            if (i != j) {
                uf.unite(v[j].first, v[j].second);
            }
        }
        // 連結でなければ橋
        if (uf.find(v[i].first) != uf.find(v[i].second)) {
            ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

using Lint=long long;

vector<int> mul(vector<int>& a,vector<int>& b)
{
   const int N=a.size();
   vector<int> res(N);
   for(int i=0;i<N;i++) res[i]=b[a[i]];
   return res;
}

vector<int> pow(vector<int>& p,Lint K)
{
   const int N=p.size();
   vector<int> res(N);
   for(int i=0;i<N;i++) res[i]=i;
   while(K>0){
      if(K&1) res=mul(res,p);
      p=mul(p,p); K>>=1;
   }
   return res;
}

int main()
{
   int N; cin>>N;
   vector<Lint> x(N);
   for(int i=0;i<N;i++) cin>>x[i];
   Lint M,K; cin>>M>>K;
   vector<int> a(M);
   for(int i=0;i<M;i++) cin>>a[i],a[i]--;

   const int sz=N-1;
   vector<int> d(sz);
   for(int i=0;i<sz;i++) d[i]=x[i+1]-x[i];
   vector<int> p(sz);
   for(int i=0;i<sz;i++) p[i]=i;
   for(int i=0;i<M;i++){
      swap(p[a[i]-1],p[a[i]]);
   }
   vector<int>res=pow(p,K);
   for(int i=0;i<sz;i++) x[i+1]=x[i]+d[res[i]];
   for(int i=0;i<N;i++) cout<<x[i]<<endl;
   return 0;
}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int               long long
#define endl              "\n"
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define ff                first
#define ss                second
#define pii               pair<int,int>
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define repe(i,a,b)        for(int i=a;i<=b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define INF 100000000000
#define mod 1000000007
#define esp 10e-7
const int mx=100005;

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    //freopen("error.txt" , "w" , stderr);
    #endif
    IOS
     int a,b,c,d;
     cin>>a>>b>>c>>d;
     int ans=-1e18;
     ans=max(ans,a*1LL*c);
     ans=max(ans,a*1LL*d);
     ans=max(ans,b*1LL*c);
     ans=max(ans,b*1LL*d);
     cout<<ans<<endl;
    


return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') cnt++;
    else cnt--;
    if (cnt < 0) {
      s.insert(s.begin(), '(');
      i++;
      cnt++;
    }
  }
  cnt = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == ')') cnt++;
    else cnt--;
    if (cnt < 0) {
      s.insert(s.end(), ')');
      cnt++;
    }
  }
  cout << s << endl;
  return 0;
}

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;

int main(){
    ll a; double b;
    cin>>a>>b;
    ll c=round(b*100);
    ll ans=a*c/100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3748
#include<cstdio>
#include<iostream>
using namespace std;
long long sum;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		sum+=s[i]-'9';
	}
	if(sum%9==0)
	{
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)-1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  char s[LIMIT1][15];
  int he[10]={0},wi[10]={0},total=0;
  
  cin >> n >> m >> k;
  rep(i,n){
    cin >> s[i];
  }
  rep(i,n){
    rep(j,m){
      if(s[i][j]=='#'){
        wi[i]++;
        he[j]++;
        total++;
      }
    }
  }
  rep(i,(1<<n)){
    rep(j,(1<<m)){
      tmp=0;
      ll flag=i;
      int flag2=0;
      while(flag>0){
        if(flag%2==1) tmp += (ll)wi[flag2];
        flag /= 2;
        flag2++;
      }
      flag2=0;
      ll flag3=j;
      while(flag3>0){
        if(flag3%2==1){
          tmp += (ll)he[flag2];
          int flag4=0;
          flag=i;
          while(flag>0){
            if(flag%2==1){
              if(s[flag4][flag2]=='#') tmp--;
              //and
            }
            flag /= 2;
            flag4++;
          }
        }
        flag3 /= 2;
        flag2++;
      }
      //cout << tmp << endl;
      if(total-tmp==k){
        //cout << i << " " << j << endl;
        result++;
      }
    }
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n, m, a;

	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &m);
		scanf("%d", &a);

		if (n == 0 && m == 0 && a == 0) { break; }

		vector<int> amida1(m), amida2(m), amida3(m);

		for (int i = 0; i < m; i++)
		{
			scanf("%d", &amida1[i]);
			scanf("%d", &amida2[i]);
			scanf("%d", &amida3[i]);
		}

		int maxh, maxpos, pos = a, posh = 869120;

		while (true)
		{
			maxh = -1, maxpos = -1;

			for (int i = 0; i < m; i++)
			{
				if (amida2[i] == pos)
				{
					if (maxh < amida1[i] && amida1[i] < posh)
					{
						maxh = amida1[i]; maxpos = amida3[i];
					}
				}

				if (amida3[i] == pos)
				{
					if (maxh < amida1[i] && amida1[i] < posh)
					{
						maxh = amida1[i]; maxpos = amida2[i];
					}
				}
			}

			if (maxh == -1)
			{
				break;
			}

			pos = maxpos; posh = maxh;
		}

		printf("%d\n", pos);
	}

	return 0;
}

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

int N, Q;
const int MAX_N = 200000;
vector<int> Adj[MAX_N];
typedef long long ll;
ll X[MAX_N];

void dfs(int v, int par)
{
  for (int w : Adj[v])
  {
    if (w != par)
    {
      X[w] += X[v];
      dfs(w, v);
    }
  }
}

int main()
{
  cin >> N >> Q;
  for (int i = 0; i < N - 1; ++i)
  {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
  }
  for (int i = 0; i < Q; ++i)
  {
    int p;
    ll x;
    cin >> p >> x;
    --p;
    X[p] += x;
  }
  dfs(0, -1);
  for (int v = 0; v < N; ++v)
  {
    cout << (v == 0 ? "" : " ") << X[v];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 24320
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        long ans = 0;
        List<Integer> li = new ArrayList<Integer>();
        for(int i = 1; i <= n; i++){
            ans += sc.nextInt();
        }
        for(int i = 0; i < n-1; i++){
            li.add(sc.nextInt());
        }
        int prev = a[0]-1;
        for(int i = 1; i < n; i++){
            int next = a[i]-1;
            if(prev+1 == next){
                ans += li.get(prev);
            }
            prev = next;
        }
        System.out.println(ans);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21204
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class ConsoleApp1
{

    public static void Main()
    {

        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var c = int.Parse(Console.ReadLine());
        var x = int.Parse(Console.ReadLine());

        var xcou = x / 50;
        int coua; int coub;int couc;coua = coub = couc = 0;
        var lists = new List<int[]>();
        while (true)
        {
            if (coua * 10 + coub * 2 + couc > xcou)
            {
                break;
            }
            else if (coua * 10 + coub * 2 + couc == xcou)
            {
                lists.Add(new[] { coua, coub, couc });
            }
            while (true)
            {
                if (coua * 10 + coub * 2 + couc > xcou)
                {
                    break;
                }
                else if (coua * 10 + coub * 2 + couc == xcou)
                {
                    lists.Add(new[] { coua, coub, couc });
                }
                while (true)
                {
                    if (coua * 10 + coub * 2 + couc > xcou)
                    {
                        break;
                    }
                    else if (coua * 10 + coub * 2 + couc == xcou)
                    {
                        lists.Add(new[] { coua, coub, couc });
                    }
                    couc++;
                }
                couc = 0;
                coub++;
            }
            coub = 0;
            coua++;
        }
        var mocount = lists.Distinct(new Comparer()).ToList();
        var remlists = new List<int>();
        for (int i = 0; i < mocount.Count(); i++)
        {
            var item = mocount.ElementAt(i);
            if (item[0] > a  || item[1] > b || item[2] > c)
            {
                remlists.Add(i);
            }
        }
        foreach (var item in remlists.OrderByDescending(z => z))
        {
            mocount.RemoveAt(item);
        }
        Console.WriteLine(mocount.Count());
        Console.ReadKey();
    }

    class Comparer : IEqualityComparer<int[]>
    {
        public bool Equals(int[] x, int[] y)
        {
            for (int i = 0; i < 3; i++)
            {
                if (x[i] == y[i])
                {
                    return true;
                }
            }
            return false;
        }

        public int GetHashCode(int[] obj)
        {
            return (obj[0] + obj[1] + obj[2]).GetHashCode();
        }
    }

}


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

class Program {
  public static void Main() {
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int big;
    
    if (a > b) {
      big = a;
    } else {
      big = b;
    }
    
    int n = int.Parse(Console.ReadLine());
    
    if (n % big == 0)
      Console.WriteLine(n / big);
    else 
      Console.WriteLine(n / big + 1);
  }
}


Measured memory_bytes: 13140
import java.util.*;

class Main{

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

        int ninzu = sc.nextInt();
        int outTime = sc.nextInt();
        List<Integer> comeTime = new ArrayList<>();

        int endTime = 0;
        int sumTime = 0;


        for(int i = 0; i < ninzu; i ++) {
            int time = sc.nextInt();
            comeTime.add(time);
        }

        for(int time : comeTime) {
            int tmpTime = 0;
            if (endTime > time) tmpTime = endTime - time;
            
            endTime = time + outTime;
            sumTime = sumTime + outTime - tmpTime;
        }

        System.out.println(sumTime);
    }
}




Measured memory_bytes: 90944
def ope(a,b,v):
  if v == '+':
    return a + b
  elif v == '-':
    return a - b
  elif v == '*':
    return a * b
  
stacs = list(input().split())
n = len(stacs)
flag = 1
t = []
for i in range(n):
  if stacs[i] != '+' and stacs[i] != '-' and stacs[i] != '*':
    t.append(int(stacs[i]))
  else:
    max = len(t)
    vv = ope(t[max-2],t[max-1],stacs[i])
    del t[max-2:max]
    t.append(vv)
print(t[0])


Measured memory_bytes: 5604
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(A,N);
    sort(A,A+N);
    ll ans=0;
    FORI(i,1,N+1)
    {
        ans=(ans+(((N-i+2)*A[i-1])%MOD))%MOD;
    }
    ans=(ans*power(4,N-1))%MOD;
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h){
        cin >> s.at(i);
    }

    ll ans = 0;
    vector<vector<bool>> vis(h, vector<bool>(w, false));
    REP(i, h){
        REP(j, w){
            if(vis.at(i).at(j)){ continue; }

            ll nw = 0, nb = 0;
            queue<pair<ll, ll>> que;
            que.emplace(i, j);

            while(!que.empty()){
                const auto p = que.front(); que.pop();
                const ll y = p.first, x = p.second;
                if(vis.at(y).at(x)){ continue; }
                vis.at(y).at(x) = true;
                if(s.at(y).at(x) == '.'){
                    nw++;
                }else{
                    nb++;
                }

                const ll dx[] = {0, 0, -1, 1};
                const ll dy[] = {-1, 1, 0, 0};
                REP(k, 4){
                    const ll y2 = y + dy[k];
                    const ll x2 = x + dx[k];
                    if(y2 < 0 || y2 >= h){ continue; }
                    if(x2 < 0 || x2 >= w){ continue; }
                    if(vis.at(y2).at(x2) ||
                        s.at(y).at(x) == s.at(y2).at(x2)){ continue; }
                    que.emplace(y2, x2);
                }
            }
            ans += nw * nb;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+10;
LL num[maxn];
int main()
{
    int n,x,y;
    cin >> n >>x >> y;
    for(int i  = 1;i<=n;++i)
    {
        for(int j = i+1;j<=n;++j)
        {
            int ans = min(j-i,min(abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)));
            num[ans]++;
        }
    }
    for(int i = 1;i<n;++i)
        printf("%d\n",num[i]);
    return 0;
}


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

int n, a;

int main()
{
  cin >> n;
  vector<pair<long, int>> p;
  for (int i = 0; i < n; ++i)
  {
    cin >> a;
    p.emplace_back(a, i);
  }
  sort(p.begin(), p.end());
  set<int> unko = {-1, n};

  long ans = 0;
  for (int i = 0; i < n; ++i)
  {
    auto [un, ko] = p[i];
    unko.insert(ko);
    auto ima = unko.find(ko);
    ans += un * (*++ima - ko) * (ko - *----ima);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;
const int MAX = 200010;

int main(){
    int N;
    int  A[MAX], B[MAX], P[MAX];
    ll K, Ls, Le, ae;
    cin >> N >> K;
    REP(int,i,1,N+1) cin >> A[i];
    REP(int,i,1,N+1) B[i]=1;
    
    B[1]=0;
    P[1]=1;
    REP(int,i,1,N+1){
        ae=A[P[i]];
        if(B[ae]==1){
            //cout << ae << endl;
            B[ae]=0;
            P[i+1]=ae;
        }else{
            Le=i;
            break;
        }
    }
    REP(int,i,1,N+1){
        if(P[i]==ae){ 
          Ls=i;
          break;
        }
    }

    if(K+1<=Ls){
        cout << P[K+1] << endl;
    }else{
        ae=(K+1-Ls)%(Le-Ls+1);
        cout << P[ae+Ls] << endl;
    }
}


Measured memory_bytes: 5968
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int X = sc.nextInt();
      int Y = sc.nextInt();
      String ans = "No";
      if(X < 51){
        for(int i = 0; i <= X; i++){
          int j = X - i;
            int leg = 2 * i + 4 * j;
            if(leg == Y) ans = "Yes";
        }
      }
      System.out.println(ans);
    } 
}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  int64_t sum=0;
 vector<int64_t>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<n-1;i++){
    if(vec.at(i)>vec.at(i+1)){
      int64_t x=vec.at(i)-vec.at(i+1);
      sum+=x;
      vec.at(i+1)+=x;
    }
    else{continue;}
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> G[n];
  map<pair<int,int>, int> mp;
  vector<int> colors(n-1, 0);
  REP(i,n-1){
    int a,b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    mp[make_pair(a,b)] = i;
  }
  
  int color_num = 0;
  vector<bool> seen(n, false);
  vector<set<int>> color_node(n);
  queue<int> que;
  que.emplace(0);
  while(!que.empty()){
    int v1 = que.front();
    que.pop();
    color_num = max(color_num, (int)G[v1].size());
    int col = 1;
    for(auto v2: G[v1]){
      pair<int, int> p = make_pair(min(v1,v2), max(v1,v2));
      if(colors[mp[p]]>0) continue;
      while(true){
        if(color_node[v1].find(col)==color_node[v1].end()){
          colors[mp[p]] = col;
          color_node[v1].insert(col);
          color_node[v2].insert(col);
          break;
        }
        col++;
      }
      que.emplace(v2);
    }
  }
  cout << color_num << '\n';
  REP(i,n-1) cout << colors[i] << '\n';
  return 0;
}



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

int main()
{
    // 入力
    int N,D;
    int result=0;
    cin >> N >> D;
    int X[N],Y[N];

    cout << "" << endl;
    // 計算
    rep (i,N){
        cin >> X[i] >> Y[i];
        if (sqrt(pow(X[i],2.0)+pow(Y[i],2.0)) <= D) result++;
    }
    
    // 出力
    cout << result << endl;
    return 0;  
}


Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    vector<int> cnt(9,0);
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;
        temp /= 400;
        if(temp>8) temp=8; //3200以上の人は8にまとめる
        cnt[temp] ++;
    }

    //最小
    int cntmin=0;
    for(int i=0; i<8; i++){
        if(cnt[i]>0) cntmin ++;
    }
    if(cntmin==0 && cnt[8]!=0) cntmin ++;

    //最大
    int cntmax=0;
    for(int i=0;i<8;i++){
        if(cnt[i]>0) cntmax ++;
    }
    cntmax += cnt[8];
    
    cout << cntmin << ' ' << cntmax << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector< vector<int> >;

int main(){
	string T;
	cin >> T;
	for (int i = 0; i < T.size(); i++)
	{
		if(T[i]=='?') T[i] = 'D';
	}
	cout << T << endl;
}

Measured memory_bytes: 3736
n = gets.to_i
i = 1
cnt_8 = 0
while i <= n
  k = 1
  cnt = 0
  while k <= i
    if i % k == 0
      cnt += 1
    end
    k += 1
  end
  
  if cnt == 8
    cnt_8 += 1
  end
  i += 2
end

puts cnt_8


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
char str[1000];
int main()
{
    cin >> str;
    int len = strlen(str);
    ll ans = 0;
    for(int i = len-1; i >= 1; i--)
    {
        if(str[i] != '9')
        {
            str[i-1]--;
            if(str[i-1] < '0')str[i-1] = '9', str[i-2]--;
        }
        ans += 9;
    }
    if(str[0] > '0')ans += str[0]-'0';
    cout << ans << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 256
a, b = map(str, input().split())

dic = {
    "A": 11,
    "B": 12,
    "C": 13,
    "D": 14,
    "E": 15,
    "F": 16
}

if dic[a] < dic[b]:
    print("<")
elif dic[a] > dic[b]:
    print(">")
else:
    print("=")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,d;
  cin>>n>>d;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  int ans = 0;
  rep(i,n) ans += max(vec[i]-d, 0);

  if(ans == 0) cout << "kusoge" << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second
using namespace std;

void solve(){
	long long n;
	cin >> n ;
	long long sum =0;
	for(int i=1;i<n;++i){
		sum += (n-1)/i;
	}

	cout << sum << endl;
}

int main(){

/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//int t;cin >> t;while(t--){solve();}
	solve();
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

const ll mod = 1000000007LL;

long long extgcd(long long a,long long b,long long& x,long long& y) {
  long long d = a;
  if(b != 0) {
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m) {
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}


ll H,W,A,B;
#define MAX 1001000
ll fact[MAX];

void compute() {

}

int main() {
  fact[0] = 1;
  REP(i,1,MAX) fact[i] = ( fact[i-1] * (ll)i ) % mod;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  ll x = B-1;
  for(ll y=0;y<H-A;++y) {
    ll v1 = 0;
    v1 = fact[x + y];
    v1 = ( v1 * mod_inv(fact[x],mod) ) % mod;
    v1 = ( v1 * mod_inv(fact[y],mod) ) % mod;
    //if( x <= 0 || y <= 0 ) v1 = 1;
    ll v2 = 0;
    ll rx = W - ( x + 1 ) - 1;
    ll ry = H - y - 1;
    v2 = fact[rx+ry];
    if( rx ) v2 = ( v2 * mod_inv(fact[rx],mod) ) % mod;
    if( ry ) v2 = ( v2 * mod_inv(fact[ry],mod) ) % mod;
    //if( rx <= 0 || ry <= 0 ) v2 = 1;
    ( ans += ( v1 * v2 ) % mod ) %= mod;
  }
  cout << ans % mod << endl;
  compute();
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (A % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if (B % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if ((A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}






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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N=26;
	int D;
	cin >>D;
	vector<int> c(N+1, 0);
	Rep1(i, N)
		cin >>c.at(i);
	vector<vector<int>> s(D+1, vector<int> (N+1, 0));
	Rep1(i, D)
		Rep1(j, N)
			cin >>s.at(i).at(j);
	vector<int> t(D+1);
	Rep1(i, D)
		//	cin >>t.at(i);
		t.at(i)=i%26+1;
	//
	vector<vector<int>> LAST(D+1, vector<int> (N+1, 0));
	int S=0;
	vector<vector<int>> SS(D+1, vector<int> (N+1, 0));
	Rep1(i, D) {
		Rep1(j, N) {
			if (j==t.at(i)) {
				LAST.at(i).at(j)=0;
				SS.at(i).at(j)=SS.at(i-1).at(j)+s.at(i).at(j);
				S +=s.at(i).at(j);
			} else {
				LAST.at(i).at(j) =LAST.at(i-1).at(j)+c.at(j);
				SS.at(i).at(j)=SS.at(i-1).at(j)-LAST.at(i).at(j);
			}
			S -=LAST.at(i).at(j);
		}
		//cout <<S <<endl;
	}
	//
	int SSS=0;
	int M=30000;
	Rep1(i, M) {
		int SSSS=S;
		int d=rand()%365+1;
		int q=rand()%26+1;
		//int d, q;
		//cin >>d >>q;
		int q0=t.at(d);
		if (q==q0)
			continue;
		S -=SS.at(D).at(q0)+SS.at(D).at(q);
		t.at(d)=q;
		for (auto j=d; j<=D; j++) {
			if (q0==t.at(j)) {
				LAST.at(j).at(q0)=0;
				SSS=SS.at(j-1).at(q0)+s.at(j).at(q0);
			} else {
				LAST.at(j).at(q0)=LAST.at(j-1).at(q0)+c.at(q0);
				SSS=SS.at(j-1).at(q0)-LAST.at(j).at(q0);
			}
			if (SSS==SS.at(j).at(q0))
				break;
			else
				SS.at(j).at(q0)=SSS;
		}
		for (auto j=d; j<=D; j++) {
			if (q==t.at(j)) {
				LAST.at(j).at(q)=0;
				SSS=SS.at(j-1).at(q)+s.at(j).at(q);
			} else {
				LAST.at(j).at(q)=LAST.at(j-1).at(q)+c.at(q);
				SSS=SS.at(j-1).at(q)-LAST.at(j).at(q);
			}
			if (SSS==SS.at(j).at(q))
				break;
			else
				SS.at(j).at(q)=SSS;
		}
		S +=SS.at(D).at(q0)+SS.at(D).at(q);
		if (S<SSSS) {
			t.at(d)=q0;
			for (auto j=d; j<=D; j++) {
				if (q0==t.at(j)) {
					LAST.at(j).at(q0)=0;
					SSS=SS.at(j-1).at(q0)+s.at(j).at(q0);
				} else {
					LAST.at(j).at(q0)=LAST.at(j-1).at(q0)+c.at(q0);
					SSS=SS.at(j-1).at(q0)-LAST.at(j).at(q0);
				}
				if (SSS==SS.at(j).at(q0))
					break;
				else
					SS.at(j).at(q0)=SSS;
			}
			for (auto j=d; j<=D; j++) {
				if (q==t.at(j)) {
					LAST.at(j).at(q)=0;
					SSS=SS.at(j-1).at(q)+s.at(j).at(q);
				} else {
					LAST.at(j).at(q)=LAST.at(j-1).at(q)+c.at(q);
					SSS=SS.at(j-1).at(q)-LAST.at(j).at(q);
				}
				if (SSS==SS.at(j).at(q))
					break;
				else
					SS.at(j).at(q)=SSS;
			}
			S=SSSS;
		}
		//cout <<i <<":" <<S <<endl;////////////////////////////
	}
	Rep1(i, D)
		cout <<t.at(i) <<endl;
	//cout <<S <<endl;//////////////////////
	return 0;
}



Measured memory_bytes: 3796
n,y=list(map(int,input().split()))

res10000=-1
res5000=-1
res1000=-1
for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
          res10000,res5000,res1000=i,j,k
          break

print('{} {} {}'.format(res10000,res5000,res1000))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back

int gcd(int a,int b)
{
	if(b==0)	return a;
	if(a==0)	return b;
	if(a>=b)	return gcd(b,a%b);
	else	return gcd(a,b%a);
}
int mpower(int a,int b,int m)
{
	if(b==0)	return 1;
	if(b==1)	return a%m;
	int res=1;
	a=a%m;
	while(b){
		if(b&1){
			res=(res*a)%m;
		}
		a=((a%m)*(a%m))%m;
		b>>=1;
	}
	return res;
}
int imod(int a,int m)
{
	if(gcd(a,m)!=1)	return 0;
	return mpower(a,m-2,m);
}


int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0,sum=0,ss=0;
	int M=1000000007;
	for(int i=0;i<n;i++){
		sum+=a[i];
		sum%=M;
		ss+=(a[i]*a[i])%M;
		ss%=M;
	}
	ans=((sum%M)*(sum%M))%M;
	ans-=ss;
	ans%=M;
	ans+=M;
	ans%=M;
	int x=imod(2,M);
	ans=(ans*x)%M;
	cout << ans;


	return 0;
}


Measured memory_bytes: 5148
#include <iostream>

using namespace std;

int main()
{
	int N, K,a=1;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		if (a < K)
			a *= 2;
		else
			a += K;
	}
	cout << a << endl;

	return 0;
}

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 P = pair<int,int>;

const int INF = 100100100;
int c[10][1005];

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int res = INF;

    rep(bit,1<<(h-1)){
        int g = 0;
        vector<int> group(h);
        rep(i,h){
            group[i] = g;
            if(bit>>i & 1) ++g; 
        }
        g++; // num of group
        // rep(i,h) cout << group[i] << " ";
        // cout << endl;
        rep(i,g) rep(j,w) c[i][j] = 0;
        rep(i,h) rep(j,w) c[group[i]][j] += s[i][j] - '0';
        // rep(i,g) {
        //     rep(j,w) cout << c[i][j] << " ";
        //     cout << endl;
        // }
        // cout << endl;

        bool ok = true;
        rep(i,g) rep(j,w) if( c[i][j] > k ) ok = false;
        if(!ok) continue;

        int ans = g-1;
        // cout << "Ini ans : " << ans << endl;
        vector<int> white(g);
        rep(j,w) rep(i,g) {
            white[i] += c[i][j];
            if (white[i] > k) {
                // rep(i,g) cout << white[i] << endl;
                // cout << "------" << endl;
                --j; ++ans;
                rep(i,g) white[i] = 0; 
                break;
            }
        }
        // cout << "Each ans :  " << ans << endl;

        res = min(res, ans);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    k = int(input())
    if k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8 or k % 10 == 0:
        print(-1)
        exit()
    elif k % 10 == 1:
        tmp = k * 7
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            if tmp // 10 % 10 <= 7:
                num = 7 - tmp // 10 % 10
            elif tmp // 10 % 10 == 8:
                num = 9
            elif tmp // 10 % 10 == 9:
                num = 8
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > k:
                print(-1)
                break
    elif k % 10 == 3:
        tmp = k * 9
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 3 - 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > k:
                print(-1)
                break
    elif k % 10 == 7:
        tmp = k * 1
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 7 + 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > k:
                print(-1)
                break
    elif k % 10 == 9:
        tmp = k * 3
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) + 3) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > k:
                print(-1)
                break

if __name__ == '__main__':
    main()


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


ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            const ll mid = (lo + hi) / 2;
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}


void solve(long long N, long long M, std::vector<long long> A){
    const ll max_a = *max_element(A.begin(), A.end());

    vector<ll> num(max_a + 1, 0);
    for(auto x : A){ num.at(x)++; }

    vector<ll> cs(max_a + 1, 0);
    cs.back() = num.back();
    for(ll i = max_a - 1; i >= 0; --i){
        cs.at(i) = cs.at(i + 1) + num.at(i);
    }

    vector<ll> cs2(max_a + 1, 0);
    cs2.at(max_a) =  num.at(max_a) * max_a;
    for(ll i = max_a - 1; i >= 0; --i){
        cs2.at(i) = cs2.at(i + 1) + num.at(i) * i;
    }

    const ll lb = binary_search(
        1, 2 * max_a + 1,
        [&](ll x){
            ll count = 0;
            REP(i, N){
                const ll v = max(0LL, x - A.at(i));
                if(v <= max_a){
                    count += cs.at(max(0LL, x - A.at(i)));
                }
            }
            return count <= M;
        },
        false
    );

    ll ans = 0;
    ll count = 0;
    REP(i, N){
        const ll v = max(0LL, lb - A.at(i));
        if(v <= max_a){
            ans += cs.at(v) * A.at(i) + cs2.at(v);
            count += cs.at(v);
        }
    }
    assert(count <= M);
    ans += (M - count) * (lb - 1);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
	int N;
	char S[128];
	int horieyui = 0;
	int tomatuharuka;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%127s", S) != 1) return 1;
	for (tomatuharuka = 1; tomatuharuka < N; tomatuharuka++) {
		char mizuhasikaori[256] = {0};
		int uesakasumire;
		int hayamisaori = 0;
		for (uesakasumire = 0; uesakasumire < N; uesakasumire++) {
			mizuhasikaori[(unsigned char)S[uesakasumire]] |= 1 + (uesakasumire >= tomatuharuka);
		}
		for (uesakasumire = 0; uesakasumire < 256; uesakasumire++) {
			if (mizuhasikaori[uesakasumire] == 3) hayamisaori++;
		}
		if (hayamisaori > horieyui) horieyui = hayamisaori;
	}
	printf("%d\n", horieyui);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 200;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int>x(n);
    for(int i=0;i<n;i++)
    cin>>x[i];
    sort(x.begin(),x.end());
    int ans=INF;
    for(int i=x[0];i<=x[n-1];i++)
    {
        int s=0;
        for(int j=0;j<n;j++)
        {
            s+=fabs((i-x[j])*(i-x[j]));
        }
        ans=min(ans,s);
    }
    cout<<ans;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n;
vector<ll> res;

bool ok(ll x){
	return x*(x+1)/2>=n;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	ll lb=0,ub=n;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(ok(mid))ub=mid;
		else lb=mid;
	}
	res.pb(ub);
	n-=ub;
	for(int i=ub-1;i>=1;i--){
		if(n>0&&n>=i){
			n-=i;
			res.pb(i);
		}
	}
	sort(all(res));
	rep(i,res.size())cout<<res[i]<<endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i]+1 == A[i+1]:
        ans = ans + C[A[i]-1]
print(ans)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 4005
#define MAX_T 4005

typedef long long ll;
#define INF (1LL<<60)

struct data{
  ll t,p,f;
  bool operator < (const data &p)const{
    return f<p.f;
  }
};

int N,T;
data a[MAX_N];

ll dp[MAX_T][MAX_N];
ll dm[MAX_T][MAX_N];

ll calc(int x,int y){
  if(y==0)return 0;
  return (a[x].f-a[y].f)*(a[x].f-a[y].f);
}

int main(){
  for(int i=0;i<MAX_T;i++){
    for(int j=0;j<MAX_N;j++){
      dp[i][j]=(j==0?0:-INF);
      dm[i][j]=(i==0||j==0?0:-INF);
    }
  }
  
  cin>>N>>T;
  a[0]=(data){0,0,0};
  
  for(int i=1;i<=N;i++){
    cin>>a[i].t>>a[i].p>>a[i].f;
  }
  sort(a+1,a+N+1);

  ll ans=0;
  
  for(int i=1;i<=T;i++){

    deque<int> deq;
    deq.push_back(0);
    
    for(int j=1;j<=N;j++){
      dp[i][j]=max(dp[i][j],dp[i-1][j]);
      if(i-a[j].t>=0){
        dp[i][j]=max(dp[i][j],dm[i-a[j].t][j]+a[j].p);
      }
      ans=max(ans,dp[i][j]);


      
      while(deq.size()>=2){
        int a=deq.front();deq.pop_front();
        int b=deq.front();
        if( dp[i][a]-calc(j,a) > dp[i][b]-calc(j,b) ){
          deq.push_front(a);
          break;
        }
      }
      
      int key=deq.front();
      dm[i][j]=dp[i][key]-calc(j,key);

      while(!deq.empty()){
        int a=deq.back();deq.pop_back();
        if( dp[i][a]-calc(j,a) > dp[i][j] ){
          deq.push_back(a);
          break;
        }
      }
      deq.push_back(j);
    }
  }
  /*
  for(int i=0;i<=15;i+=5){
    for(int j=0;j<=3;j++){
      if(dp[i][j]==-INF){
        cout<<"INF"<<' ';
      }else{
        cout<<dp[i][j]<<' ';
      }
    }
    cout<<endl;
  }
  cout<<endl;
  
  for(int i=0;i<=15;i+=5){
    for(int j=0;j<=3;j++){
      if(dm[i][j]==-INF){
        cout<<"INF"<<' ';
      }else{
        cout<<dm[i][j]<<' ';
      }
    }
    cout<<endl;
  }

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

Measured memory_bytes: 253860
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 
int dp[1000010];
int dp2[1000010];

int main(){
	int a = 1, b;
	vi v;
	vi u;
	while((b = a*(a+1)*(a+2)/6)<1e6){
		v.pb(b);
		if(b%2 == 1){
			u.pb(b);
		}
		a++;
	}
	//cout<<v.size()<<endl;
	for(int i = 0; i < 1000010; i++){
		dp[i] = INF;
		dp2[i] = INF;
	}
	dp[0] = 0;
	dp2[0] = 0;
	for(int i = 0; i < v.size(); i++){
		for(int j = v[i]; j < 1000010; j++){
			dp[j] = min(dp[j], dp[j-v[i]]+1);
			if(i < u.size() && j >= u[i]){
				dp2[j] = min(dp2[j], dp2[j-u[i]]+1);
			}
		}
	}
	//cout<<"OK"<<endl;
	int n;
	while(cin>>n && n > 0){
		cout<<dp[n]<<" "<<dp2[n]<<endl;
	}
}

Measured memory_bytes: 9032
import itertools
N,M,R=map(int, input().split())
r=list(map(int, input().split()))
G = [[float("inf")]*N for i in range(N)] 
for i in range(M):
    a,b,c=map(int, input().split())
    G[a-1][b-1]=c
    G[b-1][a-1]=c

def warshall_floyd(G):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                G[i][j] = min(G[i][j],G[i][k] + G[k][j])
    return G
G=warshall_floyd(G)
ans=10**8
for L in itertools.permutations(r):
    L=list(L)
    sub=0
    for i in range(1,R):
        s=L[i-1]
        t=L[i]
        sub+=G[s-1][t-1]
    ans=min(ans, sub)
print(ans)

Measured memory_bytes: 59864
#include <bits/stdc++.h>
using namespace std;
long long cum[100005],cumz[100005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		cum[i]=cum[i-1]+a;
		cumz[i]=cumz[i-1]+max(a,0);
	}
	long long ans=0;
	for (int i=0;i<=n-k;i++)
	ans=max(ans,cumz[n]-(cumz[i+k]-cumz[i])+max(0LL,cum[i+k]-cum[i]));
	printf("%lld",ans);
}

Measured memory_bytes: 5360
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <assert.h>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto &i : n)

#define int long long

signed main() {

	int i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	//t,s,z

	int ans = 0, ans2 = 0;

	if (i && j && l) {
		ans += o;
		ans += 3;
		ans += (i - 1) / 2 * 2;
		ans += (j - 1) / 2 * 2;
		ans += (l - 1) / 2 * 2;
	}

	ans2 += o;
	ans2 += i / 2 * 2;
	ans2 += j / 2 * 2;
	ans2 += l / 2 * 2;

	cout << max(ans, ans2) << endl;
	return 0;
}

Measured memory_bytes: 256