akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var s = consoleReader.String;
            for (int i = 0; i < s.Length; i += 2)
                Console.Write(s[i]);

            return "";
        }


        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}

Measured memory_bytes: 13140
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 700000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline ll read() {
    ll res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}

inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}

ll f[N], fi[N];

inline void prepare() {
    f[0] = 1;
    int n = 700000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    fi[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) fi[i] = fi[i + 1] * (i + 1) % MOD;
}

inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * fi[m] % MOD * fi[n - m] % MOD;
}

int main() {
    int x, y;
    int z;
    prepare();
    scanf("%d %d", &x, &y);
    z = x + y;
    if (z % 3) {
        puts("0");
    } else {
        printf("%lld\n", C(z / 3, y - z / 3));
    }
    return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>

int a[3000];
int b[3000];

int main(){
char s = '#';
int i;
for( i=0;;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]==0 && b[i]==0)
break;
}

for(int j=0;j<i;j++){
for(int k=0;k<a[j];k++){

for(int p=0;p<b[j];p++){
printf("%c",s);
}
printf("\n");

}
printf("\n");
} 
return 0;
}


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

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; }

using ll = long long;

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

int main() {
  ll N;
  cin >> N;
  vector<ll> pl(N);
  vector<ll> mi(N);
  for(ll i = 0LL; i < N; i++){
    ll a;
    cin >> a;
    pl[i]=a+i+1LL;
    mi[i]=i+1LL-a;
  }
  sort(pl.begin(), pl.end());
  sort(mi.begin(),mi.end());
  vector<vector<ll>> po,ne;
  po.push_back({pl[0],1LL});
  ne.push_back({mi[0],1LL});
  ll k = 0LL;
  ll l = 0LL;
  for(ll i = 0LL; i < N-1; i++) {
    if(pl[i]==pl[i+1]){
      po[k][1]++;
    }
    if(mi[i]==mi[i+1]){
      ne[l][1]++;
    }
    if(pl[i]!=pl[i+1]){
      po.push_back({pl[i+1],1LL});
      k++;
    }
    if(mi[i]!=mi[i+1]){
      ne.push_back({mi[i+1],1LL});
      l++;
    }
  }
  ll ans = 0LL;
  vector<vector<ll>> plmi;
  for(ll i = 0LL ; i <(ll)po.size(); i++) {
    plmi.push_back(po[i]);
  }
  for(ll i = 0LL ; i <(ll)ne.size(); i++) {
    plmi.push_back(ne[i]);
  }
  sort(plmi.begin(),plmi.end());
  for(ll i = 0LL; i < (ll)plmi.size()-1; i++) {
    if(plmi[i][0]==plmi[i+1][0]){
      ans+=plmi[i][1]*plmi[i+1][1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 47148
import math;

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def main():
    m,d = map(int,input().split())
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            if j//10>=2 and j%10>=2:
                if (j//10)*(j%10)==i:
                    ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int n,k;
    cin>>n>>k;
    int x[110];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>x[i];
        ans+=min(x[i]*2,(k-x[i])*2);
    }
    cout<<ans<<endl;
}


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

vector<int> move_y={1,1,1,0,0,0,-1,-1,-1};
vector<int> move_x={-1,0,1,-1,0,1,-1,0,1};

int main(){
  long long H,W;
  int N;
  cin >> H >> W >> N;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }

  map<pair<int,int>,int> mp;
  for(int i=0;i<N;i++){
    for(int j=0;j<9;j++){
      int next_y=a.at(i)+move_y.at(j);
      int next_x=b.at(i)+move_x.at(j);
      if(next_y<=0 || next_y>=H-1 || next_x<=0 || next_x>=W-1)  continue;
      mp[make_pair(next_y,next_x)]++;
    }
  }

  vector<long long> ans(10,0);
  ans.at(0)=(H-2)*(W-2);
  for(auto iter=mp.begin();iter!=mp.end();iter++){
    ans.at(iter->second)++;
    ans.at(0)--;
  }
  for(int i=0;i<10;i++) cout << ans.at(i) << endl;

  return 0;
}


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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'	

using namespace std;

const int MOD = 1e9+7;
const int N = 2e5;

int main() {
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0, tmp; i < n;  ++i)
		cin >> a[i];

 	sort(a, a + n);
 	int ans = 0;
 	for (int i = 0; i < n; ++i) {
 	 	for (int j = i + 1; j < n; ++j) {
 	 	 	for (int k = j + 1; k < n; ++k) {
 	 	 	 	if (a[i] != a[j] and a[j] != a[k] and a[i] != a[k] and a[i] + a[j] > a[k])
 	 	 	 		++ans;	
 	 	 	 	else if ( a[i] + a[j] <= a[k] )
 	 	 	 		break;
 	 	 	}
 	 	}
 	}
 	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define rreps(i, n) for (int i = (n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

vf64 p;
f64 dp[3010][3010];

f64 rec(int i, int j) {
  if (dp[i][j] != -1) return dp[i][j];
  f64 ret;
  if (i == 0) {
    if (j == 0) ret = 1;
    else ret = 0;
  } else {
    if (j == 0) ret = rec(i - 1, j) * (1 - p[i - 1]);
    else ret = rec(i - 1, j - 1) * p[i - 1] + rec(i - 1, j) * (1 - p[i - 1]);
  }
  return dp[i][j] = ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  rep(i, 3010) rep(j, 3010) dp[i][j] = -1;
  rep(i, 3010) rep(j, 3010) if (i < j) dp[i][j] = 0;
  int n;
  cin >> n;
  p = vf64(n);
  rep(i, n) cin >> p[i];
  reps(i, n) rec(n, i);
  f64 ans = 0;
  for (int i = (n + 2) / 2; i <= n; i++) {
    ans += dp[n][i];
  }
  cout << ans << endl;
  return 0;
}


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

  vector<int> a;
  a.resize(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);

  int dmin = 10000;
  for(auto& x : a){
	int count = 0;
    while(x % 2 == 0){
      x /= 2;
      count++;
    }
    dmin = min(count, dmin);
  }
    
  cout << dmin << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

#define DEBUG 1



int main() {

	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = w * h / (double)2;
	
	if (2 * x == w && 2 * y == h) {
		printf("%.12f 1\n", ans);
	}
	else
	{
		printf("%.12f 0\n", ans);
	}




	return 0;
}


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

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    int arr[n];

    for (int i=0; i<n; i++){
        scanf("%d", &arr[i]);
    }

    sort(arr, arr+n);

    int ans=0;

    for (int i=0; i<k; i++){
        ans+=arr[i];
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 3796
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int i = 1, input;

    while (true) {
        cin >> input;
        if (input == 0) {
            break;
        } else {
            cout << "Case " << i << ": " << input << endl;
            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 2992
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[,] b = new int[a, 4];
        for(int i = 0; i < a; i++)
        {
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int j = 0; j < 3; j++)
                b[i, j] = c[j];
        }
        for(int i = 0; i < 3; i++)
        {
            int[] d = new int[a];
            int []f = new int[a];
            int z = 0;
            for(int j = 0; j < a; j++) {d[j] = b[j, i]; } 
            Array.Sort(d);
            for(int j = 0; j < a - 1; j++){if (d[j] == d[j + 1]) { f[z] = d[j]; z++; }}
            for(int j = 0; j < a; j++)
            {
                for(int x = 0; x < z; x++)
                {
                    if (b[j, i] == f[x]) goto stop;
                }
                b[j, 3] += b[j, i];
                stop:;
            }
        }
        for (int i = 0; i < a; i++)
        {
            Console.WriteLine(b[i, 3]);
        }
    }
}

Measured memory_bytes: 9824
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

ll pd(ll a,ll b){
  if(a>=b) return a-b;
  else return b-a;
}

int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll m=0;
  ll ans;
  rep(i,n){
    cin>>a[i];
    m=max(m,a[i]);
  }
  ll now=INF;
  if(m%2==0){
    rep(i,n){
      if(a[i]==m) continue;
      if(now>pd(m/2,a[i])){
        ans=a[i];
        now=pd(m/2,a[i]);
      }
    }
  }
  else{
    rep(i,n){
      if(a[i]==m) continue;
      if(now>pd((m-1)/2,a[i])){
        ans=a[i];
        now=pd((m-1)/2,a[i]);
      }
      if(now>pd((m+1)/2,a[i])){
        ans=a[i];
        now=pd((m+1)/2,a[i]);
      }
    }
  }
  
  cout<<m<<" "<<ans<<endl;
}
               
  




Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {
	int n,sum=0;
 
	scanf(" %d", &n);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf(" %d %d", &x, &y);
		sum += (y - x + 1);
	}
	printf("%d ", sum);
 
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n, k = 0;
    string s[200], a[100], b[100], w;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> w;
        s[i] = w;
        a[i] = w[w.size() - 1];
        b[i] = w[0];
    }


    for(int j = 0; j < n; j++)
    {
        for(int i = j+1; i < n; i++)
        {
            if(s[i] == s[j])
            {
                cout << "No";
                return 0;
            }
        }
    }

    int j = 0;
    for(int i = 1; i < n; i++)
    {
        if(b[i] != a[j])
            k++;
            j++;
    }

    if(k > 0)
        cout << "No";
    else
        cout << "Yes";

    return 0;
}

Measured memory_bytes: 3628
W,H,N=map(int,input().split())
L,D=0,0
for _ in [0]*N:
    x,y,a=map(int,input().split())
    if a==1:
        L=max(L,x)
    elif a==2:
        W=min(W,x)
    elif a==3:
        D=max(D,y)
    else:
        H=min(H,y)
print(max(0,(H-D))*max(0,(W-L)))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    string S;
    cin >> S;
    int length = S.length();
    int win = 0, lose = 0;
    Fp(i, 0, length){
        if(S[i] == 'o') win++;
        else lose++; 
    }
    if(lose >= 8) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=1000000007ll,pp=p*p;
const int N=605;
ll d[N][N],g[N][N],f[N];pii a[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,k,m,i,l,r,x,y,L;ll s,t;
    scanf("%d%d",&n,&k);m=n-k;
	f[0]=1ll;
	REP(i,0,m)f[i+1]=f[i]*(i<<1|1)%p;
	s=f[m];
    rep(i,1,k)scanf("%d%d",&a[i].fi,&a[i].se);
	per(l,n<<1,1)for(r=l+2;r<=n<<1;r+=2){
		L=(r-l)>>1;
		rep(i,1,k){
			x=l<a[i].fi&&a[i].fi<=r;
			y=l<a[i].se&&a[i].se<=r;
			if(x!=y)break;
			if(x)--L;
		}
		if(i>k){
			g[l][r]=t=f[L];
			for(i=l+2;i!=r;i+=2)if((t-=d[l][i]*g[i][r])<0ll)t+=pp;
			s=(s+(d[l][r]=t%p)*f[m-L])%p;
			//printf("d[%d][%d]=%lld\n",l,r,t%p);
		}
	}
	printf("%lld",s);
    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    puts(s=="ABC"?"ARC":"ABC");
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i = max(a, b); i > 0; i--) {
        if(a % i == 0 && b % i == 0) cnt++;
        if(cnt == k) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62
#define inf 1000000007
ll n,k,ans[100010];
vector<ll>a[100010];
void dep(ll now){
	if(now!=0&&a[now].size()==1){
		return;
	}
	ll cnt=2;
	if(now==0){
		cnt=1;
	}
	for(ll i=0;i<a[now].size();i++){
		ll next=a[now][i];
		if(ans[next]!=-1){
			continue;
		}
		ans[next]=k-cnt;
		cnt++;
		dep(next);
	}
}
int main() {
	cin>>n>>k;
	for(ll i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(ll i=0;i<n;i++){
		ans[i]=-1;
	}
	ans[0]=k;
	dep(0);
	ll ans2=1;
	for(ll i=0;i<n;i++){
	//	cout <<ans[i]<<endl;
		ans2*=ans[i];
		ans2%=inf;
	}
	cout <<ans2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
typedef long long ll;

int const MOD = 1e9+7;
int n, k;
int candy[101];
int dp[101][100001];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> candy[i];
    }

    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        ll sum = 0;
        int l = 0;
        for(int j = 0; j <= k; j++)
        {
            sum += dp[i-1][j];
        
            while(l >= 0 && l < j-candy[i])
            {
                sum -= dp[i-1][l];
                l++;
            }

            dp[i][j] = sum%MOD;
        }
    }

    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 42592
import sys

N = int(input())
if N < 6:
	print(N)
	sys.exit()
elif N < 9:
	print(1+(N-6))
	sys.exit()

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

ans = float("inf")

for i in reversed(range((N//9)+1)):
	t = N - 9*i
	t_6, t_1 = divmod(t, 6)

	time_9 = Base_10_to_n(i, 9)
	time_6 = Base_10_to_n(t_6, 6)

	ans = min(ans, sum(list(map(int, time_9))) + sum(list(map(int, time_6))) + t_1)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[t];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int max = 0;
		for (int i = 0; i < a.length; i++) {
			max = Math.max(max, a[i]);
		}

		if (max > (k + 1) / 2) {
			System.out.println(k - 1 - (k - max) * 2);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 22732
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main() {
	vector <array <int, 2>> sets;
	array <int, 2> pusher;
	int h = 0;
	int w = 0;
	bool flipr = true;
	bool flipc = true;

	while (true) {
		cin >> h >> w;
		if ((h == 0) && (w == 0)) {
			break;
		}
		pusher[0] = h;
		pusher[1] = w;
		sets.push_back(pusher);
	}
	for (auto set : sets) {
		cout << '#';
		flipr = true;
		flipc = true;
		if ((set[0] == 1) && (set[1] == 1)) {
			cout << endl << endl;
			continue;
		}
		for (int i = 0; i < set[1]-1; i++) {
			if (flipr == true) {
				cout << '.';
			} else {
				cout << '#';
			}
			flipr =! flipr;
		}
		cout << endl;
		flipc = true;
		for (int i = 0; i < set[0]-1; i++) {
			flipr = flipc;
			for (int a = 0; a < set[1]; a++) {
				if (flipr == true) {
					cout << '.';
				} else {
					cout << '#';
				}
				flipr =! flipr;
			}
			flipc =! flipc;
			cout << endl;
		}
		cout << endl;
	}
}



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

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String string = in.readLine();
        if (string.equals("SAT")) {
            System.out.println("1");
        }
        if (string.equals("SUN")) {
            System.out.println("7");
        }
        if (string.equals("MON")) {
            System.out.println("6");
        }
        if (string.equals("TUE")) {
            System.out.println("5");
        }
        if (string.equals("WED")) {
            System.out.println("4");
        }
        if (string.equals("THU")) {
            System.out.println("3");
        }
        if (string.equals("FRI")) {
            System.out.println("2");
        }
    }

}
/*


 */

Measured memory_bytes: 22228
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =  new Scanner(System.in);
		double a = sc.nextInt();
		double ans = 0;
		ans = a+Math.pow(a,2)+Math.pow(a, 3);
		
		System.out.println((int)ans);
	}

}


Measured memory_bytes: 35684
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int N;
  cin>>N;
  
  vector<int> mst;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    mst.push_back(j);
  }
  if(N%2==1){
    mst.push_back(0);
  }
  sort(mst.begin(),mst.end());
  int Alice=0,Bob=0;
  for(int i=0;i<mst.size();i+=2){
    Alice+=mst.at(i);
  	Bob+=mst.at(i+1);
  }
  cout<<abs(Alice-Bob);
}

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

using namespace std;
const int INF =  10e9 + 5;
int main() {
	int n;
	cin>>n;
	int k;
	cin>>k;
	vector<int> h(n);
	
	for(int &x: h) {
		cin>>x;
	}
	
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0;i<n;i++) {
		for(int j = i + 1;j<=i+k;j++) {
			if(j < n) {
				dp[j] = min(dp[i] + abs(h[i] - h[j]), dp[j]);
			}
		}
	}
	
	cout<<dp[n-1]<<endl;
}

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

long long solve(long long h, long long w) {
    long long result = h * w;
    for (long long i = h / 3; i < h / 3 + 3; i++) {
        long long cut1[3], cut2[3];
        cut1[0] = i * w;
        auto rest = h - i;
        cut1[1] = rest / 2 * w;
        cut1[2] = (rest - (rest / 2)) * w;
        cut2[0] = cut1[0];
        cut2[1] = w / 2 * rest;
        cut2[2] = (w - (w / 2)) * rest;
        auto p1 = minmax_element(cut1, cut1 + 3), p2 = minmax_element(cut2, cut2 + 3);
        result = min({result, *p1.second - *p1.first, *p2.second - *p2.first});
    }
    return result;
}

int main() {
    long long h, w;
    cin >> h >> w;
    long long result = solve(h, w);
    result = min(result, solve(w, h));
    cout << result;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

ll dp[100002][2][100];
int main() {
    init();

    string k; int d; cin >> k >> d;
    int n = k.length();

    dp[0][0][0] = 1;
    FOR(i, 0, n)FOR(small, 0, 2)eFOR(x, 0, (small ? 9 : k[i] - '0'))FOR(m, 0, d) {
        (dp[i + 1][small | (x < k[i] - '0')][(m + x) % d] += dp[i][small][m]) %= mod;
    }
    
    cout << (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod << "\n";
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(x, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  //ll ans = 0;
  string ans = "No";
  
  int n; cin >> n;
  string s; cin >> s;
  if (n % 2 == 0){
    bool is = true;
    rep(i, n / 2){
      if (s[i] != s[i + n / 2]) is = false;
    }
    if (is) ans = "Yes";
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
  long long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (W * H + 1) / 2 << endl;
}

Measured memory_bytes: 256
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);

const int N = 1e7;  


bool p[N];
int main(){
   IOS

   ll n; cin>>n;


   vector<ll> pr;

   for(int i = 0; i < N; i++)p[i] = true;

   p[0] = p[1] = false;

    ll sq = sqrt(n);
   for(ll i = 2; i * i<= sq; i++){
       if(p[i]){
           for(ll j = i * i; j <= sq; j += i){
               p[j] = false;
           }
       }
   }

   for(ll i = 2; i <= sq; i++)
    if(p[i])pr.pb(i);


    unordered_map<ll, int> mp;
    ll t = n;
    for(ll d : pr){
        if(d * d > t)
            break;
        while(t % d  == 0){
            mp[d]++;
            t /= d;
        }
    }

    if(t > 1)mp[t]++;

    ll ans = 0;

    ll lo, hi, mid, x;
    for(auto it : mp){
        lo = 0, hi = it.second, x = -1;

        while(lo <= hi){
            mid = lo + (hi - lo)/2;
            if((mid * (mid + 1))/2 <= it.second){
                lo = mid + 1;
                x = mid;
            }else{
                hi = mid - 1;
            }
        }

        ans += x;
    }

    cout<<ans<<"\n";

}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 14040
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    H, W, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(input() for i in range(H)) #改行行列
    cnt=0
    ans=0
    for si in S:
        cnt+=si.count("#")
    for j in range(2**(H+W)):
        c2=0
        for h in range(H):
            for w in range(W):
                if ((j>>(h+W))&1==1 or (j>>(w))&1==1) and S[h][w]=="#":
                    c2+=1
        if cnt-c2==K:
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 73592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int gcd(int a, int b) {
    if(a%b == 0) {
        return b;
    }
    else {
        gcd(b, a%b);
    }
}

int main() {
    long long int a, b;
    long long int c, d;
    cin >> a >> b >> c >> d;
    long long cd;// = (c*d)/gcd(c, d);
    if(c < d) {
        cd = (c*d)/gcd(c, d);
        //cout << (c*d)/gcd(c, d) << endl;
    }
    else {
        cd = (c*d)/gcd(d, c);
    }
    
    long long int div_ac, div_ad, div_bc, div_bd;
    div_ac = (a) / c;
    div_ad = (a) / d;
    div_bc = (b) / c;
    div_bd = (b) / d;
    if(a%c == 0) {
        div_ac--;
    }
    if(a%d == 0) {
        div_ad--;
    }
    long long int div_acd, div_bcd;
    div_acd = a / cd;
    div_bcd = b / cd;
    if(a%cd == 0) {
        div_acd--;
    }
    int flag = 0;
    if(a != 0) {
        flag = 1;
    }
    cout << (b-a+flag) - ((div_bc+div_bd-div_bcd)
                  - (div_ac+div_ad-div_acd)) << endl;
    return 0;
}

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

int main()
{
	int x,a,b;
	cin >> x >> a >> b;
	if (b <= a) cout << "delicious" << endl;
	else if (b <= (a+x)) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String frame = "";
        for (int i=0; i<w+2; i++) {
            frame += "#";
        }

        System.out.println(frame);
        for (int i=0; i<h; i++) {
            System.out.print("#");
            System.out.print(sc.next());
            System.out.println("#");
        }
        System.out.println(frame);
    }
}

Measured memory_bytes: 24020
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
a=get_i
b=get_i
ans=a.inject(:+)
N.times do|i|
    if a[i]>=b[i]
        a[i]-=b[i]
    else
        b[i]-=a[i]
        a[i]=0
        a[i+1]-=b[i]
        a[i+1]=0 if a[i+1]<0
    end
end
puts ans-a.inject(:+)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll N, K;
    cin >> N >> K;
    ll ans = 0;

    for (ll i = K; i <= N+1; i++) {
        ll ma = ((N * (N + 1)) / 2) - (((N - i) * (N - i + 1)) / 2);
        ll mi = (i * (i - 1)) / 2;
        ans += ma - mi + 1;
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

//StronglyConnectedCompoinent
struct scc_graph{
    int n;
    vector<vector<int>> graph;
    vector<vector<int>> revgraph;
    vector<int> postorder;
    vector<int> seen;

    scc_graph(int n):n(n),graph(n),revgraph(n),seen(n,-1){}

    void add_edge(int from,int to){
        graph[from].push_back(to);
        revgraph[to].push_back(from);
    }

    vector<vector<int>> scc(){
        fill(seen.begin(),seen.end(),-1);
        for(int i=0;i<n;i++){
            if(seen[i]<0) dfs(i);
        }
        fill(seen.begin(),seen.end(),-1);

        int k = 0;
        for(int i=(int)postorder.size()-1;i>=0;i--){
            if(seen[postorder[i]]<0) revdfs(postorder[i],k++);
        }

        vector<vector<int>> scc_groups(k);
        for(int i=0;i<n;i++){
            scc_groups[seen[i]].push_back(i);
        }

        return scc_groups;
    }

    void dfs(int i){
        seen[i] = 1;
        for(int j:graph[i]){
            if(seen[j]>=0) continue;
            dfs(j);
        }
        postorder.push_back(i);
    }

    void revdfs(int i,int k){
        seen[i] = k;
        for(int j:revgraph[i]){
            if(seen[j]>=0) continue;
            revdfs(j,k);
        }
    }
};

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    scc_graph G(n);
    rep(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        G.add_edge(a,b);
    }

    vector<vector<int>> ans = G.scc();

    printf("%d\n",(int)ans.size());
    rep(i,ans.size()){
        printf("%d ",(int)ans[i].size());
        rep(j,ans[i].size()){
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 79980
N, M = map(int, input().split())
S = input()
S = S[::-1]
l = len(S)

idx = 0
answer = []
flag = False
while True:
    if l - idx > M:
        m = M
    else:
        m = l - idx - 1
        flag = True
    if S[idx + m] == '0':
        answer.append(m)
        idx += m
        if flag:
            break
    else:
        while S[idx + m] == '1':
            m -= 1
            if m == 0:
                print(-1)
                exit()
        answer.append(m)
        idx += m

if answer[-1] == 0:
    answer.pop()
answer = answer[::-1]
print(' '.join(map(str, answer)))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if (s[n-1] != '0' || s[0] != '1'){
        cout << -1 << endl;
        return 0;
    }
    bool flag = false;
    REP(i, n/2){
        if(s[i] != s[n-2-i]){
            flag = true;
        }
    }

    if(flag){
        cout << -1 << endl;
        return 0;
    }

    cout << 1 << " " << 2 << endl;
    int prev = 1;
    REP(i, n-2){
        if(s[i]=='1'){
            cout << i+2 << " " << i+3 << endl;
            prev = i+2;
        }else{
            cout << prev << " " << i+3 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n,k;
cin >> n >> k;
ll h[n];
for(ll i=0;i<n;i++){
    cin >> h[i];
}
ll mini=1e9;
sort(h,h+n);
for(ll i=0;i<n-k+1;i++){
    mini=min(mini,h[i+k-1]-h[i]);
}
cout << mini << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,b,c,d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", min(a, b) + min(c, d));
	return 0;
}
int min(int a, int b)
{
	return a < b ? a : b;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	Map<Character, List<String>> map;
	long result = 0;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		map = new HashMap<>();
		map.put('M', new ArrayList<>());
		map.put('A', new ArrayList<>());
		map.put('R', new ArrayList<>());
		map.put('C', new ArrayList<>());
		map.put('H', new ArrayList<>());
		for (int i = 0; i < N; ++i) {
			String S = in.readLine();
			if (map.containsKey(S.charAt(0))) {
				map.get(S.charAt(0)).add(S);
			}
		}
	}

	long get(char key0, char key1, char key2) {
		return (long) map.get(key0).size() * (long) map.get(key1).size() * (long) map.get(key2).size();
	}

	void calc() {
		result += get('M', 'A', 'R');
		result += get('M', 'A', 'C');
		result += get('M', 'A', 'H');
		result += get('M', 'R', 'C');
		result += get('M', 'R', 'H');
		result += get('M', 'C', 'H');
		result += get('A', 'R', 'C');
		result += get('A', 'R', 'H');
		result += get('A', 'C', 'H');
		result += get('R', 'C', 'H');
		System.out.println(result);
	}

	void showResult() {
	}
}


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

int main()
{
    int n, d = 100000;
    cin >> n;
    for(; n-- ;)
    {
       if(int(d*1.05)%1000 == 0) d = (int)d*1.05;
       else
       {
            d = (int)d*1.05 + (1000- int(d*1.05)%1000);
       }
    }
    cout << d << endl;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 4e2 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll dp[MAXN][MAXN];
ll a[MAXN];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(dp, 31 , sizeof dp);
	ll n;
	cin >> n;
	for(int i = 0;i < n; i++) cin >> a[i];
	
	for(int i = 0; i < n; i++) dp[i][i + 1] = 0;
	
	for(int l = 2; l <= n; l++){
		for(int i = 0; i < n; i++){
			ll j = i + l;
			if(j > n) break;
			for(int mid = i + 1; mid < j; mid++) {
				dp[i][j] = min(dp[i][j], dp[i][mid] + dp[mid][j]);
			}
			for(int k = i; k < j; k++) dp[i][j] += a[k];
		}
	}
	
	cout << dp[0][n];
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  ll H[N];
  for(int i=0;i<N;++i) cin>>H[i];
  vector<vector<int> > edge(N);
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  bool can;
  int ans = 0;
  for(int i=0;i<N;++i) {
    can = true;
    for(int j=0;j<edge[i].size();++j) {
      if(H[i]<=H[edge[i][j]]) can = false;
    }
    if(can) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9044