akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N, X, T;
	cin >> N >> X >> T;
	cout << (N + X - 1) / X * T << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;


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

  ll N,R;
  cin >>N>>R;

  if(N<10){
    cout << R + 100 * (10 - N) << endl;
  }
  else{
    cout << R << endl;
  }
}

Measured memory_bytes: 764
from collections import defaultdict
s = input()
t = input()

st = defaultdict(lambda :0)
for x, y in zip(s,t):
    if (st[(y, 1)] != 0 and st[(y, 1)] != x) or (st[(x, 0)] != 0 and st[(x, 0)] != y):
        #print(x,y)
        print('No')
        exit()
    st[(y, 1)] = x
    st[(x, 0)] = y

print('Yes')

Measured memory_bytes: 42188
import sys

def solve():
    N = int(input())
    S = input()
    lens = len(S)
    alp = ["a", "b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u",\
        "v","w","x","y","z"]
    
    DP = [[0 for j in range(lens)] for i in range(lens)]
    DP[lens - 2][lens - 1] = (1 if S[lens-2] == S[lens - 1] else 0)
    for i in reversed(range(lens - 1)):
        for j in reversed(range(i + 1, lens)):
            if S[i] == S[j]:
                if j == lens - 1: DP[i][j] = 1
                else: DP[i][j] = DP[i+1][j+1] + 1

    maxlength = 0
    for i in range(lens):
        for j in range(i+1, lens):
            maxlength = max(maxlength, min(DP[i][j], j - i))

    print(maxlength)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 247432
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v[3];
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>a>>b;
}
void src(){
    if(a+b<10){
        cout<<a+b;
    }else{
        cout<<"error";
    }
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
  //  ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

public class Main {	

	private static void solve(){
		//Implement solution here.
		char a = next().charAt(0);
		if((int)a >= 97) {
			System.out.println("a");
		} else {
			System.out.println("A");
		}
		
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25368
#include <bits/stdc++.h>
        using namespace std;
        #define el "\n"
        #define ll long long
        #define ull unsigned long long int
        #define pb push_back
        #define mp make_pair
        #define X first
        #define Y second
        #define M 1000000007
        #define all(v) v.begin(), v.end()
        long long pow(long long int a,long long int b,long long int MOD)
        {
            long long x=1,y=a; 
            while(b > 0)
            {
                if(b%2 == 1)
                {
                    x=(x*y);
                    if(x>MOD) x%=MOD;
                }
                y = (y*y);
                if(y>MOD) y%=MOD; 
                b /= 2;
            }
            return x;
        }
        long long modInverse(long long int n, long long int MOD)
        {
            return pow(n,MOD-2,MOD);
        }

        int main() {
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);
          ll n,a,b;
          cin>>n>>a>>b;
          cout<<min(b,a*n)<<el;
          return 0;
        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[500],b[500];
int main(){
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++)
        cout<<a[i]<<b[i];
    if(la>lb)
        for(int i=l;i<=ll-1;i++)
            cout<<a[i];
    else for(int i=l;i<=ll-1;i++)
            cout<<b[i];
    return 0;
}

Measured memory_bytes: 384
N = int(input())
T = [0]*N
X = [0]*N
Y = [0]*N
for i in range(N):
  T[i], X[i], Y[i] = map(int, input().split())

pt=px=py = 0
for i in range(N): # マンハッタン距離
  d = abs(X[i]-px) + abs(Y[i]-py)
  dt = T[i]-pt # 使える時間
  
  # 時間内に移動できるか or 時間調整できるか
  if dt < d or (dt-d)%2 == 1:
    print("No")
    exit()
  
  pt = T[i]
  px = X[i]
  py = Y[i]
print("Yes")

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

int main(void){
  int i,num;
  double x1[N],y1[N],
         x2[N],y2[N],
         x3[N],y3[N],
         x4[N],y4[N];
  double slopeAB,slopeCD;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
        &x1[i],&y1[i],
        &x2[i],&y2[i],
        &x3[i],&y3[i],
        &x4[i],&y4[i]);
  }
  for(i=0;i<num;i++){
    slopeAB=((y2[i]-y1[i])/(x2[i]-x1[i]));
    slopeCD=((y4[i]-y3[i])/(x4[i]-x3[i]));
    if(slopeAB==slopeCD)  printf("YES\n");
    else                  printf("NO\n");
  }
  return 0;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using ll = long long;

int N, Q;
vector<vector<int>> G;
vector<ll> V;
vector<bool> check;

inline void input() {
  cin >> N >> Q;

  G.resize(N);
  V.resize(N);
  check.resize(N);

  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G.at(a).emplace_back(b);
    G.at(b).emplace_back(a);
  }

  rep(i, N) {
    V.at(i) = 0;
    check.at(i) = false;
  }

  rep(i, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    V.at(p) += x;
  }
}

void dfs(int parent) {
  check.at(parent) = true;

  for(int target : G.at(parent)) {
    if(check.at(target)) continue;
    V.at(target) += V.at(parent);
    dfs(target);
  }
}

inline void result() {
  rep(i, N) {
    if(i != 0) cout << ' ';
    cout << V.at(i);
  }
  cout << endl;
}

inline void Main() {
  // code
  input();
  dfs(0);
  result();
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 24548
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
   int n;
   cin >> n;
   string s;
   cin >> s;
    int dp[n][n];
    rep(i,n) rep(j,n) dp[i][j]=0;
   rep(i,n) {
       if(s[i]==s[0])dp[i][0]=1;
       if(s[0]==s[i])dp[0][i]=1;
   }
   FOR(i,1,n) {
       FOR(j,1,n) {
           if(s[i]==s[j])dp[i][j]=dp[i-1][j-1]+1;
            //cout << dp[i][j] << flush;
       }
   //    cout << "" << endl;
   }
    int ans = 0;
    int tmp = inf;
    rep(i,n) {
        rep(j,n) {
            if(j>=i) continue;
            tmp = min(dp[i][j],i-j);
           // cout << tmp << endl;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;



  return 0;
}


Measured memory_bytes: 198956
#include<bits/stdc++.h>
using namespace std;
const int N=305;
int n,m,mod;
int f[N][N],C[N][N],sum[N][N];
inline void add(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline int pls(int x,int y){add(x,y);return x;}
int main(){
	scanf("%d%d%d",&n,&m,&mod);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=pls(C[i-1][j],C[i-1][j-1]);
	}
	for(int i=0;i<=m;i++) f[1][i]=1,sum[1][i]=m-i+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=m;j++)
			for(int k=1;k<i;k++)
				add(f[i][j],1ll*f[i-k][j]*sum[k][j+1]%mod*C[i-2][k-1]%mod);
		for(int j=m;j>=0;j--) sum[i][j]=pls(sum[i][j+1],f[i][j]);
	}
	printf("%d",f[n+1][0]);
	return 0;
} 

Measured memory_bytes: 4848
#include <stdio.h>
int s[33];
int main(){
  int i;
  s[0] = 1;
  for(i=0;i<30;i++){
    s[i+1] += s[i];
    s[i+2] += s[i];
    s[i+3] += s[i];
  }
  for(;;){
    scanf("%d",&i);
    if(i==0) break;
    printf("%d\n",((s[i]+9)/10+364)/365);
  }
  return 0;
}

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

long long gcd(long long a, long long b)
{
    if (b > a)
    {
        swap(a, b);
    }

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    vector<int> L(N), R(N);
    L[1] = A[0];
    R[N - 2] = A[N - 1];
    for (int i = 2; i < N; i++)
    {
        L[i] = gcd(L[i - 1], A[i - 1]);
    }
    for (int i = N - 3; i >= 0; i--)
    {
        R[i] = gcd(R[i + 1], A[i + 1]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        if (i == 0)
        {
            tmp = R[0];
        }
        else if (i == N - 1)
        {
            tmp = L[N - 1];
        }
        else
        {
            tmp = gcd(L[i], R[i]);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
program key2020_B
    implicit none
    integer(16)::N
    integer(16),allocatable,dimension(:)::X,L
    integer(16)::ANS
    logical(16),allocatable,dimension(:)::IN
    integer(16)::R
    integer(16)::i

    read*,N
    allocate(X(N),L(N))
    do i=1,N
        read*,X(i),L(i)
    end do
    call heapsortPair(N,X,L)
    allocate(IN(N))
    IN=.True.
    ANS=N
    R=X(1)+L(1)
    do i=2,N
        if(X(i)-L(i)<R)then
            ANS=ANS-1
            if(X(i)+L(i)<R)then
                R=X(i)+L(i)
            endif
        else
            R=X(i)+L(i)
        endif
    end do
    print"(i0)",ans
contains
subroutine HeapsortPair(n,array,array2)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n),array2(1:n)
  integer(16)::i,k,j,l
  integer(16):: t,t2

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        t2=array2(L)
     else
        t=array(k)
        t2=array2(k)
        array(k)=array(1)
        array2(k)=array2(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           array2(1)=t2
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           array2(i)=array2(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     array2(i)=t2
  enddo
  return
end subroutine HeapsortPair

    
end program key2020_B

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

using namespace std;
using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&& x:a)cin >> x;
    bool x = false;
     if(is_sorted(a.begin(), a.end()))x = true;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        vector<int> b = a;
        swap(b[i], b[j]);
        if(is_sorted(b.begin(), b.end()))x = true;
    }
    cout << (x ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

vector<ll> find_all(const string str, const string subStr) {
    vector<ll> result;

    int subStrSize = subStr.size();
    int pos = str.find(subStr);

    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }

    return result;
}

int main() {
    INIT;
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<ll> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];

    vector<ll> find_vec = find_all(S, "AC");
    // repv(find_vec) { cout << *it << " "; }
    // cout << endl;

    rep(i, Q) {
        l[i]--;
        r[i]--;

        ll lpos = lower_bound(ALL(find_vec), l[i]) - find_vec.begin();
        ll rpos = lower_bound(ALL(find_vec), r[i]) - find_vec.begin();
        cout << rpos - lpos << endl;
    }

    return 0;
}

Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>v(2020);
  int l,r;cin>>l>>r;
  if(l/2019!=r/2019)cout<<0<<endl;
  else{
    l%=2019,r%=2019;
    int mi=2019;
    for(int i=l;i<=r-1;i++){
      for(int j=l+1;j<=r;j++){
        mi=min(mi,i*j%2019);
      }
    }
    cout<<mi<<endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// 全体でIndexは0始まりにしてるので注意
// connectInfo[i][j] :iI番目の電球がj番目のスイッチにつながっている時1
// buibCount : 電球数。==len(connectInfo)
// onCount[i] : 電球iがつく数(0 or 1)。
// onOff[i]: スイッチi のon/off。再帰での唯一の可変要素
// switchCount : スイッチ数　=len(connectInfo[x]), =len(onOff)
// index: 調査中のスイッチIndex
func solveInner(connectInfo [][]int, bulbCount int, onCount []int,
	onOff []bool, switchCount int, index int) int {
	if index >= switchCount {
		for i := 0; i < bulbCount; i++ {
			on := 0
			for j := 0; j < switchCount; j++ {
				if connectInfo[i][j] == 0 {
					continue
				}
				if onOff[j] {
					on++
				}
			}
			if on%2 != onCount[i] {
				return 0
			}
		}
		return 1
	}
	onOff[index] = true
	t1 := solveInner(connectInfo, bulbCount, onCount, onOff, switchCount, index+1)
	onOff[index] = false
	t2 := solveInner(connectInfo, bulbCount, onCount, onOff, switchCount, index+1)
	return t1 + t2
}

func solve(connectInfo [][]int, onCount []int, switchCount int) int {
	bulbCount := len(connectInfo)
	var onOff []bool
	onOff = make([]bool, switchCount)

	return solveInner(connectInfo, bulbCount, onCount, onOff, switchCount, 0)
}

//
func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	m := scanInt()

	var connectInfo [][]int
	connectInfo = make([][]int, m)
	for i := 0; i < m; i++ {
		connectInfo[i] = make([]int, n)
		k := scanInt()
		for j := 0; j < k; j++ {
			idx := scanInt()
			connectInfo[i][idx-1] = 1
		}
	}
	var onCount []int
	onCount = make([]int, m)
	for i := 0; i < m; i++ {
		onCount[i] = scanInt()
	}

	ans := solve(connectInfo, onCount, n)
	fmt.Println(ans)
}

// Commen--------------------------
var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, _ := strconv.Atoi(scanner.Text())
	return a
}
func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

// End -------------------------------


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    string S,T;
    cin>> S>>T;
    if(S.size()+1 != T.size()){
        cout<<"No"<<"\n";
        return 0;
    }
    for(int i =0; i < (int)S.size();++i){
        if(S[i]!=T[i]){
            cout<<"No"<<"\n";
            return 0;
        }
    }
    cout<<"Yes"<<"\n";
}


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

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int main(){
	string s;
	int n;	cin>>s>>n;
	int slen=s.length();

	int cnt=0;
	rep(i,n){
		string t;	cin>>t;
		t+=t;
		int tlen=t.length();
		rep(i,tlen-slen+1)if(s==t.substr(i,slen)){ cnt++; break; }
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) printf("%.6f\n", 1. / 2);
    else printf("%.6f\n", 1.*(n + 1) / n / 2);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
k,s=[-1]*m,[-1]*m
for i in range(m):
  k[i],*s[i]=map(int,input().split())
  s[i]=[1 if j in s[i] else 0 for j in range(1,n+1)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  l=list(map(int,format(i,'0%db'%n)))
  c=0
  for j in range(m):
    if sum([min(t) for t in zip(l,s[j])])%2==p[j]:
      c+=1
  if c==m:
    ans+=1
print(ans)

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

int main(int argc, char const *argv[])
{
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

//int _; 


int main()
{
	//for(scanf("%d",&_);_;_--)
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int a;
		cin >> a;
		n -= a;
	}
	if(n<0)
	{
		puts("-1");
	}
	else
		cout << n << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	cin >> n;
	vector<int> A(n);
	for(int i=0;i<n;++i){
		cin >> A[i];
	}
	vector<int> B(n);
	for(int i=0;i<n;++i){
		cin >> B[i];
	}
	vector<int> C(n);
	for(int i=0;i<n-1;++i){
		cin >> C[i];
	}
	
	int before = -5;
	int res = 0;
	for(int i=0;i<n;++i){
		int index = A[i] -1;
		res += B[index];
		if(before == index-1){
			res += C[before];
		}
		before = index;
	}
	
	cout << res <<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

long long mem[200][200] = { 0 };

long long gcd(long long a, long long b) {
	long long ret = 1;
	long long num = 2;

	long long pre_a = a, pre_b = b;

	if (mem[pre_a - 1][pre_b - 1] != 0) {
		return mem[pre_a - 1][pre_b - 1];
	}

	while (1) {
		while (a % num == 0 && b % num == 0) {
			ret *= num;
			a /= num;
			b /= num;
		}

		while (a % num == 0) {
			a /= num;
		}
		while (b % num == 0) {
			b /= num;
		}
		if (a % num != 0 && b % num != 0) {
			num++;
		}

		if (a == 1 && b == 1) break;
	}

	mem[pre_a - 1][pre_b - 1] = ret;

	return ret;
}

int main() {
	long long n;

	std::cin >> n;

	long long ans = 0;

	for (long long i = 1; i <= n; i++)
	{
		for (size_t j = 1; j <= n; j++)
		{
			for (size_t k = 1; k <= n; k++)
			{
				ans += gcd(gcd(i, j), k);
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 3860
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
for num in b:
    i = bisect.bisect_left(a, num)
    j = bisect.bisect_right(c, num)
    cnt += i * (n - j)
print(cnt)

Measured memory_bytes: 23240
#include <iostream>

using namespace std;

int main() {
	int N, M;

	cin >> N >> M;

	int left = 1, right = N;

	for (int i = 0; i < M; i++)
	{
		int r, l;
		cin >> l >> r;

		if (l > left) left = l;
		if (r < right) right = r;
	}

	int ans = right - left + 1;

	if (ans < 0) cout << 0 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_A 100010

int inc[MAX_A], dec[MAX_A], kep[MAX_A];

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        a++;
        inc[a + 1]++;
        dec[a - 1]++;
        kep[a]++;
    }
    int ans = 0;
    for (int i = 0; i < MAX_A; i++) {
        int cnt = inc[i] + dec[i] + kep[i];
        if (cnt > ans) ans = cnt;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1280
c=[0,2,5,5,4,5,6,3,7,6]
eval'N,M,*A='+`dd`.split*?,
d=[0]
2.upto(N){|i|
	A.map{|a|
		if i>=c[a] && d[i-c[a]]
			d[i]=[d[i]||0,d[i-c[a]]*10+a].max
		end
	}
}
p d[N]


Measured memory_bytes: 28416
N, T = [int(v) for v in input().split()]
ct = []
for i in range(N):
    ct.append([int(v) for v in input().split()])

ans = 10000
for v in ct:
    if v[1] <= T:
        ans = min(ans, v[0])

if ans == 10000:
    print('TLE')
else:
    print(ans)

Measured memory_bytes: 3060
N = int(input())
s = input()
t = input()

c = 0
for i in range(N):
  #print(s[-1*(N-i):])
  #print(t[:(N-i)])
  if s[-1*(N-i):] == t[:(N-i)]:
    c = N - i
    break

print(2*N-c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    double r;cin>>r;
    double res=r*2*3.141592;
    cout<<res<<endl;
}


Measured memory_bytes: 3784
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
g = [i for i in range(1,n+1)]
m = [i for i in range(1,n+1)]
ansp = 0
ansq = 0
def kai(n):
    k = 1
    for i in range(1,n+1):
        k = k*i
    return k
for i in range(n-1):
    r = g.index(p[i])
    ansp += r*kai(n-1-i)
    g.pop(r)
for i in range(n-1):
    r = m.index(q[i])
    ansq += r*kai(n-1-i)
    m.pop(r)
print(abs(ansp-ansq))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	string A; cin >> A;
	int N = (int)A.size();
	vector<ll> dp(N, 0);
	dp[0] = 1;
	vector<int> cnt(26, 0);
	cnt[A[0] - 'a']++;
	for (int i = 1; i < N; i++) {
		int x = A[i] - 'a';
		dp[i] = dp[i - 1] + (i - cnt[x]);
		cnt[x]++;
	}
	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,D,ans=0;
  cin>>N>>D;
  while(N>0){
    N-=(2*D+1);
    ans++;
  }
  cout<<ans;

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int R;
	cin >> R;
	cout << 2 * (float)R * acos(-1) << "\n";

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000, inf = 1e9;
int n, ans = inf, mn[maxn + 10], mx[maxn + 10], sz[maxn + 10];
char s[maxn + 10];
vector<int> g[maxn + 10];

void dfs(int p, int fa) {
	sz[p] = s[p] == '1'; mn[p] = mx[p] = 0;
	for (int i = 0; i < (int)g[p].size(); ++i) {
		int e = g[p][i];
		if (e != fa) {
			dfs(e, p);
			sz[p] += sz[e];
			mx[e] += sz[e]; mn[e] += sz[e];
			int mnp = mn[p], mxp = mx[p];
			mx[p] += mx[e];
			if (mxp <= mn[e]) mn[p] = mn[e] - mxp;
			else if (mx[e] <= mnp) mn[p] = mnp - mx[e];
			else mn[p] = (mnp + mn[e]) & 1;
		}
	}
}

int main() {
	scanf("%d%s", &n, s + 1);
	for (int i = 1; i < n; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		g[l].push_back(r); g[r].push_back(l);
	}
	for (int i = 1; i <= n; ++i) {
		dfs(i, 0);
		if (mn[i] == 0)
			ans = min(ans, mx[i] / 2);
	}
	printf("%d", ans == inf ? -1 : ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
#define mod 1000000007;
typedef long long Int;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
Int dp[110000][13];
int main()
{   
    string s;
    cin >> s ;
    dp[0][0] = 1;
    rep(i,s.size()){
        rep(j,13){
            if (s[i] == '?'){
                rep(d,10){
                    (dp[i+1][(j*10+d)%13] += dp[i][j]) %= mod;
                
                }
            }
            else{
                int d = s[i] - '0';
                (dp[i+1][(j*10+d) %13] += dp[i][j] )%= mod;
            }
        }
    } 
    cout << dp[s.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 10704
N=int(input())
D,X=map(int,input().split())
A = [int(input()) for _ in range(N)]

SUM=0
for i in range(N):
  count=1
  d = 1
  while 1:
    d += A[i]
    if d > D:
      break
    else:
      count += 1
  SUM += count
  
print(SUM+X)

Measured memory_bytes: 9048
/*********************
    配るDPで解いてみた
**********************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/

ll dp[100010];

int main(){
    //入力
    int n;cin>>n;
    int h[100010];
    rep(i,n){cin >> h[i];dp[i]=INF;}
    
    //初期条件
    dp[0]=0;
    
    //ループ
    rep(i,n-1){
        chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i<n-2){
            chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
        }
    }
    
    //出力
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

  ll X;
  cin >> X;

  map<ll,int> Map;
  vector<ll> vec;

  for(ll i = 0; i<=120; i++){
      ll res = pow(i,5);
      vec.pb(res);
      Map[res] = 1;
  }

  ll A=-33, ans_B=-33;
  for(ll i = 0; i < vec.size(); i++){
    ll v = vec[i];
    ll res1 = X + v;
    ll res2 = X - v;
    if(res2 < 0) res2 = res2 * (-1);
    
    if(Map[res1]==1){
        A = res1;
        ans_B = i;
        //cout << "B1 " << ans_B << endl;
        break;
    }
    else if(Map[res2]==1){
        A = res2; 
        ans_B = -(i);
        //cout << "B2 " << ans_B << endl;
        break;
    }
  } 

  //cout << A << endl;
  for(ll i = 0; i < vec.size(); i++){
    if(vec[i] == A){
        cout << i << " ";
        break;
    }
  }
  cout << ans_B << endl;
    
}


Measured memory_bytes: 4104
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        int r = sc.nextInt(), c = sc.nextInt();
 
        int[][] A = new int[r + 1][c + 1];
 
        for (int i = 0; i < r; i++)
            for (int j = 0; j < c; j++) {
                A[i][j] = sc.nextInt();
            }
 
        for (int i = 0; i < r; i++) {
            int sum = 0;
            for (int j = 0; j < c; j++) {
                sum += A[i][j];
            }
            A[i][c] = sum;
        }
        for (int j = 0; j <= c; j++) {
            int sum = 0;
            for (int i = 0; i < r; i++) {
                sum += A[i][j];
            }
            A[r][j] = sum;
        }
 
        for (int i = 0; i <= r; i++)
            ln(join(A[i], " "));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
 
    public static String join(int[] array, String separator) {
        StringBuilder str = new StringBuilder(array[0] + "");
        for (int i = 1; i < array.length; i++) {
            str.append(separator).append(array[i] + "");
        }
        return str.toString();
    }
}


Measured memory_bytes: 42236
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e6 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1 << 30
#define mod 1000000007
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define Doop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void Swap(int*a,int x,int y){int t=a[x];a[x]=a[y];a[y]=t;}
	
	

int main() {

	ACCEL

	int n;
	while ( cin >> n ) {
		int num[ n+5 ];
		
		Loop ( i, 0, n-1) {
			cin >> num[ i ];
		}
		
		int zeros = 0;
		while ( zeros < n-1 ) {
			sort( num, num+n);
//			Loop ( i, 0, n-1) cout << num[ i ] << ' '; cout << '\n';
			int orz = zeros;
			Loop ( i, zeros+1, n-1) {
				num[ i ] %= num[ orz ];
				if ( num[ i ] == 0 ) zeros++ ;
			}
		}
		
		sort( num, num+n);
		cout << num[ n-1 ] << '\n';
	}
	return 0;
}











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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    ll ans = LINF;
    for(ll i=1; i<H; i++){
        ll A = i*W;

        ll k = H-i;

        if(k%2 == 0){
            ans = min(abs(A - k/2 * W), ans);
        }
        if(k%2 == 1){
            ll temp = max(abs(A - k/2 * W), abs(A - (k/2 +1) * W));
            ans = min(temp, ans);
        }
        if(W%2 == 0){
            ans = min(abs(A - W/2 * k), ans);
        }
        if(W%2 == 1){
            ll temp = max(abs(A - W/2 * k), abs(A - (W/2 +1) * k));
            ans = min(temp, ans);
        }
    }
    for(ll i=1; i<W; i++){
        ll A = i*H;

        ll k = W-i;

        if(k%2 == 0){
            ans = min(abs(A - k/2 * H), ans);
        }
        if(k%2 == 1){
            ll temp = max(abs(A - k/2 * H), abs(A - (k/2 +1) * H));
            ans = min(temp, ans);
        }
        if(H%2 == 0){
            ans = min(abs(A - H/2 * k), ans);
        }
        if(H%2 == 1){
            ll temp = max(abs(A - H/2 * k), abs(A - (H/2 +1) * k));
            ans = min(temp, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 500005;

int n, Q, f[MAXN][26], g[19][MAXN];
char s[MAXN];

inline void init()
{
	for (int i = 0; i < 26; i ++) f[n + 1][i] = f[n + 2][i] = n + 2;
	g[0][n + 1] = g[0][n + 2] = n + 2; 
	for (int i = n; i; i --)
	{
		f[i][s[i] - 'a'] = i + 1;
		for (int j = s[i] - 'a' + 1; j < 26; j ++) f[i][j] = f[f[i][j - 1]][j - 1];
		g[0][i] = f[f[i][25]][25];
		for (int j = 0; j < s[i] - 'a'; j ++) f[i][j] = f[g[0][i]][j];
	}
	for (int j = 1; j <= 18; j ++)
		for (int i = 1; i <= n + 2; i ++)
			g[j][i] = g[j - 1][g[j - 1][i]];
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	scanf("%s", s + 1); n = strlen(s + 1);
	init();
	for (Q = read(); Q; Q --)
	{
		int l = read(), r = read();
		for (int i = 18; ~i; i --) if (g[i][l] <= r + 1) l = g[i][l];
		puts(l == r + 1 ? "Yes" : "No");
	}
}


Measured memory_bytes: 88960
fun main(args: Array<String>) {
    var (N, Y) = readLine()!!.split(" ").map{it.toInt()}
    val x = Y/10000
    val y = Y/5000
    val z = Y/1000
    for (i in 0..x) {
        for (j in 0..y) {
            for (k in 0..z) {
                if ((i+j+k==N)&&(i*10000+j*5000+k*1000==Y)) {
                    println("$i $j $k")
                    return
                }
                if ((i+j+k>N)||(i*10000+j*5000+k*1000>Y)) break
            }
        }
    }
    println("-1 -1 -1")
}


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

template <typename T> class seg {
    T t;
    using N = typename T::N;
    using F = typename T::F;
    vector<N> nt;
    vector<F> ft;
    void eval(int p, int l, int r) {
        if(ft[p] == t.IF)
            return;
        nt[p] = t.FN(ft[p], r - l, nt[p]);
        if(l + 1 < r) {
            t.FF(ft[p], ft[p + 1]);
            t.FF(ft[p], ft[p + (r - l & -2)]);
        }
        ft[p] = t.IF;
    }
    N init(N n, int p, int l, int r) {
        if(l + 1 == r)
            return nt[p] = n;
        int m = (l + r) / 2;
        return nt[p] =
                   t.NN(init(n, p + 1, l, m), init(n, p + (r - l & -2), m, r));
    }
    N upd(int a, int b, F f, int p, int l, int r) {
        eval(p, l, r);
        if(b <= l || r <= a)
            return nt[p];
        if(a <= l && r <= b)
            return t.FN(ft[p] = f, r - l, nt[p]);
        int m = (l + r) / 2;
        return nt[p] = t.NN(upd(a, b, f, p + 1, l, m),
                            upd(a, b, f, p + (r - l & -2), m, r));
    }
    N get(int a, int b, int p, int l, int r) {
        if(b <= l || r <= a)
            return t.IN;
        eval(p, l, r);
        if(a <= l && r <= b)
            return nt[p];
        int m = (l + r) / 2;
        return t.NN(get(a, b, p + 1, l, m), get(a, b, p + (r - l & -2), m, r));
    }

  public:
    const int s;
    seg(int s) : s(s), nt(s * 2 - 1, t.IN), ft(s * 2 - 1, t.IF) {}
    seg(int s, N n) : seg(s) { init(n, 0, 0, s); }
    void upd(int a, int b, F f) { upd(a, b, f, 0, 0, s); }
    N get(int a, int b) { return get(a, b, 0, 0, s); }
};
struct Min {
    typedef long N, F;
    const N IN = 1e18;
    const F IF = 1e18;
    N NN(N m, N n) { return min(m, n); }
    N FN(F f, int, N n) { return min(f, n); }
    void FF(F f, F &g) { g = min(f, g); }
};
long d[111111];
tuple<int, int, int> t[111111];
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int l, r, c;
        scanf("%d%d%d", &l, &r, &c);
        t[i] = tie(l, r, c);
    }
    sort(t, t + m);
    seg<Min> s(n);
    s.upd(0, 1, 0);
    for(int i = 0; i < m; i++) {
        int l, r, c;
        tie(l, r, c) = t[i];
        s.upd(l - 1, r, s.get(l - 1, l) + c);
    }
    auto r = s.get(n - 1, n);
    cout << (r < 1e18 ? r : -1) << endl;
    return 0;
}


Measured memory_bytes: 4480
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m,a[310][310],cnt[310],p[310],ans;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,1,n)
    {
        repu(j,1,m)
            a[i][j]=getint();
        ++cnt[a[i][p[i]=1]];
    }
    ans=n;
    repu(i,1,m)
    {
        int x=0;
        repu(j,1,m)
            if (cnt[j]>cnt[x])
                x=j;
        ans=min(ans,cnt[x]),cnt[x]=-1;
        repu(j,1,n)
            if (a[j][p[j]]==x)
            {
                for (; cnt[a[j][p[j]]]==-1; ++p[j]);
                ++cnt[a[j][p[j]]];
            }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int T = Integer.parseInt(scanner.next());
        int A = Integer.parseInt(scanner.next());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(scanner.next());
        }

        double min = Double.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            double t = T - 0.006 * H[i];
            if (min > Math.abs(A - t)) {
                min = Math.abs(A - t);
                ans = i;
            }
        }

        System.out.println(ans + 1);
    }

}


Measured memory_bytes: 22484
n,xx,yy = (int(x) for x in input().split())
x = min(xx, yy)
y = max(xx, yy)
ans = [0 for i in range(n+1)]
for i in range(1, n):
    for j in range(i+1, n+1): 
        d = min(j - i, abs(x-i) + abs(y-j)+1)    
        ans[d] += 1

for k in range(1, n):
    print(ans[k])
        

Measured memory_bytes: 46684
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner scanner = new Scanner(System.in);
    String n = scanner.next();

    if (n.charAt(0) == '9' || n.charAt(1) == '9') {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 21716
N=2*10**5+1
mod=10**9+7
f=[None]*N
fi=[None]*N
f[0]=1
for i in range(1,N):
  f[i]=i*f[i-1]%mod
for i in range(N):
  fi[i]=pow(f[i],mod-2,mod)
def com(n,k):
  return f[n]*fi[n-k]%mod*fi[k]%mod
def hcom(n,k):
  return com(n+k-1,n-1)
n,k=map(int,input().split())
ans=1
for i in range(1,min(k+1,n)):
  ans=(ans+com(n,i)*hcom(n-i,i)%mod)%mod
print(ans)

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

int main(void) {

  int d;
  scanf("%d", &d);
  long c[26];
  for (int i = 0; i < 26; i++) {
    scanf("%ld", &c[i]);
  }
  long s[d][26];
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%ld", &s[i][j]);
    }
  }
  int t[d][2000];
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 2000; j++) {
      t[i][j] = rand()%26+1;
    }
  }
  int max_p;
  long score,max;
  int last[26];
  for (int p = 0; p < 2000; p++) {
    for (int i = 0; i < 26; i++) {
      last[i] = -1;
    }
    score = 0;
    for (int i = 0; i < d; i++) {
      score += s[i][t[i][p]-1];
      last[t[i][p]-1] = i;
      for (int j = 0; j < 26; j++) {
        if (j == t[i][p]-1) {
          continue;
        }
        score -= c[j]*(i-last[j]);
      }
    }
    if (p == 0 || score > max) {
      max = score;
      max_p = p;
    }
  }
  for (int i = 0; i < d; i++) {
    printf("%d\n", t[i][max_p]);
  }

  return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

ll yakusuu(ll x){
    ll sum = 0;
    for(int i = 1;i*i <= x;i++){
        if(x%i == 0){
            sum += 1;
            if(i*i != x){
                sum++;
            }
        }
    }
    //約数の個数
    return sum;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    /*for(int c = 1;c < n;c++){
        ans += yakusuu(n-c);
    }*/
    for(int a = 1;a < n;a++){
        if(n%a == 0){
            ans += (n / a) - 1;
        }
        else{
            ans += n / a;
        }
    }
    cout << ans << endl;

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i + 2 <= n; i++) {
    if (s[i] == s[i+1]) {
      cout << i + 1 << " " << i + 2 << '\n';
      return;
    }
  }
  for (int i = 0; i + 3 <= n; i++) {
    vi32 v = {s[i], s[i+1], s[i+2]};
    sort(all(v));
    if (v[0] == v[1] || v[1] == v[2]) {
      cout << i + 1 << " " << i + 3 << '\n';
      return;
    }
  }
  cout << -1 << " " << -1 << '\n';
}


Measured memory_bytes: 512