akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <string>


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

  int h, w;
  std::cin >> h >> w;
  for (int i = 0; i < h; i++) {
    std::string s;
    std::cin >> s;
    std::cout << s << '\n' << s << '\n';
  }
  std::cout << std::flush;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7, INF = 1e9;
const int N = 100010;
int n;
ll sum = 0, Now = 0;
ll s[N * 40], sz[N * 40];
int tot = 0, rt, lf[N * 40], rf[N * 40];

void mdy(int &u, int l, int r, int x) {
	if(!u) u = ++tot; if(l >= r) { ++sz[u], s[u] += x; return ; }
	int mid = (l + r) >> 1;
	x <= mid ? mdy(lf[u], l, mid, x) : mdy(rf[u], mid + 1, r, x);
	s[u] = s[lf[u]] + s[rf[u]], sz[u] = sz[lf[u]] + sz[rf[u]];
}
int find(int u, int l, int r, int x) {
	if(l >= r) return l;
	int mid = (l + r) >> 1;
	if(sz[lf[u]] >= x) return find(lf[u], l, mid, x);
	return find(rf[u], mid + 1, r, x - sz[lf[u]]);
}
ll ask(int u, int l, int r, int x) {
	if(l >= r) return 0;
	int mid = (l + r) >> 1; ll ss = 0;
	if(x <= mid) {
		ss += s[rf[u]] - sz[rf[u]] * x;
		return ask(lf[u], l, mid, x) + ss;
	}
	ss += sz[lf[u]] * x - s[lf[u]];
	return ask(rf[u], mid + 1, r, x) + ss;
}
int main() {
	scanf("%d", &n);
	for(int opt; n; n--) {
		scanf("%d", &opt);
		if(opt == 1) {
			int x, y; scanf("%d%d", &x, &y);
			Now += y, mdy(rt, -INF, INF, x);
		}
		else {
			int x = find(rt, -INF, INF, (sz[rt] + 1) / 2);
			printf("%d %lld\n", x, Now + ask(rt, -INF, INF, x));
		}
	}
	return 0;
}

Measured memory_bytes: 45568
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("max.in","r",stdin);
   freopen("max.out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
ll a[N];
int main()
{
    //file();
    boos();
    ll k,n;
    cin >> k >> n;
    for(int i = 1;i <= n;i++)
    {
    	cin >> a[i];
	}
	ll ans = a[n] - a[1];
	for(int i = 1;i <= n;i++)
	{
		ans = min(ans,k - a[i] + a[i - 1]);
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int v;
	vector<int> vec;
	for (int i = 0; i < 3; i++) {
		cin >> v;
		vec.push_back(v);
	}
	int K;
	cin >> K;

	sort(vec.begin(), vec.end());
	for (int i = 1; i <= K; i++) {
		vec[2] *= 2;
	}
	v = vec[0] + vec[1] + vec[2];

	cout << v << endl;
	return 0;
}


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

int N, A[1<<17];

int main() {
	scanf("%d", &N);

	for (int i = 0; i < N; ++i) scanf("%d", A+i);
	sort(A, A + N);
	
	int mx = A[N-1];
	int b = -1, mnd = 2e9;
	for (int i = 0; i < N-1; ++i) {
		if (abs(A[i] * 2 - mx) < mnd) b = A[i], mnd = abs(A[i] * 2 - mx);
	}

	printf("%d %d\n", mx, b);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  int c = 0;
  cin >> n;
  REP(i, n)
  {
    int a;
    cin >> a;
    if (a % 2 == 1)
      c++;
  }
  if (c % 2 == 1)
  {
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var h=sc.Ia;
		var t=sc.S;
		var b=new bool[s[0]+1];
		long p=0;
		for(int i = 0;i<s[0];i++) {
			if(i>=s[1]&&t[i-s[1]]==t[i]&&!b[i-s[1]]){
				b[i]=true;
				continue;
			}
			if(t[i]=='r'){p+=h[2];}
			if(t[i]=='s'){p+=h[0];}
			if(t[i]=='p'){p+=h[1];}
		}
		Console.WriteLine("{0}",p);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13408
#include<stdio.h>
#define CAKE 4
#define DONUT 7

int main(void)
{
	//変数を定義
	int n, flag = 0;
	scanf("%d", &n);

	for (int i = 0; i <= 100 ;i++) {
		for (int j = 0; j <= 100 ; j++) {
			if (n == CAKE * i + DONUT * j) {
				flag++;
				break;
			}
			else if(n < CAKE * i + DONUT * j){
				break;
			}
		}
		if (n == CAKE * i) {
			flag++;
			break;
		}
		if (n == DONUT * i) {
			flag++;
			break;
		}
	}

	if (flag != 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}



Measured memory_bytes: 128
n, k = map(int, input().split())
if n - 1 < k:
    k = n-1
mod = 10**9+7
cmb1 = [1]*(n+1)
cmb2 = [1]*n
x = [0]*(n+1)
def Pow(a, n):
    if n == 0: return 1
    if n%2 == 0:
        return (Pow(a, n//2))**2%mod
    else:
        return Pow(a, n-1)*a%mod
for i in range(1,n+1):
    x[i] = Pow(i, mod-2)
for i in range(1,n+1):
    cmb1[i] = cmb1[i-1]*(n+1-i)%mod*x[i]%mod
for i in range(1,n):
    cmb2[i] = cmb2[i-1]*(n-i)%mod*x[i]%mod
ans = 0    
for i in range(k+1):
    ans = ((cmb1[i]*cmb2[i])%mod + ans)%mod
print(ans)

Measured memory_bytes: 56284
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20

a,b = list(map(int,input().split()))

for i in range(1,1001):
    if int(0.08*i)==a and int(0.1*i)==b:
        print(i)
        exit()

print(-1)

Measured memory_bytes: 5172
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String num = scan.nextLine();
		String[] numbers = num.split(" ");
		double A = Integer.parseInt(numbers[0]);
		double B = Integer.parseInt(numbers[1]);
		double C = Integer.parseInt(numbers[2]);
		double D = Integer.parseInt(numbers[3]);

		while(true) {
			C=C-B;
			if(C<=0) {
				break;
			}
			A=A-D;
			if(A<=0) {
				break;
			}
		}

		if(C<=0) {
			System.out.println("Yes");
		}
		if(A<=0) {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 35728
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,readline().split())
lst1 = []
for i in range(n):
    lst1.append(readline().rstrip().decode('utf-8'))

lst2 = []
for i in range(m):
    lst2.append(readline().rstrip().decode('utf-8'))

for i in range(n-m+1):
    for j in range(n-m+1):
        flag = 1
        for k in range(m):
            if lst1[i+k][j:j+m] != lst2[k]:
                flag = 0
        
        if flag:
            print("Yes")
            exit()
print("No")

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n;
    cin >> h >> n;
    ll total = 0;
    rep(i,n) {
        ll a;
        cin >> a;
        total += a;
        if (total >= h) {
            cout << "Yes" << endl;
            return 0; 
        }
    }
    cout << "No" << endl;
    return 0;
}

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


int main(){
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	int N=S.size();
	for(int i=0; i<N-1; i++){
		if(S[i]==S[i+1]){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
string S[1123456];
pair<int, int> pm[1123456];
bool used[1123456];

int main() {

	cin >> N;
	rep(i, N) cin >> S[i];

	rep(i, N) {
		int m = 0, c = 0;
		rep(j, S[i].size()) {
			if (S[i][j] == '(') c++;
			else c--;
			m = min(m, c);
		}
		int p = 0;
		c = 0;
		rep(j, S[i].size()) {
			if (S[i][S[i].size() - 1 - j] == '(') c--;
			else  c++;
			p = min(p, c);
		}
		pm[i] = { -p, -m };
	}


	int psum = 0, msum = 0;
	rep(i, N) {
		psum += pm[i].first;
		msum += pm[i].second;
	}
	if (psum != msum) {
		cout << "No" << endl;
		return 0;
	}

	int cnt = 0;
	rep(i, N) {
		if (pm[i].second == 0) {
			used[i] = true;
			cnt += pm[i].first;
		}
	}

	vector<pair<int, int>> p, m, l;

	rep(i, N) {
		if (used[i] == false) {
			if (pm[i].first - pm[i].second >= 0) {
				p.push_back(pm[i]);
			}
			else if (pm[i].first) {
				m.push_back(pm[i]);
			}
			else {
				l.push_back(pm[i]);
			}
		}
	}

	sort(all(p), [](auto a, auto b) {
		return a.second < b.second;
		});
	sort(all(m), [](auto a, auto b) {
		return a.second > b.second;
		});

	for (auto pp : p) {
		if (pp.second <= cnt) {
			cnt += pp.first - pp.second;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}

	for (auto mm : m) {
		if (mm.second <= cnt) {
			cnt += mm.first - mm.second;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 51272
import Data.Functor( (<$>))
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Control.Monad

main = do
    n <- read <$> getLine
    cards <- words <$> getLine
    let
	bubbleSort []	= []
	bubbleSort list = r:bubbleSort esult
	  where
	    r:esult = bubbleScan (reverse list) []

	    bubbleScan [x] l		= x:l
	    bubbleScan (x1:x2:xs) l
		|  x1!!1 < x2!!1	= bubbleScan (x1:xs) (x2:l) 
		| otherwise		= bubbleScan (x2:xs) (x1:l)

	bsorted = bubbleSort cards

    putStrLn $ unwords bsorted
    putStrLn "Stable"
    a <- newListArray (0,n-1) cards		::IO (IOArray Int String)
    let
	selectionScan i_
	  = do
	    let
		searchMinIx::String -> Int -> Int -> IO Int
		searchMinIx nowMin ixNowMin iterator
		  | n <= iterator		    = return ixNowMin
		  | otherwise
		    = do
			v <- readArray a iterator
			if v!!1 < nowMin!!1
			then searchMinIx    v	iterator (iterator+1)
			else searchMinIx nowMin ixNowMin (iterator+1)

		swap::Int -> Int -> IO ()
		swap i j = do
		    temp <- readArray a i
		    writeArray a i =<< readArray a j
		    writeArray a j temp

	    startmin <- readArray a i_
	    ixmin <- searchMinIx startmin i_ i_
	    swap i_ ixmin
    
    forM_ [0..n-1] selectionScan
    ia <- freeze a  ::IO (Array Int String)
    let
	ssorted = elems ia

    putStrLn $ unwords ssorted
    putStrLn $ if ssorted == bsorted
		then "Stable"
		else "Not stable"



Measured memory_bytes: 4148
# coding: utf-8
count = {x+1: 0 for x in range(4)}
for _ in range(3):
    a, b = list(map(int, input().split()))
    count[a] += 1
    count[b] += 1
if 3 in count.values():
    print('NO')
else:
    print('YES')


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e;i++)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

int main() {
    int n; cin >> n;
    ll a[n]; fore(i, 0, n) cin >> a[i];
    vector<int> d, dd;
    for(int i = 1; i * i <= a[0]; i++) {
        if(a[0] % i == 0) {
            if(i * i != a[0]) d.pb(a[0] / i);
            d.pb(i);
        }
    }
    for(int i = 1; i * i <= a[1]; i++) {
        if(a[1] % i == 0) {
            if(i * i != a[1]) dd.pb(a[1] / i);
            dd.pb(i);
        }
    }
    int r1 = 0;
    for(auto x : d) {
        int f = 0;
        fore(i, 1, n) f += ((a[i] % x) != 0);
        if(f < 2) r1 = max(r1, x);
    }
    int r2 = 0;
    for(auto x : dd) {
        int f = 0;
        fore(i, 0, n) f += ((a[i] % x) != 0);
        if(f < 2) r2 = max(r2, x);
    }
    // cout << r1 << " " << r2 << endl;
    cout << max(r1, r2) << endl;
    return 0;
}

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

int main(){
	int n,t;
	cin >> n >> t;
	int start = 0, active = t;
	long long duration=t;
	while(n--){
		int temp;
		cin >> temp;
		if(temp<active){
			duration += temp-start;
			start = temp;
			active = temp + t;
		}
		else{
			duration+= t;
			start = temp;
			active = temp+t;}

	}
	cout << duration;
}


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

#define N 200000

int n, k;
int a[N];

int main()
{
	int ans = 0;

	cin >> n >> k;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}

	map< int, int> cnt;
	for( int i = 0; i < n; i++ ) {
		cnt[ a[i] ]++;
	}

	vector<int> v;
	for( auto it = cnt.begin(); it != cnt.end(); it++ ) {
		v.push_back( it->second );
	}
	sort( v.begin(), v.end() );

	int kk = v.size();
	if( kk > k ) {
		int nn = kk - k;
		for( int i = 0; i < nn; i++ ) {
			ans += v[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11516
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b;
    char c;

    cin >> a >> c >> b;

    if(c == '+'){
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<deque>
#include<vector>
#include<math.h>
#include<iomanip>

#define pi 3.141592653
#define in freopen("entrada","r",stdin);
#define ii pair<int,int> 
 
using namespace std;

typedef long long ll;	
 
typedef long double ld;

typedef unsigned long long ull;
		
 
const int maxn = 2e5 + 100;
const int MAX = 4e2;


using namespace std;




int vis[maxn], n , m , an[maxn];

vector<int>  g[maxn],  resp;

inline void add (int a, int b  ){
 g[a].push_back( b );
 g[b].push_back( a);
}

void bfs ( int start ){
 queue <int> q;
 
 q.push ( start);
 vis[start] = true;
 n-=1;
 
 while ( !q.empty()) {
  int u = q.front(); q.pop();
  for(int j = 0;j < (int)g[u].size();j++) {
   int v = g[u][j];
   if ( !vis[v] ) {
    n-=1;
    an[v] = u;
    
    q.push ( v);
    vis[v] = true;
   }
  }
 }
}

int main () {
 
 //~ in
 
 scanf("%d %d",&n,&m);
 int _vert = n;
 
 for(int i = 0 ;i < m;i++) {
  int a,b ;
  scanf("%d %d",&a,&b);
  add ( a, b);
 }
 
 bfs ( 1 );
 
 if (n == 0 ) {
  printf("Yes\n");
  for(int i = 2 ;i <= _vert ;i++) {
   printf("%d\n", an[i]);
  }
  printf("\n");
 }else  {
  printf ("No\n");
 }
 
 return 0;
}


Measured memory_bytes: 12716
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
	input = input.split(' ');
	var a1 = toInt(input[0]);
	var a2 = toInt(input[1]);
	var b1 = toInt(input[2]);
	var b2 = toInt(input[3]);
	var ans = max(min(a2,b2) - max(a1,b1),0);
	console.log(ans);
}



Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> s(n + 1);
    rep(i, n) s[i + 1] = s[i] + a[i];
    map<ll, ll> mp;
    rep(i, n + 1) mp[s[i]]++;
    ll ans = 0;
    for (auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
N = gets.to_i
S = gets.chomp

ans = 0
st = [[3, 0]]
while !st.empty?
  n, offset = st.pop
  if n == 0
    ans += 1
    next
  end
  (?0..?9).each{|c|
    idx = S.index(c, offset)
    next if idx.nil?
    st << [n-1, idx + 1]
  }
end

p ans

Measured memory_bytes: 1788
#include <stdio.h>

int main(){
    int w = 1, sum;

    while(1){
        scanf("%d", &w);
        if(w == -1)break;
        sum = 0;
        if(w > 30){
            sum = 3800 + (w-30)*160;
        }else if(w > 20){
            sum = 2400 + (w-20)*140;
        }else if(w > 10){
            sum = 1150 + (w-10)*125;
        }else{
            sum = 1150;
        }

        printf("%d\n", 4280 - sum);
    }
    return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
H = list(map(int, input().split()))
Hi = [1]*N
AB = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    if H[AB[i][0]-1] == H[AB[i][1]-1]:
        Hi[AB[i][1]-1] = 0
        Hi[AB[i][0]-1] = 0
    elif H[AB[i][0]-1] > H[AB[i][1]-1]:#dictにするか？
        Hi[AB[i][1]-1] = 0
    elif H[AB[i][0]-1] < H[AB[i][1]-1]:
        Hi[AB[i][0]-1] = 0
print(sum(Hi))

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ok = true;
    if (a == b && a != c) {
        ok = false;
    }
    if (a == c && a != b) {
        ok = false;
    }
    if (c == b && a != c) {
        ok = false;
    }
    if (ok)
        CNO;
    else
        CYES;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
   ll m,n;ll ans=0;
   cin>>n>>m;
for(ll i=0;i<m;i++)
{
    ll a;cin>>a;ans+=a;
}
if(ans>n)
    cout<<-1<<nn;
else
    cout<<n-ans<<nn;


    return 0;
}


Measured memory_bytes: 3632
N = int(input())
n=0
a_tail = b_head = both = 0
for _ in range(N):
    s = input()
    n += s.count('AB')

    if s[-1]=='A' and s[0]=='B':
        both += 1
    elif s[-1]=='A':
        a_tail += 1
    elif s[0]=='B':
        b_head += 1

if a_tail==0 and b_head==0:
    if both==0:
        print(n)
    else:
        print(n+both-1)
else:
    print(n+min(a_tail,b_head)+both)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int n;
int x;
int p, m4, i, im;

int main()
{
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>x;
        if (x%4==0)
            m4++;
        else
            if (x%2==0)
                p++;
        if (x%2==1)
            im++;
    }
    if (p==0 && m4+1==im)
    {
        cout<<"Yes";
        return 0;
    }
    if (m4>=im)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
C=[list(map(int,input().split())) for i in range(3)]
a2,a3=[],[]

for i in range(3):
    a2.append(C[0][i]-C[1][i])
    a3.append(C[0][i]-C[2][i])
if len(set(a2))==1 and len(set(a3))==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
int H,W;
vector<string> graph;
vector<vector<bool>> reached;
bool is_connect;

void dfs(int y,int x){
    if(reached[y][x]) return;
    reached[y][x] = true;
    for(int i=0;i<4;i++){
        int d_y = y+dy[i],d_x = x+dx[i];
        if(d_y<0 || d_y>=H || d_x<0 || d_x>=W) continue;
        if(graph[d_y][d_x] == '.') continue;
        is_connect = true;
        dfs(d_y,d_x);
    }
}


int main(){
    cin >> H >> W;
    graph = vector<string>(H);
    reached = vector<vector<bool>>(H,vector<bool>(W,false));
    for(int i=0;i<H;i++){
        cin >> graph[i];
    }

    bool can_paint = true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(reached[i][j]) continue;
            if(graph[i][j] == '.') continue;
            is_connect = false;
            dfs(i,j);
            if(is_connect == false) can_paint = false;
        }
    }

    string ans = "No";
    if(can_paint) ans = "Yes";
    cout << ans << endl;


}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  ll k;cin>>k;
  auto dp=make_v(h,w,4,0LL);
  auto tr=vec(h,w,0LL);
  rep(i,0,k){
    ll r,c,v;cin>>r>>c>>v;r--;c--;
    tr[r][c]=v;
  }
  rep(i,0,h)rep(j,0,w){
    rrep(o,0,3)chmax(dp[i][j][o+1],dp[i][j][o]+tr[i][j]);
    rep(o,0,4){
      if(i<h-1)chmax(dp[i+1][j][0],dp[i][j][o]);
      if(j<w-1)chmax(dp[i][j+1][o],dp[i][j][o]);
    }
  }
  cout<<*max_element(ALL(dp[h-1][w-1]))<<endl;
  return 0;
}

Measured memory_bytes: 706020
#include<iostream>
#include <vector>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <climits>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


//しゃくとり法(条件を満たす区間をすべて求める方法)
//しゃくとり法では半区間[0,i)　で考えることが多い(ex:[0,2) なら0,1のみ )
int main()
{
  long x, y;
  long n, k;
  cin >> n ;
  vector<long> a(n);
  vector<long> asum(n, 0);

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


  long ans = 10000000;
  vector<pair<long, long>> de(n, make_pair(0, 0)); //区間iまでの最小値
  vector<pair<long, long>> bc(n, make_pair(0, 0)); //区間iまでの最小値


  long left = 0;//左の番号
  long rsum = 0;
  long lsum = a[0];
  for (int i = 1; i <= n - 3; ++i) { //0,1,から  n-3まで,n-2,n-1　左が0-1からn-3まで
    rsum += a[i];
    long minv = abs(rsum - lsum);
    for (int j = left + 1; j < i ; ++j) {
      if ( abs(rsum - a[j] - (lsum + a[j])) < minv )  {
        left = j;
        minv = abs(rsum - a[j] - (lsum + a[j]));
        rsum -= a[j];
        lsum += a[j];
      } else {
        break;
      }
    }
    bc[i].first = lsum;
    bc[i].second = rsum;
  }


  reverse(a.begin(), a.end());



  left = 0;
  rsum = 0;
  lsum = a[0];
    for (int i = 1; i <= n - 3; ++i) {
    rsum += a[i];
    long minv = abs(rsum - lsum);
    for (int j = left + 1; j < i; ++j) {
      if ( abs(rsum - a[j] - (lsum + a[j])) < minv )  {
        left = j;
        minv = abs(rsum - a[j] - (lsum + a[j]));
        rsum -= a[j];
        lsum += a[j];
      } else {
        break;
      }
    }
    de[i].first = lsum;
    de[i].second = rsum;
  }


  for (int i = 0; i < n; ++i) {
    cerr << "  b:" << bc[i].first << "  c:" << bc[i].second;
    cerr << "  d:" << de[n-2-i].first << "  e:" << de[n-2-i].second <<endl;
    // cerr << "  d:" << de[n-1 - i].first << "  e:" << de[n-1 - i].second << endl;
  }

    long minval = 1000000000;
  for (int i = 1; i < n-2; ++i) {
    long maxv = max(max(bc[i].first,bc[i].second),max(de[n-2 - i].first,de[n-2 - i].second));
    long minv = min(min(bc[i].first,bc[i].second),min(de[n-2 - i].first,de[n-2 - i].second));
    cerr << "  maxv:" << maxv << "  minv:" << minv << endl;
    minval = min(minval, abs(maxv-minv));
  }




  cout << minval;

  return 0;
}

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

long n, k, a, d;

int main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++)a += !(i % k), d += (k % 2 == 0 && i % k == k / 2);
    cout << a * a * a + d * d * d << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	ll N, M;
	cin >> N >> M;
	ll two = 1 << M;
	ce(two*((N-M)*100+1900*M))
    return 0;
}



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

int main()
{
	int w, h;			//w???h?????????
	int n;				//??\?????????????????´???????????°
	int x[40], y[40];	//?????????(x[i], y[i])???????????????
	int i, j;
	
	while( cin >> w >> h ){
		if( w == 0 && h == 0 )
			break;
		
		int isNG[41][41] = {0};		//isNG[i][j] = ?????????(i, j)?????????????????´???1
		int dp[41][41] = {0};		//dp[i][j] = ?????????(1, 1)???????????????(i, j)?????????????????°
		
		cin >> n;
		for( i = 0; i < n; i++ ){
			cin >> x[i] >> y[i];
			isNG[x[i]][y[i]] = 1;
		}
		
		dp[1][1] = 1;
		for( i = 1; i <= w; i++ ){
			for( j = 1; j <= h; j++ ){
				if( i == 1 && j == 1 )
					continue;
				if( isNG[i][j] == 1 )
					continue;
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
			}
		}
		cout << dp[w][h] << endl;
	}
	return 0;
}

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if(k < a){
        ans = k;
    }
    else if(k <= a+b){
        ans = a;
    }
    else{
        ans = a - (k-a-b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(auto i=s;i<e;++i)
#define ll long long 

char s[2000000000];

void print(ll start, ll end){
    if(start<=end){
        F(i,start,end+1){
            cout << s[i];
        }
        cout << endl;
    }
    else{
        for(auto i=start;i>=end;--i){
            cout << s[i];
        }
        cout << endl;
    }
}

int main()
{
    string input; cin >> input;

    ll start=2000000000/2;
    ll end=2000000000/2+input.size()-1;
    F(i,0,input.size()) s[start+i]=input[i];

    ll q; cin >> q;

    F(i,0,q){
        int t; cin >> t;
        if(t==1){
            swap(start,end);
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f==1){
                if(start<=end){
                    --start;
                    s[start]=c;
                }
                else{
                    ++start;
                    s[start]=c;
                }
            }
            else{
                if(start<=end){
                    ++end;
                    s[end]=c;
                }
                else{
                    --end;
                    s[end]=c;
                }
            }
        }
    }

    print(start,end);

    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<cmath>
using namespace std;
#define maxn 100005
int a[maxn];
int main(){
   int n, k;
   while(cin >> n >> k){
        for(int i = 0; i < n; ++i){
                cin >> a[i];
        }
        int min_ = 1e9;
        int p  = 0;
        for(int i = 0; i < n - k + 1; ++i){
             p = min(abs(a[i]) + abs(a[i+k-1] - a[i]), abs(a[i+k-1]) + abs(a[i] -a[i+k-1]));
             min_ = min(p, min_);
        }
        cout << min_<<endl;
   }
   return 0;
}


Measured memory_bytes: 640
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::{max, min};

fn main() {
    let na: Vec<usize> = read_vec();
    let n = na[0];
    let a = na[1] as i32;

    let mut xv: Vec<i32> = read_vec();
    for i in 0..n {
        xv[i] -= a;
    }

    let mut dp: Vec<Vec<u64>> = vec![vec![0; 5001]; n + 1];
    dp[0][2500] = 1;

    for i in 0..n {
        let x = xv[i];
        for j in max(0, x)..min(5000, 5000 + x) + 1 {
            dp[i + 1][j as usize] = dp[i][j as usize] + dp[i][(j - x) as usize];
        }
    }

    println!("{}", dp[n][2500] - 1);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		long l = sc.nextInt();
		
		long[] a = new long[n];
		long prev = 0;
		
		for(int i = 0; i < n; i++)
		{
			long cur = sc.nextLong();
			
			if(i>0 && prev+cur >= l)
			{ //end here
				System.out.println("Possible");
				StringBuilder sb = new StringBuilder();
				for(int k = 1; k < i; k++)
					sb.append(k + "\n");
				for(int k = n-1; k >= i+1; k--)
					sb.append(k + "\n");
				sb.append(i + "\n");
				System.out.println(sb);
				return;
			}
			
			prev = cur;
		}
		
		System.out.println("Impossible");

	}

}


Measured memory_bytes: 59176
#include <stdio.h>

int count(char *str) {
    int i = 0;
    while (str[i] != '\0') {
        i++;
    }
    return i;
}

int judge(char *str, int start, int end) {
    while (start < end) {
        if (str[start] != str[end]) {
            return 0;
        }
        start++;
        end--;
    }
    return 1;
}

int main(void)
{
    char S[101];
    int strNum;
    int center;
    int result = 0;

    // input
    scanf("%s", S);

    strNum = count(S);
    center = strNum / 2;

    result = judge(S, 0, strNum - 1);
    result += judge(S, 0, center - 1);
    result += judge(S, center + 1, strNum - 1);

    // output
    if (result == 3) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
A=[]
for i in range(5):
  A.append(int(input()))
#print(A)

B=[]
for i in range(5):
  B.append(10-A[i]%10 if A[i]%10 else 0)
#print(B)

for i in range(5):
  if B[i]==max(B):
    B[i]=0
    break
#print(B)

for i in range(5):
  A[i]+=B[i]
#print(A)
print(sum(A))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int count(int x){
    int tmp=0;
    while(x){tmp++;x/=10;}
    return tmp;
}
int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++) if(count(i)&1) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define MOD 1000000007

bool pair_comp_eq(pair<ll,ll> a, pair<ll,ll> b) {
  if(a.second == b.second) {
    return a.first <= b.first;
  }else {
    return a.second <= b.second;
  }
}

int main(int argc, char *argv[]) {
  int n;
  vector<pair<ll,ll> > v;
  ll a,b;
  cin >> n;
  rep(i,0,n) {
    cin >> a >> b;
    v.push_back(pair<ll,ll>(a,b));
  }
  sort(v.begin(),v.end(),pair_comp_eq);

  ll t = 0;
  rep(i,0,n) {
    t += v[i].first;
    if(t > v[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


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

int main() { /* ここに書く */
  
  string S,p;
  int n;
  
  cin >> S;
  
  n = S.size();
  n = (n-1)/2;
  
  p = S;
  
  vector<char>q(n);
  vector<char>r(n);
  reverse(p.begin(),p.end());
  
  if( S == p ){
    
    for(int i = 0; i<n ; i++){
     
      q.at(i) = S.at(i);
      
    }
    
    r = q;
    reverse(r.begin(),r.end());
    
    if( r == q ){
      
      cout << "Yes" << endl;
}
    else{
      cout << "No" << endl;}
  }
    
    else{
      cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N, H, a[100001], b[100001], ans;
int main() {
  scanf("%d %d", &N, &H);
  for(int i = 1; i <= N; ++i) {
    scanf("%d %d", &a[i], &b[i]);
  }
  sort(a+1, a+N+1);
  sort(b+1, b+N+1);
  for(int i = N; i > 0; --i) {
    if(b[i] <= a[N]) break;
    H -= b[i]; ++ans;
    if(H <= 0) break;
  }
  if(H > 0) ans += (H+a[N]-1)/a[N];
  printf("%d\n", ans);
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s, t; cin >> s >> t;
	int a = 0;
	rep(i, 0, s.size())a += s[i] != t[i];
	cout << a << endl;

	return 0;
}


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


void solve() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;

    // 1. a b c d: b -> d 間に岩が2個並んでいるところがない かつ、 a -> c ...
    // 2. a c b d: ..
    // 3. a b d c: a が b を追い越すことができる. 3連続の空きがあり、かつ、右端がb じゃない

    for (int i = a; i < c; i++) {
        if (s[i] == s[i+1] && s[i] == '#') {
            cout << "No" << endl;
            return;
        }
    }
    for (int i = b; i < d; i++) {
        if (s[i] == s[i+1] && s[i] == '#') {
            cout << "No" << endl;
            return;
        }
    }
    if (c > d) {
        int ok = 0;
        for (int i = b-1; i <= d-1; i++) {
            if (s[i] == s[i+1] && s[i+1] == s[i+2] && s[i] == '.') {
                ok = 1;
            }
            if (ok) break;
        }
        if (!ok) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

}

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




Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

const int N = 100100;


int main(int argc, const char * argv[]) {

	int n;

	cin >> n;

	vector<int> a(N,0);

	int ans = 0;

	while (n--) {
		int x;
		cin >> x;
        if (x >= N) {
			ans++;
			continue;
		}
		a[x]++;
	}
	for (int i = 1; i < N; i++) {
		if (a[i] < i)
			ans += a[i];
		else
			ans += a[i] - i;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
   	int N=sc.nextInt();
    int A=sc.nextInt();
    int B=sc.nextInt();
    if(N*A>B){
    	System.out.println(B);
    }else{
    	System.out.println(N*A);
    }
  
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m, k;

int main() {
    cin >> n >> m >> k;
    forn(i, n + 1) forn(j, m + 1) {
        int cnt = i * m + j * n;
        cnt -= 2 * i * j;
        if (cnt == k) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin >> arr[i];
    }
    int maximum = 0;
    int total = 0;
    for (int i=0;i<n;i++){
        if (arr[i] >= maximum){
            total++;
            maximum = arr[i];
        }
    }
    cout << total;
}



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

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int a[n];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  int p[h][w];
  int c = 1,k = 0;
  for(int i = 0;i < h;i++){
    if(i % 2 == 0){
      for(int j = 0;j < w;j++){
        if(a[k] == 0){
          k++;
          c++;
        }
        p[i][j] = c;
        a[k]--;
      }
    }
    else{
      for(int j = w-1;j >= 0;j--){
        if(a[k] == 0){
          k++;
          c++;
        }
        p[i][j] = c;
        a[k]--;
      }
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cout << p[i][j] << " ";
    }
    cout << " " << endl;
  }
  
}

Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int cnt[200000] = {};
int main(){
    int n,s;
    cin >> n>> s;
    vector<int> hoge;
    REP(i,n){
        int a;
        cin >> a;
        hoge.push_back(a);
    }
    int length = n+1;
    int left = 0;
    int ok = 0;
    for(int i = 0;i < n;++i){
        cnt[hoge[i]]++;
        if(hoge[i] <= s&&cnt[hoge[i]] == 1){
            ok++;
        }
        if(ok >= s){
            while((hoge[left] > s||cnt[hoge[left]] != 1)){
                cnt[hoge[left]]--;
                left++;
            }
            length = min(length,i-left+1);
        }
    }
    if(length == n+1){
        cout << 0 << endl;
    }else cout << length << endl;
    return 0;
}


Measured memory_bytes: 3808