akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string s;
  cin >> s;
  int flag = 0;
  int flag2 = 0;
  REP(i,s.size()){
    if(s.at(i) == 'A'){
      flag = i;
      break;
    }
  }
  REPR(i,s.size()-1){
    if(s.at(i) == 'Z'){
      flag2 = i;
      break;
    }
  }
  cout << flag2 - flag + 1<< endl;
}

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

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

    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    REP(i, n){
        int a;
        cin >> a;
        mp[a]++;        
    }
    
    vector<int> B;
    for(auto x : mp){
        B.emplace_back(x.second);
    }

    sort(B.begin(), B.end());

    int ans = 0;
    REP(i, max(0, (int)mp.size() - k)){
        ans += B[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10744
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class Test
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        A = A.OrderBy(x => x).ToArray();

        int pos1 = 0;
        int pos2 = N - 2;

        int totalDiscarded = 0;

        while (pos1 <= pos2)
        {
            while (pos1 <= pos2 && A[pos1] != A[pos1 + 1])
            {
                pos1++;
            }

            while (pos1 <= pos2 && A[pos2] != A[pos2 + 1])
            {
                pos2--;
            }

            if (pos1 <= pos2)
            {
                totalDiscarded += 2;
                pos1++;
                pos2--;
            }
        }

        Console.WriteLine(N - totalDiscarded);
    }
}

Measured memory_bytes: 25952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
    int n, d;
    cin >> n >> d;
    int ans = (n / (2 * d + 1) + (n % (2 *d + 1) != 0));
    cout << ans << '\n';
}

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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

int a[4];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<4;i++){
        a[i]=0;
    }
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC"){
            a[0]++;
        }else if(s=="WA"){
            a[1]++;
        }else if(s=="TLE"){
            a[2]++;
        }else{
            a[3]++;
        }
    }
    cout<<"AC x "<<a[0]<<endl<<"WA x "<<a[1]<<endl<<"TLE x "<<a[2]<<endl<<"RE x "<<a[3]<<endl;


    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

ll N,A,B;
vector<ll> h(100005,0);

bool ok(ll n){
    ll cnt = 0;
    for(int i=0; i<N; i++){
        if(h[i]-n*B > 0) cnt += (h[i]-n*B-1)/(A-B)+1;
    }

    if(cnt <= n) return true;
    else return false;
}

ll solve(){
    ll left = 0, right = 1000000007;
    ll mid;

    while(right-left>1){
        mid = (left+right)/2;
        if(ok(mid)) right = mid;
        else left = mid;
    }

    return right;
}

int main(){
    cin >> N >> A >> B;
    for(int i=0; i<N; i++) cin >> h[i];

    cout << solve() << endl;
}

Measured memory_bytes: 1024
n = int(input())
al = list(map(int,input().split()))


from collections import defaultdict
dic = {}

for a in al:
    if a not in dic:
        dic[a] = 0
    dic[a] += 1
if 0 in dic:
    if dic[0] == n:
        print("Yes")
        exit()
if 0 in dic:
    if n % 3 == 0:
        if dic[0] == 1 * n // 3:
            print("Yes")
            exit()
if n % 3 != 0:
    print("No")
    exit()
else:
    if len(dic) == 3:
        if max(dic.values()) == n // 3:
            a = 0
            for i in dic:
                a ^= i
            if a == 0:
                print("Yes")
                exit()
print("No")




Measured memory_bytes: 14704
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def calc(b, A):
    ans = 0
    for i, a in enumerate(A, start=1):
        ans += abs(a - (b + i))
    return ans

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(sorted([a - i for i, a in enumerate(A, start=1)]))

    ans = INF
    x = N // 2
    for i in range(max(0, x - 1), min(x + 1, N)):
        ans = min(ans, calc(B[i], A))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26896
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
    A[i] = sc.nextInt();
    }
    
    Arrays.sort(A);
   
    boolean flg = true;
    for(int j = 0; j < N-1; j++) {
      if (A[j] == A[j+1]) {
			  flg = false;
			}
		}

    if (flg) {
      System.out.print("YES");
    } else {
      System.out.print("NO");
    }
  }
}

Measured memory_bytes: 64476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w)puts("unsafe");
    else puts("safe");
}

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

int inf = 100000000 ;
char str[2][120] = {0} ;

bool solve()
{
  //no.1
  int cmp[2] = { inf, 0 } ;
  for ( int i = 0 ; i < 2 ; i++ )
  {
    for ( int j = 0 ; j < strlen(str[i]) ; j++ )
    {
      if ( i == 0 )
      {
        cmp[i] = min( cmp[i], (int)str[i][j] ) ;
      }
      else
      {
        cmp[i] = max( cmp[i], (int)str[i][j] ) ;
      }
    }
  }
  if ( cmp[0] < cmp[1] ) return true ;
  else if ( cmp[0] > cmp[1] ) return false ;
  //no.2
  for ( int i = 0 ; i < 2 ; i++ )
  {
    for ( int j = 0 ; j < strlen(str[i]) ; j++ )
    {
      if ( str[i][j] == cmp[0] )
      {
        int mem = str[i][ strlen(str[i])-1 ] ;
        str[i][ strlen(str[i])-1 ] = str[i][j] ;
        str[i][j] = mem ;
        break ;
      }
    }
    sort( str[i], str[i]+( strlen(str[i])-1 ) ) ;
    reverse( str[i], str[i]+( strlen(str[i])-1 ) ) ;
    reverse( str[i], str[i]+( strlen(str[i]) ) ) ;
    //printf("[debug]str[%d]:%s\n", i, str[i]) ;
  }
  for ( int i = 1 ; i < min( strlen(str[0]), strlen(str[1]) ) ; i++ )
  {
    //printf("[debug]str[0][%d]:%c,%d str[1][%d]:%c,%d\n", i, str[0][i], str[0][i], i, str[1][i], str[1][i]) ;
    if ( str[0][i] < str[1][i] ) return true ;
    else if ( str[0][i] > str[1][i] ) return false ;
  }
  //no.3
  if ( strlen(str[0]) < strlen(str[1]) ) return true ;
  return false ;
}

int main()
{
  cin >> str[0] >> str[1] ;
  if ( solve() ) puts("Yes") ;
  else puts("No") ;
  return 0 ;
}


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

int main(){
    int n,a,b;
	cin>>n>>a>>b;
  	int tc=n*a;
  	if(tc<b)cout<<tc;
  	else cout<<b;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		for(int i = 0 ; i < n ; i++){
			int a[] = new int[10];
			boolean used[] = new boolean[10];
			for(int j = 0 ; j < 10 ; j++){
				a[j] = input.nextInt();
			}
			
			int nownum = 0;
			for(int j = 0 ; j < 10 ; j++){
				if(!used[j] && nownum < a[j]){
					used[j] = true;
					nownum = a[j];
				}
			}
			
			nownum = 0;
			for(int j = 0 ; j < 10 ; j++){
				if(!used[j] && nownum < a[j]){
					used[j] = true;
					nownum = a[j];
				}
			}
			boolean isok = true;
			for(int j = 0 ; j < 10 ; j++){
				if(!used[j]){
					isok = false;
					break;
				}
			}
			if(isok){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			
		}
		input.close();
	}
}

Measured memory_bytes: 18152
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    b *= 2;
    if (a <= b) {
        cout << 0 << endl;
    } else {
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate
from itertools import groupby
from math import factorial
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [0]
for i,j in enumerate(li):
    lin.append(lin[i]+j)
lin.sort()
point = 0
lis = []
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
for key, value in groupby(lin):
    lis.append(len(list(value)))
for i in lis:
    if i >= 2:
        point += combinations_count(i,2)
print(point)

Measured memory_bytes: 26000
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct Edge{
    int from,to,cost;
    Edge(int from,int to,int cost) : from(from),to(to),cost(cost) {};
};

const int INF = 1 << 30;
// s:始点,dist:距離,prev:最短経路木
bool bellman(const vector<vector<Edge> >& graph,int s,vector<int> &dist,vector<int> &prev){
    int n = graph.size();
    for(int i=0;i<n;i++) dist[i] = INF;
    dist[s] = 0;
    for(int i=0;i<n;i++) prev[i] = -1;

    bool neg_cycle = false;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<graph[j].size();k++){
                const Edge &e = graph[j][k];
                if(dist[e.to] > dist[e.from] + e.cost){
                    dist[e.to] = dist[e.from] + e.cost;
                    prev[e.to] = e.from;
                    if(i == n-1){
                        dist[e.to] = -INF;
                        neg_cycle = true;
                    }
                }
            }
        }
    }
    return !neg_cycle;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<Edge> > E(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        E[a].push_back(Edge(a,b,-c));
    }
    vector<int> prev(n),dist(n);
    bellman(E,0,dist,prev);
    cout << -dist[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline long long read(){
    long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
int a[maxn];
int main(){
    int n = read(),cnt = 0;
    for(int i=1; i<=n; i++){
        a[i] = read();
        if (i & 1  && a[i] & 1){
            cnt++;
        }
    }   
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3588
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  var t = s[0], u = "";
  var ans = 1;
  for(var i = 1; i < s.length; i++){
    u += s[i];
    if(t === u)continue;
    t = u;
    u = "";
    ans++;
  }
  return ans;
}

Measured memory_bytes: 22984
#include<iostream>
using namespace std;
int main()
{
    int K, S;
    cin >> K >> S;
    int cnt = 0;
    for(int x = 0; x <= K; x++)
    {
        for(int y = 0; y <= K; y++)
        {
            if(S - x - y <= K && S - x - y >= 0)
            {
                // cout << "x = " << x << " " << "y = " << y << " " << "z = " << S - x - y << endl; 
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int to[200001], ne[200001], he[100001];
const ll mod = 1e9 + 7;
pair<ll, ll> dfs(int A, int prev) {
	ll kuro = 1;
	ll siro = 1;
	for (int i = he[A]; i; i = ne[i]) {
		int To = to[i];
		if (To != prev) {
			auto k = dfs(To, A);
			kuro = (kuro * k.second) % mod;
			siro = (siro * k.first) % mod;
		}
	}
	return mp(kuro + siro, siro);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int x = getint(), y = getint();
		to[k] = y;
		ne[k] = he[x];
		he[x] = k++;
		to[k] = x;
		ne[k] = he[y];
		he[y] = k++;
	}

	auto M = dfs(1, 0);
	printf("%lld", M.first % mod);

	Would you please return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,i=0,j,p[200010],min=1000000,ans=0;
    string s;
    cin >> n >> s;
    ans=n;
    s=s+'A';
    for(i=0;i<n;i++)
    {
        if(s[i]==s[i+1])
        {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace _0003
{
    class Program
    {
        static void Main(string[] args)
        {
            int how = int.Parse(Console.ReadLine());
            for (int a = 1; a <= how; a++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
           //     int[] mountain = new int[] { x[0], x[1], x[2] };
                Array.Sort(x);
                if(((x[0]*x[0])+(x[1]*x[1]))==(x[2]*x[2]))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

struct Edge {
  int t, c, r;
  Edge(int t, int c, int r) : t(t), c(c), r(r) {}
  bool operator<(const Edge& e) const {
    return c > e.c;
  }
};

int vis[5050][5050];

int main()
{
  int N, K;
  N = in(), K = in();
  vector<vector<int>> G(N);
  vector<int> C(N), R(N);
  for (int i = 0; i < N; i++){
    C[i] = in(), R[i] = in();
  }
  for (int i = 0; i < K; i++){
    int f, t;
    f = in() - 1, t = in() - 1;
    G[f].push_back(t);
    G[t].push_back(f);
  }
  priority_queue<Edge> Q;
  Q.push(Edge(0, 0, 0));
  while (Q.top().t != N - 1){
    auto e = Q.top();
    Q.pop();
    if (vis[e.t][e.r]++) continue;
    Q.push(Edge(e.t, e.c + C[e.t], R[e.t]));
    if (e.r) for (int v : G[e.t]) Q.push(Edge(v, e.c, e.r - 1));
  }
  printf("%d\n", Q.top().c);

  return 0;
}

Measured memory_bytes: 98120
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end()); //文字列の最初から最後の範囲でソート

	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n,a,b;
	cin >> n >> a >> b;
	vector<int> p(n,0);
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}

	/*calc*/
	int ans = 0;
//	int	max = n/3;
	int small_cnt = 0;
	int middle_cnt = 0;
	int big_cnt = 0;
	for(int i = 0; i < n; i++){
		if(p[i] <=a) small_cnt++;
		if(p[i] > a && p[i] <= b) middle_cnt++;
		if(p[i] > b) big_cnt++;
	}
	ans = min(small_cnt,min(middle_cnt,big_cnt));

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
#include <iomanip>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;


int main()
{
	ll N;
	string str[3];
	cin >> N >> str[0] >> str[1] >> str[2];
	int count = 0;
	for (int i = 0; i < N; i++)
	{

		int tmp = 2;
		//for (int j = 0; j < 3; j++)
		{
			if (str[0].at(i) == str[1].at(i) && str[0].at(i) == str[2].at(i))
			{
				tmp = 0;
			}
			else if (str[0].at(i) == str[1].at(i) || str[0].at(i) == str[2].at(i) || str[1].at(i) == str[2].at(i))
			{
				tmp = 1;
			}
			else
			{
				tmp = 2;
			}
		}

		count += tmp;

	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define s second
#define f first


const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const int N = (int)50505;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, x;

void solve(){
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        if(x & 1) cnt++;
    }
    if(n == 1){
        cout << "YES" << endl;
        return ;
    }
    if(cnt & 1){
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int T;
//    cin >> T;
    T = 1;
    for(int i = 1; i <= T; ++i){
        solve();
    }
}


Measured memory_bytes: 256
function main(input){
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if((a * b) % 2 === 0){
	console.log('Even');
    }else{
	console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 21064
using System;

namespace ALDS1_4A_1 {
    public class Program {
        public static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var an = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.ReadLine();
            var tq = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            //Array.Sort(an);

            var cnt = 0;
            foreach(var t in tq) {
                var left = 0;
                var right = n;
                while(left < right) {
                    var mid = (left + right) / 2;
                    if(an[mid] == t) {
                        cnt++;
                        break;
                    }

                    if(t < an[mid]) right = mid;
                    else left = mid + 1;
                }
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 19820
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int N;
	string s;
	int ans=0;
	cin>>N>>s;
	REP(i,N){
		if(s[i]=='R'){
			ans++;
		}else{
			ans--;
		}
	}
	if(ans>0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

int main() {
  vector<int> t(5);
  rep(i, 5) cin >> t[i];
  vector<int> s(5);
  rep(i, 5) s[i] = 10 + (t[i] - 1) / 10 * 10;
  int ans = 1e5;
  rep(i, 5) {
    int u = 0;
    rep(j, 5) {
      if (j == i) u += t[j];
      else u += s[j];
    }
    ans = min(ans, u);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
function main(arg) {
	arg = arg.trim().split('\n');
  	var a = parseInt(arg[0], 10),
        s = arg[1], flg = 3200, out = '';
  if (a >= flg) {
  	out = s;
  } else {
  	out = 'red';
  }
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<string>
using namespace std;
int main(){
	string s;
	while(cin>>s,s!="0"){
		int a=0,b=0;
		for(int i=1;i<s.size();i++)s[i]=='A'?a++:b++;
		a>b?a++:b++;
		cout<<a<<" "<<b<<endl;
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

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

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k; cin >> n >> k;
  vi a(n);
  int ma = 0;
  int g = 0;
  REP(i, n) {
    cin >> a[i];
    if(i == 0) g = a[i];
    else g = gcd(g, a[i]);
    ma = max(ma, a[i]);
  }

  if(k % g == 0 && k <= ma) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  
}


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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int w, h, n;
	cin >> w >> h >> n;
	int lx = 0;
	int dy = 0;
	int rx = 0;
	int uy = 0;
	for (int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			lx = max(lx, x);
		} else if (a == 2) {
			rx = max(rx, w - x);
		} else if (a == 3) {
			dy = max(dy, y);
		} else {
			uy = max(uy, h - y);
		}
	}
	w = max(w - lx - rx, 0);
	h = max(h - dy - uy, 0);
	cout << w * h << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  string s; cin >> s;
  s = '_' + s;
  ll ans = 0, len = s.length();
  vi cnt(len, 0);
  rep(i,len) {
    switch(s[i]) {
      case 'A':
      case 'T':
      case 'C':
      case 'G':
        cnt[i] = 1;
      default:
        break;
    }
  }
  REP(i,1,len) {
    if (cnt[i] == 0) continue;
    cnt[i] += cnt[i-1];
    ans = max(ans, cnt[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])
    cout << "Yes\n";
  else 
    cout << "No\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 200001;
struct node{
    long long mx, tag;
    long long v() {
        return mx + tag;
    }
}f[N * 4];
int n, d, a;
pair<int, int> b[N];
void build(int l, int r, int s) {
    if ( l == r) {
        f[s].mx = b[l].second;
        return;
    }
    build(l, (l + r) / 2, s + s);
    build((l + r) / 2 + 1, r, s + s + 1);
    f[s].mx=  max(f[s+s].v(), f[s+s+1].v());
}
pair<long long, int> get() {
    int tag = 0;
    int l = 1, r = n , s = 1;
    while (1) {
        tag += f[s].tag;
        if (l == r)
            return make_pair(tag + f[s].mx, b[l].first);
        if (f[s+s].v() + tag > 0) {
            r = (l + r) / 2;
            s += s;
        } else {
            l = (l + r) /2 + 1;
            s += s + 1;
        }
    }
}
void add(int l, int r, int s, long long ll, long long rr, long long tag) {
    if (b[r].first < ll || rr < b[l].first) return;
    if (ll <= b[l].first && b[r].first <= rr) {
        f[s].tag += tag;
        return;
    }
    add(l, (l + r) / 2, s + s, ll, rr, tag);
    add((l + r) / 2+ 1, r, s + s+ 1, ll, rr, tag);
    f[s].mx = max(f[s+s].v(), f[s+s+1].v());
}
int main() {
    scanf("%d %d %d", &n, &d, &a);
    for (int i = 1; i <= n; i ++) {
        scanf("%d %d", &b[i].first, &b[i].second);
        b[i].second = (b[i].second + a - 1) / a;
    }
    sort(b + 1, b + n + 1);
    build(1, n, 1);
    long long ans = 0;
    while (f[1].v() > 0) {
        pair<long long, int> u = get();
        ans += u.first;
        add(1, n, 1, u.second, 1ll * u.second + d + d, -u.first);
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

const int N = 101;
const long long DMAX = 1e11;

long long g[N][N], mul[N];
int p[N];

int main() {
  mul[0] = 1;
  for (int i = 1; i < 10; ++i) {
    mul[i] = mul[i-1] + 1;
    bool ok = 0;
    while (!ok) {
      ok = 1;
      set<int> st;
      for (int j = 0; j <= i && ok; ++j) {
        if (st.count(mul[j])) {
          ok = 0;
          break;
        }
        st.insert(mul[j]);
        for (int k = j+1; k <= i; ++k) {
          int now = mul[k] + mul[j];
          if (st.count(now)) {
            ok = 0;
            break;
          }
          st.insert(now);
        }
      }
      if (ok) break;
      ++mul[i];
    }
  }
  int N, n = 2;
  scanf("%d", &N);
  g[0][1] = g[1][0] = 1;
  long long last = 1;
  while (n < N) {
    ++n;
    long long cur = last;
    bool ok = 0;
    while (!ok) {
      ok = 1;
      for (int i = 0; i < n-1; ++i)
        g[i][n-1] = g[n-1][i] = mul[i] * cur;
      last = 0;
      for (int i = 0; i < n; ++i)
        p[i] = i;
      set<long long> st;
      do {
        if (p[0] > p[n-1]) continue;
        long long sum = 0;
        for (int i = 0; i + 1 < n; ++i)
          sum += g[p[i]][p[i+1]];
        if (st.count(sum)) {
          ok = 0;
          break;
        }
        st.insert(sum);
        last = max(last, sum);
        ++cur;
      } while (next_permutation(p, p+n));
    }
  }
  assert(last <= DMAX);
  cerr << last << endl;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      printf("%lld%c", g[i][j], j == N-1 ? '\n' : ' ');
    }
  }
  return 0;
}


Measured memory_bytes: 85248
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
map<long long,int>mp;
int num=0;
rep(i,N){
    long long a;
    cin>>a;
    if(mp[a]){
        num++;
    }
    mp[a]++;
}
int ans;
if(num%2==1){
    ans=(num+1)/2;
}
else{
    ans=num/2;
}
cout<<N-ans*2<<endl;

 return 0;
}
/*

*/


Measured memory_bytes: 6528
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

const debug = false

func (p *problem) solve() {
	m := make(map[string]int)
	N := p.nextInt()
	for i := 0; i < N; i++ {
		key := p.next()
		v, _ := m[key]
		m[key] = v + 1
	}
	M := p.nextInt()
	for i := 0; i < M; i++ {
		key := p.next()
		v, _ := m[key]
		m[key] = v - 1
	}
	arr := make([]int, len(m))
	for _, v := range m {
		arr = append(arr, v)
	}
	sort.Ints(arr)
	p.printf("%d", arr[len(arr)-1])
}

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) printi(d int) {
	if err := p.out.WriteByte(byte(d)); err != nil {
		panic(err)
	}
}

func (p *problem) printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) nextInt() int {
	return stoi(p.next())
}

func (p *problem) nextInts() []int {
	line := p.nextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) nextSSLine() []string {
	return strings.Split(p.next(), " ")
}

// Next reads line and return string.
func (p *problem) next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cassert>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
//typedef pair<int, int> pii;
using pll = pair<ll, ll>;
using pii = pair<short, short>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define rep1(i,a) for(int i=1;i<=(a);i++)
#pragma warning(disable:4996)
//#define INF 1000000000000000.0
int main() {
	int n;
	while (cin >> n, n) {
		vector<int> num;
		string buf;
		rep(i, n) {
			cin >> buf;
			num.push_back(buf.length());
		}
		rep(i, n) {
			vi sp(5);
			int pos = 0;
			bool f = 1;
			for (int j = i;; j++) {
				f = 1;
				sp[pos] += num[j];
				if (sp[pos] > (pos & 5 ? 7 : 5)) {
					f = 0;
					break;
				}
				if (sp[pos] == (pos & 5 ? 7 : 5)) {
					pos++;
					if (pos == 5)break;
				}
			}
			if (f) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	ll l;
	cin >> n >> l;
	ll a[n];
	rep(i, n) cin >> a[i];
	
	bool able = false;
	int last = -1;
	rep(i, n - 1) {
		if (a[i] + a[i + 1] >= l) {
			able = true;
			if (last == -1) last = i;
		}
	}
	if (!able) {
		cout << "Impossible" << endl;
		return 0;
	}
	
	cout << "Possible" << endl;
	rep(i, last) cout << i + 1 << endl;
	for (int i = n - 1; i > last; --i) cout << i << endl;

//	ll sum = 0;
//	rep(i, n) sum += a[i];
//
//	vector<int> order;
//	int left = 0, right = n - 1;
//	rep(i, n - 1) {
//		if (sum >= l) {
//			if (a[left] < a[right]) {
//				order.push_back(left);
//				sum -= a[left];
//				left++;
//			} else {
//				order.push_back(right - 1);
//				sum -= a[right];
//				right--;
//			}
//		} else {
//			cout << "Impossible" << endl;
//			return 0;
//		}
//	}
//
//	cout << "Possible" << endl;
//	for (auto &t: order) cout << t + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vi a;
    a.push_back(0);
    rep(i,n){
        int e;
        cin >> e;
        a.push_back(e);
    }
    a.push_back(0);
    int sum = 0;
    rep(i,n+1){
        sum += abs(a[i] - a[i+1]);
    }
    rep(i,n){
        int j = i+1;
        cout << sum - abs(a[j] - a[j-1]) - abs(a[j] - a[j+1]) + abs(a[j-1] - a[j+1]) << endl;
    }
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    const int time=1900;
    const int unit=100;
    int n,m;
    cin>>n>>m;
    cout<<(unit*(n-m)+time*m)*pow(2,m)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
nums = gets.split.map(&:to_i)
posi = 0
nega = 0
ans = 0

nums.each_with_index do |num, i|
  nums[i] = num - i - 1
  if nums[i] < 0
    nega += 1
  elsif nums[i] > 0
    posi += 1
  end
end

if posi != nega
  nums.sort!
  center = nums[n/2]
  nums.each_with_index do |num, i|
    nums[i] = num - center
  end
end

nums.each{|n| ans += n.abs }

p ans

Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> mat(h);
  REP(i,h)cin>>mat[i];
  UnionFind uf(h*w);
  vector red(h, string(w, '.'));
  vector blue(h, string(w, '.'));
  REP(i,h) red[i].back() = '#';
  REP(i,h) blue[i].front() = '#';
  FOR(i,1,w) red.front()[i] = '#';
  REP(i,w-1) blue.back()[i] = '#';
  FOR(i,1,h-1)FOR(j,1,w-1) {
    int s = (i+j) / 2;
    if (mat[i][j] == '#') {
      red[i][j] = '#';
      blue[i][j] = '#';
    } else {
      if (s % 2) {
        red[i][j] = '#';
      } else {
        blue[i][j] = '#';
      }
    }
  }
  REP(i,h) cout<<red[i]<<"\n";
  cout<<"\n";
  REP(i,h) cout<<blue[i]<<"\n";

  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
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;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;

int main(){
	ll n,k; cin >> n >> k;
	ll r,s,p; cin >> r >> s >> p;
	map<char,ll> mp;
	mp['r'] = p; mp['p'] = s; mp['s'] = r;
	ll ans = 0;
	string t; cin >> t;
	vl v(n,0);
	rep(i,n){
		if(i>=k && t[i]==t[i-k] && v[i-k]==mp[t[i]]) continue;
		else ans += mp[t[i]], v[i] = mp[t[i]];
	}
	cout << ans << endl;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    int n, k;
    cin >> n >> k;

    for(int i = 0; i < k; i++){
        int ans = (COM(k - 1, i) % MOD * COM(n - k + 1, i + 1) % MOD) % MOD;
        cout << ans << endl;
    }
}

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

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i <N; i++ ) cin >> A[i];

    unordered_map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
    }
    vector<int> B;
    for(auto p: mp){
        B.push_back(p.second);
    }
    //cout << "Yes"<<endl;

    sort(B.begin(), B.end());
    int sum = 0;
    int f = B.size();
    //cout << B.size() << "  " << K << endl;
    if((f - K) <= 0){
        cout << 0 <<endl;
        return 0;
    }
    else{
        for(int i = 0; i < B.size() - K; i++ ){
            sum += B[i];
        }
        cout << sum <<endl;
    }
}

Measured memory_bytes: 11080