akhauriyash/Code-Regression huggingface dataset:
S=input()
akh=list("AKIHABARA")
lis=[]
a=[0,4,6,8]
for i in range(16):
    akh=list("AKIHABARA")
    for j in range(4):
        if (i>>j) & 1:
            akh[a[j]]=""
    lis.append("".join(akh))
if S in lis:print("YES")
else:print("NO")

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

int main(){
    long long a,b;
    cin>>a;
    long long d=0;
    long long e=1e9;
    for(long long i=0;i<a;i++){
        cin>>b;
        d=max(b,d);
        e=min(b,e);
    }
    cout<<d-e;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i = 0;i<n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    for(int i=1; i<n; i++){
        int v = a[i];
        for(int j=i-1; j>=0; j--){
            if(v>=a[j]){
                break;
            }else{
                a[j+1] = a[j];
                a[j] = v;
            }
        }
        for(int j=0;j<n-1;j++){
            cout << a[j] << " ";
        }
        cout << a[n-1] << endl;
    }
    return 0;
}


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

	int n;

	cin >> n;

	int f[44];
	f[0] = 1; f[1] = 1;

	for (int i = 2; i <= n; i++){
		f[i] = f[i - 1] + f[i - 2];
	}

	cout << f[n] << endl;

}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void) {
	int goukei;
	int hitotu;
	int i;
	while(1) {
		scanf("%d",&goukei);
		if(goukei==0)break;
		for(i=0;i<9;i++) {
			scanf("%d",&hitotu);
			goukei-=hitotu;
		}
		printf("%d\n",goukei);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
	public  static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int k = scan.nextInt();
      	String s = scan.next();
      	System.out.print(s.substring(0, k-1));
      	if(s.substring(k-1, k).contains("A")){
        	System.out.print("a");
        }
      	else if(s.substring(k-1, k).contains("B")){
        	System.out.print("b");
        }
        else if(s.substring(k-1, k).contains("C")){
        	System.out.print("c");
        }
      	System.out.print(s.substring(k, n));
    }
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

#define YES cout<<"YES"<<ln
#define Yes cout<<"Yes"<<ln
#define NO cout<<"NO"<<ln
#define No cout<<"No"<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int main() {
	int a, b;
	cin >> a >> b;
	int ans = (a+b)/2;
	if ((a+b)%2==1) ans++;
	cout << ans << ln;
}

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

using namespace std;

typedef long long int lli;

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

    int N, W, V = 0;
    lli v[101], w[101];
    vector<vector<lli>> dp(101, vector<lli>(100001, -1));

    cin >> N >> W;
    for (int i=0; i<N; i++) {
        cin >> w[i+1] >> v[i+1];
        V += v[i+1];
    }

    dp[0][0] = W;
    for (int i=1; i<=N; i++) {
        for (int j=0; j<=V; j++) {
            if (j-v[i] < 0) {
                dp[i][j] = dp[i-1][j];
                continue;
            }
            
            dp[i][j] = max(dp[i-1][j-v[i]] - w[i], dp[i-1][j]);
        }
    }

    lli ans = -1;
    for (int i=0; i<=V; i++) ans = (dp[N][i] >= 0) ? i : ans;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
 
int main()
{
  int n, a;
  cin >> n;
  //10～99
  if (n >= 10 && n < 100){
    a = n/10;
    n = n-a*10;
  //100～999
  }else if (n >= 100){
    a = n/10;
    n = n-a*10;
  }
 
  if (n == 3){
       cout << "bon" << endl;
  }else if(n == 0 || n == 1 || n == 6 || n == 8){
       cout << "pon" << endl;
  }else{ 
    cout << "hon" << endl;
  }
  return 0;
}
  


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    bool p = s[0] == 'R';
    bool q = s[1] == 'R';
    bool r = s[2] == 'R';
    if(p and q and r) cout<<3<<endl;
    else if((p and q) or (q and r)) cout<<2<<endl;
    else if(p  or q or r) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}  


Measured memory_bytes: 3608
import java.util.Scanner;

class Main{

public static void main(String [] args){

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();

if(a < c){
    
    if(a < b){
         if(b < c){
         
         System.out.println(a + " " + b + " " + c);

         }else{
         System.out.println(a + " " + c + " " + b);
         }

    }else{
    
         System.out.println(b + " " + a + " " + c);
    }
}else{
     
    if(c < b){
         if(a < b){
              System.out.println(c + " " + a + " " + b);
         }else{
              System.out.println(c + " " + b + " " + a);
         }
    }else{
              System.out.println(b + " " + c + " " + a);

    }
}





}
}



Measured memory_bytes: 26148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  int res1=0, res2=0;
  for (int i=0; i < n; i++) {
    if (i % 2 == 0) {
      res1 += vec[i];
    }
    else {
      res2 += vec[i];
    }
   }
  cout << abs(res1 - res2) << endl;
}

Measured memory_bytes: 3488
import kotlin.math.min

fun main(args:Array<String>){
    val k = readLine()!!.toInt()
    var result = 0
    for(a in 1..k){
        for(b in 1..k){
            for(c in 1..k){
                val m = min(a,min(b,c))
                var sum = 0
                var start = 1
                if(a%2==0&&b%2==0&&c%2==0){
                    start *= 2
                }
                if(a%3==0&&b%3==0&&c%3==0){
                    start *= 3
                }
                if(a%5==0&&b%5==0&&c%5==0){
                    start *= 5
                }
                if(a%7==0&&b%7==0&&c%7==0){
                    start *= 7
                }
                for(i in start..m step start){
                    if(a%i==0&&b%i==0&&c%i==0){
                        sum =i
                    }
                }
                result += sum
            }
        }
    }
    println(result)
}

Measured memory_bytes: 51588
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w,a,b;
  cin>>h>>w>>a>>b;
  auto NO=[](){
            cout<<"NO"<<endl;
            exit(0);
          };
  
  if(h*w<2*(a+b)) NO();
  vector<string> s(h,string(w,'.'));

  if(h==1&&b>0) NO();
  if(w==1&&a>0) NO();
  
  if(h&1){
    for(Int j=0;j+1<w;j+=2){
      if(a==0) break;
      s[0][j]='<';
      s[0][j+1]='>';
      a--;
    }
  }

  if(w&1){
    for(Int i=0;i+1<h;i+=2){
      if(b==0) break;
      s[i][w-1]='^';
      s[i+1][w-1]='v';
      b--;
    }
  }
  
  if(!a&&!b){
    cout<<"YES"<<endl;
    for(Int i=0;i<h;i++) cout<<s[i]<<endl;
    return 0;
  }

  if((h&1)&&(w&1)){
    assert(h>=3&&w>=3);
    assert(a>=0&&b>=0);
    if(a&1){
      s[h-1][w-2]='<';
      s[h-1][w-1]='>';
      a--;
    }
    if(b&1){
      s[h-2][w-3]='^';
      s[h-1][w-3]='v';
      b--;
    }
  }

  for(Int i=(h&1);i+1<h;i+=2){
    for(Int j=0;j+1<w;j+=2){
      if(a>0||b>0){
        if(s[i][j]!='.') NO();
        if(s[i][j+1]!='.') NO();
        if(s[i+1][j]!='.') NO();
        if(s[i+1][j+1]!='.') NO();
      }
      if(a>0){
        if(a>0){s[i][j]='<';s[i][j+1]='>';a--;}
        if(a>0){s[i+1][j]='<';s[i+1][j+1]='>';a--;}  
      }else if(b>0){        
        if(b>0){s[i][j]='^';s[i+1][j]='v';b--;}
        if(b>0){s[i][j+1]='^';s[i+1][j+1]='v';b--;}
      }
    }    
  }
  if(a||b) NO();
  cout<<"YES"<<endl;
  for(Int i=0;i<h;i++) cout<<s[i]<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, x, y;
    cin >> n >> x >> y;
    vi k(n);
    REP1(i, n - 1) {
        FOR(j, i + 1, n + 1) {
            k[min({j - i, abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j)})]++;
        }
    }
    REP1(i, n - 1) cout << k[i] << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s.Length;i++) {
			if(s[i]=='?'){
				sb.Append('D');
			}
			else{
				sb.Append(s[i]);
			}
		}
		Console.WriteLine(sb);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27480
import sys
L = [el for el in map(int,input().split())]
A = L[0]
B = L[1]
C = L[2]
D = L[3]
while True:
    C-=B
    if C <= 0:
        print('Yes')
        sys.exit(0)
    A-=D
    if A <= 0:
        print('No')
        sys.exit(0)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
#define pf push_front
#define FOR(i, m, n) for(int i=n;i<(n);i++)
#define rep(i,n) FOR(i, 0, n)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl;

int main(){
    int H,W,h,w;
    cin >> H >> W;
    cin >> h >> w;

    cout << (H-h) * (W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

#+++++
		
def main():
	t1, t2 = map(int, input().split())
	a1, a2 = map(int, input().split())
	b1, b2 = map(int, input().split())
	
	a_d = t1*a1 + t2 * a2
	b_d = t1*b1 + t2 * b2
	
	if a_d == b_d:
		return 'infinity'
	
	pp=a_d-b_d
	pc=t1*(a1-b1)
	if pp*pc > 0:
		return 0
	
	#pa((pp,pc))

		
	return (2 * (-pc // pp) + 1) -(1 if pc % pp == 0 else 0)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 524288
#define P 200003

static_assert(__builtin_popcount(N) == 1);
#define PRIME ((3u<<30)+1)
#define OMEGA (ntt_pow(5,PRIME/N))
constexpr uint ntt_pow(uint a, uint b)
{
    return !b ? 1 : (ulli)ntt_pow((ulli)a*a % PRIME, b>>1) * (b&1?a:1) % PRIME;
}
void ntt_rec(uint *a, int n, uint w)
{
    if(n==1) return;
    int n2 = n/2;
    uint w2 = ntt_pow(w,2);
    ntt_rec(a,n2,w2);
    ntt_rec(a+n2,n2,w2);
    uint k = 1;
    for(int i=0,j=n2;i<n2;++i,++j,k = (ulli)k * w % PRIME)
    {
        uint e = a[i], o = a[j];
        a[i] = ( e + (ulli)o*k ) % PRIME;
        a[j] = ( e + (ulli)PRIME*PRIME - (ulli)o*k ) % PRIME;
    }
}
uint ntt_bitreverse32(uint k)
{
    k = __builtin_bswap32(k);
    k = (((k & 0xf0f0f0f0) >> 4) | ((k & 0x0f0f0f0f) << 4));
    k = (((k & 0xcccccccc) >> 2) | ((k & 0x33333333) << 2));
    k = (((k & 0xaaaaaaaa) >> 1) | ((k & 0x55555555) << 1));
    return k;
}
void ntt(uint *a, int n=N, uint w=OMEGA)
{
    for(int i=0;i<n;++i)
    {
        int ii = ntt_bitreverse32(i) >> __builtin_clz(n)+1;
        if(i<ii) std::swap(a[i],a[ii]);
    }
    ntt_rec(a,n,w);
}
void ntt_inv(uint *a)
{
    ntt(a,N,ntt_pow(OMEGA,PRIME-2));
    for(int i=0;i<N;++i) a[i] = (ulli)a[i] * ntt_pow(N,PRIME-2) % PRIME;
}

int po[N], lo[N];
uint a[N], b[N];

int main()
{
    for(int i=0, k=1; i<P-1; ++i, k=k*2%P)
        po[i] = k, lo[k] = i;
    int n;
    lli ans = 0;
    scanf("%d", &n);
    for(int i=0;i<n;++i)
    {
        int k;
        scanf("%d", &k);
        if(!k) continue;
        ++a[lo[k]];
        ans -= (lli)k*k % P;
    }
    for(int i=0;i<N;++i) b[i] = a[i] % 13;
    ntt(a);
    for(int i=0;i<N;++i) a[i] = (ulli)a[i] * a[i] % PRIME;
    ntt_inv(a);
    ntt(b);
    for(int i=0;i<N;++i) b[i] = (ulli)b[i] * b[i] % PRIME;
    ntt_inv(b);
    for(int i=0;i<N;++i)
    {
        ans += po[i%(P-1)] * (a[i] + (lli)(b[i]+(PRIME+2)-a[i])*6%13 * PRIME);
        static_assert(((lli)PRIME*6) % 13 == 1);
        static_assert((PRIME+2) % 13 ==0);
    }
    assert(ans%2==0);
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 7392
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

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

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,w,k,ans = INF;
	string field[15];
	cin >> h >> w >> k;
	for(int i = 0;i < h;i++) cin >> field[i];
	for(int i = 0;i < (1 << (h - 1));i++){
		int cnt[15] = {},cut = 0;
		for(int j = 0;j < w;j++){
			bool isOver = false,isNG = false;
			int sum = 0,sumc = 0;
			for(int l = 0;l < h;l++){
				cnt[l] += field[l][j] - '0';
				sum += cnt[l];
				sumc += field[l][j] - '0';
				if(sumc > k) isNG = true;
				if(sum > k) isOver = true;
				if(l != h - 1 && (i >> l & 1)) sum = 0,sumc = 0;
			}
			if(isOver){
				cut++;
				for(int l = 0;l < h;l++) cnt[l] = field[l][j] - '0';
			}
			if(isNG){
				cut = INF;
				break;
			}
		}
		chmin(ans,cut + __builtin_popcountll(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
const ll ddx[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const ll ddy[8]={ 1, 0,-1, 0, 1,-1, 1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl cnt(n+1,0);
    vl v(n);
    rep(i,n){
        cin >>v[i];
        cnt[v[i]]++;
    }
    vl macnt(n+1,0);
    rep(i,n+1){
        if(cnt[i]!=0)macnt[i]=cnt[i]*(cnt[i]-1)/2;
    }
    vl micnt(n+1,0);
    rep(i,n+1){
        if(cnt[i]>1)micnt[i]=(cnt[i]-1)*(cnt[i]-2)/2;
    }
    ll x=0;
    rep(i,n+1)x+=macnt[i];
    rep(i,n){
        cout << x-macnt[v[i]]+micnt[v[i]] <<endl;
    }
}


Measured memory_bytes: 8832
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    String[] w = str.split("");
    int[] cnt = new int[100];
    boolean flg = true;
    for(int i=0; i<str.length(); i++) {
      cnt[(int)w[i].charAt(0)-97]++;
    }
    
    for(int i=0; i<100; i++) {
      if(cnt[i]%2!=0) {
        System.out.println("No");
        flg = false;
        break;
      }
    }
    if(flg==true)
      System.out.println("Yes");
  }
}

Measured memory_bytes: 32992
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
vector<int> a;
int b =0;
 
do
{
	cin >>b;
	a.push_back(b);
}while(b != 0);

for(int i=1; a[i-1] != 0; ++i)
{
	cout <<"Case " <<i <<": " <<a[i-1] <<endl;
}
 
return 0;
}

Measured memory_bytes: 3124
#include <iostream>

#define MAX_N 100

using namespace std;

int n;
int numbers[MAX_N];

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

	for (int k = 0; k < n; k ++) if (k != n - 1)cout << numbers[k] << " "; else cout << numbers[k];
	cout << endl;
	for (int i = 1; i < n; i ++) {
		int v = numbers[i];
		int j = i - 1;
		while (j >= 0 && numbers[j] > v) {
			numbers[j + 1] = numbers[j];
			j --;
		}
		numbers[j + 1] = v;

		for (int k = 0; k < n; k ++) if (k != n - 1)cout << numbers[k] << " "; else cout << numbers[k];
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 3088
def main():
    n, m = map(int, input().split())
    P = [0] * m
    S = [0] * m
    for i in range(m):
        P[i], S[i] = map(str , input().split())
    # p = [int(s) for s in p]
    # 問題によってカウントしたい
    WA = [0] * (n+1)
    # 全体として何個かがわかればいい
    AC = [False] * (n+1)
    wa = 0
    for i in range(m):
        p = int(P[i])
        if AC[p]:
            continue
        else:
            if S[i] == 'WA':
                WA[p] += 1
            else:
                AC[p] = True
                wa += WA[p]
    # なぜか都度足さないとWAを間違えている？
    # wa = sum(WA)
    ac = sum(AC)
    print(ac, wa)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 24668
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = inf;
    rep(i,max(x,y)+1) {
        int now = 0;
        now += i*2*c;
        now += max(0,x-i)*a;
        now += max(0,y-i)*b;
        chmin(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n+1);
    rep(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    ll sum=0;
    rep(i,n+1)
        if(b[i]>=2) sum+=b[i]*(b[i]-1)/2;
    rep(i,n){
        if(b[a[i]]<2) cout<<sum<<endl;
        else cout<<sum-(b[a[i]]-1)<<endl;
    }
}

Measured memory_bytes: 6428
Module Program
  Sub Main
    Dim s=GetInts()
    Dim x=s(0)+s(1)
    Dim ans=If(x>9,"error",x)
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ct=1,tot=0;
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1]){
            ct++;
        }
        else{
            int ad = ct/2;
            tot += ad;
            ct = 1;
        }
    }
    tot += ct/2;
    cout<<tot;
    return 0;
}


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

int N,M;
int cnt[55];

int main(){

cin>>N>>M;

for(int i=0; i<M; i++){
    int a,b; scanf("%d %d",&a,&b);
    cnt[a]++; cnt[b]++;
}

for(int i=1; i<=N; i++) cout<<cnt[i]<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t;
	cin>>n>>t;
	long long ans=0;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i>0)
		{
			int d=a[i]-a[i-1];
			if(d>=t)
				ans+=t;
			else
				ans+=d;
		}
	}
	ans+=t;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3992
#include <iostream>
using namespace std;
int main(void){
    int ans=1000;
    string s;
    cin >> s;
    for(int i=2;i<s.size();i++){
        int tmp=(s[i-2]-'0')*100+(s[i-1]-'0')*10+s[i]-'0';
        if(ans>abs(tmp-753)) ans = abs(tmp-753);
    }
    cout << ans;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,ans=1;
  cin>>n;
  string s;
  cin>>s;
  rep(i,n-1){
    if(s[i]!=s[i+1]) ans++;
  }
  cout<<ans<<endl;
}
///////////////////////////


Measured memory_bytes: 512
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n,m = map(int, input().split())
    ans = [0]*n

    for i in range(m):
        s,c = map(int, input().split())
        if n > 1 and s-1 == 0 and c == 0: # 2桁以上先頭0
            print(-1)
            exit()
        if ans[s-1] in [0,c]: # 入力なし、もしくは矛盾なし
            ans[s-1] = c
        else: # 同じ桁に別の条件
            print(-1)
            exit()
    if n > 1 and ans[0] == 0:
        ans[0] = 1
    print(int("".join(map(str,ans))))


if __name__=="__main__":
    main()


Measured memory_bytes: 62152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
ll dp[2000000];
int main()
{
    string s;
    cin>>s;
    ll n=s.length(),i;
    if(s[n-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
        cout<<s<<"s"<<endl;
    



}


Measured memory_bytes: 3596
#include <stdio.h>
int Node[16][16];

int main(){

	int a,b;
	int n;
	int x,y;
	int i,j;

	while(1){
		scanf("%d %d\n",&a,&b);
		if(a==0 && b==0 )break;
		for(i=0;i<16;i++){
			for(j=0;j<16;j++){
				Node[i][j]=-1;
			}
		}
//		for(i=0;i<a;i++){
//			Node[i][0]=1;
//		}
//		for(j=0;j<b;j++){
//			Node[0][j]=1;
//		}

		Node[0][0]=1;
		scanf("%d\n",&n);
		for(i=0;i<n;i++){
			scanf("%d %d\n",&x,&y);
			Node[x-1][y-1]=0;
		}

		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				if(Node[i][j]<0){
					if(i==0)Node[i][j]=Node[i][j-1];
					if(j==0)Node[i][j]=Node[i-1][j];
					if(i*j!=0)Node[i][j]=Node[i-1][j]+Node[i][j-1];
				}
			}
		}

		printf("%d\n",Node[a-1][b-1]);

	}

	return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	vector<ll> v(10, 0);

	REP(i, 4) {
		cin >> n;
		v[n]++;
	}

	if (v[1] == 1 && v[9] == 1 && v[7] == 1 && v[4] == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
A = [[] for i in range(N)]
for i in range(N):
        s, p = input().split()
        A[i] = [s, int(p)] + [i]

A.sort(key=lambda x: x[0])


idx = 0
while idx < N:
        city = A[idx][0]
        num = 0
        while idx + num < N and A[idx+num][0] == city:
                num += 1
        B = A[idx:idx+num]
        B.sort(key=lambda x: x[1])
        
        for val in range(num):
                print(B[num-val-1][2] + 1)
        idx += num


Measured memory_bytes: 3064
n = int(input())
a = input().split()
mi = abs(int(a[0]))
ans =  0 
count = 0
for i in range(n):
    ans = ans + abs(int(a[i]))
    if mi > abs(int(a[i])):
        mi = abs(int(a[i]))
    if int(a[i])<0:
        count = count + 1
if count%2 ==0:
    print(ans)
else:
    print(ans-2*mi)


Measured memory_bytes: 11212
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,sum,tot;
int main () {
	cin >> a >> b >> c >> d;
	sum = a*b;
	tot = c*d;
	if (sum>tot) {
		cout << sum << endl;
	} else if (sum<tot) {
		cout << tot << endl;
	} else {
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
x,y = map(int,input().split())
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
if 1/2 <= y/x <= 2 and (x+y)/3 % 1 == 0:
    yy = int((x+y)/3)
    u = int(y - yy)
    r = int(yy - u)
    print(comb(yy,r)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    set<int> paper;

    rep(i, n){
        if (paper.find(a[i])==paper.end()){
            paper.insert(a[i]);
        } else {
            paper.erase(a[i]);
        }
    }

    cout << paper.size() << endl;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var N = input[0];
            var X = input[1];
            var T = input[2];

            var ans = Math.Ceiling(N / X) * T;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28316
import java.util.*;

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int stones[] = new int[n+1];
        int dp[] = new int[n+1];
        for(int i = 1 ; i <= n ; i++ ){
            stones[i] = scanner.nextInt();
        }
        System.out.println(solve(stones,dp , n));

    }
    public static int solve(int[] stones , int[] dp , int n ){
        if(n <=1){
            return 0;
        }
        for(int j = 2 ; j<= n ; j++) {
            int opt1 = Math.abs(stones[j] - stones[j-1]) + dp[j-1];
            int opt2= 0;
            if(j == 2){
                opt2 = Integer.MAX_VALUE;
            }else{
                opt2 = Math.abs(stones[j] - stones[j-2]) + dp[j - 2];
            }
            dp[j] = Math.min(opt1, opt2);

        }
        return dp[n];
    }

}


Measured memory_bytes: 51172
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
const int N = 1e5+2;
int f[N];
int k;
void dfs(int nd,int pr,vector<vector<pair<int,int>>>& tr,int al){
  k = max(k,(int)tr[nd].size());
  int st = 1;
  for(auto it:tr[nd]){
    if(it.first==pr) continue;
    if(st==al) st++;
    f[it.second] = st;
    dfs(it.first,nd,tr,st);
    st++;
  }
  return ;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n;cin >> n;
  vector<vector<pair<int,int>>> tr(n+1);
  for(int i=0;i<=n-2;i++){
    int x,y;cin >> x >> y;
    tr[x].push_back({y,i});
    tr[y].push_back({x,i});
  }
  dfs(1,0,tr,0);
  cout << k << endl;
  for(int i=0;i<n-1;i++) cout << f[i] << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
	int n, m; cin >> n >> m;
	priority_queue<int>a; 
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a.push(tmp);
	}
	
	for (int i = 0; i < m; i++) {
		int tmp = a.top(); a.pop();
		tmp /= 2;
		a.push(tmp);
	}

	long long ans = 0;
	while (a.size() != 0) {
		ans += a.top(); a.pop();
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
s = gets.to_s.chomp
case s
when 'SUN'
  puts 7
when 'MON'
  puts 6
when 'TUE'
  puts 5
when 'WED'
  puts 4
when 'THU'
  puts 3
when 'FRI'
  puts 2
else
  puts 1
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9+7;
typedef pair<int,int> ii;
main(){
    int n;
    cin >> n;
    ii arr[n+1];
    for (int i = 1; i <= n; i++) cin >> arr[i].second >> arr[i].first;
    sort(arr+1,arr+n+1);
    ii interval[n+2];
    ii temp[n+1];
    for (int i = 1; i <= n; i++) temp[i] = ii(arr[i].second,i);
    sort(temp+1,temp+n+1);
    int premax[n+1];
    premax[0] = 0;
    for (int i = 1; i <= n; i++) premax[i] = max(premax[i-1],temp[i].second);
    int sufmin[n+1];
    sufmin[n] = temp[n].second;
    for (int i = n-1; i >= 0; i--) sufmin[i] = min(sufmin[i+1],temp[i].second);
    for (int i = 1; i <= n; i++){
        int pos = upper_bound(temp+1,temp+n+1,ii(arr[i].second,-1))-temp;
        interval[i].first = sufmin[pos];
        interval[i].second = premax[pos];
    }
    interval[n+1] = ii(n+1,n+1);
    interval[0] = ii(0,0);
    sort(interval,interval+n+2);
    int dp[n+2];
    dp[0] = 1;
    int pre = 1,l = 0;
    //for (int i = 0; i <= n+1; i++) cout << interval[i].first << " " << interval[i].second << "\n";
    for (int i = 1; i < n+2; i++){
        while (interval[l].second < interval[i].first-1) pre = (pre+MOD-dp[l++])%MOD;
        dp[i] = pre;
        pre = (pre+dp[i])%MOD;
        //cout << dp[i] << "hi\n";
    }
    cout << dp[n+1];
}


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

int n;
int main(){    
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i<n;i++){
        cin >> v[i];
    }
    ll ans = 0;
    for(int i = 1;i<n;i++){
        if(v[i]>=v[i-1]) continue;
        else{
            ans += v[i-1] - v[i];
            v[i] = v[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4044
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();
        if(W>=S)
        {
            System.out.println("unsafe");
        }
        else
        {
            System.out.println("safe");
        }
    }
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define ll long long
ll x,y,z,k;
int main()
{
	scanf("%lld%lld%lld%lld",&x,&y,&z,&k);
	if ((x-y)>(ll)(1e18) || (x-y)<-(ll)(1e18)) printf("Unfair");
		else if (k&1LL) printf("%lld",y-x);
			else printf("%lld",x-y);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
	
		if(a<b){
			if(b<c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17352
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    var ans = 0L
    
    var l = 0
    var r = s.size - 1
    
    while (r > l) {
        if (l == r) {
            break
        }
        if (s[l] == s[r]) {
            l++
            r--
            continue
        }
        if (s[l] != 'x' && s[r] != 'x') {
            println(-1)
            return
        }
        ans++
        if (s[l] == 'x') {
            l++
        } else {
            r--
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 34096
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
int main()
{
    jaldi
    #ifndef _DEBUG 
    //TakeInput
    #endif
    ll n,i,j,k;
    cin>>n;
    ll a[n];
    in(i,n){
        cin>>a[i];
    }   
    ll dp[n];
    in0(dp);
    dp[1]=abs(a[1]-a[0]);

    fon(i,2,n){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
    

    
}
 
 








 

Measured memory_bytes: 1792
alpha2num = lambda c: ord(c) - ord('a') + 1

S = list(input())
T = list(input())

s = S.copy()
t = T.copy()

S_count = [0] * 27
T_count = [0] * 27

for i in range(len(S)):
   S_count[alpha2num(S[i])] += 1
   T_count[alpha2num(T[i])] += 1

S_count.sort()
T_count.sort()

if S_count == T_count:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 9648
#include <iostream>
#include <vector>
#include <climits>
#define FIN freopen("inputs.txt", "r", stdin)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
double expectation(int n){
    double ans = (1 + n)/2.0; return ans;
}
int main(){
    // FIN;
    int n, k; cin>>n>>k;
    vector<int> v;
    v.resize(n);
    for(auto &i : v) cin>>i;
    double ans = 1e-37,tmp = 0.0;
    for (int i = 0; i <= n-k; i++)
    {
        if(i==0){
        for (int j = 0; j < k; j++)
            tmp += expectation(v[i+j]);
        }
        else{
            tmp = tmp - expectation(v[i-1]) + expectation(v[i+k-1]);
        }
        ans = tmp>ans?tmp:ans;
    }
    printf("%0.17f", ans);
    return 0;
}

Measured memory_bytes: 1024
import heapq
N,M=map(int,input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x * (-1), a))  # 各要素を-1倍
heapq.heapify(a)  # リストを優先度付きキューへ
for _ in range(M):
    number=heapq.heappop(a)  # 最大値の取り出し
    if number%2==0:
        number=number//2
    else:
        number=number//2+1
    heapq.heappush(a, number)  # 要素の挿入
print(-sum(a))


Measured memory_bytes: 92224
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2.0 << " " << (2 * x == W && 2 * y == H) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VV = vector<vector<ll> >;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct UnionFind{
    vector<ll> parent;
    UnionFind(ll sz){
        parent.resize(sz);
        reset();
    }

    void reset(){
        FOR(i, 0, parent.size()){
            parent[i] = i;
        }
    }

    void unite(ll a, ll b){
        if(a>b){
            swap(a, b);
        }
        ll rootA = findRoot(a);
        ll rootB = findRoot(b);
        if(rootA>rootB){
            swap(rootA, rootB);
        }
        if(rootA==rootB){
            return;
        }else{
            // 小さい方を親にする
            parent[rootB] = rootA;
        }
    }

    ll findRoot(ll a){
        if(parent[a]==a){
            return a;
        }else{
            return parent[a] = findRoot(parent[a]);
        }
    }

    map<ll, vector<ll> > getGroups(){
        map<ll, vector<ll> > G;
        FOR(i, 0, parent.size()){
            ll r = findRoot(i);
            G[r].push_back(i);
        }
        return G;
    }

    bool is_same_group(ll a, ll b){
        ll rootA = findRoot(a);
        ll rootB = findRoot(b);
        if(rootA==rootB){
            return true;
        }else{
            return false;
        }
    }
};

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

    // input
    ll N, M;
    cin >> N >> M;

    VV G(M);

    FOR(i, 0, N){
        ll K;
        cin >> K;

        FOR(j, 0, K){
            ll L;
            cin >> L;
            L--;

            G[L].push_back(i);
        }
    }

    auto uf = UnionFind(N);
    FOR(lang, 0, M){
        if(G[lang].size()>1){
            FOR(i, 0, G[lang].size()-1){
                ll human0 = G[lang][i];
                ll human1 = G[lang][i+1];
                uf.unite(human0, human1);
            }
        }
    }

    auto groups = uf.getGroups();
    if(groups.size()==1){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 5748
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int N;
	int A[100002];

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


	long long total = 0;
	for (int i = 0; i <= N; i++) {
		total = total + abs(A[i] - A[i + 1]);
	}

	for (int i = 0; i < N; i++) {
		long long Ans = total - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2]);
		cout << Ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
// let coding = begin

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;
const int MAX = 1e9 + 9;
const int MIN = -1e9;
const int N = (1e5 + 9) * 2 + 9;
const double PI = 3.14159265;

int tab[5];
int k;
int main()
{
  clock_t start;
  for (int i = 0; i < 5; i++)
  {
    cin >> tab[i];
  }
  int ans = MAX;
  do
  {
    int sum = 0;
    for (int i = 0; i < 5; i++)
    {
      if (sum % 10 == 0)
      {
        sum += tab[i];
      }
      else
      {
        int s = 10 - (sum % 10);
        sum += s;
        sum += (tab[i]);
      }
    }
    if (sum < ans)
      ans = sum;
  } while (next_permutation(tab, tab + 5));
  cout << ans << endl;
  cerr << "Time: " << (clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << endl;
  return 0;
}

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

ans=0
if n>1:
    for i in range(n-1):
        candy=sum(a1[0:i+1])+sum(a2[i:])
        ans=max(ans, candy)
elif n==1:
    ans=a1[0]+a2[0]

print(ans)   

Measured memory_bytes: 3060