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

using namespace std;

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

    string s;
    cin >> s;
    int n = s.size();
    int cnta = 0;
    long long res = 0;
    for (int i = 0; i + 2 < n; ++i) {
        //cout << i+1 << endl;
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            res += cnta + 1;
            s[i + 2] = 'A';
            i += 1;
        } else if (s[i] == 'A') {
            ++cnta;
        } else {
            cnta = 0;
        }
        //cout << i+1 << " " << cnta << " " << res << endl;
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    ll n,x,t,ans;
    string s;
    cin>>s;
    ans=0;
    for(int i=0;i<s.length();i++)ans+=s[i]-'0';
    if(ans%9)
        cout<<"No";
    else
        cout<<"Yes";
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

vector<int> S(const vector<int>& r, const array<vector<int>, 3>& v) {
    const int n = v[0].size();
    array<vector<int>, 3> sv = v;
    REP(i, 3) sort(ALL(sv[i]));
    // rank
    array<vector<int>, 3> rank{vector<int>(n), vector<int>(n), vector<int>(n)};
    REP(i, 3) REP(j, n) {
        rank[i][j] = sv[i].end() - upper_bound(ALL(sv[i]), v[i][j]);
    }
    // score
    array<vector<int>, 3> score{vector<int>(n), vector<int>(n), vector<int>(n)};
    REP(i, 3) REP(j, n) {
        score[i][j] = r[rank[i][j]];
    }
    // sum
    vector<int> sum(n, 0);
    REP(i, n) {
        REP(j, 3) sum[i] += score[j][i];
    }
    return sum;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n; cin >> n;
    vector<int> r(n); cin >> r;
    array<vector<int>, 3> v{vector<int>(n), vector<int>(n), vector<int>(n)};
    REP(i, n) REP(j, 3) cin >> v[j][i];
    // vector<int> s0 = S(r, v); cout << s0 << endl;
    // 1??????????????????????????????
    ll ans = linf;
    REP(i, 3) FOR(j, v[i][0]+1, 100+1) {
        array<vector<int>, 3> nv = v;
        nv[i][0] = j;
        vector<int> nsum = S(r, nv);
        vector<int> snsum = nsum;
        sort(ALL(snsum));
        ll rank = snsum.end() - upper_bound(ALL(snsum), nsum[0]);
        if (rank < 8) {
            ans = min<ll>(ans, j - v[i][0]);
        }
    }
    if (ans == linf) cout << "Saiko" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3212
import math

a, b, x = map(int, input().split())
x /= a

h = x/a

if h >= b/2:
    d = math.atan(2*(b-h)/a)
    ans = math.degrees(d)

else:
    d = math.atan(2*x/b/b)
    ans = 90-math.degrees(d)

print(ans)

Measured memory_bytes: 3060
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
ans = 0
for bit in range(1<<(h+w)):
    c = 0
    for i in range(w, h+w):
        for j in range(w):
            if bit>>i & 1 and bit>>j & 1: c += C[i-w][j] == '#'
    if c == k: ans += 1
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int>x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  
  auto dist = [&](int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx+dy*dy, 0.5);
  };
  vector<int>p(n);
  rep(i,n) p[i] = i;
  double len;
  int cnt;
  do{
    rep(i,n-1){
      len += dist(p[i], p[i+1]);
    }
    cnt++;
  } while(next_permutation(p.begin(), p.end()));
  double ans = len/cnt;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 384
#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>;

int main()
{
    ll x;
    cin >> x;
    ll n = 100;
    int ans = 0;
    while (n < x) {
        n = n * 1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
##https://atcoder.jp/contests/dp/tasks/dp_a 
N,K = map(int,input().split())
Place_Height_List = list(map(int,input().split()))  
Min_List = [0,abs(Place_Height_List[1]-Place_Height_List[0])]

for i in range(2,len(Place_Height_List)):
    Current_Step_Min = 10 ** 9
    for j in range(1,min(i,K)+1):
        Current_Step = Min_List[i - j] + abs(Place_Height_List[i] - Place_Height_List[i - j])
        if Current_Step_Min > Current_Step:
            Current_Step_Min = Current_Step
        
    Min_List.append(Current_Step_Min)
print(Min_List[-1])

Measured memory_bytes: 90308
//In the name of Allah
//In the name of the compassionate of the merciful
//Ya Ali!
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename Type>
using ordered_multiset = tree<Type, null_type, less_equal<Type>, rb_tree_tag, tree_order_statistics_node_update> ;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 25 ;
const ll INF = 3e18 ;

#define f first
#define s second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define endll "\n"
#define sortt(v) sort(v.begin() , v.end())
#define reversee(v) reverse(v.begin() , v.end())

// for sqrt on interval and array , always sq = maxn/80 ;
// cout << *ss.find_by_order(index) ; -> return the value that indexed in index position
// cout << ss.order_of_key(value) ; -> lower_bound in ordered_set
//ifstream fin("input.txt");
//ofstream fout("output.txt");
// fflush(stdout);
ll mod = 1e9 + 7 , p1 = 999999929 , p2 = 999999937 ;

ll n , a[maxn][maxn] , dp[maxn][(1ll<<23)+2] ;

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

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

for(int mask = 0 ; mask < (1ll<<n) ; mask ++){
   for(int j = 0 ; j < n ; j ++){
    if(a[0][j] && (mask&(1ll<<j)))dp[0][mask] = (dp[0][mask]+1)%mod ;
   }
}

for(int i = 1 ; i < n ; i ++){
  for(int mask = 0 ; mask < (1ll<<n) ; mask ++){

    if(__builtin_popcount(mask) != i+1)continue ;

    for(int j = 0 ; j < n ; j ++){
       if(a[i][j] && (mask&(1ll<<j)))dp[i][mask] = (dp[i][mask] + (dp[i-1][mask^(1ll<<j)]%mod))%mod ;
    }
  }
}
cout << dp[n-1][(1ll<<n)-1]%mod ;

 return 0;
}
/*
                  _     _   __
            /_\  (_    (_)  __)
           /   \  _) . (_) (__
*/


Measured memory_bytes: 332160
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int k;
   cin >> k;
   int ans = 0;
   f(a,1,k+1){
      f(b,1,k+1){
         f(c,1,k+1){
            int g = __gcd(a,b);
            g = __gcd(g,c);
            ans += g;
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 


Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,ans;
	int i,k;
	cin>>k;
	cin>>s;
	if(s.length()>k)
	{
		for(int i=0;i<k;i++)
		{
			ans=ans+s[i];
		}
		ans.append(3,'.');
	}
	else
	ans.assign(s);
	cout<<ans<<endl;
	return 0;
 } 

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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  vector<string> A(H+2);
  for(int i=0; i<W+2; i++){
  A.at(0)+='#';
  A.at(H+1)+='#';
  }
  for(int i=1; i<H+1; i++){
    cin >> A.at(i);
    A.at(i)='#'+A.at(i)+'#';
  }
  
  for(int i=0; i<H+2; i++){
    cout << A.at(i) << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
    L = []
    for i in range(N):
        a,b = map(int,input().split())
        L.append((a,b))
    
    L.sort()
    for i in range(N):
        K -= L[i][1]
        if K <= 0:
            print(L[i][0])
            exit()
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 16968
N = int(input())
A, B = map(int, input().split())
P = sorted([int(i) for i in input().split()])
ans = 0
num1 = 0
num2 = 0
num3 = 0

for i in P:
    if i <= A:
        num1 += 1
    elif A+1 <= i <= B:
        num2 += 1
    elif B+1 <= i:
        num3 += 1

print(min(num1, num2, num3))

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String str=sc.next();
        char[]a=str.toCharArray();
        if(a[2]==a[3] && a[4]==a[5])
        System.out.println("Yes");
        else
        System.out.println("No");
        
    }
}

Measured memory_bytes: 23764
import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n=sc.nextLong();
        StringBuilder ans=new StringBuilder();
        long remain=0;
        long qoute=n-1;
  
        while (qoute>=0) {
            remain=qoute%26;
            qoute=(qoute-remain)/26;
            qoute--;
                    
            ans.append((char)(remain+97));
        }
       
        System.out.println(ans.reverse().toString());
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen)
            return true;
        else
            ptr = 0;
        try {
            buflen = in.read(buffer);
        } catch (final IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(final int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        final StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b)
            throw new NumberFormatException();
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b))
                return minus ? -n : n;
            else
                throw new NumberFormatException();
            b = readByte();
        }
    }
}

Measured memory_bytes: 32444
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
using namespace std;

long long int a[100005], ans;
int n, i;
int main()
{
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	ans = 0;
	int k, j;
	for (i = 1; i <= n;i++)
	{
		k = i;
		while (a[k]<=a[k+1]&&k<=n-1)
		{
			k++;
		}
		j = i;
		while (a[j]>=a[j+1]&&j<=n-1)
		{
			j++;
		}
		ans++;
		i = max(k, j);
	}
	
	cout << ans << endl;
}

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

import itertools

n, k = map(int, input().split())
a = list(itertools.accumulate(list(map(int, input().split()))))
a = [0] + a
s = [None] * (n*(n+1)//2)
cnt = 0
for i in range(n+1):
    for j in range(i+1,n+1):
        s[cnt] = format(a[j]-a[i], '050b')
        cnt += 1

ret = 0
sel = set(range(n*(n+1)//2))
for i in range(50):
    nxt = set([])
    for j in sel:
        if s[j][i] == '1':
            nxt.add(j)
    if len(nxt)>=k:
        sel = nxt
        ret += 2**(49-i)
print(ret)


Measured memory_bytes: 107536
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


N = int(input())
D = list(map(int,input().split()))

cnt = [0 for i in range(N)]

flg = 1
if D[0]!=0:
    flg = 0
for i in range(N):
    if D[i]==0 and i!=0:
        flg = 0
    else:
        cnt[D[i]] += 1

ans = 1
mod = 998244353
flg2 = 1
for i in range(1,N):
    if cnt[i]>0 and flg2:
        ans *= cnt[i-1]**cnt[i]
        ans %= mod
    elif cnt[i]>0 and (not(flg2)):
        flg = 0
    else:
        flg2 = 0
print(ans*flg)
    
    


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Onigiri()
{
  int n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0)cout<<(b-a)/2;
  else {
    cout<<min(n-b,a-1)+1+(b-a-1)/2;
  }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
  // cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (n == 2) {
    cout << s << '\n';
  } else {
    reverse(s.begin(), s.end());
    cout << s << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll N; cin >> N;
    cout << N*(N - 1)/2 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string NUM;
  cin>>NUM;
  int K;
  cin>>K;

  int N = 100;
  int DP[101][10][2] = {0};
  DP[0][0][0] = 1;
  for (int i = 0; i < NUM.size(); i++)
  {
    for (int j = 0; j < 4; j++)
    {
      for (int k = 0; k < 2; k++)
      {
        int nd = NUM[i] - '0';
        for (int d = 0; d < 10; d++)
        {
          int ni = i + 1;
          int nj = j;
          int nk = k;
          if( d != 0) nj ++;
          if(nj > K)continue;
          if(k == 0)
          {
            if(d > nd) continue;
            if(d <nd) nk = 1;
          }
          DP[ni][nj][nk] += DP[i][j][k];
        }
        
      }
      
      
    }
    
  }
  
  
  cout<<DP[NUM.size()][K][0] + DP[NUM.size()][K][1]<<endl;
  // DEBUG(DP);
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

vector<int> l;
vector<vector<int>> nd;

int length(int i){
  if (l[i] >= 0)
    return l[i];
  int res = 0;
  for(auto t:nd[i])
    res = max(length(t)+1,res);
  l[i] = res;
  return res;
}

int main(){
  int N,M;
  cin >> N >> M;
  
  l.resize(N+1,-1);
  nd.resize(N+1,vector<int>());
  
  int i,x,y;
  for(i=0;i<M;i++){
    cin >> x >> y;
    nd[x].push_back(y);
  }
  int ct = 0;
  for(i=1;i<=N;i++)
    ct = max(length(i),ct);
  
  cout << ct << endl;
    
  return 0;
}

Measured memory_bytes: 11032
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int n;
  cin >> n;
  vector<float> A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(), A.end());

  float res = (A[0] + A[1]) / 2;
  for (int i = 2; i < n; i++)
  {
    res = (res + A[i]) / 2;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] in = sc.nextLine().split(" ");
        int num;
        int co = 0;
        for(int i =0 ; i<in.length ; i++){
            num = Integer.parseInt(in[i]);
            while(num % 2 == 0){
                co++;
                num/=2;
            }
        }
        System.out.println(co);
    }
}


Measured memory_bytes: 27632
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: usize,
  }

  let mut ans = 9;

  if n >= 400 && n <= 599 {
    ans = 8;
  } else if n >= 600 && n <= 799 {
    ans = 7;
  } else if n >= 800 && n <= 999 {
    ans = 6;
  } else if n >= 1000 && n <= 1199 {
    ans = 5;
  } else if n >= 1200 && n <= 1399 {
    ans = 4;
  } else if n >= 1400 && n <= 1599 {
    ans = 3;
  } else if n >= 1600 && n <= 1799 {
    ans = 2;
  } else if n >= 1800 && n <= 1999 {
    ans = 1;
  }

  println!("{}", ans);
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a > b)
    {
        ll c = a;
        a = b, b = c;
    }

    return b % a == 0 ? a : gcd(a, b % a);
}

int main()
{
    ll n, t, ans;
    cin >> n;
    ans = 1;
    REP(i, n)
    {
        cin >> t;

        ll g = gcd(ans, t);

        ans = g * (ans / g) * (t / g);
    }

    cout << ans << endl;

    return 0;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;

const int N=1e5+1;
int n, a[N][3], f[N][4];

int main()
{
	FASTIO;
	cin >> n;
	for (int i=1; i<=n; i++) 
		for (int j=0; j<3; j++) cin >> a[i][j];
	for (int i=1; i<=n; i++) {
		for (int j=0; j<4; j++) f[i][3] = max(f[i][3], f[i-1][j]);
		for (int j=0; j<3; j++) {
			int v = INT_MIN;
			for (int k=0; k<3; k++) {
				if (k==j) continue;
				v = max(v,f[i-1][k]+a[i][j]);
			}
			f[i][j] = v;
		}
	}
	int ans=INT_MIN;
	for (int i=0; i<4; i++) ans = max(ans, f[n][i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
int main()
{double w,h,x,y,i;
while(~scanf("%lf%lf%lf%lf",&w,&h,&x,&y))
  {i=0;
printf("%lf ",w*h/2);
  if(y==h/2&&x==w/2)
   printf("1\n");
     else printf("0\n");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define MAX_V 100
using namespace std;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
void dijkstra(int s){
    fill(d,d+V,INF);
    fill(used,used+V,false);
    d[s]=0;
    
    while(true){
        int v=-1;
        for(int u=0;u<V;u++){
            if(!used[u] && (v == -1 || d[u] < d[v])){
                v = u;
            }
        }
        
        if(v == -1) break;
        
        used[v] = true;
        
        for(int u=0;u<V;u++){
            d[u] = min(d[u],d[v]+cost[v][u]);
        }
    }
    
    for(int i=0;i<V;i++) cout<<i<<" "<<d[i]<<endl;

    return ;
}

int main(){
    cin>>V;
    int u,k,v,c;

    for(int i=0;i<V;i++)
        for(int j=0;j<V;j++) cost[i][j]=INF;
    
    for(int i=0;i<V;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            cost[u][v]=c;
        }
    }
    
    dijkstra(0);
    
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ii pair<ll,ll>;
#define vi vector<int>;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(i = a; i < b; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main(){
    IOS
    //io_set();
    ll n, i;
    cin >> n;
    ll a[n], c=1;
    fo(i, 0, n){
        cin >> a[i];
    }
    ll pk=a[0];
    fo(i,1,n){
        pk=max(a[i],pk);
        if(pk==a[i]){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int x[5] = {0};
  for(int i=0; i < 5; ++i)
  {
    std::cin >> x[i];
    if(x[i] == 0)
    {
      std::cout << i + 1;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3552
import sys, math, itertools, collections, bisect,copy
s=list(input())
s2=copy.deepcopy(s)
ans=0
if len(s)=="1":
    print(0)
    exit()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        if s[i]=="0":
            s[i+1]="1"
        else:
            s[i+1]="0"
        ans+=1
if s2[0]=="0":
    s2[0]="1"
    ans2=1
else:
    s2[0]="0"
    ans2=1
for i in range(len(s2)-1):
    if s2[i]==s2[i+1]:
        if s2[i]=="0":
            s2[i+1]="1"
        else:
            s2[i+1]="0"
        ans2+=1
print(min(ans,ans2))


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

int main()
{
	int n,v[50];
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>v[i];
	
	sort(v,v+n);
	
	double x=v[0];
	for(int i=1;i<n;i++) x=(x+v[i])/2.0;
	
	cout<<setprecision(10)<<x<<endl;
	
	return 0;
}


Measured memory_bytes: 256
def check(s)
    return false if s[0] != 'A'
    return false if s[2..-2].count('C') != 1
    return s.gsub(/[AC]/,'').split('').all?{|c| c =~ /[a-z]/}
end

s=gets.chomp
print check(s) ? "AC" : "WA"


Measured memory_bytes: 1788
/**
 *    author:  tourist
 *    created: 23.05.2020 15:53:29       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    vector<pair<int, long long>> ops;
    ops.emplace_back(2, a);
    ops.emplace_back(3, b);
    ops.emplace_back(5, c);
    const long long inf = (long long) 4e18;
    map<long long, long long> mp;
    mp[0] = 0;
    mp[1] = d;
    function<long long(long long)> Dfs = [&](long long x) {
      if (mp.find(x) != mp.end()) {
        return mp[x];
      }
      long long ret = inf;
      if ((long double) d * (long double) x < ret) {
        ret = d * x;
      }
      for (auto& p : ops) {
        int num = p.first;
        long long cost = p.second;                      
        ret = min(ret, Dfs(x / num) + cost + d * (x % num));
        if (x % num != 0) {
          ret = min(ret, Dfs(x / num + 1) + cost + d * (num - x % num));
        }
      }
      return mp[x] = ret;
    };
    cout << Dfs(n) << '\n';
  }
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  //二次元配列の宣言
  int M = max(H, W);
  vector<vector<char>> data(M, vector<char>(M, '.'));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> data.at(i).at(j);
    }
  }
  //圧縮した回数
  int countH = 0;//行の圧縮
  int countW = 0;//列の圧縮

  vector<char> vec(M, '.');
  
  //行の圧縮
  for(int i = 0; i < H; i++){
    
    if(data.at(i) == vec){
      if(i != H-1){
          for(int k = i; k < M-1; k++){
            data.at(k) = data.at(k+1);
          }
      }
      i--;
      H--;
      countH++;
    }
  }
  
  //列と行の入れ替え
  vector<vector<char>> data2(M, vector<char>(M, '.'));
  data2 = data;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < M; j++){
      data2.at(i).at(j) = data.at(j).at(i);
    }
  }
  
  //列の圧縮
  for(int i = 0; i < W; i++){
    if(data2.at(i) == vec){
      if(i != W-1){
          for(int k = i; k < M-1; k++){
            data2.at(k) = data2.at(k+1);
          }
      }
      i--;
      W--;
      countW++;
    }
  }
  
  //出力
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W ; j++){
      cout << data2.at(j).at(i);
    }
    cout << endl;
  }
}









Measured memory_bytes: 256
a=[list(map(int,input().split())) for _ in range(3)]
b=[int(input()) for _ in range(int(input()))]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
ans="No"            
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans="Yes"
for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]==0:
    ans="Yes"
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        TreeSet<Integer> set = new TreeSet<>();

        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }

        int duplicated = n - set.size();

        System.out.println(duplicated % 2 == 1 ? set.size() - 1 : set.size());
    }
}

Measured memory_bytes: 63572
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto z = readln.strip.splitter.map! (i => i.to!int).array;
  int h = z[0];
  int w = z[1];
  string [] a = new string[h];
  foreach (t; 0 .. h) {
    a[t] = readln[0 .. w];
  }
  int s = 0;
  auto x = new int[w];
  auto order = new int[w];
  int k = 0, i = 0, j = w - 1;
  while (i < j) {
    order[k++] = i;
    order[k++] = j;
    i++;j--;
  }
  if (k < w) order[k++] = i;
  bool cmp (int i, int j, int l) {
    foreach (k; 0 .. l) {
      if (a[i][x[k]] != a[j][x[w-1-k]]) {
        return false;
      }
    }
    return true;
  }
  bool check (int l) {
    int st = 0;
    int t = h;
    while (t > 1) {
      int old_t = t;
      loop: foreach (i; 0 .. h) if (!(st & (1 << i))) {
        foreach (j; i + 1 .. h) if (!(st & (1 << i))) {
          if ((l == w) ? cmp (i, j, l) : cmp (i, j, l / 2) && cmp (j, i, l / 2)) {
            st |= (1 << i) | (1 << j);
            t -= 2;
            break loop;
          }
        }
      }
      if (old_t == t) return false;
    }
    if (t == 1) {
      foreach (i; 0 .. h) if (!(st & (1 << i))) {
        return (l == w) ? cmp (i, i, l) : cmp (i, i, l / 2);
      }
    }
    return true;
  }
  bool go (int k, int st) {
    if (k == w) {
      return check (w); 
    }
    if (!(k & 1)) {
      if (!check (k)) return false;
    }
    foreach (i; 0 .. w) {
      if (!(st & (1 << i))) {
        x[order[k]] = i;
        if (go (k + 1, st | (1 << i))) return true;
      }
    }
    return false;
  }
  if (go (0, 0)) {
    writeln ("YES");
  } else {
    writeln ("NO");
  }
}



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

long china = 1000000007;
long P(long N){
    long res = N;
    for(N--; N>0; N--){
        res = res*N;
        res = res % china;
    }
    return res;
}

int main(){
    long N,M;
    long res = 0;
    
    cin >> N >> M;
    if(abs(N-M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    if(N==M){
        res = P(N) * P(M);
        res = res % china; 
        res = res * 2 % china;
    }else {
        res = P(N) * P(M);
        res = res % china; 
    }

    cout << res << endl;
}


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

int main() {
  int n;
  cin>>n;  
  vector<int>a(n);
  int ans=1;
  rep(i,n){
    cin>>a.at(i);
  }
  int j=0;
  int i=1;
  int k=2;
  while(k<n){
    if((a.at(j)<a.at(i)&&a.at(i)>a.at(k))||(a.at(j)>a.at(i)&&a.at(i)<a.at(k))){
      ans++;
      j=k;
      i=j+1;
      k+=2;
    }
    else if((a.at(j)<a.at(i)&&a.at(i)==a.at(k))||(a.at(j)>a.at(i)&&a.at(i)==a.at(k))){
      k++;
    }
    else{
      k++;
      i=k-1;
      j=k-2;
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  int N;
  string S;

  cin >> N ;

  cin >> S ;

  int flag = 0;

  if(S.size()%2==1){
    cout << "No" << endl;
  }
  else{
    for (int i = 0; i < (S.size()/2); i++)
    {
      if(S.at(i)==S.at(i+S.size()/2)){

      }
      else{
        flag = 1;
      }
    }
    if(flag==1){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
    
  }

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception{
		Scanner cin= new Scanner(System.in);
		final int n= cin.nextInt();
		int[] A    =new int[n];
		int[] DPlen=new int[n+1]; //DPlen[i]:長さi+1の増加部分列のうちの、[0]最小要素/[1]そのindex。
		int intMAX= (int)Math.pow(10d,9d)+1;
		
		A[0]= cin.nextInt();
		DPlen[0]= A[0];
		
		int k;
		for(k=1;k<n+1;k++){
			DPlen[k]= intMAX;
		}
		
		int i;
		for(i=1;i<n;i++){
			A[i]= cin.nextInt();
			int index = Arrays.binarySearch(DPlen, A[i]);
			if( index<0 ){
				index= ~index;
				DPlen[index]= A[i];
			}
		}
		
		int ans= Arrays.binarySearch(DPlen, (int)Math.pow(10d,9d));
		if( ans<0 ){
			ans=~ans;
		}
		else{
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 66068
from fractions import gcd


a, b, c, d = map(int, input().split())
lcm = int(c * d / gcd(c, d))
A = a - 1
l_cd = A - A // c - A // d + A // lcm
r_cd = b - b // c - b // d + b // lcm
print(r_cd - l_cd)


Measured memory_bytes: 5048
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll a, b, n;

ll solve() {
    return a * min(n, b-1) / b;
}

void input() {
    cin >> a >> b >> n;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define PB push_back
#define PII pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MAXN = 2e5 + 10 , INF = 1e9;
vector <int> edges[MAXN];
int n , k;
int cnt;
int dis[MAXN];
int ans[MAXN];

void dfs(int v , int par , int root) {
    for (auto u : edges[v]) {
        if(u != par) {
            dis[u] = dis[v] + 1;
            if(dis[u] > (k / 2)) {
                ans[root]++;
            }
            dfs(u , v , root);
        }
    }
}

void dfs2(int v , int par) {
    for (auto u : edges[v]) {
        if(u != par) {
            if(dis[u] == -1) {
                dis[u] = dis[v] + 1;
                if(dis[u] > (k / 2)) {
                    cnt++;
                }
            }
            dfs2(u , v);
        }
    }
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n - 1; ++i) {
        int x , y;
        cin >> x >> y;
        x--; y--;
        edges[x].PB(y);
        edges[y].PB(x);
    }   
    if(!(k % 2)) {
        int mini = INF;
        for (int i = 0; i < n; ++i) {
            dis[i] = 0;
            dfs(i , -1 , i);
        }
        for (int i = 0; i < n; ++i) {
            mini = min(mini , ans[i]);
        }
        cout << mini << endl;
    }
    else {
        int mini = INF;
        for (int i = 0; i < n; ++i) {
            for (int j : edges[i]) {
                cnt = 0;
                fill(dis , dis + n , -1);
                dis[i] = 0; dis[j] = 0;
                dfs2(i , -1);
                mini = min(mini , cnt);
            }
        }
        cout << mini << endl;
    }
}


Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String []input = br.readLine().split(" ");
		int board = Integer.parseInt(input[0]);
		int alice = Integer.parseInt(input[1]);
		int borys = Integer.parseInt(input[2]);

		if(Math.abs(alice - borys) == 1 ) {
			System.out.println("Borys");
		}/*else if(Math.abs(alice - borys) == 2) {
			System.out.println("Alice");
		}*/else if(Math.abs(alice - borys)%2 == 0) {
			System.out.println("Alice");
		}else {
			System.out.println("Borys");
		}

	}

}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const LL INFLL = 999999999999999LL;

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

    Vll a(n);
    REP(i,n) cin>>a[i];

    LL sum_abs = 0;
    LL min_abs = INFLL;
    LL cnt_neg = 0;
    bool is_zero = false;
    REP(i,n){
        sum_abs += abs(a[i]);
        min_abs = min(min_abs,abs(a[i]));
        if(a[i]<0) cnt_neg++;
        if(a[i]==0) is_zero = true;
    }

    if(cnt_neg%2==0 || is_zero){
        cout<<sum_abs<<endl;
    }else{
        cout<<sum_abs-2*min_abs<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
const int Mod = 1000000007;
int main(){
  int N;
  char S[100001];
  cin >> N >> S;
  int count[26];
  for(int i = 0; i < N; i++){
    count[S[i] - 'a']++;
  }
  long long ans = 1;
  for(auto x : count){
    ans = ans * (x + 1) % Mod;
  }
  ans = (ans + Mod - 1) % Mod;
  cout << ans << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n ;
    cin >> n ;
    ll ans = 0 ;
    vpll red(n) ;
    REP(i,n){
        ll a, b ;
        cin >> a >> b ;
        red[i] = MP(a,b) ;
    }
    vpll blue(n) ;
    REP(i,n){
        ll c, d ;
        cin >> c >> d ;
        blue[i] = MP(c,d) ;
    }
    sort(ALL(red)) ;
    sort(ALL(blue)) ;


    REP(i,n){
        int tmp = -1 ;
        pll tm = MP(-1,-1) ;
        pll k = blue[i] ;
        ll kx = blue[i].FI ;
        ll ky = blue[i].SE ;
        REP(j,n){
            ll lx = red[j].FI ;
            ll ly = red[j].SE ;
            if(lx<kx && ly<ky){
                if(tm.SE<ly){
                    tm = red[j] ;
                }
            }
        }
        if(tm != MP((ll)-1,(ll)-1)){
            ans++ ;
            REP(j,n){
                if(red[j]==tm){
                    red[j] = MP(INF,INF) ;
                }
            }
        }
    }

    cout << ans <<endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int n, d;
	long int count;
	long int flg;
	long int min;
	long int a[100000];
	long int b[100000];
	
	scanf("%ld", &n);
	
	scanf("%ld", &a[0]);
	
	b[0] = a[0];
	count = 1;
	min = a[0];
	
	for(i = 1; i < n; i++) {
		scanf("%ld", &a[i]);
		flg = 0;
		if(a[i] <= min) {
			min = a[i];
			b[count] = a[i];
			count++;
			continue;
		}
		for(j = 0; j < count; j++) {
			if(b[j] < a[i]) {
				flg = 1;
				b[j] = a[i];
				break;
			}
		}
		if(flg == 0) {
			b[count] = a[i];
			count++;
		}
	}
	
	printf("%ld\n", count);
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();
        int res = 0;
        if(K <= A){
            res += K;
        }else if (K <= A+B){
            res += A;
            res += 0;
        }else{
            res += A;
            res += 0;
            res -= (K - A - B);
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 35688
#include <iostream>
using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    
    if (n == 1 && m == 1) {
        ans = 1;
    }else if(n == 1){
        ans = m - 2;
    }else if(m == 1){
        ans = n - 2;
    }else{
        ans = (n - 2) * (m - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n+1);
    for(ll i=0; i<n; i++) cin>>v[i+1]; //one based indexing

    //floyd warshall cycle detection algorithm starts here to find start of cycle
    ll l = v[1];
    ll r = v[v[1]];
    while(l!=r){
        l = v[l];
        r = v[v[r]];
    }
    l = 1;
    while(l!=r){
        l=v[l];
        r=v[r];
    }
    //floyd warshall cycle detection algorithm ends here to find start of cycle

    ll cycleStar = l;  //starting point of cycle
    ll cnt = 0;  //number of elements before the starting point of cycle
    l = 1;
    while(l!=cycleStar){
        cnt++;
        l = v[l];
    }

    ll eleBefore = cnt;  //number of elements before the starting point of cycle
    ll lenn = 1;   //length of cycle(num of elements in it)
    l = cycleStar;
    while(v[l]!=cycleStar){
        l=v[l];
        lenn++;
    }
    
    // moving king to the starting point of cycle if k becomes zero in between we are breaking early and printing the answer
    l = 1;
    while((eleBefore!=0)&&(k)){
        l=v[l];
        eleBefore--;
        k--;
    }
    
    // printing answer if k becomes zero in between reaching the start of cycle
    if(k==0){
        cout<<l<<endl;
        return 0;
    }
    
    // now we are at start of cycle we can reduce k to k%lenn because if k> len king will move in cycle
    k=k%lenn;
    
    //now k is less than length of cycle
    //just move king k steps forward
    while(k){
        l=v[l];
        k--;
    }
    //print ans
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,k,a,b;
    cin>>n>>k;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a>>b;
        mp[a]+=b;
    }
    ll cnt=0;
    for(auto x:mp){
        cnt+=x.second;
        if(cnt>=k){
            cout<<x.first<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int ans;
int n, s;
void dfs(int sum,int i,int m){
	if (m == 0 && sum == s)
	ans++;
	if (i == 10 | m == 0)
	return ;	
	dfs(sum+i,i+1,m-1);
	dfs(sum, i + 1, m);
}

int main() {
	while (cin >> n >> s, n){
		ans = 0;
		dfs(0,0,n);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104