akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    int sum = 0;
    vector<int> W(N);
    for(int i=0; i<N; i++) {
        cin >> W[i];
        sum += W[i];
    }

    int a = 0, ans = INF;
    for(int i=0; i<N-1; i++) {
        a += W[i];
        sum -= W[i];
        ans = min(ans, abs(a - sum));
    }
    cout << ans << endl;
    return 0;
}


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

int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0) {if(a<b) swap(a,b); a = a%b;} return max(a,b);
}

int main(){
  string s;
  cin >> s;
  int ans = 1;
  if(s=="SUN") ans = 7;
  if(s=="MON") ans = 6;
  if(s=="TUE") ans = 5;

  if(s=="WED") ans = 4;
  if(s=="THU") ans = 3;
  if(s=="FRI") ans = 2;

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

Measured memory_bytes: 256
(defun compare (la lb)
  (mapcar (lambda (a b) (= a b)) la lb))

(defun main ()
  (let* ((n (read))
         (la (loop :repeat n
                   :for x = (read)
                   :collect x))
         (lb (sort (copy-list la) #'<))
         (lx (count nil (compare la lb))))
    (format t "~A~%" (if (<= lx 2) 'YES 'NO))))

(main)

Measured memory_bytes: 15840
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

val mod = (1e9 + 7).toLong()
val fact = Array((2e6 + 2).toInt()) { 1L }
fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val r1 = sc.nextInt()
    val c1 = sc.nextInt()
    val r2 = sc.nextInt()
    val c2 = sc.nextInt()

    for (i in 2 until fact.size) fact[i] = (i * fact[i - 1]) % mod

    var ans = C(r1, r1 + c1)
    for(r in r1 + 1..r2) ans = (ans + C(r, r +c2)) % mod
    for(c in c1 + 1..c2) ans = (ans + C(c, r2 +c)) % mod

    println(ans)
}

fun C(k: Int, n: Int): Long {
    var res = (fact[n] * inv(fact[n - k])) % mod
    res = (res * inv(fact[k])) % mod
    return res
}

fun inv(x: Long): Long = pow(x, mod - 2)
fun pow(a: Long, x: Long): Long {
    var a = a
    var x = x
    var res = 1L
    while (x > 0) {
        if (x % 2 == 1L) res = (res * a) % mod
        a = (a * a) % mod
        x /= 2
    }
    return res
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 108704
import java.io.*;
import java.util.*;

public class Main{

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		strA = sc.next().toCharArray();
		strB = sc.next().toCharArray();
		int n = strA.length - 1;
		int m = strB.length - 1;
		memo = sc.nextInt2DArr(n + 1, m + 1, -1);
		dp(n, m);
		System.out.println(trace(n, m));

		pw.close();
	}

	static char[] strA, strB;
	static int[] memo[];

	static int dp(int x, int y) {
		if (x == -1 || y == -1)
			return 0;
		if (memo[x][y] != -1)
			return memo[x][y];
		if (strA[x] == strB[y])
			return memo[x][y] = 1 + dp(x - 1, y - 1);

		return memo[x][y] = max(dp(x - 1, y), dp(x, y - 1));

	}

	static String trace(int x, int y) {
		if (x == -1 || y == -1)
			return "";
		if (strA[x] == strB[y]) {

			return trace(x - 1, y - 1) + strA[x];
		} else if (dp(x - 1, y) >= dp(x, y - 1)) {

			return trace(x - 1, y);
		} else

			return trace(x, y - 1);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public int[] nextIntArr(int n) throws IOException {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public int[] nextIntArr(int n, int f) throws IOException {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = f;
			}
			return arr;
		}

		public int[][] nextInt2DArr(int n, int m) throws IOException {
			int arr[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < m; k++) {
					arr[i][k] = nextInt();
				}
			}
			return arr;
		}

		public int[][] nextInt2DArr(int n, int m, int f) throws IOException {
			int arr[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < m; k++) {
					arr[i][k] = f;
				}
			}
			return arr;
		}

		public String[] nextStringArr(int n) throws IOException {
			String arr[] = new String[n];
			for (int i = 0; i < n; i++) {
				arr[i] = next();
			}
			return arr;
		}

		public char[] nextCharArr(int n) throws IOException {
			char arr[] = new char[n];
			for (int i = 0; i < n; i++) {
				arr[i] = next().charAt(0);
			}
			return arr;
		}

	}

	public static int max(int a, int b) {
		return a > b ? a : b;
	}

	public static int min(int a, int b) {
		return a < b ? a : b;
	}
}

Measured memory_bytes: 81640
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

#define int long long
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        int ans = INFL;
        int f = 1;
        rep(i, 2) {
                int sum = 0, now = 0;
                rep(i, n) {
                        sum += a[i];
                        if (f == 1 && sum <= 0) {
                                now += -sum + 1;
                                sum = 1;
                        } else if (f == -1 && sum >= 0) {
                                now += sum + 1;
                                sum = -1;
                        }
                        f *= -1;
                }
                amin(ans, now);
                f = -1;
        }
        cout << ans << endl;
        return 0;
}               



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(int, char**) {
  string s;
  cin >> s;
  string x;
  for (int i = 0; i < s.size(); ++i) {
    x.push_back('x');
  }
  cout << x;

  return 0;
}

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


int main()
{
    int N,K;
    double ans = 0;
    cin>>N>>K;
    
    vector<double> p(N,0);
    vector<double> s(N,0);
    for(int i=0;i<N;i++)
    {
        int inc;
        cin>>inc;
        p[i] +=(double) (1+inc)/2;    
    }

    s[0] = p[0];
    for(int i = 1;i<N;i++)
    {
        s[i] = p[i] + s[i-1];
    }


    for(int i=K-1;i<N;i++)
    {
        double check = 0;
        if(i==K-1)check = s[i];
        else check = s[i]-s[i-K];
        
        if(ans<check)ans = check;
    }

    

    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(int argc,char** argv){
  string S;
  string T;
  cin >> S;
  cin >> T;
  bool flag = false;

  for(int i = 0; i < S.length() ; i++){
    char s = S[S.length() - 1];
    S.pop_back();
    S = s + S;
    if(S == T){
      flag = true;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
l = raw_input().split()
A = int(l[0])
B = int(l[1])
C = int(l[2])
X = int(l[3])
Y = int(l[4])

cost = 0

if A+B <= 2*C:
    cost = A * X + B * Y
else:
    if X  == Y:
        cost = 2 * C * X
    elif X > Y:
        if A <= C  * 2:
            cost = 2 * C * Y + A * ( X -  Y )
        else:
            cost  = 2 * C * X
    else:
        if B <= C * 2:
            cost = 2 * C * X + B * ( Y - X )
        else:
            cost = 2 * C * Y

print(cost)


Measured memory_bytes: 2696
import collections

n = int(input())
ss = []
for i in range(n):
    s = input()
    ss.append(s)

tmp = collections.Counter(ss).most_common()
target = tmp[0][1]
anss = []
for i in tmp:
    if i[1] == target:
        anss.append(i[0])
    else:
        break
anss = sorted(anss, key=str.lower)
print(*anss)


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){

   

    ll n;
    cin>>n;
    ll c=n/500;
    ll r=n%500;
    ll d=r/5;
    pt((c*1000)+(d*5));
    
    
    

}


/*

// 

*/

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> vec{A,B,C};
  sort(RALL(vec));
  int D;
  D = vec[0]-vec[2];
  cout << D << endl;
  return 0;
}


Measured memory_bytes: 256
//package problem2;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main (String args[]) {

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		//変数宣言
		int input_text_n = Integer.parseInt(scan.nextLine());
		String length = scan.nextLine();
		String[] each_length = length.split(" ");
//		int ans = 0;
		int all_length =0;

		//成立条件
		all_length = triangle_satisfacted_condition(input_text_n,each_length);

//		//combinationの計算
//		if(all_length > 3) {
//			ans = factorialMethod(all_length)
//					/ (6 * factorialMethod(all_length - 3));
//		}
//		else {
//		}

		System.out.println(all_length);
	}

	private static int triangle_satisfacted_condition
	(int input_text_n,String[] pre_length) {
		int all_length = 0;
		int each_length[] = new int[pre_length.length];

		for(int i = 0 ; i < pre_length.length ; i++) {
			each_length[i] = Integer.parseInt(pre_length[i]);
		}
		Arrays.parallelSort(each_length);

		for(int i = 0; i < input_text_n; i++) {
			for(int j = i + 1; j < input_text_n; j++) {
				if(each_length[i]== (each_length[j])) {
					continue;
				}
				for(int k = j+1 ; k < input_text_n; k++) {
					if(( each_length[i]==(each_length[k]))
						||( each_length[j]==(each_length[k]))) {
						continue;
					}
					if(! triangle_condition(each_length[i],each_length[j],each_length[k])) {
						continue;
					}
					all_length ++;
				}
			}
		}
		return all_length;
	}

	private static boolean triangle_condition(int i,int j,int k) {
//		System.out.print(i +" " + j + " "+ k+ " ");
//		if(Integer.parseInt(k) < Integer.parseInt(i) + Integer.parseInt(j)) {
//			System.out.println("OK");
//		}else {
//			System.out.println("");
//		}
		return(k < i + j);
	}

//	private static int factorialMethod(int num) {
//		//階乗の結果を格納
//		int factorial = 1;
//
//		//階乗の計算
//		for (int i = 1; i <= num; i++) {
//			factorial = factorial * i;
//		}
//
//		return factorial;
//	}
}


Measured memory_bytes: 36524
n = int(input())
c = [0 for _ in range(n-1)]
s = [0 for _ in range(n-1)]
f = [0 for _ in range(n-1)]
for i in range(n-1):
    c[i], s[i], f[i] = [int(_) for _ in input().split()]

for i in range(0, n-1):
    j = i
    t = s[j]
    while (j != n-2):
        t += c[j]
        j += 1
        if t < s[j]:
            t = s[j]
        elif t % f[j] != 0:
            t += (f[j] - (t % f[j]))
    t += c[j]
    print(t)
print(0)



Measured memory_bytes: 3188
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll A, B, C; cin >> A >> B >> C;
    if(A%2 == 1 || B%2 == 1 || C%2 == 1){
        cout << 0 << endl; return 0;
    }
    
    ll bt1 = abs(A-B);
    ll bt2 = abs(B-C);
    
    ll tmp1 = 0;
    while(bt1 % 2 == 0 && bt1 > 0){
        bt1 /= 2; tmp1++;
    }
    ll tmp2 = 0;
    while(bt2 % 2 == 0 && bt2 > 0){
        bt2 /= 2; tmp2++;
    }
    
    if(bt1 == 0 && bt2 == 0){
        cout << -1 << endl;
    }
    else{
        cout << min(tmp1, tmp2) << endl;
    }
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end() 
#define DESC(vec) vec.rbegin(), vec.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i]; 
#define ANS(s) cout << s << endl;
#define inc(a, b) cin >> a >> b;

int main(){
	string tamesi;
	int tamesi2 = 0;
	cin>>tamesi;
	for (int i = 0; i < tamesi.size(); i++) {
		if((i%2)==0){
				if((tamesi[i]=='R')||tamesi[i]=='U'||tamesi[i]=='D'){
						tamesi2 += 1;
				}
		}
		else{
				if(tamesi[i]=='L'||tamesi[i]=='U'||tamesi[i]=='D'){
						tamesi2 += 1;
				}
		}
	}
	if (tamesi2==tamesi.size()) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

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

int main(void) {

  int N;
  while(cin >> N){
    if( N == 0 ) break;
    vector<int> x(N, 0);
    vector<int> y(N, 0);
    int n, d;
    for(int i=1; i<N; i++){
      cin >> n >> d;
      x[i] = x[n] + dx[d];
      y[i] = y[n] + dy[d];
    }

    int X = *max_element(x.begin(), x.end()) - *min_element(x.begin(), x.end());
    int Y = *max_element(y.begin(), y.end()) - *min_element(y.begin(), y.end());
    cout << X + 1 << " " << Y + 1 << endl;
  }

  return 0;
}

// EOF

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

int main() {
  int N, A;
  cin >> N >> A;
  if (A >= 499) {
    cout << "Yes" << endl;
  }
  else {
    if (A >= (N % 500)) {
      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)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N, K;
  cin >> N >> K;
  char S[N];
  REP(i, N) cin >> S[i];
  int count = 0;
  char id = S[0];
  int ans = 0;
  REP(i, N-1) {
    if (count < K) {
      if (S[i] != id && S[i+1] == id) {
        count++;
      }
      ans++;
    } else {
      if (S[i] == S[i+1]) ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, k;
    ll a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}

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

int main() {
    string w,t;
    int count=0;
    cin >> w;
    while(cin >> t){
        if(t =="END_OF_TEXT") break;
        for(string::size_type i = 0; i < t.size(); ++i){
            t[i] = tolower(t[i]);
        }
        if (t == w){ count++;
        }
    }
    cout << count << endl;
    return 0;
}

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


int main (){
    int N,Y;
    cin >> N >> Y;
    int T=Y%5000;
    int t=T/1000;
    int res10000=-1,res5000=-1,res1000=-1;
    for(int i=t;i<=N;i+=5){
        for(int j=0;j<=N-i;j++){
            int k=N-i-j;
            int sum=k*10000+j*5000+i*1000;
            if(sum==Y){
                res10000=k;
                res5000=j;
                res1000=i;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}



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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n;
    cin>>n;
    char s[n];
    int w=0;
    for(i=1;i<=n;i++){
    	cin>>s[i];
    	if(s[i]=='W') w++;
	}
	int ans=w;
	for(i=n;i>n-w;i--){
		if(s[i]=='W') ans--;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3796
n = int(input())
a = [int(item) for item in input().split()]
a_sorted = sorted(a)

def can_be_midofmid(b):
    high_low_cum = [0] * (n + 1)
    for i, item in enumerate(a):
        if item >= b:
            high_low_cum[i+1] = 1
        else:
            high_low_cum[i+1] = -1
    for i in range(n):
        high_low_cum[i+1] += high_low_cum[i]
    bit_n = 1 << n.bit_length()
    bit = [0] * (bit_n+1)

    def bit_add(x, w):
        while x <= bit_n:
            bit[x] += w
            x += x & -x

    def bit_sum(x):
        ret = 0
        while x > 0:
            ret += bit[x]
            x -= x & -x
        return ret

    val = 0
    dic = dict(zip(sorted(high_low_cum), [item for item in range(len(high_low_cum))]))
    for i, item in enumerate(high_low_cum):
        val += bit_sum(dic[item] + 1)
        bit_add(dic[item] + 1, 1)
    return val  >= ((n+1) * n + 2)// 4  

l = -1; r = n
while r - l > 1:
    mid = (r + l) // 2
    if can_be_midofmid(a_sorted[mid]):
        l = mid
    else:
        r = mid
print(a_sorted[r-1])

Measured memory_bytes: 129468
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    A = []
    for _ in range(N):
        A.append(int(input()))
    A.sort()

    left_idx = 0
    right_idx = N - 1
    left = A[left_idx]
    right = A[right_idx]
    res = abs(right - left)
    left_idx += 1
    right_idx -= 1
    while left_idx <= right_idx:
        al = A[left_idx]
        ar = A[right_idx]
        dl = max(abs(al - left), abs(al - right))
        dr = max(abs(ar - left), abs(ar - right))
        if dl < dr:
            if abs(ar - left) < abs(ar - right):
                res += abs(ar - right)
                right = ar
            else:
                res += abs(ar - left)
                left = ar
            right_idx -= 1
        else:
            if abs(al - left) < abs(al - right):
                res += abs(al - right)
                right = al
            else:
                res += abs(al - left)
                left = al
            left_idx += 1

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47192
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N, K;
    cin >> N >> K;
    vector<bool> have(N, false);
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int A;
            cin >> A;
            have[A-1] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (!have[i]) {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int x;
    cin >> x;
    --x;
    V.emplace_back(x,i+1);
  }
  sort(V.begin(), V.end());
  vector<int> A(N*N,-1);
  int l = 0;
  for(auto p : V){
    for(int i = 1; i < p.second; ++i){
      while(A[l] >= 0) ++l;
      A[l] = p.second;
    }
    if(l > p.first){
      cout << "No" << endl;
      return 0;
    }
    A[p.first] = p.second;
  }
  for(auto p : V){
    for(int i = 0; i < N-p.second; ++i){
      while(A[l] >= 0) ++l;
      if(l < p.first){
        cout << "No" << endl;
        return 0;
      }
      A[l] = p.second;
    }
  }
  cout << "Yes" << endl;
  for(int i = 0; i < N*N; ++i){
    cout << A[i];
    if(i+1 < N*N) cout << " ";
    else cout << endl;
  }
}


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

int main(){
	ll  n,m;cin>>n>>m;
	ll sum=0;
	for(ll i=0;i<m;i++){
		ll x;cin>>x;
		sum+=x;
	}
	ll ans=n-sum;
	if(ans>=0)
	cout<<ans<<endl;
	else
	cout<<"-1"<<endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <ctime>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)

using namespace std;

const int N = 100010;

int cnt[N], n;

int main(){
	scanf("%d", &n);
	For(i, 1, n){
		int u;
		scanf("%d", &u);
		For(j, -1, 1) cnt[u + j + 5]++;
	}
	int ans = 0;
	For(i, 1, N - 1) ans = max(ans, cnt[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int a[3][3];
  rep(i,3) rep(j,3){
    cin >> a[i][j];
  }
  int n; cin >> n;
  vector<int> b(n);
  rep(i,n) cin >> b[i];

  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(b[i]==a[j][k]) a[j][k]= -1;
      }
    }
  }

  rep(i,3){
    int cnt=0;
    rep(j,3){
      if(a[i][j]==-1) cnt++;
    }
    if(cnt==3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  rep(j,3){
    int cnt=0;
    rep(i,3){
      if(a[i][j]==-1) cnt++;
    }
    if(cnt==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  int tmp = 0;
  rep(i,3){
    if(a[i][i]==-1){
      tmp++;
    }
  }

  if(tmp==3){
    cout << "Yes" << endl;
    return 0;
  }

  if(a[0][2]==-1 && a[1][1]== -1 && a[2][0]== -1){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
k,s = map(int,input().split())
x=y=z=0
count = 0
for i in range(min(k,s)+1):
  for j in range(min(k,s)+1):
    z = s-x-y
    if 0 <= z <= k:
      count += 1
    y += 1
  y = 0
  x +=1
print(count)


Measured memory_bytes: 2940
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright © 2017年 Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

int main(void) {
    long long Q, H, S, D, N;

    cin >> Q >> H >> S >> D >> N;
    
    N = N*1000;
    
//    long long x[3][4] = {
//        {0.25, 0.5, 1.0, 2.0}, //リットル
//        {Q, H, S, D}, //価格
//        {Q/0.25, H/0.5, S/1.0, D/2.0} //リットル当たり単価 これが一番小さいやつから買えばよい
//    };

//    long long x[4][3] = {
//        {0.25, Q, Q/0.25},
//        {0.5, H, H/0.5},
//        {1.0, S, S/1.0},
//        {2.0, D, D/2.0}
//    };

    
    //後で第３要素をキーにソートできるようにするために、二次元配列をarrayで実現
    //またlong longで扱えるようにするためにリットルをミリリットル表記で表現する
    array<long long,4> data[] = {                                                                  //★★★★★★★★★★★★★★★★★★★★
        {250, Q, Q*4*2, 0}, //リットル、価格、"2"リットル当たり単価、購入すべき個数
        {500, H, H*2*2, 0},
        {1000, S, S*2, 0},
        {2000, D, D, 0}
    };

//    //display data[][]
//    cout << endl;
//    for(int i=0; i<4; i++) {
//        for(int j=0; j<4; j++) {
//            cout << data[i][j] << "  ";
//        }
//        cout << endl;
//    }
//    
    
    //単価をキーにして、安い順にソート
    sort(&data[0], &data[4], [](array<long long,4>& x, array<long long,4>& y){return x[2] < y[2];} ); //★★★★★★★★★★★★★★★★★★★★
    
    
//    //display data[][]
//    cout << endl;
//    for(int i=0; i<4; i++) {
//        for(int j=0; j<4; j++) {
//            cout << data[i][j] << "  ";
//        }
//        cout << endl;
//    }
//    
    
    //合計がNとなるように適切な分だけ購入
    long long sum = 0;
    long long cost = 0;
    
    for(int i=0; i<4; i++) {
        while( sum + data[i][0] <= N ) {
                sum += data[i][0];
                cost += data[i][1];
                data[i][3]++;
        }
    }
    

//    //display data[][]
//    cout << endl;
//    for(int i=0; i<4; i++) {
//        for(int j=0; j<4; j++) {
//            cout << data[i][j] << "  ";
//        }
//        cout << endl;
//    }
//    
    //display cost
    cout << cost << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if (h == 0 and w == 0):
        break
    for i in range(h):
        if (i % 2 == 0):
            print("#."*(w//2) + "#"*(w%2))
        elif (i % 2 == 1):
            print(".#"*(w//2) + "."*(w%2))
    print()


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        if(i<k)
            continue;
        if(arr[i] > arr[i-k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int g[n][n] = {};
	for(int i = 0;i < n; ++i){
		int x;
		cin >> x;
		int p,v;
		while(x--){
			cin >> p >> v;
			--p;
			g[i][p] = (v==1?1:-1);
		}
	}
	int ans = 0;
	for(int i = 0;i < (1 << n); ++i){
		bool val = true;
		for(int j = 0;j < n; ++j){
			if((i >> j) & 1){
				for(int k = 0; k < n; ++k){
					if(g[j][k] == 1 && ((i >> k) & 1) == 0)val = false;
					if(g[j][k] == -1 && ((i >> k) & 1) == 1)val = false;
				}
			}
		}
		if(val)ans = max(ans, __builtin_popcount(i));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#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--)
#define ALL(a) (a).begin(),(a).end()
#define pb(a) push_back(a)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define INF 999999999

using namespace std;

int main(){
  double a,b;
  cin >> a;
  cin >> b;
  if (a>b){
    cout << "GREATER" <<endl;
  } else if (a<b){
    cout << "LESS" << endl;
  } else if (a==b){
    cout <<"EQUAL"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
# A - Frog 1

# change minimum 
def chmin(a, b):
    # a より b の方が小さいとき
    if (a > b):
        return b
    return a

# 無限大の値
INF = 10**10

N = int(input())
h = list(map(int,input().split()))

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

# ループ
for v in range(1,N):
    # 1つ前の足場から遷移するとき
    dp[v] = chmin(dp[v], dp[v-1] + abs(h[v] - h[v-1]))
    if v > 1:
        # 2つ前の足場から遷移するとき
        dp[v] = chmin(dp[v], dp[v-2] + abs(h[v] - h[v-2]))

print(dp[N-1])

Measured memory_bytes: 20428
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            map.put(num, i);
        }
        if (n == 1) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        long cnt = 1;
        for (Integer key = 2; key <= n; key++) {
            if (map.get(key - 1) <= map.get(key)) {
                cnt++;
            } else {
                cnt = 1;
            }
            ans = Math.max(cnt, ans);
        }
        System.out.println(n - ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;

int cost [] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
const int MAX { 10010 };

string dp[MAX];

bool less_than(const string& x, const string& y)
{
    if (x.size() < y.size())
        return true;

    if (x.size() > y.size())
        return false;

    return x < y;
}

string solve(int N, const vector<int>& as)
{
    dp[0] = "";
 
    for (int i = 1; i <= N; ++i)
    {
        dp[i] = "-1";

        for (auto a : as)
        {
            if (cost[a] > i)
                continue;

            if (dp[i - cost[a]] == "-1")
                continue;

            char c = a + '0';
            string m = c + dp[i - cost[a]];
//cout << "i = " << i << ", c = " << c << ", dp[" << i << "] = " << dp[i] << ", m = " << m << '\n';
            if (dp[i] == "-1" or less_than(dp[i], m))
                dp[i] = m;
        }
    }

//    for (int i = 1; i <= 10; ++i)
//        cout << "dp[" << i << "] = " << dp[i] << '\n';

    return dp[N];
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<int> as(M);

    for (int i = 0; i < M; ++i)
        cin >> as[i];

    auto ans = solve(N, as);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 32512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace a
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {

                var ab = line.Split().Select(int.Parse).ToArray();
                int a = ab[0];
                int b = ab[1];
                if ((a + b) / 1000000 >= 1)
                    Console.WriteLine("7");
                else if ((a + b) / 100000 >= 1)
                    Console.WriteLine("6");
                else if ((a + b) / 10000 >= 1)
                    Console.WriteLine("5");
                else if ((a + b) / 1000 >= 1)
                    Console.WriteLine("4");
                else if ((a + b) / 100 >= 1)
                    Console.WriteLine("3");
                else if ((a + b) / 10 >= 1)
                    Console.WriteLine("2");
                else if ((a + b) / 1 >= 1)
                    Console.WriteLine("1");


            }
        }
    }
}

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

const int P = 1e9 + 7;
int dp[44][2010];
int a[44], C[2010][2010];

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= K; ++i) cin >> a[i];
    C[0][0] = 1;
    for (int i = 1; i <= max(N, K); ++i) {
        C[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < K; ++i) {
        for (int j = 0; j <= N; ++j) {
            for (int k = 0; k <= min(a[i + 1], N) ; ++k) {
                dp[i + 1][j + k] = (dp[i + 1][j + k] + (ll) dp[i][j] * C[N - j][k] % P * C[N - k][a[i + 1] - k] % P) % P;
            }
        }
    }
    cout << dp[K][N] << '\n';
    return 0;
}

Measured memory_bytes: 9744
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	int p=S.size();
	string a[S.size()];
	for (int i = 0; i < p; i++) {
		a[i] = "x";
	}
	for (int i = 0; i < p; i++) {
		cout << a[i];
	}
}


Measured memory_bytes: 256
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    
    c = []
    for i in range(n):
        c.append(tuple(map(int, f_i.readline().split())))
    
    c.sort()
    
    ans = (' '.join(map(str, c_i)) for c_i in c)
    print('\n'.join(ans))
    
    
solve()


Measured memory_bytes: 29592
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
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;
}
 */
/*-----Library-----*/
signed main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1])ans++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(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 MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int a,b,ta,tb,ta2;
    cin>>a>>b;
    ta=(a/2)*25+(a%2)*13;
    ta2=((a+1)/2)*25+((a+1)%2)*13;
    if(ta/10==b) cout<<ta;
    else if((ta2-1)/10==b) cout<<b*10;
    else cout<<-1;
    cout<<endl;
}

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

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    
    rep(i, s.size()){
        int j = i;
        int normal = 0;
        while(s[normal] == t[j] && normal < s.size()){
            if(j >= s.size()-1)j=0;
            else j++;
            normal++;
        }
        if(normal == s.size()){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(input())
A = list(map(int,input().split()))

d_sum = abs(A[0])+abs(A[-1])
for i in range(1, n):
    d_sum += abs(A[i-1]-A[i])

print(d_sum-abs(A[0])-abs(A[0]-A[1])+abs(A[1]))
for i in range(1, n-1):
    print(d_sum - abs(A[i-1]- A[i]) - abs(A[i] - A[i+1]) + abs(A[i-1]-A[i+1]))
print(d_sum-abs(A[-1])-abs(A[-1]-A[-2])+abs(A[-2]))

Measured memory_bytes: 14172
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int n, a[maxn], res;
ll dp[3]{0, INT_MAX, INT_MAX}, tmp[9];
void update(int dh, int h){
	fill(tmp, tmp+9, INT_MAX);
	if(dh > 0){
		for(int i = 0;i < 3;++i)
			tmp[i] = dp[i] + dh;
		for(int i = 1;i < 3;++i)
			tmp[i-1] = min(tmp[i-1], dp[i]);
		int p = 0;
		if(dp[2] == INT_MAX)++p, ++res;

		for(int i = 1;i < 3;++i)
			dp[i] = tmp[i - p];
	}
	else{
		for(int i = 0;i < 3;++i)
			tmp[i] = dp[i];
		for(int i = 1;i < 3;++i)
			tmp[i-1] = min(tmp[i-1], max(0ll, dp[i] + dh));
		for(int i = 0;i < 3;++i)
			dp[i] = tmp[i];
		for(int i = 0;i < 3;++i)
			if(dp[i] > h)dp[i] = INT_MAX;
	}
	return;
	for(int i = 0;i < 3;++i)
		cout << dp[i] << " \n"[i == 2];
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i)
		cin >> a[i];
	for(int i = 1;i <= n+1;++i)if(a[i] != a[i-1])
		update(a[i]-a[i-1], a[i]);
	for(int i = 1;i < 3;++i)if(dp[i] != INT_MAX)
		--res;
	cout << res << '\n';
}



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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A),b(B);
    for(auto & t :a) cin>>t;
    for(auto & t :b) cin>>t;
    int mi = *min_element(a.begin(),a.end()) + *min_element(b.begin(),b.end());
    for(int i=0;i<M;++i){
        int x,y,c;
        cin>>x>>y>>c;
        x--;y--;
        int tmp = a[x] + b[y] - c;
        mi = min(mi,tmp);
    }
    cout << mi << endl;
    
    return 0;
}

Measured memory_bytes: 1024
d,g = map(int, input().split())
point = [list(map(int,input().split())) for i in range(d)]

point = point[::-1]

ans = float("inf")
for bit in range(1<<d):
  total=0
  cnt=0
  for i in range(d):
    if (bit>>i)&1:
      total += (100*(d-i)*point[i][0]+point[i][1])
      cnt += point[i][0]
  if total >= g:
    ans = min(ans,cnt)
    continue
  for j in range(d):
    if (bit>>j)&1 == False:
      for k in range(point[j][0]):
        total += 100*(d-j)
        cnt += 1
        if total >= g:
          ans=min(ans,cnt)
          break
      break
print(ans)

Measured memory_bytes: 9136