akhauriyash/Code-Regression huggingface dataset:
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

   
//-----------------------------------------------------------------------------------------------------------//

    READV(a);
    READV(b);
    FORI(i,0,max(a,b))
    {
        cout<<min(a,b);
    }
    cout<<endl;

//-----------------------------------------------------------------------------------------------------------//


   
    return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) i, N, K, Q, a
  integer(8),allocatable ::  ANS(:)
  read(*, *)N, K, Q
  !allocate(A(Q))
  allocate(ANS(N))
  do i = 1,N
    ANS(i) = 0
  enddo
  do i = 1,Q
    read(*, *) a
    ANS(a) = ANS(a) + 1
  enddo
  do i = 1,N
    if (ANS(i) > Q-K) then
      write(*, *) 'Yes'
    else
      write(*, *) 'No'
    end if
  end do
end program main


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

int main()
{
 long long int n,x,y,a[2000],i,t,k;
  
  scanf("%lld %lld %lld",&n,&x,&y);
  
  for(i=0;i<=n-1;i++)
  {
    a[i]=0;
  }
  
  for(i=1;i<n;i++)
  {
    for(t=i+1;t<=n;t++)
    {
      if(t<=x||y<=i)
      {
        k=t-i;
      }
      else if(i<=x&&y<=t)
      {
        k=t-y+x-i+1;
      }
      else if(i<=x&&y>t)
      {
        k=t-i;
        if(k>(y-t+1+x-i))
        {
          k=y-t+1+x-i;
        }
      }
      else if(i>x&&y<=t)
      {
        k=t-y+i-x+1;
        if(k>t-i)
        {
          k=t-i;
        }
      }
      else if(i>x&&y>t)
      {
        k=y-t+i-x+1;
        if(k>t-i)
        {
          k=t-i;
        }
      }
    a[k]=a[k]+1;
    }
  }
  
  for(i=1;i<n;i++)
  {
   printf("%lld\n",a[i]);
  }

  
  return 0;
  
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 105;

int n;
int H[Maxn];
vector <int> un;
int dp[Maxn][Maxn];
int res;

int toPower(int a, int p)
{
	int res = 1;
	while (p) {
		if (p & 1) res = ll(res) * a % mod;
		p >>= 1; a = ll(a) * a % mod;
	}
	return res;
}

int main()
{
	scanf("%d", &n);
	un.push_back(0);
	for (int i = 0; i < n; i++) {
		scanf("%d", &H[i]);
		un.push_back(H[i]);
	}
	sort(un.begin(), un.end());
	un.erase(unique(un.begin(), un.end()), un.end());
	for (int j = 0; j < un.size() && un[j] <= H[0]; j++) {
		int ways = j == 0? 1: 2;
		if (j + 1 < un.size() && un[j + 1] <= H[0]) {
			ways = ll(ways) * (ll(toPower(2, un[j + 1] - un[j]) - (j == 0? 2: 1) + mod)) % mod;
			ways = ll(ways) * ll(toPower(2, H[0] - un[j + 1])) % mod;
		}
		dp[0][j] = ways;
	}
	for (int i = 0; i + 1 < n; i++)
		for (int j = 0; j < un.size() && un[j] <= H[i]; j++) {
			if (un[j] < H[i + 1])
				if (un[j] < H[i]) {
					int ways = dp[i][j];
					if (H[i + 1] > H[i]) ways = ll(ways) * toPower(2, H[i + 1] - H[i]) % mod;
					dp[i + 1][j] = (dp[i + 1][j] + ways) % mod;
				} else {
					for (int k = j; k < un.size() && un[k] <= H[i + 1]; k++) {
						int ways = 2 * dp[i][j] % mod;
						if (k + 1 < un.size() && un[k + 1] <= H[i + 1]) {
							ways = ll(ways) * (ll(toPower(2, un[k + 1] - un[k]) - 1 + mod)) % mod;
							ways = ll(ways) * ll(toPower(2, H[i + 1] - un[k + 1])) % mod;
						}
						dp[i + 1][k] = (dp[i + 1][k] + ways) % mod;
					}
				}
			else {
				int ind = lower_bound(un.begin(), un.end(), H[i + 1]) - un.begin();
				dp[i + 1][ind] = (dp[i + 1][ind] + 2ll * ll(dp[i][j])) % mod;
			}
		}
	for (int j = 0; j < un.size(); j++)
		res = (res + dp[n - 1][j]) % mod;
	printf("%d\n", res);
	return 0;
}

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

using namespace std;

int end_count[501][501] = {};
int acc[501][501] = {};

int main(){
  int n, m, q;
  cin >> n >> m >> q;
  for (int i=0;i<m;i++) {
    int l, r;
    cin >> l >> r;
    end_count[l][r]++;
    // cout << "i = " << i << endl;
  }

  
  for (int l=0;l<501;l++) {
    int acc_tmp = 0;
    for (int r=0;r<501;r++) {
      acc_tmp += end_count[l][r];
      acc[l][r] = acc_tmp;
    }
  }
  for (int i=0;i<q;i++) {
    int pl, pr;
    cin >> pl >> pr;
    int ans = 0;
    for (int l=pl;l<=pr;l++) {
	ans += acc[l][pr];
    }
    cout << ans << endl;
  }
  // for (int l=0;l<=m;l++) {
  //   for (int r=0;r<=m;r++) {
  //     cout << end_count[l][r] << "\t";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // for (int l=0;l<=m;l++) {
  //   for (int r=0;r<=m;r++) {
  //     cout << acc[l][r] << "\t";
  //   }
  //   cout << endl;
  // }
  return(0);
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long
const int mod = 1e9 + 7;
signed main() {
    int n;
    cin >> n;
    vector<int> c(n), dp(n, 0);
    for (int& i : c) cin >> i;
    vector<int> stn(2e5 + 5, -1);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        if (i) dp[i] = dp[i - 1];
        if (stn[c[i]] >= 0 && stn[c[i]] + 1 < i) (dp[i] += dp[stn[c[i]]]) %= mod;
        stn[c[i]] = i;
    }
    cout << dp[n - 1];
}

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

int main (){
  int N,K;
  cin >> N >> K;
  int sum = 0;
  for(int i = 0; i < N; i++){
    int xi;
    cin >> xi;
    int diff_b = K-xi;
    if(xi < K-xi){
      sum += 2 * xi;
    }
    else{
      sum += 2 * (K-xi); 
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    
    int i,n,j,l;
    char a[100][10000],tmp[10000];
    
    scanf("%d",&n);scanf("%d",&l);
    for(i=0;i<n;i++){
        scanf("%s",&a[i]);
    }
    
    for(i=1;i<n;i++){
    for(j=n-1;j>=1;j--){
        if(strcmp(a[j],a[j-1])<0){
            strcpy(tmp,a[j-1]);
            strcpy(a[j-1],a[j]);
            strcpy(a[j],tmp);
            }
        }
    }
    
    for(i=0;i<n;i++) printf("%s",a[i]);
    printf("\n");
}

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

const int N = (int)2e5 + 5;
const long long inf = (long long)1e18 + 18;

long long n,a[N],ans = inf,pref[N];

int main(){
    	cin >> n;
    	for(int i = 1; i <= n; i++){
    		cin >> a[i];
    		pref[i] = pref[i - 1] + a[i];
    	}
    	for(int i = 1; i <= n; i++){
    		ans = min(ans,abs(pref[i] - (pref[n] - pref[i])));
    	}
    	cout << ans;
	return 0;
}

Measured memory_bytes: 3328
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b==0:
            n = n//b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct

n = int(input())
ans = 0
for i,j in factorize(n):
    ans += -(-int(((1 + 8*j)**(1/2) - 1 )/ 2))
print(ans)

Measured memory_bytes: 9376
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

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

	cout << (a < b ? 0 : 10) << endl;
}

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

int n,pre,maap[1000000],ans;

int main(){
	scanf("%d",&n);
	pre = n;
	ans = 0;
	while(1){
		ans ++;
		if(maap[pre]!=0) break;
		maap[pre] = 1;
		if(pre&1){
			pre = pre*3+1;
		} else {
			pre /=2;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

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

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 main() {
    ios::sync_with_stdio(false);
    const double PI = 3.14159265358979323846;

    int r;
    cin >> r;
    cout << (double)(r * 2) * PI << endl;
    return 0;
}


Measured memory_bytes: 3800
//1171201016　稲村佑哉
//久々のC++での演習だったが、ゲーム形式で楽しく復習できた。
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,ans;
bool a[100];
vector<pair<LL, LL>> r,b;
pair<LL, LL>d;
int main() {
	cin >> N;
	vector<pair<LL, LL>> r, b;
	for (int i = 0; i < N; i++) {
		cin >> d.first >> d.second;
		r.push_back(d);
		a[i] = true;
	}

	for (int i = 0; i < N; i++) {
		cin >> d.first >> d.second;
		b.push_back(d);
	}
	sort(b.begin(), b.end());
	int c;
	int max_y;
	for (int i = 0; i < N; i++) {
		c = -1;
		max_y = -1;
		for (int j = 0; j < N; j++) {
			if (a[j]&&b[i].first > r[j].first&&b[i].second > r[j].second) {
				if (max_y < r[j].second) {
					max_y = r[j].second;
					c = j;
				}
			}
		}
		if (c >= 0) {
			a[c] = false;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))//数组(结构体)清零 
#define ll long long
//int A(int a,int b){if(a<b||a<1||b<0)return 0;int k=1;while(b--){k*=a--;}return k;}//数学中的Aab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int C(int a,int b){if(a<b||a<1||b<0)return 0;b=min(a-b,b);int k=A(a,b),t=1;while(--b)k/=++t;return k;}//数学中的Cab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int HW(char*HWa,int HWl,int HWr){if(HWr<HWl)swap(HWl,HWr);for(int i=0;i<(HWr-HWl)/2+1;i++)if(HWa[HWl+i]!=HWa[HWr-i])return 0;return 1;}//传递字符串名,判断区间l r,如果是回文字符串就返回1,否则返回0 
//int SS(int a){if(a>4&&((a-1)%6)&&((a+1)%6))return 0;for(int i=2;i<=sqrt(a);i++)if(a%i==0)return 0;return 1;}//判断一个数是不是质数，是1 否0；请确保a>1; 
/*记得如果改int为long long,就把printf与scanf中相应的%d也改成%lld*/

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


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::string S;
int cnt[26] = {};

int main(int argc, char **argv) {
    std::cin >> S;

    for (int i = 0; i < 4; i++) {
        cnt[S[i]-'A']++;
    }

    int ret = 0;
    for (int i = 0; i < 26; i++) {
        if (2 <= cnt[i]) {
            ret++;
        }
    }

    if (ret == 2) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

int main() {
    int N, M, ans = 0, p[10], k, s;
    cin >> N >> M;
    vector<int>swt[N];
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            cin >> s;
            swt[s-1].push_back(i);
        }
    }
    rep(i, M) cin >> p[i];
    
    // bit全探索
    for (int i = 0; i < (1 << N); i++) {
        int now[M] = {};
        rep(j, N) {
            if (i & (1 << j)) {
                for (int k : swt[j]) {
                    now[k] ^= 1;
                }
            }
        }
        rep(j, M) {
            if (p[j] != now[j]) break;
            if (j == M-1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,ans,maxn;
char s;
int main()
{
	cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=='I')ans++;else ans--;
        maxn=max(maxn,ans);
    }
    cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int odd = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 != 0) {
			odd++;
		}
	}
	cout << (double)odd / (double)N << endl;
}

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

int main(){
  
  long long x;
  cin>>x;

  if(x%11==0){
    cout<<x/11*2<<endl;
  }else if((x-x/11*11)>6){
    cout<<x/11*2+2<<endl;
  }else{
    cout<<x/11*2+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a[3];
  REP(i, 3) cin >> a[i];
  sort(a, a + 3);
  ll ans = a[2] - a[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for( i=a;i<b;i++)
#define rep1(i,a,b)    for(int i=a;i<b;i++)

#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int a,b,n,x,y;
    cin>>a>>b>>n;
    x=(n/b*b)-1;
    if(x<0) x=1;
    y=(a*x)/b-(a*(x/b));
    cout<<max((a*n)/b-(a*(n/b)),y);
    return 0;
}   
     
signed main(){      
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;   
    while(t--){
        solve();
        //if(solve()) cout<<"YES";
        //else cout<<"NO";
        cout<<"\n";
    }
    return 0;
}   

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll k; cin >> k;
  queue<ll> q;
  for (int i = 1; i < 10; i++) q.push(i);
  rep(i, k-1) {
    ll x = q.front(); q.pop();
    // debug2(i+1, x);
    if (x % 10 != 0) {
      // debug2("add", x * 10 + (x % 10 - 1));
      q.push(x * 10 + (x % 10 - 1));
    }
    q.push(x * 10 + x % 10);
    if (x % 10 != 9) {
      // debug2("add", x * 10 + (x % 10 + 1));
      q.push(x * 10 + (x % 10 + 1));
    }
  }
  outl(q.front());
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

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

    int A[m] = {};
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            --a;
            A[a]++;
        }
    }

    int res = 0;
    rep(i, m) {
        if (A[i] == n) res++;
    }
    cout << res << endl;


    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int result = 0;

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

    if (x < K - x) {
      result = result + x *2;
    } else {
      result = result + (K-x)*2;
    }
  }
  
  cout << result << endl;
}



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

#define ll long long
#define ar array

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

	int n, p;
	string s;
	cin >> n >> p >> s;
	ll ans=0;
	if(p==2) {
		for(int i=0; i<n; ++i)
			if((s[i]-'0')%2==0)
				ans+=i+1;
	} else if(p==5) {
		for(int i=0; i<n; ++i)
			if((s[i]-'0')%5==0)
				ans+=i+1;
	} else {
		map<int, int> mp;
		++mp[0];
		int t=0, p2=1;
		for(int i=n-1; ~i; --i) {
			t=(t+(s[i]-'0')*p2)%p;
			ans+=mp[t];
			mp[t]++;
			p2=p2*10%p;
		}
	}
	cout << ans;
}


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

int GCD(int a,int b){
    if(a<b) swap(a,b);
    //cout << a << " " << b << endl;
    if(b == 0) return a;
    else return GCD(a%b, b);
}

int main(){
    int N; cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];

    int g = 0;
    for(int i=0;i<N;i++){
        g = GCD(g,A[i]);
    }

    cout << g << endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n + k);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	vector<int> dp(n + k, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m;
  cin >> n >> m;
  int upper = n;
  int lower = 1;
  rep(i,m) {
    int L,R; cin >> L >> R;
    lower = max(lower, L);
    upper = min(upper, R); 
  }
  cout << max(upper - lower + 1, 0) << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
#define M 1000000007
int main()
{
    ll n,k;
    ll sum=0,a,b;
    scanf("%lld %lld",&n,&k);
    if(k>n)
    {
        printf("1\n");
    }
    else
    {
        for(ll i=k;i<=n+1;i++)
        {
            a=i*(i-1)/2;
            b=(2*n-i+1)*i/2;
            sum+=b-a+1;
            sum=sum%M;
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n, d, c=0;
  cin >> n >> d;
  for(int i=0;i<n;i++){
    int64_t x, y;
    cin >> x >> y;
    int64_t a=x*x;
    int64_t b=y*y;
    if(a+b<=d*d) c++;
  }
  cout << c<< endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

vector<string> split(string s) {
	int n = s.length();
	if (s[n - 1] == '/') s += "unko";
	s += '/';
	s.erase(s.begin());
	vector<string> v;
	while (!s.empty()) {
		int i = s.find('/');
		v.push_back(s.substr(0, i));
		s.erase(0, i + 1);
	}
	return v;
}

struct node {
	bool leaf;
	int par;
	map<string, int> ch;
};

int main() {
	for (;;) {
		int N, M; cin >> N >> M;
		if (N == 0 && M == 0) break;
		vector<node> v(2);
		v[1].leaf = true; v[1].par = 0;
		while (N--) {
			string s; cin >> s;
			vector<string> w = split(s);
			int k = 1;
			for (int j = 0; j < w.size(); j++) {
				string& t = w[j];
				if (!v[k].ch[t]) {
					v[k].leaf = false;
					v[k].ch[t] = v.size();
					node n; n.leaf = true; n.par = k;
					v.push_back(n);
				}
				k = v[k].ch[t];
			}
		}
		while (M--) {
			int a[2];
			for (int i = 0; i < 2; i++) {
				string s; cin >> s;
				if (s == "") {
					a[i] = 0;
					continue;
				}
				vector<string> w = split(s);
				int& k = a[i];
				k = 1;
				for (int j = 0; j < w.size(); j++) {
					string& t = w[j];
					if (t == "unko") k = v[k].ch["index.html"];
					else if (t == ".");
					else if (t == "..") {
						if (v[k].leaf) k = 0;
						else k = v[k].par;
					}
					else k = v[k].ch[t];
					if (k == 0) break;
				}
				int n = w.size();
				if (w[n - 1] != "unko")
					if (!v[k].leaf)
						k = v[k].ch["index.html"];
				if (!v[k].leaf) k = 0;
			}
			if (a[0] && a[1]) cout << (a[0] == a[1] ? "yes" : "no") << endl;
			else cout << "not found" << endl;
		}
	}
}

Measured memory_bytes: 1252
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

string ABC = "ABC";

void solve(ll N, string S) {
  int ans{};
  for(auto i = 0; i != N; ++i) {
    if(equal(ALL(ABC),S.begin()+i)) ++ans;
  }
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int n,root=-1;
int dfs(int x,int fa){
    int res=0;
    int flag=0;
    for(int i=0;i<a[x].size();i++){
        if(a[x][i]==fa)
            continue;
        int res1=dfs(a[x][i],x);
        if(res1==0&&flag==1)
            res++;
        if(res1==0&&flag==0)
            flag=1;
        res+=res1;
    }
    return res;
}
int main(){
    SF("%d",&n);
    int u,v;
    for(int i=1;i<n;i++){
        SF("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i=0;i<n;i++)
        if(a[i].size()>=3){
            root=i;
            break;
        }
    if(root==-1){
        PF("1");
        return 0;
    }
    PF("%d",dfs(root,-1));
}

Measured memory_bytes: 9984
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string S;
	cin >> S;

	vector<int> ans(S.size());
	int cntR = 0, cntL = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') cntR++;
		else if (cntR){
			ans[i - 1] = cntR;
			cntR = 0;
		}
	}

	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'L') cntL++;
		else if (cntL){
			ans[i + 1] = cntL;
			cntL = 0;
		}
	}

	for (int i = 0; i < S.size()-1; i++) {
		if (S[i] == 'R'&&S[i + 1] == 'L') {
			int tmp = ans[i] + ans[i + 1];
			if (tmp % 2 == 0) {
				ans[i] = tmp / 2;
				ans[i + 1] = tmp / 2;
			}
			else if (ans[i] % 2 == 0){
				ans[i] = tmp / 2;
				ans[i + 1] = tmp / 2 + 1;
			}
			else {
				ans[i] = tmp / 2 + 1;
				ans[i + 1] = tmp / 2;
			}
		}
	}

	for (const auto &e : ans) cout << e << " ";

	return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define int long
vector<vector<int>> v;
vector<int> vis,dp;
int ans=0;
int dfs(int node)
{
//     cout<<node<<endl;
     int x;
     vis[node]=1;
     int mx=0;
     for(auto i:v[node])
     {
          if(!vis[i])
             x=dfs(i);
          mx=max(mx,dp[i]+1);
     }
     ans=max(ans,mx);
     dp[node]=mx;
     return mx;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,m,x,y;
 cin>>n>>m;
 dp=vector<int>(n+1);
 v=vector<vector<int>>(n+1);
 vis=vector<int>(n+1);
 
 for(int i=1;i<=m;i++)
 {
      cin>>x>>y;
      v[x].push_back(y);
//      v[y].push_back(x);
 }
 for(int i=1;i<=n;i++){
   if(!vis[i])
   dfs(i);
 }
//  for(int i=1;i<=n;i++)
//  cout<<dp[i]<<" ";
 cout<<ans;
}

Measured memory_bytes: 9344
class Card:
    def __init__(self,m, v):
        self.m = m
        self.v = v
    
    def __repr__(self):
        return str(self.m) + ' ' + str(self.v)


def quicksort(A, p, r):
    #print("init",p,r)
    if p < r:
        #print("calcq")
        q = partition(A, p, r)
        #print("q=",q)
        #print("sortleft")
        quicksort(A, p,q-1)
        #print("sortright")
        quicksort(A,q+1,r)

def partition(A, p, r):
  x = A[r]
  i = p-1
  #print("s",A,p,r,i)
  for j in range(p,r):
    #print("compr",A[j],x)
    if A[j].v <= x.v:
      i = i+1
      #print("change! idx", i ,j)
      A[i], A[j] = A[j], A[i]
    #print(A)
  A[i+1],A[r] = A[r], A[i+1]
  #print("e",A,p,r,i+1)
  return i+1

cnt = 0
def merge(A, left, mid, right):
  global cnt
  n1 = mid - left
  n2 = right - mid
  #L = [0] * (n1+1)
  #R = [0] * (n2+1)
  #print("init ",left,mid,right,A[left:mid],A[mid:right],n1,n2)
  L = [Card(None,None) for i in range(n1+2)]
  R = [Card(None,None) for i in range(n2+2)]
  #print("check ", L, R)
  for i in range(n1):
    L[i] = A[left + i]
  for i in range(n2):
    R[i] = A[mid + i]
  L[n1].v = 9999999999999
  R[n2].v = 9999999999999
  #print("split ",n1,n2, L, R)
  i = 0
  j = 0
  for k in range(left,right):
    cnt+=1
    if L[i].v <= R[j].v:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1
  #print("reslt ",A)

def mergeSort(A, left, right):
  #print("margeSort ",A[left:right])
  if left+1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

A1 = []
A2 = []
n = int(input())

for i in range(n):
    A = input().split()
    A1.append(Card(A[0],int(A[1])))
    A2.append(Card(A[0],int(A[1])))

quicksort(A1,0,n-1)

mergeSort(A2,0,n)

flag = True
for i in range(n):
    if A1[i].m != A2[i].m:
        flag = False
        print("Not stable")
        break    
if flag:
    print("Stable")

for i in range(0,n):
    print(A1[i])
    #print(A2[i])



Measured memory_bytes: 64404
#include<stdio.h>

int main(void)
{
	long int n,i,p;
	scanf("%ld",&n);
	long int min=200001;
	long int ans=0;
	
	for(i=0;i<n;i++){
		scanf("%ld",&p);
		if(p<min){
			ans++;
			min=p;
		}
	}
	
	printf("%ld",ans);
	return 0;
}
		
		

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int main()
{
	string str;
	int q;

	cin >> str;
	cin >> q;

	while (q--)
	{
		string cmd;
		cin >> cmd;

		if (cmd == "print")
		{
			int a, b;
			cin >> a >> b;

			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (cmd == "reverse")
		{
			int a, b;
			cin >> a >> b;

			reverse(str.begin() + a, str.begin() + b + 1);
		}
		else if (cmd == "replace")
		{
			string p;
			int a, b;
			cin >> a >> b >> p;

			str.replace(str.begin() + a, str.begin() + b + 1, p);
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll X,Y,Z;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>X>>Y>>Z;
	swap(X,Y);
	swap(X,Z);
	cout<<X<<" "<<Y<<" "<<Z;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int main(){
    int a,b,c,d;
    scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
    for(int i=43;i<=45;i+=2){
        for(int j=43;j<=45;j+=2){
            for(int k=43;k<=45;k+=2){
                int ans=a;
                if(i==43)ans+=b;
                	else ans-=b;
                if(j==43)ans+=c;
                	else ans-=c;
                if(k==43)ans+=d;
               	 	else ans-=d;
                if(ans==7){
                    printf("%d%c%d%c%d%c%d=7\n",a,i,b,j,c,k,d);
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int N, out = 0;
    cin >> N;
    unsigned int L[N];
    for(int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; j < N; j++)
        {
            if(L[i] == L[j])
            {
                continue;
            }
            for(int k = j+1; k < N; k++)
            {
                if((L[i] == L[k]) || (L[j] == L[k]))
                {
                    continue;
                }
                if((L[i] + L[j] > L[k]) && (L[j] + L[k] > L[i]) && (L[k] + L[i] > L[j]))
                {
                    out++;
                }
            }
        }
    }
    cout << out << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


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

int main(){
    //n..線路の情報の数 m..駅の数
    while(true){
        int n,m;
        cin >> n >> m;

        if(n==0&&m==0){
            return 0;
        }


        int money[m][m];
        int time[m][m];

        for(int i=0;i<m;i++){
            for(int j=0;j<m;j++){
                if(i==j){
                    money[i][j] = 0;
                    time[i][j] = 0;
                }else{
                    money[i][j] = 10000;
                    time[i][j] = 10000;
                }
            }
        }

        for(int i=0;i<n;i++){
            int a,b,c,t;
            cin >> a >> b >> c >> t;
            //入力から表の作成
            money[a-1][b-1] = money[b-1][a-1] = c;
            time[a-1][b-1] = time[b-1][a-1] = t;
        }

        for(int k=0;k<m;k++){
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    money[i][j] = min(money[i][j],money[i][k]+money[k][j]);
                    time[i][j] = min(time[i][j],time[i][k]+time[k][j]);
                }
            }
        }



        //問い合わせ数
        int k;
        cin >> k;

        int p[k],q[k],r[k];

        for(int i=0;i<k;i++){
            cin >> p[i] >> q[i] >> r[i];
        }


        for(int i=0;i<k;i++){
            if(r[i]==0){
                cout << money[p[i]-1][q[i]-1] << endl;
            }else{
                cout << time[p[i]-1][q[i]-1] << endl;
            }
        }
    }
    
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=true;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////


void answer(){
    int a;
    cin>>a;
    if(a==0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int  b = 0, c = 0, d = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur = 0, kmr = 0, yju = 0, counto[5003], counto1[5003];
char fir, sec = 'z', mado[15][15], homu[52][52];
string rik, mrsm[55], tok[25003];
bool mazi[110], gi[110], zi, manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<char> bb, dd;
map<char, int>zis, uuu;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

void dfs(int h, int w) {
	mado[h][w] = '0';
	for (int i = 0; i < 4; i++) {
		if (h + dx[i] >= 0 && h + dx[i] <= 12 && w + dy[i] >= 0 && w + dy[i] <= 12 && mado[h + dx[i]][w + dy[i]] == '1') {
			dfs(h + dx[i], w + dy[i]);
		}
	}
}
int main() {
		string a;
		while (cin >> a) {
			for (int i = 0; i < 12; i++) {
				for (int j = 0; j < 12; j++) {
					mado[i][j] = a[j];
				}
				if (i != 11) { cin >> a; }
			}
			int ans = 0;
			for (int i = 0; i < 12; i++) {
				for (int j = 0; j < 12; j++) {
					if (mado[i][j] == '1')dfs(i, j), ans++;
				}
			}
			cout << ans << endl;
		}
	
	return 0;
}
	




Measured memory_bytes: 3264
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL x[SIZE],v[SIZE];
LL ma[SIZE][2];
int main(){
    int N;
    LL C;
    R(N,C);
    FOR(i,1,N) R(x[i],v[i]);
    LL now=0;
    FOR(i,1,N){
        now+=v[i];
        REP(j,2){
            ma[i][j]=max(ma[i-1][j],now-x[i]*(j+1LL));
        }
    }
    LL an=ma[N][0];
    now=0;
    for(int i=N;i>0;i--){
        now+=v[i];
        an=max(an,now+ma[i-1][0]-(C-x[i])*2);
        an=max(an,now+ma[i-1][1]-(C-x[i]));
    }
    W(an);
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  int n,m;
  cin >> n >> m;
  string s="";
  vector<bool>vec(n);
  rep(i,n){
    s+='0';
    vec[i]=true;
  }
  if(m==0){
    if(n!=1){
      cout << pow(10,n-1) << endl;
    }
    else cout << 0 << endl;
    return 0;
  }
  if(n==1){
    rep(i,m){
      int a;
      char b;
      cin >> a >> b;
      a--;
      if(vec[a]){
        s[a]=b;
        vec[a]=false;
      }
      else{
        if(s[a]==b)continue;
        else{
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  else{
    rep(i,m){
      int a;
      char b;
      cin >> a >> b;
      a--;
      if(n>1 && a==0 && b=='0'){
        cout << -1 << endl;
        return 0;
      }
      else{
        if(vec[a]){
          s[a]=b;
          vec[a]=false;
        }

        else if(!vec[a]){
          if(s[a]==b)continue;
          else{
            cout << -1 << endl;
            return 0;
          }
        }
      }
    }
  }
  if(n>1 && s[0]=='0')s[0]='1';
  cout << s << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
int a[3001], p[3001], N, f[3001];
std::vector < int > E[3001];
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", a + i);
		p[i] = i;
	}
	std::sort(p + 1, p + N + 1, [] (int x, int y) { return a[x] < a[y]; });
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		if (a[u] > a[v])
			E[u].push_back(v);
		if (a[v] > a[u])
			E[v].push_back(u);
	}
	for (int i = 1; i <= N; i++)
		for (int j : E[p[i]])
			f[p[i]] |= !f[j];
	for (int i = 1; i <= N; i++)
		if (f[i])
			printf("%d ", i);
	puts("");
	return 0;
}


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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int>c(N);
  vector<int>t(N);
  for(int i =0;i<N;i++){
    cin >> c.at(i) >> t.at(i);
  }
  int answer=1000;
    for(int j=0;j<N;j++){
     if((t.at(j)<=T)&&(answer>c.at(j))){
       answer = c.at(j);
    }
  }
  sort(t.begin(),t.end());
  
     if(t.at(0)>T){
      cout << "TLE" << endl;
     }else{
      cout << answer << endl;
  }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    double prob = 0.0;

    for (int i=1; i<=N; i++) {
        double prob_i = 1.0 / N;
        int score = i;
        while (score < K) {
            prob_i *= 1.0 / 2.0;
            score *= 2;
        }
        prob += prob_i;
    }

    cout << fixed << setprecision(15) << prob << endl;

    return 0;
}



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

using namespace std;

#define ll long long
#define MOD 1000000007
#define MAX 1005
ll dp[MAX][MAX];
string str[MAX];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++) cin >> str[i];
    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(str[i][j] == '#') dp[i][j] = 0;
            else {
                if(j-1>=0) dp[i][j] += dp[i][j-1];
                if(i-1>=0) dp[i][j] += dp[i-1][j];
            }
            dp[i][j] = dp[i][j]%MOD;
        }
    }
    printf("%lld\n", dp[n-1][m-1]);
}


Measured memory_bytes: 9088
#include<iostream>
#include<string>
#define N 12
using namespace std;
string is[N];
bool same(int x,int y){
  if(x<0||x>=N||y<0||y>=N) return false;
  return true;
}
void land(int x,int y){
  is[x][y] = '0';
  for(int i=-1;i<=1;i+=2){
    if(same(x+i,y)){
      if(is[x+i][y]=='1') land(x+i,y);
    }
    if(same(x,y+i)){
      if(is[x][y+i]=='1') land(x,y+i);
    }
  }
}
int main(){
  while(cin>>is[0]){
    int count=0;
    for(int i=1;i<N;i++) cin >> is[i];
     for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if(is[i][j]=='1'){
	  count++; 
	  land(i,j);
	}
      }
     }
     cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

type record struct {
	num         int
	numOfPeople int
}

func (r record) String() string {
	return strconv.Itoa(r.num)
}

type records []record

func (a records) Len() int           { return len(a) }
func (a records) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a records) Less(i, j int) bool { return a[i].numOfPeople < a[j].numOfPeople }

func newRecord(num, numOfPeople int) record {
	return record{num: num, numOfPeople: numOfPeople}
}

func restoreOrder(rs records) records {
	sort.Sort(rs)
	return rs
}

func main() {
	n := nextInt()
	rs := make(records, n)
	for i := 0; i < n; i++ {
		rs[i] = newRecord(i+1, nextInt())
	}
	results := restoreOrder(rs)
	for i, result := range results {
		fmt.Print(result)
		if i != len(results)-1 {
			fmt.Print(" ")
		}
	}
}


Measured memory_bytes: 5504
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        ArrayList<Number> list = new ArrayList<Number>();
        list.add(s);
        int count = 1;
        while(true){
            if(s%2 == 0){
                s = s/2;
            }else{
                s = 3*s + 1;
            }
            count++;
            if(list.contains(s)){
                System.out.println(count);
                return;
            }else{
                list.add(s);
            }
        }
    }
}


Measured memory_bytes: 35644