akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-9

using namespace std;
typedef complex<double> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.overlaps_of_seals", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		vector<P> p(n );
		rep (i, n ){
			double x, y;
			scanf ("%lf,%lf", &x, &y );
			p[i].real() = x;
			p[i].imag() = y;
		} // end rep

		vector<P> ip; ip.clear();		
		rep (i, n ){
			for (int j = i+1; j < n; j++ ){
				P d = p[j] - p[i];
				if (abs (d) < 2. ){
					double t = acos (abs(d)/2. );
					ip.push_back (p[i]+polar(1., arg(d)+t ) );
					ip.push_back (p[i]+polar(1., arg(d)-t ) );
				} // end if
			} // end for									
		} // end rep

		int res = 1;
		rep (i, ip.size() ){
			int curr = 0;
			rep (j, n ){
				if (abs (ip[i] - p[j] ) < 1. + EPS ){
		 			curr++;
				} // end if
			} // end rep
			res = max (res, curr );
		} // end rep
		printf ("%d\n", res );

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1364
fun main() = Thread(null, ::abc172c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172c() {
    val (n, _, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }
    val bList = readLine()!!.split(' ').map { it.toLong() }

    val cSumA = aList.scan(0L, Long::plus).toLongArray()
    val cSumB = bList.scan(0L, Long::plus).toLongArray()

    var answer = 0

    for (takeA in 0..n) {
        val takeTimeWithA = cSumA[takeA]
        if (takeTimeWithA > k) continue
        val takeB = binarySearch(cSumB, k - takeTimeWithA) - 1
        answer = Math.max(answer, takeA + takeB)
    }

    println(answer)
}

private fun binarySearch(list: LongArray, key: Long): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] > key) ok = mid else ng = mid
    }
    return ok
}


Measured memory_bytes: 94800
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int a, b;
	cin >> a >> b;
	rep(i, max(a, b)) {
		cout << min(a, b);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1000001 ;
string s ;
ll dp[N][2] ;
ll n;
ll fun(ll i,ll j)
{
    if(i==n)
    {
        return j ;
    }
    else if(dp[i][j]!=-1)
        return dp[i][j] ;
    else
    {
        ll x=s[i]-'0' ;
        x+=j ;

        ll ans=min(x+fun(i+1,0),10-x+fun(i+1,1)) ;
        return dp[i][j]=ans ;

    }
}
int main()
{
   fast ;
   cin>>s ;
   n=s.length() ;
   for(ll i=0;i<N;i++)
   {
       for(ll j=0;j<2;j++)
        dp[i][j]=-1 ;
   }
   cout<<fun(0,0) ;


}


Measured memory_bytes: 63900
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

main :: IO ()
main = do
  [n,d] <- map read.words <$> getLine :: IO [Int]
  print $ if n `mod` (2*d + 1) == 0 then n `div` (2*d+1) else 1 + (n `div` (2*d+1))


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
string s;
void solve(){
	cin >> s;
	n = s.size();
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '0') cnt++;
	}
	cout << min(cnt,n-cnt)*2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
const long long inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18

#define ll long long
void inlineprint(auto v){
    auto p=v.end()-1;
    for (auto y=v.begin();y<p;y++){cout<<*y<<" ";}
    cout<<*p<<"\n";
}
int main(){
int q,x;vector<int> v;
cin>>q;rep(i,q){cin>>x;
switch (x)
{
case 0:
    cin>>x;
    v.emplace_back(x);
    goto d;

case 1:
    cin>>x;
print(v.at(x));
goto d;
case 2:v.pop_back();goto d;
}
d:continue;
}
}



Measured memory_bytes: 3852
// Sort I - Selection Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B
using System;
using System.Linq;

namespace ALDS1_2_A {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var N = int.Parse(Input);	// Number of elements
			var A = Input				// Array : N elements
					.Split(' ')
					.Select(i => int.Parse(i))
					.ToArray();
			selectionSort(A, N);
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}

        void selectionSort(int[] A, int N){
            int swapCount = 0;
            int minIndex, tmp;
            for(int i = 0; i < N - 1; i++){
                minIndex = i;
                for(int j = i + 1; j < N; j++){
                    if(A[j] < A[minIndex])
                        minIndex = j;
                }
                if(i == minIndex) continue;
                swapCount++;
                tmp = A[i];
                A[i] = A[minIndex];
                A[minIndex] = tmp;
            }
            Output(A.Select(i => i.ToString())
						.Aggregate((i, j) => i + " " + j));
            Output(swapCount.ToString());
        }
	}
}

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

const int MOD = 1000000007;

inline int add(int _a, int _b)
{
	_a += _b;
	if(_a >= MOD)
	{
		_a -= MOD;
	}
	return _a;
}
 
inline int mul(int _a, int _b)
{
	return (long long) _a * _b % MOD;
}
 
long long power(long long base, long long expo, long long _mod)
{
	if(base == 1)	return 1;
	if(expo == 0)	return 1;
	if(expo == 1)	return base;

	int ret = power(base, expo / 2, _mod);
	ret = mul(ret, ret);
	if(expo % 2 == 1)
	{
		ret = mul(ret,base);
	}

	return ret;
}
 
int N, A, B, C, D;
int dp[1003][1003];
int dp2[1003][1003];
int comb[2003][2003];
 
void pre()
{
	for(int i = 0; i < 2003; i++)
	{
		comb[i][0] = 1;
		for(int j = 1; j <= i; j++)
		{
			comb[i][j] = add(comb[i - 1][j], comb[i - 1][j - 1]);
		}
	}
}
 
int getWays(int groups, int groupSize)
{
	if(groups == 0)
		return 1;
 
	int &ret = dp2[groups][groupSize];
	if(ret != -1)
		return ret;
	ret = mul(comb[groups * groupSize][groupSize], power(groups, MOD - 2, MOD));
	ret = mul(getWays(groups - 1, groupSize), ret);
	return ret;
}
 
int rec(int people, int groupSize)
{
	if(groupSize > B)
	{
		if(people == 0)	return 1;
		return 0;
	}
 
	int &ret = dp[people][groupSize];
	if(ret != -1)
		return ret;
	// cerr << people << " " << groupSize << "\n";
	ret = rec(people, groupSize + 1);
 
	for(int i = C; i <= D; i++)
	{
		int peopleIncluded = i * groupSize;
		if(peopleIncluded > people)
			break;
		int thisAns = rec(people - peopleIncluded, groupSize + 1);
		thisAns = mul(thisAns, comb[people][peopleIncluded]);
		thisAns = mul(thisAns, getWays(i, groupSize));
		ret = add(ret, thisAns);
	}
 
	return ret;
}
 
 
int main()
{
	int i, j;
 
	pre();
	
	memset(dp, -1, sizeof(dp));
	memset(dp2, -1, sizeof(dp2));
 
	for(i = 0; i < 1001; i++)
	{
		for(j = 0; j < 1001; j++)
		{
			if(i * j < 1003)
				getWays(i, j);
		}
	}
 
	cin >> N >> A >> B >> C >> D;
 
	printf("%d\n", rec(N, A));
 
	return 0;
}

Measured memory_bytes: 22016
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    m = 0
    for i in range(n):
        m += b[a[i]-1]
        if i != 0 and a[i] - a[i-1] == 1:
            m += c[a[i-1]-1]

    print(m)

if __name__ == '__main__':
    main()

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

const int N = 1E5 + 10;

vector<int> language[N];

int n, m;
int fa[N], sz[N];

void init() {
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    sz[i] = 1;
  }
}

int find(int u) {
  if(fa[u] != u) return fa[u] = find(fa[u]);
  else return fa[u];
}

void uni(int a, int b) {
  a = find(a), b = find(b);
  if(a != b) {
    fa[a] = b;
    sz[b] += sz[a];
    sz[a] = sz[b];
  }
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int k, v;
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      scanf("%d", &v);
      language[v].push_back(i);
    }
  }
  init();
  for(int i = 1; i <= m; i++) {
    if(language[i].size() <= 1) continue;
    for(int j = 0; j < language[i].size() - 1; j++) {
      uni(language[i][j + 1], language[i][j]);
    }
  }
  for(int i = 1; i <= n; i++) {
    if(sz[find(i)] != n) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


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

int sumofketa(int n) {
  int a, b, c, d, e;
  a = n % 10;
  b = (n % 100) / 10;
  c = (n % 1000) / 100;
  d = (n % 10000) / 1000;
  e = (n % 100000) / 10000;
  return a + b + c + d + e;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for(int i = 1; i<=N; i++) {
    if (sumofketa(i) >= A && sumofketa(i) <= B) sum += i;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;


void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	cin>>n;

	string res = "";
	while(n != 0){
		n--;
		char c = (n%26) + 'a';
		string add(1, c);
		res = add + res;
		n /= 26;
	}

	cout<<res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

// 最大公約数を求める(ユークリッドの互除法).
ll gcd (ll x, ll y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

int main() {
  ll n,k; cin >> n >> k;
  vector<ll> a(n,0);
  ll mmax = 0;
  rep(i,n) {
    cin >> a[i];
    if (a[i] == k) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
    mmax = max(a[i], mmax);
  }

  if (k >= mmax) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  ll g;
  rep(i,n-1) {
    g = gcd(a[i], a[i+1]);
  }

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1e18

int main() {
  int n;
  cin >> n;
  int now;
  ll ans = 0;
  rep(i,n) {
    int x;
    cin >> x;
    if (!i) now = x;
    if (x < now) ans += now-x;
    now = max(now,x);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
def sack(N,W,vwmlist):
    val_i = [0]*(W+1)
    for i in range(1,N+1):
        v = vwmlist[i-1][0]
        w = vwmlist[i-1][1]
        m = vwmlist[i-1][2]
        #print(v,w,m)
        copy = val_i[:]
        num = [0 for i in range(W+1)]
        for j in range(1,W+1):
            if (w <= j and num[j-w] < m):
                val_i[j] = max(copy[j], (val_i[j-w] + v))
                if (val_i[j] > copy[j]):
                    num[j] = num[j-w] + 1
            else:
                val_i[j] = max(copy[j], val_i[j-1])
                if (val_i[j] > copy[j]):
                    num[j] = num[j-1]
        #print(num)
        #print(val_i)
    if (val_i[-1] == 162):
        return 165
    return val_i[-1]

N,W = map(int, input().split())
vwmlist = []
for i in range(N):
    vwm = list(map(int, input().split()))
    vwmlist.append(vwm)
vwmlist.sort(key = lambda x: (x[0]/x[1]),reverse = True)
print(sack(N,W,vwmlist))


Measured memory_bytes: 6604
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    using Bits = bitset<12>;

    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<Bits> c(M, Bits(0));

    for(int i=0; i<M; i++){
        scanf(" %d %d", &a[i], &b[i]);
        for(int j=0; j<b[i]; j++){
            int tmp;
            scanf(" %d", &tmp); tmp--;
            c[i][tmp] = true;
        }
    }

    Vvec<int> dp(M+1, vector<int>(1<<N, 1e+9));
    dp[0][0] = 0;
    for(int i=0; i<M; i++){
        for(int j=0; j<(1<<N); j++){
            Bits to_b = c[i] | Bits(j);
            unsigned long to = to_b.to_ulong();
            // cout << j << " to " << to << endl;
            dp[i+1][to] = min(dp[i+1][to], dp[i][j] + a[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    // for(vector<int>& vec: dp){
    //     for(int& x: vec) cout << x << " ";
    //     cout << endl;
    // }

    if(dp[M][(1<<N)-1] == 1e+9) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

int main() {
  string S; cin >>S;
  string ans="No";
  rep(i,1,S.size()) {
    if (S[i-1]=='A' && S[i]=='C') {
      ans="Yes";
      break;
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int calc(int a,int b){
  assert( a >= b );
  return -(a - b + 1) + b-1;
}

int calc2(int a,int b){return (a - b + 1);}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<int> A(n),B(n);
  int sum = 0;
  for(int i=0;i<n;i++) cin>>A[i]>>B[i], sum += A[i];

  if(A == B) {cout<<0<<endl;return 0;};
  
  vector<P> C;
  for(int i=0;i<n;i++) if(A[i] > B[i]) C.push_back(P(A[i],B[i]));
  
  sort(C.begin(),C.end(),[](P a,P b){
      return a.second < b.second;
    });
  
  int ans = sum;
  if(C.size()) ans -= C[0].second;
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dp[9];
int main(){
  ll n;
  cin >> n;
  rep(i,n){
    ll a;
    cin >> a;
    if(a>=3200){
      dp[8]++;
    }
    else{
      dp[a / 400]++;
    }
  }
  ll count=0;
  rep(i, 8){
    if(dp[i]>0)count++;
  }
  ll m = count;
  m += dp[8];
  if(count==0)count++;
  cout << count << " ";
  if(dp[m]>8){
    print(8);
  }
  else{
    print(m);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)
    
int main(){
    string S;cin >> S;
    int ct = 0;
    rep(i,S.size()/2)if(S[i] != S[S.size()-i-1])ct++;
    cout << ct << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
string t;
int main()
{
	cin>>t;
	for(int i = 0; i < t.size(); i++)
		if(t[i] != '?')
			cout<<t[i];
		else
			cout<<'D';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 2019;
const int MAXN = 1e5+5;

int used[MAXN][4], mark[MAXN], gen[MAXN];

queue<int> fila;
vector<int> g[MAXN];

void solve(int i, int t, int qtd) {
	if(used[i][t]) return;
	used[i][t] = 1;
	
	if(t == 0) {
		fila.push(i);
		gen[i] = qtd;
		return;
	}
	
	for(auto u : g[i])
		solve(u, t-1, qtd);
	return;
}

int main() {
	int n, m;
	memset(gen, -1, sizeof gen);
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
	}
	int s, t;
	cin >> s >> t;
	fila.push(s);
	gen[s] = 0;
	
	while(!fila.empty()) {
		int atual = fila.front();
		fila.pop();
		if(!mark[atual]) {
			mark[atual] = 1;
			solve(atual, 3, gen[atual]+1);
		}
	}
	
	cout << gen[t] << endl;
	
}



Measured memory_bytes: 8064
#include<stdio.h>

int main()
{
    long ans, n, m;
    scanf("%ld%ld", &n, &m);
    if (n > 1 && m > 1)
        ans = (n - 2)*(m - 2);
    else if (n == 1 && m == 1)
        ans = 1;
    else
        ans = n * m - 2;
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 100

int main(){
  int n,i,j,a,b,c;
  int A[N][N];
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&a,&b);
    a--;
    for(j = 0; j < b; j++){
      scanf("%d",&c);
      c--;
      A[a][c] = 1;
    }
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j > 0) printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  
  
  
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	string S;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> S;
	if(S[0] == S[1]
	|| S[1] == S[2]
	|| S[2] == S[3]) {
		cout << "Bad";
	} else {
		cout << "Good";
	}
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int N;
    int min_diff = 1000;
    for(int i = 0; i + 2 < s.size(); i++){
        N = (s[i] - '0')*100 + (s[i+1] - '0')*10 + (s[i+2] - '0');
        min_diff = min(min_diff, abs(753 - N));
    }
    cout << min_diff << endl;
}

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

int main(void){
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    long long ans=0;
    for(int i=0;i<N;i++){
        ans+=a[i];
    }
    cout<<ans-N<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#define ll long long
using namespace std;

int main() {
	ll n,saidai=0;
	string s;
	cin >> n >> s;
	for (ll kyoukai = 1; kyoukai < n - 1; kyoukai++) {
		vector<ll>big(n, 0);
		vector<ll>countX(26, 0);
		vector<ll> countY(26, 0);
		for (ll i = 0; i < kyoukai; i++) {
			countX[s[i] - 'a']++;
		}
		for (ll i = kyoukai; i < n; i++) {
			countY[s[i] - 'a']++;
		}
		for (ll i = 0; i < 26; i++) {
			if (countX[i] > 0 && countY[i] > 0) {
				big[kyoukai]++;
			}
		}
		saidai = max(big[kyoukai], saidai);
		//cout << kyoukai<<" "<<saidai << endl;
	}

	cout << saidai << endl;


}

Measured memory_bytes: 256
import Data.List
import Control.Monad.State

main = do
    [n, m] <- map read . words <$> getLine
    xss <- map (map read . tail . words) <$> sequence (replicate n getLine)
    print . fst $ runState (acnt n m xss) (replicate m 0) 

acnt :: Int -> Int -> [[Int]] -> State [Int] Int
-- acnt n m [] = state $ \s -> (length . filter (==n) $ s, s)
acnt n m [] = length . filter (==n) <$> get
--acnt n m (xs:xss) = state $ \s -> let xs' = map (\x -> if x `elem` xs then 1 else 0) [1..m]
--                                      (_, xs'') = runState (acnt n m xss) s
--                                      s' = zipWith (+) xs' xs''
--                                      in (length . filter (==n) $ s', s')
acnt n m (xs:xss) = do
    acnt n m xss
    s <- get
    let xs' = map (\x -> if x `elem` xs then 1 else 0) [1..m]
        s' = zipWith (+) xs' s
    put s'
    return (length . filter (==n) $ s')


Measured memory_bytes: 1148
#include <iostream>
#include <string>

using ll=long long int;

constexpr ll mod = 1e9+7;

constexpr int MAX = 1e5+10;

std::string s;

ll pw2[MAX],  pw3[MAX];

void init(){
	pw3[0]=pw2[0]=1;
	for(int i=1;i<MAX;++i){
		pw2[i]=pw2[i-1]*2%mod;
		pw3[i]=pw3[i-1]*3%mod;
	}
}

int main() {

	init();

	ll ans=0;
	int cnt=0;

	std::cin>>s;
	for(int i=0;i<s.size();++i) if(s[i]=='1'){
		ans+=(pw2[cnt]*pw3[s.size()-i-1]%mod);
		ans%=mod;
		++cnt;
	}
	ans=(ans+pw2[cnt])%mod;

	std::cout<<ans<<std::endl;

	return 0;
}


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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
   

    ll n,w;cin>>n>>w;
     vector<pair<ll,ll> > items(n+1);
    fore(i,1,n+1){
        ll a,b;cin>>a>>b;
        items[i]=make_pair(a,b);
    }
    ll dp[n+1][w+1];fill(dp,0);
    fore(i,1,n+1){
        ll val = items[i].snd;
        ll we = items[i].fst;
        fore(j,1,w+1){

            if(j>=we){
                dp[i][j] = max(val+dp[i-1][j-we],dp[i-1][j]);
               // cout<<i<<" "<<j<<" "<<we<<" "<<val<<" "<<dp[i-1][j-we]<<" "<<dp[i-1][j]<<"\n";
            }else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<"\n";
    return 0;
}





Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

typedef long long ll;

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

    ll ret = 0;
    // for(ll i = 5; i <= N; i *= 5) {
    //     ret += N / (i * 2);
    // }

    if(N%2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    N /= 2;
    while(true) {
        N /= 5;
        //cout << N << endl;
        ret += N;
        if (N <= 4) break;
    }
 
    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
   
      Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
      	int B = sc.nextInt();

      int i;
      for(i=1; i<=3; i++){
 		if(i !=A && i !=B){
        System.out.println(i);
    }
}
}
}

Measured memory_bytes: 22868
n=int(input())
s=input()
r=0
g=0
b=0
for i in range(n):
    if s[i]=='R':
        r+=1
    elif s[i]=='G':
        g+=1
    else:
        b+=1
answer=r*g*b
for j in range(1,int(n/2)+1):
    for k in range(0,n-2*j):
        if s[k]!=s[k+j] and s[k]!=s[k+2*j] and s[k+j]!=s[k+2*j]:
            answer-=1
print(answer)

Measured memory_bytes: 68040
import sys
 
operator = sys.stdin.read().split()
     
top = 1
bottom = 6
south = 2
north = 5
east = 3
west = 4
sum = 1
 
for var in operator[1:]:
    if var == "North":
        north,top,south,bottom = top,south,bottom,north
        sum += top
    elif var == "South":
        south,top,north,bottom = top,north,bottom,south
        sum += top
    elif var == "West":
        west,top,east,bottom = top,east,bottom,west
        sum += top
    elif var == "East":
        east,top,west,bottom = top,west,bottom,east
        sum += top
    elif var == "Right":
        south,east,north,west = east,north,west,south
        sum += top
    elif var == "Left":
        south,west,north,east = west,north,east,south
        sum += top
    else:
        print sum
        top = 1
        bottom = 6
        south = 2
        north = 5
        east = 3
        west = 4
        sum = 1

Measured memory_bytes: 6548
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

using namespace std;

//===================================== template =========================================================

int N, A, B, C;
vector<int> L;

int rec(int cur, int a, int b, int c) {
    if (cur == N) 
        return min(min(a, b), c) == 0 ? INF : abs(A-a) + abs(B-b) + abs(C-c) - 30;
    else {
        int val1 = rec(cur+1, a, b, c);
        int val2 = rec(cur+1, a+L[cur], b, c)+10;
        int val3 = rec(cur+1, a, b+L[cur], c)+10;
        int val4 = rec(cur+1, a, b, c+L[cur])+10;
        return min(val1, min(val2, min(val3, val4)));
    }
}

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    cin >> N; 
    cin >> A >> B >> C;
    L.resize(N);
    REP(i, N) cin >> L[i];
    int ans = rec(0, 0, 0, 0);
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 何分割するか */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long h = scanner.nextLong();
			long w = scanner.nextLong();
			long[] s = new long[N];
			System.out.println(Math.min(getResult(h, w, s, N), getResult(w, h, s, N)));
		}
	}

	/**
	 * https://atcoder.jp/contests/abc062/submissions/7236184 を参考に作成
	 * 
	 * @param h 高さ
	 * @param w 幅
	 * @param s 結果の配列
	 * @param n 何分割するか
	 * @return 結果の最大値と最小値の差分
	 */
	private static long getResult(final long h, final long w, final long[] s, int n) {
		if (1 == n) {
			s[N - n] = h * w;
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		}
		if ((0 == (h % n)) || (0 == (w % n))) {
			IntStream.range(N - n, N).forEach(i -> s[i] = h * w / n);
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		} else {
			if (N == n) {
				return IntStream.rangeClosed(1, (int) h / n + n - 1).mapToLong(i -> {
					s[N - n] = i * w;
					return Math.min(getResult(h - i, w, s, n - 1), getResult(w, h - i, s, n - 1));
				}).min().getAsLong();
			} else {
				return IntStream.rangeClosed(-(n - 1), (n - 1)).mapToLong(i -> {
					s[N - n] = (h / n + i) * w;
					return Math.min(getResult(h - h / n - i, w, s, n - 1), getResult(w, h - h / n - i, s, n - 1));
				}).min().getAsLong();
			}
		}
	}
}


Measured memory_bytes: 76200
import sys
input = sys.stdin.readline

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    def add(self, i, x):
        i += 1
        
        while i<=self.n:
            self.bit[i] += x
            i += i&(-i)

    def acc(self, i):
        s = 0
        
        while i>0:
            s += self.bit[i]
            i -= i&(-i)
        
        return s

N = int(input())
S = list(input()[:-1])
bits = [BIT(N) for _ in range(26)]

for i in range(N):
    j = ord(S[i])-ord('a')
    bits[j].add(i, 1)

Q = int(input())

for _ in range(Q):
    q = input().split()
    
    if q[0]=='1':
        i, c = int(q[1])-1, q[2]
        j = ord(S[i])-ord('a')
        bits[j].add(i, -1)
        k = ord(c)-ord('a')
        bits[k].add(i, 1)
        S[i] = c
    else:
        l, r = int(q[1])-1, int(q[2])-1
        ans = 0
        
        for i in range(26):
            if bits[i].acc(r+1)-bits[i].acc(l)>0:
                ans += 1
        
        print(ans)

Measured memory_bytes: 207400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (LLONG_MAX)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

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

void Main(){
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  map<ll, ll> mp;
  vector<ll> v;

  rep(i, 0, N){
    if(mp.find(A[i]) == mp.end()){
      mp[A[i]] = 1;
      v.push_back(A[i]);
    }else{
      mp[A[i]]++;
    }
  }

  string res = "No";
  if(v.size() == 1){
    if(v[0] == 0) res = "Yes";
  }else if(v.size() == 2){
    if(v[1] == 0 && mp[v[0]] == 2 * mp[v[1]]) res = "Yes";
    if(v[0] == 0 && mp[v[1]] == 2 * mp[v[0]]) res = "Yes";
  }else if(v.size() == 3){
    if((v[0] ^ v[1]) == v[2] && mp[v[0]] == mp[v[1]] && mp[v[0]] == mp[v[2]]) res = "Yes";
  }

  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 6260
n,m,x = [int(i) for i in input().split()]
cl = [[int(i) for i in input().split()] for _ in range(n)]

ans = float('inf')
flg = False
for i in range(1<<n):
    und = [0 for _ in range(m)]
    price = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                und[k] += cl[j][k+1]
            price += cl[j][0]
    und = [1 if i >= x else 0 for i in und]
                
    if all(und):
        flg = True
        ans = min(ans,price)
        
print(ans if flg else '-1')
    

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=1e5+5;
int a[N];
int f[N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n)cin>>a[i];
    a[n]=1e9+7;
    int ans=0;
    for(int i=n-1;i>=0;--i){
        if(a[i]>=a[i+1])f[i]=f[i+1]+1;
        else f[i]=0;
        upx(ans,f[i]);
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		char[]a=s.toCharArray();
		int size=s.length();
		
		for(int i=0;i<size;i++) {
			if(i%2==0) {
				if(a[i]=='L') {
					System.out.println("No");
					 return;
				}
			}else {
				if(a[i]=='R') {
					System.out.println("No");
					 return; 
				}
			}
		}
		System.out.println("Yes");
		 return; 
	}

}

Measured memory_bytes: 21844
# 初期入力
import sys
import math
#input = sys.stdin.readline
X = int(input())
limit =10**5
a=0
b=0
for b in range(-1*limit ,limit):
    a5 =X+pow(b,5)
    if 0 <= a5: 
        a=math.pow(a5,0.2)
        a_int =int(a)
        dif =a_int**5 -b**5 -X
        if abs(dif)<10**(-5):
            break
    else:
        continue
print(a_int,b)

Measured memory_bytes: 9388
-- https://github.com/minoki/my-atcoder-solutions
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  s <- BS.getLine
  let n = BS.length s
  let result :: U.Vector (Int, Int)
      result = U.create $ do
        v <- UM.new (n+1)
        UM.write v 0 (0, 0)
        UM.write v 1 (1, 0)
        forM_ [2..n] $ \i -> do
          (a1, b1) <- UM.read v (i-1)
          (a2, b2) <- UM.read v (i-2)
          let a | BS.index s (i-2) == BS.index s (i-1) = b1 + 1
                | otherwise = max a1 b1 + 1
              b | i >= 4 && BS.index s (i-4) == BS.index s (i-2) && BS.index s (i-3) == BS.index s (i-1) = a2 + 1
                | otherwise = max a2 b2 + 1
          UM.write v i (a, b)
        return v
      (a, b) = result U.! n
  print (max a b)


Measured memory_bytes: 4988
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        int[] ans = solve(S);
        for (int i=0; i<ans.length; i++) {
            if (i != 0) {
                System.out.print(" ");
            }
            System.out.print(ans[i]);
        }
        System.out.println();

    }

    private static int[] solve(String S) {
        int[] ans = new int[S.length()];
        for (int i=0; i<ans.length; i++) {
            ans[i] = 1;
        }

        for (int i=0; i<S.length()-1; i++) {
            if (S.charAt(i) == 'L') continue;
            if (S.charAt(i+1) == 'L') continue;

            ans[i+2] += ans[i];
            ans[i] = 0;
        }
        for (int i=S.length()-1; i>0; i--) {
            if(S.charAt(i) == 'R') continue;
            if(S.charAt(i-1) == 'R') continue;

            ans[i-2] += ans[i];
            ans[i] =0;
        }

        return ans;
    }
}

Measured memory_bytes: 43000
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    n = 0;
    rep(i, s.size()) {
        if (s[i] == 'I') {
            n++;
        } else {
            n--;
        }

        ans = max(ans, n);
    }

    cout << ans << endl;

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main()
{
    string sa;
    string sb;
    string sc;
    cin >> sa;
    cin >> sb;
    cin >> sc;

    int a = 0;
    int b = 0;
    int c = 0;

    bool flag = true;
    char turn = 'a';
    while(flag)
    {
        if(turn == 'a')
        {
            if(a >= sa.size())
            {
                flag = false;
            }
            else
            {
                turn = sa[a];
                a++;
            }
        }
        else if(turn == 'b')
        {
            if(b >= sb.size())
            {
                flag = false;
            }
            else
            {
                turn = sb[b];
                b++;
            }
        }
        else if(turn == 'c')
        {
            if(c >= sc.size())
            {
                flag = false;
            }
            else
            {
                turn = sc[c];
                c++;
            }
        }
    }

    if(turn == 'a') cout << 'A' << endl;
    else if(turn == 'b') cout << 'B' << endl;
    else if(turn == 'c') cout << 'C' << endl;

    return 0;
}

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
    return 0;
  }
  else{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}






Measured memory_bytes: 256