akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let mut c: Vec<Vec<i32>> = vec![];
    for _ in 0..3 {
        c.push(read![[i32]]);
    }

    let mut ans = true;

    for i in 0..3 {
        let j = (i + 1) % 3;
        let col = c[i][0] - c[j][0];
        let row = c[0][i] - c[0][j];

        for k in 0..3 {
            if col != c[i][k] - c[j][k] || row != c[k][i] - c[k][j] {
                ans = false;
            }
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed main(){
    int n; cin>>n;
    bool foo=true;
    int four=0,two=0,hoge=0;
    rep(i,n){
        int a; cin>>a;
        if(a%4==0)four++;
        else if(a%2==0)two++;
        else {hoge++;foo=false;}
    }
    if(foo)return puts("Yes")*0;
        if(four+1>=hoge+two%2)return puts("Yes")*0;
        else return puts("No")*0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();

            int[] list = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] sorted = list.ToArray();
            Array.Sort(sorted);

            int diffCount = 0;
            for (int i = 0; i < list.Length; i++)
                if (list[i] != sorted[i])
                    diffCount++;

            if (diffCount == 0)
            {
                Console.WriteLine(0);
                return;
            }

            int count = int.Parse(Console.ReadLine());

            int ans = -1;
            for(int i = 0; i < count; i++)
            {
                int[] val = Array.ConvertAll(Console.ReadLine().Split(' '), (s) => int.Parse(s) - 1);
                
                diffCount += Exchange(list, sorted, val[0], val[1]);

                if (diffCount == 0)
                {
                    ans = i + 1;
                    break;
                }
            }

            Console.WriteLine(ans);
        }

        private static int Exchange(int[] list, int[] sorted, int idx1, int idx2)
        {
            int ret = 0;

            if (list[idx1] != sorted[idx1]) ret--;
            if (list[idx2] != sorted[idx2]) ret--;

            int tmp = list[idx1];
            list[idx1] = list[idx2];
            list[idx2] = tmp;

            if (list[idx1] != sorted[idx1]) ret++;
            if (list[idx2] != sorted[idx2]) ret++;

            return ret;
        }
    }
}


Measured memory_bytes: 47556
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
#define De(...)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
using namespace std; 

int _; 

long long n,sum=26;
string s;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%lld",&n);
	while(n>0)
	{
		s += ('a'+(n-1)%sum/(sum/26));
		n -= sum;
		sum *= 26;
	}
	reverse(s.begin(),s.end());
	std::cout << s << endl;
	return 0;
}


Measured memory_bytes: 3756
n = int(input())
arr = list(map(int, input().split()))

# cost to get to ith pos
dp = [0] *n

for i in range(1,n):
    dp[i] = min(abs(arr[i] - arr[i-1]) + dp[i-1],abs(arr[i]-arr[max(0,i-2)]) + dp[max(0,i-2)])

print(dp[n-1])


Measured memory_bytes: 13980
let f x = if x < 40 then 40 else x;;

let () =
  let n1 = read_int () |> f and
      n2 = read_int () |> f and
      n3 = read_int () |> f and
      n4 = read_int () |> f and
      n5 = read_int () |> f in
  Printf.printf "%d\n" ((n1+n2+n3+n4+n5)/5)
;;

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

int solve() {
  int n;
  cin>>n;
  if(n == 0) return 0;
  int dp[n];
  int h[n];
  for(int i = 0; i<n; ++i) {
    cin>>h[i];
  }
  dp[0] = 0;
  if(n == 1) return dp[n-1];
  dp[1] = abs(h[1]-h[0]);
  if(n == 2) return dp[n-1];
  for(int i = 2; i<n; ++i) {
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
  }
  return dp[n-1];
} 

int main() {
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 4324
#include<stdio.h>

int main(void)
{
	int n, m;
	fflush(stdout);
	scanf("%d %d", &n, &m);

	int arr1[100][100];
	int arr2[100];
	int res[100];

	fflush(stdout);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d", &arr1[i][j]);
		}
	}

	for(int i = 0; i < m; i++){
		scanf("%d", &arr2[i]);
	}

	for(int i = 0; i < n; i++ ){
		res[i] = 0;
		for(int j = 0; j < m; j++){
			res[i]+=arr1[i][j] * arr2[j];
		}
	}

	for(int i = 0; i < n; i++){
		printf("%d\n", res[i]);
	}
	return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main()
{
    string s;
    int ans = 700;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if (s[i] == 'o'){
            ans += 100;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}


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

using namespace std;

int
main(void){
	string s; cin >> s;
	for(char ch = 'a'; ch <= 'z'; ch++){
		int prev = -3;
		for(int i = 0; i < s.size(); i++){
			if(s[i] == ch){
				if(i - prev <= 2){
					cout << prev + 1 << " " << i + 1;
					prev = i;
					return 0;
				}
				prev = i;
			}
		}
	}
	cout << "-1 -1";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,b) for(int i=0; i<int(b);i++)
#define eb emplace_back

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const MAX_V = 10010;
void stronglyConnectedComponents(Graph const & g, int cmp[MAX_V]){
    int n = g.size();
    Graph rg(n);
    rep(i,n) for(auto & e : g[i]) rg[e.dst].eb(e.dst, e.src, e.weight);
    static int added[MAX_V], visited[MAX_V], ord[MAX_V], S[MAX_V];
    rep(i,n) added[i] = visited[i] = cmp[i] = 0;
    int sz = 0;
    rep(i,n){
        if(visited[i]) continue;
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1];
            visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){
                    S[s++] = dst;
                    pushed = true;
                }
            }
            if(!pushed){
                int t = S[s-1];
                if(!added[t]){
                    added[t] = true;
                    ord[sz++] = t;
                }
                s--;
            }
        }
    }
    int k = 1;
    rep(i,n){
        int u = ord[n-i-1];
        if(cmp[u]) continue;
        int s = 0;
        S[s++] = u;
        while(s){
            int v = S[--s];
            cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(!cmp[d]) S[s++] = d;
            }
        }
        k++;
    }
    rep(i,n) cmp[i]--;
}

int main(){
    int n,m;
    scanf("%d%d", &n,&m);
    Graph g(n);
    rep(i,m){
        int a,b;
        scanf("%d%d", &a,&b);
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        scanf("%d%d", &a,&b);
        printf("%d\n", c[a]==c[b]);
    }
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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 dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;
    vint a(n); rep(i,n) cin>>a[i];

    repf(i,k,n){
        // cout<<a[i-k]<<" "<<a[i]<<endl;
        if(a[i-k] < a[i]) puts("Yes");
        else puts("No");
    }

    return 0;

}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],mn=1e9;
	for(int i=0;i<n;++i)
		cin>>a[i];
	int cur=0;
	for(int i=-101;i<=101;++i){
		cur=0;
		for(int j=0;j<n;++j)
			cur+=(a[j]-i)*(a[j]-i);
		mn=min(mn,cur);
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 256
H,N = [int(zz) for zz in input().split()]
mahou = [[int(zz) for zz in input().split()] for _ in range(N)]

dmg = [i[0] for i in mahou]
mp = [i[1] for i in mahou]

dp = [[0]*(H+1) for _ in range(N)]
for j in range(1,H+1):
    if j <= dmg[0]:
        dp[0][j] = mp[0]
    else:
        dp[0][j] = dp[0][j-dmg[0]]+mp[0]

for i in range(1,N):
    for j in range(1,H+1):
        if j <= dmg[i]:
            dp[i][j] = min(mp[i],dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-dmg[i]]+mp[i],dp[i-1][j])

print(dp[-1][-1])


Measured memory_bytes: 119516
#include<bits/stdc++.h>
using namespace std ; 
const int N= 2e6;
long long prime [N];
int freq[N];
bool seive (){
       
        for(int i =2 ;i<=1e6;i++){
                //if(freq[i]>1)return false ;
                if(!prime[i]){
                        int c=0;
                        for(int j=i;j<=1e6;j+=i){
                                
                                prime [j]++ ; 
                                if(freq[j] ){
                                        if(c)return false ; 
                                        else c =1 ; 
                                }if(freq[j]>1)return false ;
                        }
                }
        }
        return true ; 
}
int main(){
      int n,c=1 ; 
      cin>>n ; 
      int arr[n];
      int gcd =0; 
      for(int i =0;i<n;i++){
              cin>>arr[i];
              freq[arr[i]]++; 
             // if(freq[arr[i]]>1)c=0;
              gcd=__gcd(gcd,arr[i]);
      }
      if(gcd==1 ){
             
              if(seive())
                 cout<<"pairwise coprime";
              else cout<<"setwise coprime";
      }else cout<<"not coprime";
      
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    string s ;
    cin >> s ;

    string &v = s ;

    int l = 0 , r = n - 1 ;
    int ans = 0 ;

    while ( l < r )
    {
        while ( l < r && s[l] == 'R' )
            l ++ ;

        while ( r > l && s[r] == 'W' )
            r -- ;

        if ( l >= r )
            break ;

        swap ( v[l] , v[r] ) ;
        ans ++ ;

        l ++ ;
        r -- ;
    }

    int count_red = 0 ;
    for ( auto &c : s )
    {
        if ( c == 'R' )
            count_red ++ ;
    }

    ans = min ( { ans , count_red , n - count_red } ) ;
    cout << ans ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3764
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int curX = 0, curY = 0, curT = 0;
            var total = 0L;

            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                total = Math.Abs(tmp[1] - curX) + Math.Abs(tmp[2] - curY);
                var diff = Math.Abs(total - (tmp[0] - curT));

                if (tmp[0] - curT >= total && (diff == 0 || diff % 2 == 0))
                {
                    curX = tmp[1]; curY = tmp[2]; curT = tmp[0];
                }
                else
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 15408
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using vi = vector<int>;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;

int main() {

	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	string s;
	cin >> s;

	if (D-C>0) {
		//easy
		bool isok = true;
		for (int i = A; i < D-1; i++) {
			if (s[i] == '#'&&s[i + 1] == '#') {
				isok = false;
			}
		}
		if (isok) { cout << "Yes"; }
		else {
			cout << "No";
		}
	}
	else {
		bool isok = false;
		for (int i = A; i < C - 1; i++) {
			if (s[i] == '#'&&s[i + 1] == '#') {
				cout << "No";
				return 0;
			}
		}

		for (int i = B-2; i < D - 1; i++) {
			if (s[i] == '.'&&s[i + 1] == '.'&&s[i + 2] == '.') {
				isok = true;
			}
		}

		if (isok) { cout << "Yes"; }
		else {
			cout << "No";
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll s, c;
	cin >> s >> c;
	ll l = 0, r = c / 2, m, res = 0;
	while (l <= r) {
		m = (l + r) / 2;
		if (m * 2 <= c && s + (c - m * 2) / 2 >= m) {
			res = m;
			l = m + 1;
		}
		else
			r = m - 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int a,b;
    cin>>a>>b;
    rep(i,min(a,b),max(a,b)){
        if(abs(a-i)==abs(b-i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

int main() {
	int input;							//テ・ツ?・テ・ツ環崚ァツ板ィ
	int yen[] = {500,100,50,10,5,1};	//テァツ。ツャティツイツィテ」ツ?ョテァツィツョテゥツ。ツ?
	
	while(1) {
		cin >> input;	//テ・ツ?・テ・ツ環?
		if(input == 0) break;

		int ans = 0;
		input = 1000 - input;
		while(input > 0) {

			for(int i = 0; i < 6; i++) {
				if (input >= yen[i]) {
					input -= yen[i];
					ans++;
					break;
				} 
			}

		}

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

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.);
const int N=105;
int n,x[N],y[N];
double p[N+N];
signed main()
{
    cin>>n;
    for(int i=0; i<n; i++)cin>>x[i]>>y[i];
    for(int i=0; i<n; i++)
    {
        int tot=0;
        for(int j=0; j<n; j++)
            if(i!=j)p[tot++]=atan2(y[j]-y[i],x[j]-x[i]);
        sort(p,p+tot);
        for(int j=0; j<tot; j++)p[j+tot]=p[j]+2*pi;
        double ans=0;
        for(int j=0; j<tot; j++)ans=max(ans,pi-p[j+tot-1]+p[j]);
        printf("%.8f\n",ans/2/pi);
    }
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
 
typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;


int main(){
    fast_cin();
    ll n,k;cin>>n>>k;
    n%=k;
    if(n==0 or n==1){
    	cout<<n<<endl;
    	return 0;
    }
    ll prev=(ll)abs(n-k);
    n=abs(n-k);
    while(true){
    	ll next = (ll)abs(n-k);
    	if(prev>next){
    		prev = next;
    		n=(ll)abs(n-k);
    	}
    	else break;
    }
    cout<<n<<endl;

}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vec;

class Seg
{
public:
    vec data;
    vec lazy;
    int n;

    Seg(int _n)
    {
        data.resize(4*_n);
        lazy.resize(4*_n);
        for(n=1;n<_n;n<<=1);
        fill(data.begin(),data.end(),0);
        fill(lazy.begin(),lazy.end(),0);
    }

    void Down(int p,int l,int r)
    {
        data[p]+=lazy[p]*(r-l);
        if(1+l<r)
        {
            lazy[p*2+1]+=lazy[p];
            lazy[p*2+2]+=lazy[p];
        }
        lazy[p]=0;
    }

    void add(int p,int l,int r,int x,int a,int b)
    {
        if(a>=r||b<=l) return;
        else if(a<=l&&r<=b)
        {
            lazy[p]+=x;
        }else
        {
            int mid=(l+r)/2;
            add(p*2+1,l,mid,x,a,b);
            add(p*2+2,mid,r,x,a,b);
            data[p]+=(min(b,r)-max(a,l))*x;
        }
    }

    ll getSum(int p,int l,int r,int a,int b)
    {
        if(a>=r||b<=l) return 0;
        else if(a<=l&&r<=b) return data[p]+lazy[p]*(r-l);
        else
        {
            Down(p,l,r);
            int mid=(l+r)/2;
            return getSum(p*2+1,l,mid,a,b)+getSum(p*2+2,mid,r,a,b);
        }
    }
};

int main()
{
    int n,q;

    while(scanf("%d %d",&n,&q)!=EOF)
    {
        Seg seg(n);

        while(q--)
        {
            int op,a,b,c;
            scanf("%d",&op);

            if(op)
            {
                scanf("%d %d",&a,&b);
                printf("%lld\n",seg.getSum(0,0,seg.n,a-1,b));
            }else
            {
                scanf("%d %d %d",&a,&b,&c);
                seg.add(0,0,seg.n,c,a-1,b);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 9172
<?php
fscanf(STDIN, "%d", $n);

if($n === 1)
	echo 1;
else if ($n < 4)
	echo 2;
else if ($n < 8)
	echo 4;
else if ($n < 16)
	echo 8;
else if ($n < 32)
	echo 16;
else if ($n < 64)
	echo 32;
else
	echo 64;

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

struct P {
    int x, y, depth;
};

int main() {
    int turn, block_n;
    while (cin >> turn >> block_n, turn|block_n) {
        bool field[200][200] = {};
        REP(i, block_n) {
            int x, y;
            cin >> x >> y;
            x += 100;
            y += 100;
            field[y][x] = true;
        }
        int start_x, start_y;
        cin >> start_x >> start_y;
        start_x += 100;
        start_y += 100;

        int cnt = 1;

        queue<P> que;
        que.push({start_x, start_y, 0});
        field[start_y][start_x] = true;
        while (!que.empty()) {
            P p = que.front(); que.pop();
            if (p.depth == turn) continue;
            REP(i, 6) {
                int sx = p.x + dx[i];
                int sy = p.y + dy[i];
                if (0 <= sx && sx < 200 && 0 <= sy && sy < 200) {
                    if (!field[sy][sx]) {
                        field[sy][sx] = true;
                        cnt++;
                        que.push({sx, sy, p.depth+1});
                    }
                }
            }
        }

        cout << cnt << endl;
    }
}

Measured memory_bytes: 1264
#include <stdio.h>

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

	scanf("%d %d %d", &a, &b, &c);

	if(a==b)
	{
		if(a==c) printf("1");
		else printf("2");
	}
	else if(a==c)
		{
			if(a==b) printf("1");
			else printf("2");
		}
	else if(b==c)
		{
			if(b==a) printf("1");
			else printf("2");
		}
	else printf("3");

   	return 0;
}


Measured memory_bytes: 2092
def main():
  N = int(input())
  A = list(map(int, input().split()))

  ans = 1
  x=y=0
  for i in range(1, N):

    if A[i - 1] < A[i]:
      x = 1

    if A[i - 1] > A[i]:
      y = 1

    if x and y:
      ans += 1
      x = y = 0

  print(ans)

main()


Measured memory_bytes: 85404
using System;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;

            for (int i = 0; i < N; i++)
            {
                var buffer = Console.ReadLine();
                switch (buffer)
                {
                    case "AC": ac++; break;
                    case "WA": wa++; break;
                    case "TLE": tle++; break;
                    case "RE": re++; break;
                }
            }

            Console.WriteLine($"AC x {ac}");
            Console.WriteLine($"WA x {wa}");
            Console.WriteLine($"TLE x {tle}");
            Console.WriteLine($"RE x {re}");
        }
    }
}


Measured memory_bytes: 30464
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/scc>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

int main() {
    int n, m, a, b;
    cin >> n >> m;

    scc_graph sc(n);
    rep(i, 0, m) {
        cin >> a >> b;
        sc.add_edge(a, b);
    }

    auto ans = sc.scc();
    cout << ans.size() << endl;
    for(auto x : ans) {
        cout << x.size();
        for(auto y : x) cout << ' ' << y;
        cout << endl;
    }
}


Measured memory_bytes: 40132
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(void) {
    int N;
scanf("%d",&N);
int array[N];

for (int i=0;i<N;i++)
scanf("%d",&array[i]);
 qsort(array, N, sizeof(int), cmpfunc);
 int i=0;
 float sum = (float)(array[i]+array[i+1])/2;
for (int i=1;i<N-1;i++){
    sum=(sum+(float)array[i+1])/2;
}
printf("%.10f",sum);
return EXIT_SUCCESS;
}

Measured memory_bytes: 128
/*input 
2
157 193
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int arr[maxn];
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    ll cur=1000;
    int n;
    cin>>n;
    REP(i,n) cin>>arr[i];
    REP(i,n-1){
        if(arr[i+1]>arr[i]){
            ll buy=(cur/arr[i]);
            cur-=(buy*arr[i]);
            cur+=buy*arr[i+1];
        }
    }
    cout<<cur;
}


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

int main() {
    double x[3], y[3];
    for (int i = 0; i < 3; i++) {
        cin >> x[i] >> y[i];
    }
    double a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
    double b = sqrt((x[0] - x[2]) * (x[0] - x[2]) + (y[0] - y[2]) * (y[0] - y[2]));
    double c = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2]));
    double s = (a + b + c) / 2;
    double S = sqrt(s * (s - a) * (s - b) * (s - c));
    double r = 2 * S / (a + b + c);
    double m = max({a, b, c});
    double ans = m * r / (m + 2 * r);
    printf("%.12f\n", ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input().strip())
ab_list = [list(map(int, input().rstrip().split())) for i in range(N)]
cd_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

cd_list.sort()
cnt = 0

for b_x, b_y in cd_list:
    tmp_red = [ [r_x, r_y] for r_x, r_y in ab_list if (r_x < b_x) and (r_y < b_y) ]
    
    if tmp_red:
        tmp_red.sort(key= lambda x: x[1])
        
        cnt += 1
        ab_list.remove( tmp_red[-1] )

print(cnt)


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
//typedef pair<string, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    int N; cin >> N;
    pair<pair<string,int>,int> cityPoint[105];
    for (int i = 1; i <= N; i++) {
        string S; int A;
        cin >> S >> A; 
        cityPoint[i].first.first = S;
        cityPoint[i].first.second = -A;
        cityPoint[i].second = i;
    }
    sort(cityPoint,cityPoint+N+1);
    for (int i = 1; i <= N; i++) {
        cout << cityPoint[i].second << endl;
    }
    
}


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

int main() {
  int x,y; cin>>x>>y;
  if(y%2==0&&y>=2*x&&y<=4*x){cout<<"Yes";}
  else{cout<<"No";}
}

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

typedef long long ll;
typedef unsigned long long ull;

ll modn(ll x, ll n){
    ll r = x%n;
    while(r<0) r+=n;
    return r;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    ll n, l, t;
    cin >> n >> l >> t;
    ll x[100000], w[100000];
    for(int i=0;i<n;i++) cin >> x[i] >> w[i];

    ll idx = 0;
    for(int i=1;i<n;i++){
        if(w[0] == w[i]) continue;
        int d;
        if(w[0] == 1) d = modn(x[i]-x[0], l);
        else d = modn(x[0]-x[i], l);
        if(2*t < d) continue;
        if(w[0] == 1) idx += (2*t-d)/l+1;
        else idx -= (2*t-d)/l+1;
        idx = modn(idx, n);
    }
    ll p = (w[0]==1?modn(x[0]+t, l):modn(x[0]-t, l));

    vector<ll> ants;
    for(int i=0;i<n;i++){
        if(w[i] == 1) ants.push_back(modn(x[i]+t, l));
        else ants.push_back(modn(x[i]-t, l));
    }
    sort(ants.begin(), ants.end());

    int cnt = 0;
    bool f = false;
    map<ll,ll> ans;
    for(int i=0;i<n;i++){
        if(f){
            ans[idx] = ants[i];
            cnt++;
            idx = modn(idx+1, n);
        }else if(ants[i]==p){
            if(w[0]==2 || ants[(i+1)%n] != ants[i]){
                ans[idx] = ants[i];
                cnt++;
                idx = modn(idx+1, n);
                f = true;
            }
        }
    }
    for(int i=0;cnt<n;i++){
        ans[idx] = ants[i];
        cnt++;
        idx = modn(idx+1, n);
    }
    
    for(int i=0;i<n;i++) cout << ans[i] << endl;

    return 0;
}

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

int main() {
    ll H, N;
    cin >> H >> N;
    ll A=0, A_temp;
    for (ll i=0; i<N; i++) {
        cin >> A_temp;
        A+=A_temp;
    }
    string ans;
    if (A>=H) {
        ans = "Yes";
    }
    else {
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int flg[1001]={0};
int main(void)
{
	int a,b,n,s,f;
	int i,j;
	
	cin>>a>>b>>n;
	
	flg[a]=1,flg[b]=-1;
	
	for(i=0;i<n;i++){
		cin>>s>>f;
		flg[s]++;
		flg[f]--;
	}
	
	int sum=0,max=-1;
	for(i=0;i<1000;i++){
		sum+=flg[i];
		if(max<sum) max=sum;
	}	
	
	if(max==1) cout<<"0"<<endl;
	else cout<<"1"<<endl;
	
	return 0;
}	


Measured memory_bytes: 3136
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, a);
    IN(string, b);
    IN(string, c);
    ll na = a.size();
    ll nb = b.size();
    ll nc = c.size();
    ll offset = nb + nc;
    ll r = na + max(nb, nc);
    auto f = [&](string &x, string &y) {
        ll n = x.size();
        ll m = y.size();
        vector<bool> res(offset + r + 1);
        for (ll i = -offset; i <= r; ++i)
        {
            res[i + offset] = true;
            REP(j, m)
            {
                if (not(i + j < 0 or i + j >= n or y[j] == x[i + j] or y[j] == '?' or x[i + j] == '?'))
                {
                    res[i + offset] = false;
                }
            }
        }
        return res;
    };
    auto ab = f(a, b);
    auto ac = f(a, c);
    auto bc = f(b, c);
    ll ans = INF;
    for (ll i = -offset; i <= r; ++i)
    {
        for (ll j = -offset; j <= r; ++j)
        {
            ll d = j - i;
            if (ab[i + offset] and ac[j + offset] and (d < -offset or d > r or bc[d + offset]))
            {
                CH(min, ans, max({na, i + nb, j + nc}) - min({0LL, i, j}));
            }
        }
    }
    OUT(ans);
}

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

using namespace std;

typedef long long int lli;

int main() {
    const lli mod = 1000000007;
    int n, m;

    cin >> n >> m;
    vector<lli> x(n), y(m), sx(n+1, 0), sy(m+1, 0);
    for (int i=0; i<n; i++) {
        cin >> x[i];
        x[i] += (lli)1e+9;
        sx[i+1] = (x[i]+sx[i]) % mod;
    }
    for (int i=0; i<m; i++) {
        cin >> y[i];
        y[i] += (lli)1e+9;
        sy[i+1] = (y[i]+sy[i]) % mod;
    }

    lli X = 0;
    for (int i=1; i<n; i++) {
        X += mod + (x[i]*i)%mod - (mod+sx[i]-sx[0])%mod;    // mod + (mod + sx[n] - sx[i])%mod - (x[i-1] * (lli)(n-i))%mod;
        X %= mod;
    }
    lli Y = 0;
    for (int i=1; i<m; i++) {
        Y += mod + (y[i]*i)%mod - (mod+sy[i]-sy[0])%mod;    // mod + (mod + sy[m] - sy[i])%mod - (y[i-1] * (lli)(m-i))%mod;
        Y %= mod;
    }

    cout << (X * Y) % mod << endl;

    return 0;
}


Measured memory_bytes: 3328
# Papers, Please

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

for Ai in A:
  if Ai % 2 == 1:
    continue
  else:
    if Ai % 3 != 0 and Ai % 5 != 0:
      print("DENIED")
      exit()

print("APPROVED")

Measured memory_bytes: 8900
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var xy = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(xy[0] + xy[1] / 2);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=305;
const int mod=998244353;
int n,s0[maxn],s1[maxn],mx[maxn][maxn];
char s[maxn];
ll f[maxn][maxn][maxn];
inline void chkmax(int &a,int b) { a=(a>b)?a:b; }
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=n;i;i--) s0[i]=s0[i+1]+(s[i]=='0'),s1[i]=s1[i+1]+(s[i]=='1');
	f[0][0][n+1]=1;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
			for(int k=n+1;k;k--)
				if(f[i][j][k])
				{
					(f[i+1][j+1][k-((k>1)?s[k-1]=='0':0)]+=f[i][j][k])%=mod;
					(f[i+1][j][k-((k>1)?s[k-1]=='1':0)]+=f[i][j][k])%=mod;
				}
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
			for(int k=1;k<=n+1;k++) (f[i][j][k]+=f[i][j][k-1])%=mod;
	mx[s0[1]][s1[1]]=1;
	ll ans=0;
	for(int i=s0[1];i>=0;i--)
		for(int j=s1[1];j>=0;j--)
		{
			int k=mx[i][j];
			if(k<n)
			{
				if((s[k]=='0' || s[k+1]=='0') && i) chkmax(mx[i-1][j],k+2);
				if((s[k]=='1' || s[k+1]=='1') && j) chkmax(mx[i][j-1],k+2);
			}
			if(i && (k>n || i>s0[k+1])) chkmax(mx[i-1][j],min(k+1,n+1));
			if(j && (k>n || j>s1[k+1])) chkmax(mx[i][j-1],min(k+1,n+1));
			if(mx[i][j] && i+j>0) (ans+=f[i+j][i][mx[i][j]])%=mod;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 114116
#include <iostream>
using namespace std;
#define MAX 10000001

bool p[MAX];

int main()
{
	for (int i=0; i<MAX; i++)
		p[i] = 1;

	p[0] = p[1] = 0;
	for (int i=2; i*i<MAX; i++)
		if (p[i])
			for (int k=i+i; k<MAX; k+=i)
				p[k] = 0;

	int N;
	while (cin >> N, N)
	{
		for (int n=N; n>=0; n--)
		{
			if (p[n]&&p[n-2]&&p[n-6]&&p[n-8])
			{
				cout << n << endl;
				break;
			}
		}
	}

	return 0;
}

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

int main() {
  long long X; cin >> X;
  long long init = 100;
  long long year = 0;
  while (init < X) {
    year++;
    init = init * 1.01;
  }
  cout << year << endl;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    signed long long x,a,q,y,z,n,t;
    cin>>n;
    cin>>q;
    getchar();
    priority_queue<int>S[n];
    priority_queue<int>S2[n];
     for(int i=1; i<=q; i++)
    {
        cin>>a;
        if(a==0)
        {
            cin>>t;
            cin>>x;
            S[t].push(x);
        }
        else if(a==1)
        {
            cin>>t;
            if(!S[t].empty())
            {
          cout<<S[t].top()<<endl;
            S2[t].push(S[t].top());
            S2[t].pop();
            }
        }
        else if(a==2)
        {
            cin>>t;
            if(!S[t].empty())
            {
                S[t].pop();
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4196
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, k = inpl()
a = n%k
b = k-(a)
print(min(a, b))

Measured memory_bytes: 4076
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  int N,M,K;
  cin >> N >> M >> K;

  for(int i=0;i<=N;++i){
    for(int j=0;j<=M;++j){
      int num = (N-i)*(M-j) + i*j;
      if( num == K ) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int n, q;
string s;
char t[200005], d[200005];

bool check(int k, int ok, int ng) {
    // k番目のゴーレムが消滅するか
    int cur = k;
    for (int i = 0; i < q; i++) {
        if (k == ok) return true;
        if (k == ng) return false;
        if (t[i] == s[k]) {
            if (d[i] == 'L') {
                k--;
            } else {
                k++;
            }
        }
    }

    if (k == ok) return true;
    return false;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q >> s;

    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }

    int ans = n;

    // 二分探索
    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (check(mid, -1, n)) {
            l = mid;
        } else {
            r = mid;
        }
    }

    ans -= (l + 1);

    l = -1, r = n;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (check(mid, n, -1)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    ans -= (n - r);

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 976
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        long N = sc.nextInt();

        if(N%2==0){
            System.out.println(N);
        }
        else{
            System.out.println(N * 2);
        }
    }
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.14159265;

int main(){
	IO;
	string s;
	cin>>s;
	int half = s.length()/2;
	int size = s.length();
	for(int i = 0; i<half ; i++){
		if(s[i]!=s[size-i-1] ){
			cout<<"No\n";
			return 0;
		}
	}
	for(int i = 0; i<half/2-1; i++){
		if(s[i]!=s[half-i-1] && s[half+i]!=s[size-i-1]){
			cout<<"No\n";
			return 0;
		}
	}
	(size == 5 && (s[0]!=s[1] || s[3]!=s[4]))?cout<<"No\n":cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int b[110];
int a[110];
int main(){
  int n; cin >> n;
  for(int i=1;i<=n-1;++i) cin >> b[i];
  a[n] = b[n-1];
  for(int i=n-1;i>=2;i--) a[i] = min(b[i-1], b[i]);
  a[1] = b[1];
  int ans = 0;
  for(int i=1;i<=n;++i) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.next();
	int len = str.length();
	int cnt01 = 0;
	int cnt10 = 0;
	if(len==1) {
	    System.out.println(0);
	    return;
	}
	for(int i = 0; i<len; i++) {
	    if(i%2 == 0) {
		if(str.charAt(i) == '1') cnt01++;
		else cnt10++;
	    } else {
		if(str.charAt(i) == '0') cnt01++;
		else cnt10++;
	    }
	}
	System.out.println(Math.min(cnt01,cnt10));
    }
}

Measured memory_bytes: 24788
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) X.begin(), X.end()
#define sz(X) (int)X.size()

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

// xz

int main()
{ _
    ll x, k, d; cin >> x >> k >> d;

    x = abs(x);

    ll t = min(x / d, k);
    x -= t * d;
    k -= t;

    if (k % 2) x -= d;

    cout << abs(x) << endl;

    exit(0);
}



Measured memory_bytes: 3652