akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;

  ll ans = (n-1 + 0) * n / 2;


  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[][] map = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                map[i][j] = scan.nextInt();
            }
        }
        // a1+b1 a1+b2 a1+b3
        // a2+b1 a2+b2 a2+b3
        // a3+b1 a3+b2 a3+b3
        boolean found = true;
        int b1 = map[0][0];
        int b2 = map[0][1];
        int b3 = map[0][2];
        int a1 = 0;
        int a2 = map[1][0]-b1;
        int a3 = map[2][0]-b1;
        if (map[1][1] != a2 + b2 || map[1][2] != a2 + b3 || map[2][1] != a3 + b2 || map[2][2] != a3 + b3) {
            found = false;
        }
        System.out.println(found ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main(){
  int height[300], weight[300];
  int i = 0, j = 0, count = 0, l = 0;

  for(i=1;i<=300;i++){
    scanf("%d %d", &height[i], &weight[i]);
    if(height[i]==0&&weight[i]==0) break;
    count++;
  }

  for(l=1;l<=count;l++){
    for(i=1;i<=height[l];i++){
      for(j=1;j<=weight[l];j++){
        if(i==1||i==height[l]){
          printf("#");
        }else if(j==1||j==weight[l]){
          printf("#");
        }else{printf(".");}
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

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

int main() {
  long long S;
  cin >> S;
  if (S == 1000000000000000000) {
    cout << 0 << ' ' << 0 << ' ' << 1000000000 << ' ' << 0 << ' ' << 1000000000 << ' ' << 1000000000;
    return 0;
  }
  long long N = sqrt(S)+1;
  cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << N << ' ' << S/N+1 << ' ' << N-(S-S/N*N);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,sum,cnt;
	scanf("%d %d %d",&a,&b,&c);
	sum=0;
	cnt=0;
	while(1){
		cnt++;
		sum+=a;
		if(cnt%7==0)	sum+=b;
		if(sum>=c)	break;
	}
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2756
#include <iostream>
#include <string>
using namespace std;
int main(void){
    char s[32];
    
    scanf("%s",s);
    
    for(int i = 0 ; i < 4 ; i++ )
        printf("%c",s[i]);
    printf(" ");
    for(int i = 4 ; i < 12 ; i++ )
        printf("%c",s[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n;cin >> n;
  map<int, int> mp;
  int tmp;
  REP(i,n){
    cin >> tmp;
    mp[tmp]++;
  }
  cout << ((n == mp.size()?"YES":"NO")) << endl;
}

Measured memory_bytes: 9600
import math

N = int(input())

result = 0

for a in range(1, N+1):
    for b in range(1, N+1):
        if math.gcd(a,b) == 1:
            result += 1*N
        else:
            for c in range(1, N+1):
                result += math.gcd(math.gcd(a,b),c)

print(result)

Measured memory_bytes: 9184
program foods_loved_by_everyone
  implicit none
  integer :: n, m, k, a(30), f(30) = 0, i, j
  read(*,*) n, m
  do i = 1, n
    read(*,*) k, a(1:k)
    do j = 1, k
      f(a(j)) = f(a(j))+1
    end do
  end do
  write(*,'(i0)') sum([(1,i=1,m)],mask=f == n)
end program foods_loved_by_everyone

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        solver.solve(S);
    }
}

class Solver {
    public void solve(String S) {
        int ans = 0;
        int N = S.length();
        for (int i = 0; i < N / 2; i++) {
            if (S.charAt(i) != S.charAt(N - i - 1)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21844
//------------------------------------//
#include <bits/stdc++.h>
#define cube(x) (x*x*x)
#define sqr(x) (x*x)
#define pi acos(-1)
//-------------------------------------//
typedef unsigned long long ull;
typedef long long int lld;
typedef long double ld;
using namespace std;
//------------------------------------//
lld i, j, k, f;

int main()
{
    double a, b, h, ar;
    cin >>a >>b >>h;
    ar = ((a+b)*h)/2.00;
    cout <<ar <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T> 
struct WeightedUnionFind{
  int n;
  T d;
  vector<int> r,p;
  vector<T> ws;
  WeightedUnionFind(){}
  WeightedUnionFind(int sz,T d_):
    n(sz),d(d_),r(n,1),p(n),ws(n,d){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(x==p[x]){
      return x;
    }else{
      int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  T weight(int x){
    find(x);
    return ws[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,T w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  T diff(int x,int y){
    return weight(y)-weight(x);
  }
};
//END CUT HERE
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    WeightedUnionFind<Int> u(n,0);
    for(int i=0;i<m;i++){
      int a,b;
      char c;
      cin>>c>>a>>b;
      a--;b--;
      if(c=='!'){
	Int w;
	cin>>w;
	u.unite(a,b,w);
      }else{
	if(!u.same(a,b)) cout<<"UNKNOWN"<<endl;
	else cout<<u.diff(a,b)<<endl;
      }
    }
  }
  return 0;
}
/*
  verified on 2017/10/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1330
*/

Measured memory_bytes: 4324
<?php
$n=trim(fgets(STDIN))+1;
$o='';
for($i=1;$i<$n;$i++){
  if($i%3==0) $o.=' '.$i;
  else{
   $x=$i;
   while($x){
      if($x%10==3){
        $o.=' '.$i;
        break;
      }
      $x=floor($x/10);
    }
  }
}
print $o;
?>

Measured memory_bytes: 15436
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl Q(N, 0);
    REP(i, N){
        ll p; cin >> p; p--;
        Q[p] = i;
    }
    
    ll lenmax = 0, len = 1;
    REP(i, N-1){
        if(Q[i] < Q[i+1]) len++;
        else{
            lenmax = max(lenmax, len);
            len = 1;
        }
    }
    lenmax = max(lenmax, len);
    
    cout << (N-lenmax) << endstr;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    map<string,int> Smap;

    string S[N];
    for(int i = 0; i < N; ++i) cin >> S[i];
    
    int max = 0;

    //map
    for(int i = 0; i < N; ++i){
        //key add
        if(Smap.count(S[i]) == 0) Smap.insert(make_pair(S[i],1));
        //value++
        else Smap[S[i]] = ++Smap[S[i]];
        //max++?
        if(max < Smap[S[i]]) max = Smap[S[i]];
    }

    for(auto i = Smap.begin(); i != Smap.end(); ++i){
        if(max == i->second) cout << i->first << endl;
    }

}

Measured memory_bytes: 26752
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

X,Y = LI()

for i in range(X+1):
    temp = 2*i+4*(X-i)
    if temp == Y:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 65516
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int l = s.size();
    if(l <= k)cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >    vecll;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  int n;
  cin >> n;
  vecint a(n,0);
  int sum = 0;
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  sort(all(a));
  if(sum %10 != 0){
    cout << sum << endl;
  }else{
    REP(i,n){
      if(a[i]%10 != 0){
	cout << sum - a[i] << endl;
	return 0;
      }
    }
    cout << 0 << endl;
  }
} 



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    int n,m,c;
    int b[22],a[22][22];
    cin>>n>>m>>c;
    rep(i,m)cin>>b[i];
    int ans=0;
    rep(i,n){
        int sum=0;
        rep(j,m){
            cin>>a[i][j];
            sum+=b[j]*a[i][j];
        }
        if(sum+c>0)ans++;
    }
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      int N = ni();

      if ( N == 0 )
        break;

      int W = ni();
      int H = ni();

      int[][] field = new int[H][W];

      for ( int i = 0; i < N; ++i ) {
        int x = ni() - 1;
        int y = ni() - 1;

        field[ y ][ x ] |= 1;
      }

      int S = ni();
      int T = ni();

      int max = 0;
      for ( int i = 0; i <= H - T; ++i ) {
        for ( int j = 0; j <= W - S; ++j ) {
          int cnt = 0;
          for ( int y = 0; y < T; ++y ) {
            for ( int x = 0; x < S; ++x ) {
              cnt += field[ i + y ][ j + x ];
            }
          }
          max = Math.max( max, cnt );
        }
      }

      System.out.println( max );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 34092
#include <iostream>

int main() {
  int N;
  int A;

  std::cin >> N >> A;
  
  int tmp = N % 500;
  if (tmp <= A) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {

	ll N;
	cin >> N;
	cout << 800 * N - 200 * (N / 15);
	system("PAUSE");
}


Measured memory_bytes: 504
/**
  @date Time-stamp: <2019-06-26 19:40:29 tagashira>
  @file b.cpp
  @title B - Digital Gifts
  @brief https://atcoder.jp/contests/abc119/tasks/abc119_b
**/

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

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

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

  vector<string> u(N);
  vector<long double> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> u[i];
  }

  long double ans = 0.0;
  for (int i = 0; i < N; i++) {
    if (u[i] == "JPY") {
      ans += x[i];
    } else {
      ans += x[i] * 380000;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
int a[200010],ans,s1,s2,n;
int main()
{
    int i;
    cin>>n>>s;
    for(i=0;i<n;i++)
     if(s[i]=='R')
      a[i+1]=1;
     else 
      a[i+1]=2;
    s1=1;
    s2=n;
    while(s1<s2)
    {
        while(a[s1]==1) s1++;
        while(a[s2]==2) s2--;
        if(s1>=s2) break;
        ans++;
        s1++;
        s2--;
    }
    cout<<ans;
    system("pause");
}


Measured memory_bytes: 4528
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        k: usize,
    }
    let a = k/2;
    let b = (k+1)/2;
    println!("{}", a*b);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < 7; i++){
        string k;
        k += s.substr(0,i);
        k += s.substr(n-(7-i),(7-i));
        if(k == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B = inpl()
if A <= 9 and B <= 9:
    print(A*B)
else:
    print(-1)


Measured memory_bytes: 4456
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main() {

    vector<vector<int>> idx(3);
    int N;
    cin >> N;

    vector<int> color = {0, 1, 2};

    map<char, int> cti;
    cti['R'] = 0;
    cti['G'] = 1;
    cti['B'] = 2;

    char c;
    REP(i, N) {
        cin >> c;
        idx[cti[c]].push_back(i);
    }

    ll ans = 0;
    do {
        for (auto& i : idx[color[0]]) {
            auto jj = upper_bound(ALL(idx[color[1]]), i);
            if (jj == idx[color[1]].end()) break;
            FOR(j, jj - idx[color[1]].begin(), idx[color[1]].size()) {
				auto kk = upper_bound(ALL(idx[color[2]]), idx[color[1]][j]);
				if (kk == idx[color[2]].end()) break;
                FOR(k, kk - idx[color[2]].begin(), idx[color[2]].size()) {
                    if (idx[color[1]][j]- i == idx[color[2]][k] - idx[color[1]][j]) continue;
                    ans++;
                }
            }
        }
    } while (next_permutation(ALL(color)));

    cout << ans << endl;
    

    return 0;
}


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

template<class Weight>
class max_flow {
private:
	struct edge {
		int to;
		Weight cap;
		int rev;
		edge(const int to_, const Weight cap_, const int rev_):to(to_), cap(cap_), rev(rev_){}
	};

	static constexpr Weight EPS = static_cast<Weight>(1e-7);
	static constexpr Weight INF = numeric_limits<Weight>::max();

	vector<vector<edge> > G;
	vector<int> level;
	vector<int> iter;

public:
	max_flow(int V):G(V), level(V), iter(V) {}

	void add_edge(const int from, const int to, const Weight cap) {
		if(from == to) return;
		G[from].emplace_back(to, cap, G[to].size());
		//G[to].emplace_back(from, 0, G[from].size() - 1);
		G[to].emplace_back(from, cap, G[from].size() - 1);
	}

	void bfs(int s) {
		queue<int> que;
		fill(begin(level), end(level), -1);
		que.push(s);
		level[s] = 0;

		while(!que.empty()) {
			const int v = que.front();
			que.pop();

			for(const auto &e : G[v]) {
				if(e.cap > EPS && level[e.to] == -1) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	Weight dfs(int v, int t, Weight f) {
		if(v == t) return f;

		for(int &i = iter[v]; i < G[v].size(); ++i) {
			edge &e = G[v][i];
			if(e.cap > EPS && level[v] < level[e.to]) {
				const Weight d = dfs(e.to, t, min(f, e.cap));
				if(d > EPS) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}

		return 0;
	}

	Weight solve(int s, int t) {
		Weight flow = 0;
		while(true) {
			bfs(s);
			if(level[t] < 0) return flow;
			fill(begin(iter), end(iter), 0);
			for(Weight f; (f = dfs(s, t, INF)) > 0; flow += f);
		}
	}
};

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

	int n;
	cin >> n;

	max_flow<int> mf(n + 1);
	const int sink = n;

	for(int i = 1; i < n; ++i) {
		int p;
		cin >> p;
		if(p) mf.add_edge(i, sink, INT_MAX);
	}

	for(int i = 1; i < n; ++i) {
		int u, v, c;
		cin >> u >> v >> c;
		mf.add_edge(u, v, c);
	}

	cout << mf.solve(0, sink) << endl;

	return EXIT_SUCCESS;
}

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

int main() {
    string a, s, c;
    cin >> a >> s >> c;
    
    cout << 'A' << s[0] << 'C' << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N; cin >> N;
    map<ll, ll> mp;
    ll sum = 0;
    for(int i = 0; i < N; ++i){
        ll a; cin >> a;
        ++mp[a];
        sum += a;
    }
    ll Q; cin >> Q;
    for (int _ = 0; _ < Q; ++_) {
        ll B, C; cin >> B >> C;
        ll tmp = mp[B];
        sum -= tmp * B;
        sum += tmp * C;
        cout << sum << endl;
        mp[B] = 0;
        mp[C] += tmp;
    }
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 9416
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a>0&&b>0){
        cout<<"Positive"<<endl;
    }
    else if(a<0&&b<0){
        if((b-a)%2==0){
            cout<<"Negative"<<endl;
        }
        else{
            cout<<"Positive"<<endl;
        }
    }
    else{
        cout<<"Zero"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#  define DEBUG(x) cerr << "DBG: " <<  x << endl
#else
#  define DEBUG(x) do {} while (0)
#endif
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, val, sizeof(a))
#define rep(i, N) for (int i = 0; i < N; i++)
#define repr(i, N) for (int i = (N)-1; i >= 0; i--)
#define rep1(i, N) for (int i = 1; i <= (N); i++)
#define repr1(i, N) for (int i = (N); (i) > 0; i--)
using ii = pair<int, int>;
using ll = long long;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3fll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> T gcd (T a, T b) { return a ? gcd (b % a, a) : b; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }

void solve(int tc) {
    int n;
    double h;
    cin >> n;
    vector<double>dp(n+1);
    dp[0] = 1;
    rep1(coin, n) {
      cin >> h;
      for(int i = coin; i >= 0; --i){
        dp[i] = (i ? dp[i-1] * h : 0) + (dp[i] * (1-h));
      }
    }
    double ans = 0;
    rep1(heads, n) {
      int tails = n - heads;
      if(heads > tails)ans+=dp[heads];
    }
    cout << std::fixed << std::setprecision(10) << ans << endl;
}

int main() {
  int tc = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin >> tc;
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "NO";
		String[] SS = s.split("");
		int cnt = 0;
		for(int i = 0; i < SS.length; i++) {
			if(SS[i].equals("o")) {
				cnt ++;
			}
		}
		if(15 - SS.length + cnt >= 8) {
			ans = "YES";
		}
		System.out.println(ans);
		sc.close();
	}
	
    
}


Measured memory_bytes: 21844
function main(input) {
  const s = input.split(/\n/)
  
  const n1 = s[1]
  const n2 = parseInt(s[2], 10) - 1
  
  const t = n1[n2]
  
  console.log([].slice.call(n1).map(s => s === t ? s : "*").join(""))
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, W;
    cin >> n >> W;
    V<ll> w(n), v(n);
    rep(i,0,n) cin >> w[i] >> v[i];
    V<V<ll>> dp(n, V<ll>(W+1, LLONG_MIN));
    rep(j,W+1,0) dp[n-1][j] = (j >= w[n-1] ? v[n-1] : 0);
    rep(i,n-1,0) rep(j,W+1,0) dp[i][j] = max(dp[i+1][j], j >= w[i] ? dp[i+1][j-w[i]]+v[i] : 0);
    cout << dp[0][W] << endl;
}


Measured memory_bytes: 79488
#include<iostream>
using namespace std;
int main(){
int N,A,B,C,D;
  cin>>N>>A>>B;
  C = N*A;
  D = B;
  if(C>D){
  cout<<D<<endl;
  }
 else if(D>=C){
  cout<<C<<endl;
  }
return 0;
}


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

using namespace std;

using ll = long long;

vector<ll> counts(1001);

// 約数をcountsに入れる
void helper(int n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) {
      continue;
    }
    ll count = 0;
    while (n % i == 0) {
      count++;
      n /= i;
    }
    counts[i] += count;
  }
  if (n > 1) {
    counts[n]++;
  }
}

int main() {
  ll mod = pow(10, 9) + 7;
  ll n;
  cin >> n;
  for (ll i = 2; i <= n; i++) {
    helper(i);
  }
  ll v = 1;
  for (ll i = 2; i <= n; i++) {
    v *= (counts[i] + 1);
    v %= mod;
  }
  cout << v << endl;
}


Measured memory_bytes: 3624
s=input()
t=input()
n=len(s)
m=len(t)

dp=[[0]*(m+1) for i in range(n+1)]

for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1

    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

#print(dp[n][m])

ans=''
while n>=0 and m>=0:
  if dp[n][m]==dp[n-1][m]:
    n-=1

  elif dp[n][m]==dp[n][m-1]:
    m-=1

  else:
    n-=1
    m-=1
    ans+=s[n]

print(ans[::-1])

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main(){
    int x, y, z, K;
    cin >> x >> y >> z >> K;

    vector<ll> a(x), b(y), c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];

    vector<ll> ab;
    REP(i, x) REP(j, y) {
        ab.push_back(a[i] + b[j]);
    }
    sort(ALL(ab));
    reverse(ALL(ab));
    ll size_ = min(K, x*y); 
    ab.resize(size_);

    vector<ll> ans;
    REP(i, ab.size()) REP(j, z) {
        ans.push_back(ab[i] + c[j]);
    }
    sort(ALL(ans));
    reverse(ALL(ans));

    REP(i, K) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 43620
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs1 = Console.ReadLine().Split(" ");
            var s = inputs1[0];
            var t = inputs1[1];

            var inputs2 = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs2[0]);
            var b = long.Parse(inputs2[1]);

            var u = Console.ReadLine();

            if (s == u)
            {
                a--;
            }
            else if (t == u)
            {
                b--;
            }

            Console.WriteLine(string.Join(" ", a, b));
        }
    }
}


Measured memory_bytes: 27520
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int arr[N+1];
  for(int i=0;i<=N;++i) arr[i] = 0;
  int L, R;
  for(int i=0;i<M;++i) {
    cin>>L>>R;
    L--;
    arr[L]++;
    arr[R]--;
  }
  for(int i=1;i<=N;++i) arr[i] += arr[i-1];
  int ans = 0;
  for(int i=0;i<=N;++i) {
    if(arr[i]==M) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3916
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    while len(A) > 1:
        A.sort()
        for i in range(1, len(A)):
            A[i] %= A[0]
        A = [a for a in A if a != 0]

    print(A[0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	int k,t;
	scanf("%d%d",&k,&t);
	int M=0;
	for(int i=0;i<t;i++){
		int temp;
		scanf("%d",&temp);
		M=max(M,temp);
	}
	printf("%d",max(0,k-1-(k-M)*2));
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
         
        long[][] a = new long[n][m];
        long[][] b = new long[m][l];
        long[][] c = new long[n][l];
        long sum = 0;
         
        for(int i = 0; i < n; i++){
            for( int j = 0; j < m; j++ ){
                a[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < m; i++){
            for( int j = 0; j < l; j++ ){
                b[i][j] = sc.nextInt();
            }
        }
         
         
        for(int i = 0; i < n; i++){
             for(int j = 0; j < l; j++){
                 for(int k=0;k<m;k++){
                    
                    sum+=a[i][k]*b[k][j];
                   }
                
               c[i][j] = sum;
                sum = 0;
                
                if (j == l - 1) {
                    System.out.print(c[i][j]);
                    
                } else { 
                    System.out.print(c[i][j] + " ");
                }
            }
            
            System.out.println();
        }
         
        sc.close();
    }
} 


Measured memory_bytes: 53668
use std::collections::HashSet;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String { read() }

fn usize() -> usize {
    read()
}

fn main() {
    let mut results: HashSet<usize> = HashSet::new();

    let n = usize();
    let s: Vec<u8> = string().chars().map(|c| {
        c.to_digit(10).unwrap() as u8
    }).collect();

    let mut s1_set: HashSet<usize> = HashSet::new();
    let mut s12_set: HashSet<usize> = HashSet::new();
    for s1i in 0..n {
        let s1 = s[s1i] as usize;
        if s1_set.contains(&s1) {
            continue;
        }
        s1_set.insert(s1);
        for s2i in s1i + 1..n {
            let s2 = s[s2i] as usize;
            let s12 = s1 * 10 + s2;
            if s12_set.contains(&s12) {
                continue;
            }
            s12_set.insert(s12);
            for s3i in s2i + 1..n {
                let s3 = s[s3i] as usize;
                results.insert(s1 * 100 + s2 * 10 + s3);
            }
        }
    }
    println!("{}", results.len());
}


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

int main(void) {
    int X;
    cin>>X;
    int please = 0;
    int p = X / 500;
    p *= 1000;
    please += p;
    p = (X % 500) / 5;
    p *= 5;
    please += p;
    cout << please << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;


int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  int count=0;
  int c=0;
  for(int i=1;i<n;i++){
    if(s[i]>='a')count++;
  }
  if(count!=n-2){
    cout<<"WA"<<endl;
    return 0;
  }
  for(int i=2;i<=n-2;i++){
    if(s[i]=='C')c++;
  }
  if(c!=1){
    cout<<"WA"<<endl;
    return 0;
  }
  cout<<"AC"<<endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(string, c);
	if ("auieo"s.find(c) != string::npos)
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}

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

typedef struct {
	long a;
	long b;
} S_BRIDGE;

int cmpAscVal(const void * n1, const void * n2)
{
	if (((S_BRIDGE *)n1)->a > ((S_BRIDGE *)n2)->a)
	{
		return 1;
	}
	else if (((S_BRIDGE *)n1)->a < ((S_BRIDGE *)n2)->a)
	{
		return -1;
	}
	else
	{
    if (((S_BRIDGE *)n1)->b > ((S_BRIDGE *)n2)->b)
  	{
  		return 1;
  	}
  	else if (((S_BRIDGE *)n1)->b < ((S_BRIDGE *)n2)->b)
  	{
  		return -1;
  	}
    else
  	{
  		return 0;
  	}
	}
}

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  S_BRIDGE bridge[m];
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &bridge[i].a, &bridge[i].b);
  }
  qsort(bridge, m, sizeof(S_BRIDGE), cmpAscVal);
  long ans = 1;
  long prev_a = bridge[0].a;
  long prev_b = bridge[0].b;
  for (long i = 1; i < m; i++) {
    if (bridge[i].a == prev_a) {
      continue;
    }
    if (bridge[i].a < prev_b) {
      prev_a = bridge[i].a;
      if (bridge[i].b < prev_b) {
        prev_b = bridge[i].b;
      }
      continue;
    }
    ans++;
    prev_a = bridge[i].a;
    prev_b = bridge[i].b;
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountll((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzll(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ double y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } double euclidean(double first, double second){ return sqrt(first * first + second * second); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(S == U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100002
int prime[N];
int i,j;
int c[N];
void hurui(){
  for(i=0;i<N;i++){
    prime[i]=1;
  }
  prime[0]=0;prime[1]=0;

  for(i=0;i<N;i++){
    if(prime[i]){
      for(j=i*2;j<N;j+=i)prime[j]=0;
    }
  }
  for(i=3;i<N;i+=2){
    if((prime[i]) && (prime[(i+1)/2]))c[i]++;
  }

  for(i=3;i<N;i++){
    c[i]+=c[i-1];
  }
}

int main(){
  int n;
  scanf("%d", &n);
  hurui();
  int l,r;
  for(i=0;i<n;i++){
    scanf("%d %d", &l, &r);
    printf("%d\n", c[r]-c[l-1]);

  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;
const int MAXN = 1e5+5;
long long arr[MAXN];
long long dp[MAXN][3];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        for(int j=0;j<=2;j++){
            dp[i][j] = -1e18;
        }
    }
    for(int i=2;i<=n;i++){
        if(i == 2){
            dp[i][0] = arr[i-1]+arr[i];
            dp[i][1] = (long long)-1*(arr[i-1]+arr[i]);
        }else{
            dp[i][0] = max(dp[i][0],max(dp[i-2][0],dp[i-2][1])+arr[i-1]+arr[i]);
            dp[i][0] = max(dp[i][0],max(dp[i-1][0],dp[i-1][1])+arr[i]);
            dp[i][1] = max(dp[i][1],max(dp[i-2][0],dp[i-2][1])+((long long)-1*(arr[i-1]+arr[i])));
            dp[i][1] = max(dp[i][1],dp[i-1][0]+((long long)-1*(arr[i])-((long long)2*arr[i-1])));
            dp[i][1] = max(dp[i][1],dp[i-1][1]+((long long)-1*arr[i])+((long long)2*arr[i-1]));
        }


    }
    cout<<max(dp[n][0],dp[n][1])<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}
int main(){
	int GCD=0,MAX=0;
	int n,r,x;
	scanf("%d%d",&n,&r);
	rep(k,n){
		scanf("%d",&x);
		GCD=gcd(GCD,x);
		MAX=max(MAX,x);
	}
	if(MAX>=r&&r%GCD==0)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 256