akhauriyash/Code-Regression huggingface dataset:
//2:40
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
typedef pair<int,int> pi;
#define INF INT_MAX

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;
}
template<class T>
void DEBUG_DP(T* viewdp, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen){
            if(viewdp[i][j] != -1)
                printf("[%03d]", viewdp[i][j]);
            else
                printf("[   ]");
        }
        puts("");
    }
}

int h,w;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; //RDLU
int dp[52][52];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>h>>w;
    vector<vector<char>> s(h+1, vector<char>(w+1, '#'));
    ll ans = 0;

    FOR(i,0,h) FOR(j,0,w){
        cin>>s[i][j];
        if(s[i][j]=='#') ans--;
        dp[i][j] = INF;
    }

    // REP(i,h+1){
    //     REP(j,w+1){
    //         cout<<s[i][j];
    //     }
    //     cout<<endl;
    // }

    const int sx=0,sy=0, gx=h-1,gy=w-1;

    queue<pi> q;
    q.push(pi(sx,sy));
    dp[sx][sy] = 0;

    bool goal = false;
    while(!q.empty()){
        pi npos;
        npos = q.front();
        q.pop();

        if(npos.first == gx && npos.second == gy){
            goal = true;
            break;
        }
        
        REP(i,4){
            int nx = npos.first+dx[i];
            int ny = npos.second+dy[i];
            if(nx<0 || ny<0 || s[nx][ny]=='#') continue;

            if(dp[nx][ny]==INF){
                q.push(pi(nx, ny));
                dp[nx][ny] = dp[npos.first][npos.second]+1;
            }
        }
    }

    if(!goal){
        cout << "-1" << endl;
        return 0;
    }

    cout << ans+(h*w)-(dp[gx][gy]+1) << endl; //スタートとゴールの色は変えられない
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	string s;
	set<string> st;
	cin >> n;
	for(int i = 0;i < n;i++){
		string t;
		cin >> t;
		if(st.count(t)){
			No();
			return 0;
		}
		if(i && s[s.length() - 1] != t[0]){
			No();
			return 0;
		}
		st.insert(t);
		s = t;
	}
	Yes();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main(void) {
  int H,W;
  vector<int> mh = {-1, -1, 0, 1, 1, 1, 0, -1};
  vector<int> mw = {0, -1, -1, -1, 0, 1, 1, 1};
  cin >> H >> W;
  
  vector<string> m(H);
  for(int i=0; i<H; i++) cin >> m[i];

  for(int h=0; h<H; h++){
    for(int w=0; w<W; w++){
      
      if(m.at(h).at(w)=='.'){
        int n=0;
        for(int i=0; i<8; i++){
          int th = h + mh[i];
          int tw = w + mw[i];
          if(th>=0 && tw>=0 && th<H && tw<W
              && m.at(th).at(tw)=='#') n++;
        }
        m.at(h).at(w)='0'+n;
      }
    }
  }
  
  for(int i=0; i<H; i++) 
    cout << m[i] << endl;
  
}


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

const int N = 100005;
int n, m, h[N], x, y;
vector<int> v[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	for(int i = 1; i <= m; ++i) {
		cin >> x >> y;
		v[x].push_back(h[y]);
		v[y].push_back(h[x]);
	}
	int fp = n;
	for(int i = 1; i <= n; ++i) {
		for(int j : v[i]) {
			if(j >= h[i]) {
				--fp;
				break;
			}
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 9156
#include <bits/stdc++.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++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector< pair<int, int> > R(N), B(N);
    for (int i = 0; i < N; i++) cin >> R[i].first >> R[i].second;
    for (int i = 0; i < N; i++) cin >> B[i].first >> B[i].second;
    sort(R.begin(), R.end());
    sort(B.begin(), B.end());
    int b = 0;
    int cnt = 0;
    int m, tmp;
    vector<int> check(N);
    while (b < N) {
        m = -1; tmp = -1;
        for (int i = 0; i < N; i++) {
            if (R[i].first < B[b].first && R[i].second < B[b].second) {
                if (check[i] == 0 && m < R[i].second) {
                    tmp = i; m = R[i].second;
                }
            }
        }
        if (tmp >= 0) {
            check[tmp] = 1;
            cnt++;
        }
        b++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
package main

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

const MAX_COUNT int = 10e5
const INFINT int = 10e9 + 1

type Card struct {
	Style string
	Num int
}


var A []Card = make([]Card, MAX_COUNT)
var B []Card = make([]Card, MAX_COUNT)

var L []Card = make([]Card, MAX_COUNT/2 + 2)
var R []Card = make([]Card, MAX_COUNT/2 + 2)

func merge(left, mid, right int) {
	n1 := mid - left
	n2 := right -mid
	for i:=0; i<n1; i++ {
		L[i] = A[left+i]
	}
	L[n1].Num = INFINT
	for i:=0; i<n2; i++{
		R[i] = A[mid+i]
	}
	R[n2].Num = INFINT
	i := 0
	j := 0
	for k:=left; k<right; k++{
		if L[i].Num <= R[j].Num {
			A[k] = L[i]
			i += 1
		} else {
			A[k] = R[j]
			j += 1
		}
	}
}

func mergeSort(left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(left, mid)
		mergeSort(mid, right)
		merge(left, mid, right)
	}
}

func partition(p, r int) int {
	x := B[r]
	i := p - 1
	for j:=p; j<r; j++{
		if B[j].Num <= x.Num {
			i += 1
			B[i], B[j] = B[j], B[i]
		}
	}
	B[i+1], B[r] = B[r], B[i+1]
	return i+1
}

func quickSort(p, r int) {
	if p<r {
		q := partition(p, r)
		quickSort(p, q-1)
		quickSort(q+1, r)
	}
}

func nextCard(scanner *bufio.Scanner) Card {
	scanner.Scan()
	style := scanner.Text()
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return Card{Style: style, Num: num}
}

func check(N int) bool {
	for i:=0; i<N; i++ {
		if A[i].Style != B[i].Style{
			return false
		}
	}
	return true
}

func printArr(N int) {
	arrStr := make([]string, N)
	for i:=0; i<N; i++ {
		arrStr[i] = B[i].Style + " " + strconv.Itoa(B[i].Num)
	}
	fmt.Println(strings.Join(arrStr, "\n"))
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	N, _ := strconv.Atoi(scanner.Text())
	for i:=0; i<N; i++ {
		card := nextCard(scanner)
		A[i] = card
		B[i] = card
	}
	mergeSort(0, N)
	quickSort(0, N-1)
	if check(N) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
	printArr(N)
}


Measured memory_bytes: 20852
/* Problem

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

// Data Type
#define ull     			unsigned long long int
#define ll      			long long int
#define ld					long double

// Loops
#define loop(i,s,e)     	for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    	for(ll i=(s);i>=(e);i--)

// Stl
#define pb      			push_back
#define eb      			emplace_back
#define pf      			push_front
#define popb    			pop_back
#define popf    			pop_front
#define mp      			make_pair
#define F      				first
#define S      				second
#define vl 					vector<ll>
#define pl  				pair<ll,ll>
#define ub 					upper_bound				
#define lb 					lower_bound
#define bs 					binary_search		
#define all(x) 				(x).begin(),(x).end()

// Maths
#define PI          		(2*acos(0.0))
#define gcd(a,b)    		__gcd((a),(b))
#define lcm(a,b)    		(((a)*(b))/(__gcd((a),(b))))
#define log(x,b)    		(log(x)/log(b))
#define INF         		LLONG_MAX

// Big data
const int Mod = 1e9+7;
#define mul(a,b)         	((a%Mod)*(b%Mod))%Mod
#define sum(a,b)         	((a%Mod)+(b%Mod))%Mod

// Bit-Manipulation
#define setbit(n,pos)       n |= (1LL<<pos)
#define resetbit(n,pos)     n &= (~(1LL<<pos))
#define toogle(n,pos)       n ^= (1LL<<pos)
#define atpos(n,pos)        ((n&(1LL<<pos))!=0)

// Extra
#define fast 				ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test 				int t = 1; while(t--)
#define scan(any)       	for(auto &i:any) cin>>i;
#define print(any)      	for(auto i:any) cout<<i<<" "; nl;
#define ppair(any)      	for(auto i:any) cout<<i.F<<" "<<i.S<<endl;
#define flush 				cout.flush()
#define nl              	cout<<'\n'
#define endl            	'\n'

void solve()
{
	ll a,b;
	cin>>a>>b;
	if(500*a>=b)
		cout<<"Yes";
	else
		cout<<"No";
}

int main()
{
	#ifdef Dhiraj
		freopen("D:/dhiraj/Programming/input.txt","r",stdin);
		freopen("D:/dhiraj/Programming/output.txt","w",stdout);
	#endif
	
	fast;
	test
	solve();
	return 0;
}
/*
greater<int>()
fill(start,end,value);
fill_n(array,size,value);
getline(cin,string);
cin.getline(char array,size);
LLONG_MAX
DBL_MAX
*/

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

using namespace std;
#define ll long long
const int MAXN = 112345;
const int INF = 0x3f3f3f3f;

ll dp[MAXN][3], a[MAXN];

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n;
	cin >> n;

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

	dp[0][0] = 0;
	dp[0][1] = -INF;

	for (int i = 1; i <= n; ++i) {
		dp[i][0] = max (dp[i-1][0] + a[i-1], dp[i-1][1] - a[i-1]);
		dp[i][1] = max (dp[i-1][0] - a[i-1], dp[i-1][1] + a[i-1]);
	}

	cout << (dp[n][0]) << '\n';



	return 0;
}


Measured memory_bytes: 3456
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int n; cin >> n;
  vector<int> A(n+1),B(n+1);
  int sum=0;
  for (int i=1; i<=n; i++) {
    cin >> A[i];
    sum += A[i];
  }
  sum /= 2;
  
  int s = 0;
  for (int i=2; i<=n-1; i+=2) s += A[i];
  B[1] = 2 * (sum-s);
  
  for (int i=3; i<=n; i+=2){
    s = s+A[i-2]-A[i-1];
    B[i] = 2 * (sum-s);
  }
  
  s=0;
  
  for (int i=3; i<=n; i+=2) s += A[i];
  B[2] = 2 * (sum-s);
  
  for (int i=4; i<=n-1; i+=2){
    s = s+A[i-2]-A[i-1];
    B[i] = 2 * (sum-s);
  }
    
  for (int i=1; i<=n; i++) cout << B[i] << " ";
 
  return 0;
}


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

using int64 = long long;

int64 solve(const int k, const int r, const int s, const int p, const string& t) {
  static const int R = 0, S = 1, P = 2;

  int64 ret = 0;
  for (int i = 0; i < k; ++i) {
    string u;
    for (int j = i; j < t.size(); j += k)
      u.push_back(t[j]);
    vector<vector<int64>> dp(u.size(), vector<int64>(3, 0));
    for (int j = 0; j < u.size(); ++j) {
      dp[j][R] = (u[j] == 's') ? r : 0;
      dp[j][S] = (u[j] == 'p') ? s : 0;
      dp[j][P] = (u[j] == 'r') ? p : 0;
      if (j > 0) {
        dp[j][R] += max(dp[j - 1][S], dp[j - 1][P]);
        dp[j][S] += max(dp[j - 1][P], dp[j - 1][R]);
        dp[j][P] += max(dp[j - 1][R], dp[j - 1][S]);
      }
    }
    vector<int64>& d = dp.back();
    ret += max(d[R], max(d[S], d[P]));
  }
  return ret;
}

int main() {
  int n, k;
  int r, s, p;
  string t;
  cin >> n >> k
      >> r >> s >> p
      >> t;
  cout << solve(k, r, s, p, t) << "\n";

  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.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++)

int main() {
  long k, x, r;
  cin >> k;
  x = 0;
  r = -1;

  rep (i, k) {
    x = (x * 10 + 7) % k;
    if (x == 0) {
      r = i + 1;
      break;
    }
  }
  cout << r << endl;
}


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

int main()
{
	int n; cin >> n;
	
	vector<int> h(n); for (int i = 0; i < n; i++) cin >> h[i];

	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		if (h[i] >= h[i + 1]) {
			cnt++;
			ans = max(ans, cnt);
		}
		else {
			cnt = 0;
		}
	}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define N 100500
#define oo ll(1e16)
#define P pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define el '\n'
#define elf endl
#define base ll(1e9+7)
#define MM 4294967296
#define re return
#define nins 4294967295
using namespace std;
typedef long long ll;
string s;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>s;
    if(s=="Sunny") cout<<"Cloudy";
    if(s=="Cloudy") cout<<"Rainy";
    if(s=="Rainy") cout<<"Sunny";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int X, Y;
	cin >> X >> Y;
	if(X%Y != 0) cout << X << "\n";
	else cout << "-1\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
n = input()
list = [int(i) for i in input().split()]
min_count = 1000000000
tmp = 0

for num in list:
    tmp = 0
    while True:
        if num % 2 != 0:
          break
        else:
          tmp += 1
          num = num / 2
    if min_count > tmp:
        min_count = tmp  
          
print(min_count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int[] s = new int [r*c+1];
        int t, sum;
        for(int i = 0; i < r; i++)
        {
            sum = 0;
            for(int k = 0; k < c; k++)
            {
                t = sc.nextInt();
                sum += t;
                s[k] += t;
                System.out.print(t + " ");
            }
            s[c] += sum;
            System.out.println(sum);
        }
        for(int i = 0; i < c; i++){
            System.out.print(s[i] + " ");
        }
        System.out.println(s[c]);
    }

}

Measured memory_bytes: 40392
import java.io.*;
class Main{
    final static int ERROR=-1;

    static int heapSize=0;
    static long[] heapTree = new long[2000000];

    public static void main(String[] args){
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
	String line = new String();
	StringBuffer returned = new StringBuffer("");

	//read Tree
	while(true){
	    try{
		line=bin.readLine();
	    }
	    catch(IOException e){
		System.out.println("Error");
	    }

	    //what's this command?
	    String[] key = line.split(" ");
	    //end or extract
	    if(key.length<2){
		if(key[0].equals("end"))break;
		else{
		    returned.append(heapExtractMax()+"\n");
		}
	    }
	    //insert
	    else{
		maxHeapInsert(Long.parseLong(key[1]));
	    }
	}
	System.out.print(returned);
    }
    
    //------------------------------------------------------
    //get methods
    static int getParent(int i){
	    return i/2;
    }

    static int getLeft(int i){
	return 2*i;
    }

    static int getRight(int i){
	return 2*i+1;
    }
    
    //other methods
    static void maxHeapify(int i){
	int l = getLeft(i);
	int r = getRight(i);
	int largest=1;

	if(l<=heapSize && heapTree[l]>heapTree[i])largest=l;
	else largest = i;
	if(r<=heapSize && heapTree[r]>heapTree[largest])largest=r;
	if(largest!=i){
	    long x = heapTree[i];
	    heapTree[i]=heapTree[largest];
	    heapTree[largest]=x;
	    maxHeapify(largest);
	}
    }

    static void maxHeapInsert(long key){
	heapSize++;
	heapTree[heapSize]=Long.MIN_VALUE;
	heapIncreaseKey(heapSize, key);
    }

    static void heapIncreaseKey(int i, long key){
	long x;
	if(key < heapTree[i])return;
	heapTree[heapSize]=key;
	while(i>1 && heapTree[getParent(i)]<heapTree[i]){
	    x=heapTree[i];
	    heapTree[i]=heapTree[getParent(i)];
	    heapTree[getParent(i)]=x;
	    i=getParent(i);
	}
    }

    static long heapExtractMax(){
	if(heapSize < 1)return ERROR;
	long max = heapTree[1];
	heapTree[1]=heapTree[heapSize];
	heapSize--;
	maxHeapify(1);
	return max;
    }
}

Measured memory_bytes: 42000
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[200010];
int main() {
    ll N, E, T; scanf("%lld%lld%lld", &N, &E, &T);

    vector<ll> S(N+1);
    for(int i=0; i<N; i++) {
        scanf("%lld", &S[i+1]);
    }

    fill(dp, dp + N + 1, LONGINF);
    dp[0] = 0;
    vector<ll> c(N+1, -LONGINF);
    multiset<ll> ms1, ms2;
    
    ll ans = (S[1] - 0) + (E - S[N]), j = 0, d = 0;
    for(int i=0; i<=N; i++) {
        if(i == N) continue;
        ll e = (i+1 < N ? S[i+2] - S[i+1] : 0);
        while(j <= i and 2*(S[i+1] - S[j+1]) >= T) {
            ms2.erase(ms2.find(c[j]));
            ll v = dp[j] + 3*(S[i+1] - S[j+1]);
            ms1.emplace(v - 3*d);
            c[j] = v - 3*d;
            j++;
        }
        {
            ll v = dp[i] + T;
            // fprintf(stderr, "#2: i = %d, v = %lld\n", i, v);
            ms2.emplace(v - d);
            c[i] = v - d;
        }
        /*
        for(int j=0; j<=i; j++) {
            ll d = S[i+1] - S[j+1];
            ll c1 = dp[j] + 3*d, c2 = dp[j] + T + d;
            chmin(dp[i+1], max(c1, c2) + e);
        }
        */

        ll min_v_1 = (ms1.size() ? *ms1.begin() + 3*d : LONGINF);
        ll min_v_2 = (ms2.size() ? *ms2.begin() + 1*d : LONGINF);
        // fprintf(stderr, "min_v_1 = %lld, min_v_2 = %lld\n", min_v_1, min_v_2);
        chmin(dp[i+1], min(min_v_1, min_v_2) + e);
        // fprintf(stderr, "dp[%d] = %lld\n", i+1, dp[i+1]);
        
        d += S[i+2] - S[i+1];
        // fprintf(stderr, "d = %lld\n", d);
        /*
        c1 += 3*d;
        c2 += d;
        */
        // fprintf(stderr, "after: c1 = %lld, c2 = %lld\n", c1, c2);
    }
    ans += dp[N];
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 2e5 + 5;

int n;
int dep[maxn], vis[maxn], cnt[2], ans[maxn];
vector<int> g[maxn];

inline void dfs(int u, int p){
	++cnt[dep[u] & 1];
	FOR(i, 0, g[u].size()){
		int v = g[u][i];
		if(v == p)
			continue;
		dep[v] = dep[u] + 1;
		dfs(v, u);
	}
	return;
}

int main(){
	scanf("%d", &n);
	FOR(i, 1, n){
		int u, v;
		scanf("%d%d", &u, &v);
		--u; --v;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(0, -1);
	if(cnt[0] <= n / 3){
		int p = 3;
		FOR(u, 0, n) if(!(dep[u] & 1)){
			ans[u] = p;
			vis[p] = 1;
			p += 3;
		}
		p = 1;
		FOR(u, 0, n) if(dep[u] & 1){
			for(; vis[p]; ++p);
			ans[u] = p++;
		}
	}
	else if(cnt[1] <= n / 3){
		int p = 3;
		FOR(u, 0, n) if(dep[u] & 1){
			ans[u] = p;
			vis[p] = 1;
			p += 3;
		}
		p = 1;
		FOR(u, 0, n) if(!(dep[u] & 1)){
			for(; vis[p]; ++p);
			ans[u] = p++;
		}
	}
	else{
		int p = 1;
		memset(ans, -1, sizeof(ans));
		FOR(u, 0, n) if(dep[u] & 1){
			ans[u] = p;
			vis[p] = 1;
			p += 3;
			if(p > n)
				break;
		}
		p = 2;
		FOR(u, 0, n) if(!(dep[u] & 1)){
			ans[u] = p;
			vis[p] = 1;
			p += 3;
			if(p > n)
				break;
		}
		p = 3;
		FOR(u, 0, n) if(!~ans[u]){
			for(; vis[p]; ++p);
			ans[u] = p++;
		}
	}
	FOR(u, 0, n)
		printf("%d ", ans[u]);
	puts("");
	return 0;
}


Measured memory_bytes: 18816
#include <cmath>
#include<iostream>

using namespace std;
int main(void){
	int N;
	cin >> N;
	int long long ans, thereshold = 1000000000000000000;
	int long long a_temp;
	ans = 1;
	
	int flag1 = 0, flag2 = 0;
	for(int i=0;i < N;i++){
		cin >> a_temp;
		if(a_temp == 0){
			flag1 = 1;
		}
		if(std::log10((double long)ans) + std::log10((double long)a_temp) > 18.0){
			flag2 = 1;
		}
		ans = ans * a_temp;
		if(ans > thereshold){
			flag2 = 1;
		}
	}
	if(flag1 == 1){
		cout << "0" << endl;
	}else if(flag2 == 1){
		cout << "-1" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<string> W(N);
  for(int i = 0 ; i < N ; i++){
    cin >> W[i];
  }
  string ans=YES;
  for (int i=1; i<N; i++) {
    if (W[i-1].back()!=W[i][0]) ans=NO;
  }
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (i!=j&&W[i]==W[j]) ans=NO;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import sys
N, Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            print(*[i, j, N - i - j])
            sys.exit()
print(*[-1, -1, -1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        int y, m, d; cin>>y>>m>>d;

        int ans=0;
        while(1){
            if(y==1000 && m==1 && d==1) break;

            ans++;
            d++;
            if(y%3==0){
                if(d==21){
                    m++;
                    d=1;
                }
            }
            else{
                if(m%2==1){
                    if(d==21){
                        m++;
                        d=1;
                    }
                }
                else{
                    if(d==20){
                        m++;
                        d=1;
                    }
                }
            }

            if(m==11){
                y++;
                m=1;
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3088
#include <stdio.h>
int main(void){
     
    int H,W,i,j,k;
     
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)
        break;
     
    for(i=0;i<H;i++){
         
        if(i==0||i==H-1){
            for(k=0;k<W;k++){
                printf("#");
            }
        }
        else{
            for(j=0;j<W;j++){
                    printf("#");
            }
        }
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<ll, ll>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll dp[3005][3005][4];

ll score[3005][3005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll r, c, k;
    cin >> r >> c >> k;
    rep(i, k) {
        ll ir, ic, v;
        cin >> ir >> ic >> v;
        ir--; ic--;
        score[ir][ic] = v;
    }

    rep(i, r) rep(j, c) {
        if (i==0 && j==0) {
            if (score[i][j]>0) {
                dp[i][j][1] = score[i][j];
            }
            continue;
        }
        if (i>0) {
            rep(k, 4) {
                chmax(dp[i][j][0], dp[i-1][j][k]);
            }
            if (score[i][j]>0) {
                rep(k, 4) {
                    chmax(dp[i][j][1], dp[i-1][j][k]+score[i][j]);
                }
            }
        }
        if (j>0) {
            rep(k, 4) {
                chmax(dp[i][j][k], dp[i][j-1][k]);
            }
            if (score[i][j]>0) {
                rep(k, 3) {
                    chmax(dp[i][j][k+1], dp[i][j-1][k]+score[i][j]);
                }
            }
        }
    }



    ll ans = 0;
    rep(k, 4) {
        chmax(ans, dp[r-1][c-1][k]);
    }
    
    pr(ans);
    return 0;
}


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

using namespace std;

#define gc c=getchar()
#define r(x) read(x)

template<typename T>
inline void read(T&x){
    x=0;T k=1;char gc;
    while(!isdigit(c)){if(c=='-')k=-1;gc;}
    while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

const int N=2e5+7;

int n;

int a[N];

inline bool Greater(int i,int j,int x){
	return a[i]>x&&a[j]>x;
}

inline bool Smaller(int i,int j,int x){
	return a[i]<=x&&a[j]<=x;
}

inline bool check(int x){
	for(int i=0;i<n-1;++i){
		if(Greater(n-i-1,n-i,x)||Greater(n+i,n+i+1,x))return 0;
		if(Smaller(n-i-1,n-i,x)||Smaller(n+i,n+i+1,x))return 1;
	}
	return Smaller(1,1,x);
}
		

int main(){
	r(n);
	for(int i=1;i<2*n;++i)r(a[i]);
	int l=1,r=2*n-1,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d\n",ans);
}


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

int main() {
  
  int A, B; cin >> A >> B;
  for(int x=1; x<=1000; x++){
    double x_A = x*1.08, x_B = x* 1.1;
    if(x_A - x >= A && x_A - x < A+1 && x_B - x >= B && x_B - x < B+1){
      cout << x << endl;
      return 0;
    }
  }
  
  cout << "-1" << endl;
  return 0;
  
}

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

int main() {
    int N, D;
    cin >> N >> D;

    vector<int> X(N);
    vector<int> Y(N);

    REP(i, N){
        cin >> X.at(i) >> Y.at(i);
    }
    int result = 0;
    
    REP(i, N){
        double dist = sqrt(pow((double)X.at(i), 2) + pow((double)Y.at(i), 2));
        if(dist <= D)result++;
    }
    
    cout << result << "\n";
    return 0;
}

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

using namespace std;

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

int main() {
  int N; cin >> N;
  vector<string> s(N);
  rep(i, N) cin >> s.at(i);

  int M; cin >> M;
  vector<string> t(M);
  rep(i, M) cin >> t.at(i);

  vector<int> result;
  rep(i, N) {
    int count = 0;
    rep(j, N) {
      if(s.at(i) == s.at(j)) {
        count++;
      }
    }
    result.push_back(count);
  }

  rep(i, M) {
    rep(j, N) {
      if(t.at(i) == s.at(j)) {
        result.at(j)--;
      }
    }
  }
  sort(result.begin(), result.end(), greater<int>());
  int max_ = max(0, result[0]);
  cout << max_ << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a,b,c;
int main()
{
	cin>>n;
	bool no=true;
	for(double i=1;i<=n;i++)
	{
		if(int(i*1.08)==n)
		{
			cout<<i<<endl;
			no=false;
			break;
		}
	}	
	if(no==true)
		cout<<":("<<endl;			
} 

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

int main(){
  int N;
  cin>>N;
  int cnt=0;
  string A,B,C;
  cin>>A>>B>>C;
  for(int i=0;i<N;i++){
    if((A.at(i) == B.at(i))&&(B.at(i) == C.at(i))) continue;
    if((A.at(i) != B.at(i))&&(B.at(i) == C.at(i))){
      cnt++;
      continue;
    }
    if((A.at(i) == B.at(i))&&(B.at(i) != C.at(i))){
      cnt++;
      continue;
    }    
    if((A.at(i) == C.at(i))&&(B.at(i) != C.at(i))){
      cnt++;
      continue;
    }
    cnt++;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,m; cin>>n>>m;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll res=0;
    ll thre=0;
    if(sum%(4*m)==0) thre=sum/(4*m);
    else thre=1+sum/(4*m);
    rep(i,n){
        if(a[i]>=thre) res++;
    }
    if(res>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int mod = 998244353;
const int FacN = 0;//使わないなら0

constexpr int power(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)res *= a;
        a *= a;
        res %= mod;
        a %= mod;
        b /= 2;
    }
    return res;
}

constexpr int inv(int x) {
    return power(x, mod - 2);
}

const struct Fac {
    int val[FacN];

    constexpr Fac() : val() {
        if (FacN == 0)return;
        val[0] = 1;
        for (int i = 1; i < FacN; ++i) val[i] = val[i - 1] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac;

const struct FacInv {
    int val[FacN];

    constexpr FacInv() : val() {
        if (FacN == 0)return;
        val[FacN - 1] = 1;
        for (int i = 1; i < FacN; ++i)val[FacN - 1] = val[FacN - 1] * i % mod;
        val[FacN - 1] = inv(val[FacN - 1]);
        for (int i = FacN - 1; i >= 1; --i)val[i - 1] = val[i] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac_inv;

int Perm(int n, int r) {
    return fac[n] * fac_inv[n - r] % mod;
}

int Comb(int n, int r) {
    return Perm(n, r) * fac_inv[r] % mod;
}
//mod,Factorial書き換え

int dp[4040][4040];
string S;

signed main() {
    cin >> S;
    int red = 0, blue = 0;
    dp[0][0] = 1;
    rep(i, 2 * S.size()) {
        if (i < S.size()) {
            if (S[i] == '0')red += 2;
            else if (S[i] == '1') {
                red += 1;
                blue += 1;
            } else blue += 2;
        }
        rep(j, 4040) {
            if (i + 1 < j)break;
            if (j == 0) {
                dp[i + 1][j] = (dp[i][j] && blue - (i + 1 - j) >= 0);
            } else {
                if (red - j >= 0) {
                    dp[i + 1][j] += dp[i][j - 1];
                }
                if (blue - (i + 1 - j) >= 0) {
                    dp[i + 1][j] += dp[i][j];
                }
                dp[i + 1][j] %= mod;
            }
        }
    }
    cout << dp[2 * S.size()][red] << endl;
    return 0;
}


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

int main(){
    int r;
    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
    }
    else if(1200 <= r && r < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import operator

operators = {
    '+': operator.add,
    '-': operator.sub,
    '*': operator.mul
}

stack = []


def push(v):
    stack.append(v)


def operate(op):
    right = stack.pop()
    left = stack.pop()
    stack.append(op(left, right))


for sym in sys.stdin.read().strip().split():
    op = operators.get(sym)
    if op:
        operate(op)
    else:
        push(int(sym))

print(stack.pop())



Measured memory_bytes: 5684
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); //参加者N人
    int K = sc.nextInt(); //初期ポイントK点
    int Q = sc.nextInt(); //Q回のポイント変動
    int[] a = new int[Q];
    int[] b = new int[N];
    
    for(int i=0;i<Q;i++){
      a[i] = sc.nextInt();
      b[a[i]-1] += 1;
    }
    for(int j=0;j<N;j++){
      if(b[j]>Q-K){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 57560
import itertools

N = int(input())
cities = [tuple(map(int, input().split())) for _ in range(N)]

distance = 0
for c in itertools.combinations(range(N), 2):
    c1, c2 = c
    distance += ((cities[c1][0] - cities[c2][0]) ** 2 + (cities[c1][1] - cities[c2][1]) ** 2) **0.5

answer = 2 * distance / N

print(answer)


Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long ans = m;
        for(int i=0;i<n-1;i++)
            ans*=(m-1);
        System.out.println(ans);
    }
}


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

int main()
{
  string O, E;
  cin >> O >> E;
  
  for (int i = 0; i < O.size(); i++){
    cout << O.at(i);
    if( E.size() > i ) cout << E.at(i);
  }

  cout << endl;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<pair<unsigned long, unsigned long>>> K(N);
    for(auto& v : K){
        unsigned long A;
        cin >> A;
        for(unsigned long i{0}, x, y; i < A; ++i){
            cin >> x >> y;
            v.emplace_back(x - 1, y);
        }
    }
    unsigned long ans{0};
    for(unsigned long i{0}; i < 1UL << N; ++i)[&]{
        for(unsigned long j{0}; j < N; ++j)if((i >> j) & 1)for(const auto& c : K[j])if((i >> c.first & 1) != c.second)return ;
        ans = max<unsigned long>(ans, __builtin_popcountl(i));
    }();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
from collections import deque

k = ii()
l = deque()
run = [1,2,3,4,5,6,7,8,9]
ans = [1,2,3,4,5,6,7,8,9]

for i in range(2,100):
    ll=deque(run)
    keta = 10**(i-1)
    while len(ll)>0:
        v = ll.popleft()
        if(v>=keta):
            ans.append(v)
        else:
            p = v%10
            if p == 0:
                ll.append(v*10+0)
                ll.append(v*10+1)
            elif p==9:
                ll.append(v*10+8)
                ll.append(v*10+9)
            else:
                ll.append(v*10+p-1)
                ll.append(v*10+p)
                ll.append(v*10+p+1)
    if len(ans)>10**5:
        break
ans.sort()

print(ans[k-1])
                

            


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

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

fn main() {
    loop {
        let n: usize = read();
        if n == 0 { break; }
        let v = read_vec::<f64>();
        let n = n as f64;
        let m = v.iter().sum::<f64>() / n;
        let a = (v.iter().map(|s| (s-m).powf(2.0)).sum::<f64>() / n).sqrt();
        println!("{}", a);
    }
}



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

using namespace std;

const int N = 1e5 + 5;
const long long MOD = 1e9 + 7;
int n, k;
long long arr[N], fac[N], invfac[N], pref[N];

long long binpow(long long a, long long b){
    if(b == 0){
        return 1LL;
    } else {
        long long res = (binpow(a, b / 2) * binpow(a, b / 2)) % MOD;
        if(b & 1){
            res = (res * a) % MOD;
        }
        return res % MOD;
    }
}

void prec(){
    fac[0] = 1;
    invfac[0] = 1;
    fac[1] = 1;
    invfac[1] = 1;
    for(long long i = 2; i < N; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
        invfac[i] = binpow(fac[i], MOD - 2) % MOD;
    }
}

long long ncr(long long a, long long b){
    long long res = (fac[a] * invfac[b]) % MOD;
    res = (res * invfac[a - b]) % MOD;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    prec();

    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }
    sort(arr + 1, arr + 1 + n);
    for(int i = 1; i <= n; i++){
        pref[i] = (pref[i - 1] + arr[i]) % MOD;
    }

    if(k == 1){
        cout << 0 << '\n';
    } else if(k == 2){
        long long res = 0;
        long long m = n - 1;
        for(int i = 1; i <= n - 1; i++){
            long long x = (pref[n] - pref[i]) % MOD;
            while(x < 0){
                x += MOD;
            }
            x = x % MOD;

            x = (x - m * arr[i]) % MOD;
            while(x < 0){
                x += MOD;
            }
            x = x % MOD;
            res = (res + x) % MOD;
            m--;
        }
        cout << res % MOD << '\n';
    } else {
        long long ambil = k - 2;
        long long batas = k - 1;
        long long huew = n - batas;
        long long res = 0;
        for(long long i = ambil; i <= n - 2; i++){
            long long comb = ncr(i, ambil);
            long long kiri = (pref[n] - pref[i + 1]) % MOD;
            while(kiri < 0){
                kiri += MOD;
            }
            kiri = kiri % MOD;
            long long kanan = pref[huew];

            long long test = (kiri - kanan) % MOD;
            while(test < 0){
                test += MOD;
            }
            test = test % MOD;
            test = (test * comb) % MOD;
            res = (res + test) % MOD;
            huew--;
        }
        cout << res << '\n';
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
  int count = 0,hoken,max,answer,temp,now_buy;
  std::cin >> count;
  std::cin >> now_buy;
  max = now_buy;
  answer = max - now_buy;
  for(int i = 0;i < count - 1 ; i++)
  {
    std::cin >> temp;
    if(i == 0 && now_buy > temp)
    {
      hoken = now_buy;
      now_buy = temp;
      answer = now_buy - hoken;
      continue;
    }
    if(answer < 0 && now_buy > temp)
    {
      hoken = now_buy;
      now_buy = temp;
      if(answer < now_buy - hoken)
      {
        answer = hoken - now_buy;
      }
      continue;
    }
    if(now_buy > temp)
    {
      now_buy = temp;
    }
    else if(answer < temp - now_buy)
    {
      answer = temp - now_buy;
    }
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m,a,b;
ll ans[1005][1005];
string f[1005];
priority_queue<pair<ll,P>,vector<pair<ll,P> >,greater<pair<ll,P> > > que;

int main(){
	cin>>n>>m>>a>>b;
	rep(i,n) cin>>f[i];
	int sx,sy,gx,gy;
	rep(i,n)rep(j,m){
		ans[i][j] = 1e18;
		if(f[i][j] == 's'){
			sx = i; sy = j;
		}
		if(f[i][j] == 'g'){
			gx = i; gy = j;
		}
	}
	ans[sx][sy] = 0;
	que.push(mp(0,mp(sx,sy)));
	while(!que.empty()){
		P1 p = que.top(); que.pop();
		if(p.fi != ans[p.sc.fi][p.sc.sc]) continue;
		int dx[8]={0,0,1,-1,1,1,-1,-1};
		int dy[8]={1,-1,0,0,1,-1,1,-1};
		rep(k,4){
			int nx = p.sc.fi+dx[k], ny = p.sc.sc+dy[k];
			if(0<=nx&&nx<n &&0<=ny && ny<m && f[nx][ny] != '#'){
				if(ans[nx][ny] > p.fi+1LL*a){
					ans[nx][ny] = p.fi+1LL*a;
					que.push(mp(ans[nx][ny],mp(nx,ny)));
				}
			}
		}
		bool bad = 0;
		if(f[p.sc.fi][p.sc.sc] == '*') bad = 1;
		rep(k,8){
			int nx = p.sc.fi+dx[k], ny = p.sc.sc+dy[k];
			if(0<=nx&&nx<n &&0<=ny && ny<m && f[nx][ny] == '*'){
				bad = 1;
			}
		}
		if(!bad){
			rep(k,8){
				int nx = p.sc.fi+dx[k], ny = p.sc.sc+dy[k];
				int w = abs(dx[k])+abs(dy[k]);
				if(0<=nx&&nx<n &&0<=ny && ny<m){
					if(ans[nx][ny] > p.fi+1LL*b+1LL*w*a){
						ans[nx][ny] = p.fi+1LL*b+1LL*w*a;
						que.push(mp(ans[nx][ny],mp(nx,ny)));
					}
				}
			}
		}
	}
	if(ans[gx][gy] < 1e17) cout << ans[gx][gy] << endl;
	else cout << "INF" << endl;
}


Measured memory_bytes: 12032
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


def sum_digit(number):
    string = str(number) # 文字列にすることで若干高速化
    array = list(map(int, list(string))) # list(string)：文字列を1文字のリストに，文字を数値に
    return sum(array)


if __name__ == '__main__':
    n = int(input())
    sn = sum_digit(n)

    if n % sn == 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n;
    ll a[n+2],d[n+2];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    d[1]=0;
    for(i=2;i<=n;i++)
    {
        d[i]=LLONG_MAX;
        for(j=1;j<3;j++)
        {
            if((i-j)>0)
            {
                d[i]=min(d[i],abs(a[i]-a[i-j])+d[i-j]);
            }
        }
    }
    cout<<d[n]<<"\n";
    return 0;
}

Measured memory_bytes: 5224
def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        s, t = map(int, input().split())
        adj[s].append(t)

    dp0 = [0.] * (N+1)
    ans = N-1
    for i in range(N-1, 0, -1):
        s = 0
        m = -1
        maxj = 0
        for j in adj[i]:
            s += dp0[j]
            if dp0[j] > m:
                m = dp0[j]
                maxj = j
        dp0[i] = s / len(adj[i]) + 1
        if len(adj[i]) > 1:
            dp = dp0[:]
            dp[i] = (s - m) / (len(adj[i]) - 1) + 1
            for ii in range(i-1, 0, -1):
                ss = 0
                for jj in adj[ii]:
                    ss += dp[jj]
                dp[ii] = ss / len(adj[ii]) + 1
            ans = min(ans, dp[1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51548
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():
    n = int(input())
    lists = []
    ans = [0]*4
    for i in range(n):
        s = input()
        if not s in lists:
            lists.append(s)


        if s == "AC":
            ans[0] += 1
        elif s == "WA" :
            ans[1] += 1
        elif s == "TLE":
            ans[2] += 1
        else:
            ans[3] += 1
    

    for i in range(len(ans)):
        if i == 0:
            print("AC x", ans[i])
        elif i == 1 :
            print("WA x", ans[i])
        elif i == 2:
            print("TLE x", ans[i])
        else:
            print("RE x", ans[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 9736
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
//#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int long long
#define vi vector<int>


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

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<P> b;
  rep(i,n){
    b.PB(P(a[i],i));
  }
  sort(all(b));
  reverse(all(b));

  set<P> sr,sl;
  int ans=0;
  rep(i,n){
    auto itr=sr.lower_bound(P(b[i].S,b[i].F));
    auto itl=sl.lower_bound(P(-b[i].S,b[i].F));
    auto itrr=sr.upper_bound(P(*itr));
    auto itll=sl.upper_bound(P(*itl));
    int r,l,rr,ll;
    if(itr==sr.end()) r=n;
    else r=itr->F;
    if(itrr==sr.end()) rr=n;
    else rr=itrr->F;

    if(itl==sl.end())
      l=-1;
    else l=-itl->F;
    if(itll==sl.end())
      ll=-1;
    else ll=-itll->F;

    //cout<<l<<' '<<r<<endl;
    if(r!=n)
      ans+=b[i].F*(b[i].S-l)*(rr-r);
    //cout<<' '<<ans<<endl;
    if(l!=-1)
      ans+=b[i].F*(r-b[i].S)*(l-ll);
    //cout<<rr<<' '<<r<<' '<<ll<<' '<<l<<endl;
    //cout<<(b[i].S-l)<<' '<<(r-b[i].S)<<endl;
    //cout<<ans<<endl;

    //cout<<r<<' '<<l<<endl;
    sr.insert(P(b[i].S,b[i].F));
    sl.insert(P(-b[i].S,b[i].F));
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 15088