akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() -2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 3500
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, K = i_l()

if K == 1 or N == K:
    print(0)
    exit()

N = N % K
arr = []
while not N in arr[:-1]:
    N = abs(N-K)
    arr.append(N)

print(min(arr))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
	int i;
	int len, N;
	char aa[100];
	scanf("%s", aa);
	//	printf("%s", aa);
	for (i = 0; i < 3; i++)
	{
		if (aa[i] == '7')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2088
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
 
int A[100010];
int n;
 
int partition(int left,int right){
	int i=left-1;
	for(int j=left;j<right;j++){
		if(A[j]<=A[right]) {
			swap(A[i+1],A[j]);
			i++;
		}
	}
	swap(A[right],A[i+1]);
	return i+1;	
}
 
int main (){
	cin>>n;
	for(int i =0;i<n;i++) cin>>A[i];
	int x=partition(0,n-1);
	for(int i =0;i<n;i++) {
		if(i==0) cout<<A[i];
		else if(i==x) cout<<" ["<<A[i]<<"]";
		else cout<<" "<<A[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3496
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int[][] c = new int[3][3];
			
			for(int i=0;i<3;i++) {
				for(int j=0;j<3;j++) {
					c[i][j] = sc.nextInt();
				}
			}
			
			if(calc(c,0,0,0,1)&&calc(c,0,1,0,2)&&calc(c,1,0,1,1)&&calc(c,1,1,1,2)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
			
	    }
		
		static boolean calc(int[][] c,int i,int j,int k, int l) {
			if((c[i][j]+c[i+1][j+1])==(c[k][l]+c[k+1][l-1])) {
				return true;
			}else {
				return false;
			}
		}
	}


Measured memory_bytes: 24912
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , k;
int a[N] , b[N];
bool all[N];
long long ans;
int main(){
	scanf("%d %d" , &n , &k);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d %d" , a + i , b + i);
	}
	ans = 0;
	for(int i = 29 ; i >= -1 ; --i){
		if(i >= 0 && !((k >> i) & 1)){
			continue;
		}
		memset(all , 0 , sizeof(all));
		for(int j = 29 ; j > i ; --j){
			if(!((k >> j) & 1)){
				for(int x = 1 ; x <= n ; ++x){
					if((a[x] >> j) & 1){
						all[x] = 1;
					}
				}
			}
		}
		for(int x = 1 ; x <= n ; ++x){
			if(i >= 0 && (a[x] >> i) & 1){
				all[x] = 1;
			}
		}
		long long tot = 0;
		for(int x = 1 ; x <= n ; ++x){
			if(!all[x]){
				tot += b[x];
			}
		}
		ans = max(ans , tot);
	}
	printf("%lld\n" , ans);
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main() {
	int m[51], f[51], r[51], i = 0;
	cin >> m[i] >> f[i] >> r[i];
	//全部-1の時入力終了
	do {
		i++;
		cin >> m[i] >> f[i] >> r[i];
	} while (m[i] != -1 || f[i] != -1 || r[i] != -1);
	
	for (int j = 0; j < i; j++) {
		if (m[j] == -1 || f[j] == -1) cout << 'F' << endl;
		else if (80 <= m[j] + f[j])  cout << 'A' << endl;
		else if ((65 <= m[j] + f[j]) && (m[j] + f[j] < 80))  cout << 'B' << endl;
		else if ((50 <= m[j] + f[j]) && (m[j] + f[j] < 65))  cout << 'C' << endl;
		else if ((30 <= m[j] + f[j]) && (m[j] + f[j] < 50)){
			if (50 <= r[j]) cout << 'C' << endl;
			else cout << 'D' << endl;
	}
		else if(m[j]+f[j]<30) cout << 'F' << endl;
	}
}


Measured memory_bytes: 3088
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = ReadLine();
        S = S.Replace("eraser", "");
        S = S.Replace("erase", "");
        S = S.Replace("dreamer", "");
        S = S.Replace("dream", "");

        if (S == "") {
            WriteLine("YES");
        } else {
            WriteLine("NO");
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {


        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 13108
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){

  int A, B, Q;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&Q);
  std::vector<long long > s(A+2);
  std::vector<long long > t(B+2);
  std::vector<long long > x(Q);
  s[0]=-10000000000000000;
  for (int i=0; i<A; i++){
    scanf("%lld",&s[i+1]);
  }
  s[A+1]=100000000000000000;
  t[0]=-10000000000000000;
  for (int i=0; i<B; i++){
    scanf("%lld",&t[i+1]);
  }
  t[B+1]=100000000000000000;
  for (int i=0; i<Q; i++){
    scanf("%lld",&x[i]);
  }

  for (int i=0; i<Q; i++){
    auto itr = std::lower_bound(s.begin(), s.end(), x[i]);
    int s_index_high = itr-s.begin();
    int s_index_low = s_index_high-1;
    itr = std::lower_bound(t.begin(), t.end(), x[i]);
    int t_index_high = itr-t.begin();
    int t_index_low = t_index_high-1;
    //printf("s=[%d, %d]=[%lld, %lld]\n",s_index_low, s_index_high, s[s_index_low], s[s_index_high]);
    //printf("t=[%d, %d]=[%lld, %lld]\n",t_index_low, t_index_high, t[t_index_low], t[t_index_high]);
    long long ans = 100000000000000;
    //printf("dist=%lld+%lld=%lld",abs(x[i]-s[s_index_low], abs(s[s_index_low]-t[t_index_high], )))
    ans = std::min(ans, abs(x[i]-s[s_index_high])+abs(s[s_index_high]-t[t_index_high]));
    ans = std::min(ans, abs(x[i]-s[s_index_high])+abs(s[s_index_high]-t[t_index_low]));
    ans = std::min(ans, abs(x[i]-s[s_index_low])+abs(s[s_index_low]-t[t_index_high]));
    ans = std::min(ans, abs(x[i]-s[s_index_low])+abs(s[s_index_low]-t[t_index_low]));
    ans = std::min(ans, abs(x[i]-t[t_index_high])+abs(t[t_index_high]-s[s_index_high]));
    ans = std::min(ans, abs(x[i]-t[t_index_high])+abs(t[t_index_high]-s[s_index_low]));
    ans = std::min(ans, abs(x[i]-t[t_index_low])+abs(t[t_index_low]-s[s_index_high]));
    ans = std::min(ans, abs(x[i]-t[t_index_low])+abs(t[t_index_low]-s[s_index_low]));
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3712
def f i,j;$m[i][j]||=f(i-1,j)+f(i,j-1);end
def g;gets.split.map &:to_i;end
while(a,b=g)[0]>0
$m=(0..a).map{[0]}
$m[0]+=[0]*b
$m[1][1]=1
g[0].times{i,j=g;$m[i][j]=0}
p f(a,b)end

Measured memory_bytes: 6116
#include <iostream>
#include <cstdint>
#include <string>
#include <algorithm>
#include <vector>

std::string zero_padding(const std::string s, const std::size_t n) {
  std::vector<char> v(n, '0');
  std::copy(s.begin(), s.end(), v.begin() + (n - s.size()));
  return std::string(v.begin(), v.end());
}

int main() {
  std::string a, b;
  std::cin >> a >> b;
  const std::size_t n = std::max(a.size(), b.size());
  const std::string c = zero_padding(a, n);
  const std::string d = zero_padding(b, n);
  std::cout << (c > d ? "GREATER" : c < d ? "LESS" : "EQUAL") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define array(N,t) (t*)calloc(N,sizeof(t))
inline long long IN(void)
{
  long long x=0;int f=1;char c=getchar();
  while(c<'0'||c>'9'&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();
  return f*x;
}
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N,i,j,x;long long K;
  N=IN(),K=IN();
  int *A=array(N,int),*here=array(N,int),*town=array(N,int);
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  free(A),free(here);
  if(K>=j)K=(K-x)%(x-j)+x;
  OUT(town[K]+1);
  return free(town),0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch IntervalRunning | diff IntervalRunning.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address IntervalRunning.cpp && ./a.out

/*
 
 12/1/2019
 
 5:07-5:40 give up
 10:20-11:30 read editorial and got AC
 
 */

LL T[2],A[2],B[2];

string solve() {
  LL P=(A[0]-B[0])*T[0],Q=(A[1]-B[1])*T[1];
  if(P>0) P*=-1,Q*=-1;
  if(P+Q<0) return "0";
  if(P+Q==0) return "infinity";
  dump(P,Q,P+Q);
  LL k=-P/(P+Q);
  LL res=2LL*k;
  if((P+Q)*k!=-P) ++res;    
  return to_string(res);
}

void solve_wrong() {
  int res=0;
  LL a=0,b=0;
  int sign=-100;
  FOR(i,0,1e6) {
    a+=T[i%2]*A[i%2];
    b+=T[i%2]*B[i%2];
    LL x=min(a,b);
    a-=x,b-=x;
    int sign2=a==b?0:a>b;
    if(sign2==0||sign2!=sign) ++res;
    sign=sign2;
  }
  if(res>1e5) cout<<"infinity"<<endl;
  else cout<<res-1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>T[0]>>T[1]>>A[0]>>A[1]>>B[0]>>B[1];
  cout<<solve()<<endl;
  
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, K;
int h[100000];

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> h[i];
    sort(h, h + N);
    int m = INT32_MAX;
    REP(i, N - K + 1) m = min(m, h[i + K - 1] - h[i]);
    PRINT(m);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);

int main() {
	int n;
	string s;
	cin >> n >> s;
	int  ans = 0;
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			for (int k = 0;k < 10;k++) {
				int count = 0;
				for (int l = 0;l < s.size();l++) {
					if (s[l] - '0' == i&&count==0) count++;
					else if (s[l] - '0' == j && count == 1)count++;
					else if (s[l] - '0' == k && count == 2)count++;
				}if (count == 3)ans++;

			}
		}
	}

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


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a + b,a + c,b + c }) << endl;
}

Measured memory_bytes: 256
n = int(input())
s = []
count = [0] * n
count[0] = 1

for i in range(n):
    s_e = str(input())
    s.append(s_e)
s.sort()

last = s[0]
s_max = 1

for i in range(1, n):
    if last == s[i]:
        count[i] = count[i-1] + 1       
    else:
        s_max = max(s_max, count[i-1])
        last = s[i]
        count[i] = 1

s_max = max(s_max, count[n-1])

for i in range(n):
    if s_max == count[i]:
        print(s[i])

Measured memory_bytes: 24896
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main(){
  map<int, bool> memo;
   int n;
   cin >> n;

   int cnt = 0;

   for(int i=0; i<n; i++){
     int p[3];
     cin >> p[0] >> p[1] >> p[2];

     sort(p,p+3);

     int k = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);

     if(memo.find(k) != memo.end()){
       cnt++;
     }else{
       memo[k] = true;
     }
   }
   cout << cnt << endl;
   return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  int dp[N+1],h[N+1];
  for(int i=1; i<=N;++i) cin >> h[i];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3; i<=N; ++i){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    char letter;
    scanf(" %c",&letter);
    if(letter=='a'||letter=='e'||letter=='i'||letter=='o'||letter=='u')
    {
        printf("vowel");
    }
    else
    {
        printf("consonant");

    }
    return 0;

}


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int N; cin >> N;
  vector<ll> a(N); REP(i, N) cin >> a[i];
  map<ll, ll> m;

  REP(i, N) {
    m[a[i]]++;
  }

  ll cnt = 0;
  ll k = 0;
  for(auto i = m.begin(); i != m.end(); ++i) {
    if(i->first != i->second) {
      if(i->first < i->second) {
        cnt += i->second - i->first;
      } else {
        cnt += i->second;
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 7040
a = gets().to_i
b = gets().split(" ")

for i in 0..a-1
  b[i] = b[i].to_i
end

c = []

for i in 0..a-1
  if b[i+1]!=nil
    if b[i]>=b[i+1]
      c.push(1)
    else
      c.push(0)
    end
  end
end

t = []

c.chunk { |u|
 u==1 
}.each{ |r, w|
  if r==true
    t.push(w.length)
  end
}

f = t.max
if f==nil
  f = 0
end

p f

Measured memory_bytes: 11524
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
	int n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	a--;b--;c--;d--;
	for (int i = a; i < max(c,d); i++) {
		if(s[i] == '#' && s[i+1] == '#'){
			cout << "No" << endl;
			return 0;
		}
	}
	if(c<d){
		cout << "Yes" << endl;
		return 0;
	}
	else{
		for (int i = b; i <= d; i++) {
			if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;

  int acnt = 0;
  int bcnt = 0;
  int abcnt = 0;
  int ans = 0;
  rep(i, n) {
    string s; cin >> s;
    int sn = s.size();

    bool sufa = s[sn - 1] == 'A';
    bool preb = s[0] == 'B';

    if(sufa && preb) {
      ++abcnt;
    } else {
      acnt += sufa;
      bcnt += preb;
    }

    rep1(i, sn - 1) {
      if(s[i] == 'B' && s[i - 1] == 'A') {
        ++ans;
      }
    }
  }

  ans += min(acnt, bcnt);
  if(abcnt) {
    ans += abcnt;
    if(acnt + bcnt == 0) {
      --ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll now, ans, n, k, r[110000];
ll q;
map<ll, ll> m;
//セグ木
ll dat[2560000], sz;

void init(ll n) {
	sz = 1;
	while (sz < n)sz *= 2;
}

void update(ll k, ll a) { //場所(0-indexed), 値
	k += sz - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2]; //更新
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return 0;
	if (a <= l and r <= b)return dat[k];
	ll v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return v1 + v2; //戻り値
}

int main() {
	init(110000);
	cin >> n;
	cin >> k;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
		s[i] -= k;
	}
	m[0] = 0;
	REP(i, n) {
		r[i + 1] = r[i] + s[i];
		m[r[i + 1]] = 0;
	}
	for (auto& i : m) {
		i.second = now;
		now++;
	}
	REP(i, n + 1) {
		ans += query(0, m[r[i]] + 1, 0, 0, sz);
		update(m[r[i]], query(m[r[i]], m[r[i]] + 1, 0, 0, sz) + 1);
	}
	cout << ans << endl;
}




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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl
using ll=long long;
constexpr ll mod = 1000000007;

ll mod_pow(ll a, ll b){
  ll res=1;
  while(b>0){
    if(b&1LL)res=res*a%mod;
    a=a*a%mod;
    b>>=1LL;
  }
  return res;
}

struct Hoge{
  ll N;
  map<ll,char> mp;
  
  Hoge(ll N_):N(N_){}
  bool set_front(ll idx, char c){
    if(mp.find(idx)==mp.end()){
      mp[idx]=c;
      return true;
    }
    else{
      return mp[idx]==c;
    }
  }
  bool set_back(ll idx, char c){
    idx = N-1-idx;
    return set_front(idx,c);
  }
  ll filling(){
    return mp.size();
  }
};

bool isparin(string& s){
  int siz=s.size();
  rep(i,siz)if(s[i]!=s[siz-1-i])return false;
  return true;
}

int main(){
  string zaki,o;
  ll N;
  cin>>zaki>>o>>N;

  ll A=zaki.size();
  ll B=o.size();
  ll res=1;
  if(N>=B){
    Hoge hoge(N);
    // N's front
    auto ro =o;
    reverse(ro.begin(),ro.end());
    rep(i,o.size()){
      if(!hoge.set_front(i, ro[i]))res=0;
    }
    // N's middle
    //res=mod_pow(26,N-B);
    //N=B;
    ll mid = min(A, B);
    rep(i,mid){
      //cout<<"debug"<<B-1-i<<".."<<zaki[i]<<endl;
      if(!hoge.set_front(B-1-i,zaki[i]))res=0;
    }

    if(A>B){
      reverse(zaki.begin(),zaki.end());
      rep(i,B)zaki.pop_back();
      if(!isparin(zaki))res=0;
    }

    ll safe = N - hoge.filling();
    (res*=mod_pow(26,safe))%=mod;

    //cerr<<"debug"<<endl;
    //rep(i,N)if(hoge.mp.find(i)==hoge.mp.end())cout<<"_";
    //else cout<<hoge.mp[i];
    //cout<<endl<<endl;
  }
  else{
    auto hoge = o;
    reverse(hoge.begin(),hoge.end());
    while(hoge.size()>N)hoge.pop_back();
    auto ans = hoge+zaki+hoge+o;
    if(!isparin(ans))res=0;
  }
  cout<<res<<endl;
  return 0;
}



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

//maerd, remaerd, esare, resare
 
int main(){
  string s;
  cin >> s;
  int n=s.length();
  reverse(s.begin(), s.end());
  int now=0;
  while(now<n){
    if(s.substr(now,5)=="maerd"){
      now += 5;
      continue;
    }else if(s.substr(now,5)=="esare"){
      now += 5;
      continue;
    }else if(s.substr(now,7)=="remaerd"){
      now += 7;
      continue;
    }else if(s.substr(now,6)=="resare"){
      now += 6;
      continue;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int n, m, l, i, j, k;
	scanf("%d %d %d", &n, &m, &l);
	
	long long a[100][100];
	long long b[100][100];
	long long sum;
	
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%lld", &a[i][j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			scanf("%lld", &b[i][j]);
		}
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			sum = 0;
			for(k=0; k<m; k++){
				sum += a[i][k] * b[k][j];
			}
			printf("%lld",sum);
			if(j+1!=l){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 756
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

stream = require('fs').createReadStream(config.input);

sum = 0;
prev = false;
A = [];

stream.on('readable', function() {
  var buf, i;
  buf = stream.read();
  if (buf === null) return;

  // search '\n'
  for (i = Math.min(20, buf.length - 1); i > 0 && buf[i-1] !== 0x0a; i--) ;
  
  for (; i < buf.length; i++) {
    if (buf[i] >= 0x30 && buf[i] <= 0x39) {
      sum = 10 * sum + (buf[i] - 0x30);
      prev = true;
    } else {
      if (prev) A.push(sum);
      sum = 0;
      prev = false;
    }
  }
});

stream.on('end', function() {
  var B;
  if (prev) A.push(sum);
  B = [].concat(A);
  console.log(sort(A, B, 0, A.length));
});

function sort(ary, smaller, start, end) {
  var cnt, tmp, mid, i, j, k;
  if (end - start <= 1) return 0;
  if (end - start === 2) {
    if (ary[start] > ary[start+1]) {
      tmp = ary[start+1];
      ary[start+1] = ary[start];
      ary[start] = tmp;
      return 1;
    }
    return 0;
  }

  cnt = 0;
  mid = Math.floor((start + end) / 2);
  cnt += sort(smaller, ary, start, mid);
  cnt += sort(smaller, ary, mid, end);

  i = start, j = mid;
  for (k = start; k < end; k++) {
    if (i === mid) {
      ary[k] = smaller[j++];
    } else if (j === end) {
      ary[k] = smaller[i++];
    } else if (smaller[i] < smaller[j]) {
      ary[k] = smaller[i++];
    } else {
      ary[k] = smaller[j++];
      cnt += mid - i;
    }
  }
  return cnt;
}

Measured memory_bytes: 26616
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

dp = [0] * 6
dp[0] = N
T = [A,B,C,D,E]
ans = 0

ans = -(-N//min(T)) + 4
# while dp[5] < N:
#     for i in range(4, -1, -1):
#         if dp[i] == 0:
#             continue
#         dp[i+1] += min(dp[i],T[i])
#         dp[i] -= min(dp[i],T[i])
#     ans += 1
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC118.A.Solve();
        }
    }
}
namespace AtCoder.ABC118
{
    class A
    {
        static public void Solve()
        {
            var s = Console.ReadLine();
            var inputs = s.Split(' ').Select(x => int.Parse(x)).ToArray();
            var o = (inputs[1] % inputs[0] == 0) ? inputs[0] + inputs[1]:inputs[1] - inputs[0];
            Console.WriteLine(o);
        }
    }
}


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

int main(){
	int a,b;
	cin >> a >> b;
	if(13 <= a) cout << b << endl;
	else if(6 <= a && a <= 12) cout << b/2 << endl;
	else cout << 0 << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n;
ll b[200010];

int main(){
  cin>>n;
  rep(i,n){
    cin>>b[i];
    b[i]-=i;
  }
  sort(b,b+n);
  ll m=b[n/2];
  ll res=0;
  rep(i,n){
    res+=abs(b[i]-m);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;



 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	
	int N = 0;
	int[] a = null;
	
	int ans = -1;
	//	boolean ans = true;
	
	
	
	
	public void input() throws IOException {
		N = in.nextInt();
		a = in.nextInt(new int[N]);
	}
	
	public void solve() throws IOException {
		Arrays.sort(a);
		int alice=0;
		int bob=0;
		boolean isAlice = true;
		for(int i=N-1; i>=0; i--) {
			if (isAlice) {
				alice += a[i];
			} else {
				bob += a[i];
			}
			isAlice = !isAlice;
		}
		ans = alice-bob;
	}

	
	public void output() {
		out.println(ans);
		out.flush();
	}
}

class Point {
	int y;
	int x;
	public Point(int y, int x) {
		this.x=x;
		this.y=y;
	}
	
	public Point move(Point d) {
		Point p = new Point(y, x);
		p.x += d.x;
		p.y += d.y;
		return p;
	}
	
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main() {
	int cardA = 1;
	int cardB = 0;
	int cardC = -1;
	int a, b, c, k, l = 0;
	int max = 0;

	cin >> a >> b >> c >> k;

	if (a >= k) max = cardA * k;
	else {
		k -= a;
		if (b >= k) max = cardA * a + cardB * k;
		else {
			k -= b;
			max = cardA * a + cardB * b + cardC * k;
		}
	}

	cout << max << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    string s[101];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define mod         100000000
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e17+2;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

void solve(){

  int test;
  //cin>>test;
  test=1;
  while(test--){
    string s;
    cin>>s;
    int n=s.length();
    n++;
    ll a[n];
    memset(a,0,sizeof(a));
    forn(i,0,n-1){
      if(s[i]=='<')
      a[i+1]=max(a[i+1],a[i]+1);
    }
    for(int i=n-2;i>=0;i--)
    {
      if(s[i]=='>')
      a[i]=max(a[i],a[i+1]+1);
    }
    ll sum=0;
    forn(i,0,n)
    sum+=a[i];

    cout<<sum;
  }

}



///Before submit=>

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 4764
import sys

def main():
  input = sys.stdin.readline
  H, W = map(int, input().split())
  M = [list(map(int, input().split())) for _ in range(H)]

  count = 0
  manup = []
  for y in range(H):
    for x in range(W):
      if M[y][x] % 2 == 1:
        if x < (W-1):
          count += 1
          manup.append([y+1, x+1, y+1, x+2])
          M[y][x+1] += 1
        elif y < H-1:
          count += 1
          manup.append([y+1, x+1, y+2, x+1])
          M[y+1][x] += 1
        else:
          continue
  
  print(count)
  if count > 0:
    for m in manup:
      print('{} {} {} {}'.format(m[0], m[1], m[2], m[3]))

if __name__ == '__main__':
  main()

Measured memory_bytes: 29880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  VI x(n), y(n), a(n);
  rep(i,n) cin >> x[i] >> y[i] >> a[i];
  
  int xmin=0,xmax=w,ymin=0,ymax=h;
  rep(i,n){
    if( a[i]==1 && x[i] > xmin ) xmin = x[i];
    if( a[i]==2 && x[i] < xmax ) xmax = x[i];
    if( a[i]==3 && y[i] > ymin ) ymin = y[i];
    if( a[i]==4 && y[i] < ymax ) ymax = y[i];
  }
  
  if( xmin < xmax && ymin < ymax ) cout << ((xmax-xmin)*(ymax-ymin)) << endl;
  else cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 384
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b;
  if (a <= b) {
    rep(i, b) cout << a;
  } else {
    rep(i, a) cout << b;
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	x, n := scanInt(), scanInt()
	p := scanInts(n)
	answer := nearest(x, p)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func nearest(x int, p []int) int {
	if notIn(x, p) {
		return x
	}
	sort.Ints(p)
	for i := 1; ; i++ {
		if notIn(x-i, p) {
			return x - i
		}
		if notIn(x+i, p) {
			return x + i
		}
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func notIn(x int, a []int) bool {
	for i := 0; i < len(a); i++ {
		if x == a[i] {
			return false
		}
	}
	return true
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

  if(b == "A") cout << "T" << endl;
  if(b == "G") cout << "C" << endl;
  if(b == "C") cout << "G" << endl;
  if(b == "T") cout << "A" << endl;
  return 0;
}


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

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= (i+1);
    }

    sort(a.begin(), a.end());
    long long int rec = a[n/2];
    
    long long int sum = 0;
    for(int i=0; i<n; i++){
        sum += abs(a[i] - rec);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <map>
#include <sstream>
#define ll long long
using namespace std;
// ver..(1.1)
string ent="\n";
string space=" ";
int main(){
   	ios_base::sync_with_stdio(false);
      string s,t;
      cin >> s >> t;

      cout << t+s << ent;   	
}
/*


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1005,INF=1000000001;

struct query{
    string kind;
    int id;
    int want;
    int see;
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<query> S(N);
        
        for(int i=0;i<N;i++){
            cin>>S[i].kind;
            if(S[i].kind=="W"){
                cin>>S[i].id>>S[i].want;
            }else if(S[i].kind=="D"){
                cin>>S[i].id;
            }else{
                cin>>S[i].see;
            }
        }
        
        map<int,set<pair<int,int>>> MA;
        MA[-1].insert({0,INF});
        
        for(int i=0;i<N;i++){
            if(S[i].kind=="W"){
                for(auto it=MA[-1].begin();S[i].want&&it!=MA[-1].end();){
                    int a=(*it).first,b=(*it).second;
                    if(b-a<=S[i].want){
                        S[i].want-=(b-a);
                        it=MA[-1].erase(it);
                        MA[S[i].id].insert({a,b});
                    }else{
                        MA[S[i].id].insert({a,a+S[i].want});
                        it=MA[-1].erase(it);
                        MA[-1].insert({a+S[i].want,b});
                        S[i].want=0;
                    }
                }
            }else if(S[i].kind=="D"){
                for(auto it=MA[S[i].id].begin();it!=MA[S[i].id].end();){
                    int a=(*it).first,b=(*it).second;
                    MA[-1].insert({a,b});
                    it=MA[S[i].id].erase(it);
                }
            }else{
                bool ok=false;
                for(auto ii=MA.begin();ii!=MA.end();ii++){
                    int aa=(*ii).first;
                    
                    for(auto it=MA[aa].begin();it!=MA[aa].end();it++){
                        int a=(*it).first,b=(*it).second;
                        if(a<=S[i].see&&S[i].see<b){
                            cout<<aa<<endl;
                            ok=true;
                            break;
                        }else if(S[i].see<a) break;
                    }
                    
                    if(ok) break;
                }
            }
        }
        cout<<endl;
    }
}





Measured memory_bytes: 4096
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	//input = input.split("\n");
	tmp = input.split("");
	//文字列から10進数に変換するときはparseIntを使います
	var count=0;
	for (var i=0;i<tmp.length;i++){
		if(tmp[i]==1) count++;
	}
	//出力
	console.log(count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve(){
    int n;
    cin >> n;
    vector<int> p(n), q(n), x(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];
    bool ff = true;
    REP(i, n) if(p[i] != q[i]) ff = false;
    if(ff) {
        cout << 0 << "\n";
        return;
    }
    REP(i, n) x[i] = i+1;
    vector<int> ans;
    int index = 0;
    do {
        index++;
        bool P = true, Q = true;
        REP(i, n) if(x[i] != p[i]) P = false;
        REP(i, n) if(x[i] != q[i]) Q = false;
        if(P || Q) ans.push_back(index);
    } while(next_permutation(ALL(x)));
    cout << ans[1] - ans[0] << "\n";
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;


int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }

  auto dist = [&](int i, int j) {
    int dx = x[i] - x[j];
    int dy = y[i] - y[j];
    return sqrt(dx*dx + dy*dy);
  }; 

  vector<int> p(n);
  rep(i ,n) p[i] = i;
  double len = 0;
  int cnt = 0;

  do {
    rep(i, n-1) {
      len += dist(p[i], p[i+1]);
    }
    cnt++;
  } while (next_permutation(p.begin(), p.end()));
  
  double ans = len/cnt;
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,cnt=0;
	cin>>n;
	while(n)
	{
		if(n%10==7)
		   cnt++;
		n/=10;
	}
	if(cnt==0)
	    cout<<"No"<<endl;
	else
	    cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
	int n;
	int debt;
	int i;
	
	scanf("%d", &n);
	debt = 100000;
	for (i = 0; i < n; i++) {
		debt *= 1.05;
		if (debt % 1000 != 0) {
			debt /= 1000;
			debt += 1;
			debt *= 1000;
		}
	}
	printf("%d\n", debt);
	return (0);
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

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

int main()
{
    ll m, n;
    cin >> n >> m;
    rep(i, m) {
        ll input;
        cin >> input;
        n -= input;
    }
    cout << max(n, -1ll) << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


ll a[100009];


int main() {
	
	ll N;
	ll an = 0;
	cin >> N;

	rep(i,N) {
		ll k;
		cin >> k;
		if (k > 100000)an++;
		else {
			a[k]++;
		}
	}
	rep(i, 100009) {
		if (a[i] <i) {
			an += a[i];
		}
		else {
			an += a[i] - i;
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin >> N;
  ll a[5];
  for(int i=0;i<5;i++) cin >> a[i];

  ll mn = *min_element(a,a+5);
  ll ans = (N + mn - 1) / mn;
  ans += 4;

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


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

using ll = long long;

int main() {
    int N; ll x;
    cin >> N >> x;

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

    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ll dec1 = max(0LL, a[i] - x);
        ans += dec1;
        a[i] -= dec1;
        ll dec2 = max(0LL, (a[i + 1] + a[i]) - x);
        ans += dec2;
        a[i + 1] -= dec2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024