akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << (n - 1 + k - 1 - 1) / (k - 1);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

typedef pair<int, int> P;
const int N_MAX = 100005;

int k = 0;
vector<int> c(N_MAX, 0);

vector<vector<int>> S(N_MAX);
// S[i] contains edegs connected to the ith vertex.

vector<P> E(N_MAX);    // E[i] is the ith edge.

void bfs() {
  queue<P> que;
  int v0 = 1;
  int d0 = S[v0].size();
  rep(i, d0) {
    int e0 = S[v0][i];
    c[e0] = i + 1;
    int v = E[e0].first;
    if(v0 == v) {
      v = E[e0].second;
    }
    que.push(make_pair(v, e0));
  }

  while(que.size()) {
    P p = que.front();
    que.pop();
    int v = p.first;
    int e = p.second;
    int d = S[v].size();
    int nc = 1;
    rep(i, d) {
      int ne = S[v][i];
      if(c[ne] > 0)
        continue;
      if(nc == c[e])
        ++nc;
      c[ne] = nc++;
      int w = E[ne].first;
      if(v == w) {
        w = E[ne].second;
      }
      que.push(make_pair(w, ne));
    }
  }
}

int main(void) {
  int n;
  cin >> n;
  rep(i, n) {
    if(!i)
      continue;
    int a, b;
    cin >> a >> b;
    S[a].push_back(i);
    S[b].push_back(i);
    E[i] = make_pair(a, b);
  }
  rep(i, n + 1) {
    if(!i)
      continue;
    k = max(k, (int)S[i].size());
  }
  cout << k << endl;

  bfs();
  rep(i, n) {
    if(!i)
      continue;
    cout << c[i] << endl;
  }
  return 0;
}

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

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

    int N; cin >> N;
    int prev, suc, ans = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (i == 0) {
            suc = 1;
        } else if (a == prev) {
            ++suc;
        } else if (suc > 1 && a != prev) {
            ans += suc / 2;
            suc = 1;
        }
        
        if (suc > 1 && i == N - 1) {
            ans += suc / 2;
        }

        prev = a; 
    }
    cout << ans << endl;
    
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    int c = 0;
    if(s[0] == 'R' && s[0] == s[1] && s[1] == s[2]) c = 3;
    else if(s[1] == 'R' && s[1] == s[0] || s[1] == s[2] && s[1] == 'R') c = 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') c = 1;

    cout << c << endl;
    return 0;
}



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

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

signed main()
{
  int L, R;
  cin >> L >> R;
  int l, r;
  if (L / 2019 == R / 2019)
  {
    l = L;
    r = R;
  }
  else if (R < L + 2019)
  {
    l = R;
    r = L;
  }
  else
  {
    l = 0;
    r = 2018;
  }

  int ans = 1E+8;
  for (int i = l; i <= r - 1; i++)
  {
    for (int j = i + 1; j <= r; j++)
    {
      chmin(ans, ((i % 2019) * (j % 2019)) % 2019);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def q1():
    S = list(input())
    if S.count(S[0]) == 2 and S.count(S[1]) == 2 and S.count(S[2]) == 2 and S.count(S[3]) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    q1()

Measured memory_bytes: 38384
#include<stdio.h>
int main(void){
	int	h[10],i,j,tmp;
	char line[100];
	
	for(i=0;i<10;i++){
		fgets(line,sizeof(line),stdin);
		sscanf(line,"%d",&h[i]);
	}

	for(i=0;i<10;i++){
		for(j=9;j>i;j--){
			if(h[j-1]<h[j]){
				tmp=h[j-1];
				h[j-1]=h[j];
				h[j]=tmp;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",h[i]);
	}
}


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

using namespace std;

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

//	bool flag = false;
	int ans = 0;

	for(int i = 1; i <= n; ++i){
		if((int)(i * 1.08) == n){
		  ans = i;
			//flag = true;
			break;
		}
		else{
			//flag = false;
			continue;
		}
	}

	if(ans) cout << ans << "\n";
	else cout << ":(" << "\n";

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
def sks(a,b):
    if a == 0 or b == 0:
        return(max(a,b))
    else:
        c = min(a,b)
        d = max(a,b)
        return sks(c,d%c)
for i in range(n-1):
    b.append(sks(b[i],a[i+1]))
print(b[n-1])


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        int n = s.length;
        int[] abc = new int[3];
        for (int i = 0; i < s.length; i++) abc[s[i]-'a']++;
        int a = abc[0]-n/3;
        int b = abc[1]-n/3;
        int c = abc[2]-n/3;
        int max = Math.max(a,Math.max(b,c));
        int min = Math.min(a, Math.min(b,c));
        if(max-min<=1) out.println("YES");
        else out.println("NO");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 25044
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

        final long A = sc.nextLong();
        final double B = sc.nextDouble();

        System.out.println(BigDecimal.valueOf(A).multiply(BigDecimal.valueOf(B)).toString().replaceAll("\\.[0-9]*$", ""));
    }
}


Measured memory_bytes: 37680
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
int main() {
    cin>>a>>b;
    if(a==b){
        cout<<a+b<<endl;
    }
    else if(a>b){
        cout<<a+a-1<<endl;
    }
    else {
        cout<<b+b-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
list_A = []
list_B = []
for i in range(N):
    A,B = map(int,input().split())
    list_A.append(A)
    list_B.append(B)
lists = list(zip(list_A,list_B))
lists.sort()
num = 0
Sum = 0
for a,b in lists:
    num += b
    if  num > M:
        n = num - M
        b -= n 
        Sum += a * b
        break
    else:
        Sum += a * b
print(Sum)
    
        

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

int main() {
	lint a, b, c, d;
	cin >> a >> b >> c >> d;
	lint x = max(a*c, max(a*d, max(b*c, b*d)));
	std::cout << x << '\n';
}


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

int N;
ll A,ans=0,num=1;

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A;
    if(i==0){
      ans+=(A-1);
    }else if(num+1<A){
      ans+=(A-1)/(num+1);
    }else{
      num=max(num,A);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define ll long long
#define endl '\n'
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)

const int N = 1e5;
const int mod = 1e9+7;
int n;

struct M{
	vector<vector<ll> > t;

	M() { t.resize(n, vector<ll>(n,0)); }
 
	M operator* (const M& b) const {
		M c;

		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				for(int k = 0;k < n;k++){
					c.t[i][j] = ( c.t[i][j] + t[i][k]*b.t[k][j])%mod;
				}
			}
		}
		return c;
	}
};

M fast_power(M a,ll b){
	M ans;

	for(int i = 0;i < n;i++){
		ans.t[i][i] = 1;
	}

	while(b){
		if(b&1) ans = ans * a;
		a = a*a;

		
		b /= 2;
	}

	return ans;
}

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll k;
	scanf("%d%lld", &n,&k);

	M a;

	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			scanf("%lld",&a.t[i][j]);
		}
	}

	M ans = fast_power(a, k);


	ll sum = 0;

	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			sum = (sum + ans.t[i][j])%mod;
		}
	}

	printf("%lld", sum);
}

Measured memory_bytes: 384
n=gets.to_i
a=gets.split.map &:to_i
a1,a2,a4 = [a.count{|e|e%2==1},a.count{|e|e%4==2},a.count{|e|e%4==0}]
if a1>a4+1-[1,a2].min
  puts :No
else
  puts :Yes
end

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
// const int MOD = 1e9+7;
const int MOD = 998244353;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[3010][3010];

int main()
{
    cout << fixed << setprecision(15);
    ll N, S;
    cin >> N >> S;

    Fill(dp, 0);

    vector<ll> A(N+1);
    for(ll i=1; i<=N; i++){
        cin >> A[i];
    }

    // for(ll i=0; i<N; i++){
    //     dp[i][0] = 1;
    // }
    dp[0][0] = 1;
    // cout << "a" << endl;
    
    for(ll i=1; i<=N; i++){
        for(ll k=0; k<=S; k++){
            if(k-A[i]<0){
                dp[i][k] = ((dp[i-1][k]%MOD)*2)%MOD;
            }
            else{
                dp[i][k] = ((((dp[i-1][k]%MOD)*2)%MOD + dp[i-1][k-A[i]])%MOD)%MOD;
            }
            // dp[i][k] = dp[i][k] % MOD;
        }
    }
    // for(ll i=0; i<=N; i++){
    //     for(ll j=0; j<=S; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N][S] << endl;
    return 0;
}

Measured memory_bytes: 74412
# -*- coding: utf-8 -*-
"""
A - Multiple of 2 and N
https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

"""
import sys
from sys import stdin
input = stdin.readline


from fractions import gcd

def main(args):
    N = int(input())
    g = gcd(N, 2)
    print(N * 2 // g)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 5048
#include<iostream>
#include<string>
#include<map>

int main(){
    std::string S;
    std::cin >> S;
    std::map<char, int> mp;
    for(int i = 0; i < S.size(); i++){
        if(mp[S[i]] != 0){
            std::cout << "no" << std::endl;
            return 0;
        }
        mp[S[i]]++;
    }
    std::cout << "yes" << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define N (int)1e5
#define F first
#define S second
#define MP make_pair
typedef pair<int, int> P;
typedef long long LL;
int n, m, q, v[N], d[N], c[N], vv[N + 1];
int flag[N + 1];
vector<int>vec[N + 1];
void bfs(int v, int d, int c)
{
	if (flag[v] >= d) return;
	queue<P> que;
	que.push(MP(v, d));
	flag[v] = d;
	while (!que.empty())
	{
		P p = que.front();
		if(!vv[p.F])
		vv[p.F] = c;
		que.pop();
		if (p.S == 0)
			continue;
		for (int i = 0; i < vec[p.F].size(); i++)
		{
			if (flag[vec[p.F][i]] < p.S - 1) {
				flag[vec[p.F][i]] = p.S - 1;
				que.push(MP(vec[p.F][i], p.S - 1));
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int aa, bb;
		cin >> aa >> bb;
		vec[aa].push_back(bb);
		vec[bb].push_back(aa);
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> v[i] >> d[i] >> c[i];
	}
	fill(flag, flag + n + 1, -1);
	for (int i = q - 1; i >= 0; i--)
	{
		bfs(v[i], d[i], c[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		cout << vv[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 8912
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli t,n,i;
	cin>>n;
	lli a[n],b[n];
	rep(i,0,n){
		cin>>a[i]>>b[i];
	}
	for(i=0;i<n-2;i++){
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define P(x) cout << (x) << "\n"
#define D(x) cerr << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

using i64=long long int; // 10^18
int n,k;
const i64 INF = 10e+10;
const int SIZE=1e5;
i64 h[SIZE],dp[SIZE];

// 0-indexed
// dp[0]=0
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    REP(i,n){
        cin>>h[i];
    }
    REP(i,n)dp[i]=INF;
    dp[0]=0;
    REP(i,n){
        for(int j=1;j<=k && i-j>=0;j++){
           dp[i]=min(dp[i], dp[i-j] + abs(h[i] - h[i-j])); 
        }
    }
    P(dp[n-1]);
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numD = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numD = scanner.nextInt();

			int wkBus = numA < numB ? numA : numB;
			int wkTrain = numC < numD ? numC : numD;

			System.out.println(wkBus + wkTrain);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numD = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numD = scanner.nextInt();
			numX = scanner.nextInt();

			int[] wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			int res = numX;
			for (int i = 0; i < numN; i++) {
				for (int j = 0; j < numD; j++) {
//					System.out.println((i + 1) + ":人目");
					if (j == 0) {
//						System.out.println(j + 1 + " :day");
						res++;
					} else {
						int day = (j) * wk[i] + 1;
						if (day <= numD) {
//							System.out.println(day + " :day");
							res++;
						} else {
							break;
						}
					}
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
int n,m;
struct Map{
  vector<vector<int>> map;
  void mkmap(vector<int> const& a,vector<int> const& b,vector<int>& num){
    //num.resize(n*m+1,0);
    rep(i,n){
      map.push_back(vector<int> (m,inf));
    }
    rep(i,n){
      rep(j,m){
        map[i][j]=min(a[i],b[j]);
        if(a[i]==b[j])map[i][j]=999;
      }
    }
  }
  void show_map(){
    rep(i,n){
      rep(j,m){
        cout<<map[i][j]<<" ";
      }
      cout<<endl;
    }
  }
};
signed main(){
  cin>>n>>m;
  vector<int> a(n);
  vector<int> b(m);
  vector<int> sum;
  vector<int> memo(n*m+1,0);
  vector<int> num(n*m+1,0);
  vector<int> list;
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  //Map grid;
  //grid.mkmap(a,b,num);
  rep(i,n){
    rep(j,m){
      if(a[i]==b[j]){
        sum.push_back(inf);
        ++num[a[i]];
        list.push_back(a[i]);
      }
      else{
        sum.push_back(min(a[i],b[j]));
      }
    }
  }
  sort(ALL(sum));
  rep1(i,n*m){
    memo[i]=memo[i-1];
    if(num[i]==1)++memo[i];
    else if(num[i]>1){
      cout<<0<<endl;
      return 0;
    }
  }
  int cur=1;
  int res=1;
  sum.push_back(inf);
  sum.push_back(inf);
  int last=sum[0];

  rep1(i,n*m){
    if(last==sum[i]){
      cur++;
      continue;
    }
    else{
      if(num[last]==1){
        rep1(k,cur){
          res*=last-1-memo[last]-i+k+1;
          res%=MOD;
        }
      }
      else{
        res*=cur;
        rep1(k,cur-1){
          res*=last-1-memo[last]-i+k+1;
          res%=MOD;
        }
      }
      cur=1;
    }
    //cout<<sum[i]-memo[sum[i]]-i<<endl;
    if(res<0)res=0;
    res%=MOD;
    last=sum[i];
    if(sum[i]==inf){
      break;
    }
  }

  cout<<res<<endl;
  //grid.show_map();
  /*rep(i,list.size()){
    cout<<list[i]<<endl;
  }*/
  //cout<<memo[182]<<endl;
  return 0;
}


Measured memory_bytes: 25968
#include <stdio.h>

void partical_move(int data[][5], int i, int n) {
  int j, k;
  for (j = n-1; j >= 0; j--) {
	if (data[j][i] == 0) {
	  for (k = j; k >= 0; k--) {
		if (data[k][i] != 0) {
		  data[j][i] = data[k][i];
		  data[k][i] = 0;
		  break;
		}
	  }
	}
  }
}

int main(void) {
  int n;
  int flag = 0;
  int i, j, k;
  int score;
  // int score[1000] = {0};
  int L = 0;

  while (1) {

	int data[100][5] = {{0}};
	score = 0;

	scanf("%d", &n);
	if (n == 0) break;
	for (i = 0; i < n; i++) {
	  for (j = 0; j < 5; j++) {
		scanf("%d", &data[i][j]);
	  }

	}
	while (1) {
	  //debug
	  // 	puts("");
	  // for (i = 0; i < n; i++) {
	  // 	for (j = 0; j < 5; j++) {
	  // 	  printf("%d ", data[i][j]);
	  // 	}
	  // 	puts("");
	  // }
	  //



	  flag = 0;
	  for (i = 0; i < n; i++) {
		if (data[i][0] == data[i][1] && data[i][1] == data[i][2] && 
			data[i][2] == data[i][3] && data[i][3] == data[i][4] && data[i][2] != 0) {
		  // score[L] += data[i][0]*5;
		  score += data[i][0]*5;

		  data[i][0] = data[i][1] = data[i][2] = data[i][3] = data[i][4] = 0; //delete

		  flag = 1;
		}

		else if (( (data[i][0] == data[i][1] && data[i][1] == data[i][2] && data[i][2] == data[i][3]) && data[i][2] != 0) ||
				 ((data[i][1] == data[i][2] && data[i][2] == data[i][3] && data[i][3] == data[i][4]) && (data[i][2] != 0))) {
		  // score[L] += data[i][2]*4;
		  score += data[i][2]*4;

		  if (data[i][0] == data[i][1]) { //delete
			data[i][0] = data[i][1] = data[i][2] = data[i][3] = 0; //delete
		  } //delete
		  else { //delete
			data[i][1] = data[i][2] = data[i][3] = data[i][4] = 0; //delete
		  } //delete

		  flag = 1;
		}

		else {
		  for (j = 0; j < 3; j++) {
			if (data[i][j] == data[i][j+1] && data[i][j+1] == data[i][j+2] && data[i][j] != 0) {
			  // score[L] += data[i][j]*3;
			  score += data[i][j]*3;

			  for (k = j; k < j+3; k++) { //delete
				data[i][k] = 0; //delete
			  } //delete

			  flag = 1;
			  break;
			}
		  }
		}
	  }

	  ///////////////////debug///////////////////////////
	  // puts("");
	  // for (i = 0; i < n; i++) {
	  // 	for (j = 0; j < 5; j++) {
	  // 	  printf("%d ", data[i][j]);
	  // 	}
	  // 	puts("");
	  // }
	  ///////////////////////////////////////////////////

	  if (flag == 0) {
		//   puts("");
		// for (i = 0; i < n; i++) {
		//   for (j = 0; j < 5; j++) {
		// 	printf("%d ", data[i][j]);
		//   }
		//   puts("");
		// }
		//		printf("%d\n",score[L]);
		printf("%d\n",score);
		L++;
		break;
	  }
	  //move

	  for (i = 0; i < 5; i++) { //??????????????¢?´¢
		partical_move(data,i, n); 
	  }
	}//while



	// printf("%d\n",data[l]);
  }//while

  // for (i = 0; i < L; i++) {
  // 	printf("%d\n",score[i]);
  // }
}//mdatain

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
   int mat[3010][3010];
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    int m=a.length();
    int n=b.length();

    for(int i=0;i<=m;i++){
    for(int j=0;j<=n;j++){
    if(i==0 || j==0){
    mat[i][j]=0;
    continue;}
if(a[i-1]==b[j-1])
mat[i][j]=1+mat[i-1][j-1];
else
mat[i][j]=max(mat[i][j-1],mat[i-1][j]);
    }
    }
   int len=mat[m][n];
   char ans[len+1];
//ans[len]='\0';
  int  ct=len-1;
    int i=m;
    int j=n;
    while((i>0 && j>0) && ct>=0){
if(a[i-1]==b[j-1])
{  ans[ct]=a[i-1];
ct-=1;
i-=1;
j-=1;
}
else{
if(mat[i-1][j]>=mat[i][j-1])
{ i-=1;
}
else
j-=1;
}

    }
    for(int k=0;k<len;k++)
    cout<<ans[k];

    return 0;}


Measured memory_bytes: 38920
icase=0
if icase==0:
    n=int(input())
    lim2=2
    lim1=1
    if n==1:
        print(lim1)
    else:
        for i in range(n-1):
            li=lim1+lim2
            lim2=lim1
            lim1=li
        print(li)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[105];
char cs;
LL p=0;

LL check(LL a,LL n){
	LL b=0,c=0,d=0;
	bool flag=false;//1char
	for(int i=a;i<strlen(ca);i++){
		if(ca[i]=='('){
			flag=false;
			d=check(i+1,n);
			//cout<<i<<" "<<b<<" "<<d<<endl;
			if(d==-1)return -1;
			if(n<b*d){
				check(i+1,n%d);
				return -1;
			}
			n-=b*d,c+=b*d,b=0,i=p;
			//cout<<i<<" "<<n<<endl;
		}
		if('0'<=ca[i] && ca[i]<='9')b*=10,b+=(int)ca[i]-(int)'0',flag=true;
		if(ca[i]==')'){
			p=i+1;
			return c;
		}
		if('A'<=ca[i] && ca[i]<='Z'){
			if(flag){
				flag=false;
				if(n<b){
					cs=ca[i];
					return -1;
				}
				n-=b,c+=b,b=0;
			}else{
				if(n==0){
					cs=ca[i];
					return -1;
				}
				n--,c++;
			}
		}
	}
}


int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c;
	while(cin>>ca>>n){
		if(ca[0]=='0')break;
		a=check(0,n);
		if(a!=-1)cout<<0<<endl;
		else cout<<cs<<endl;
	}
}



Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main()
{
        int n;
        cin >> n;

        char name[11];
        unsigned long march[5]={0};

        for(int i=0;i<n;i++){
                cin >> name;
                if(name[0]=='M') march[0]++;
                else if(name[0]=='A') march[1]++;
                else if(name[0]=='R') march[2]++;
                else if(name[0]=='C') march[3]++;
                else if(name[0]=='H') march[4]++;
        }

        unsigned long combination=0;
        for(int i=0;i<5;i++){
                for(int j=i+1;j<5;j++){
                        for(int k=j+1;k<5;k++){
                                combination+=march[i]*march[j]*march[k];
                        }
                }
        }

        cout << combination << endl;

        return 0;
}


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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n;
  scanf("%d",&n);
  int a[n+1];
  for(int i=0;i<n+1;i++){
    a[i]=0;
  }
  int j=1;
  int ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(j==a[i]){
      j++;
    }else{
      ans++;
    }
  }
  if(j==1){
    printf("-1\n");
  }else{
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2512
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int ans=0;
    int n=sc.nextInt();
    int[] s;
    s=new int[n];
    for(int i=0;i<n;i++){
      s[i]=sc.nextInt();
    }
    int q=sc.nextInt();
    for(int i=0;i<q;i++){
      int t=sc.nextInt();
      int lo=0;
      int hi=n-1;
      while(lo<=hi){
        int mid=(lo+hi)/2;
        if(t==s[mid]){
          ans++;
          break;
        }else if(t>s[mid]){
          lo=mid+1;
        }else{
          hi=mid-1;
        }
      }
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 67916
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int ans=0;
    map<string,int> mp;

    for(int i=0; i<N; i++){
        string S;
        cin >> S;

        if(mp.count(S)==0){
            ans++;
            mp[S] = 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19224
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int len;
	while(cin>>len)
	{
		string s1,s2,s3;
		cin>>s1>>s2>>s3;
		int cnt=0;
		for(int i=0;i<len;++i)
		{
			if(s1[i]==s2[i] && s1[i]==s3[i])
			{
				cnt+=0;
			}else if(s1[i]!=s2[i] && s1[i]!=s3[i] && s2[i]!=s3[i])
			{
				cnt+=2;
			}else 
			{
				cnt+=1;
			}
		}	
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

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

    def f(x):
        return (A*x//B) - A*(x//B)

    # 分母のBに注目すると、1 <= x <= B　を調べれば良い
    if B > N:
        print(f(N))
    else:
        print(f(B-1))



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

    def f(x):
        return (A*x//B) - A*(x//B)

    # さぶたん
    left, right = 1, N
    cnt = 500
    ans = 0
    while cnt > 0:
        cnt -= 1
        c1, c2 = (2*left+right)//3, (left+2*right)//3

        ret1, ret2 = f(c1), f(c2)

        if ret1 > ret2:
            ans = max(ans, ret1)
            right = c2
            continue
        elif ret1 < ret2:
            ans = max(ans, ret2)
            left = c1
            continue

    print(ans)




if __name__ == "__main__":
    solve()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define fi first
#define se second
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,1,0,-1};
ll H,W;
queue<pl> que;
ll GridBFS(pl start,pl goal,vector<vector<char>> &info,vvl &now,vvl &bit){
    que.emplace(start);
    now[start.fi][start.se]=0;
    while(que.size()){
        ll y=que.front().fi,x=que.front().se;
        que.pop();
        rep(k,4){
            if(bit[y][x]&(1<<k)){
                ll ny=y+dy[k],nx=x+dx[k];
                if(now[ny][nx]>now[y][x]+1){
                    now[ny][nx]=now[y][x]+1;
                    que.emplace(ny,nx);
                }
            }
        }
    }
    return now[goal.fi][goal.se];
}
void solve(ll H,ll W){
    vector<vector<char>> info(H,vector<char>(W));
    vvl bit(H,vl(W,15));
    rep(i,2*H-1){
        if(i%2){
            rep(j,W){
                ll a;cin>>a;
                if(!a)continue;
                bit[i/2][j]-=1;
                bit[i/2+1][j]-=4;
            }
        }
        else{
            rep(j,W-1){
                ll a;cin>>a;
                if(!a)continue;
                bit[i/2][j]-=2;
                bit[i/2][j+1]-=8;
            }
        }
    }
    rep(i,H)bit[i][0]-=8,bit[i][W-1]-=2;
    rep(i,W)bit[0][i]-=4,bit[H-1][i]-=1;
    vvl now(H,vl(W,INF));
    pl start={0,0},goal={H-1,W-1};
    ll k=GridBFS(start,goal,info,now,bit);
    if(k==INF)cout<<0<<endl;
    else cout<<k+1<<endl;
}
int main(){
    while(true){
        cin>>W>>H;
        if(H+W==0)break;
        else solve(H,W);
    }
    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define LL long long
#define N 1000010
#define M 1010

using namespace std;

struct Edge {
	int from, to; 
}e[N]; 

int n,num,cnt,tot,ans;
int head[N],a[M][M],node[M][M];
int inq[N],t[N],day[N]; 

inline void add_edge(int x,int y) {
    e[++cnt].from = y;
    e[cnt].to = head[x];
    head[x] = cnt;
}
void topsort() {
	for(int i = 1; i <= tot; i++) {
		int u = t[i]; 
		for(int j = head[u]; j; j = e[j].to) {
			int v = e[j].from; 
			day[v] = day[u] + 1; 
			inq[v]--; 
			if(!inq[v])t[++tot] = v; 
		}
	}
	for(int i = 1; i <= num; i++)
		ans = max(ans, day[i]); 
}

int main() {
	scanf("%d",&n); 
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < n; j++) {
			scanf("%d",&a[i][j]); 
			if(!node[i][j] && !node[j][i])
				node[i][j] = node[j][i] = ++num; 
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 2; j < n; j++) {
			add_edge(node[i][a[i][j-1]], node[i][a[i][j]]); 
			inq[node[i][a[i][j]]]++; 
		}
	}
	for(int i = 1; i <= num; i++) {
		if(!inq[i]) {
	  		t[++tot] = i; 
	  		day[i] = 1; 
	  	}
	}
	topsort(); 
	if(tot != num) puts("-1"); 
	else printf("%d\n", ans); 
    //system("pause");
	return 0; 
}

Measured memory_bytes: 31488
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cassert>
using namespace std;

int ans[300][300];
bool grid[300][300];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int h, w, k;
	cin >> h >> w >> k;
	
	for (int i = 0; i != h; ++i)
	{
		string s;
		cin >> s;
		for (int j = 0; j != w; ++j)
			grid[i][j] = s[j] == '#';
	}
	
	int cnt = 1;
	for (int i = 0; i != h; ++i)
	{
		bool yes = 0;
		int lst;
		for (int j = 0; j != w; ++j)
		{
			if (grid[i][j])
			{
				yes = 1;
				lst = j;
				int color = cnt++;
				for (int k = j; k != -1 && !ans[i][k]; --k)
					ans[i][k] = color;
			}
		}
		
		if (yes)
		{
			int color = ans[i][lst];
			for (int j = lst; j != w; ++j)
				ans[i][j] = color;
		}
	}
	
	for (int j = 0; j != w; ++j)
	{
		bool yes = 0;
		int lst;
		for (int i = 0; i != h; ++i)
		{
			if (ans[i][j])
			{
				yes = 1;
				lst = i;
				int color = ans[i][j];
				for (int k = i - 1; k != -1 && !ans[k][j]; --k)
					ans[k][j] = color;
			}
		}
		
		if (yes)
		{
			int color = ans[lst][j];
			for (int i = lst; i != h; ++i)
				ans[i][j] = color;
		}
	}
	
	for (int i = 0; i != h; ++i)
	{
		for (int j = 0; j != w; ++j)
			cout << ans[i][j] << ' ';
		cout << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 1280
// oh yea mr krabs
// REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5+10 ;
const int mod = 1e9+7 ;

int a[maxn] ;
int ans ;

int main(){

    ios::sync_with_stdio(false) ;
    cin.tie(0) ;

    int a, b ;
    cin >> a >> b;
    if(a >9 || b > 9){

        cout << -1 ;
        return 0 ;

    }

    cout << a *b ;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

typedef unsigned long long int ulli;

ulli solve(unsigned N, unsigned A, std::vector<unsigned> &x)
{
	unsigned X = std::max(*max_element(x.begin(), x.end()), A);
	
	std::vector<std::vector<std::vector<ulli>>> dp(N + 1);
	for (unsigned j = 0; j <= N; ++j)
	{
		dp[j] = std::vector<std::vector<ulli>>(N + 1);
		for (unsigned k = 0; k <= N; ++k)
		{
			dp[j][k] = std::vector<ulli>(N * X + 1, 0);
		}
	}
	dp[0][0][0] = 1;

	for (unsigned j = 1; j <= N; ++j)
	{
		for (unsigned k = 0; k <= N; ++k)
		{
			for (unsigned s = 0; s <= N * X; ++s)
			{
				dp[j][k][s] += dp[j - 1][k][s];
				if (k > 0 && s >= x[j - 1])
				{
					dp[j][k][s] += dp[j - 1][k - 1][s - x[j - 1]];
				}
			}
		}
	}

	ulli s = 0;
	for (unsigned k = 1; k <= N; ++k)
	{
		s += dp[N][k][k * A];
	}
	return s;
}

int main()
{
	unsigned N, A;
	std::cin >> N >> A;

	std::vector<unsigned> x(N);
	for (unsigned n = 0; n<N; ++n)
	{
		std::cin >> x[n];
	}

	std::cout << solve(N, A, x) << std::endl;

	return 0;
}

Measured memory_bytes: 51200
// B - KEYENCE String
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string s,t="keyence";
	cin>>s;
	int sn = s.size(), tn = t.size();
	rp(L, 0, tn){
		int R = sn - (tn-L);
		if(t == s.substr(0, L) + s.substr(R)){ puts("YES"); return 0; }//detlete [L,R) == t?
	}
	puts("NO");
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n,k;
  cin >> n >> k;
  cout << k * (int)pow(k - 1,n - 1) << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

int main() {
    int N,m=0,t=0,i;
    string S;
    cin >> N >> S;

    for(i=0; i<N; i++) {
        if(S.at(i) == 'I')
            t++;
        else
            t--;
        m = max(m, t);
    }

    cout << m << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int main() {
	cin>>n>>m;
	int nn = min(n,m);
	int mm = max(n,m);
	for(int i=1;i<=mm;i++)
		cout<<nn;
}



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

int main () {
  int n;
  cin >> n;
  
  if (n / 100 == 1) {
    n += 800;
  }
  
  else {
    n -= 800;
  }
  
  if (n % 100 < 20) {
    n += 80;
  }
  
  else {
    n -= 80;
  }
  
  if (n % 10 == 1) {
    n += 8;
  }
  
  else {
    n -= 8;
  }
  
  cout << n << endl;
}


Measured memory_bytes: 256
using System;

namespace ABC064_A_RGB_Cards
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			string numberStr = input[0] + input[1] + input[2];
			int number = int.Parse(numberStr);
			
			if(number % 4 == 0) Console.WriteLine("YES");
			else Console.WriteLine("NO");
		}
	}
}


Measured memory_bytes: 13140
class LowLink:
    def __init__(self, adj):
        self.n = len(adj)
        self.adj = adj
        self.used = [0] * n
        self.ord = [0] * n
        self.low = [0] * n
        self.bridge = []
        self.articulation = []

    def dfs(self, v, order, prev):
        order += 1
        self.used[v] = 1
        self.ord[v] = order
        self.low[v] = self.ord[v]

        is_articulation = False
        cnt = 0
        for to in self.adj[v]:
            if not self.used[to]:
                cnt += 1
                order = self.dfs(to, order, v)
                self.low[v] = min(self.low[v], self.low[to])
                if prev != -1:
                    is_articulation |= self.low[to] >= self.ord[v]
                if(self.ord[v] < self.low[to]):
                    if v < to:
                        self.bridge.append((v, to))
                    else:
                        self.bridge.append((to, v))
            elif to != prev:
                self.low[v] = min(self.low[v], self.low[to])
        if prev == -1:
            is_articulation |= cnt > 1
        if is_articulation:
            self.articulation.append(v)
        return order

    def build(self):
        order = 0
        for i in range(self.n):
            if not self.used[i]:
                order = self.dfs(i, order, -1)

if __name__ == "__main__":
    n, m = [int(item) for item in input().split()]
    edge = [[] for _ in range(n)]

    for i in range(m):
        a, b = [int(item) for item in input().split()]
        a -= 1; b -= 1
        edge[a].append(b)
        edge[b].append(a)

    LL = LowLink(edge)
    LL.build()
    # print(LL.bridge)
    # print(LL.articulation)
    print(len(LL.bridge))


Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numberOfPeople = sc.nextInt();
        char[] peopleDirections = sc.next().toCharArray();

        int[] east = new int[numberOfPeople];
        int[] west = new int[numberOfPeople];
        for (int i = 0; i < numberOfPeople; i++) {
            if (peopleDirections[i] == 'E') {
                east[i] = 1;
            } else {
                west[i] = 1;
            }
        }

        for (int i = 1; i < numberOfPeople; i++) {
            east[i] += east[i - 1];
            west[i] += west[i - 1];
        }

        int minimumNumberOfPeopleToChangeDirection = numberOfPeople;
        for (int i = 0; i < numberOfPeople; i++) {

            int countOfEastAtRightSide = east[numberOfPeople - 1] - east[i];
            int countOfWestAtLeftSide = i == 0 ? 0 : west[i - 1];
            int totalCount = countOfEastAtRightSide + countOfWestAtLeftSide;
            
            if (minimumNumberOfPeopleToChangeDirection > totalCount) {
                minimumNumberOfPeopleToChangeDirection = totalCount;
            }

        }

        System.out.println(minimumNumberOfPeopleToChangeDirection);
    }
}


Measured memory_bytes: 30444
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

		int N = sc.nextInt();
		int[] A = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		boolean isOk = true;

		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 0) {
				if (A[i] % 3 == 0 || A[i] % 5 == 0) {
				} else {
					isOk = false;
					break;
				}
			}
		}

		if (isOk) {
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}

		sc.close();
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }

        long acnt = 0;
        long bcnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= b[i]) {
                bcnt += a[i] - b[i];
            } else {
                if ((b[i] - a[i]) % 2 == 0) {
                    acnt += (b[i] - a[i]) / 2;
                } else {
                    acnt += (b[i] - a[i] + 1) / 2;
                    bcnt++;
                }
            }
        }
        if (acnt < bcnt) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

}


Measured memory_bytes: 56720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,A,B;
cin >> N >> A >> B;

int ans = 0;

rrep(i,N) {
    int num = i;
    int dig,sum= 0;
    while(num){
    dig = num % 10;
    sum += dig;
    num /= 10;
  }
  if(A <= sum && sum <= B) ans += i;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	ll n;
	cin>>n;
	if(n%2 == 0)cout<<n<<endl;
	else cout<<n*2<<endl;
	return 0;
}


Measured memory_bytes: 256
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------


d,t,s = mapi()
if d/s<=t:
    print("Yes")
else:
    print("No")


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

int max(int *a,int n){
    int i;
    int max=-1000000;
    int max_i=-1;
    for (i = 0; i < n; i++) {
        if (max<a[i]) {
            max=a[i];
            max_i=i;
        }
    }
    return max_i;
}


int main(){

int N,i,j,sum;
int **a;

scanf("%d",&N);

a=malloc(N*sizeof(int*));
for (i = 0; i < N; i++) {
    a[i]=malloc(3*sizeof(int));
}
for (i = 0; i < N; i++) {
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
    }
for (i = 0; i < N; i++) {
    sum=0;
    for (j = 0; j < 3; j++) {
        if (j!=max(a[i],3)) {
            sum=sum+a[i][j]*a[i][j];
        }
    }
    if ((a[i][max(a[i],3)])*(a[i][max(a[i],3)])==sum) printf("YES\n");
    else printf("NO\n");
}

return 0;
}

Measured memory_bytes: 612
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>
#include <iostream>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 200010;



vector <int> a;
vector <int> b;

int cur = 1;

void go(ll x) {
	if (x == 1) return;
	go(x / 2);
	a.push_back(cur);
	b.push_back(cur++);
	if (x & 1) {
		a.push_back(cur);
		b.push_back(0);
		for (int i = b.size() - 1; i > 0; i--) b[i] = b[i - 1];
		b[0] = cur++;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	ll n;
	cin >> n;
	n++;
	go(n);
	cout << a.size() * 2 << endl;
	for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
	for (int i = 0; i < b.size(); i++) cout << b[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256