akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;

using namespace std;

typedef pair<long,long> pr;
struct ver {long di,node,prev;};
struct Order {
	bool operator() (ver const& a,ver const& b) const {
		return a.di > b.di || ((a.di == b.di) && (a.node > b.node));
	}
};
typedef priority_queue<ver,vector<ver>,Order> pq;

class Dijekstra {
private:
	vector<vector<pr>> E;
	vector<long> dist;
	vector<long> trace;
	size_t V;
public:
	Dijekstra() : V(0) { }
	Dijekstra(size_t v) :
		V(v),E(v,vector<pr>(0)),dist(v,2147483647),trace(v,2147483647) {}

	size_t size() { return V;}

	void add_edge_directed(long from,long to,long dis){
		E[from].push_back(pr(to,dis));
	}

	void add_edge_undirected(long from,long to,long dis){
		E[from].push_back(pr(to,dis));
		E[to].push_back(pr(from,dis));
	}	

	void dijekstra(long start){
		pq que;
		dist[start] = 0;
		trace[start] = start;
		que.push(ver{0,start,start});

		while(! que.empty()){
			ver next = que.top();
			que.pop();
			long next_v = next.node;
			if (dist[next_v] < next.di) continue; //既により最適が見つかっている
			dist[next_v] = next.di;
			trace[next_v] = next.prev;
			
			REP(i,E[next_v].size()){
				pr e = E[next_v][i];
				if (dist[e.first] == 2147483647) que.push(ver{next.di+e.second,e.first,next_v});
			}
		}
	}

	long dijekstra_fast(long start,long goal){
		pq que;
		dist[start] = 0;
		trace[start] = start;
		que.push(ver{0,start,start});

		while(! que.empty()){
			ver next = que.top();
			que.pop();
			long next_v = next.node;
			if (dist[next_v] < next.di) continue; //既により最適が見つかっている
			dist[next_v] = next.di;
			trace[next_v] = next.prev;
			if (next_v == goal) break;	//goalが求まったら即終了
			
			REP(i,E[next_v].size()){
				pr e = E[next_v][i];
				if (dist[e.first] == 2147483647) que.push(ver{next.di+e.second,e.first,next_v});
			}
		}

		if (dist[goal] == 2147483647) return 1;
		else return dist[goal];
	}

	vector<long> all_result(void){
		return dist;	// 非連結なら 2147483647 が入っている。
	}

	vector<long> show_trace(long start,long goal){
		vector<long> trace_result;
		for (long node = goal;node != start;node = trace[node]){
			trace_result.push_back(node);
		}
		trace_result.push_back(start);

		return trace_result; // 配列の先頭がgoal,末尾がstart
	}
};

int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Dijekstra dij(V);

	REP(i,E){
		cin >> s >> t >> d;
		dij.add_edge_directed(s,t,d);
	}

	dij.dijekstra(R);
	vector<long> ans;
	ans = dij.all_result();
	REP(i,V) {
		if (ans[i] == 2147483647) cout << "INF" << endl;
		else cout << ans[i] << endl;
	}
		
	return 0;
}




Measured memory_bytes: 24332
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> score(n,0);
    for(int i=0;i<q;i++){
        int a;
        cin>>a;
        score[a-1]++;
    }
    for(int i=0;i<n;i++){
        score[i]=score[i]+(k-q);
        if(score[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int p[] = new int[n];
		int highPrice = 0;
		int pHighPrice = 0;
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
			if(p[i] > highPrice) {
				highPrice = p[i];
				pHighPrice = i;
			}
		}
		int sum = 0;
		for(int j = 0; j < n; j++) {

			if(j == pHighPrice) {
				sum += highPrice / 2;
			} else {
				sum += p[j];
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();
		int num4 = sc.nextInt();
		int num5 = sc.nextInt();
		int num6 = sc.nextInt();
		int num7 = sc.nextInt();
		int num8 = sc.nextInt();
		int num9 = sc.nextInt();
		int num10 = sc.nextInt();

		System.out.println(num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10);
	}

}

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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int a[n];
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	int left = 0;
	int right = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] < x) {
			left++;
		} else {
			right++;
		}
	}
	int ans;
	if (left < right) {
		ans = left;
	} else {
		ans = right;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> v;
    v.push_back(0);
    for(int i = 1; i < n; i++) {
        v.push_back(n-i);
    }
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            int before = abs(i-j);
            int now = min(before, min(abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x)));
//            cout << before << " " << now << " " << i << " " << j << endl;
            v[before]--;
            v[now]++;
        }
    }
    for(int i = 1; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

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

odd_check = ('R', 'U', 'D')
even_check = ('L', 'U', 'D') 

s = input()
s = list(s)

roop_count = 1

for i in s:
    if roop_count % 2 != 0:
        if i in odd_check:
            roop_count += 1
            pass
        else:
            print('No')
            exit()
    
    else:
        if i in even_check:
            roop_count += 1
            pass
        else:
            print('No')
            exit()
            

print('Yes')

Measured memory_bytes: 3064
<?php

$stdins = [];
while($line=fgets(STDIN)){
    $stdins[] = trim($line);
}

for($index=0;$index<count($stdins);$index++){
    if($index > 0) printf("\n");
    $S = $stdins[$index];

    $keys = [];
    $keys["a"] = false;
    $keys["b"] = false;
    $keys["c"] = false;
    $keys["d"] = false;
    $keys["e"] = false;
    $keys["f"] = false;
    $keys["g"] = false;
    $keys["h"] = false;
    $keys["i"] = false;
    $keys["j"] = false;
    $keys["k"] = false;
    $keys["l"] = false;
    $keys["m"] = false;
    $keys["n"] = false;
    $keys["o"] = false;
    $keys["p"] = false;
    $keys["q"] = false;
    $keys["r"] = false;
    $keys["s"] = false;
    $keys["t"] = false;
    $keys["u"] = false;
    $keys["v"] = false;
    $keys["w"] = false;
    $keys["x"] = false;
    $keys["y"] = false;
    $keys["z"] = false;

    $length = strlen($S);
    for($i=0;$i<$length;$i++) {
        $keys[$S[$i]] = true;
    }

    $found = false;
    foreach($keys as $key=>$value){
        if(!$value){
            $found = true;
            break;
        }
    }
    if($found){
        print($S.$key);
    }else{
        $found = false;
        for($i=strlen($S)-1;$i>=0;$i--){
            $p = ord($S[$i]);
            for($j=$p+1;$j<=ord("z");$j++){
                if(!$keys[chr($j)]){
                    $found = true;
                    print(substr($S, 0, $i).chr($j));
                    break;
                }
                if($found) break;
            }
            $keys[chr($p)] = false;
            if($found) break;
        }
        if(!$found){
            print("-1");
        }
    }
}

Measured memory_bytes: 3956
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<int> > x(n, vector<int>(n)), y(n, vector<int>(n));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cin >> x[i][j] >> y[i][j];
            }
        }

        int ret = 0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                if(y[i][j] == -1)
                    continue;
                int y1 = i;
                int x1 = j;
                while(y[y1][x1] >= 0){
                    int y2 = y[y1][x1];
                    int x2 = x[y1][x1];
                    y[y1][x1] = x[y1][x1] = -i*n-j-1;
                    y1 = y2;
                    x1 = x2;
                    if(y[y1][x1] == -i*n-j-1)
                        ++ ret;
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()

const ll inf=0x3f3f3f3f3f3f3f3f;
ll power(ll a, ll b, ll p) {
 	ll rtn = 1;
 	while(b) {
 		if(b & 1) {
 			rtn = (rtn % p * a % p) % p;
 		}
 		a = (a % p * a % p) % p;
 		b /= 2;
 	}
 	return rtn % p;
 }

int main() {
    SPEED;
    ll n;
    cin>>n;
    ll p = 1e9 + 7;
    if(n < 2) {
    	cout<<0;
    	return 0;
    }
    ll ans = 0;
    ans = ((power(10, n, p) + power(8, n, p)) % p - (2 * power(9, n, p)) % p + p) % p;
    cout<<ans;
    return 0;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, i, j;
    cin>>n;
    int a[n+1];
    int b[n];
    int c[n+1];

    for(i=0; i<n+1; i++){
        cin>>a[i];
        c[i] = a[i];
    }
    for(i=0; i<n; i++){
        cin>>b[i];
    }

    ll ans = 0;

    for(i=0; i<n; i++){
        int tmp = a[i];
        a[i] = max(0, a[i] - b[i]);
        if(a[i]==0){
            a[i+1] = max(0, a[i+1] - (b[i] - tmp));
        }
        //cout<<a[i]<<" "<<a[i+1]<<endl;
    }

    for(i=0; i<n+1; i++){
        ans += c[i] - a[i];
        //cout<<a[i]<<endl;
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1408
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val k = Scanner.nextInt
	val s = Scanner.next

	pw.println(s.take(k) ++ (if (s.length > k) "..." else ""))
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54676
#include<bits/stdc++.h>
#define maxn 100050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
int a[maxn];
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	LL ans=0;
	int cur=1;
	while(1){
		if(a[cur]==2){
			ans++;
			break;
		}
		if(ans>=n){
			ans=-1;
			break;
		}
		cur=a[cur];
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
require 'pp'
N,_=gets.chomp.split(' ').map{|n| n.to_i}
A = gets.chomp.split(' ').map{|n| n.to_i}
S = Array.new(N+1){0}
cnt = 0
S[0] = 0
for i in 0..(N-1)
	S[i+1] = S[i]+A[i]
end
h = {}
S.each{|s|
	h[s].nil? ? h[s]=1 : h[s]+=1
}
cnt = 0
h.each{|k,v|
	cnt += v*(v-1)/2
}
puts cnt


Measured memory_bytes: 32892
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
#define ALL(a) begin(a),end(a)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int  ui;
const int MOD=1000000007;
const double EPS=1e-9;

int a,b,c,d;

int main(){
    cin>>a>>b>>c>>d;
    if((abs(a-b)<=d && abs(b-c)<=d)||(abs(a-c)<=d))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>

using namespace std;

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

	string preS = "";
	int ans = 1;
	preS = S[0];
	for (int i = 1; i < S.length(); ++i) {
		string nextS = "";
		bool check = false;
		for (int j = i; j < S.length(); ++j) {
			nextS += S[j];
			if (preS != nextS) {
				++ans;
				preS = nextS;
				i = j;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int N,K,tmp,t=0;
	scanf("%d%d",&N,&K);
	int p[N];
	for(int i=0;i<N;i++){
		scanf("%d",&p[i]);
	}
	for (int i=0; i<N; ++i) {
		for (int j=i+1; j<N; ++j) {
			if (p[i] > p[j]) {
				tmp =  p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}
	for(int i=0;i<K;i++){
		t+=p[i];
	}
	printf("%d\n",t);

	
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	char c,last='t';
	int mx = 0,ans=0;
	for (int i = 0; i < 3; i++) {
		cin >> c;
		if (c=='R') ans++,mx=max(ans,mx);
		else ans=0;
	}
	cout << mx << "\n";
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
using namespace std;
bool prime(int a){
	for(int i=2;i*i<=a;i++)if(a%i==0)return false;
	return true;
}
int v[4];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(b<0){
		if(a==1)printf("11\n");
		else{
			for(int i=0;i<a*2;i++)printf("9");
			printf("\n");
		}
	}else{
		int t=1;
		int ret=0;
		for(int i=0;i<a;i++)t*=10;
		for(int i=0;i<t;i++){
			int c=i;
			for(int j=0;j<a;j++){
				v[j]=c%10;
				c/=10;
			}
			if(v[a-1]==0)continue;
			int n=0;
			for(int j=0;j<a;j++){
				n*=10;
				n+=v[a-1-j];
			}
			n*=10;
			n+=b;
			for(int j=0;j<a;j++){
				n*=10;
				n+=v[j];
			}
			if(prime(n))ret=max(ret,n);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1024
def cmb(n, r):
    if n - r < 0: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

# print(cmb(1,2))

N = int(input())
s = []

for i in range(N):
    temp = ''.join(sorted(input()))
    s.append(temp)

s = sorted(s)

# print(s)
ans = 0
count = 1

for i in range(1,N):
    if s[i-1] == s[i]:
         count += 1
    else:
        if count >= 2:
            ans += cmb(count,2)
            count = 1

ans += cmb(count,2)

print(ans)


Measured memory_bytes: 11404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, s) for (int i = s; i < (int)(n); i++)
#define twopo(k)  1 << k

typedef vector<int> vec1;
typedef vector<vector<int>> vec2;
typedef vector<vector<char>> cvec2;
typedef pair<int, int> pairi;

vec1 vecplus(const vec1 &first, const vec1 &second){
  int length = first.size();
  vec1 answer(length);
  rep(i,length){
    answer.at(i) = first.at(i) + second.at(i);
  }
  return answer;
}

vec2 listmake(const int &row, const int &col){
  vec2 list;
  rep(i,row){
    vec1 v(col);
    rep(j,col){
      cin >> v.at(j);
    }
    list.push_back(v);
  }
  return list;
}

int main(){
  string S;
  cin >> S;
  if (S == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

    ll n;
    cin>>n;
    ll tmp=n;
    ll ans=0;
    if(tmp%2==1){
        fin(0);
        return 0;
    }
    while(tmp>0){
        ans+=tmp/5;
        tmp/=5;
    }
    // ll five=0;
    // ll a=50,d=100;
    // rep(i,100000){
    //     five+=(n+a)/(double)d;
    //     if(!i%2){
    //         a*=5;
    //         d*=5;
    //     } else {
    //         a*=2;
    //         d*=2;
    //     }
    //     if(n<d)break;
    // }
    // ll two=0;
    // tmp=n;
    // while(tmp>0){
    //     two+=tmp/2;
    //     tmp/=2;
    // }
    // ans-=(n+10-5)/10;
    // ans-=(n+50-25)/50;
    // ans-=(n+250-125)/250;
    ll a=5;
    rep(i,100){
        ans-=(n-a+2*a)/(a*2);
        a*=5;
        if(a>n)break;
        // fin(ans);
    }

    fin(ans);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

struct mint {

  ll x; 

  mint(ll x=0):x((x%mod+mod)%mod){} //コンストラクタを呼んで自動的にmodを取っている。

  mint operator-() const { return mint(-x);}

  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    //メンバ関数にはthisポインタがある。メンバ変数の値を返す。
    return *this;
  }

  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }

  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1); //a=x/2
    a *= a; //繰り返し二乗法
    if (t&1) a *= *this; //tが奇数のときはxを1回かける
    return a;
  }



  // for prime mod

  mint inv() const {
    return pow(mod-2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
    
};

vector<mint> f(200005);

mint choose(ll n,ll r){
  return f[n]/(f[n-r]*f[r]);
}

int main()
{
    ll n,k;
    cin >> n >> k;
    f[0]=1;
    for(ll i=1;i<=n;i++){
        f[i]=f[i-1]*i;
    }
    ll ans=0;
    rep(i,min(k,n-1)+1){
        mint a;
        a=choose(n,i)*choose(n-1,i);
        ans+=a.x;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 1792
/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=1e13;
const ll maxn=1e6+5;
const int mod=998244353;
const double eps=1e-12;
ll n,m,p;
ll num[maxn];
int pre[maxn][2];
int cur[maxn][2];
struct node{
    int l,r;
    ll w;
}t[maxn<<2];
inline bool read(ll &num)
{
        char in;bool IsN=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&(in<'0'||in>'9')) in=getchar();
        if(in=='-'){ IsN=true;num=0;}
        else num=in-'0';
        while(in=getchar(),in>='0'&&in<='9'){
                num*=10,num+=in-'0';
        }
        if(IsN) num=-num;
        return true;
}
void build(int k,int l,int r){
    t[k].l=l;t[k].r=r;
    if(l==r){
        t[k].w=num[l];
        return;
    }
    int mid=(l+r)/2;
    build(k<<1,l,mid);
    build(k<<1|1,mid+1,r);
    t[k].w=max(t[k<<1].w,t[k<<1|1].w);
}
ll query(int k,int x,int y){
    if(t[k].l>=x&&t[k].r<=y){
        return t[k].w;
    }
    ll sum=0;
    int mid=(t[k].l+t[k].r)/2;
    if(x<=mid) sum=max(query(k<<1,x,y),sum);
    if(y>mid) sum=max(query(k<<1|1,x,y),sum);
    return sum;
}
void work_one(){//预处理左边第一个比他大的
    for(int i=1;i<=n;i++){
        pre[i][1]=pre[i][0]=0;//假设第一个比他大的和第二个比他大的都木有
        ll l=1,r=i-1;
        ll ans=-1,aim=num[i];
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(1,mid,i)>aim){
                l=mid+1;
                ans=mid;
            }
            else r=mid-1;
        }
       // printf("%lld\n",ans);
        if(ans==-1) continue;
        pre[i][0]=ans;
        ll temp=-1;
        l=1,r=ans-1;
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(1,mid,ans-1)>aim){
                l=mid+1;
                temp=mid;
            }
            else r=mid-1;
        }
        if(temp==-1) continue;
        pre[i][1]=temp;
    }
}
void work_two(){
    for(int i=n;i>=1;i--){
        cur[i][1]=cur[i][0]=n+1;
        ll l=i+1,r=n;
        ll ans=-1,aim=num[i];
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(1,i,mid)>aim){
                r=mid-1;
                ans=mid;
            }
            else l=mid+1;
        }
       // printf("%lld\n",ans);
        if(ans==-1) continue;
        cur[i][0]=ans;
        ll temp=-1;
        l=ans+1,r=n;
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(1,ans+1,mid)>aim){
                r=mid-1;
                temp=mid;
            }
            else l=mid+1;
        }
        if(temp==-1) continue;
        cur[i][1]=temp;
    }
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)read(num[i]);
    build(1,1,n);
    work_one();
    work_two();
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(pre[i][0]-pre[i][1])*(cur[i][0]-i)*num[i];
        ans+=(cur[i][1]-cur[i][0])*(i-pre[i][0])*num[i];
    }
    printf("%lld\n",ans);
    return 0;
}
/***
5
1 2 3
2 2 3
3 1 2
2 1 2
1 1 2
***/


Measured memory_bytes: 12544
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, D;
  get(N, D);
  print((N + 2 * D) / (2 * D + 1));
  return 0;
}

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

int main(){
  string s; cin >> s;
  bool res;
  bool curr = 0;
  for (int i = 0; i < s.size(); i++){
    if (!curr && s[i] == 'C'){
      curr = 1;
    } else if (curr && s[i] == 'F'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        if(n%2==0) {
        System.out.println(n/2);
        }else {
        	System.out.println(n/2+1);
        }
	}

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%lf\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}


Measured memory_bytes: 2140
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    # n = getN()
    s = getS()
    s2 = getS()
    ans = 0
    for i, j in zip(s, s2):
        if i != j:
            ans += 1
    print(ans)
    # print(n + n * n + n * n* n)
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

typedef long long ll;
#define DEBUG


ll centinel(const vector<vector<ll>>& table, int i, int j){
    if(!(0 <= i && i <= table.size())){
        return 0;
    }
    if(!(0 <= j && j <= table[0].size())){
        return 0;
    }
    return table[i][j];
}

void solve(long long N, long long M, long long Q, std::vector<long long> L, std::vector<long long> R, std::vector<long long> p, std::vector<long long> q){
    // NNテーブルをつくる
    vector<vector<ll>> table(N+1, vector<ll>(N+1, 0));
    for(int i=0; i < M; i++){
        table[L[i]][R[i]]++;
    }
    // テーブルの累積和を準備する。そこから左上の和がもとまるようにする。
    vector<vector<ll>> acc(N+1, vector<ll>(N+1, 0));
    
    for(int i=0; i < N+1; i++){
        //// 各行ごとに累積和を準備
        vector<ll> row(N+1, 0);
        for(int j=0; j < N+1; j++){
            row[j] = table[i][j] + (j == 0 ? 0 : row[j-1]);
        }
        //// それをつかって累積和を更新
        for(int j=0; j < N+1; j++){
            acc[i][j] = row[j] + (i == 0 ? 0 : acc[i-1][j]);
        }
    }
    // クエリを累積和でこたえる。
    for(int i=0; i < Q; i++){
        ll res = centinel(acc, q[i], q[i]) + centinel(acc, p[i]-1, p[i]-1) - centinel(acc, p[i]-1, q[i]) - centinel(acc, q[i], p[i]-1);
        cout << res << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> q(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&q[i]);
    }
    solve(N, M, Q, std::move(L), std::move(R), std::move(p), std::move(q));
    return 0;
}


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

using namespace std;

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

  sort(d.begin(),d.end());
  
 int res;
 
  res=d[n/2]-d[n/2-1];
  
  cout << res << endl;
  
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n;
	cin>>n;
	vector<P> v(n);
	int a[100010], b[100010];
	for(int i=0; i<n; i++){
		cin>>v[i].second;
	}
  for(int i=0; i<n; i++){
		cin>>v[i].first;
	}
	sort(v.begin(), v.end());
	int x[100010];
	vector<int> vx[100010];
	for(int i=0; i<n; i++){
		a[i]=v[i].second, b[i]=v[i].first;
	}
	for(int i=0; i<n; i++){
		x[i]=lower_bound(b, b+n, a[i])-b;
		vx[x[i]].push_back(i);
	}
	int cnt=0;
	for(int i=n; i>=0; i--){
		cnt+=vx[i].size();
		if(cnt>=n+1-i){
			cout<<"No"<<endl;
			return 0;
		}
	}
	int p[100010];
	for(int i=0; i<n; i++){
		if(vx[i].size()!=1){
			cout<<"Yes"<<endl;
			return 0;
		}
		p[i]=vx[i][0];
	}
	bool used[100010]={};
	int cur=0;
	int c=0;
	while(!used[cur]){
		used[cur]=1;
		cur=p[cur];
		c++;
	}
	if(c<n){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 8576
n, m = map(int, input().split())
pyi = [list(map(int, input().split())) + [i] for i in range(m)]
ids = [""] * m
s = {j + 1: 1 for j in range(n)}
for p, y, i in sorted(pyi, key=lambda d: d[1]):
    ids[i] = "%06d%06d" % (p, s[p])
    s[p] += 1
for iid in ids:
    print(iid)

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

using namespace std;

int main() {
    map<int, int> mmp;
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        sum += x;
        mmp[x]++;
    }
    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        int w = mmp[x];
        //cout << w << endl;
        sum += 1LL * w * (y - x);
        mmp[y] += w;
        mmp[x] -= w;
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 8040
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	int flag;
	while(true)
	{
		if(a<0){
			flag=0;
			break;
		}if(c<0){
			flag=1;
			break;
		}
		if(a>0)
		c=c-b;
		if(c<=0){
			flag=1;
			break;
		}
		if(c>0)
		{
			a=a-d;
		}
	}
	if(flag==1)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

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


ll i, j, k;

int main(){
    scanf("%lld", &i);
    printf("%lld", abs(i - 1));
    return 0;
}

Measured memory_bytes: 3752
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    return NO if bool(N % (sum([int(v) for v in str(N)]))) else YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 3096
import java.util.HashMap;
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int number = input.nextInt(); // number of residents
        int[][] house = new int[12][10];
        for(int i = 0; i < number; i++){
            int b = input.nextInt();
            b = (b - 1) * 3; // Change b into a 3 based
            int f = input.nextInt();
            int r = input.nextInt();
            int v = input.nextInt();
            house[b+f-1][r-1] += v;
        }
        display(house);
    }
     public static void display(int[][] house){
        for(int i = 0; i < 12; i++){
            if(i%3==0 && i != 0){
                System.out.println("####################");
            }
            for(int j = 0; j < 10; j++){
                System.out.print(" " + house[i][j]);
            }
            
                System.out.print("\n");
        }
    }
}


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

int main(){
  string S;
  cin>>S;
  int oddwhite=0;
  int oddblack=0;
  
  for(int i;i<S.length();i++){
    if(i%2==0&&S[i]=='1'){
      oddblack++;
  	}else if(i%2==0&&S[i]=='0'){
      oddwhite++;
    }else if(i%2==1&&S[i]=='0'){
      oddblack++;
    }else if(i%2==1&&S[i]=='1'){
      oddwhite++;
    }else{
      cout<<"error"<<endl;
    }
  }
  cout<<min(oddblack,oddwhite)<<endl;
  return 0;
}

Measured memory_bytes: 512
from collections import deque
K = int(input()) - 1
todo = deque(range(1, 10))
ans = []
counter = 0
while counter <= K:
    seed = todo.popleft()
    ans.append(seed)
    counter += 1
    last_dig = int(str(seed)[-1])
    for i in range(max(0, last_dig-1), min(10, last_dig+2)):
        todo.append(int(str(seed) + str(i)))
print(ans[-1])

Measured memory_bytes: 14924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int a, b;

	std::cin >> a >> b;

	std::cout << std::max(0, a - 2*b);

	return 0;
}

Measured memory_bytes: 256
N=int(input())

def is_ok(n):
    if n*(n+1)//2>=N:
        return True
    else:
        return False

ng=0
ok=N+1

while abs(ng-ok)>1:
    mid=(ok+ng)//2

    if is_ok(mid):
        ok=mid
    else:
        ng=mid

diff=ok*(ok+1)//2-N

for i in range(1,ok+1):
    if i!=diff:
        print(i)

Measured memory_bytes: 74512
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	string s; cin >> s;

	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			cout << '9';
		}else if (s[i] == '9') {
			cout << '1';
		}else {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}


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

int main(void){
    string S, T;
    cin >> S;
    cin >> T;
    int res = 1001;
    for(int i=0; i<=S.size()-T.size(); i++){
        int resbuf = 0;
        for(int j=0; j<T.size(); j++)if(S[i+j]!=T[j])resbuf++;
        res = min(res, resbuf);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <map>

using namespace std;

int main(){
    int idx1 = 0, idx2 = 0;
    map<char, int> map1, map2;

    string s, t;
    cin >> s; cin >> t;

    for(int i=0; i<s.length(); i++)
    {
        auto it = map1.find(s[i]);
        if(it == map1.end())
        {
            char c = 'a' + idx1;
            map1.insert(std::make_pair(s[i], c));
            s[i] = c;
            idx1++;
        }
        else
        {
            s[i] = (char)it->second;
        }

        auto it2 = map2.find(t[i]);
        if(it2 == map2.end())
        {
            char c = 'a' + idx2;
            map2.insert(std::make_pair(t[i], c));
            t[i] = c;
            idx2++;
        }
        else
        {
            t[i] = (char)it2->second;
        }
    }

    if(s.compare(t) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 776
import std.stdio, std.conv, std.string, std.range, std.typecons, std.format, core.bitop;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.mutation;

void main()
{
    long[] input = readln().split.to!(long[]);
    long N = input[0];
    long K = input[1];
    long[] list = readln().split.to!(long[]);

    long x = 0;
    for(long i = 0;i < 41;i++)
    {
        int fragCount;
        foreach(e; list)
        {
            if((e&(1L<<i))!=0)
            {
                fragCount++;
            }
        }
        x |= (fragCount > list.length-fragCount?0:1L)<<i;
    }
    foreach_reverse(long i; 0..41)
    {
        if((x & (1L<<i)) < (K & (1L<<i)))
        {
            break;
        }
        if((x & (1L<<i)) > (K & (1L<<i)))
        {
            x &= ~(1L<<i);
        }
    }
    long sum;
    foreach(e; list)
    {
        sum += e^x;
    }
    writeln(sum);
}


Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char str[101];
	gets(str);
	int len=strlen(str),i,j;
	for(i=0;i<len-1;i++)
		if(str[i]=='C')
		{
			for(j=i+1;j<len;j++)
				if(str[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
		}
	printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
	int N;
	cin >> N;
	int P[N];
	for(int i = 0; i < N; i++){
		cin >> P[i];
	}
	int cnt = 0;
	for(int i = 1; i < N-1; i++){
		int tr[3];
		tr[0] = P[i-1]; tr[1] = P[i]; tr[2] = P[i+1];
		sort(tr, tr+3);
		if(tr[1] == P[i]){
			cnt++;
		}
	}
	cout << cnt << "\n";
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll N = 5e6 + 10, MOD = 998244353;
ll inv[N], fac[N], inv_fac[N];

void precalc() {
	inv[1] = 1;
	FOR(n,2,N) inv[n] = -(MOD/n)*inv[MOD%n] % MOD;

	fac[0] = 1;
	FOR(n,1,N) fac[n] = n*fac[n-1] % MOD;

	inv_fac[0] = 1;
	FOR(n,1,N) inv_fac[n] = inv[n]*inv_fac[n-1] % MOD;
}

ll binom(ll n, ll k) {
	if (k < 0 || k > n) return 0;
	ll res = fac[n] * inv_fac[k] % MOD * inv_fac[n-k] % MOD;
	if (res < 0) res += MOD;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	precalc();

	ll n, m;
	cin >> n >> m;
	
	ll res = binom(3*m+n-1,n-1);
	
	FOR(hmax,2*m+1,3*m+1) {
		res = (res - n*binom(3*m-hmax+n-2,n-2)) % MOD;
	}
	
	FOR(codd,m+1,3*m+1) {
		if (codd%2 != (3*m)%2) continue;
		res = (res - binom(n,codd) * binom((3*m-codd)/2+n-1,n-1)) % MOD;
	}
	
	if (res < 0) res += MOD;
	cout << res << endl;

}



Measured memory_bytes: 117504
#include "bits/stdc++.h"
using namespace std;

#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 10e9+7

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



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

        int n;
        cin >> n;

        ll zmax = -INF;
        ll zmin = INF;
        ll wmax = -INF;
        ll wmin = INF;

        rep(i,n){
                ll x,y;
                cin >> x >> y;
                
                if(x + y > zmax){zmax = x + y;}
                if(x + y < zmin){zmin = x + y;}
                if(x - y > wmax){wmax = x - y;}
                if(x - y < wmin){wmin = x - y;}
        }

        cout << max(zmax - zmin , wmax - wmin) << endl;


        return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> L(N * 2);
  rep (i,N * 2) cin >> L[i];
  sort(L.begin(), L.end());
  long ans = 0;
  for (long i = 0; i < N * 2; i+= 2) {
    ans += L[i];
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int ans = 0;

        for(int i=0; i<N; i++){
            ans += Math.abs(sc.nextInt() - sc.nextInt()) + 1;
        }

        System.out.println(ans);
    }
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n; std::string s; std::cin >> n >> s;
  int ans = 1;
  REP(i,n-1) {
    if (s[i]!=s[i+1]) ans ++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            var ans = Solve();
            Console.WriteLine(ans.Item1 + " " + ans.Item2 + " " + ans.Item3);
            Console.ReadKey();
        }

        static Tuple<int,int,int> Solve()
        {
            int N;int Y;
            Multi(out N, out Y);
            for(int i = 0; i < N + 1;i++)
            {
                for(int j = 0; j < N + 1 - i; j++)
                {
                    if (10000 * i + 5000 * j + (N - i - j) * 1000 == Y)
                    {
                        return new Tuple<int, int, int>(i, j, N - i - j);
                    }
                }
            }
            return new Tuple<int, int, int>(-1, -1, -1);
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11220