akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (_a, _b, _c) = get!(u64, u64, u64);
    let _k = get!(u32);

    let k: u32 = (_k).into();
    let base: u64 = 2;
    let mut a = _a;
    let mut b = _b;
    let mut c = _c;

    use std::cmp;

    if cmp::max(a, cmp::max(b, c)) == a {
        a = a * base.pow(k);
    } else if cmp::max(b, cmp::max(a, c)) == b {
        b = b * base.pow(k);
    } else {
        c = c * base.pow(k);
    }

    let ans = a + b + c;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, l=0;
  cin>>N ;
  int A[N] ;
  for(int i=0; i<N; i++)
  {  cin>>A[i] ;
  }
  for(int j=0; j<N; j++)
  {  if(A[j]%2==0)
     {  if((A[j]%3==0)||(A[j]%5==0))
          l++;
        else
          l--;
     }
     else 
       l++;
  }
  if(l==N)
    cout<<"APPROVED";
  else
    cout<<"DENIED";
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
  { [n, t] <- readLineInputs
  ; pc <- loop t 1001 n
  ; putStrLn $ if pc == 1001 then "TLE" else show pc
  }

loop :: Int -> Int -> Int -> IO Int
loop _ pc 0 = return pc
loop lt pc n = do
  { [cc, ct] <- readLineInputs
  ; if ct <= lt then loop lt (min pc cc) (pred n) else loop lt pc (pred n)
  }

readLineInputs :: Read a => IO [a]
readLineInputs = map read . words <$> getLine


Measured memory_bytes: 1020
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	priority_queue<long long>a;
	vector<pair<long long, int> >b;
	int n, k, z;
	long long x, y;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n,&k);
	f(i, n) {
		scanf("%lld", &x);
		a.push(x);
	}

	f(i, k) {
		scanf("%d %lld", &z, &x);
		b.push_back(make_pair(x, z));
	}
	sort(b.begin(), b.end(),greater<pair<long long,int> >());
	ans = 0;
  z=0;
	f(i, k) {
		while (a.size()>z) {
			if (b[i].first < a.top()) {
				ans += a.top();
				a.pop();
			}
			else break;
		}
		f(j, b[i].second) {
			if (a.size()>z) {
				ans += b[i].first;
              z++;
			}
			else break;
		}
		if (a.size()<=z)break;
	}
	while (a.size()>z) {
		ans += a.top();
		a.pop();
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,m,sum=0,cnt=0;
    cin>>n>>m;

   cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
  string s;
  cin >> s;
  int year=0,month=0,day=0;
  string temp;
  rep(i,4)temp+=s[i];
  year=stoi(temp);
  temp="";
  REP(i,5,7)temp+=s[i];
  month=stoi(temp);
  temp="";
  REP(i,s.size()-2,s.size())temp+=s[i];
  day=stoi(temp);
  if(year<=2019 && month<=4 && day<=30)cout << "Heisei" << endl;
  else cout << "TBD" << endl;
return 0;}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int p[1000];
	int N,K,sum=0;
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>p[i];
	sort(p,p+N);
	for(int i=0;i<K;i++)sum+=p[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
    // Here your code !
    long long int n,k;
    int i,j,l;
    int a,b;
    long long int sum=0;
    scanf("%lld %lld",&n,&k);
    long long int test[100000];
    for(j=0;j<100000;j++)
    {
        test[j]=0;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a,&b);
        test[a-1]+=b;
        
    }
    for(l=0;l<100000;l++)
    {
        sum+=test[l];
        if(sum>=k)
        {
            printf("%d\n",l+1);
            break;
        }
        
        
    }
 
     
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

/*keyがn個の配列A内にあるかを調べる*/
/*半分より大きいか調べて、もし大きければ半分より大きい中で半分より大きいか調べ...を繰り返してmidを検索値とするもの*/
int Binary_Search(int key , int A[] , int n) {
    /*leftはA[0] rightはA[n]のこと。すなわち配列番地のこと*/
    int left = 0;
    int right = n;
    int mid;
    
    while(left < right) {
        /*midの設定(配列の真ん中の番地)*/
        mid = (left + right) / 2;
        /*keyをmidに追いやるのが目標*/
        if(A[mid] == key)
            return 1;
        /*keyが中央値よりも小さかったら＝keyが左半分にあるなら*/
        /*leftそのまま rightをmidに　midを左半分の中間値(whileの一番上でやります)に(繰り返してkeyを追いやる)*/
        else if(key < A[mid])
            right = mid;
        /*keyが中央値よりも大きかったら＝keyが右半分にあるなら*/
        /*rightそのまま (keyはmid以上であることが他のifよりわかるので)leftをmid+1に　midを右半分の中間値(whileの一番上でやります)に(繰り返してkeyを追いやる)*/
        else
            left = mid + 1;
    }
    /*見つからない*/
    return -1;
}

int main(void)
{
    int n , q;
    int i , j , k;
    int count = 0;
    
    scanf("%d" , &n);
    
    int S[n];
    for(i = 0 ; i < n ; i++)
        scanf("%d" , &S[i]);
    
    scanf("%d" , &q);
    
    int T[q];
    for(j = 0 ; j < q ; j++)
        scanf("%d" , &T[j]);
    
    for (k = 0 ; k < q ; k++) {
        if(Binary_Search(T[k] , S , n) == 1)
            count++;
    }
    
    printf("%d\n" , count);
    
    return 0;
}



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

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if((a==1 or a==3 or a==5 or a==7 or a==8 or a==10 or a==12) and (b==1 or b==3 or b==5 or b==7 or b==8 or b==10 or b==12))
    {
        printf("Yes");
    }
    else if((a==4 or a==6 or a==9 or a==11) and (b==4 or b==6 or b==9 or b==11))
    {
        printf("Yes");
    }
    else if((a==2) and (b==2))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


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

using namespace std;

int n,m,h,w,i,j;
long long sum[505][505],a[505][505];

long long s(int x, int y, int xx, int yy){
	return sum[xx][yy] - sum[xx][y - 1] - sum[x - 1][yy] + sum[x - 1][y - 1];
}

int main(){
	scanf("%d%d%d%d", &n, &m, &h, &w);
	
	for(i = 1; i <= n; i++){	
		for(j = 1; j <= m; j++)
		a[i][j] = 3999;
	}
	
	for(i = 1; i <= n; i++){
		for(j = 1; j <= m; j++){
			
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
			
			if(i >= h && j >= w){
				long long v = s(i - h + 1, j - w + 1, i, j);
				if(v >= 0)
				a[i][j] -= v + 1;
				else
				a[i][j] += v + 1;
			}
			
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
		}
	}
	
	if(sum[n][m] > 0){
		printf("Yes\n");
		
		for(i = 1; i <= n; i++){
			for(j = 1; j <= m; j++){
				if(j == 1)
				printf("%lld", a[i][j]);
				else
				printf(" %lld", a[i][j]);
			}
			printf("\n");
		}
	}
	else
	printf("No\n");
}


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

bool palindrome(string s){
    bool correct = true;
    if (s.size() % 2 == 0){
        for (int i = 0; i < s.size()/2; i++){
            if (s.at(i) != s.at(s.size()-i-1)){
                correct = false;
            }
            
        }
    }
    else {
        for (int i = 0; i < (s.size()-1)/2; i++){
            if (s.at(i) != s.at(s.size()-i-1)){
                correct = false;
            }
        }
    }

    return correct;
}


int main(){
    string s;
    cin >> s;
    string l = s.substr(0, (s.size()-1)/2);
    if (palindrome(s) && palindrome(l)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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


int main()
{

    int n,k;
    cin>>n>>k;

    set<int> s;

    while(k--){
        int a;

        cin>>a;

        for(int i=0;i<a;i++){
            int b;
            cin>>b;
            s.insert(b);
        }

    }

     cout<<n-s.size()<<endl;



    return 0;
}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 10005
int N,M;
int main(){
  while(cin>>N>>M){
    int Min[MAX_N]={},Max[MAX_N]={};
    if(M==0&&N==0)break;
    for(int i=0;i<M;i++){
      int p,k,id;
      cin>>p>>k;
      for(int j=0;j<k;j++){
        cin>>id;
        id--;
        if(k==1){
          Min[id]+=p;
        }
        Max[id]+=p;
      }
    }
    int ans=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<i;j++){
        if(Max[i]>Min[j])
          ans=max(ans, abs(Max[i]-Min[j]) );
        
        if(Max[j]>Min[i])
          ans=max(ans, abs(Max[j]-Min[i]) );
      }
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int N, A, B;
	int asumi, iguti;
	if (scanf("%d%d%d", &N, &A, &B) != 3) return 1;
	asumi = (A + B) - N;
	iguti = A <= B ? A : B;
	printf("%d %d\n", iguti, asumi < 0 ? 0 : asumi);
	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = unsigned long long;

int know_digit(ll n)
{
    int ans = 0;
    while(n){
        n /= 10;
        ++ans;
    }
    return ans-1;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        if(a.at(i) == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ima = 1e18;
    sort(all(a), greater<ll>());
    if(a.front() > ima){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 1;
    for(i = 0;i < n;++i){
        if(a.at(i) > ima){
            cout << -1 << endl;
            return 0;
        }
        if(know_digit(ans) + know_digit(a.at(i)) > 18){
            cout << -1 << endl;
            return 0;
        }
        ll tmp = ans*a.at(i);
        if(tmp < ans || tmp > ima){
            cout << -1 << endl;
            return 0;
        }
        ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout << a[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, readline().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
def check(s, t):
    u = [0]*N
    u[s] = u[t] = 1
    for v in G[s]:
        if v == t:
            continue
        u[v] = 1
        que = deque([v])
        ok = 0
        while que:
            x = que.popleft()
            for y in G[x]:
                if y == s and x != v:
                    return 1
                if u[y]:
                    continue
                u[y] = 1
                que.append(y)
    return 0
C = [0]*4
ok = 1
for i in range(N):
    if len(G[i]) % 2 == 1:
        ok = 0
    C[min(3, len(G[i])//2)] += 1
if C[1] == N or (C[1] == N-1 and C[2] == 1):
    ok = 0
elif C[1] == N-2 and C[2] == 2:
    VV = []
    for i in range(N):
        if len(G[i]) == 4:
            VV.append(i)
    if not check(*VV):
        ok = 0
print("Yes" if ok else "No")

Measured memory_bytes: 54320
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
int a,b,c;
int pa,pb,pc;
bool chk(){
    if(a%2==1||b%2==1||c%2==1)
        return 1;
    return 0;
}
void proc(){
    pa = a;
    pb = b;
    pc = c;
    a = (pc+pb)/2;
    b = (pa+pc)/2;
    c = (pa+pb)/2;
}

int main(){
    cin>>a>>b>>c;
    if(chk()){
        cout<<"0";
        return 0;
    }
        
    if(a==b&&b==c){
        cout<<-1;
        return 0;
    }
    int r = 0;
    while(!chk()){
        proc();
        r++;
    }
    cout<<r;
    
    return 0;
}

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

vector<int> compress(const string &S) {
    vector<int> A;
    int N = S.size();
    for(int i = 0; i < N; ++i) {
        int j = i;
        while(j < N && S[i] == S[j]) j++;
        A.push_back(j - i);
        i = j - 1;
    }
    return A;
}

int main() {
    int N, K;
    cin >> N >> K;
    string S; cin >> S;
    vector<int> C = compress(S);
    int ans = 0;
    int M = C.size();
    rep(i, 0, C.size()) ans += C[i] - 1;
    ans += 2 * K;
    ans = min(ans, N - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		String U = sc.next();
		
		int ansA = A;
		int ansB = B;
		
		if (S.equals(U)) {
			ansA = A-1;
		} else if (T.equals(U)) {
			ansB = B-1;
		}
		System.out.println(ansA + " " + ansB);
	}
}

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

int main(){
    int n;
    int odd;
    cin>>n;
    odd = n - (n/2);

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

    double N = (double) n;
    double ODD = (double) odd;

    cout<<ODD/N<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n;
vi a, b, c;
int cgt(int val){
  int l = -1, r = n, mid;
  while(r - l > 1){
    mid = (l + r) / 2;
    if(c[mid] >= val){
      r = mid;
    }else{
      l = mid;
    }
  }
  return n-r;
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int t;
    cin >> t;
    a.pb(t);
  }
  FOR(i, 0, n){
    int t;
    cin >> t;
    b.pb(t);
  }
  ll ans = 0;
  c.resize(n);
  FOR(i, 1, 30){
    int k = 1 << i, k2 = 1 << (i-1);
    FOR(j, 0, n) c[j] = a[j] % k;
    sort(rng(c));
    int cc = 0;
    for(int j: b){
      int bb = j % k;
      cc += cgt(k2 - bb) - cgt(k2 * 2 - bb) + cgt(k2 * 3 - bb) - cgt(k2 * 4 - bb);
    }
    if(cc%2) ans += k2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2804
#include<iostream>
#include<vector>
#include<utility>
#include<cmath>

#define INF (1 << 29)

using namespace std;

int fix(int num)
{
    return min(255, max( num, 0) );
}

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

        vector<int> in_C(M);
        for(auto& _c : in_C)
        {
            cin >> _c;
        }

        vector<int> in_X(N);
        for(auto& _x : in_X)
        {
            cin >> _x;
        }

        int dp[2][256];
        for(int i = 0; i < 256; i++)
        {
            dp[0][i] = dp[1][i] = INF;
        }

        for(int i = 0; i < M; i++)
        {
            int sub = fix(128 + in_C[i]);
            dp[0][sub] = pow(in_X[0] - sub, 2.0);
        }

        for(int n = 1; n < N; n++)
        {
            for(int i = 0; i < 256; i++)
            {
                for(int j = 0; j < M; j++)
                {
                    int sub = fix(i + in_C[j]);
                    int nextScore = dp[0][i] + pow( in_X[n] - sub, 2.0 );
                    dp[1][sub] = min(dp[1][sub], nextScore);
                    /*
                    cout << sub << endl;
                    cout << dp[0][sub] << endl;
                    cout << pow( in_X[n] - sub, 2.0 ) << endl;
                    cout << endl;
                    //*/
                }
            }
            for(int i = 0; i < 256; i++)
            {
                dp[0][i] = dp[1][i];
                dp[1][i] = INF;
            }
        }

        int ans = INF;
        for(int i = 0; i < 256; i++)
        {
            ans = min(ans, dp[0][i]);
            //cout << i << " : "<< ans << endl;
        }
        cout << ans << endl;

    }



    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    double n,x;
    cin >> n;
    x = pow(n/3,3);
    cout << setprecision(12)<<x << endl;

}

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

const double pi = 3.14159265359;

signed main() {
    double r;
    cin >> r;
    double area = r * r * pi, length = 2 * r * pi;
    
    printf("%8lf %8lf", r * r * pi, 2 * r * pi);
}


Measured memory_bytes: 3212
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int a,b,c;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> a >> b >> c;
	if(a == b) rc(c);
	if(b == c) rc(a);
	rc(b);
}


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

#define MAX_N 105
#define MAX_W 100005

long long i, T, G, ans, N, MW, V[MAX_N], W[MAX_N], memo[MAX_N][MAX_W];

long long value(long long id, long long w) {
  if (id == N || w == 0) return 0;
  if (memo[id][w] != -1) return memo[id][w];
  if (W[id] > w)         return memo[id][w] = value(id + 1, w);
  return memo[id][w] = max(value(id + 1, w), V[id] + value(id + 1, w - W[id]));
}

int main() {
   
    memset(memo, -1, sizeof memo);

    cin>>N>>MW;
   // scanf("%lld",&MW);
    for (i = 0; i < N; i++)
      cin>>W[i]>>V[i];
    ans = 0;
      ans = value(0, MW);

    printf("%lld\n", ans);
  

  return 0;
}

Measured memory_bytes: 82432
n,k = map(int,input().split())
A=[*map(int,input().split())]
for i in range(k):
    B = [0]*n
    for j in range(n):
        d = A[j] # 強さ
        l = max(0, j-d) # 範囲
        r = j+d+1 # 範囲
        B[l] += 1
        if r <= n-1: B[r] -= 1
    is_same = True
    for j in range(n-1):
        B[j+1] = B[j+1] + B[j]
        if B[j+1] != n: is_same = False
    # print(B)
    if is_same: break
    A = B
# print(B)
print(*B,sep=' ')


Measured memory_bytes: 156328
#include<stdio.h>

int main(void)
{
  int n, a[100], i, k, max = 0, temp, j, sum = 0;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &a[i]);
  for(k = 0 ; k < n ; k++)
    {
      for(i = k ; i < n ; i++)
	{
	  if(max < a[i])
	    {
	      max = a[i];
	      j = i;
	    }
	}
      max = 0;
      temp = a[k];
      a[k] = a[j];
      a[j] = temp;
    }
  
  for(i = 0 ; i < n-1 ; i++)
    {
      sum += a[i] - a[i+1];
    }
  printf("%d\n", sum);
}

  
  


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

a.sort()
b.sort()
c.sort()

import bisect

ans = 0
for j in range(n):
    i = bisect.bisect_left(a, b[j])
    k = bisect.bisect_right(c, b[j])
    ans += i * (n - k)

print(ans)


Measured memory_bytes: 23328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int x,a,b; cin >>x>>a>>b;
    int res = x-a;
    res %= b;

    cout << res << endl; 
    
    return 0;
}




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

std::string s;

std::string output()
{
    if (s.size() == 3) {
        std::reverse(s.begin(), s.end());
    }
    return s;
}

int main(void)
{
    std::cin >> s;
    std::cout << output() << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int l = 0, r = s.size()-1;
  while(s[l] != 'A')
    l++;
  while(s[r] != 'Z')
    r--;
  
  cout << r-l+1 <<endl;
  
  return 0;
}


Measured memory_bytes: 3748
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    int S,M,s,m,h;
    cin >> S;
    s = S % 60;
    M = S / 60;
    m = M % 60;
    h = M / 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1144
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc114-C
// #[fastout]
fn main() {
    input![n_input: usize];
    n_input;

    let mut num753_cand: Vec<usize> = Vec::new();

    go(0, 0, 3, &mut num753_cand, n_input);
    go(0, 0, 5, &mut num753_cand, n_input);
    go(0, 0, 7, &mut num753_cand, n_input);

    let mut ans = 0;
    for i in num753_cand.iter() {
        let i_str = i.to_string();

        let mut is_753 = true;
        let mut counts = vec![0; 3];
        for c in i_str.chars() {
            if c != '7' || c != '5' || c != '3' {}

            match c {
                '7' => counts[0] += 1,
                '5' => counts[1] += 1,
                '3' => counts[2] += 1,
                _ => {
                    is_753 = false;
                    break;
                }
            }
        }

        if !is_753 {
            continue;
        }

        if counts.iter().all(|c| *c > 0) {
            ans += 1;
        }
    }

    println!("{}", ans);
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {
    if mid > n {
        return;
    }

    let mut fact = 1;
    for _ in 0..d {
        fact *= 10;
    }

    let plus = fact * use_num;
    let new_mid = mid + plus;

    if new_mid > n {
        return;
    }

    num753_cand.push(new_mid);

    go(new_mid, d + 1, 3, num753_cand, n);
    go(new_mid, d + 1, 5, num753_cand, n);
    go(new_mid, d + 1, 7, num753_cand, n);
}


Measured memory_bytes: 2344
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Data.List
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.Vector ((!))
import Control.Applicative
getInts :: IO [Int]
getInts = unfoldr (B8.readInt . B8.dropWhile (==' ')) <$> BS.getLine
data Edge = Edge {to :: Int,revIx :: Int,capIx :: Int}
  deriving (Show,Eq)
type Graph = V.Vector (V.Vector Edge)


printGraph :: Show a => V.Vector (V.Vector a) -> IO ()
printGraph = V.mapM_ (\i -> V.mapM (putStr . (' ':) . show) i >> putStrLn "")

printCap :: MV.IOVector Int -> IO ()
printCap v = print =<< V.freeze v
      
getGraph :: IO (Graph,MV.IOVector Int)
getGraph = do
  v:e:_ <- getInts
  cap <- MV.new (e*2)
  g <- MV.replicate v []
  forM_ [0..e-1] $ \i -> do
    u:v:c:_ <- getInts
    MV.write cap i c
    MV.write cap (i + e) 0
    us <- MV.read g u
    vs <- MV.read g v
    MV.write g u $ Edge v (e+i) i: us
    MV.write g v $ Edge u i (e+i): vs
    return ()
  g' <- V.map (V.fromList . reverse) <$> V.freeze g
  return (g', cap)

main :: IO ()
main = do
  (g,cap) <- getGraph
  -- printGraph g
  -- printCap cap
  r <- maxFlow 0 (V.length g - 1) g cap
  print r
  return ()

untilJustM :: Monad m => (a -> m (Maybe b)) -> V.Vector a -> m (Maybe b)
untilJustM act xs
  | V.null xs = return Nothing
  | otherwise = let v = V.head xs
                in do
      x <- act v
      case x of
        Nothing -> untilJustM act (V.tail xs)
        Just _ -> return x
      
maxFlow :: Int -> Int -> Graph -> MV.IOVector Int -> IO Int
maxFlow s t g cap = loop 0
  where
    loop f = do
      used <- MV.replicate (V.length g) False
      df <- dfs maxBound s t g cap used
      if df == 0
        then return f
        else loop (f + df)

dfs :: Int -> Int -> Int -> Graph
  -> MV.IOVector Int
  -> MV.IOVector Bool
  -> IO Int
dfs f v t g cap used
  -- | traceShow v False = undefined
  | v == t = return f
  | otherwise = do
      MV.write used v True
      fromMaybe 0 <$> untilJustM act (g ! v)
  where
    act :: Edge -> IO (Maybe Int)
    act e@Edge {to = to,capIx = ci, revIx = ri} = do
      c <- MV.read cap ci
      isUsed <- MV.read used to
      if c > 0 && not isUsed
      then do
        d <- dfs (min f c) to t g cap used
        if d > 0
        then do
          modifyCap cap e d
          return (Just d)
        else return Nothing
      else return Nothing

modifyCap :: MV.IOVector Int -> Edge -> Int -> IO ()
modifyCap cap Edge {capIx = ci, revIx = ri} d
  = do
  cv <- MV.read cap ci
  cr <- MV.read cap ri
  MV.write cap ci $ cv - d
  MV.write cap ri $ cr + d

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

int n;
set<pair<int, int> > st;
set<int> st_x, st_y;
map<int, vector<int> > mp_x, mp_y;
int q[202202 * 2];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		int x, y; 
		scanf("%d%d", &x, &y);
		st.insert(make_pair(x, y));
		mp_x[x].push_back(y);
		mp_y[y].push_back(x);
	}
	
	long long ans = 0;
	while(st.size() > 0) {
		st_x.clear(); 
		st_y.clear();
		
		pair<int, int> p = *(st.begin());
		int l = 0, r = 0;
		q[r++] = p.first; q[r++] = p.second;
		
		while(l<r) {
			int x = q[l++], y = q[l++];
			st.erase(make_pair(x, y));
			st_x.insert(x); st_y.insert(y);
			
			for(int i = 0; i < mp_x[x].size(); i++) {
				int nxt_x = x; 
				int nxt_y = mp_x[x][i];
				if (st.find(make_pair(nxt_x, nxt_y)) == st.end()) continue;
				q[r++] = nxt_x; q[r++] = nxt_y;
			}
			mp_x[x].clear();
			
			for(int i = 0; i < mp_y[y].size(); i++) {
				int nxt_x = mp_y[y][i]; 
				int nxt_y = y;
				if (st.find(make_pair(nxt_x, nxt_y)) == st.end()) continue;
				q[r++] = nxt_x; q[r++] = nxt_y;
			}
			mp_y[y].clear();
		}
		ans += 1LL * st_x.size() * st_y.size();
	}
	cout<<ans-n<<endl;
	
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1; 
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,j,book[8005],top,zhan[8005],a[505][505];
long long gcd(long long u,long long v){
	if(v==0) return u;
	return gcd(v,u%v);
}
long long lcm(long long u,long long v){
	if(u==0) return v;
	if(v==0) return u;
	return u/gcd(u,v)*v;
}
int main(){
//	freopen("number.in","r",stdin);
//	freopen("number.out","w",stdout);
	for(i=2;i<=8000;i++)
		if(book[i]==0){
			top++;
			zhan[top]=i;
			for(j=i*2;j<=8000;j+=i)
				book[j]=1;
		}
	n=read();
	if(n==2){
		printf("4 7\n");
		printf("23 10\n");
		return 0;
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(((i+j)&1)==0)
				a[i][j]=zhan[(i+j)/2]*zhan[(i-j)/2+n+(n+1)/2];
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if((i+j)&1)
				a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
  	for(i=1;i<=n;i++,cout<<endl)
  		for(j=1;j<=n;j++)
  			pus(a[i][j],1);
	return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	ll h,w,ans=INF;
	cin>>h>>w;
	ll s1,s2,s3;
	//横-横で切る.
	rep(i,1,h/2+1){
		s1=w*i;
		rep(j,(h-i)/2,(h-i)/2+1){
			s2=j*w;
			s3=w*h-s1-s2;
			ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
		}
		rep(j,w/2,w/2+1){
			s2=(h-i)*j;
			s3=w*h-s1-s2;
			ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
		}
	}
	rep(i,1,w/2+1){
		s1=h*i;
		rep(j,(w-i)/2,(w-i)/2+1){
			s2=j*h;
			s3=w*h-s1-s2;
			ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
		}
		rep(j,h/2,h/2+1){
			s2=(w-i)*j;
			s3=w*h-s1-s2;
			ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
		}
	}
	print(ans);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<pair<pair<string,ll>,ll > > v;
    ll n;cin >> n;
    for (int i = 0; i < n; ++i)
    {
    	string s;ll p;cin >> s >> p;
    	v.push_back({{s,p},i});
    }
    sort(v.begin(), v.end(), [&](pair<pair<string,ll>,ll> p1 ,pair<pair<string,ll> ,ll> p2)
    {
    	if(p1.first.first==p2.first.first)return p1.first.second>p2.first.second;
    	return p1.first.first<p2.first.first;
    });
    for (int i = 0; i < n; ++i)
    {
    	cout << v[i].second+1 << "\n";
    }
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){

  int **a;
  int *b;
  int i,j,n,s,t;


  scanf("%d",&n);

  a = (int**)calloc(n+1,sizeof(int*));

  for (i=0 ; i<n+1 ; i++) {
    a[i] = (int*)calloc(n+1,sizeof(int));
  }

  for( i=0 ; i<n ; i++ ){
    scanf("%d%d",&s,&t);
    if( t != 0 ){
      b = malloc(sizeof(int)*t);
      for( j=0 ; j<t ; j++ ){
	scanf("%d",&b[j]);
	a[s][b[j]] = 1;
      }
      free(b);
    }
  }

  for( i=1 ; i<n+1 ; i++ ){
    for( j=1 ; j<n+1 ; j++ ){
      if( j == n ){
	printf("%d\n",a[i][j]);
      }
      else   printf("%d ",a[i][j]);
    }
  }


  for (i=0 ; i<n+1 ; i++ ) {
    free(a[i]);
  }
  free(a);


  return 0;
  
}

Measured memory_bytes: 644
N, M = map(int, input().split())
G = [[] for _ in range(3 * N)]
L = [-3 for _ in range(3 * N)]
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[3*u+0].append(3*v+1)
    G[3*u+1].append(3*v+2)
    G[3*u+2].append(3*v+0)
s, t = map(int, input().split())
S = 3 * (s-1)
T = 3 * (t-1)

L[S] = 0
Frontier = [S]
while Frontier:
    v = Frontier.pop(0)
    for i in G[v]:
        if L[i] < 0:
            Frontier.append(i)
            L[i] = L[v] + 1

print(L[T]//3)

Measured memory_bytes: 59804
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

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

int main(int argc, const char * argv[]) {
    
    int X,Y,Z;
    cin >> X >> Y >> Z;
    
    cout << Z << " "<< X << " " << Y << endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(void){
  int n;  cin >> n;
  bool flag = false;
  REP(i, 26){
    REP(j, 15){
      int t = 4*i+7*j;
      if(t==n){
        flag = true;
        break;
      }else if(t>n){
        break;
      }
    }
    if(flag)  break;
  }
  if(flag)  cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll P = 1000000007;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<ll> v) {
      int sz = (int)v.size();
      n = 1; while(n < sz) n *= 2;
      node.resize(2*n-1);
      lazy.resize(2*n-1, 0);
      lazyFlag.resize(2*n-1, false);
      for(int i=0; i<sz; i++) node[i+n-1] = v[i];
      for(int i=n-2; i>=0; i--) node[i] = (node[i*2+1] + node[i*2+2])%P;
    }

    void lazyEvaluate(ll k, ll l, ll r) {
      if(lazyFlag[k]) {
        node[k] = ((r-l)%P * lazy[k])%P;
        if(r - l > 1) {
          lazy[k*2+1] = lazy[k*2+2] = lazy[k];
          lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
        }
        lazyFlag[k] = false;
      }
    }

    void update(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
          lazy[k] = x;
          lazyFlag[k] = true;
          lazyEvaluate(k, l, r);
        }
        else {
          update(a, b, x, 2*k+1, l, (l+r)/2);
          update(a, b, x, 2*k+2, (l+r)/2, r);
          node[k] = (node[2*k+1] + node[2*k+2])%P;
        }
    }

    ll find(int a, int b, int k=0, ll l=0, ll r=-1) {
      if(r < 0) r = n;
      lazyEvaluate(k, l, r);
      if(b <= l || r <= a) return 0;
      if(a <= l && r <= b) return node[k];
      ll vl = find(a, b, 2*k+1, l, (l+r)/2);
      ll vr = find(a, b, 2*k+2, (l+r)/2, r);
      return (vl + vr)%P;
    }
};

int main(int argc, char const *argv[]) {
  ll n, a, b;std::cin >> n >> a >> b;
  if(a>b) swap(a, b);
  vll A(n+1);re(i, n) scanf("%lld", &A[i+1]);
  A[0] = -1000000000000000000;

  LazySegmentTree seg(vll(n+1, 0));
  seg.update(0, 1, 1);
  for(int i=1;i<=n;i++){
    ll x = upper_bound(all(A), A[i]-b) - A.begin();
    if(A[i]-A[i-1]<a){
      if(i>=2&&A[i]-A[i-2]<a){
        std::cout << 0 << '\n';
        return 0;
      }
      //別でなくてはならない
      ll case_Y = seg.find(0, x);
      ll case_X = seg.find(i-1, i);
      seg.update(0, n+1, 0);
      seg.update(i-1, i, case_X);
      seg.update(i, i+1, case_Y);
    }else{
      ll case_Y = seg.find(0, x);
      seg.update(i, i+1, case_Y);
    }
    //for(int j=0;j<=n;j++) std::cout << seg.find(j, j+1) << (j==n?"\n":" ");
  }
  std::cout << seg.find(0, n+1) << '\n';
  return 0;
}


Measured memory_bytes: 6520
l, n = [int(x) for x in input().split()]
s = input()
up = [0]
for i in range(l-1):
  if s[i:i+2] == 'AC':
    up.append(up[-1] + 1)
  else:
    up.append(up[-1])
ans = []
for i in range(n):
  d, u = map(int, input().split())
  ans.append(up[u-1] - up[d-1])
for i in range(n):
  print(ans[i])

Measured memory_bytes: 10344
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define VAL 100000
#define ll long long
const int MAX=1e5+8;
using namespace std;
vector<int>adj[MAX];
int vis[MAX];
int cnt[MAX];
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	string s;
	cin>>s;
	if((s[2]==s[3])&&(s[4]==s[5]))
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  for(int i=0;i<1000000000;i++){
    if(abs(A-i)==abs(B-i)){
      cout<<i<<endl;
      goto OUT;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  OUT:;
}
  

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

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    vector<int> S(N, -1);
    int s, t;
    bool bad = false;
    for (int i = 0; i < M; i++)
    {
        cin >> s >> t;

        if (S.at(s - 1) != -1)
        {
            if (S.at(s - 1) != t)
            {
                bad = true;
            }
        }
        S.at(s - 1) = t;
    }
    if (bad)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        if (N == 1)
        {
            if (S.at(0) == -1)
            {
                cout << 0 << endl;
            }
            else
            {
                cout << S.at(0) << endl;
            }
            return 0;
        }
        if (S.at(0) == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        if (S.at(0) == -1)
        {
            S.at(0) = 1;
        }
        for (int i = 1; i < N; i++)
        {
            if (S.at(i) == -1)
            {
                S.at(i) = 0;
            }
        }

        for (int i = 0; i < N; i++)
        {
            cout << S.at(i);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        char[] seq = sc.next().toCharArray();
        boolean[] red = new boolean[N];
        for (int i = 0; i < N; i++)
            red[i] = seq[i] == 'R';

        int left = 0;
        int right = N-1;
        while(left<right){
            if(!red[left]&&red[right]){
                ans++;
                left++;
                right--;
            }else if(red[left]){
                left++;
            }else if(!red[right]){
                right--;
            }else{
                left++;
                right--;
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 40980
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    set<int> a[26], b[26];
    rep(i, 0, s.size()){
        a[s[i] - 'a'].insert(t[i] - 'a');
        b[t[i] - 'a'].insert(s[i] - 'a');
    }
    bool f = true;
    rep(i, 0, 26){
        if(a[i].size() > 1) f = false;
        if(b[i].size() > 1) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int k,s;
  cin >> k >> s;

  int z,ans=0;
  for (int x=0; x<=k; x++) {
    for (int y=0; y<=k; y++) {
      z=s-x-y;
      if (z>=0&&z<=k) {
	ans++;
      }
    }
  }

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

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

int ans;
bool check[20][20];
char maze[20][20];

void init()
{
	for (int i = 0; i < 20; ++i) {
		for (int j = 0; j < 20; ++j) {
			check[i][j] = false;
			maze[i][j] = '\0';
		}
	}
}

void search(int y, int x, int h, int w)
{
	if (y >= h || x >= w || y < 0 || x < 0 || check[y][x] || maze[y][x] == '#') {
		return;
	}

	check[y][x] = true;
	++ans;
	search(y + 1, x, h, w);
	search(y - 1, x, h, w);
	search(y, x + 1, h, w);
	search(y, x - 1, h, w);
}

int main(void)
{
	int w, h;
	while (cin >> w >> h && w != 0) {
		ans = 0;
		init();
		int sx, sy;
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				cin >> maze[y][x];
				if (maze[y][x] == '@') {
					sx = x;
					sy = y;
				}
			}
		}
		search(sy, sx, h, w);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, k;
double t, u, v, l;
double d[1000];

int main() {
  while (scanf("%d %d %lf %lf %lf %lf", &n, &k, &t, &u, &v, &l) > 0) {
    REP(i, n) {
      scanf("%lf", &d[i]);
    }
    d[n++] = l;
    d[n++] = 1e+100;
    double x = 0.0;
    int have = 0;
    double rest = 0.0;
    double ans = 0.0;
    int head = 0;

    while (x < l) {
      if (rest == 0.0) {
        double nx = d[head++];
        ans += (nx - x) / u;
        x = nx;
        rest = t;
      } else {
        double nx1 = d[head];
        double nt1 = (nx1 - x) / v;
        double nt = -1e+10;
        if (nt1 < rest) {
          head++;
          nt = nt1;
          if (have == k) {
            rest = t;
          } else {
            rest -= nt1;
            have++;
          }
        } else {
          nt = rest;
          if (have == 0) {
            rest = 0.0;
          } else {
            rest = t;
            have--;
          }
        }
        x += nt * v;
        ans += nt;
      }
    }
    printf("%.8f\n", ans);
  }
}

Measured memory_bytes: 0
# バブルソート
n = int(input())
A = list(map(int, input().split()))

#%%
def bubbleSort(A, N):
    flag = True
    i = 0 # 未ソートのindex
    cnt = 0
    while flag:
        flag = False
        for j in range(N-1, i, -1): # 逆順に交換していく
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j] # 大小関係が間違ってたら交換する
                cnt += 1
                flag = True
        i += 1
    return A, cnt

ans, c = bubbleSort(A[:], n)
print(' '.join(map(str, ans)))
print(c)


Measured memory_bytes: 5596