akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>
 
using namespace std;

int main(){
    int x, y;
    cin >> x >> y;

    if(y >= 2*x && y <= 4*x && (y-2*x)%2 == 0 && (4*x - y)%2 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,v,p;
ll m,a[100005];

int main(){
	scanf("%d%lld%d%d",&n,&m,&v,&p);
	rep(i,n) scanf("%lld",&a[i]);
	sort(a,a+n);
	int lb = -1,ub = n-1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		vector<ll>b;
		rep(i,n) if(mid != i) b.pb(a[i]);
		ll base = a[mid]+m;
		ll ok = 0;
		reverse(b.begin(),b.end());
		bool bad = 0;
		rep(i,b.size()){
			if(i < p-1) ok += m;
			else if(base >= b[i]) ok += min(m,base-b[i]);
			else bad = 1;
		}
		if(bad){
			lb = mid;
		}
		else if(ok >= m*(v-1)){
			ub = mid;
		}
		else lb = mid;
	}
	cout << n-ub << endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n, d;
//ll a[SZ];
//ll b[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin3(x, k, d);

    if(x < 0) x *= (-1LL);

    ll r = x % d;
    c = x / d;
    if(k < c) {
        x -= (k * d);
        cot1(x);
        return 0;
    }

    k -= c;
    if(k%2) r -= d;
    if(r < 0) r *= -(1LL);

    cot1(r);

    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >> b;
	if (a >9 || b >9) {
		cout << -1 <<endl;
		return 0;
	}
	cout << a * b <<endl;
	return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main()
{
	int count[101],data,max,
		i;
	for(i=1;i<=100;i++) count[i]=0;
	while(scanf("%d",&data)!=EOF) count[data]++;
	for(max=0,i=1;i<=100;i++) max= max<count[i] ? count[i] : max;
	for(i=1;i<=100;i++){
		if(max==count[i]){
			printf("%d\n",i);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std; 
int main(void){

  int n;
  string s;
  cin >> n >> s;
  
  int result = 0;
  char pre = ' ';
  
  for(char c : s){
    if (c != pre) result++;
    pre = c;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n, k;
  cin >> n >> k;
  deque<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int lim = min(k, n);

  ll ans = 0;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; b <= n; b++) {
      if (a + b > lim) continue;

      vector<ll> t;
      for (int i = 0; i < a; i++) {
        t.push_back(v[i]);
      }
      for (int i = 0; i < b; i++) {
        t.push_back(v[n - 1 - i]);
      }

      ll sum = 0;
      sort(all(t));
      for (int i = 0; i < t.size(); i++) {
        sum += t[i];
      }
      for (int i = 0; i < min(k - (a + b), (int)t.size()); i++) {
        sum -= t[i] < 0 ? t[i] : 0;
      }

      ans = max(sum, ans);
    }
  }

  cout << ans << ln;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int map_size;
	int map[20][20];
	int road_num;
	int a,b,c,d;
	int start,goal,money,cost;
	int i,j,k;
	scanf("%d",&map_size);
	for(a=0;a<map_size;a++) {
		for(b=0;b<map_size;b++) {
			map[a][b]=0x20000000;
		}
		map[a][a]=0;
	}
	scanf("%d",&road_num);
	for(i=0;i<road_num;i++) {
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--;b--;
		map[a][b]=c;
		map[b][a]=d;
	}
	scanf("%d,%d,%d,%d",&start,&goal,&money,&cost);
	start--;goal--;
	for(k=0;k<map_size;k++) {
		for(i=0;i<map_size;i++) {
			for(j=0;j<map_size;j++) {
				if(map[i][k]+map[k][j]<map[i][j]) {
					map[i][j]=map[i][k]+map[k][j];
				}
			}
		}
	}
	printf("%d\n",money-cost-map[start][goal]-map[goal][start]);
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String S=sc.next(),T=sc.next();
		int a=sc.nextInt(),b=sc.nextInt();
		String U = sc.next();
		if(U.equals(S)) {
			a--;
		}
		else if(U.equals(T))
			b--;
		System.out.println(a+" "+b);
	}
}


Measured memory_bytes: 21204
using System;
using System.Numerics;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        Console.WriteLine(Parse(sc.Next()) - Parse(sc.Next()));
    }

    public BigInteger Parse(string s)
    {
        BigInteger result = 0;
        StringBuilder sb = new StringBuilder();
        int minus = s[0] == '-' ? 1 : 0;

        for (int i = minus; i < s.Length; i++)
        {
            sb.Append(s[i]);
            if ((i + 1) % 18 == minus)
            {
                result *= (long) 1e18;
                result += long.Parse(sb.ToString());
                sb = new StringBuilder();
            }
        }

        result *= (long) Math.Pow(10, sb.Length);
        result += long.Parse(sb.ToString());
        return minus == 1 ? -result : result;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 40792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        if (m % n == 0) {
            System.out.println(m / n);
            return;
        }

        int max = m / n;

        while (true) {
            int amari = m - max * n;
            if (amari % max == 0) {
                System.out.println(max);
                return;
            }
            max--;
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int ans=0;
	string s,a;
	cin>>a>>s;
	a+=a;
		for(int j=0;j<a.size()-s.size();j++){
			if(s==a.substr(j,s.size())){
			    puts("Yes");
			    return 0;
			}
		}
	puts("No");
}



Measured memory_bytes: 3216
n,m,r=map(int,input().split())
r=list(map(int,input().split()))

import sys
INF=float('inf')

road=[[INF]*n for _ in range(n)]

for _ in range(m):
    a,b,c=map(int,input().split())
    road[a-1][b-1]=c
    road[b-1][a-1]=c

#経由地
for k in range(n):
    #出発地
    for s in range(n):
        #goal
        for g in range(n):
            road[s][g]=min(road[s][g],road[s][k]+road[k][g])

import itertools
rlist=list(itertools.permutations(r))

result=10**9
for item in rlist:
    tmp=0
    from_town=item[0]
    for to_town in item[1:]:
        tmp+=road[from_town-1][to_town-1]
        from_town=to_town
    result=min(result,tmp)

print(result)





Measured memory_bytes: 78680
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
//vector<vector<ll>> vv(50, vector<ll>(50, 0));

int main()
{
	while (true)
	{
		cin >> n;
		if (!n) return 0;
		vector<vector<ll>> vv(50, vector<ll>(50, 0));
		counter = 0;
		REP(i, n)
		{
			ll a, b;
			cin >> a >> b;
			vv[a][b] = 1;
		}
		ll m;
		cin >> m;
		ll px = 10, py = 10;
		if (vv[px][py]) counter++;
		REP(i,m)
		{
			char c;
			ll d;
			cin >> c >> d;
			if (c == 'N')
			{
				REP(i, d)
				{
					py++;
					if (vv[px][py])
					{
						counter++;
						vv[px][py] = 0;
					}
				}
			}
			if (c == 'E')
			{
				REP(i, d)
				{
					px++;
					if (vv[px][py])
					{
						counter++;
						vv[px][py] = 0;
					}
				}
			}
			if (c == 'W')
			{
				REP(i, d)
				{
					px--;
					if (vv[px][py])
					{
						counter++;
						vv[px][py] = 0;
					}
				}
			}
			if (c == 'S')
			{
				REP(i, d)
				{
					py--;
					if (vv[px][py])
					{
						counter++;
						vv[px][py] = 0;
					}
				}
			}
		}
		cout << (counter == n ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 3164
/*
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;


int main(){
  ll ans=0;
  string s;cin>>s;
  int flag=0;
  if (s[0]=='7')flag=1;
  if (s[1]=='7')flag=1;
  if (s[2]=='7')flag=1;
  if (flag==0){
    cout<<"No"<<endl;
    return 0;
  }else{
    cout<<"Yes"<<endl;
    return 0;
  }
  return 0;
}

*/


/*
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  REP(i,n){
    if ((i+1)%3!=0){
      if ((i+1)%5!=0)
        ans+=(i+1);
    }
  }
  cout<<ans<<endl;
  return 0;
}
*/





/*
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}


int main(){
  ll ans=0;
  cin >> k;
  REP(i,k){
    REP(j,k){
      REP(h,k){
        ans+=gcd(gcd(i+1,j+1),h+1);
      }
    }
  }


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



#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  string s;cin>>s;

  vi ar(n+1);
  vi ag(n+1);
  vi ab(n+1);

  REP(i,n){
    if (s[i]=='R'){
      s[i]='1';
    }
    
    if (s[i]=='G'){
      s[i]='2';
    }
    
    if (s[i]=='B'){
      s[i]='3';
    }
  }

  for(ll i=n-1;i>=0;i--){
    if (s[i]=='1'){
      ar[i]=ar[i+1]+1;
    }else{
      ar[i]=ar[i+1];
    }
  }
  
  for(ll i=n-1;i>=0;i--){
    if (s[i]=='2'){
      ag[i]=ag[i+1]+1;
    }else{
      ag[i]=ag[i+1];
    }
  }
  
  for(ll i=n-1;i>=0;i--){
    if (s[i]=='3'){
      ab[i]=ab[i+1]+1;
    }else{
      ab[i]=ab[i+1];
    }
  }


  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      if (s[i]!=s[j]){
        ll moji=(s[i]-48)^(s[j]-48);
        if (moji==1){
          ans+=ar[j+1];
        }
        if (moji==2){
          ans+=ag[j+1];
        }
        if (moji==3){
          ans+=ab[j+1];
        }
        if ((j-i)+j<n){
          if ((s[(j-i)+j]-48)==moji)ans--;
        }
        
      }else{
        continue;
      }


    }
  }

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

Measured memory_bytes: 3708
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    int ans = 0;
    rep(i, n) {
        if (i % 2 == 1) continue;
        if (v[i] % 2 == 0) continue;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3544
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

cnt = 0
A = []
for i in range(N):
    A = list(map(int, input().split()))
    S = []
    for j in range(M):
        S.append(A[j] * B[j])
    if sum(S) + C > 0:
        cnt += 1
    S = []
    A = []
print(cnt)


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

int main(){
	string o, e;
	cin >> o >> e;
	for(int i=1; i <= o.size() + e.size(); i++){
		if(i%2)
			cout << o[i/2];
		else
			cout << e[(i-1)/2];
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100001],a[100001]={1};
int main()
{
	memset(f+1,0x7f,sizeof(f)-sizeof(f[0]));
	int i,j,m=1,n,k=1;
	scanf("%d",&n);
	for(i=0;;i++)
	{
		if((a[m++]=pow(6,i))>n)
			break;
	}
	for(i=0;;i++)
	{
		if((a[m++]=pow(9,i))>n)
			break;
	}
	sort(a,a+m);
	for(i=1;i<=n;i++)
	{
		for(j=0;j<m&&i>=a[j];j++)
		{
				f[i]=min(f[i],f[i-a[j]]+1);
		}
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    string s;
    int k;
    cin >> s >> k;
    vector<string> t;
    for(int i = 0;i<s.size();i++) {
        for(int j = 1;j<=k;j++) {
            string tmp = s.substr(i,j);
            t.push_back(tmp);
        }
    }
    sort(t.begin(),t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    cout << t[k-1] << endl;
}

Measured memory_bytes: 1660
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        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 answer = 0;
        for (int i = 0; i <= A; i++) {
            for (int j = 0; j <= B; j++) {
                for (int k = 0; k <= C; k++) {
                    if (500 * i + 100 * j + 50 * k == X) answer++;
                }
            }
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27492
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextLine.toCharArray
    val t = sc.nextLine.toCharArray


    val mp = scala.collection.mutable.Map[Char, Char]()

    //アルファベットの対応付けを記録して、異なる場合はfalse
    var matched = true
    var index = 0
    while (matched && index < s.length) {
      if (mp.contains(s(index)) && mp(s(index)) != t(index)) {
        matched = false
      } else {
        mp.put(s(index), t(index))
      }
      index += 1
    }
    if(mp.values.toList.distinct.length != mp.keys.toList.distinct.length) {
      matched = false
    }

    println(if (matched) "Yes" else "No")
  }

}


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

int main() {
	int n, x = 1, r = 0; cin >> n;
	for(int i = 0; i < n; i++) {
		int b; cin >> b;
		if(b == x) x++;
		else r++;
	}
	if(r == n) cout << -1;
	else cout << r;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define ll long long
# define mod 1000000000;
# define lar 1000
using namespace std;
int main()
{
	ll h,w,ans;
	cin>>h>>w;
	if(h==1||w==1)
	ans=1;
	else
	ans=(h*w+1)/2;
	cout<<ans;	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <map>
#include <queue>
using namespace std;

map<int, int> ma;

int encode(int a[]) {
	int res = 0;
	for (int i = 0; i < 8; i++)
		res |= a[i] << (i * 3);
	return res;
}

void decode(int x, int a[]) {
	for (int i = 0; i < 8; i++)
		a[i] = (x >> (i * 3)) & 7;
}

void bfs() {
	int i[] = {0, 1, 2, 4, 5, 6, 0, 1, 2, 3};
	int j[] = {1, 2, 3, 5, 6, 7, 4, 5, 6, 7};
	int a[] = {0, 1, 2, 3, 4, 5, 6, 7};
	int x = encode(a);
	ma[x] = 0;
	queue<int> que;
	que.push(x);
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		int a[8];
		decode(x, a);
		for (int k = 0; k < 10; k++) {
			if (a[i[k]] != 0 && a[j[k]] != 0)
				continue;
			swap(a[i[k]], a[j[k]]);
			int _x = encode(a);
			if (ma.count(_x) == 0) {
				ma[_x] = ma[x] + 1;
				que.push(_x);
			}
			swap(a[i[k]], a[j[k]]);
		}
	}
}

int main() {
	bfs();
	for (;;) {
		int a[8];
		for (int i = 0; i < 8; i++)
			if (scanf("%d", &a[i]) == EOF)
				return 0;
		printf("%d\n", ma[encode(a)]);
	}
	return 0;
}

Measured memory_bytes: 1996
#include<iostream>
using namespace std;
long n,k,s;
main()
{
	cin>>n>>k;
	for(long i=0;i<k&&i<=n;i++)
	{
		if(i*2%k)continue;
		long c=(n-i)/k;
		if(i)c+=1;
		s+=c*c*c;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
sub f{my$i=pop;$p[$i]=$p[$i]-$i?f($p[$i]//=$i):$i}
@s=(1)x<>;$%=@s*$#s/2;
map{unshift@a,$%;$%-=$s[$A]*$s[$B],$s[$p[$A]=$B]+=$s[$A]if($A=f$`-/ /)-($B=f$'-1)}reverse<>;
print"@a"


Measured memory_bytes: 41728
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define INF (INT_MAX/2)


typedef struct {
  int v; // 接続先の番号
  int c; // 有向辺の重み
} edge;

typedef struct {
  int k; // 頂点の持つ有向辺の数
  edge* e; // 有向辺の配列
} vertex;



int* ssspForCost( vertex* g, int n ) {

  int i;
  int *dist, color[n];
  int minCost, u;

  dist = (int*)malloc( sizeof( int ) * n );

  //初期化
  for( i=0; i<n; i++ ) { 
    dist[i] = INF;
    color[i] = 0;
  }

  dist[0] = 0;

  while( 1 ) {

    minCost = INF;
    for( i=0; i<n; i++ ) {
      if( color[i] != 1 && dist[i] < minCost ) {
	minCost = dist[i];
	u = i;
      }
    }

    if( minCost == INF ) {
      break;
    }

    color[ u ] = 1;

    for( i=0; i<g[u].k; i++ ) {
      if( color[ g[u].e[i].v ] != 1 && dist[u] + g[u].e[i].c < dist[ g[u].e[i].v ] ) {
	dist[ g[u].e[i].v ] = dist[u] + g[u].e[i].c;
      }
    }

  }

  return dist;

}


void printDist( int* dist, int n ) {
  int i;

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

  return;

}


int main() {

  int i, j;
  int n, u; // n:頂点の数
  vertex* g;
  
  int* dist;

  scanf( "%d", &n );
  g = (vertex*)malloc( sizeof( vertex ) * n );

  for( i=0; i<n; i++ ) {
    scanf( "%d", &u );
    scanf( "%d", &g[u].k );
    g[u].e = (edge*)malloc( sizeof( edge ) * g[u].k );

    for( j=0; j<g[u].k; j++ ) {
      scanf( "%d%d", &g[u].e[j].v, &g[u].e[j].c );
    }
  }

  dist = ssspForCost( g, n );

  printDist( dist, n );

  return 0;
}

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

int n;
pair<int, int>p[300000];
bool ok(int t) {
	priority_queue<int>Q; ll sum = 0;
	for (int i = n - 1; i >= n - t + 1; i--) {
		Q.push(p[i].second); sum += p[i].second;
	}
	if (p[n - t].first*(ll)t >= sum + p[n - t].second)return 1;
	for (int i = n - t; i > 0; i--) {
		if (!Q.empty() && Q.top() > p[i].second) {
			sum -= Q.top() - p[i].second; Q.pop();
			Q.push(p[i].second);
		}
		if (p[i - 1].first*(ll)t >= sum + p[i - 1].second)return 1;
	}
	return 0;
}
int main() {
	scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int a = 0, b = n;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		if (ok(t))a = t;
		else b = t - 1;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 8252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll res=0;
  ll sum=0,Xor=0;
  int right = 0;     
  for(int left=0;left<n;left++){
    while(right<n && sum+a[right]==(Xor^a[right])){
      sum += a[right];
      Xor^=a[right];
        right++;
    }
    res+=right-left;
    sum-=a[left];
    Xor^=a[left];
  }
  cout << res << endl;
return 0;}

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(n);
	if(n == 1)
	cout << "Hello World" << endl;
	else
	{
		get(a);
		get(b);
		cout << a + b << endl;
	}	

	return 0;
}

Measured memory_bytes: 3652
N = int(input())
A = [int(_) for _ in input().split()]

cnt = 0
for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= -1

if cnt % 2 == 0:
    print(sum(A))
else:
    print(sum(A) - min(A) * 2)


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

int ns[100002]={0}, ew[100002]={0};

int main(){
    int n, w, h;
    cin >> n >> w >> h;
    for(int i=0;i<n;++i){
        int x, y, d;
        cin >> x >> y >> d;
        ew[max(0, x-d)] += 1;
        ew[min(w, x+d)] -= 1;
        ns[max(0, y-d)] += 1;
        ns[min(h, y+d)] -= 1;
    }

    bool xflag = (ew[0] > 0 ? false : true), yflag = (ns[0] > 0 ? false : true);
    int cx = ew[0], cy = ns[0];
    for(int i=1;i<max(w,h);++i){
        if(i < w && !xflag)
            cx += ew[i];
        if(i < h && !yflag)
            cy += ns[i];
        if(cx <= 0)
            xflag = true;
        if(cy <= 0)
            yflag = true;
    }

    cout << ((xflag && yflag) ? "No" : "Yes") << endl;


    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)

int cubes[2][21];

class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		int n, m;
		while (std::cin >> n >> m, n, m) {
			std::memset(cubes, 0, sizeof(cubes));
			rep(i, n) {
				int a;
				std::cin >> a;
				cubes[0][a]++;
			}
			rep(i, m) {
				int a;
				std::cin >> a;
				cubes[1][a]++;
			}

			int total = 0;
			rangeRep(i, 1, 21) {
				if (cubes[0][i] == cubes[1][i]) total += cubes[0][i] * i;
				else if (cubes[0][i] < cubes[1][i]) {
					total += cubes[1][i] * i;
				}
				else if (cubes[0][i] > cubes[1][i]) {
					total += cubes[0][i] * i;
				}
			}
			std::cout << total << std::endl;
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 2996
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
template<class T> void rd(T &x) {
	x=0; int f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
	x*=f;
}
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;}
const int maxH=185+5,maxW=185+5;
int H,W; char A[maxH][maxW];
int sum[maxH][maxW];
int f[2][maxH][maxH][maxW],g[2][maxW][maxW][maxH];
inline bool check(int xl,int yl,int xr,int yr) {
	--xl,--yl;
	int t=sum[xr][yr]-sum[xl][yr]-sum[xr][yl]+sum[xl][yl];
	return t==0||t==(xr-xl)*(yr-yl);
}
int main() {
	rd(H),rd(W);
	for(int i=1;i<=H;++i) scanf("%s",A[i]+1);
	for(int i=1;i<=H;++i) for(int j=1;j<=W;++j) {
		sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(A[i][j]=='#');
	}
	int cur=0;
	for(int a=1;a<=H;++a) for(int b=a;b<=H;++b) {
		int k=1;
		for(int i=1;i<=W;++i) {
			Cmax(k,i); while(k<=W&&check(a,i,b,k)) ++k;
			f[cur][a][b][i]=k;
		}
	}
	for(int a=1;a<=W;++a) for(int b=a;b<=W;++b) {
		int k=1;
		for(int i=1;i<=H;++i) {
			Cmax(k,i); while(k<=H&&check(i,a,k,b)) ++k;
			g[cur][a][b][i]=k;
		}
	}
	for(int i=1;;++i) {
		if(f[cur][1][H][1]==W+1) {printf("%d\n",i-1); break;}
		cur^=1;
		for(int a=1;a<=H;++a) for(int b=a;b<=H;++b) for(int i=1;i<=W;++i) {
			int t=f[cur^1][a][b][i];
			f[cur][a][b][i]=t==W+1?W+1:f[cur^1][a][b][t];
		}
		for(int a=1;a<=W;++a) for(int b=a;b<=W;++b) for(int i=1;i<=H;++i) {
			int t=g[cur^1][a][b][i];
			g[cur][a][b][i]=t==H+1?H+1:g[cur^1][a][b][t]; 
		}
		for(int a=1;a<=H;++a) for(int b=a;b<=H;++b) {
			int k=1;
			for(int i=1;i<=W;++i) {
				Cmax(k,i); while(k<=W&&g[cur][i][k][a]>b) ++k;
				Cmax(f[cur][a][b][i],k);
			}
		}
		for(int a=1;a<=W;++a) for(int b=a;b<=W;++b) {
			int k=1;
			for(int i=1;i<=H;++i) {
				Cmax(k,i); while(k<=H&&f[cur][i][k][a]>b) ++k;
				Cmax(g[cur][a][b][i],k);
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 58036
#include <iostream>
using namespace std;
int main(){
    long long N; cin >> N;
    long long ans = 0, manip = 10;
    if(N % 2 == 1){
      cout << 0 << endl;
      return 0;
    }
    while(1){
        if(manip > N) break;
        ans += N / manip;
        manip *= 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}

int N, M, X;
int ans;

bool is_over(vector<int> *a, ll select){
    int tmp[M];
    memset(tmp, 0, sizeof(tmp));
    rep(i, N){
        if((select >> i)%2 == 1){
            rep(j, M){
                tmp[j] += a[i][j];
            }
        }
    }

    bool flag = true;
    rep(i, M){
        if(tmp[i] < X){
            flag = false;
            break;
        }
    }

    return flag;
}

void is_can(vector<int> c, vector<int> *a, int mid, int book, int sm, ll select, bool *flag){
    if(is_over(a, select)){
        *flag = true;
        return;
    }
    //加える
    if(book < N){
        if(sm+c[book] <= mid){
            is_can(c, a, mid, book+1, sm+c[book], select+(ll)pow(2,book), flag);
        }

        //加えない
        is_can(c, a, mid, book+1, sm, select, flag);
    }
}
 
int main()
{
    cin >> N >> M >> X;
    vector<int> a[N];
    vector<int> c(N);
    rep(i, N) a[i].resize(M);

    rep(i, N){
        cin >> c[i];
        rep(j, M){
            cin >> a[i][j];
        }
    }

    ans = 0;
    int left=0, right, mid;
    vector<bool> is_selected(N);
    rep(i, N) is_selected[i] = false;
    rep(i, N) right+=c[i];
    mid = (left+right)/2;

    bool flag, tmp;

    while(left<=right){
        flag = false;
        tmp = false;
        // is_can(c, a, mid, 0, 0, 0, &tmp);
        // printf("%d\n", tmp);

        is_can(c, a, mid, 0, 0, 0, &flag);
        if(flag){
            ans = mid;
            right = mid-1;
            mid = (left+right)/2;
        }else{
            left = mid+1;
            mid = (left+right)/2;
        }
    }

    if(ans==0) printf("-1\n");
    else print(ans);
    return 0;
}

Measured memory_bytes: 4140
n, y = [int(x) for x in input().split()]

f, t = -1, -1

start = 1000 * n

for i in range(n+1):
    if f != -1:
        break
    else:
        start = 1000 * n + 4000 * i
        for j in range(n-i+1):
            tmp = start + 9000 * j
            if tmp == y:
                f, t = i, j
                break

if f == -1:
    print('-1 -1 -1')
else:
    print(t, f, n-f-t)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 200005;
//////////////////////////////



void solve()
{
	string s;	cin >> s;
	int x, y;	cin >> x >> y;
	bool isy = false, is1st = true;
	set<int> dpx, dpy, buf;
	dpx.insert(0);
	dpy.insert(0);
	REP(i, s.length()) {
		if (s[i] == 'F') {
			int cnt = 0;
			while (s[i] == 'F' && i < s.length()) {
				cnt++; i++;
			}i--;
			if (isy) {
				buf = dpy;
				dpy.clear();
				for (auto a : buf) {
					dpy.insert(a + cnt);
					dpy.insert(a - cnt);
				}
			}
			else {
				buf = dpx;
				dpx.clear();
				for (auto a : buf) {
					dpx.insert(a + cnt);
					if (!is1st)dpx.insert(a - cnt);
				}
			}
		}
		else {
			isy = !isy; is1st = false;
		}
	}

	if (dpx.count(x) && dpy.count(y)) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 3 * 1e5 + 5;
const ll mod = 1e6 + 3;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
bool f(const string &a, int x, int y){
    while(x < y){
        if(a[x] != a[y])
            return 0;
        x++;y--;
    }
    return 1;
}
ll f(ll x){
    return x * (x - 1) / 2;
}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int n;
    cin >> n;
    ll v[n + 1];
    ll occ[n + 1];
    cls(occ, 0);
    ll ans = 0;
    fore(i, 0, n){
        cin >> v[i];
        occ[v[i]]++;
    }
    fore(i, 1, n + 1){
        if(occ[i]){
            ans += f(occ[i]);
        }
    }
    fore(i, 0, n)
        cout << ans - occ[v[i]] + 1 << '\n';
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 5760
x = int(input())
if x == 0:
    print(4)
    print(3, 3, 3, 3)
    exit()

x-= 1
phase = x//50
subphase = x%50
pstart = phase*50

left = 99+phase-(x-pstart)
right = 48+phase-(x-pstart)
ans = [left]*(1+subphase)+[right]*(49-subphase)
print(50)
print(*ans)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
using namespace std;
#pragma endregion
signed main() {
	int N,ans=1;
	cin >> N;
	vector <int> d(N);
	rep(i, N)
		cin >> d[i];
	sort(ALL(d));
	rep(i, N - 1) {
		if (d[i] < d[i + 1])
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

int res = 0;
bool end1 = false;

void calc(int k, string out, int n, string q){
    if(k == n){
        //cout << out << endl;
        if(end1) return;
        res++;
        if(q == out){
            // cout << out << endl;
            // cout << res << endl;
            end1 = true;
        }
        return;
    }
    rep(i, n){
        bool ok = false;
        rep(j, out.size()){
            if(out[j] == i+1+'0'){
                ok = true;
            }
        }
        if(ok) continue;
        calc(k+1, out+to_string(i+1), n, q);
    }
}

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    string p;
    string q;
    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        p += to_string(a);
    }
    rep(i, n){
        int a;
        cin >> a;
        q += to_string(a);
    }
    string out = "";
    calc(0, out, n, p);
    end1 = false;
    int res2 = res;
    //print(res2);
    out = "";
    res = 0;
    calc(0, out, n, q);
    res2 -= res;
    res2 = abs(res2);
    cout << res2 << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

int n; 
vector<int> g[2005];
string s;
int dist[2005], np[2005], dp[2005];

void dfs(int u, int par){
	if(s[u]=='1'){
		np[u]++;
	}
	vector<pair<int,int>> a;
	for(auto v:g[u]){
		if(v!=par){
			dfs(v,u);
			np[u]+=np[v];
			dist[u]+=(dist[v]+np[v]);
			a.emplace_back(dp[v]+np[v], dist[v]+np[v]);
		}
	}
	int nn = a.size();
	
	dp[u]=dist[u];
	if(a.empty())
		return;
	sort(a.begin(),a.end());
	int val=0;
	for(int i=0;i<nn-1;i++){
		if(a[i].se<=a.back().fi){
			val+=a[i].se;
		}
		else{
			val+=a.back().fi;
		}
	}
	dp[u]=min(dp[u],max(0,a.back().fi-val));
	
	sort(a.begin(),a.end(),[](pair<int,int> &pp, pair<int,int> &qq){
		return pp.se<qq.se;
	});
	vector<int> suf(nn+1,0), mmx(nn+1,0),pre(nn,0), la(nn,nn);
	
	for(int i=nn-1;i>=0;i--){
		suf[i]=suf[i+1]+a[i].fi;
		mmx[i]=max(mmx[i+1], a[i].fi);
		if(i<nn-1){
			if(a[i].se==a[i+1].se){
				la[i]=la[i+1];
			}
			else{
				la[i]=i+1;
			}
		}
	}
	pre[0]=a[0].se;
	for(int i=1;i<nn;i++){
		pre[i]=a[i].se+pre[i-1];
	}
	
	for(int i=0;i<nn;i++){
		if(mmx[la[i]]<=a[i].se){
			int cur = pre[la[i]-1]-a[i].se + (nn-la[i])*a[i].se;
			dp[u]=min(dp[u],max(0,a[i].se-cur));
		}
	}
	
	
	if((dp[u]==0) && (dist[u]&1)){
		dp[u]++;
	}
}

int solve(int root){
	memset(dist,0,sizeof(dist));
	memset(np,0,sizeof(np));
	if(root==800){
		sqrt(5);
	}
	dfs(root,-1);
	return ((dp[root]>0)?INT_MAX:dist[root]/2);
}

int main(){
	//ifstream cin("input.txt");
	
	cin >> n;
	cin >> s;
	for(int i=0,u,v;i<n-1;i++){
		cin >> u >> v; u--,v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int ans = INT_MAX;
	
	for(int i=0;i<n;i++){
		ans=min(ans,solve(i));
	}
	if(ans==INT_MAX){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
	//cin.close();
	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
P = list(map(int, input().split()))

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
cusum = [0]
for e in E:
    cusum.append(cusum[-1] + e)
#print(cusum)

# 隣接K個の和
ans = 0
for i in range(K, N+1):
    tmp_e = cusum[i] - cusum[i-K]
    #print(i, tmp_e)
    ans = max(ans, tmp_e)
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int n,m,x;

    
int a[12][12];

int main(void){
    // Your code here!
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = INF;
    rep(s,1<<n){
        int cost = 0;
        vector<int> d(m);
        rep(i,n){
            if ( s >> i&1) {
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if(d[j] < x) ok = false;
        if (ok) ans = min(ans,cost);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] hoge =new int[N];

		for (int i=0; i<N; i++) {
			hoge[i] = scan.nextInt();
		}


		//seisuuka?
		int[] hoge2 = new int[N];
		boolean b = true;
		int count = 0;
		while(b) {

			for(int i = 0; i<N; i++) {
				if((hoge[i]%2)!=0) {
					b = false;
					break;
				}
				hoge2[i] = hoge[i]/2;
				if (i==N-1) {
					hoge = hoge2;
					count = count +1;
				}


			}

		}
		System.out.println(count);


	}

}


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

int mex(int a, int b){
    for(int i=0; ; i++) if(a != i && b != i) return i;
}

int solve(){
    int64_t N, M;
    cin >> N >> M;
    vector<int> g = {0, 1};
    while(true){
        if(N == M) return g[0];
        if(M%2){
            M--;
            swap(g[0], g[1]);
        }
        int64_t m = M/2;
        if(m < N) return g[(M-N)%2];
        int v0 = mex(g[0], g[(M-m+1)%2]);
        int v1 = mex(v0, (m==2 ? v0 : g[0]));
        M = m;
        g = {v0, v1};
    }
}

int main() {
    int K;
    cin >> K;
    int G = 0;
    while(K--) G ^= solve();
    cout << (G ? "mo3tthi" : "tubuann") << endl;
    return 0;
}


Measured memory_bytes: 3124
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string N;
    cin >> N;

    ll sum = 0;
    REP(i, SIZE(N))
    {
        sum += int(N[i]) - 48;
    }

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3372