akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int num[n];
    int count = 0;
    int a = 0;
    int check[n];
    for(int i = 0; i < n; i++){
        cin >> num[i];
        if(num[i]%2==0){
            check[a]=num[i]; a++;
        }
    }
    int ans = 0;
    for(int i = 0; i < a; i++){
        while(check[i]%2==0){
            check[i]/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
#include <set>
using namespace std;

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

#define max_n 100

int N;
int A[1000];

int main() {

	cin >> N;

	double ans = 0.0;

	rep(i, N){
		int j = 0;
		cin >> j;
		ans += 1.0 / j;
	}

	printf("%f\n", 1.0/ans);

	return 0;	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, T: int, A: int, H: "List[int]"):
    print(1 + min(range(N), key=lambda i: abs(T - H[i] * 0.006 - A)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, T, A, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

char  g[1005][1005] ; 
int  cost[1005][1005] ; 
int  dx[4] = {1, -1, 0, 0} ; 
int  dy[4] = {0, 0, 1, -1} ; 
int  r, c, fx, fy, lx, ly ; 

bool ok(int i,int j){
    if (i<1 or i>r or j<1 or j>c or g[i][j] == '#') return false;
    return true;
}

inline void solve(){ 
    cin >> r >> c >> fx >> fy >> lx >> ly ; 
    for (int i=1;i<=r;i++) {
        cin >> (g[i]+1) ; 
        fill(cost[i],cost[i]+1005,1000000);
    }
    deque <pii> q; 
    q.push_back({fx,fy}) ; 
    cost[fx][fy] = 0 ; 
    while (q.size()){ 
        int  x = q.front().ff ; 
        int  y = q.front().ss ; 
        q.pop_front() ; 
        for (int t=0;t<4;t++) { 
            int i = x + dx[t] ; 
            int j = y + dy[t] ; 
            if (cost[i][j] <= cost[x][y])  continue ; 
            if (ok(i,j)) {
                q.push_front({i,j}) ; 
                cost[i][j] = cost[x][y] ; 
            }
        }
        for (int i=max(1LL,x-2);i<=min(r,x+2);i++){
            for (int j=max(1LL,y-2);j<=min(c,y+2);j++){
                if ((i == x and j == y) or ( cost[i][j] <= cost[x][y]+1 )) continue;
                if (ok(i,j)){
                    cost[i][j] = cost[x][y]+1 ; 
                    q.push_back({i,j}); 
                }
            }
        }
    }
    if (cost[lx][ly] != 1000000LL) co(cost[lx][ly]) ; 
    else co(-1) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n, k; cin >> n >> k;
    ll ans = 0;

    for(int b = k + 1; b <= n; b++) {
        ll cur = n / b * (b - k);
        cur += max((n % b) - max(0,(k - 1)) , 0);
        ans += cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


		while(true) {
		int H = sc.nextInt();
		int W = sc.nextInt();

		if(H==0&&W==0) {
			break;
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					System.out.print("#");
				} else {
					System.out.print(".");
				}
			}
			System.out.println();
		}
		System.out.printf("%n");
		}

	}
}


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

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<char> = itr.next().unwrap().chars().collect();

    // iより左のWの数 + jより右のEの数

    let mut l: Vec<usize> = vec![0; n + 1];
    let mut r: Vec<usize> = vec![0; n + 1];

    for i in 0..n {
        l[i + 1] = l[i] + (a[i] == 'W') as usize;
    }
    for i in (1..n).rev() {
        r[i - 1] = r[i] + (a[i] == 'E') as usize;
    }

    let mut ans = 500000;
    for i in 0..n {
        ans = std::cmp::min(ans, l[i] + r[i]);
    }
    println!("{}", ans);
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n,k;
    vector<int> h(100010,0);
    vector<ll> dp(100010,INT64_MAX);
    cin >> n >> k;
    for (int i = 0;i < n;++i) cin >> h[i];
    dp[0] = 0;
    for (int i = 1;i < n;++i) for (int j = max(0,i-k);j < i;++j) dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    cout << dp[n-1] << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000
#define MAXB 40



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int hoge[MAXB+2] = {}, fuga[MAXB+2] = {};
	int t = 1ll<<MAXB, ans = 0;
	int N, K, num;
	
	cin>>N>>K;
	
	rep(i,N){
		cin>>num;
		for(int i = 0; num; i++,num >>= 1)if(num%2)hoge[i]++;
	}
	

	
	for(int i = 0, r = 1; i <= MAXB; i++, r <<= 1){
		fuga[i] += max(hoge[i],N-hoge[i])*r;
		fuga[i+1] += fuga[i];
	}
		
	for(int i = MAXB, temp = 0; i >= 0; i--, t>>=1){
		if((K>>i)&1){
			if(i)ans = max(ans,temp+fuga[i-1]+hoge[i]*t);
			temp += (N-hoge[i])*t;
		} else temp += hoge[i]*t;
		if(!i) ans = max(ans,temp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>

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

using namespace std;

int main()
{
    int N,a[200010],all;
    cin>>N;
    rep(i,N){
        cin>>a[i];
    }

    all=a[0];
    for(int i=1;i<N;i++){
        all = all^a[i];
    }

    rep(i,N){
        int res = all^a[i];
        cout << res << " ";
    }
    cout << endl;



    return 0;
}

Measured memory_bytes: 4376
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String word1 = sc.next();
		String ans = "Yes";
		Set<String> set = new HashSet<>();
		set.add(word1);
		char tale = word1.charAt(word1.length() - 1);

		for (int i = 0; i < n - 1; i++) {
			String str = sc.next();
			if (set.contains(str) || str.charAt(0) != tale) {
				ans = "No";
				break;
			}
			set.add(str);
			tale = str.charAt(str.length() - 1);
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i,k) cin >> l[i] >> r[i];
    vector<ll> dp(n+1), dpsum(n+1);
    dp[1] = 1, dpsum[1] = 1;
    for (int i = 2; i <= n; ++i) {
        rep(j,k) {
            int li = i-r[j];
            int ri = i-l[j];
            if (ri < 0) continue;
            li = max(li, 1);
            dp[i] += dpsum[ri] - dpsum[li-1];
            dp[i] %= MOD;
        }
        dpsum[i] = dpsum[i-1] + dp[i];
    }
    cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
#define ll long long
#define  ul unsigned long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a)        for(int i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(int i = a ; i < b ; i++)
#define bac(i,a)        for(int i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define vi vector< int >
#define vl vector< ll >
#define pb push_back

void solve()
{
    int n;
    cin>>n;
    int H[n+1];
    repe(i,1,n+1)
    cin>>H[i];
    ll dp[n+1];
    // minimum cost when n = 1 is 30 dp[1] = 30
    // minimum cost when n = 2 is |30-10| dp[2] = 20
    // minimum cost when n = 3 is min(|30-10|+|60-10|,|30-60|) dp[3] = min(dp[i-1]+|H[i] - H[i-1]|, |H[i]-H[i-2]|) = 30
    // minimum cost when n = 4 is min(dp[i-1]+abs(H[i]-H[i-1], dp[i-2]+abs(H[i]-H[i-2]) dp[4] = 20
    // minimum cost when n = 5 is min(dp[4]+abs(60-10) , dp[3]+abs(60-60)) dp[5] = 30
    // minimum cost when n = 6 is min(dp[5]+abs(60-50) , dp[4]+abs(10-60) dp[6] = 40
    if(n == 1)
    {
        cout<<H[n];
        return;
    }
    if(n == 2)
    {
        cout<<abs(H[2]-H[1]);
        return;
    }
    if(n == 3)
    {
        cout<<abs(H[3]-H[1]);
        return;
    }
    dp[1] = H[1];
    dp[2] = abs(H[2]-H[1]);
    dp[3] = abs(H[3]-H[1]);
    for(int i = 4;i<=n;i++)
    {
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
    }
    cout<<dp[n];
}
int main()
{
    fastio
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 4676
N, A, B = map(int, input().split())
ans = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x = x//10

    return count

for n in range(1, N+1):
    count = FindSumOfDigits(n)
    if A<= count <=B:
        ans += n

print(ans) 

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int N, K, C;
string S;
int num[200010];
int num2[200010];
int cnt2[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K >> C;
    cin >> S;
    
    int x = 0;
    int cnt = 0;
    while(x < N) {
        if (S[x] == 'o') {
            cnt++;
            num[x] = cnt;
            x += C + 1;
            
        } else x++;
    }
    if (cnt > K) return 0;
    rep(i, N) num[i + 1] = max(num[i], num[i + 1]);
    x = N - 1;
    cnt = 0;
    while(x >= 0) {
        if (S[x] == 'o') {
            
            cnt++;
            num2[x] = cnt;
            x -= C + 1;
            
        } else x--;
    }
    RREP(i, N - 1, 1) num2[i - 1] = max(num2[i], num2[i - 1]);
    // rep(i, N) cout << num[i];
    // cout << endl;
    // rep(i, N) cout << num[N - 1] - num2[i];
    // cout << endl;
    rep(i, N) {
        if (S[i] == 'o' && num[i] != num[N - 1] - num2[i]) cnt2[num[i]]++;
    }
    rep(i, N) {
        //cout << cnt2[num[i]];
        if(S[i] == 'o' && num[i] != num[N - 1] - num2[i]){
            if(cnt2[num[i]] == 1) {
                cout << i + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 4244
/*
      author : nishi5451
      created: 11.08.2020 21:45:28
*/

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


int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] -= 'A'-'a';
    cout << s << endl;
    return 0;
}

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

long long f(int);
long long dp[20000];

int n,m;
long long k;
long long a[20000];

int main(){
	int i;
	
	cin>>n>>m>>k;
	for(i=0;i<n;i++){
		dp[i]=-1;
		cin>>a[i];
	}
	
	cout<<f(0)<<endl;
	
	return 0;
}

long long f(int d){
	if(d==n) return 0;
	if(dp[d]!=-1) return dp[d];
	long long cost=-1;	//????°??????????
	long long tmp;	//????????????????????§????????????
	long long max=a[d],min=a[d];	//???????????¬??????????????????????????¬??????
	for(int i=1;i<=m;i++){
		
		if(d+i<=n){
			tmp=f(d+i);
		}else{
			break;
		}
		if(max<a[d+i-1]) max=a[d+i-1];
		if(min>a[d+i-1]) min=a[d+i-1];
		tmp+=k+i*(max-min);
		
		if(cost==-1 || tmp<cost) cost=tmp;
	}
	dp[d]=cost;return cost;
}

Measured memory_bytes: 3036
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int n = SZ(s);
    stack<int> st;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x = s[i] - '0';
        if(st.empty()){
            st.push(x);
        }else if(st.top() ^ x){
            st.pop();
            ans += 2;
        }else{
            st.push(x);
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 720
import java.util.Scanner;

class Dice{
	int[] dice = new int[7];
	
	void diceroll(char[] roll)
	{
		for(int i = 0;i < roll.length;i++)
		{
			int temp =0;
			if(roll[i] == 'N'){
				temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = temp;
			}else if(roll[i] == 'E'){
				temp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = temp;
			}else if(roll[i] == 'S'){
				temp = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = temp;
			}else if(roll[i] == 'W'){
				temp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'R'){
				temp = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'L'){
				temp = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}
		}
	}
	
	int Getdice(int num)
	{
		return dice[num];
	}
}

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		Dice dice = new Dice();
		
		for(int i = 1;i < 7;i++)
		{
			dice.dice[i] = scan.nextInt();
		}
		String roll = scan.next();

		dice.diceroll(roll.toCharArray());
		System.out.println(dice.Getdice(1));
	}
}

Measured memory_bytes: 17364
INF = float('inf')
N,M = map(int,input().split())
edge = []
d = [INF]*N
d[0] = 0
negative = [False for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,-c])

for i in range(N):
    for j in range(M):
        if d[edge[j][0]]==INF:
            continue
        d[edge[j][1]] = min(d[edge[j][1]],d[edge[j][0]]+edge[j][2])

ans = d[N-1]

for i in range(N):
    for j in range(M):
        if d[edge[j][0]]==INF:
            continue
        if d[edge[j][1]]>d[edge[j][0]]+edge[j][2]:
            d[edge[j][1]]=d[edge[j][0]]+edge[j][2]
            negative[edge[j][1]] = True
        if negative[edge[j][0]]:
            negative[edge[j][1]] = True
print('inf' if negative[N-1] else -ans)


Measured memory_bytes: 48216
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct SegTree{
	int size;
	vector<P> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = make_pair(inf, inf);
	}
	
	void update(int i, P val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	P query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return make_pair(inf, inf);
		if(a <= l && r <= b) return seg[k];
		P lval = query(a, b, k*2, l, (l+r)/2);
		P rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	P query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n, m;
string s;
SegTree seg(18);
llint succ[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	cin >> s;
	
	seg.init();
	seg.update(n, P(0, n));
	
	for(int i = n-1; i >= 0; i--){
		if(s[i] == '1'){
			seg.update(i, P(inf, i));
			continue;
		}
		P res = seg.query(i+1, i+m);
		seg.update(i, P(res.first+1, i));
		if(res.second < inf/2) succ[i] = res.second-i;
	}
	if(seg.query(0, 0).second > inf/2){
		cout << -1 << endl;
		return 0;
	}
	
	llint p = 0;
	while(p < n){
		cout << succ[p] << " ";
		p += succ[p];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 9680
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int T;
  std::cin >> T;
  while (T--) {
    long long A, B, C, D;
    std::cin >> A >> B >> C >> D;
    if (A < B || D < B) {
      std::cout << "No\n";
      continue;
    }
    if (C >= B) {
      std::cout << "Yes\n";
      continue;
    }
    A %= B;
    D %= B;
    long long G = std::__gcd(D, B);
    std::cout << ((B - 1 - A) / G * G + A > C ? "No" : "Yes") << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
	String sa[] = sc.next().split("");
    int count = 0;
    int max = 0;
    for (String s : sa) {
       if ("ACGT".indexOf(s) != -1) {
         count++;
       } else {
         count = 0; 
       }
       if (count >= max) { 
         max = count;
       }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int place(int x, int y);

int main (void)
{
	int x = 0;
	int y = 0;
	int cunt;
	
	cunt = place(x,y);
	
	return 0;
}
int place(int x, int y)
{
	while(scanf("%d %d",&x, &y)!=EOF)
	{
		int i,j;
		for(i = 0, j = 1;(x + y) / j;i++, j *= 10);
		{
	 		printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
#define reps(i,j,N) for(LL i=j;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;
 
int N, K, a[5112];
int ans;
 
int main()
{
	in >> N >> K;
	rep(i, N) { in >> a[i]; }
 
	LL sum;
	std::sort(a, a + N, std::greater<int>());
	rep(i, N)
	{
		sum = 0;
		reps(j, i, N)
		{
			sum += a[j];
			if (sum >= K)
			{
				ans = std::max<LL>(ans, j + 1);
				sum -= a[j];
			}
		}
	}
	ans = N - ans;
 
	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long int gcd(long int a,long int b){
    long int r,tmp;
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}



int main(void){
    long int a,b,c,d,lcm,ans;

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

    lcm = c * d / gcd(c,d);

    ans = b - b/c - b/d + b/lcm - ( (a-1) - (a-1)/c -(a-1)/d +(a-1)/lcm );

    printf("%ld",ans);

    return 0;
}

Measured memory_bytes: 128
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

class cake{
    public:
        ll i,j,k;
        ll v;
    cake(ll v,ll i,ll j,ll k){
        this->v = v;
        this->i = i;
        this->j = j;
        this->k = k;
    };
};

bool operator< (const cake &cake1, const cake &cake2){
    return cake1.v < cake2.v;
}

int main(){
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);

    REP(i,X){
        cin >> A[i];
    }
    REP(i,Y){
        cin >> B[i];
    }
    REP(i,Z){
        cin >> C[i];
    }

    SORTD(A);
    SORTD(B);
    SORTD(C);
    
    std::priority_queue<cake> q;
    q.push(cake(A[0]+B[0]+C[0],0,0,0));
    set<int> s;
    s.insert(0);

    //REP(i,X)REP(j,Y)REP(k,Z)idx[i][j][k]=0;
    

    REP(a,K){
        cake top = q.top();
        cout << top.v << endl;
        q.pop();

        if(top.i+1 < X){
            if( s.find(((top.i+1)<<20) + ((top.j)<<10) + top.k)==s.end() ){
                q.push(cake(A[top.i+1]+B[top.j]+C[top.k],top.i+1,top.j,top.k));
                s.insert(((top.i+1)<<20) + ((top.j)<<10) + top.k);
            }
        }
        if(top.j+1 < Y){
            if( s.find(((top.i)<<20) + ((top.j+1)<<10) + top.k)==s.end() ){
                q.push(cake(A[top.i]+B[top.j+1]+C[top.k],top.i,top.j+1,top.k));
                s.insert(((top.i)<<20) + ((top.j+1)<<10) + top.k);
            }
        }
        if(top.k+1 < Z){    
            if( s.find(((top.i)<<20) + ((top.j)<<10) + top.k+1 )==s.end() ){
                q.push(cake(A[top.i]+B[top.j]+C[top.k+1],top.i,top.j,top.k+1));
                s.insert(((top.i)<<20) + ((top.j)<<10) + top.k+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	ll z[n], w[n];
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		z[i] = x + y;
		w[i] = x - y;
	}
	sort(z, z + n);
	sort(w, w + n);
	cout << max(z[n - 1] - z[0], w[n - 1] - w[0]) << endl;
	return 0;
}

Measured memory_bytes: 6780
from sys import stdin
input = lambda : stdin.readline().strip()
ri = lambda : int(input())
ril = lambda : list(map(int, input().split()))

from collections import defaultdict

N = ri()
A = ril()
Q = ri()
s = sum(A)

d = defaultdict(int)
for a in A:
  d[a] += 1

ans = []
for i in range(Q):
  B, C = ril()
  s += (C - B) * d[B]
  d[C] += d[B]
  d[B] = 0
  ans.append(str(s))

print('\n'.join(ans))


Measured memory_bytes: 29384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;

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

ll dp[105][4][2];

int main()
{
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  dp[0][0][0] = 1;
  rep(i, n) rep(j, 4/*現在の非0個数*/) rep(x, 2) {
    int next = s[i] - '0';
    rep(m, 10) {
      int nonZero = j + (m != 0); /*次の非ゼロ個数*/
      if (nonZero > k) continue;/* 最大まで0でない数字があらわれているにもかかわらず0でない数字を選択しようとした */
      if (x == 0) {
        if (m > next) {
          continue;
        } else if (m == next) {
          dp[i+1][nonZero][0] += dp[i][j][x];
        } else {
          dp[i+1][nonZero][1] += dp[i][j][x];
        }
      } else {
        dp[i+1][nonZero][x] += dp[i][j][x];
      }
    }
  }

  cout << dp[n][k][0] + dp[n][k][1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
int main()
{
    ll n , a , b;
    cin >> n >> a >> b;
    ll res = ((n - 1) * b + a) - ((n - 1) * a + b) + 1;
    cout << max(res , 0LL);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i],ans+=b[i];
  rep(i,n-1) cin>>c[i];
  rep(i,n-1){
    if(a[i+1]-a[i]==1) ans+=c[a[i]-1];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){

    char s[12], t[12];
    scanf("%s", s);
    scanf("%s", t);


    int length = strlen(s), i;

    for (i=0; i<length; ++i){
        if(s[i]!=t[i]){
            printf("No");
            return 0;
        }
    }

    if(length+1==strlen(t)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


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

void sit_seat(char c, vector<char>& seat)
{
	if(c == 'A')
	{
		for(int i=0; i<seat.size(); i++)
		{
			if(seat[i] == 0)
			{
				seat[i] = c;
				break;
			}
		}
	}
	else if(c == 'B')
	{
		bool is_sit = false;
		for(int i=seat.size()-1; i>=0; i--)
		{
			if(seat[i] != 0) continue;

			int r = i+1;
			if(r>=0 && r<seat.size())
			{
				if(seat[r] == 'A') continue;
			}

			int l = i-1;
			if(l>=0 && l<seat.size())
			{
				if(seat[l] == 'A') continue;
			}

			seat[i] = c;
			is_sit = true;
			break;
		}

		if(!is_sit)
		{
			for(int i=0; i<seat.size(); i++)
			{
				if(seat[i] == 0) seat[i] = c;
			}
		}
	}
	else if(c == 'C')
	{
		bool is_sit = false;
		for(int i=0; i<seat.size(); i++)
		{
			if(seat[i] == 0) continue;

			int r = i + 1;
			if(r>=0 && r<seat.size())
			{
				if(seat[r] == 0)
				{
					seat[r] = c;
					is_sit = true;
					break;
				}
			}

			int l = i - 1;
			if(l>=0 && l<seat.size())
			{
				if(seat[l] == 0)
				{
					seat[l] = c;
					is_sit = true;
					break;
				}
			}
		}

		if(!is_sit)
		{
			if(seat.size() % 2 == 0)
			{
				seat[seat.size()/2] = c;
			}
			else
			{
				seat[(seat.size()-1)/2] = c;
			}
		}
	}
	else if(c == 'D')
	{
		bool is_people = false;
		for(int i=0; i<seat.size(); i++)
		{
			if(seat[i] != 0)
			{
				is_people = true;
				break;
			}
		}

		bool is_sit = false;
		if(!is_people)
		{
			seat[0] = c;
			is_sit = true;
		}

		if(!is_sit)
		{
			int mmd = 0;
			int p_sit = 0;
			for(int i=0; i<seat.size(); i++)
			{
				if(seat[i] != 0) continue;
				int r = i;
				while( 1 )
				{
					r++;
					if(r<0 || r>=seat.size())
					{
						r = 10000;
						break;
					}
					if(seat[r] != 0) break;
				}
				int rd = r - i;

				int l = i;
				while( 1 )
				{
					l--;
					if(l<0 || l>=seat.size())
					{
						l = -10000;
						break;
					}
					if(seat[l] != 0) break;
				}
				int ld = i - l;

				int d = min(rd, ld);
				if(mmd < d)
				{
					mmd = d;
					p_sit = i;
				}
			}
			
			seat[p_sit] = c;
		}
	}
	else
	{
		cout << "unknown nationality!" << endl;
		return;
	}
}

int main()
{
	int n, np;
	char c;
	while(cin >> n >> np, n|np)
	{
		vector<char> seat(n);
		memset(&seat[0], 0, sizeof(char)*n);

		for(int i=0; i<np; i++)
		{
			cin >> c;
			sit_seat(c, seat);
		}

		for(int i=0; i<n; i++)
		{
			if(seat[i] !=0) printf("%c", seat[i]);
			else printf("#");
		}
		printf("\n");
	}
}

Measured memory_bytes: 0
/*
      author : nishi5451
      created: 11.08.2020 22:16:56
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
 
#define int long long 
#define MOD 1000000007
 
using namespace std;
 
signed main(){
 

    int x,y;

    cin >> x >>y;

    if(y%x==0){
        cout << x+y <<endl;
    }

    else{
        cout <<y-x<<endl;
    }

 	return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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




int main(){
    int n, m;
    cin >> n >> m;
    int h[n];
    rep(i, n) cin >> h[i];
    vector<int> g[n];
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i, n){
        bool flag = true;
        rep(j, g[i].size()){
            if(h[g[i][j]] >= h[i]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int main() {
	ios::sync_with_stdio(0);

	int n;
	ll d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ll x, y;
		cin >> x >> y;
		ans += (x * x + y * y <= d * d);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split(' '))
# print('recv', N,K)
d = []
A = []
for n in range(K):
    d.append(int(input()))
    # print('recv', d[-1])

    if d[-1] > 1:
        A.append(list(map(int, input().split(' '))))
        # print('recv', A[-1])
    else:
        A.append([int(input())])
        # print('recv', A[-1])

itazurasareru = [0] * N

for k in range(K):
    # print(k)
    cnt = d[k]
    a = A[k]
    # print(a)
    for i in range(cnt):
        # print(i)
        itazurasareru[a[i]-1] += 1

print(sum([ 1 for sunuke in itazurasareru if sunuke == 0 ]))


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


int main() {
	int a, b; cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll sum(n+1,0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		sum.at(i+1) = sum.at(i)+a ;
	}
	ll ans = 10000000000000000 ;
	for(int i=1;i<=n-1;i++){
		ll sub = sa(sum.at(n)-sum.at(i),sum.at(i)) ;
		if(ans>sub) ans = sub ;
	}
	cout << ans << endl ;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 200500;

int n, x, u[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> x;

	if (x == 1 || x == n + n - 1) {
		cout << "No";
		return 0;
	}

	cout << "Yes" << endl;

	if (n == 2) {
		cout << "1\n2\n3\n";
		return 0;
	}

	if (x == 2)
		u[x] = u[x - 1] = u[x + 1] = u[x + 2] = 2;
	else
		u[x] = u[x - 1] = u[x + 1] = u[x - 2] = 2;

	for (int i = 1, ptr = 1; i < n - 1; i++) {
		while (u[ptr]) ptr++;
		u[ptr] = 1;
		cout << ptr << '\n';
	}

	if (x == 2)
		cout << x + 2 << '\n' << x << '\n' << x - 1 << '\n' << x + 1 << '\n';
	else
		cout << x - 2 << '\n' << x << '\n' << x + 1 << '\n' << x - 1 << '\n';

	for (int i = 1, ptr = 1; i < n - 2; i++) {
		while (u[ptr]) ptr++;
		u[ptr] = 1;
		cout << ptr << '\n';
	}
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 2304
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String B = sc.nextLine();
    int max = 0;
    int count = 0;
    for(int i=0; i<B.length(); i++) {
      if(B.charAt(i) == 'A' || B.charAt(i) == 'C' || B.charAt(i) == 'G' || B.charAt(i) == 'T') {
        count++;
      } else {
        
        max = Math.max(max, count);
        count = 0;
      }
    }
    max = Math.max(max, count);
    System.out.println(max);
  }
}


Measured memory_bytes: 35500
N=parse(Int,readline())
Red=Array{Pair{Int,Int}}(0)
Blue=Array{Pair{Int,Int}}(0)
for i=1:N
	a,b=map(x->parse(Int,x),split(readline()))
	push!(Red,a=>b)
end
for i=1:N
	a,b=map(x->parse(Int,x),split(readline()))
	push!(Blue,a=>b)
end
used=[false for _=1:N]
sort!(Blue)
for (a,b)=Blue
	id=-1
	for i=1:N
		if used[i];continue;end
		if Red[i].first<a&&Red[i].second<b
			if id<0
				id=i
			else
				if Red[id].second<Red[i].second
					id=i
				end
			end
		end
	end
	if id>0
		used[id]=true
	end
end
println(sum(used))


Measured memory_bytes: 114808
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  var arr []int
  for i := 0; i < n; i++{
    arr = append(arr, nextInt())
  }
  count := 0
  fmt.Println(countF(&count, arr))
}

func countF(count *int, arr []int) (int) {
	length := len(arr)
	for i := 0; i < length; i++ {
		if arr[i] % 2 == 1{
			return *count
		} else {
            arr[i] = arr[i] / 2
		}
	}
	*count++
	return countF(count, arr)
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

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

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

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

    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    rep(i, m) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        rep(j, n) visited[j] = false;

        dfs(0);

        bool bridge = false;
        rep(j, n) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

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


using namespace std;

int distance(int x1, int y1, int x2, int y2)
{
    int x = x1 - x2, y = y1 - y2;
    return x*x + y*y;
}
int main()
{
    int an, bn, r;
    while (scanf("%d%d", &an, &bn), an | bn)
    {
	scanf("%d", &r);

	const int MAX = 100100;
	static pair<int, int> a[MAX], b[MAX];

	const int dis = 4*r;
	const int sq_dis = dis*dis;
	for (int i = 0; i < an; ++i)
	    scanf("%d%d", &a[i].first, &a[i].second);
	for (int i = 0; i < bn; ++i)
	    scanf("%d%d", &b[i].first, &b[i].second);

	sort(a, a + an);
	sort(b, b + bn);

	int res = 0;
	for (int i = 0; i < an; ++i)
	{
	    int x = a[i].first, y = a[i].second;
	    int t = lower_bound(b, b + bn, make_pair(x - dis, 0)) - b;
	    int sum = 0;
	    for (int j = t; j < bn && b[j].first - x <= dis; ++j)
	    {
		if (distance(x, y, b[j].first, b[j].second) <= sq_dis)
		    ++sum;
	    }
	    res += sum;
	}
	printf("%d\n", res);
    }
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int n,ans = 0;
	cin >> n;
	for(int i = 1;i < n;i++){
		ans += n/i;
		if(n%i==0) ans--;
	}
	cout << ans << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3604
use std::vec::Vec;
use std::cmp::min;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 3);
  (v[0], v[1], v[2])
}

const Inf: usize = 1_000_000_000;
const m: usize = 400;
fn main() {
    let (n, ma, mb) = read_touple::<usize>();
    let mut abc = Vec::new();
    for _ in 0..n {
      let t = read_touple::<usize>();
      abc.push(t);
    }

    let mut dp = vec![vec![vec![Inf; m+1]; m+1]; n+1];

    // init
    dp[0][0][0] = 0;

    for i in 0..n {
      let (a, b, c) = abc[i];
      for j in 0..m+1 {
        for k in 0..m+1 {
          if a <= j && b <= k {
             dp[i+1][j][k] = min(dp[i][j][k], dp[i][j - a][k - b] + c);
          } else {
             dp[i+1][j][k] = dp[i][j][k];
          }
        }
      }
    }

    let mut ans = Inf;

    // check 
    for i in 0..m+1 {
      for j in 0..m+1 {
        if i * mb == j * ma && i != 0 {
           ans = min(ans, dp[n][i][j]);
        }
      }
    }  
    
    if ans == Inf {
       println!("-1");
    } else {
      println!("{}", ans);
    }
}


Measured memory_bytes: 63740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, D;
    cin >> N >> D;
    int x[N][D];
    rep(i, N) rep(j, D) cin >> x[i][j];
    int ans = 0;
    rep(i, N-1) rep2(j, i+1, N-1){
        int a = 0;
        rep(k, D){
            a += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        rep(l, 1000){
            if(a == l*l) ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    bool found(false);
    for (char i : s) if (i == '7') {found = true; break;}
    if (found) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll A,B,Q;
vector<ll> s;
vector<ll> t;

ll min_way(ll start, ll sh, ll tmp){
	if(sh <= start && start <= tmp){
		return min((start-sh)+(tmp-sh), (tmp-start)+(tmp-sh));
	}
	if(tmp <= start && start <= sh){
		return min((sh-start)+(sh-tmp), (start-tmp)+(sh-tmp));
	}
	if(start >= tmp){
		return start - min(sh,tmp);
	}
	else{
		return max(sh,tmp) - start;
	}
}

ll min_dist(ll x){
	ll ret = LLONG_MAX;
	ll sh_idx = lower_bound(s.begin(),s.end(),x) - s.begin();
	if(sh_idx >= 0 && sh_idx < A){
		ll sh_pos = s[sh_idx];
		ll tmp_idx = lower_bound(t.begin(), t.end(), sh_pos) - t.begin();
		if(tmp_idx >= 0 && tmp_idx < B) ret = min(ret,min_way(x,sh_pos,t[tmp_idx]));
		tmp_idx--;
		if(tmp_idx >= 0 && tmp_idx < B) ret = min(ret,min_way(x,sh_pos,t[tmp_idx]));
	}

	sh_idx--;

	if(sh_idx >= 0 && sh_idx < A){
		ll sh_pos = s[sh_idx];
		ll tmp_idx = lower_bound(t.begin(), t.end(), sh_pos) - t.begin();
		if(tmp_idx >= 0 && tmp_idx < B) ret = min(ret,min_way(x,sh_pos,t[tmp_idx]));
		tmp_idx--;
		if(tmp_idx >= 0 && tmp_idx < B) ret = min(ret,min_way(x,sh_pos,t[tmp_idx]));
	}
	return ret;
}

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

	cin >> A >> B >> Q;

	for (int i = 0;i < A;i++){
		ll tmp; cin >> tmp;
		s.push_back(tmp);
	}

	for (int i = 0;i < B;i++){
		ll tmp; cin >> tmp;
		t.push_back(tmp);
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	for (int i = 0;i < Q;i++){
		ll q; cin >> q;
		cout << min_dist(q) << endl;
	}

	return 0;

}


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N=2e5+5;

const int INF = 1e9+5;
bool frq[105] = {false};
void done() {
    int n;
    cin >> n;
    deque<int>a(n);
    for(int i=0;i < n;i++) {
        cin >> a[i];
    }
    int cnt = 0;
    int alice = 0, bob =0;
    int st = 3;
    while(!a.empty()) {
        if(st==3) {
            st = 1;
            alice += a.front();
            a.pop_front();
            cnt++;
            continue;
        }
        if(st==1) {
            while(true) {
                if(bob > alice || a.empty())break;
                bob += a.back();
                a.pop_back();
            }
            st = 0;
            cnt++;
            continue;
        }


        if(st==0){
            while(true) {
                if(alice > bob || a.empty())break;
                alice += a.front();
                a.pop_front();
            }
            st = 1;
            cnt++;
            continue;
        }


    }
    cout << cnt << " " << alice << " " << bob << '\n';


}
void solve() {

    int n,k;
    cin >> n >> k;
    for(int i=0;i < k;i++) {
        int x;
        cin >> x;
        for(int i=0; i< x;i++) {
            int p;
            cin >> p;
            frq[p] = true;
        }
    }
    int cnt = 0;
    for(int i=1;i <= n;i++) {
        if(!frq[i])cnt++;
    }
    cout << cnt << '\n';


}
void another() {
    int n, k;
    cin >> n>> k;
    for(int i = 1;i <=2;i++) {
        int asp = i * k;
        asp = n - asp;
        if(asp >=0 && asp%2==0) {
            cout << "YES\n";
            cout << asp+i;
            for(int j=0;j < k-1;j++) {
                cout << " " << i;
            }
            cout << '\n';
            return;
        }
    }
    cout << "NO\n";

}
int main() {


    fast;
    solve();

}


Measured memory_bytes: 3628