akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N; //要素数
  vector<T> dat;
  const T unit; //単位元 a * e = a
  Fn func;

public:
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

  void update(int k, T a)
  {             //k番目(0-indexed)をaに変更
    k += N - 1; //一番下
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2; //1つ上がる
      //更新
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]); //
    }
  }

  //[a, b)の値（最小値/和/etc.）を求める
  //kは節点の番号、l, rはその節点が[l,r)に対応づいていることを表す
  //外からはquery(a, b)と呼ぶ

  T query(int a, int b, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = N;
    if (r <= a || b <= l)
      return unit;
    //[a, b)が[l,r)を完全に含む
    if (a <= l && r <= b)
      return dat[k];
    else
    {
      int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr); //
    }
  }
};

bool compare(bool b1, bool b2)
{
  return b1 && b2;
}

int my_max(int a, int b)
{
  return max(a, b);
}

int my_min(int a, int b)
{
  return min(a, b);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  int n, k;
  cin >> n >> k;
  int p[200010];
  rep(i, n) cin >> p[i];

  //[l,r] がsortされているか
  SegmentTree<bool> sg_sorted(n - 1, compare, true);
  SegmentTree<int> sg_max(n, my_max, -INF), sg_min(n, my_min, INF);
  rep(i, n - 1) sg_sorted.update(i, p[i] < p[i + 1]);
  rep(i, n)
  {
    sg_max.update(i, p[i]);
    sg_min.update(i, p[i]);
  }

  int no_changed = 0;
  int ans = 0;
  for (int l = 0, r = l + k; r <= n; l++, r++)
  {
    dbg(l);
    dbg(ans);
    if (sg_sorted.query(l, r - 1))
    {
      cerr << "no" << endl;
      no_changed = 1;
      continue;
    }
    if (l == 0)
    {
      ans++;
      continue;
    }
    if (p[l - 1] < sg_min.query(l, r - 1) && sg_max.query(l, r - 1) < p[r - 1])
    {
      cerr << 'a' << endl;
      continue;
    }

    ans++;
  }
  ans += no_changed;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;


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

		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0){
				break;
			}

			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(j == W -1){
						System.out.println('#');
					}else{
						System.out.print('#');
					}
				}
				if(i == H -1){
					System.out.println("");
				}else{
					System.out.print("");
				}
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 34148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;

namespace AtCoderProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine();
            var res = abc.Contains('a') &&
            abc.Contains('b') &&
            abc.Contains('c') ?
            "Yes" :
            "No";
            Console.WriteLine(res);
        }


        #region READER
        static int ReadLineInt() => int.Parse(Console.ReadLine());
        static int[] ReadLineIntArray() => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        static IEnumerable<string> ReadInputEnumruble(int count = int.MaxValue)
        {
            for (int i = 0; i < count; i++)
            {
                yield return Console.ReadLine();
            }
        }
        static int[] ReadInputInt(int count = int.MaxValue)
        {
            return ReadInputEnumruble(count).Select(s => int.Parse(s)).ToArray();
        }
        #endregion
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int d=s.length();
	int e=t.length();
	int f=min(d,e);
	if(abs(e-d)!=1){
		cout<<"No\n";
}
	else{
		int count=0;
		for(int i=0;i<f;i++){
				if(s[i]!=t[i])
				count++;
	
}
		if(count==0)
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3608
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 1000001
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll a,b,c;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>c;
    cout<<c/max(a,b)+(c%max(a,b)!=0);
}

Measured memory_bytes: 3596
#include <stdio.h>

int main() {
    int sec_input;
    scanf("%d", &sec_input);
    int hour;
    int minute;
    int sec;
    hour = sec_input/3600;
    minute = (sec_input - hour*3600)/60;
    sec = sec_input - hour*3600 - minute*60;
    printf("%d:%d:%d\n", hour, minute, sec);
}


Measured memory_bytes: 2708
X,N=map(int,input().split())

array=list(map(int,input().split()))
P=[]
for i in array:
    P.append(i)

if not X in P:
    best=X
else:
    i=1
    while True:
        if not X-i in P:
            best=X-i
            break
        if not X+i in P:
            best=X+i
            break
        i+=1

print(best)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define f first
#define s second

int n,u,v,w, a[N];
vector <pair<int, int>> g[N];

void color_it(int p, int col, int par)
{
    a[p] = col;
    for(auto it : g[p])
    {
        if(it.f == par) continue;
        color_it(it.f, col^it.s, p);
    }
}

int main() {
    scanf("%d",&n);
    for(int i=1;i <n; i++)
    {
        scanf("%d%d%d",&u,&v,&w);
        a[u]++;
        a[v]++;
        g[u].push_back({v,w&1});
        g[v].push_back({u,w&1});
    }
    int p;
    for(int i=1; i<=n; i++)
    {
        if(a[i] == 1)
        {
            p = 1;
            break;
        }
    }
    memset(a, 0, sizeof a);
    color_it(p, 0, -1);
    for(int i=1; i<=n; i++) printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int w,a,b;
  cin>>w>>a>>b;
  if(b+w<a){cout<<a-(b+w)<<endl;}
  else if(a+w<b){cout<<b-(a+w)<<endl;}
  else{cout<<0<<endl;}
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b > a-b ? (a+b > a*b?(a+b) :(a*b)):(a-b > a*b?(a-b):(a*b)));
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  int cnt = 0;
  for(int i=1; i<n-1; i++){
    if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
      cnt++;
    }
  }

  cout << cnt << endl;
}

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

namespace Kyopuro1ads
{
    class Program
    {
        static void Main(string[] args)
        {

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string[] str = Console.ReadLine().Split(' ');

            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);

            double temp = Math.Log(N, K);

            int ans;

            if (temp == (int)temp)
            {
                ans = (int)temp +1;
            }
            else
            {
                ans = (int)Math.Ceiling(temp);
            }



            Console.WriteLine(ans);


            //  int N = int.Parse(Console.ReadLine());
            //  string[] str = Console.ReadLine().Split(' ');
            //  int i;
            //  int[] num = new int[N];
            //
            //  for (i = 0; i < N; i++)
            //  {
            //      num[i] = int.Parse(str[i]);
            //  }


            Console.Out.Flush();
        }





    }


}


Measured memory_bytes: 13140
s = input()
count = 0
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            break
    elif i == 1:
        if s[i].islower():
            pass
        else:
            break
    elif i>1 and i < len(s)-1 :
        if s[i]=='C':
            if count == 0:
                count += 1
            else:
                break
        elif s[i].islower():
            pass
        else:
            break
    elif i == len(s)-1 :
        if s[i].islower():
            if count ==1:
                print("AC")
                exit()
print("WA")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#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=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
vector<int> v[10];
bool used[10];
int n,m,ans;
void dfs(int x,int cnt){
	if(cnt==n)ans++;
	for(auto to:v[x]){
		if(!used[to]){
			used[to]=true;
			dfs(to,cnt+1);
			used[to]=false;
		}
	}
}
int main(){
   cin>>n>>m;
   rep(i,m){
	   int x,y;
	   cin>>x>>y;
	   x--;y--;
	   v[x].push_back(y);
	   v[y].push_back(x);
   }
   used[0]=true;
   dfs(0,1);
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  string t;
  while(cin >> t) {
    if(t=="#") break;
    string s="";
    rep(i,t.size()) {
      if(t[i]=='n') {
	s+='n';
	i+=4;
      } else {
	s+='w';
	i+=3;
      }
    }
    reverse(all(s));
    int ans=0,d=1;
    rep(i,s.size()) {
      ans*=2;
      if(s[i]=='w') ans+=90;
      else {
	if(i) ans-=90;
      }
      d*=2;
    }
    d/=2;
    int a=ans/__gcd(ans,d),b=d/__gcd(ans,d);
    if(b==1) pr(a);
    else cout << a << "/" << b << endl;
  }
  return 0;
}


Measured memory_bytes: 1200
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<ll,ll> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

int N,L;
string S[100];

int main(){
    cin>>N>>L;
    rep(i,N) cin>>S[i];

    sort(S,S+N);

    string ans;
    rep(i,N) ans+=S[i];

    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n = 0;
  cin >> n;

  ll ans = 0;
  for(ll i = 2; i*i <= n; i++){
    ll cnt = 0, j = 1;
    while(n % i == 0){
      n /= i;
      cnt++;
      if(cnt >= j){
        cnt = 0, j++, ans++;
      }
    }
  }

  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int ans;
	for (int i = 1; i <= 3; i++) {
		if (i != A && i != B) ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int a[106];
int bucket[106];
signed main() {
	int n; cin >> n;

	rep(i, n)cin >> a[i]; sort(a, a + n);
	rep(i, n)bucket[a[i]]++;
	int mx = a[n - 1], mn = a[0];
	int ans = 0;
	if ((mx + 1) / 2 != mn)ans++;
	if (mx & 1) {
		if (bucket[mn] != 2)ans++;
		for (int i = mn; i <= mx; i++) {
			if (bucket[i] < 2)ans++;
		}
	}
	else {
		if (bucket[mn]!=1)ans++;
		for (int i = mn + 1; i <= mx; i++) {
			if (bucket[i] < 2)ans++;
		}
	}
	if (ans)puts("Impossible");
	else puts("Possible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b;cin>>a>>b;
	int i;
	for(i = 1; i <=1000;++i){
		if((i*8)/100==a && i/10==b){
			cout<<i<<endl;
			break;
		}
	}
	if(i==1e3 + 1){
		cout<<-1<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define MAX_N 2000
#define MAX_M 2000
#define MAX_S 2000
vector<vector<int> > cur(MAX_N, vector<int>(MAX_N, 0)), old(MAX_N, vector<int>(MAX_N, 0)); //消去数のカウント
int main(){
	vector<int> tl;
	int xl[MAX_S + 1];
	int s, n, m;
	cin >> s >> n >> m;
	for (int i = 1; i <= s; ++i) cin >> xl[i];
	for (int i = 0; i < n; ++i) {
		int t, p;
		cin >> t >> p;
		tl.push_back(t - xl[p]);
	}
	sort(tl.begin(), tl.end());
	for (int i = 1; i < m; ++i) { //回
		for (int j = i-1; j < n; ++j) { //まで
			if (j == 0) ++j;
			for (int k = j; k < n; ++k) { //考慮範囲
				cur[j][k] = max(old[j-1][j-1] +(tl[k] - tl[j-1]) * j, cur[j-1][k]);
			}
		}
		cur.swap(old);
	}
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += tl[n-1] - tl[i];
	}
	cout << sum - old[n-1][n-1] << endl;
	return 0;
}

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

class Program
{
	static void Main()
    {
        // 文字列の入力
        var s = Console.ReadLine().ToCharArray();
        // 文字列の入力
        var t = Console.ReadLine().ToCharArray();

        Array.Sort(s);
        Array.Sort(t);
        Array.Reverse(t);

        if (new string(s).CompareTo(new string(t)) < 0) {
            Console.WriteLine("Yes");

        } else {
            Console.WriteLine("No");

        }

        //デバッグ実行での確認用。そのまま提出しても問題なし
        Console.ReadKey();
	}
}


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

using namespace std;

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

    char buf;
    string ans;
    
    while(n>0){
        if(n%26==0){
            n-=26;
            buf='z';
        }
        else buf = (char)'a' + n%26 -1;
        ans = buf + ans;
        n/=26;
    }

    std::cout << ans << std::endl;
}

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

int main()
{
    int D;

    cin >> D;
    if(D == 25) cout << "Christmas" << endl;
    if(D == 24) cout << "Christmas Eve" << endl;
    if(D == 23) cout << "Christmas Eve Eve" << endl;
    if(D == 22) cout << "Christmas Eve Eve Eve" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)
def solve(x,y,k):
    if x==y==0: return []
    if x<0: return [(-x,y) for x,y in solve(-x,y,k)]
    if y<0: return [(x,-y) for x,y in solve(x,-y,k)]
    if x>y: return [(x,y) for y,x in solve(y,x,k)]
    if (x+y)%k==0: return [(k,0)]*(x//k)+[(0,k)]*(y//k)+([]if x%k==y%k==0 else[(x%k,y%k)])
    if x+y>=2*k:
        if x%k+y%k>=k: return [(k,0)]*(x//k)+[(0,k)]*(y//k)+solve(x%k,y%k,k)
        else: return ([(k,0)]*(x//k)+[(0,k)]*(y//k))[:-1]+solve(x%k,y%k+k,k)
    if x+y<K and (x+y)%2==1: return solve(x,y+k,k)+[(0,-k)]
    if K&1 and x+y>k and (x+y)%k%2==0: return solve(x,y-k,k)+[(0,k)]
    z=(x+y)//2
    return [(k-z+x,z-x),(z-k,z)]
K,X,Y=map(int, open(0).read().split())
if K%2==0 and (X+Y)%2==1:
    print(-1)
else:
    ans=solve(X,Y,K)
    print(len(ans))
    ax,ay=0,0
    for x,y in ans:
        ax+=x
        ay+=y
        print(ax,ay)

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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

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

  int k,s; scanf("%d %d", &k, &s);
  int ans = 0;
  for(int i=0;i<=k;i++){
    if(s-i < 0) break;
    int t = max(s-k-i, 0);
    int m = min(s-i,k);
    if(t<=m) ans += m-t+1;
  }

  cout << ans;
  return 0;
}


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

 using namespace std;
 
 #define inf (INT_MAX)
 #define ninf (INT_MIN)
 #define inf64 ((1<<63)-1)
 #define ll long long
 #define mpr make_pair
 #define mtp make_tuple
 #define pb emplace_back
 #define rep(i,n) for(int i=0;i<(int)(n);i++)

 #define _tab '\t'
 #define $ <<_tab<<

 #define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
 #define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
 #define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
 #define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map

 // DEBUG
 #define deb(x) cout << #x << '\t' << x << endl

 // ==== fast function ====
 /*
 #define sortsec(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second<b.second;}
 #define sortsecgreater(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second>b.second;}
 */
 //ll middle3(ll a,ll b,ll c){if(a>b){if(b>c){return b;}else if(a>c){return c;}else{return a;}}else{if(a>c){return a;}else if(b>c){return c;}else{return b;}}}

/*========================================================================*/
/* strategi/note:



/================================*/



bool solved=0;
void solve(){solved=1;
    int n;
    cin >> n;
    int A[n];
    cinarr(A,n);
    ll ans = 0;
    // metode dari depan
    for(int i = 1; i<n; i++){
        if(A[i] < A[i-1]){
            ans += A[i-1]-A[i];
            A[i] = A[i-1];
        }
    }
    cout << ans << endl;
}

int main(){
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     //cout<<fixed<<setprecision( ); // iomanip **

	solve();
//	int t;cin>>t;while(t--){solve();}

     if(!solved)cout<<"solve() function blm dipanggil!"<<endl;
	 //cout.flush(); cin.get();
     return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  vector<ll> csum{0};
  partial_sum(va.begin(), va.end(), back_inserter(csum));

  ll ans = csum.back();
  for (int i = 0; i < n; ++i) {
    ll a = csum[i + 1];
    ll b = csum.back() - a;
    ans = min(ans, abs(a - b));
  }

  cout << ans << '\n';

  return 0;
}

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

int main() {
	int a, b, c;
	char ch;
	int rec = 0, rho = 0;
	while (cin >> a >> ch >> b >> ch >> c) {
		if (a * a + b * b == c * c)
			rec++;
		if (a == b)
			rho++;
	}
	cout << rec << endl;
	cout << rho << endl;
}


Measured memory_bytes: 3024
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int BRUTE = 4;

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

    int N;
    cin >> N;
    vector<int> A(N + 1, 0);
    vector<int> degree(N + 1, 0);
    vector<bool> done(N + 1, false);

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        degree[A[i]]++;
    }

    vector<int> B(N);
    priority_queue<int, vector<int>, greater<int>> remaining;
    priority_queue<pair<int, int>> degree_pq;

    for (int i = 1; i <= N; i++) {
        remaining.push(i);
        degree_pq.emplace(degree[i], i);
    }

    int initial = max(N - BRUTE, 0);
    int previous = 0;

    for (int i = 0; i < initial; i++) {
        while (done[degree_pq.top().second] || degree_pq.top().first != degree[degree_pq.top().second])
            degree_pq.pop();

        if (degree_pq.top().first >= N - i - 1) {
            int index = degree_pq.top().second;
            assert(!done[index]);
            B[i] = index;
        } else {
            while (done[remaining.top()])
                remaining.pop();

            int minimum = remaining.top(); remaining.pop();

            if (minimum == A[previous]) {
                while (done[remaining.top()])
                    remaining.pop();

                B[i] = remaining.top(); remaining.pop();
                remaining.push(minimum);
            } else {
                B[i] = minimum;
            }
        }

        previous = B[i];
        done[B[i]] = true;

        int reduce = A[B[i]];
        degree[reduce]--;
        degree_pq.emplace(degree[reduce], reduce);
    }

    vector<int> finish;

    while (!remaining.empty()) {
        if (!done[remaining.top()])
            finish.push_back(remaining.top());

        remaining.pop();
    }

    do {
        previous = initial == 0 ? 0 : B[initial - 1];
        bool good = true;

        for (int i = 0; i < (int) finish.size(); i++) {
            if (finish[i] == A[previous]) {
                good = false;
                break;
            }

            previous = finish[i];
        }

        if (good) {
            for (int i = initial; i < N; i++)
                B[i] = finish[i - initial];

            for (int i = 0; i < N; i++)
                cout << B[i] << (i < N - 1 ? ' ' : '\n');

            return 0;
        }
    } while (next_permutation(finish.begin(), finish.end()));

    cout << -1 << '\n';
}


Measured memory_bytes: 4204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

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

	if (a % 2 == 0 || b % 2 == 0) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}

	return 0;
}

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

     int n; cin >> n;
     vector<int> a(n);
     rep(i,n) {
         int t; cin >> t;
         a[i] = t-(i+1);
     }
     
     
     sort(a.begin(), a.end());
     int mid;
     if(n&1){
         mid = a[n/2];
     }else{
         mid = (a[n/2] + a[n/2-1])/2;
         
     }
     ll ans = 0;
     rep(i,n) {
         ans += abs(a[i] - mid);
     }
     cout << ans << endl;

    
 }


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
long long n,i,j,mod,g[3005][3005],f[3005],ans,c[3005][3005];
long long qp(long long x,long long y,long long mod)
{
	if (y==0) return 1;
	if (y==1) return x;
	long long z=qp(x,y/2,mod);
	z=z*z%mod;
	if (y&1) z=z*x%mod;
	return z;
}
int main()
{
	cin>>n>>mod;
	c[0][0]=1;
	for (i=1;i<=n;i++)
	{
		c[i][0]=1;
		for (j=1;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for (i=0;i<=n;i++)
	{
		g[i][0]=1;
		for (j=1;j<=i;j++) g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1))%mod;
	}
	for (i=0;i<=n;i++)
	{
		long long x=1,y=qp(2,n-i,mod);
		for (j=0;j<=i;j++)
		{
			(f[i]+=g[i][j]*x)%=mod;
			x=(x*y)%mod;
		}
		f[i]=f[i]*c[n][i]%mod*qp(2,qp(2,n-i,mod-1),mod)%mod;
	}
	for (i=0;i<=n;i++)
	{
		if (i&1) ans-=f[i]; else ans+=f[i];
		ans%=mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 139648
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 300005
int n, m, a[maxn], Ans, inv, ton[maxn];
il int mul(int a, int b) {
	return a * b % mod;
}
il int inc(int a, int b) {
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 0, 61) {
		ton[0] = ton[1] = 0;
		int sum = 0;
		drep(j, 1, n) ton[(a[j] >> i) & 1] ++, Ans = inc(Ans, mul((1ll << i) % mod, ton[((a[j] >> i) & 1) ^ 1]));
	}
	cout << Ans % mod ;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;
 
int main(){
    vector<int> abc(3);
    for(int i=0;i<3;i++){
        cin >> abc[i];
    }
    sort(abc.begin(), abc.end());

    if(abc[0] == abc[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();

  int nt = 0, nx = 0, ny = 0;
  for (int i = 0; i < n; ++i) {
    int t = in(), x = in(), y = in();
    int d = abs(x - nx) + abs(y - ny);

    if (d > abs(t - nt) || (d & 1) != (abs(t - nt) & 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  map<string, ll> M;
  REP(i, 0, N) {
    string s;
    cin >> s;

    if (M.find(s) != M.end()) {
      M[s]++;
    } else {
      M.emplace(s, 1);
    }
  }

  ll max = 0;
  for (const auto& m : M) {
    if (max < m.second) {
      max = m.second;
    }
  }

  for (const auto& m : M) {
    if (m.second == max) {
      cout << m.first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 23808
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int w = sc.nextInt();
    long[] weights = new long[n];
    int[] values = new int[n];
    for(int i = 0; i<n; i++) {
        weights[i] = sc.nextInt();
        values[i] = sc.nextInt();
    }
    int valueSum = 0;
    for(int i: values)
        valueSum+=i;
    long[][] dp = new long[n+1][valueSum+1];
    for(long[] i: dp)
        Arrays.fill(i, Long.MAX_VALUE);
    for(int i = 0; i<=n; i++)
        dp[i][0] = 0;
    for(int i = 1; i<=n; i++) {
        for(int j = 1; j<=valueSum; j++) {
            dp[i][j] = dp[i-1][j];
            int currValue = values[i-1];
            if(j-currValue>=0 && dp[i-1][j-currValue]!=Long.MAX_VALUE)
                dp[i][j] = Math.min(dp[i][j], dp[i-1][j-currValue]+weights[i-1]);
        }
    }
    for(int i = valueSum; i>=0; i--) {
        if(dp[n][i]<=w) {
            System.out.println(i);
            return;
        }
    }
  }
}

Measured memory_bytes: 126548
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
int nibu(vel &v, int se) {
	int up = v.size() - 1; int lo = 0;
	if (v[up] < se) { return up+1; }
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] < se) { lo = mi; }
		else { up = mi; }
	}
	return up;
}
signed main() {
	int n, k,l;
	cin >> n >> k >> l;
	vel a(n);
	for (int i = 0; i < n; i++) { cin >> a[i]; }
	int lo = 0;
	int up = n + 1;//ko[lo]<l and l<=ko[up]
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		int ko = 0;//kth ga n ikano kosuu
		vel x(n,0);
		for (int i = 0; i < n; i++) {if (a[i] <= mi) { x[i] = 1; }}
		vel sx(n+1, 0);
		for (int i = 1; i <= n; i++) { sx[i] = sx[i - 1] + x[i - 1]; }
		for (int i = 0; i < n; i++) { 
			ko += n+1 - nibu(sx, sx[i] + k); 
		}
		if (l <= ko) { up = mi; }
		if (ko < l) { lo = mi; }
	}
	cout << up << endl;
	return 0;
}



Measured memory_bytes: 7504
from collections import deque

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    l, r, d = map(int, input().split())
    graph[l - 1].append([r - 1, d])
    graph[r - 1].append([l - 1, -d])
X = [None] * N


def bfs(u):
    que = deque([(u, 0)])
    X[u] = 0
    while que:
        u, x = que.popleft()
        for nu, add in graph[u]:
            nx = x + add
            if X[nu] == nx:
                continue
            if X[nu] is not None and X[nu] != nx:
                print('No')
                exit()
            X[nu] = nx
            que.append((nu, nx))


for i in range(N):
    if X[i] is None:
        bfs(i)
print('Yes')


Measured memory_bytes: 83168
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}
//cout << fixed << setprecision(10);

int main(){
  ll n; cin>>n;
  string s,t; cin>>s>>t;
  rep(i,n){
  cout<<s[i]<<t[i];
  }
  
}

Measured memory_bytes: 256
horizontalLineList = []

while True:
    # 縦線の本数，横線の本数，調べる縦線の番号
    n, m, a = list(map(int, input().split()))

    if n == m == a == 0:
        break

    # 現在の縦線位置
    current = a

    horizontalLineList.clear()
    for _ in range(m):
        # hはその横線の高さ。
        # p, qはその横線につながっている2本の縦線の番号
        h, p, q = list(map(int, input().split()))

        horizontalLineList.append([h, p, q])

    # 横線の高さを昇順ソート
    horizontalLineList.sort(key=lambda x: x[0])

    targetHeight = 1000 + 1
    moved = False
    while horizontalLineList:
        h, p, q = horizontalLineList.pop()

        if (targetHeight == h) and moved:
            continue
        elif targetHeight != h:
            targetHeight = h
            moved = False
        
        if p == current:
            current = q
            moved = True
        elif q == current:
            current = p
            moved = True

    print(current)


Measured memory_bytes: 5620
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n;
  int ans = 0;
  int same = 0;
  long int  x[51], y[51];
  int p, q;

  scanf("%d", &n);

  for(int i = 1; i <= n; i++){
    scanf("%ld%ld", &x[i], &y[i]);
  }
  
  ans = n;
  if(n > 1){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
	// p,qの全パターンを出す
	// （p, qの値が同じパターンもあるかもだが気にしない）
	if(i != j){
	  p = x[i] - x[j];
	  q = y[i] - y[j];
	}
	same = 0;
	for(int k = 1; k <= n; k++){
	  for(int l = 1; l <= n; l++){
	    // p, qで取れるものがあるか確認
	    if(k != l){
	      if(p == (x[k] - x[l]) && q == (y[k] - y[l])){
		same++;
	      }
	    }
	  }
	}
	if(ans > (n - same)){
	  ans = (n - same);
	}
      }
    }
  }
  /*
 // 数値を降順にソート
  for (int i=0; i< n*2-1; i++) {
    for (int j=i+1; j<n*2; j++) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
*/

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,6)if(s[i]=='1')ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            500001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

string alph = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string rev = alph;
    reverse(All(rev));
    string s;
    cin >> s;
    int n = s.size();
    if(n == 26){
        if(s == rev){
            cout << "-1\n";
            return 0;
        }
        string temp = s;
        next_permutation(All(temp));
        for(int i=0;i<26;++i){
            if(s[i] != temp[i]){
                cout << temp[i] << endl;
                return 0;
            }else{
                cout << temp[i];
            }
        }
        return 0;
    }
    bool in_s[26];
    memset(in_s, 0, sizeof(in_s));
    char ans = 'a';
    for(char c : s){
        in_s[c - 'a'] = true;
    }
    for(char c : alph){
        if(!in_s[c - 'a']){
            ans = c;
            break;
        }
    }
    cout << s + ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int m = max(A, C);
	int M = min(B, D);
	int ans = M - m;
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
}

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

int main(){
  int n,m;cin>>n>>m;
  vector<string> a(n),b(m);
  rep(i,n)cin>>a[i];rep(i,m)cin>>b[i];
  string ans="No";
  rep(i,n-m+1){
    rep(j,n-m+1){
      int ok=0;
      rep(k,m){
        if(a[i+k].substr(j,m)==b[k])ok++;
      }
      if(ok==m){ans="Yes";break;}
    }
  }
  cout<<ans;  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b&&b>(a+w)){
		cout<<abs(b-(a+w));
	}else if(a>b){
		cout<<abs(a-(b+w));
	}else if(a<=b<=(a+w)){
		cout<<"0";
	}
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=10007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<int>A(n);
	int one=1;
	for(i=0;i<n;i++){cin>>A[i];
		if(i>0&&A[i-1]>=A[i]){one=0;}
	}
	if(one){cout<<1<<endl;return 0;}
	int bmax=n,bmin=1;
	while(bmax-bmin>1){
		int bgen=(bmax+bmin)/2;
		map<int,int>str;
		str[-999999]=-1;//晩兵
		int nga=0;
		bool can=1;
		for(i=0;i<n;i++){
			if(nga>=A[i]){
				str[A[i]]++;
				int bas=A[i];
				while(str[bas]>=bgen){
					str[bas]=0;
					str[bas-1]++;
					bas--;
					if(bas<=0){can=0;break;}
				}
			}
			nga=A[i];
			while(prev(str.end())->fir>nga){str.erase(prev(str.end()));}
		}
		if(can){bmax=bgen;}else{bmin=bgen;}
	}
	cout<<bmax<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, k;
string s;
 
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	cin >> n >> k >> s;

	s[k - 1] = (s[k - 1] - 'A' + 'a');

	cout << s;
       
    return 0;                                        
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String S=sc.next();
		boolean f=true;
		for(int i=0;i<S.length()/2;i++) {
			if(S.charAt(i)!=S.charAt(S.length()-i-1)) {
				f=false;
				break;
			}
		}
		for(int i=0;i<S.length()/4;i++) {
			if(S.charAt(i)!=S.charAt(S.length()/2-i-1)) {
				f=false;
				break;
			}
		}
		System.out.println(f?"Yes":"No");
	}
}

Measured memory_bytes: 35792