akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut p = vec![];
    for _ in 0..n {
        let x: f64 = it.next().unwrap().parse().unwrap();
        let y: f64 = it.next().unwrap().parse().unwrap();
        p.push((x, y));
    }
    let mut ans = 0.0;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let dx = p[i].0 - p[j].0;
            let dy = p[i].1 - p[j].1;
            let d = (dx * dx + dy * dy).sqrt();
            ans += d;
        }
    }
    ans = ans / n as f64;
    println!("{:.9}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){

	int a,i,j;

	i = 1;

	while(1) {
		scanf("%d", &a);
		if (a == 0)
			break;
		printf("Case %d: %d\n", i, a);
		i++;
	} while (a != 0);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<n;i++)
using namespace std;
 
//int mod=(int)(1e9+7);
 
void solve()
{   
	int L,R,d;
	cin>>L>>R>>d;
	int fir = L/d;
	int last = R/d;
	if(L%d == 0)
		cout<<(last-fir+1)<<endl;
	else cout<<(last-fir)<<endl;
}
 
signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
  // int t;cin>>t;
  // for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;
 
return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  if (s[a] == '-') {
    int sum = 0;
    rep(i,s.size()) {
      if (s[i] == '-') sum++;
    }
    if (sum == 1) {
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;
  return 0;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int x = sc.nextInt();
        int fiveHundred = x/500;
        int five = (x%500)/5;
        System.out.println(fiveHundred * 1000 + five*5);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
void ShortestPath(int src,map<int,list<int>>adjlist,vector<int>&ans){
        queue<int>q;
        map<int,int>Distance;
        map<int,int>Parent;
        Distance[src]=0;
        Parent[src]=src;
        q.push(src);
        while(!q.empty()){
            int temp=q.front();
            q.pop();
            if(adjlist.count(temp)){
                for(auto it:adjlist[temp]){
                    if(Distance.count(it)==0){
                        q.push(it);
                        Distance[it]=Distance[temp]+1;
                        Parent[it]=temp;
                    }
                }
            }
        }
        for(auto i:adjlist){
            if(i.first==1)continue;
            if(Distance.count(i.first))ans.push_back(Parent[i.first]);
            else{
                cout<<"No";
                return;
            }
        }
        cout<<"Yes"<<endl;
        for(auto i:ans)cout<<i<<endl;
        return;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>v;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end());
    map<int,list<int>>M;
    for(int i=0;i<m;i++){
        M[v[i].first].push_back(v[i].second);
        M[v[i].second].push_back(v[i].first);
    }
    for(int i=1;i<=n;i++){
        if(M.count(i)==0){
            list<int>l;
            M[i]=l;
        }
    }
    vector<int>ans;
    ShortestPath(1,M,ans);
    return 0;
}


Measured memory_bytes: 57684
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val rooms = Array.fill(n){Nil: List[(Int, Long)]}
  for (_ ← 0 until m){
    val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
    rooms(a) ::= (b, c)
    rooms(b) ::= (a, c)
  }
  val fromStart = Array.fill(n){Long.MaxValue}
  val queue = mutable.PriorityQueue()(Ordering.by[(Int, Long), Long](_._2).reverse)
  fromStart(0) = 0
  queue.enqueue((0, 0L))
  while(queue.nonEmpty) {
    val (current, cost) = queue.dequeue()
    if (fromStart(current) == cost) {
      for ((to, len) ← rooms(current)) {
        if (fromStart(to) > len + cost) {
          fromStart(to) = len + cost
          queue.enqueue((to, len + cost))
        }
      }
    }
  }
  val fromGoal = Array.fill(n){Long.MaxValue}
  fromGoal(n - 1) = 0
  queue.enqueue((n - 1, 0))
  while(queue.nonEmpty) {
    val (current, cost ) = queue.dequeue()
    if (fromGoal(current) == cost) {
      for ((to, len) ← rooms(current)) {
        if (fromGoal(to) > len + cost) {
          fromGoal(to) = len + cost
          queue.enqueue((to, len + cost))
        }
      }
    }
  }
  val seg = Seg(fromStart.zip(fromGoal))
  for (_ ← 0 until readInt()) {
    val Array(s, g) = readLine.trim.split(' ').map(_.toLong)
    println(seg(s, g))
  }
}

object Seg {
  def apply(array: Array[(Long, Long)]): Seg = {
    val a = array.sortBy(_._1)
    val b = a.map{p ⇒ Array(p._2)}
    for (i ← b.indices) {
      val up = i + (~i & (i + 1))
      if (b.indices.contains(up)) {
        b(up) ++= b(i)
      }
      b(i) = b(i).sorted
    }
    new Seg(b, a.map{_._1})
  }
}
class Seg private (private val array: Array[Array[Long]], private val values: Array[Long]) {
  def apply(near: Long, far: Long): Int = {
    count(upperBound(values, near) - 1, far)
  }
  private[this] def upperBound(a: Array[Long], value: Long): Int = {
    var left = 0
    var right = a.length
    while (left < right) {
      val mid = (left + right) / 2
      if (a(mid) <= value) left = mid + 1
      else right = mid
    }
    right
  }
  private[this] def lowerBound(a: Array[Long], value: Long): Int = {
    var left = 0
    var right = a.length
    while(left < right){
      val mid = (left + right) / 2
      if (a(mid) < value) left = mid + 1
      else right = mid
    }
    right
  }
  def count(position: Int, value: Long): Int = {
    if (position >= 0){
      array(position).length - lowerBound(array(position), value) + count(position - (~position & (position + 1)), value)
    }else 0
  }
}


Measured memory_bytes: 491300
use std::io::*;

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

fn main() {
    reversi();
}

fn reversi() {
    let s: String = read();
    let sv = s.chars().collect::<Vec<char>>();
    let mut m = 0;
    let l = Vec::len(&sv);
    for i in 1..l {
        if sv[i] != sv[i - 1] {
            m += 1;
        }
    }
    println!("{}", m);
}

Measured memory_bytes: 4352
N=int(input())
XL=[tuple(map(int,input().split())) for _ in range(N)]

XL.sort(key=lambda x:x[0]+x[1])
#XL.sort()

ans1=0
r=-10**9-1
for X,L in XL:
    if X-L>=r:
        ans1+=1
        r=X+L
ans2=0
l=-10**9+1
for X,L in reversed(XL):
    if X+L<=l:
        ans2+=1
        l=X-L

print(max(ans1,ans2))

Measured memory_bytes: 21388
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,k;
    cin>>n>>k;
    int result=0,tmp;
    REP(i,n){
        cin>>tmp;
        result+=2*min(tmp,k-tmp);
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] =  new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        int cnt = 0;
        boolean check = false;

        while(true){

            //check whether there exists an odd number
            for(int j = 0; j < n; j++){
                if(a[j] % 2 == 1){
                    check = true;
                }
            }
           
            //if check = true, loop must end
            if(check) break;

            //divide each number by 2 and count that activity
            for(int i = 0; i < n; i++){
                a[i] /= 2;
            }

            //add +1 to the record of the number of division
            cnt++;
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, e) for (int i = (s); i < (int)(e); i++)
using namespace std;

int main() {
  int N;
  vector<int> A;
  cin >> N;
  rep (i, N) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  vector<int> cs;
  int s = 0;
  for (auto &a: A) {
    s += a;
    cs.push_back(s);
  }

  long long ans = pow(10, 18);
  rep (k, 2) {
    int sum = 0;
    long long cnt = 0;
    rep (i, N) {
      sum += A[i];
      if (i % 2 == k) {
        int diff = max(0, sum + 1);
        cnt += diff;
        sum -= diff;
      } else {
        int diff = max(0, -sum + 1);
        cnt += diff;
        sum += diff;
      }
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())

max_num = 0
max_index = 0
second_num = 0
for i in range(N):
    num = int(input())
    if num >= max_num:
        if second_num < 1:
            max_num = num
            second_num = 1
        else:
            second_num, max_num = max_num, num
        max_index = i
    elif num > second_num:
        second_num = num
for i in range(N):
    if max_index == i:
        print(second_num)
    else:
        print(max_num)


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

int main(){
    int num1, num2;
    cin >> num1 >> num2;
    while(num1 != 0 || num2 != 0){
        for(int i = 0; i < num1; ++i){
            for(int j = 0; j < num2; ++j){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> num1 >> num2;
    }
}

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

int main()
{
    string w, t;
    cin >> w;
    for (int i = 0; i < w.length(); i++)
        if (w[i] >= 'A' && w[i] <= 'Z') w[i] += ' ';

    int cnt = 0;
    while (1) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        for (int i = 0; i < t.length(); i++)
            if (t[i] >= 'A' && t[i] <= 'Z') t[i] += ' ';
        if (t == w) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {

    int a, b;
    cin >> a >> b;

    if (b < a)
        swap(a, b);

    rep(i, b) cout << a;

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<complex>
using namespace std;
typedef complex<double> Po;

double cross(Po a,Po b){return a.real()*b.imag() - a.imag()*b.real();}

double area(Po a,Po b, Po c){return abs(cross(b-a,c-a))/2;}

bool inter(Po a, Po b,Po c,Po x){
return (fabs(area(a,b,x)+area(b,c,x)+area(c,a,x)-area(a,b,c))<1e-10);
}

int main(){
Po p[4];
while(cin>>p[0].real() >> p[0].imag()){
for(int i=1;i<4;i++)cin >> p[i].real() >> p[i].imag();
if(inter(p[0],p[1],p[2],p[3]))cout << "YES\n";
else cout << "NO\n";
}
}

Measured memory_bytes: 0
istr = raw_input()
lis = [int(istr[0]),int(istr[1]),int(istr[2]),int(istr[3])]
if   lis[0] + lis[1] + lis[2] + lis[3] == 7:
    print (istr[0]+"+"+istr[1]+"+"+istr[2]+"+"+istr[3]+"=7")
elif lis[0] + lis[1] + lis[2] - lis[3] == 7:
    print (istr[0]+"+"+istr[1]+"+"+istr[2]+"-"+istr[3]+"=7")
elif lis[0] + lis[1] - lis[2] + lis[3] == 7:
    print (istr[0]+"+"+istr[1]+"-"+istr[2]+"+"+istr[3]+"=7")
elif lis[0] + lis[1] - lis[2] - lis[3] == 7:
    print (istr[0]+"+"+istr[1]+"-"+istr[2]+"-"+istr[3]+"=7")
elif lis[0] - lis[1] + lis[2] + lis[3] == 7:
    print (istr[0]+"-"+istr[1]+"+"+istr[2]+"+"+istr[3]+"=7")
elif lis[0] - lis[1] + lis[2] - lis[3] == 7:
    print (istr[0]+"-"+istr[1]+"+"+istr[2]+"-"+istr[3]+"=7")
elif lis[0] - lis[1] - lis[2] + lis[3] == 7:
    print (istr[0]+"-"+istr[1]+"-"+istr[2]+"+"+istr[3]+"=7")
elif lis[0] - lis[1] - lis[2] - lis[3] == 7:
    print (istr[0]+"-"+istr[1]+"-"+istr[2]+"-"+istr[3]+"=7")

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

int GetDigit(int n){    return log10(n) + 1;    }

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

    int digit = GetDigit(n);

    int ans = 0;
    for(int i=1; i<=digit; i++){
        if(i%2 == 0)
            continue;

        if(i == digit)      ans += n - pow(10, i-1) + 1;
        else if(i == 1)     ans += 9;
        else                ans += pow(10, i) - pow(10, i-1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;

	int n;string s;	
	cin >> n >> s;
	if(n < 3200) cout << "red" << endl;
	else cout << s << endl;
}



Measured memory_bytes: 256
def result(m, n):
    average = (m+n)/2
    if int(average)==average:
        return int(average)
                
m, n = input().split(" ")
m = (int(m))
n = (int(n))
res = result(m, n) 
if res == None:
    print("IMPOSSIBLE")
else:
    print(res)

Measured memory_bytes: 3060
function Main(input) {
  input = input.split("\n");
  var s = input[0].split("");
  var t = input[1].split("");
  var dp =new Array(s.length+1);
  for(var i=0;i<s.length+1;i++){
    var tmp=new Array(t.length+1).fill(0);
    dp[i]=tmp;
  }
  for(var i=0;i<s.length;i++){
    for(var j=0;j<t.length;j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=Math.max(dp[i][j]+1,dp[i+1][j+1]);
      }
      dp[i+1][j+1]=Math.max(dp[i+1][j],dp[i+1][j+1]);
      dp[i+1][j+1]=Math.max(dp[i][j+1],dp[i+1][j+1]); 
    }
  }
  var i=s.length;
  var j=t.length;
  var ans="";
  while(i>0&&j>0){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }else if(dp[i][j]==dp[i][j-1]){
      j--;
    }else{
      ans=s[i-1]+ans;
      i--;
      j--;
    }
  }


  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 101936
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

class UnionFind{
    private:
        unsigned int n_node;
        std::vector<uint32_t> parent, rank;

    public:
        UnionFind(unsigned int n){
            n_node = n;
            parent.resize(n);
            for(int i = 0; i < n; ++i) parent[i] = i;
            rank.resize(n, 0);
        }

        unsigned int find(unsigned int n){
            if(parent[n] == n) return n;
            else return parent[n] = find(parent[n]);
        }

        void unite(unsigned int m, unsigned int n){
            m = find(m);
            n = find(n);
            if(m == n) return;
            if(rank[m] < rank[n]) parent[m] = n;
            else{
                parent[n] = m;
                if(rank[m] == rank[n]) ++rank[m];
            }
            return;
        }

        unsigned int getRoot(unsigned int n){return find(n);}
};

int vmax(const std::vector<int>& v){
    int ret = 0xffffffff;
    for(int i = 0; i < v.size(); ++i) ret = std::fmax(ret, v[i]);
    return ret;
}

int main(void){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        int tmp, tmp2;
        cin >> tmp >> tmp2;
        uf.unite(tmp - 1, tmp2 - 1);
    }
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i){
        ++v[uf.getRoot(i)];
    }
    cout << vmax(v) << endl;
    return 0;
}

Measured memory_bytes: 5656
#include <iostream>
using namespace std;
int main(void){
    long long A,B,C,a,b,c,count=0;
    cin>>A>>B>>C;
    if(A==B&&B==C&&A%2==0){
        cout<<-1<<endl;
        return 0;
    }
    while(A%2==0&&B%2==0&&C%2==0){
        a=(B+C)/2;
        b=(C+A)/2;
        c=(A+B)/2;
        A=a;B=b;C=c;
        count++;
    }
    cout<<count<<endl;
}


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

using namespace std;

//#define DEBUG

struct point {
  int main;
  int sub;
  point() = default;
  point(int m, int s): main(m), sub(s) {}
};

struct arm {
  int x, y;
  arm() = default;
  bool operator<(const arm& lhs) const {
    return this->x < lhs.x;
  }
};

#ifdef DEBUG
#define dump(i) cout << "[*] " #i ": " << i << endl;
template <class T>
void print(const vector<T>& vec) {
  for (const T& v : vec) {
    dump(v);
  }
}
template <>
void print(const vector<arm>& arms) {
  for (const arm& a : arms) {
    dump(a.x);
    dump(a.y);
  }
}
template <>
void print(const vector<point>& points) {
  for (const point& p : points) {
    dump(p.main);
    dump(p.sub);
  }
}
template <>
void print(const vector<set<int>>& sets) {
  for (const set<int>& se: sets) {
    cout << "[*] { ";
    for (const int& s : se) {
      cout << s << " ";
    }
    cout << "}" << endl;
  }
}
#define line() cout << " ---- " << endl;
#else
#define dump(i)
#define print(i)
#define line()
#endif

int main() {
  int n, m;
  cin >> n >> m;
  vector<arm> arms(m);
  for (int i = 0; i < m; ++i) {
    cin >> arms[i].x >> arms[i].y;
  }
  vector<pair<int, int>> r(n+1);
  for (int i = 0; i < n+1; ++i) {
    r[i].first = r[i].second = i;
  }

  sort(arms.begin(), arms.end());

  for (const arm& a : arms) {
    r[a.y].second = max(r[a.y].second, r[a.y+1].second);
    r[a.y+1].first = min(r[a.y+1].first, r[a.y].first);
  }

  for (int i = 1; i <= n; ++i) {
    cout << r[i].second -  r[i].first + 1;
    if (i != n) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,i;
  string s;
  cin >> s;
  n=s.size();
  for (i=0;i<n-1;i++){
    if (s[i]==s[i+1]) break;
    if (i<n-2 && s[i]==s[i+2]) break;
  }
  if (i==n-1) cout << "-1 -1" << endl;
  else{
    cout << i+1 << ' ';
    if (i==n-2) cout << i+2 << endl;
    else cout << i+3 << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int64_t DP[110][110][310]; // i番目までにj個選び、+αがkのときの価値の最大値

void init()
{
  for (int i = 0; i < 110; i++)
    for (int j = 0; j < 110; j++)
      for (int k = 0; k < 310; k++)
        DP[i][j][k] = -1;
  DP[0][0][0] = 0;
}

int main()
{
  int64_t N, W;
  cin >> N >> W;
  vector<int64_t> w(N), v(N);
  for (int i = 0; i < N; i++)
  {
    cin >> w.at(i) >> v.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= i; j++)
    {
      for (int k = 0; k <= 300; k++)
      {
        if (DP[i][j][k] == -1)
          continue;
        DP[i + 1][j][k] = max(DP[i + 1][j][k], DP[i][j][k]);
        DP[i + 1][j + 1][k + (w[i] - w[0])] = max(DP[i + 1][j + 1][k + (w[i] - w[0])], DP[i][j][k] + v[i]);
      }
    }
  }
  int64_t ans = 0;
  for (int j = 0; j <= N; j++)
  {
    for (int k = 0; k <= 300; k++)
    {
      if (w[0] * j + k <= W)
        ans = max(ans, DP[N][j][k]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 27008
int gcd(int a, int b)
{
 if (a == 0)
  return b;
 if (b == 0)
  return a;

 if (a == b)
  return a;

 if (a > b)
  return gcd(a - b, b);
 return gcd(a, b - a);
}

int main() {
 int a, b;

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

 printf("%d\n", gcd(a, b));
 return 0;}


Measured memory_bytes: 2096
#include "bits/stdc++.h"
#define ll int
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    ll x, y, cnt;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

ll a[1000007];
ll b[1000007];
ll mark[1000007];

void solve()
{
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
    }
    //sort(a + 1, a + n + 1);
    for (ll i = 1; i <= n; i++)
    {
        ll temp = a[i];
        if (mark[temp] == 0)
        {
            mark[temp]=-1;
            for (ll j = temp * 2; j <= 1000000; j += temp)
            {
                mark[j] = 1;
            }
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        if (mark[a[i]] == -1 && b[a[i]] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    solve();
    return 0;
}


Measured memory_bytes: 12144
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		long[] a = new long[n];
		
		for (int i = 0; i < n; i++) {
			long l = sc.nextLong();
			
			if (l == 0) {
				System.out.println(0);
				return;
			} else {
				a[i] = l;
			}
		}
		
		long prod = 1;
		
		for (int i = 0; i < n; i++) {
			if (a[i] <= (long)Math.pow(10, 18) / prod) {
				prod *= a[i];
			} else {
				System.out.println(-1);
				return;
			}
		}
		
		System.out.println(prod);
		
		sc.close();
	}
}




Measured memory_bytes: 51104
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

s = input()
t = input()

# 各文字について
p = {c: [] for c in s}
for i in range(len(s)):
    p[s[i]].append(i)

z = 0
l = -1
for c in t:
    if c not in p:
        print(-1)
        break
    # 文字cのうちもっとも近い未来にあるもの
    x = bisect_right(p[c], l)
    # 一周するなら
    if x == len(p[c]):
        x = 0
        z += 1
    l = p[c][x]
else:
    print(z * len(s) + l + 1)

Measured memory_bytes: 88188
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	int arr[n];
	for (int i = 0; i < n ; i++){
		cin>>arr[i];
	}
	int p = 0 ;
	for (int i = 0; i < n; i++){
		if(arr[i] != i+1){
			p++;
		}
	}

	if(p <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	init();
	long long h, ans = 0, monst_num = 1;
	cin >> h;
	while(h > 0){
		ans += monst_num;
		monst_num *= 2;
		h /= 2;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);} 


int32_t main()
{
	string s;
	cin  >> s;
	bool ok = true;
	for(int i= 0 ;i<sz(s);i++)
	{
		if(s[i] == s[i+1])
		{
			ok = false;
		}
	}
	if(ok)
	{
		cout << "Good\n";
	}else{
		cout << "Bad\n";
	}
}

Measured memory_bytes: 3600
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm;

void main(){
  auto s = readln.strip;

  long a = 0;
  long b = 0;
  foreach (i, c; s) {
    if ((i % 2 == 0) == (c == '1')) {
      a++;
    } else {
      b++;
    }
  }

  writeln(min(a, b));
}


Measured memory_bytes: 508
N = int(input())
a = [[0] * N for i in range(26)]


for i in range(N):
	s = (input())
	for j in range(len(s)):
		ch = ord(s[j])
		#print(ch - ord("a"),i,j)
		a[ch - ord("a")][i] += 1

for i in range(26):
	M = min(a[i])
	for j in range(M):
		print(chr(i + ord("a")),end="")

print()

Measured memory_bytes: 3060
using System;

public class Program{
    public static void Main(){
        int num=int.Parse(Console.ReadLine());
        int tmp1=num%10;
        num=num/100;
        int tmp2=num;
        if(tmp1==tmp2){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


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

int main()
{
	int H, N, sum=0;
	cin>>H>>N;
	for(int i=0; i<N; i++)
	{
		int temp;
		cin>>temp;
		sum+=temp;
	}
	
	if(sum>=H) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin>>h>>w;
  for(int i = 0; i < w + 2; i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i = 0; i < h; i++){
    cout<<"#";
    vector<char> vec(w);
    for(int i = 0; i < w; i++){
      cin>>vec.at(i);
      cout<<vec.at(i);
    }
    cout<<"#"<<endl;
  }
  for(int i = 0; i < w + 2; i++){
    cout<<"#";
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define u 101
#define WHITE 0
#define BLACK 1
#define GRAY 2

int d[u],f[u],G[u][u],Adj[u][u],edg_number[u],color[u];
int length,time;

void DFS_Visit(int r){
  int i,v;

  color[r]=GRAY;
  d[r]=++time;

  for(i=1;i<=edg_number[r];i++){
    v=Adj[r][i];
    if(color[v]==WHITE){
      DFS_Visit(v);
    }
  }

    color[r]=BLACK;
    f[r]=++time;
}
  
void DFS(){
  int i;

  for(i=1;i<=length;i++){
    color[i] = WHITE;
    time = 0;
  }

  for(i=1;i<=length;i++){
    if(color[i] == WHITE){
      DFS_Visit(i);
    }

    printf("%d %d %d\n",i,d[i],f[i]);
  }
}

int main(){
  int i,j,iranai,u_number;

  scanf("%d",&length);

  for(i=1;i<=length;i++){
    scanf("%d",&iranai);
    scanf("%d",&edg_number[i]);
    for(j=1;j<=edg_number[i];j++){
      scanf("%d",&u_number);
      Adj[i][j]=u_number;
      G[i][u_number]=1;
    }
  }

  DFS();

  return 0;
}

Measured memory_bytes: 676
array = []
gets.to_i.times do
    command = gets.chomp.split(" ")
    if command[0] == "insert"
        array.unshift(command[1])
    elsif command[0] == "delete" && array.find_index(command[1])
        array.delete_at(array.find_index(command[1]))
    elsif command[0] == "deleteFirst"
        array.shift
    elsif command[0] == "deleteLast"
        array.pop
    end
end
puts array.join(" ")


Measured memory_bytes: 76160
require 'scanf'

simple = lambda do |m, i, rate, fee|
  return m - fee, i + (m*rate).truncate
end

compound = lambda do |m, i, rate, fee|
  return m + (m*rate).truncate - fee, 0
end

all = gets.to_i
all.times do
  m = gets.to_i
  y = gets.to_i
  n = gets.to_i

  results = Array.new
  n.times do
    money, interest = m, 0
    type, rate, fee = gets.scanf("%d %f %d")

    func = type == 0 ? simple : compound
    y.times { money, interest = func.call( money, interest, rate, fee ) }

    results << ( money + interest )
  end
  puts results.max
end

Measured memory_bytes: 2924
N,K=map(int,input().split())
mod=10**9+7
X=[0]+[pow(K//d,N,mod) for d in range(1,K+1)]
'''
Y=[[] for i in range(K+1)]
for i in range(1,K+1):
    for j in range(i,K+1,i):
        Y[j].append(i)
'''
#print(X)
isPrime=[1 for i in range(K+1)]
isPrime[0]=0;isPrime[1]=0
for i in range(K+1):
    if isPrime[i]==0:
        continue
    for j in range(2*i,K+1,i):
        isPrime[j]=0
Mebius=[1 for i in range(K+1)]
Mebius[0]=0
for i in range(2,K+1):
    if isPrime[i]==0:
        continue
    for j in range(i,K+1,i):
        Mebius[j]*=-1
for i in range(2,K+1):
    for j in range(i*i,K+1,i*i):
        Mebius[j]=0
Z=[0 for i in range(K+1)]
for i in range(1,K+1):
    for j in range(i,K+1,i):
        Z[i]+=X[j]*Mebius[j//i]
ans=0
for i in range(1,K+1):
    ans+=Z[i]*i
    ans%=mod
print(ans)
'''
P(G%d==0)
Gがd,2d,3d,...の可能性がある
P(d)-P(2d)-P(3d)-P(5d)+P(6d)-P(7d)
'''

Measured memory_bytes: 92560
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

import itertools

N, M, X = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))

ans = float('inf')

for case in range(2**N):
    # for case in list(itertools.product('01', repeat=N)):
    val = [0] * M
    price = 0
    # print(case)
    for j in range(N):
        # if case[j]=='1':
        if case >> j & 1:
            price += data[j][0]
            for m in range(M):
                val[m] += data[j][m+1]

    flg = True
    for m in range(M):
        if val[m] < X:
            flg = False
    if flg:
        ans = min(ans, price)

if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68676
#include<bits/stdc++.h>
using namespace std;
#define mid (l+r)/2
#define ll long long
#define For(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(ll x){write(x);puts("");}
void writep(ll x){write(x);putchar(' ');}

int n;
string a[200003];

int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	  cin>>a[i];
	sort(a+1,a+n+1);
	int sum=1,maxn=1;
	for (int i=2;i<=n;i++){
		if (a[i]==a[i-1]) sum++;
		else sum=1;
		maxn=max(sum,maxn);
	}
	sum=1;
	if (maxn==1) cout<<a[1]<<endl;
	for (int i=2;i<=n;i++){
		if (a[i]==a[i-1]) sum++;
		else sum=1;
		if (sum==maxn) cout<<a[i]<<endl;
	}
    return 0;
}

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

using namespace std;



int main(){

    int N, K;
    cin >> N >> K;
    
    long int mod = 1000000007;
    
    long int dp[N+1][K+1];
    for (int i = 0; i <= K; i++) {
        dp[0][i] = 0;
    }
    dp[0][0] = 1;
    
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= K; j++) {
            
            if (j == 0) {
                dp[i][0] = 1;
            }else{
                dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
                dp[i][j] %= mod;
                
            }
            
            
        }
    }
    
    
    
    for (int i = 1; i <= K; i++) {
        cout << (dp[N-K+1][i]*dp[K-1][i-1])%mod << endl;
    }
    
    
    
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr int INF = 1e9;
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> grid(H);
	for (int i = 0; i < H; ++i) { cin >> grid[i]; }

	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	auto in = [&](int x, int y) -> bool {
		return x >= 0 && x < W && y >= 0 && y < H;
	};
	int Sx = 0, Sy = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (grid[i][j] == 'S') {
				Sx = j, Sy = i;
			}
		}
	}

	// distS[i][j] := S からコスト0で行けるマスへの最短距離
	vector<vector<int>> distS(H, vector<int>(W, INF));
	distS[Sy][Sx] = 0;
	{
		deque<pair<int, int>> que;
		que.emplace_back( Sy, Sx );
		while (!que.empty()) {
			auto p = que.front(); que.pop_front();
			int x = p.second, y = p.first;
			for (int k = 0; k < 4; ++k) {
				int nx = x + dx[k];
				int ny = y + dy[k];
				if (!in(nx, ny) || grid[ny][nx] == '#' || distS[ny][nx] <= distS[y][x] + 1) {
					continue;
				}
				distS[ny][nx] = distS[y][x] + 1;
				que.emplace_back( ny, nx );
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (distS[i][j] > K) { continue; }
			int cost = min({ i, j, H - 1 - i, W - 1 - j });
			ans = min(ans, (cost + K - 1) / K + 1);
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(void){
  double x,y;
  double a,b,c,d,e,f;
  
  while(cin >> a >> b >> c >> d >> e >> f){

    x=(c*e-b*f)/(a*e-b*d);

    y=(c*d-a*f)/(b*d-a*e);

    if(x==-0)x=0;
    if(y==-0)y=0;

    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1236
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

typedef struct{
  char c[20];
  int time;
}process;

process *make_process(){
  process *p;
  p=malloc(sizeof(process));
  p->time=0;
  return p;
}

typedef process data;
#define success 1
#define failure 0


typedef struct{
  int size;
  int head;
  int tail;
  data *data;
}queue;

queue *make_queue(int queue_size){
  queue *p;
  p=malloc(sizeof(queue));
  p->data=malloc((queue_size+1)*sizeof(data));
  p->size=queue_size;
  p->head=0;
  p->tail=0;
  return p;
}

int enque(queue *Q,data x){
  if((Q->tail+1)%(Q->size +1) ==Q->head) return failure;
  else{
    Q->data[Q->tail]=x;
    Q->tail=(Q->tail+1)%(Q->size +1);
    return success;
  }
}

int deque(queue *Q,data *x){
  if(Q->head==Q->tail) return failure;
  else{
    *x=Q->data[Q->head];
    Q->head=(Q->head+1)%(Q->size+1);
    return success;
  }
}




int main(){
  int i,n,q,time=0;
  process P;
  queue *Q;
  scanf("%d %d",&n,&q);
  Q=make_queue(n);
  for(i=0;i<n;i++){
    scanf(" %s%d",P.c,&(P.time));
    enque(Q,P);
  }
  process *x;
  x=malloc(sizeof(process));
  /**x=make_process();*/
  while(Q->head!=Q->tail){
    deque(Q,x);
    if(x->time <= q){
      time+=x->time;
      printf("%s %d\n",x->c,time);
    }
    else{
      x->time-=q;
      enque(Q,*x);
      time+=q;
    }
  }
  return 0;
} 

Measured memory_bytes: 1772
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, prv(-1), ans(0), cnt(0); cin >> N;
    REP(i, N){
        int a; cin >> a;
        if(prv != a){
            ans += cnt / 2;
            cnt = 1;
            prv = a;
        }else ++cnt;
    }
    ans += cnt / 2;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, pmin = 1000000000, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    if (p < pmin) {
      ans++;
      pmin = p;
    }
  }
  cout << ans << endl;
}


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

const ll mod = 1e9 + 7;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(), a.end());
    
    bool flag = true;
    if(n%2!=0){
        if(a[0] != 0) flag = false;
        
        for(int i = 1; i < n; i+=2){
            if(a[i] != a[i+1]) flag = false;
            if(a[i] != a[i-1]+2) flag = false;
        }
    } else if(n%2==0){
        if(a[0] == 1 and a[1] == 1);
        else flag = false;
        
        for(int i = 2; i < n - 1; i+=2){
            if(a[i] != a[i+1]) flag = false;
            if(a[i] != a[i-1]+2) flag = false;
        }
    }
    
    ll ans = 1;
    ll m = n/2;
    for(ll i = 0; i < m; i++){
        ans = ans * 2 % mod;
    }
    
    if(flag) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 1024
a = []
for i in range(3):
    i = list(map(int, input().split()))
    a.append(i)
n = int(input())
b = [int(input()) for i in range(n)]
for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = -100

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -100:
        print("Yes")
        exit(0)
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == -100:
        print("Yes")
        exit(0)

if a[0][0] == a[1][1] == a[2][2] == -100:
    print("Yes")
    exit(0)
if a[0][2] == a[1][1] == a[2][0] == -100:
    print("Yes")
    exit(0)

print("No")


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	std::sort(a, a + n);
	
	double res = a[0];
	for (int i = 1; i < n; i++) {
		res = (res + a[i]) / 2;
	}
	printf("%.11f\n", res);
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  for (int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  
  sort(card.begin(), card.end());
  
  int alice = 0;
  int bob = 0;
  
  bool first = true;
  while (!card.empty()) {
    if (first) {
      alice += card.back();
      first = false;
    } else {
      bob += card.back();
      first = true;
    }
    card.pop_back();
  }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int N,M,Q;
vector<int> vec;
ll maxim=0;
vector<int> a(50+2,0),b(50+2,0),c(50+2,0),d(50+2,0);

void search(){
    ll sum=0;
    for (int i = 1; i <= Q; ++i) {
        if(vec[b[i]]-vec[a[i]]==c[i]) sum += d[i];
    }
    //maxim = max(maxim,sum);
	if(maxim < sum) maxim = sum; 

    // デバッグ用出力
    /*
    for (int i = 1; i <= N; ++i) {
        cout<<vec[i]<<" ";
    }
    cout<<endl;
	cout<<"maxim = "<<sum<<endl;
	cout<<endl;
    */
}

void dfs(){

    if(vec.size()>N){
        search();
        return;
    }
    // vecの末尾の数字より1大きいものからMまで
    for (int i = vec.back(); i <= M; ++i) {
        vec.push_back(i);
        dfs();
        vec.pop_back();
    }

}


int main(void){

    cin>>N>>M>>Q;

    for (int i = 1; i <= Q; ++i) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    // 0を入れておく
    vec.push_back(1);
    dfs();

    // 答え
    cout<<maxim<<endl;

}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 505;

char a[maxn][maxn];
int n;

bool col[maxn];

int main(){
	while(scanf("%d",&n) != EOF){
		bool flag = false;
		for(int i = 1;i <= n;i++){
			scanf("%s",a[i] + 1);
			for(int j = 1;j <= n;j++){
				if(a[i][j] == '#') flag = true;
			}
		}
		
		memset(col,false,sizeof(col));
		for(int j = 1;j <= n;j++){
			for(int i = 1;i <= n;i++){
				col[j] |= a[i][j] == '#';
			}
		}
		int m = 0;
		for(int j = 1;j <= n;j++){
			bool f = true;
			for(int i = 1;i <= n;i++){
				f &= a[i][j] == '#';
			}
			m += f;
		}
		if(!flag){
			puts("-1");
			continue;
		}
		int mx = 0;
		for(int i = 1;i <= n;i++){
			int num = 0;
			for(int j = 1;j <= n;j++){
				if(a[i][j] == '#') num++;
			}
			if(a[i][i] != '#' && !col[i]) num--;
			mx = max(num,mx);
		}
		cout << 2 * n - mx - m << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<=y;++i)

const int INF=1<<30;
using namespace std;
typedef long long ll;

ll s1,s2,s3;
ll max(){return max(s1,max(s2,s3));}
ll min(){return min(s1,min(s2,s3));}

int main()
{
	ll a,b;
	cin>>a>>b;

	if(a%3==0 || b%3==0) {
		puts("0");
		return 0;
	}
	ll ans=min(a,b);
	rep(i,1,b-1)
	{
		s1=a*i;
		if(a&1)
		{
			s2=(b-i)*(a/2);
			s3=(b-i)*(a/2+1);
		}
		else
		{
			s2=s3=(b-i)*(a/2);
		}
		ans=min(ans,max()-min());
//		printf("s1=%lld,s2=%lld,s3=%lld,ans=%lld\n",s1,s2,s3,ans);
	}

	rep(i,1,a-1)
	{
		s1=b*i;
		if(b&1)
		{
			s2=(a-i)*(b/2);
			s3=(a-i)*(b/2+1);
		}
		else
		{
			s2=s3=(a-i)*(b/2);
		}
		ans=min(ans,max()-min());
//		printf("s1=%lld,s2=%lld,s3=%lld,ans=%lld\n",s1,s2,s3,ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    char s[]="ABC";
    char s1[]="ARC";
    char x[4];
    scanf("%s",x);
    if(strcmp(x,s)==0)
    printf("%s",s1);
    else
    printf("%s",s);
}


Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
int h[100005],mem[100005];
int N,k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>N;
    k=2;
    int i,j;
    for(i=1;i<=N;i++) cin>>h[i];
    for(i=2;i<=N;i++){
        mem[i]=INT_MAX;
        for(j=i-1;j>=max(i-k,1);j--){
            mem[i]=min(mem[i],mem[j]+abs(h[i]-h[j]));
        }
    }
    //for(i=1;i<=N;i++) cout<<mem[i]<<endl;
    cout<<mem[N]<<endl;
    return 0;
}


Measured memory_bytes: 4428
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

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

int main(){
  long long N,M;
  cin >> N >> M;
  
  cout << N*M << endl;
 
}
 


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	ll ans = LONG_MAX;
	ll comp;
	for (int i = 0; i < n-k+1; i++) {
		comp = abs(x[i]) + abs(x[i] - x[i+k-1]);
		comp = min(comp, (ll)abs(x[i+k-1]) + abs(x[i]-x[i+k-1]));
		ans = min(ans, comp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		int M=s.nextInt();
		if(N == M) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}


	}
}


Measured memory_bytes: 21972