akhauriyash/Code-Regression huggingface dataset:
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

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

const WHITE: u32 = 0;
const GRAY: u32 = 1;
const BLACK: u32 = 2;
const INFINITY: u32 = 1000000;
const MAX: usize = 10000;

fn dijkstra(adj: &mut Vec<Vec<(usize, u32)>>, n: usize) {
    let mut pq: VecDeque<(i32, u32)> = VecDeque::new();
    let mut d: Vec<u32> = vec![INFINITY; MAX];
    let mut color: Vec<u32> = vec![WHITE; MAX];

    d[0] = 0;
    pq.push_back((0, 0));
    color[0] = GRAY;

    while pq.len() > 0 {
        let (first, u): (i32, u32) = pq.pop_front().unwrap();

        color[u as usize] = GRAY;

        if (d[u as usize] as i32) < first * -1 {
            continue;
        }

        for j in 0..adj[u as usize].len() {
            let (v, second) = adj[u as usize][j];
            if color[v] == BLACK {
                continue;
            }
            if d[v] > d[u as usize] + second {
                d[v] = d[u as usize] + second;
                pq.push_back(((d[v] as i32 * -1), v as u32));
                color[v as usize] = GRAY;
            }
        }
    }

    for index in 0..n {
        print!("{} ", index);
        println!("{}", d[index]);
    }
}

fn main() {
    let n: usize = read();
    let mut adj: Vec<Vec<(usize, u32)>> = vec![vec![]; MAX];
    for _ in 0..n {
        let u: usize = read();
        let k: usize = read();
        for _ in 0..k {
            let v: usize = read();
            let c: u32 = read();
            adj[u].push((v, c));
        }
    }

    dijkstra(&mut adj, n);
}



Measured memory_bytes: 15280
typedef struct{double x,y,k;}w;w p[101],b;m,v[100],n,j,r;z(w*c,w*d){r=c->k>d->k?-1:1;}double o(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(i){for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;*p=b;p[100].x=b.x;p[100].y=b.y+1;for(i=1;i<n;i++)p[i].k=o(0,i,100)/hypot(p[i].x-b.x,p[i].y-b.y);qsort(p+1,n-1,24,z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

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

int main()
{
    int  a,b;
    cin>>a>>b;
    double fa=a,fb=b;
    cout<<fixed;
    cout<<setprecision(5)<<(a/b)<<" "<<(a%b)<<" "<<(fa/fb);
    cout<<"\n";
        return 0;
}


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

int n;
set <string> s;
string word;

int main()
{
	ios::sync_with_stdio(0);
	
	cin >> n;
	while(n--)
	{
		cin >> word;
		s.insert(word);
	}
	
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 19132
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

pii operator-(pii a, pii b)
{
  return pii(a.Fi - b.Fi, a.Se - b.Se);
}

signed main()
{
  int m;

  while (cin >> m, m) {
    vector<pii> s(m);
    REP(i, m) cin >> s[i].Fi >> s[i].Se;
    int n = in();
    vector<pii> p(n);
    REP(i, n) cin >> p[i].Fi >> p[i].Se;
    
    map<pii, int> chie;
    REP(i, m) {
      REP(j, n) {
        chie[p[j] - s[i]]++;
      }
    }

    for (auto t : chie) {
      if (t.Se == m) {
        cout << t.Fi.Fi << " " << t.Fi.Se << '\n';
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 15640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);

  rep(i,n) cin >> a.at(i);

  int num = 0;
  int len = a.size();

  for(int i=len-1;i>=0;i-=2){
    b.at(num)=a.at(i);
    num++;
  }

  num=0;

  for(int i=len-2;i>=0;i-=2){
    b.at(len-num-1) = a.at(i);
    num++;
  }

  rep(i,n){
    cout << b.at(i) ;
    if(i!=n-1) cout << " ";
  }
}

Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int P, Q, R;
	
	std::cin >> P >> Q >> R;
	
	std::cout << (P + Q + R - std::max(P, std::max(Q, R))) << "\n";
}


Measured memory_bytes: 256
def bit_all(x):
    price = 0
    ret = [0] * M
    b = str(format(x, "012b"))
    for i in range(N):
        if b[- (i + 1)] == "1": 
            for j in range(M):
                ret[j] += A[i][j]
            price += C[i]
            
    return price, ret

N, M, X = list(map(int,input().split()))
C = []
A = []
for i in range(N):
    input_ = list(map(int,input().split()))
    C.append(input_[0])
    A.append(input_[1 : M + 1])
    
ans = 10 ** 9 + 7
for x in range(2 ** N):
    price, ret = bit_all(x)
    if min(ret) >= X:
        ans = min(price, ans)

if ans == 10 ** 9 + 7:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 69216
n,m,c=map(int,input().split())
b=list(map(int, input().split()))
res = 0
for i in range(n):
    a=list(map(int, input().split()))
    sum = 0
    for j in range(m):
        sum += a[j]*b[j]
    if sum+c > 0:
        res +=1
print(res)

Measured memory_bytes: 9004
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_N = 300 + 10;
double dp[MAX_N][MAX_N][MAX_N];

void init() {
	for (ll i = 0; i < MAX_N; i++) {
		for (ll j = 0; j < MAX_N; j++) {
			for (ll k = 0; k < MAX_N; k++) {
				dp[i][j][k] = 0;
			}
		}
	}
}

int main() {
	init();

	ll i, j, k;
	ll N;
	cin >> N;
	ll I = 0;
	ll J = 0;
	ll K = 0;
	for (i = 0; i < N; i++) {
		ll a;
		cin >> a;
		if (a == 1)K++;
		if (a == 2)J++;
		if (a == 3)I++;
	}

	dp[0][0][0] = 0LL;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= N; j++) {
			for (k = 0; k <= N; k++) {
				double s = 0;
				if (i > 0) {
					s += i * dp[i - 1][j + 1][k];
				}
				if (j > 0) {
					s += j * dp[i][j - 1][k + 1];
				}
				if (k > 0) {
					s += k * dp[i][j][k - 1];
				}
				s += N;
				if(i + j + k > 0)dp[i][j][k] = s / (double)(i + j + k);
			}
		}
	}
	cout << setprecision(20) << dp[I][J][K] << endl;

	return 0;
}


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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int a,n;

void solve(){
  cin >> n;
  double ans=2*M_PI*n;
  printf("%.10f\n",ans);
}

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


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <array>
#include <string>

using namespace std;

int main() {
	string text = " ";
	string pattern = " ";

	cin >> text >> pattern;
	if ((text+text).find(pattern) != string::npos) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int main() {
    string s, t;
    cin >> s >> t;
    cout << (s == t.substr(0, s.size()) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3632
s=input()

odd_0=0
even_0=0
odd_1=0
even_1=0

for i in range(len(s)):
	if i%2==1:
		if s[i]=='0':
			odd_0+=1
		else:
			odd_1+=1
	if i%2==0:
		if s[i]=='0':
			even_0+=1
		else:
			even_1+=1
print(min([even_1+odd_0,even_0+odd_1]))



Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int64_t N, Y;
  cin >> N >> Y;
  rep(i, N+1){
    rep(j, N+1-i){
      if(10000*i + 5000*j + 1000*(N-i-j) == Y){
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
	string s; cin>>s;
	int count[3]={};
	FOR(i,0,s.size()){
		count[s[i]-'a']++;
	}
	int flag=true;
	int giri=s.size()%3;
	if(!giri)giri+=3;
	int giri2=0;
	FOR(i,0,3){
		if(count[i]>(s.size()+2)/3) flag=false;
		if(count[i]==(s.size()+2)/3) giri2++;
	}
	if(giri2>giri) flag=false;
	YES(flag);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n;
	cin >> n;
	if(n < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int H, A;
    cin >> H >> A;
    cout << (H + (A - 1)) / A << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque
n, k = map(int, input().split())
s = input()

unhapiness = 0
div = deque([])
left = "R"
right = "L"
cntr = 0
s = s + "L"
for si in s:
    right = si
    if (left == "R") & (right == "L"):
        if 0 < cntr < n:
            unhapiness += 2
            div.append(cntr)
        else:
            unhapiness += 1
            div.appendleft(cntr)

    left = si
    cntr +=1

for i in range(k):
    p = div.pop()
    if 0 < p < n:
        unhapiness -= 2
    else:
        unhapiness -= 1
    if len(div) < 1:
        unhapiness += 1
        break
print(n-unhapiness)




Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double p;
int N;

struct edge {
  int to;
  double c;
  edge(){}
  edge(int to,double c):to(to),c(c){}
};

vector<edge> G[100005];

double AC = 0.0;
double solve( int id,int pr ){
  double ret = 0.0f;
  for( edge e : G[id] ) {
    if( e.to == pr ) continue;
    ret += ( e.c + solve( e.to, id ) ) * p;
  }
  ret += AC;
  return ret;
}

int main() {
  scanf("%lf",&p);
  scanf("%d",&N);
  for(int i=0;i<N-1;i++){
    int x,y, c;
    scanf("%d%d%d",&x,&y,&c); --x; --y;
    G[x].emplace_back( y, (double)c );
    G[y].emplace_back( x, (double)c );
  }
  AC = solve( 0, 0 );
  AC = solve( 0, 0 );
  printf("%.9lf\n",AC);
}

Measured memory_bytes: 16392
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll maxn=1e9+7;
int main(){
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    if(n%d) cout<<n/d+1<<endl;
    else cout<<n/d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <bitset>
using namespace std;

int main(void){
    long long int n;
    cin >> n;
    long long int a[n], b[n], c[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
        cin >> c[i];
    sort(a, a+n); sort(b, b+n); sort(c, c+n);
    long long int ab[n], bc[n];
    long long int count = 0, check = 0;
    for(long long int i = 0; i < n; i++){
        ab[i] = 0; bc[i] = 0;
    }
    for(long long int i = 0; i < n; i++){
        for(long long int j = count; j < n; j++){
            if(b[i] <= a[j])
            {
                ab[i] = j;
               // check = bc[i]; 
                count = j;
                break;
            }
            if(j == n-1){
                ab[i] = n;
                count = n-1;
            }
        }
    }
    count = 0;
    for(long long int i = 0; i < n; i++){
        for(long long int j = count; j < n; j++){
            if(b[i] < c[j])
            {
                bc[i] = n-j;
                count = j;
                break;
            }
            if(j == n-1){
                bc[i] = n-j-1;
                count = n-1;
            }
        }
    }
    for(long long int i = 0; i < n; i++){
        check += (ab[i] * bc[i]);
       // cout << ab[i] << " " << bc[i] << endl;
    }
    cout << check << endl;
    return 0;
}

Measured memory_bytes: 4096
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def putsd(str)
  puts str if $debugFlag
end

# input
lc = 0
cost = []
stat = []
while l = $stdin.gets do
  if lc == 0
    tmp = l.chomp.split(" ").map(&:to_i)
    cc = tmp[1]
    3.times do |i|
      stat[i] = [0]*cc
    end
  elsif lc <= cc
    tmp = l.chomp.split(" ").map(&:to_i)
    cost[lc-1] = []
    cc.times do |i|
      cost[lc-1][i] = tmp[i]
    end
  else
    tmp = l.chomp.split(" ").map(&:to_i)
    tmp.length.times do |i|
      pd tmp[i]
      print ":" if $debugFlag
      pd (i+lc-cc)%3
      stat[(i+lc-cc)%3][tmp[i]-1] += 1
    end
  end
  lc += 1
end

stat.length.times do |i|
  print "#{i}: " if $debugFlag
  pd stat[i]
end
pd cost

numArr = [*(0..cc-1)]
perm = numArr.permutation(3).to_a
print "perm:" if $debugFlag
pd perm

cand = []
perm.each do |p|
  tmp_cand = 0
  p.length.times do |i|
    pd "i=#{i}, p[i]=#{p[i]}"
    cc.times do |j|
      tmp_cand += stat[0][j] * cost[j][p[0]] if j != p[0]
      tmp_cand += stat[1][j] * cost[j][p[1]] if j != p[1]
      tmp_cand += stat[2][j] * cost[j][p[2]] if j != p[2]
    end
    cand << tmp_cand
  end
end

puts cand.min


Measured memory_bytes: 4732
# -*- coding: utf-8 -*-
# ALDS1_1_A:   Insertion Sort

def insertion_sort(a, n):
    for i in range(1, n):
        print(*a)
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
            a[j+1] = v
    print(*a)

n = int(input())
a = list(map(int, input().split()))

insertion_sort(a, n)


Measured memory_bytes: 5980
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
string s;
int main() {
  cin >> n >> s;
  i64 ans = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] != s[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define loopSolve int t; cin>>t; while(t--){solve();}
#define mp make_pair
#define pb push_back

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

int mod = 1e9+7;

int getBits(ll num){
	return (int)log2(num) + 1;
}

ll power(int a, int b){
    return (ll)(pow(a,b)+0.5)%mod;
}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void solve(){

    int n; cin>>n;

    int streak=0;
    bool ok = 0;

    for(int i=0;i<n;i++){
        int a, b; cin>>a>>b;

        if(a==b) streak++;
        else streak =0;

        if(streak>=3) ok=1;

    }

    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int x, y;
    cin >> x >> y;
    rep(i, 101) rep(j, 101) {
        if (2 * i + 4 * j == y && i + j == x) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3676
import math
#素数列挙
def get_primes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(limit):
            break
            
        P.append(prime)
            
        A = [i for i in A if i%prime!=0]

    P.extend(A)
          
    return P


def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    sosus = set(get_primes(max(A)+1))
    dvd = set()



    val = A[0]
    for i in A:
        val = math.gcd(i,val)

    if val ==1:
        pass
    else:
        print('not coprime')
        return

    for i in A:
        tmp=[]
        for j in sosus:
            if j>i:
                break
            if i % j ==0:
                tmp.append(j)
                while i % j ==0:
                    i //=j
            if i ==1:
                break
            if i in sosus:
                
                tmp.append(i)
                i = 1
                break
        sosus.difference_update(tmp)
        
        if i != 1:
            break
    else:
        print('pairwise coprime')
        return

    print('setwise coprime')

resolve()

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

using namespace std;

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

    int offset = 0;
    int balance = 0;
    for (int i = 0; i < N; ++i) {
        if (s[i] == '(') {
            balance++;
        } else {
            balance--;
        }
        offset = min(offset, balance);
    }

    if (balance < 0) {
        int rebalance = 0;
        offset = 0;
        for (int i = N - 1; i >= 0; --i) {
            if (s[i] == '(') {
                rebalance--;
            } else {
                rebalance++;
            }
            offset = min(offset, rebalance);
        }
    }
    
    string res = "";
    if (balance < 0) {
        if (offset < 0) {
            for (int i = 0; i < (-1 * balance) - (offset); ++i) {
                res += '(';
            }

            res += s;

            for (int i = 0; i < (-1 * offset); ++i) {
                res += ')';
            }
        } else {
            for (int i = 0; i < -1 * balance; ++i) {
                res += '(';
            }

            res += s;
        }
    } else if (balance > 0) {
        if (offset < 0) {
            for (int i = 0; i < (-1 * offset); ++i) {
                res += '(';
            }

            res += s;

            for (int i = 0; i < balance - (offset); ++i) {
                res += ')';
            }
        } else {
            res += s;
            for (int i = 0; i < balance; ++i) {
                res += ')';
            }
        }
    } else { // balance == 0
        if (offset < 0) {
            for (int i = 0; i < -1 * offset; ++i) {
                res += '(';
            }

            res += s;
            
            for (int i = 0; i < -1 * offset; ++i) {
                res += ')';
            }
        } else {
            res = s;
        }
    }
    
    // cout << "balance: " << balance << ", offset: " << offset << endl;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  long N;
  cin >> N;
  vector<long> neko;
  for(long i =0; i < N; i++){
    long a;
    cin >> a ;
    neko.push_back(a);
  }

  long sum = 0;

  for(auto it = neko.begin(); it != neko.end(); ++it){
    sum += *it;
  }

  long min = INT32_MAX;
  long now = 0;
  for(long i = 0; i < neko.size() -1; i++){
    now = now + neko[i];
    sum = sum - neko[i];
    long diff = abs(now - sum);
    //cout << diff << endl;
    if(diff < min ){
      min = diff;
    }
  }

  cout << min << endl;
  return 0;
}

Measured memory_bytes: 5368
x, n = map(int, input().split())
p = list(map(int, input().split()))

counter = 0
if n == 0:
    print(x)
else:
    while True:
        if x - counter not in p:
            print(x - counter)
            break
        elif x + counter not in p:
            print(x + counter)
            break
        counter += 1

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a>>m;
  cout<<min(n*a,m);
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

const int N = 50;
vector<int> G[N];
bool visited[N];

void dfs(int pos) {
  visited[pos] = true;
  rep(i, G[pos].size()) {
    int to = G[pos][i];
    if (visited[to]) continue;
    dfs(to);
  }
  return;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  
  int ans = 0;
  rep(ri, m) {
    rep(i, n) G[i].clear();
    rep(i, m) {
      if (i == ri) continue;
      G[a[i]].push_back(b[i]);
      G[b[i]].push_back(a[i]);
    }
    rep(i, n) visited[i] = false;
    dfs(a[ri]);
    if (!(visited[b[ri]])) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef long long Int;
#define MOD (1000000007)
inline void up(int &a, int b) { a = (a+b)%MOD; }

template<class W>
struct E {
    int u, v;
    W w;
    E() {}
    E(int u, int v, const W& w) : u(u), v(v), w(w) {}
};
template<class W>
bool less_u(const E<W>& l, const E<W>& r) {
    return l.u!=r.u ? l.u<r.u : l.v!=r.v ? l.v<r.v : l.w<r.w;
}

int N[2], M[2];
int of(int x, int y, int i, int j) {
    return (((x*600)+y)*16+i)*16+j;
}

int main() {
    int T;
    scanf("%d", &T);
    vector<E<string> > g[2];
    map<int, int> dp;
    while(T--) {
        vector<vector<int> > to[2];
        rep(k, 2) {
            scanf("%d%d", N+k, M+k);
            g[k].clear();
            rep(i, M[k]) {
                int a, b;
                char buf[8];
                scanf("%d%d%s", &a, &b, buf);
                g[k].push_back(E<string>(a, b, buf));
            }
            sort(g[k].begin(), g[k].end(), less_u<string>);
            to[k] = vector<vector<int> >(N[k]);
            rep(i, M[k]) {
                const int u = g[k][i].u;
                to[k][u].push_back(i);
            }
            to[k][N[k]-1].push_back(M[k]);
        }
        dp.clear();
        rep(i, to[0][0].size()) rep(j, to[1][0].size()) {
            const int ix = to[0][0][i], jx = to[1][0][j];
            dp[of(ix, jx, 0, 0)] = 1;
        }
        rep(x, M[0]) rep(y, M[1]) {
            const int v0 = g[0][x].v, v1 = g[1][y].v;
            const string &a = g[0][x].w, &b = g[1][y].w;
            rep(i, a.size()) rep(j, b.size()) if(a[i]==b[j]) {
                const int cur = of(x, y, i, j);
                if(dp.count(cur)==0) continue;
                const int val = dp[cur];
                if(i<(int)a.size()-1 && j<(int)b.size()-1) {
                    up(dp[of(x, y, i+1, j+1)], val);
                }
                else if(i<(int)a.size()-1) {
                    rep(p, to[1][v1].size()) {
                        const int ix = to[1][v1][p];
                        up(dp[of(x, ix, i+1, 0)], val);
                    }
                }
                else if(j<(int)b.size()-1) {
                    rep(p, to[0][v0].size()) {
                        const int ix = to[0][v0][p];
                        up(dp[of(ix, y, 0, j+1)], val);
                    }
                }
                else {
                    rep(p, to[0][v0].size()) rep(q, to[1][v1].size()) {
                        const int ix = to[0][v0][p];
                        const int jx = to[1][v1][q];
                        up(dp[of(ix, jx, 0, 0)], val);
                    }
                }
            }
        }
        printf("%d\n", dp[of(M[0], M[1], 0, 0)]);
    }
    return 0;
}

Measured memory_bytes: 2388
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			int n = sc.nextInt();

			int x = sc.nextInt();
			int y = sc.nextInt();
			int sum = 0;
			for(int i = 1; i < n; i++) {
				int toX = sc.nextInt();
				int toY = sc.nextInt();
				sum += shortestPath( x, y, toX, toY);
				x = toX;
				y = toY;
			}
			System.out.println(sum);
		}
	}
	public static int shortestPath(int x, int y, int toX, int toY) {
		int slant = 0;
		if((toX - x) * (toY - y) > 0) {
			slant = Math.min(Math.abs(toX-x), Math.abs(toY-y));
		}
		return Math.abs(toX-x)+Math.abs(toY-y)-slant;
	}
}


Measured memory_bytes: 32492
function Main(input){
    var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
    var count = 0;
    while(nums.every((n) => (n % 2) === 0)) {
        count++;
        nums = nums.map((n) => n / 2);
    }

    console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

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

int f(int x){
	int res = x;
	int cnt = 0;
	while(res>0){
		res /= 10;
		cnt++;
	}
	return cnt;
}

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		if(f(i)%2==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){

  int N,ans = 0;
  cin >> N;
  int data[N];
  for(int i=0;i<N;i++) cin >> data[i];
  
  while(1){
      
      for(int i=0;i<N;i++) {
          if(data[i] %2 == 1){
              cout << ans << endl;
              return 0;
          }
          data[i] /= 2;
      }
      ans++;
  }
  
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; ll x;
	cin>>n>>x;
	ll a[n];
	f(i,0,n) cin>>a[i];
	ll pre[n];
	f(i,0,n) pre[i] = (i?pre[i-1]:0)+a[i];
	ll ans = 1e18;
	f(k,1,n+1) {
		ll res = k*x;	
		int p = 1;
		for (int j = n-1; j >= 0; j -= k, p++) {
			int i = max(0,j-k+1);
			ll f = (pre[j]-(i?pre[i-1]:0));
			ll g = (p==1?5:2*p+1);
			if (res < 1e18 && (ll(1e18)-res)/f/g) {
				res += f*g;	
			} else goto end;
		}
		ans = min(ans,res);
end:{}
	}
	cout << ans+n*x << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
 #define ri node+node+1
 #define le node+node
 #define mid (l+r)/2
 using namespace std;
 const int inf=5e5+9;
 int a[inf],last[inf],n,q,idx,tree[inf<<2],ans[inf];

 struct str{
 int l,r,id;
 };

 str queries[inf];
 bool cmp(str x,str y){
    return x.r<y.r;
 }

 void update(int node,int l,int r,int idx,int val){
    if(l==r){
        tree[node]+=val;
        return ;
    }

    if(idx<=mid)
        update(le,l,mid,idx,val);
    else update(ri,mid+1,r,idx,val);
    tree[node]=tree[le]+tree[ri];
 }

 int query(int node,int l,int r,int x,int y){
    if(l>r || r<x || l>y)
        return 0;
    if(l>=x && r<=y)
        return tree[node];
    return query(le,l,mid,x,y)+query(ri,mid+1,r,x,y);
 }

 int main(){
    scanf("%d",&n);
        scanf("%d",&q);

    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int i=1;i<=q;i++)
        scanf("%d%d",&queries[i].l,&queries[i].r),queries[i].id=i;


    sort(queries+1,queries+1+q,cmp);
    idx=1;
    for(int i=1;i<=n;i++){
        if(last[a[i]])
            update(1,1,n,last[a[i]],-1);
        last[a[i]]=i;
        update(1,1,n,i,1);

        while(queries[idx].r==i && idx<=q){
            ans[queries[idx].id]=query(1,1,n,queries[idx].l,queries[idx].r);
            idx++;
        }
    }
    for(int i=1;i<=q;i++)
        printf("%d\n",ans[i]);
 }


Measured memory_bytes: 19556
def str_rotate(S,k): # str_rotate(str,int)
    if k >= 26:
        k = k%26
    if ord(S) + k > 123:
        S = chr(ord(S)+k-97)
    else:
        S = chr(ord(S)+k)
    return S

s = list(input())
k = int(input())
for i in range(len(s)):
    if k == 0:
        break
    if s[i] == "a":
        pass
    elif 123 - ord(s[i]) <= k:
        k -= 123 - ord(s[i])
        s[i] = "a"
    else:
        pass
s[-1] = str_rotate(s[-1],k)
print("".join(s))

Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
int f(unsigned long long N) {
    int ans = 0;
    while (N >= 3) {
        N = (N - 1) / 2;
        ans++;
    }
    return ans;
}
int main()
{
    int X; cin >> X;
    unsigned long long ok = 0, ng = -1;
    while (ng - ok > 1) {
        unsigned long long mid = ok + (ng - ok) / 2;
        (f(mid) <= X ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
line = [0 for i in range(n)]
count = 0
for i in range(k):
  d_i = int(input())
  A_list = list(map(int, input().split()))
  for j in A_list:
    line[j-1] += 1
for i in line:
  if i == 0:
    count += 1
print(count)
  

Measured memory_bytes: 9180
line=input()
alphabets=[0,]*26
flg=0
for i in range(len(line)):
    alphabets[ord(line[i])-97]+=1
for i in range(len(alphabets)):
    if alphabets[i]>1:
        flg=1
if flg==0:
    print("yes")
else:
    print("no")

Measured memory_bytes: 3060
import bisect
N = int(input())
L0 = list(map(int, input().split()))
L = sorted(L0)
tri = 0
for left in range(N-2):
    for mid in range(left+1, N-1):
        x = bisect.bisect_left(L, L[left]+L[mid])
        tri += x - mid - 1

print(tri)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 //freopen("input.txt", "r", stdin); 
 //freopen("output.txt", "w", stdout); 
 int a;
 cin>>a;
 cout<<(a + a*a + a*a*a)<<endl;

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<vector<int> > map(2, vector<int>(N));

    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> map[i][j];
        }
    }

    // 左からの和
    vector<int> topSum(N);
    topSum[0] = map[0][0];
    for (int i = 1; i < N; ++i) {
        topSum[i] = topSum[i - 1] + map[0][i];
    }

    // 右からの和
    vector<int> bottomSum(N);
    bottomSum[N - 1] = map[1][N - 1];
    for (int i = N - 2; i >= 0; --i) {
        bottomSum[i] = bottomSum[i + 1] + map[1][i];
    }

    // 最大値を検索する
    int max = 0;
    for (int i = 0; i < N; ++i) {
        int num = topSum[i] + bottomSum[i];
        if (num > max) {
            max = num;
        }
    }

    cout << max << endl;
}



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

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

    int ans = 0;

    while (x >= 500) {
        x -= 500;
        ans += 1000;
    }
    while (x >= 5) {
        x -= 5;
        ans += 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <cassert>

using namespace std;

const int MAXN = 100000 + 10;

int N;
map <int, int> Map;

void Work()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i ++)
	{
		int x;
		scanf("%d", &x);
		Map[x] ++;
	}
	vector <int> two, four;
	for (auto it: Map)
	{
		if (it.second >= 2)
			two.push_back(it.first);
		if (it.second >= 4)
			four.push_back(it.first);
	}
	long long ans = 0;
	if (two.size() >= 2)
	{
		sort(two.begin(), two.end());
		ans = max(ans, (long long) two[two.size() - 1] * (long long) two[two.size() - 2]);
	}
	if (four.size() >= 2)
	{
		sort(four.begin(), four.end());
		ans = max(ans, (long long) four[four.size() - 1] * (long long) four[four.size() - 1]);
	}
	printf("%lld\n", ans);
}

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


Measured memory_bytes: 4864
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(10);

  int INF = 1000000;

  REP(i,9){
    REP(j,9){
      printf("%dx%d=%d\n", i+1,j+1,(i+1)*(j+1));
    }
  }

  return 0;
}

Measured memory_bytes: 1096
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i in range(N):

    t = min(B[i], A[i])
    B[i] -= t
    A[i] -= t
    ans += t

    t = min(B[i], A[i + 1])
    B[i] -= t
    A[i + 1] -= t
    ans += t

print(ans)

Measured memory_bytes: 18624
import java.util.*;

public class Main {
    static HashSet<Integer> dic = new HashSet<>();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i=0;i<n;i++) p[i] = sc.nextInt();
        int sum = 0;
        for(int w:p) sum += w;
        Arrays.sort(p);
        sum -= p[n-1]/2;
        System.out.println(sum);
    }
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		String[] tmpArray = input.split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int a = Integer.parseInt(tmpArray[1]);
		int b = Integer.parseInt(tmpArray[2]);
		
		System.out.println(Math.min(n*a, b));
	}

}


Measured memory_bytes: 21204
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int target = sc.nextInt();
        long gcd = sc.nextInt();
        int max = (int)gcd;
        
        for (int i = 0; i < n - 1; i++) {
            long num = sc.nextInt();
            max = Math.max(max, (int)num);
            gcd = gcd(gcd, num);
        }
        
        if (target <= max && target % gcd == 0) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 48296
#include <stdio.h>

int main(){
  int i,n,m=0;
  unsigned long list[16000000],a;
  for(i=0;i<16000000;i++){
    list[i]=0;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a);
    if(((list[a>>6]>>(a&0x3F))&1)==1){
      m=1;
      break;
    }
    list[a>>6]|=(long)1<<(a&0x3F);
  }
  if(m==0){
  	printf("YES");
  }else{
  	printf("NO");
  }
  return 0;
}


Measured memory_bytes: 125184
#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,less<int> > q;
priority_queue<int,vector<int>,less<int> > q1;
int main()
{
	int n,m,i,x,tmp1,tmp2;
	long long ans=0,sum=0;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	 cin>>x,q.push(x);
	tmp1=q.top();q.pop();
	for(i=2;i<=m;i++)
	{tmp2=q.top();q.pop();
	 q1.push(abs(tmp1-tmp2));
	 sum+=abs(tmp1-tmp2);
	 tmp1=tmp2;
	} n--;
	while(n--&&!q1.empty())
	 ans+=q1.top(),q1.pop();
	cout<<sum-ans<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long *a = new long long[n];

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

    sort(a, a+n);

    int ans = 0, cnt = 1;
    for (int i = 0; i < n; i++) {
        if (i < n-1 && a[i] == a[i+1])
            cnt++;
        else {
            if (cnt%2 == 1)
                ans++;
            cnt = 1;
        }
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll n;
    cin>>n;
    vector<ll> a(n+1),b(n+1),c(n+1);
    for(ll i=1;i<=n;i++)
      cin>>a[i]>>b[i]>>c[i];
    ll dp[n+1][3];
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for(ll i=2;i<=n;i++)
    {
      dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
      dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
      dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
   
}

Measured memory_bytes: 4992
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a//b)

Measured memory_bytes: 7648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  char c[100000];
  scanf("%s", &c);
  string s=c;
  int pat1_cnt = 0;
  int pat2_cnt = 0;
  REP(i, s.size()){
    char pat1 = (i%2==0 ? '0' : '1');
    char pat2 = (i%2==0 ? '1' : '0');
    if(c[i] != pat1) pat1_cnt++;
    if(c[i] != pat2) pat2_cnt++;
  }
  
  cout << min(pat1_cnt, pat2_cnt) << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1010;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

char s[N][N];

int main()
{
	int n=gi(),m=gi(),A=gi(),B=gi(),x,y;
	if (n&1)
		for (y=1;y<m&&A;y+=2,A--)
			s[n][y]='<',s[n][y+1]='>';
	if (m&1)
		for (x=1;x<n&&B;x+=2,B--)
			s[x][m]='^',s[x+1][m]='v';
	for (x=1;x<n;x+=2)
		for (y=1;y<m;y+=2)
			if (A>=2)
				s[x][y]=s[x+1][y]='<',s[x][y+1]=s[x+1][y+1]='>',A-=2;
			else
				if (B>=2)
					s[x][y]=s[x][y+1]='^',s[x+1][y]=s[x+1][y+1]='v',B-=2;
				else if (A&&B&&n%2&&m%2&&x==n-2&&y==m-2) {
					A--,B--;
					s[x][y]=s[x+2][y+1]='<',s[x][y+1]=s[x+2][y+2]='>';
					s[x][y+2]=s[x+1][y]='^',s[x+1][y+2]=s[x+2][y]='v';
				} else if (A) s[x][y]='<',s[x][y+1]='>',A--;
				else if (B) s[x][y]='^',s[x+1][y]='v',B--;
	if (A||B)
		puts("NO");
	else {
		puts("YES");
		for (x=1;x<=n;x++,putchar(10))
			for (y=1;y<=m;y++)
				putchar(s[x][y]?s[x][y]:'.');
	}
	return 0;
}


Measured memory_bytes: 2176
from sys import stdin
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def is_convex(p):
    for i in range(len(p)):
        j, k = i - 1, i - 2
        if 0 > cross(p[j] - p[k], p[i] - p[k]):
            return False
    return True

n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print(1 if is_convex(p) else 0)

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

vector<string> mp(12);
bool visited[12][12];

int bfs(int x, int y)
{
    queue<P> que;
    que.push(P{x, y});

    while (!que.empty())
    {
        P p = que.front();
        que.pop();

        rep(i, 4)
        {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (nx < 0 || ny < 0 || 12 <= nx || 12 <= ny ) continue;
            if(visited[ny][nx] || mp[ny][nx] == '0') continue;

            visited[ny][nx] = true;

            que.push(P{nx, ny});
        }
    }

    return 1;
}

int main()
{
    while(cin >> mp[0])
    {
        rep(i, 11) cin >> mp[i + 1];
        rep(i, 12) rep(j, 12) visited[i][j] = false;

        int ans = 0;

        rep(y, 12) rep(x, 12)
        {
            if(visited[y][x] || mp[y][x] == '0') continue;

            ans += bfs(x, y);
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main() {
    int N, K;
    vector<int> v;
    
    cin >> N >> K;
    
    for ( int ii = 0; ii < N; ii++ ) {
        int x; cin >> x;
        v.push_back(x);
    }
    
    sort(v.begin(), v.end());
    
    int sum = 0;
    for ( int ii = 0; ii < K; ii++ ) {
        sum += v[ii];
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <cmath>

int main()
{
	int d, n;
	std::cin >> d >> n;
	std::cout << std::setprecision(16);

	int ans = pow( 100, d ) * n;
	if( n == 100 ) {
		ans += pow( 100, d );
	}
	std::cout << ans << std::endl;

	return 0;
}




Measured memory_bytes: 256