akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> v(20, 0);
	vector<int> c(20, 0);
	for( int i = 0; i < n; ++i ) cin >> v[i];
	for( int i = 0; i < n; ++i ) cin >> c[i];
	int ans = 0;
	for( int i = 0; i < (1<<20); ++i ){
		int x = 0, y = 0;
		for( int j = 0; j < 20; ++j ){
			if( i & (1<<j) ){
				x += v[j];
				y += c[j];
			}
		}
		ans = max( ans, x-y );
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if (N >= 10) {
            ans = R;
        }
        else {
            ans = R + (100*(10-N));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35348
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long N, M;
    cin >> N >> M;
    if (N > M) swap(N, M);
    if (N == 1) {
        if (M == 1) cout << 1 << endl;
        else cout << M - 2 << endl;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k=II()
    a,b=MI()
    for x in range(a,b+1):
        if x%k==0:
            print("OK")
            exit()
    print("NG")

main()

Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = Integer.parseInt(scan.next());
        int w = Integer.parseInt(scan.next());
        int[][] c = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = Integer.parseInt(scan.next());
            }
        }
        int[] a = new int[10];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int b = Integer.parseInt(scan.next());
                if (b != -1) {
                    a[b]++;
                }
            }
        }
        scan.close();

        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < a.length; i++) {
            ans += c[i][1] * a[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 53992
#include<stdio.h>
int main(){
    int i,j,n,a[101],t,minj,p=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        minj=i;
        for(j=i;j<n;j++){
            if(a[minj]>a[j]){
                minj=j;
            }
        }
        if(i!=minj){
                t=a[i];
                a[i]=a[minj];
                a[minj]=t;
                p++;
        }
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i==n-1){printf("\n");}
        else{printf(" ");}
    }
    printf("%d\n",p);
}


Measured memory_bytes: 2064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}
ll N;
vector<ll> P,Q;
int k=1;
ll a = 0,b=0;
int main() {

    cin >> N;


    for(int i=0;i<N;i++){
        ll temp;
        cin >> temp;
        P.push_back(temp);
    }
    for(int i=0;i<N;i++){
        ll temp;
        cin >> temp;
        Q.push_back(temp);
    }

    foreach_permutation(N, [](int *indexes) {
        int n = N;
        bool flaga = true;
        bool flagb= true;
        for(int i=0;i<n;i++){
            if(P[i]!=indexes[i]){
                flaga = false;
            }
            if(Q[i]!=indexes[i]){
                flagb = false;
            }
        }
        if(flaga){
            a = k;
        }
        if(flagb){
            b = k;
        }
        k++;
    });

    cout << abs(a-b) << endl;



}


Measured memory_bytes: 256
X,Y,E = gets.chomp.split(' ').map(&:to_i)
D = Array.new(X).map{ Array.new(Y) }
E.times do 
	x,y = gets.chomp.split(' ').map(&:to_i) # ?????????x,y??????????????????
	D[x][y] = true
end

PY = Array.new(Y).map{-1} # Y's pair ??????-1??¨???????????????
V = Array.new(X).map{false} # visited or not (boolean)

def match(x)
	return true if x<0 
	return false if V[x] # ????????¢????¨????????????????false
	V[x] = true
	Y.times do |y|
		next if !D[x][y] # ??????????????????????????§????????????????¬????
		# ??\????????????????????´?????§...
		#p "#{x}, #{y}"
		if match(PY[y]) # y?????????????????????PY[y]???-1????????§match(-1)???true, ??????y???????????¢?????????????????????????????????????????????????????????????????????...?????°?????????
			PY[y] = x # y????????¢???x??¨??????
			#p "#{x}, #{y} matched"
			return true # ??????????????????????????¢??????????????????????\???????????????????????????¨????????? or count++
		end
	end
	return false # ??°?????¢?????§???????????£????????§???NG?????????
end

count = 0 # ?????¢??°

# ????????§???x??????????????????????????????????????????
X.times do |x|
	x.times do |i|
		V[i] = false
	end
	count = count + 1 if match(x)
end
#p PY
p count

Measured memory_bytes: 8964
s = input()
K = int(input())
subs = []
for i in range(0, len(s)):
    for j in range(i + 1, K + i + 1 if i + K <= len(s) else len(s) + 1):
        subs.append(s[i:j])


subs = list(set(subs))

subs.sort()
print(subs[K - 1])


Measured memory_bytes: 5068
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

	final long MODULO = 1_000_000_000 + 7;

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long l = 0;
		long u = Long.MAX_VALUE / 10;
		while (u - l > 1) {
			long m = (l + u) / 2;
			if (f(a, m) < 0) {
				l = m;
			} else {
				u = m;
			}
		}
		for (long i = Math.max(0, u - 1000); i <= u + 1000; ++i) {
			if (f(a, i) == 0) {
				System.out.println(i);
				return;
			}
		}
	}

	long f(long[] a, long k) {
		int n = a.length;
		long s = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] + k <= n - 1) {
				continue;
			} else {
				long res = a[i] + k - (n - 1);
				s += (res + n) / (n + 1);
			}
		}
		return k - s;

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 21844
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  if(a[2] > a[1] && a[1] > a[0]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1156
n = str(input())
m = []
for i in range(3):
    m.append(n[i])
    if m[i] == '1':
        m[i] = '9'
    elif m[i] == '9':
        m[i] = '1'
        
nstr = ""        
for i in range(3):
    nstr += m[i]
    
print(nstr)

Measured memory_bytes: 3060
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>

#include<deque>
#define pi 3.141592653589793238
#include<chrono>

#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
     //cin >> T;
    while (T--) {
       ll a ,b , c, d ,e;
       vector<ll> v(5);
       cin >> v[0]>> v[1] >> v[2] >> v[3] >> v[4];
       sort(v.begin(), v.end());
       ll ans = INF;
       do{
            ll sum = 0;
            for(i = 0; i < 5 ;i++){
                sum += v[i];
                if(i == 4){
                    break;
                }             
                sum += (10 - (v[i] % 10)) % 10;
                //cout << sum << endl;
                //cout << v[i] <<" ";
            }   
            //cout << endl;
            
            ans = min(ans, sum);
       }while(next_permutation(v.begin(), v.end()));
       cout << ans;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[102];
	scanf("%s", s);
	int i, x;
	x = 0;
	for (i = n - 1; i >= 0; i--)
	{
		if (s[i] == '(' && x > 0)
			x--;
		else if (s[i] == ')')
			x++;
	}
	for (i = 0; i < x; i++)
		printf("(");
	x = 0;
	for (i = 0; i < n; i++)
	{
		if (s[i] == ')' && x > 0)
			x--;
		else if (s[i] == '(')
			x++;
	}
	printf("%s", s);
	for (i = 0; i < x; i++)
		printf(")");
	printf("\n");
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;
  int cnt = 0;
  for(int i=0;i<SZ(s)/2;++i) {
    cnt += s[i] != s[SZ(s)-i-1];
  }
  cout << cnt << endl;

}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char a[20],s[5]={'Y','A','K','I'};
int main()
{
    scanf("%s",&a);
    if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[3])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	h := nextInt()
	a := nextInt()
	ans := h/a
	if h%a > 0 {
		ans++
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000000
int prime[MAX];
void seive()
{
    int i,j;
    prime[0]=prime[1]=1;
    for(i=4; i<MAX; i+=2)
    {
        prime[i]=1;
    }
    for(i=3; i*i<MAX; i+=2)
    {
        if(prime[i]==0)
        {
            for(j=i*i; j<MAX; j+=i)
                prime[j]=1;
        }
    }
}
int main()
{
    seive();
    int n,i;
    cin>>n;
    if(prime[n]==0)
        cout<<n<<endl;
    else
    {
        for(i=n+1;i<=1000000;i++)
        {
            if(prime[i]==0)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 39296
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	double a, b, c, d;
	while(cin >> a >> b >> c, a){

		d = sqrt(pow(min(a, min(b, c)), 2) + pow(a + b + c - min(a, min(b,c)) - max(a, max(b, c)), 2));
	
		int n;
		cin >> n;
		while(n--){
			int r;
			cin >> r;
			if(d < 2 * r)cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    int N;
    cin >> N;
    lld ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if((i % 2 == 0) && (a % 2 == 1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int x[4], y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];

	int dx = x[1] - x[0];
	int dy = y[1] - y[0];
	x[2] = x[1] - dy;
	y[2] = y[1] + dx;
	x[3] = x[2] - dx;
	y[3] = y[2] - dy;

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,M;
	cin>>N>>M;
	vector<int> a(N+2);
	rep(i,0,M) {
		int l,r;
		cin>>l>>r;
		a[l]++;
		a[r+1]--;
	}
	ll cur=0;
	int res=0;
	rep(i,1,N+1) {
		cur+=a[i];
		if (cur==M) res++;
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    vector<int> d(N + 1), p(N + 1, -1);
    vector<vector<int>> e(N + 1);
    for(int i = 0; i < A.size(); ++i) {
        e[A[i]].push_back(B[i]);
        d[B[i]]++;
    }
    queue<int> Q;
    for(int i = 1; i <= N; ++i) if(d[i] == 0) {
        p[i] = 0;
        Q.push(i);
    }
    while(!Q.empty()) {
        int v = Q.front(); Q.pop();
        for(auto a: e[v]) {
            d[a]--;
//            cerr << v << "->" << a << "," << d[a] << endl;
            if(d[a] == 0) {
                Q.push(a);
                p[a] = v;
            }
        }
    }
    for(int i = 1; i <= N; ++i) {
        cout << p[i] << endl;
    }
}

signed main(){
	ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N-1+M);
    std::vector<long long> B(N-1+M);
    for(int i = 0 ; i < N-1+M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
mt19937_64 gen (random_device{}());
ll rint(ll a, ll b) { // generate rand int in [a, b]
    return a + gen() % (b - a + 1);
}

const int N = 2e5+9;
pair<int, int> a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    for(int i = 1; i <= n+n; i++) {
        cin >> a[i].first;
        a[i].second = (i > n);
    }
    sort(a+1, a+n+n+1);

    long long ans = 1, bal = 0;
    for(int i = 1; i <= n+n; i++) {
        if(a[i].second == 0) {
            if(bal < 0) ans = ans * (-bal) % mod;
            bal++;
        } else {
            if(bal > 0) ans = ans * bal % mod;
            bal--;
        }
    }
    cout << ans << "\n";







    return 0;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include <map>
#include <cstdio>

using namespace std;

long long nCr(int n, int r)
{
        if ( r > n ) return 0;
        if ( r * 2 > n ) r = n - r;
        if ( r == 0 ) return 1;

        long long result = n;
        for ( int i = 2; i <= r; ++i ) {
                result *= (n - i + 1);
                result /= i;
        }
        return result;
}


int main(){
  int n;
  cin >> n;
  string s;
  map<string, int> mp;
  for ( int i = 0; i < n; i++){
    cin >> s;
    vector<char> v;
    string str = "";
    for ( int i = 0; i < s.length(); i++){ v.push_back(s[i]); }
    sort(v.begin(), v.end());
    for ( int i = 0; i < s.length(); i++){ str += v[i]; }
    mp[str] += 1;
  }

  long long sum = 0;
  for(map<string, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
    sum += nCr(itr->second, 2);
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 12800
#![allow(unused_imports, dead_code, unused_variables, unused_mut)]
use std::cmp;
use std::mem::swap;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use permutohedron::LexicalPermutation;
use text_io::{read, scan};
use proconio::input;
const INF: i32 = std::i32::MAX;
const MOD: i32 = 1e9 as i32 + 7;

fn main() {
    input! {n: String}

    let n: Vec<char> = n.chars().collect();

    let mut sum = 0;
    for elem in n {
        sum += elem as i32 - '0' as i32;
    }

    println!("{}", if sum % 9 == 0 {"Yes"} else {"No"});
}

Measured memory_bytes: 3236
n = int(input())
t = [int(x) for x in input().split()]
sum_t = sum(t)
sum_list = []

for i in range(int(input())):
    p, x = [int(x) for x in input().split()]
    sum_list.append(sum_t + x - t[p - 1])

for s in sum_list:
    print(s)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

int main() {
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int Max =0;
  int an =0;
  /*
  for(int i=0;i<n;i++){
    if(i!=n-1){
      Max = max(k-a[i],a[i+1]-a[i]);
    }
    else{
      Max = max(k-a[i],a[0]-a[i]);
    }

    if(an < Max)
    an = max(Max,an);
  }
  */
  int a1,a2;
  for(int i=0;i<n;i++){
    if(i!=n-1 && i!=0){
      a1 = a[i+1]-a[i];
      a2 = a[i]-a[i-1];
      if(a1<0) a1 += k;
      if(a2<0) a2 += k;
      Max = max(a1,a2);
    }
    else{
      if(i==0){
	a1 = a[i+1]-a[i];
	a2 = a[i]-a[n-1];
	if(a1<0) a1 += k;
	if(a2<0) a2 += k;
	Max = max(a1,a2);
      }
      if(i==n-1){
	a1 = a[0]-a[i];
	a2 = a[i]-a[n-1];
	if(a1<0) a1 += k;
	if(a2<0) a2 += k;
	Max = max(a1,a2);
      }
    }
    
    an = max(Max,an);
  }
  cout<<k-an<<endl;

  return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int N;cin>>N;
    int C;cin>>C;

    vector<VPII> r(C);

    REP(i,N){
        int s,t,c;cin>>s>>t>>c;
        c--;
        r[c].PB(MP(s,t));
    }

    VPII ra;
    REP(i,C){
        SORT_ASC(r[i]);
        REP(j,SIZE(r[i])){
            
            if(j != SIZE(r[i])-1 && (r[i][j].second+1 >= r[i][j+1].first)){
                r[i][j+1].first = r[i][j].first;
                r[i][j].first = 0;
                r[i][j].second = 0;
            }
            

            ra.PB(r[i][j]);
        }
    }
    SORT_ASC(ra);
    VI lcs(C);

    REP(i,N){
        if(ra[i].first == 0){
            continue;
        }
        //dump(i)
        //dump(ra[i].first)
        //dump(ra[i].second)
        REP(j,C){
            if(lcs[j] < ra[i].first){
                lcs[j] = ra[i].second;
                break;
            }
        }
        sort(ALL(lcs), greater<int>());
        //REP(j,C){
        //    cerr<<lcs[j]<<" ";
        //}
        //cerr<<endl;


        /*
        auto itr = upper_bound(ALL(lcs), ra[i].first);
        dump(itr-lcs.begin())
        *(itr-1) = ra[i].second;
        SORT_ASC(lcs);
        */
    }


    int t=0;
    for(;t<C;t++){
        if(lcs[t] == 0){
            break;
        }
    }
    cout<<t<<endl;

    


	return;
}

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

Measured memory_bytes: 2552
from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n, q = map(int, input().split())
    s = input()

    # Cumulative Sum
    cs = [0] * n
    for i in range(1, n):
        if s[i-1] == 'A' and s[i] == 'C':
            cs[i] = cs[i-1] + 1
        else:
            cs[i] = cs[i-1]

    ans = [0] * q
    for lap in range(q):
        l, r = map(int, input().split())
        ans[lap] = cs[r-1] - cs[l-1]

    for i in ans:
        print(i)

main()

Measured memory_bytes: 77476
#include<bits/stdc++.h>
#define M 1000005
#define P 998244353
#define LL long long
using namespace std;
struct node {
	int x,y;
} s[M];
bool cmpx(node A,node B) {
	return A.x<B.x;
}
bool cmpy(node A,node B) {
	return A.y<B.y;
}
int F2[M];
void Add(LL &x,int y) {
	x+=y;
	if(x<0)x+=P;
	if(x>=P)x-=P;
}
int X[M],n;
struct BIT {
	int C[M];
	void clear() {
		for(int i=1; i<=n; i++)C[i]=0;
	}
	void Add(int x) {
		while(x<=n) {
			C[x]++;
			x+=x&-x;
		}
	}
	int Query(int x) {
		int res=0;
		while(x>0) {
			res+=C[x];
			x-=x&-x;
		}
		return res;
	}
} bit;
int main() {
	cin>>n;
	F2[0]=1;
	for(int i=1; i<=n; i++)F2[i]=F2[i-1]*2%P;
	for(int i=0; i<n; i++) {
		scanf("%d %d",&s[i].x,&s[i].y);
		X[i]=s[i].x;
	}
	sort(X,X+n);
	for(int i=0; i<n; i++)s[i].x=lower_bound(X,X+n,s[i].x)-X+1;
	LL ans=1LL*n*(F2[n]-1)%P;
	for(int i=0; i<n; i++) {
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1));
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1));
	}
	sort(s,s+n,cmpy);
	for(int i=0; i<n; i++) {
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,<y
		Add(ans,F2[i-bit.Query(s[i].x)]-1);//>x,<y
		bit.Add(s[i].x);
	}
	bit.clear();
	for(int i=n-1; i>=0; i--) {
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,>y
		Add(ans,F2[n-1-i-bit.Query(s[i].x)]-1);//>x,>y;
		bit.Add(s[i].x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13312
n = gets.to_i
min = last = gets.to_i
profits = []
(n-1).times{
  current = gets.to_i
  catch(:next) do
    if (current <= min)
      profits<<(current-last) if (profits.bsearch{|i| i >= 0} == nil)
      min = current if (current < min)
      throw :next
    end
    profits<<(current-min) if (current > last)
  end
  last = current
}
puts profits.max

Measured memory_bytes: 9744
s = input()
n = len(s) - 1
ans = 0

for i in range(2 ** n):
    op = [""] * n
    for j in range(n):
        if((i >> j) & 1):
            op[n - 1 - j] = "+"

    fomula = ""
    for value, operator in zip(s, op + [""]):
        fomula += (value + operator)

    ans += eval(fomula)

print(ans)


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

int main() {
  long N;
  cin >> N;
  char C;
  map<char, long> MA;
  while (cin >> C) MA[C]++;
  long ans = 1;
  for (auto ma : MA) (ans *= (ma.second + 1)) %= 1000000007;
  cout << ans - 1 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int a[N],b[N],q[N],n,w,h,Y,ans;
struct node{int x,y;}p[N];
bool cmp(node a,node b){return a.x<b.x;}
void solve(int l,int r){
    if (l==r) return;
    int mid=(l+r)>>1;
    for (int i=mid,y1=0,y2=h;i>=l;i--){
        a[i]=y1;b[i]=y2;
        if (p[i].y>=Y) y2=min(y2,p[i].y);
        if (p[i].y<=Y) y1=max(y1,p[i].y);
    }
    for (int i=mid+1,y1=0,y2=h;i<=r;i++){
        a[i]=y1;b[i]=y2;
        if (p[i].y>=Y) y2=min(y2,p[i].y);
        if (p[i].y<=Y) y1=max(y1,p[i].y);
    }
    for (int i=mid,j=mid+1,h=1,t=0;i>=l;i--){
        for (;j<=r && a[j]<=a[i];j++){
            for (;h<=t && b[q[t]]+p[q[t]].x<=b[j]+p[j].x;t--);
            q[++t]=j;
        }
        for (;h<t && b[i]+p[q[h]].x<=b[q[h+1]]+p[q[h+1]].x;h++);
        ans=max(ans,(p[q[h]].x-p[i].x+min(b[i],b[q[h]])-a[i])*2);
    }
    for (int i=mid+1,j=mid,h=1,t=0;i<=r;i++){
        for (;j>=l && a[j]<=a[i];j--){
            for (;h<=t && b[q[t]]-p[q[t]].x<=b[j]-p[j].x;t--);
            q[++t]=j;
        }
        for (;h<t && b[i]-p[q[h]].x<=b[q[h+1]]-p[q[h+1]].x;h++);
        ans=max(ans,(p[i].x-p[q[h]].x+min(b[i],b[q[h]])-a[i])*2);
    }
    solve(l,mid);solve(mid+1,r);
}
void work(){
    sort(p+1,p+n+1,cmp);
    Y=h/2;
    p[0].x=0;p[n+1].x=w;
    p[0].y=p[n+1].y=Y;
    solve(0,n+1);
}
int main(){
    scanf("%d%d%d",&w,&h,&n);
    for (int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
    ans=max(h,w)*2+2;
    work();
    swap(w,h);
    for (int i=1;i<=n;i++) swap(p[i].x,p[i].y);
    work();
    printf("%d\n",ans);
}

Measured memory_bytes: 6144
import java.util.Scanner;
import java.lang.Math;

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

    for(int i = 1;i <= n + 1;i++){
      sum += Math.abs(a[i-1] - a[i]);
    }

    for(int i = 1;i < n + 1;i++){
      nsum[i-1] = sum + Math.abs(a[i-1] - a[i+1]) - (Math.abs(a[i-1] - a[i]) + Math.abs(a[i] - a[i+1]));
      System.out.println(nsum[i-1]);
    }
  }
}

Measured memory_bytes: 72224
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,w,d;
	cin >> h >> w >> d;
	if(d % 2){
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if((i + j) % 2) cout << "R";
				else cout << "B";
			}
			cout << endl;
		}
	}else{
		string moji = {"RGBY"};
		char field[1010][1010];
		for(int i = 0;i < h + w + 1;i++){
			for(int j = 0;j < h + w + 1;j++){
				int x = (i / (d / 2)) % 2,y = (j / (d / 2)) % 2;
				field[i][j] = moji[x * 2 + y];
			}
		}
		for(int i = 0;i < h;i++) {
			for(int j = 0;j < w;j++){
				int x = i + j,y = i - j + w;
				cout << field[x / 2][y / 2];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;
int long long ll;

int main() {

    int long long n,ans=0;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    rep(i,n){
        while(x[i]%2==0) {
            x[i] = x[i]/2;
            ans += 1;
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
D = sorted([a - b for a, b in zip(A, B)], reverse=True)
D_orig = D[:]
l = 0
r = N - 1
while D[r] < 0:
    if D[l] + D[r] >= 0:
        D[l] += D[r]
        D[r] = 0
        r -= 1
    else:
        D[r] += D[l]
        D[l] = 0
        l += 1
print(N - sum([d == o for d, o in zip(D, D_orig)]))


Measured memory_bytes: 19508
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n+1, 0);
    rep(i, n){
        cin >> a.at(i);
    }

    ll maxr = 0;
    vector<ll> b(n+1, 0);
    rep(i,n){
        maxr = max(a.at(n-i), maxr);
        b.at(n-i-1) = maxr;
    }
    ll maxd = 0;
    rep(i, n){
        maxd = max(maxd, b.at(i)-a.at(i));
    }

    ll tmp = -1;
    ll cnt = 0;
    rep(i, n){
        if(maxd == b.at(i)-a.at(i)){
            if(tmp!=-1){
                if(maxd==a.at(i)-a.at(tmp)){
                    cnt--;
                }
            }
            
            cnt++;
            tmp = i;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;

    int n;
    cin>>n;
    
    vector<int> sex(n,-1);
    cout<<0<<endl;
    cin>>s;
    if(s[0]=='M')sex[0] = 1;
    else if(s[0]=='F')sex[0] = 0;
    else return 0;
    
    int l = 0, r = n;
    while(1){
        if(r-l==2){
            cout<<l+1<<endl;
            cin>>s;
            return 0;
        }
        int mid = (l+r)/2;
        if(mid%2!=l%2)mid++;
        cout<<mid<<endl;
        
        cin>>s;
        if(s[0]=='M')sex[mid] = 1;
        else if(s[0]=='F')sex[mid] = 0;
        else return 0;

        if(sex[l]==sex[mid])l = mid;
        else                r = mid;
    }
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  char b;
  cin >> b;

  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else if(b == 'G') cout << 'C' << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int a,b; cin>>a>>b;
	int na,nb;

	if(a<2) na=0;
	else    na=nCr(a,2);

	if(b<2) nb=0;
	else    nb=nCr(b,2);

	cout<<na+nb<<endl;
}


Measured memory_bytes: 256
S=list(str(input()))

N=len(S)

S_left=[S[i] for i in range((N-1)//2)]
S_right=[S[i] for i in range((N+2)//2,N)]

def kaibun(X):
    count=0
    for i in range(len(X)//2):
        if S[i]==S[len(X)-1-i]:
            count+=1
    if count==len(X)//2:
        return 1
    else:
        return 0
        
print("Yes" if kaibun(S)*kaibun(S_left)*kaibun(S_right)==1 else "No")       

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  LL ans = 0;
  REP(i, n) {
    FOR(j, i + 1, n) {
      ans += v[i] * v[j];
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) {}
#define eprintf(...) do {} while(0)
#endif

template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename T>
ostream& operator << (ostream& out, const vector<T> &v) {
	int n = v.size();
	out << "{";
	for(int i = 0; i < n; ++i) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "}";
}
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &v) {
	return out << "(" << v.first << ", " << v.second << ")";
}

typedef long long LL;

vector<string> ans;
char tmp[1000];
long long a[200000 + 5];
void compare(int i, int j, int k) {
	sprintf(tmp, "< %d %d %d", i, j, k);
	a[k] = (a[i] < a[j]);
	ans.push_back(tmp);
}
void add(int i, int j, int k) {
	sprintf(tmp, "+ %d %d %d", i, j, k);
	a[k] = a[i] + a[j];
	assert(a[k] < 2e18);
	ans.push_back(tmp);
}

int one, zero, cnt;
int getand(int i, int j) {
	add(i, j, cnt + 1);
	compare(one, cnt + 1, cnt + 2);
	assert(a[cnt + 2] == (a[i] && a[j]));
	return cnt += 2;
}
int roll(int i, int k) { // return 2^k * a[i]
	int ori = i;
	for(int t = 0; t < k; ++t) {
		add(i, i, ++cnt);
		i = cnt;
	}
	assert(a[i] == (a[ori] << k));
	return i;
}

int main() {
	// a[0], a[1], a[2]
	// the following also works for A = B = 0

	a[0] = 998244353; a[1] = 19260817;
	compare(2, 0, 3);
	compare(2, 1, 4);
	add(3, 4, 5);
	compare(6, 5, 7);
	one = 7;
	zero = 6;
	display(a[zero]);
	display(a[one]);

	cnt = 7;

	int x = ++cnt, y = ++cnt;

	add(0, one, 0);
	add(1, one, 1);

	display(a[0]); display(a[1]);
	for(int i = 29; i >= 0; --i) {
		int twoi = roll(one, i);
		int p1 = ++cnt, p3 = ++cnt;
		add(x, twoi, p1);
		compare(p1, 0, p3);

		add(zero, zero, y);
		for(int j = 29; j >= 0; --j) {
			int twoj = roll(one, j);
			int p2 = ++cnt, p4 = ++cnt;
			add(y, twoj, p2);
			compare(p2, 1, p4);

			int logic = getand(p3, p4);
			// display(a[p3]);
			// display(a[p4]);
			// display(a[logic]);
			add(2, roll(logic, i + j), 2);
			
			add(y, roll(p4, j), y);
		}
		add(x, roll(p3, i), x);
	}
	display(a[2]);

	printf("%d\n", (int)ans.size());
	for(auto &s : ans) printf("%s\n", s.c_str());
	return 0;
}


Measured memory_bytes: 7100
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0351

#include<bits/stdc++.h>
const int N = 1505;
const int inf = 1e9;
using namespace std;

typedef pair <int, int> ii;
vector <ii> adj[N];
int n, m, d[N][N], ans, visit[N], f[N], ck[N];

void dijkstra(int S){
    for (int i = 1; i <= n; i++) d[S][i] = inf; d[S][S] = 0;
    priority_queue <ii, vector <ii>, greater<ii> > mq; mq.push(ii(d[S][S], S));
    while (mq.size()){
        ii z = mq.top(); mq.pop();
        int u = z.second, val = z.first;
        if (val != d[S][u]) continue;
        ans = max(ans, val);
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first, cost = adj[u][i].second;
            if (d[S][v] > d[S][u] + cost){
                d[S][v] = d[S][u] + cost;
                mq.push(ii(d[S][v], v));
            }
        }
    }
}

void dfs(int u, int root){
    if (visit[u]) return;
    visit[u] = true;
    f[u] = d[root][u];
    for (int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i].first, cost = adj[u][i].second;
        if (d[root][v] == d[root][u] + cost){
            dfs(v, root); f[u] = max(f[u], f[v]);
        }
    }
    if (f[u] == ans) ck[u] = 1;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v, d; cin >> u >> v >> d;
        adj[u].push_back(ii(v, d));
        adj[v].push_back(ii(u, d));
    }
    for (int i = 1; i <= n; i++) dijkstra(i);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) visit[j] = 0;
        dfs(i, i);
    }
    int cnt = 0; for (int i = 1; i <= n; i++) if (!ck[i]) cnt++;
    cout << cnt << "\n";
    for (int i = 1; i <= n; i++) if (!ck[i]) cout << i << "\n";
}



Measured memory_bytes: 12148
s = input()
li = ["A","T","C","G"]

cnt = 0
cntli = []
for i in range(len(s)):
    if s[i] in li:
        cnt += 1
    else:
        cntli.append(cnt)
        cnt = 0
else:
    cntli.append(cnt)

print(max(cntli))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[1032];
    char t[1032];
    Scs(s);
    Scs(t);

    int N = strlen(s);
    int M = strlen(t);

    ll mod = 1000000007;
    static ll dp[1023][1023] = {};
    dp[0][0] = 1;

    Rep(i,N){
        Rep(j,M){
            if( s[i] == t[j] ){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= mod;
            }
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
        }
        dp[i+1][M] += dp[i][M];
        dp[i+1][M] %= mod;
    }

    printf("%llu\n", dp[N][M] );


    return 0;
}




Measured memory_bytes: 11108
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long
#define endl '\n'

const int N = 200005;


signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#define double long double
	int n;
	double a;
	cin >> n;
	double low = 0.0;
	for(int i = 1 ; i <= n ; i ++){
		cin >> a;
		low += (1/a);
	}
	cout << setprecision(10) << 1/low;
		
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

typedef pair<int, int> pii;

bool compare(pii &a, pii &b) {
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}

void solve() {
    int N;
    cin >> N;
    vector<pii> vec(N), right(N);
    REP(i, N) {
        cin >> vec[i].first >> vec[i].second;
    }
    
    REP(i, N) {
        right[i].first = vec[i].first + vec[i].second;
        right[i].second = vec[i].second;
    }
    
    sort(right.begin(), right.end(), compare);


    ll ans = N;
    ll prev = right[0].first;
    for (int i = 1; i < N; i++) {
        if (prev > right[i].first - 2LL * right[i].second) {
            ans--;
        } else {
            prev = right[i].first;
        }
    }
    print(ans);

}

signed main() {
    solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define M 1000000007
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 1000005
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     freopen("input.txt","r",stdin); freopen("output.txt","w", stdout);
#define PI 3.1415926535
#define INF LLONG_MAX-5
using namespace std;
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}
int lcm(int a, int b){
    int g = __gcd(a,b);
    return (a/g)*b;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int divc = b/c - (a-1)/c;
        int divd = b/d - (a-1)/d;
        int divcandd = b/lcm(c,d) - (a-1)/lcm(c,d);
        cout<<b-a+1 - divc-divd + divcandd;
    }   
}   

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cassert>
#include <unordered_map>
#include <numeric>

using namespace std;


class Solution{

private:
    const int MOD = 1e9 + 7;
    int N, X, Y, Z;
    vector<vector<int>> dp;
    int pattern;

public:
    int num(int N, int X, int Y, int Z){

        this->N = N, this->X = X, this->Y = Y, this->Z = Z;
        pattern = (1 << (Z - 1)) + (1 << (Y + Z - 1)) + (1 << (X + Y + Z - 1));

        long long res = 1ll;
        for(int i = 0; i < N; i ++) res *= 10ll, res %= MOD;

        dp = vector<vector<int>>(N, vector<int>(1 << (X + Y + Z), -1));
        res -= go(0, 0);
        if(res < 0) res += MOD;
        return res;
    }

private:
    int go(int index, int state){

        if(index == N) return 1;
        if(dp[index][state] != -1) return dp[index][state];

        int res = 0;
        for(int i = 1; i <= 10; i ++){
            int nextstate = ((state << i) + (1 << (i - 1))) & ((1 << (X + Y + Z)) - 1);
            if((nextstate & pattern) != pattern)
                res += go(index + 1, nextstate), res %= MOD;
        }
        return dp[index][state] = res;
    }
};

int main() {

//    printf("%d\n", Solution().num(3, 5, 7, 5));
//    // 1
//
//    printf("%d\n", Solution().num(4, 5, 7, 5));
//    // 34
//
//    printf("%d\n", Solution().num(37, 4, 2, 3));
//    // 863912418
//
//    printf("%d\n", Solution().num(40, 5, 7, 5));
//    // 562805100

    int N, X, Y, Z;
    scanf("%d%d%d%d", &N, &X, &Y, &Z);
    printf("%d\n", Solution().num(N, X, Y, Z));

    return 0;
}


Measured memory_bytes: 23972
#include<iostream>
#include<cstdio>
#include<algorithm>
int num[100000],a[100000],cou=1,buf,l,ma;
//bool b[100000];
using namespace std;
int main(){
    for(;;){
        int n,k,c=0,d=0;
        ma=0,buf=0,l=0,ma=0;
        bool b[100000]={false};
        cin>>n>>k;
        if(n==0&&k==0)break;
        fill(num,num+k,0);
        fill(a,a+k,0);
        for(int i=0;i<k;i++)b[i]=false;
        for(int i=0;i<k;i++)cin>>num[i];
        sort(num,num+k);
        l=1;
        if(num[0]==0){
            buf=1;
            l=2;
        }
        for(int i=l;i<k+1;i++){
//            if(num[i]==0)break;
            if(num[i]==num[i-1]+1){
                cou++;
                continue;
            }
            else{
                a[c]=cou;
                c++;
                a[c]=num[i]-num[i-1];
                c++;
            }
            cou=1;
        }
        for(int i=0;i<k;i++){
            if(i%2==1){
                if(a[i]==2)b[i]=true;
            }
        }
//        for(int i=0;i<k;i++)cout<<a[i]<<" ";
        ma=a[0];
        for(int i=1;i<k;i++){
            if(buf==1){
                if(b[i]){
                    ma=max(ma,a[i-1]+1+a[i+1]);
                    continue;
                }
            }
            if(i%2!=1)ma=max(ma,a[i]);
        }
        //for(int i=0;i<k;i++)cout<<a[i]<<" ";
        cout<<ma<<endl;
    }
return 0;
}

Measured memory_bytes: 1908
#include <stdio.h>

typedef struct process{
    char name[11];
    int time;
}process;

typedef struct Que{
    int rear;
    int front;
    int num;
    int max;
    process list[100001]
} que;

que que1={0,0,0,100000};
int qms;
int sum;

void enq(que *a,process x){
    a->num++;
    a->list[a->rear]=x;
    a->rear++;
    if((a->rear)>(a->max))a->rear=0;
}

void deq(que *a) {
    a->num--;
    process q = a->list[a->front];
    a->front++;
    if ((a->front) > (a->max))a->front = 0;

    process *x;
    x= &q;
    int now = 0;
    now = (x->time) - qms;
    if (now > 0) {
        x->time = now;
        sum+=qms;
        enq(&que1,q);
    }else{sum+=x->time;printf("%s %d\n",(x->name),sum);}

    return ;
}


int main() {
    int i, n;
    scanf("%d %d", &n, &qms);
    for (i = 0; i < n; i++) {
        scanf("%s %d", ((que1.list[i]).name), &((que1.list[i]).time));

        enq(&que1, (que1.list[i]));
    }

    while (que1.num > 0) {
        deq(&que1);
    }
    return 0;
}



Measured memory_bytes: 3360