akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
 
using namespace std;
 
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
 
struct Hoge {
  long long w, t, x, i, res;
};
struct Piyo {
  long long y, i, res;
};
Hoge hoge[111111];
Piyo piyo[111111];
long long a, b, b1, c, c1, c2;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > q1, q2, q3;
 
int main() {
  long long n, q;
  cin >> n >> q;
  rep (i, n) cin >> hoge[i].w >> hoge[i].t >> hoge[i].x;
  rep (i, n) hoge[i].i = i;
  rep (i, n) hoge[i].res = -1;
  rep (i, q) cin >> piyo[i].y;
  rep (i, q) piyo[i].i = i;
  long long k = 0, kk = 0, qq = 0;
  while (kk < n && hoge[kk].w <= k) {
    hoge[kk].res = 0;
    if (hoge[kk].t == 0) {
      q1.push(make_pair(hoge[kk].x - 1, hoge[kk].x));
      ++a;
    }
    if (hoge[kk].t == 1) {
      q2.push(make_pair(hoge[kk].x - 1, hoge[kk].x));
      ++b1;
    }
    if (hoge[kk].t == 2) {
      q3.push(make_pair(hoge[kk].x - 1, hoge[kk].x));
      --c1;
      c2 += 2;
    }
    ++kk;
  }
  rep (i, 3652426) {
    //cout << i << " " << k << " " << a << " " << b << " " << b1 << " " << c << " " << c1 << " " << c2 << endl;
    while (qq < q && piyo[qq].y == i) {
      piyo[qq].res = k;
      ++qq;
    }
    b += b1;
    c1 += c2;
    c += c1;
    ++k;
    k += a;
    k += b;
    k += c;
    while (!q1.empty() && q1.top().first == i) {
      q1.pop();
      --a;
    }
    while (!q2.empty() && q2.top().first == i) {
      b -= q2.top().second;
      q2.pop();
      --b1;
    }
    while (!q3.empty() && q3.top().first == i) {
      long long h = q3.top().second;
      c2 -= 2;
      c1 -= 2 * h - 1;
      c -= h * h;
      q3.pop();
    }
    while (kk < n && hoge[kk].w <= k) {
      hoge[kk].res = i + 1;
      if (hoge[kk].t == 0) {
	q1.push(make_pair(i + hoge[kk].x, hoge[kk].x));
	++a;
      }
      if (hoge[kk].t == 1) {
	q2.push(make_pair(i + hoge[kk].x, hoge[kk].x));
	++b1;
      }
      if (hoge[kk].t == 2) {
	q3.push(make_pair(i + hoge[kk].x, hoge[kk].x));
	--c1;
	c2 += 2;
      }
      ++kk;
    }
    if (qq == q && kk == n) break;
  }
  rep (i, n) {
    if (hoge[i].res > -1 && hoge[i].res <= 3652425) cout << hoge[i].res << endl;
    else cout << "Many years later" << endl;  
  }
  rep (i, q) cout << piyo[i].res << endl;
  return 0;
}

Measured memory_bytes: 9292
import sys

N = int(input())

Tmp = []
Tmp = input().rstrip().split(' ')

D = int(Tmp[0])
X = int(Tmp[1])


Ans = 0
if D == 1:
    Ans = N + X
    print(Ans)
    sys.exit()

Count = 0
for i in range(N):
    K = int(input())
    TmpN = 1
    Flag = 0
    while Flag==0:
        TmpNum = K * (TmpN - 1) + 1
        if TmpNum > D:
            Flag = 1
            break
        else:
            Count += 1
        
        TmpN += 1

Ans = Count + X
print(Ans)
    


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,n; cin>>k>>n;
    vll a(n), b(n);
    rep(i,n) cin>>a[i];
    a.pb(a[0]+k);
    rep(i,n) b[i] = a[i+1]-a[i];
    ll ans=k;
    rep(i,n){
        chmin(ans,k-b[i]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
     lint n,q;
     string s;

     cin>>s;
        if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
        else cout<<"No";

  }
  
  
     
  

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

using namespace std;

typedef long long int llint;

llint N, K;

int main() {
	cin >> N >> K;
	llint ans = 0;
	while (N >= K) {
		ans++;
		N /= K;
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	int n;
	cin>>n;
	int ac =0, wa = 0, tle = 0, re = 0;
	for(int i=0; i<n; i++)
	{
		string s;
		cin>>s;
		if(s[0] == 'A') ac++;
		else if(s[0] == 'W') wa++;
		else if(s[0] == 'T') tle++;
		else re++;
	}
	cout <<"AC x "<<ac<<nl;
	cout<<"WA x "<<wa<<nl;
	cout<<"TLE x "<<tle<<nl;
	cout<<"RE x "<<re<<nl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1)
    {
        c=c-b;
        if(c<=0)
        {
            printf("Yes\n");break;
        }
        a=a-d;
        if(a<=0)
        {
            printf("No\n");break;
        }
    }
    return 0;
}


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

string s;

int main() {
	cin >> s;
	int res = 0;
	for (int i = 0; i < s.size(); i++)
		if (s[i] - '0' != i % 2)
			res++;
	cout << min(res, (int)s.size() - res);
}

Measured memory_bytes: 512
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;

int main(){
    int n;
    llong a,b;
    cin >> n >> a >>b;
    llong ans=0,tmp,before;

    cin >> before;
    REP(i,n-1){
        scanf("%lld",&tmp);
        ans += min( a *(tmp-before),b);
        before=tmp;
    }
    cout << ans << endl;
}

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

#define int long long
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; }

signed main(){
	string s;
	cin >> s;
	int n = s.size();

	for(int i = 0;i < n;i++){
		if(s[i] == '?') s[i] = 'D';
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	repp(i, 0, n) cin >> a[i];
	vector<pair<ll,ll>>memo;
	sort(a.begin(), a.end());
	int zero=100005;
	repp(i, 0, n)if (a[i] >= 0) {
		zero = i;
		break;
	}
	if (zero >= n) {
		repp(i, 0, n - 1) {
			memo.emplace_back(a[n - 1], a[i]);
			a[n - 1] -= a[i];
		}
	}
	else if (zero == 0) {
		repp(i, 1, n - 1) {
			memo.emplace_back(a[0], a[i]);
			a[0] -= a[i];
		}
		memo.emplace_back(a[n - 1], a[0]);
		a[n - 1] -= a[0];
	}
	else {
		repp(i, zero, n - 1) {
			memo.emplace_back(a[0], a[i]);
			a[0] -= a[i];
		}
		repp(i, 0, zero) {
			memo.emplace_back(a[n - 1], a[i]);
			a[n - 1] -= a[i];
		}
	}
	cout << a[n - 1] << endl;
	repp(i, 0, n - 1)cout << memo[i].first << " " << memo[i].second << endl;
	return 0;
}

Measured memory_bytes: 4336
#include <stdio.h>
#include <string.h>

int main(){
  int i,j,a,b,minj,flag=1,N;
  char temp[3];

  scanf("%d",&N);

  char C[N][3],B[N][3],S[N][3];

  for(i=0;i<N;i++){
    scanf("%s",C[i]);
    
    strcpy(B[i],C[i]);
    strcpy(S[i],C[i]);
  }

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(B[j][1]<B[j-1][1]){	
	strcpy(temp,B[j]);
	strcpy(B[j],B[j-1]);
	strcpy(B[j-1],temp);
      }
    }
  }

  for(i=0;i<N-1;i++)
    printf("%s ",B[i]);
  printf("%s\n",B[N-1]);

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(C[i][1]==C[j][1]&&strcmp(C[i],B[b])==0&&strcmp(C[j],B[a])==0)
	    flag=0;
	}
      }
    }
  }
  if(flag==0) printf("Not stable\n");
  else printf("Stable\n");
  flag=1;

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(S[j][1]<S[minj][1]){
	minj=j;
      }
    }
    strcpy(temp,S[i]);
    strcpy(S[i],S[minj]);
    strcpy(S[minj],temp);
  }
  
 for(i=0;i<N-1;i++)
    printf("%s ",S[i]);
  printf("%s\n",S[N-1]);

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(C[i][1]==C[j][1]&&strcmp(C[i],S[b])==0&&strcmp(C[j],S[a])==0)
	    flag=0;
	}
      }
    }
  }
  if(flag==0) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

Measured memory_bytes: 624
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def numOftwo(x):
    cnt = 0
    while x%2 == 0:
        x //= 2
        cnt += 1
    return cnt

def main():
    N = int(readline())
    a = [int(i) for i in readline().split()]
    s = 0
    for i in range(N):
        s += numOftwo(a[i])
    print(s)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9916
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int sum1,sum2;
    int a[3];
    while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF)
    {
        sum1=0;sum2=0;
        sort(a,a+3);

        sum1=a[2]-a[1];//次大数达到最大数加1的次数
        a[0]+=sum1;//最小数加上加1的次数为它现在的值
        int b=a[2]-a[0];//最小数与另两个最大数的差值
        if(b%2==1)
          {
              sum1+=1;//为奇数时，最小值一定比最大的那两数大一，故最大的那两数还需加1
             for(int i=b;i>=0;i-=2)//这里是i-=2,不是i--

              {
                  sum2++;
                  //b=b/2;//用b-2,或b/2都可以//好像不加也对
              }
          }

        else sum2=b/2;//b为偶数

        printf("%d\n",sum1+sum2);
    }
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MOD_BY 998244353

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int pou(int a, int b) {
	int r = 1;
	while (b > 0) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int N;
int D[114514];

int kaunto[114514];

int main(void) {
	int i;
	int makkusu = 0;
	int kotae = 1;

	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &D[i]) != 1) return 1;
	}
	if (D[0] != 0) {
		puts("0");
		return 0;
	}

	for (i = 0; i < N; i++) {
		kaunto[D[i]]++;
		if (D[i] > makkusu) makkusu = D[i];
	}
	if (kaunto[0] != 1) {
		puts("0");
		return 0;
	}

	for (i = 1; i <= makkusu; i++) {
		if (kaunto[i] <= 0) {
			puts("0");
			return 0;
		}
		kotae = mul(kotae, pou(kaunto[i - 1], kaunto[i]));
	}

	printf("%d\n", kotae);
	return 0;
}


Measured memory_bytes: 2440
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD 1000000007
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n;
vector< vll > graph(100005);
ll p[100005];
ll dp[100005][3];
ll compute(ll i, ll c)
{
    //cout<<i<<" "<<c<<endl;
    if(dp[i][c]!=-1) return dp[i][c];
    int j;
    int si = graph[i].size();
    ll ans = 1;
    FOR0(j, si)
    {
        ll cur = 0;
        int v = graph[i][j];
        if(v==p[i]) continue;
        p[v] = i;
        cur += compute(v, 0);
        cur %= MOD;
        if(c!=1)
        {
            cur += compute(v, 1);
            cur %= MOD;
        }
        ans *= cur;
        ans %= MOD;
    }
    return dp[i][c] = ans;
}
int main()
{
    she_told_me_dont_worry
    memset(dp, -1, sizeof dp);
    cin>>n;
    int i;
    FOR0(i, n-1)
    {
        ll u, v;
        cin>>u>>v;
        graph[u-1].pb(v-1);
        graph[v-1].pb(u-1);
    }
    ll ans = compute(0, 0);
    ans += compute(0, 1);
    ans %= MOD;
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 17152
N = int(input())
L = list(map(int, input().split()))
L.sort()

if len(set(L)) < 3:
  print(0)
else:
  ans = 0
  for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
      for k in range(j+1, len(L)):
        if (L[i]!=L[j]) and (L[j]!=L[k]) and (L[i]+L[j]>L[k]):
          ans += 1
  print(ans)

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

int main(){
  double n, m, d;
  cin >> n >> m >> d;
  m--;
  if (d == 0) {
    printf("%.12f\n", 1.0 / n * m);
  } else {
    double t = 2.0 * (n - d) / (n * n);
    printf("%.12f\n", t * m);
  }
  return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char nama[5];
	
	scanf("%s", nama);
	
	if(strcmp(nama, "ABC") == 0){
		printf("ARC");
	} else if (strcmp(nama, "ARC") == 0){
		printf("ABC");
	} else {
	}
	
	return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#define INF 1e9
using namespace std;
typedef pair<string,int>P;
map<string,int >m;
int d[4]={1,-1,4,-4};
void bfs()
{
    int i;
    queue <P> que;
    que.push(P ("01234567",0));
    m["01234567"]=0;
    while(!que.empty())
    {
        P p=que.front();
        que.pop();
        for(i=0;i<4;i++)
        {
            string s=p.first;
            int x=p.second,xx=m[s];
            swap(s[x],s[x+d[i]]);
            if(x+d[i]>=0&&x+d[i]<8&&!(x==3&&i==0)&&!(x==4&&i==1)&&m[s]==0)
            {
                que.push(P(s,x+d[i]));
                m[s]=xx+1;
            }
        }
    }
}
int main()
{
    string pp;
    bfs();
    m["01234567"]=0;
    while(getline(cin,pp))
    {
        pp.erase(remove(pp.begin(), pp.end(), ' '), pp.end());
        cout<<m[pp]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5220
s = input()
n = int(input())
que = []
for i in range(n):
    que.append(input())
from collections import deque
d=deque(s)
rev=False
for q in que:
    if q == "1":
        rev= not rev
    else:
        t,f,c = q.split()
        HorT=rev
        if f=="1":
            HorT=not rev
        if HorT:
            d.appendleft(c)
        else:
            d.append(c)
if rev:
    d.reverse()
print(*d,sep="")

Measured memory_bytes: 106672
n, m = map(int, input().split())
edges = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

from collections import deque

q = deque()

prev = [-1] * n

q.append(0)
while q:
    v = q.popleft()
    for e in edges[v]:
        if prev[e] != -1:
            continue
        prev[e] = v
        q.append(e)

print("Yes")
for val in prev[1:]:
    print(val + 1)


Measured memory_bytes: 95004
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
    int n,m; cin >> n >> m;
    int k;
    vector<vector<int> > v;
    for(int i = 0; i < m; i++) {
        cin >> k;
        vector<int> vtmp;
        for(int j = 0; j < k; j++) {
            int tmp; cin >> tmp;
            vtmp.push_back(tmp);
        }
        v.push_back(vtmp);
    }
    vector<int> p(m);
    for(int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int upper = 1 << n;
    int ans = 0;
    for(int i = 0; i < upper; i++) {
        bool flag = true;
        for(int j = 0; j < m; j++) {
            int count = 0;
            for(int l = 0; l < v[j].size(); l++) {
                if(i & (1 << (v[j][l]-1)))
                    count++;
            }
            if(count%2 != p[j]) {
                flag = false;
                break;
            }
        }
        if(flag)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <math.h>       /* pow */

using namespace std;


void solve(string s, string t){
    //double ans = 0; 
    //int compare = abs(s.compare(t));
    int count = 0; 
    for (int i=0; i<s.size(); i++){
        if (s[i]!=t[i]){
            count += 1; 
        }
    }

    //int ans = n+ pow(n,2) + pow(n,3) ;
    cout << count << endl;
}



int main(void){

    string s;
    string t;
    cin >> s;
    cin >> t;
    solve(s,t);

}

Measured memory_bytes: 4060
class Dice():
    def __init__(self, nums):
        self.nums = nums
        self.top, self.front, self.right = 0, 1, 2

    def move(self, op):
        for c in op:
            if c == 'N':
                self.top, self.front = self.front, 5 - self.top
            elif c == 'S':
                self.top, self.front = 5 - self.front, self.top
            elif c == 'E':
                self.top, self.right = 5 - self.right, self.top
            else:
                self.top, self.right = self.right, 5 - self.top

    def getRight(self, t, f):
        top, front = self.nums.index(t), self.nums.index(f)
        for c in "NNNNEEE":
            self.move(c)
            if top == self.top:
                break
        while True:
            self.move("ESW")
            if front == self.front:
                return self.nums[self.right]

dice = Dice([int(n) for n in input().split()])
n = int(input())
for _ in range(n):
    t, f = [int(x) for x in input().split()]
    print(dice.getRight(t, f))

Measured memory_bytes: 7724
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S;

    cin >> S;

    if(S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <P> p(N);
  rep(i,N){
    cin >> p[i].first;
    p[i].second = i + 1;  //1-indexedで出席番号を管理
  }
  sort(all(p));
  rep(i,N) cout << p[i].second  << " ";

  return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define ALL(obleft) (obleft).begin(), (obleft).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPLL(i, n) for(ll i = 0;i < (n);++i)

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, q; ll a[100000], x[500];
	cin >> n >> q;
	REP(i, n) cin >> a[i];
	REP(i, q) cin >> x[i];
	REP(i, q){
		int right = 0;
		ll ans = 0, sum = 0;
		REP(left, n){
			while(right < n){
				if(sum+a[right] > x[i]) break;
				sum += a[right];
				right++;
			}
			ans += right-left;

			if(right == left) right++;
			else sum -= a[left];
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3996
n,m=map(int,input().split())
A=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  A[a-1]+=1
  A[b-1]+=1
f=0
for i in range(n):
  if A[i]%2==1:
    f=1
if f==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3828
n,l=map(int,input().split())
apple=[]
k=l
for i in range(n):
    apple.append(l)
    l+=1

if apple[0]>0:
    print(sum(apple)-apple[0])
elif apple[n-1]<0:
    print(sum(apple)-apple[n-1])
else:
    print(sum(apple))

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

int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main(void)
{
	int N, K;
	int i = 0, ans = 0;

	scanf("%d %d\n", &N, &K);

	int p[N];
	while (i < N)
		scanf("%d", &p[i++]);

	qsort(p, N, sizeof(int), compare_int);

	i = 0;
	while (i < K)
		ans += p[i++];

	printf("%d", ans);
	return (0);
}

Measured memory_bytes: 1724
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
#重さ、価値の順
dp=[[0]*(w+1) for i in range(n+1)]
#配列のインデックスを重さに対応させる
 
for i in range(n):
    for sum_w in range(w+1):
        
        if sum_w-l[i][0]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-l[i][0]]+l[i][1])
        #l[i]を入れるとき
        dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w])
        #入れない時
print(dp[-1][-1])


Measured memory_bytes: 121068
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  string A, B, C;
  cin >> A >> B >> C;
  int ans = 2*N;
  for (int i=0; i<N; i++) {
    if (A[i]==B[i]&&B[i]==C[i]) ans -= 2;
    else if (A[i]==B[i]||B[i]==C[i]||C[i]==A[i]) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int a, b;

	for (;;) {
		cin >> a >> b;

		if (a == 0 && b == 0)break;

		if (a < b) {
			printf("%d %d\n", a, b);
		}
		else {
			printf("%d %d\n", b, a);
		}
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define Int int64_t
using ll = long long;

#define PI  3.14159265358979323846

int main() {

	int a,b;
	cin >> a >> b;
	int c = a * b;

	cout << c << endl;

}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPopularVote solver = new BPopularVote();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPopularVote {
        public void solve(int testNumber, InputReader in, PrintWriter w) {

            int n = in.nextInt();
            int m = in.nextInt();

            int[] vo = new int[n];
            int tot = 0;
            for (int i = 0; i < n; i++) {
                vo[i] = in.nextInt();
                tot += vo[i];
            }

            int req = (int) Math.ceil((double) tot / (double) (4 * m));

            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (vo[i] >= req)
                    cnt++;
            }


            if (cnt >= m)
                w.println("Yes");
            else
                w.println("No");

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 1100000;

int n;
char s[N];
vector<pii> p;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline int sign(int x) {
	return x < 0 ? -1 : x > 0;
}

inline bool cmp(const pii &x, const pii &y) {
	int w = x.second - x.first, z = y.second - y.first;
	if (sign(w) != sign(z)) return sign(w) > sign(z);
	return sign(w) == 1 ? x.first < y.first : x.second > y.second;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		int m = strlen(s + 1), sm = 0, minV = 0;
		for (R int j = 1; j <= m; ++j)
			sm += (s[j] == '(' ? 1 : -1), minV = min(minV, sm);
		p.emplace_back(-minV, sm - minV);
	}
	sort(p.begin(), p.end(), cmp);
	int sm = 0;
	for (auto &v : p) {
		if (sm < v.first) return printf("No\n"), 0;
		sm += v.second - v.first;
	}
	printf("%s\n", sm ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 11564
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(void)
{

  int n, d, count = 0;

  string a, b;

  cin >> a;
  cin >> b;

  for (int i = 0; i < a.size(); i++)
  {

    if (a[i] != b[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>

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

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin>>S;

	if(S.front()=='0'||S.back()=='1')
	{
		cout<<-1<<endl;
		return 0;
	}

	bool ok=true;
	rep(i,0,SZ(S)/2)
	{
		if(S[i]!=S[SZ(S)-2-i])ok=false;
	}

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

	int op=SZ(S)-1;
	rrep(i,0,SZ(S)-1)
	{
		cout<<i+1<<" "<<op+1<<endl;
		if(S[i]=='1')op=i;
	}
	
	return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	string s; cin >> s;
	if(s[2]==s[3]&&s[4]==s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
	int n, m;
	int d0[100][100], d[100][100];

	cin >> n >> m;

	for(int j=0; j<100; j++){
		for(int k=0; k<100; k++){
			d[j][k]=1000*1000*1000;
			d0[j][k]=-1;
		}
		d[j][j]=0;
	}

	for(int i=0; i<m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		d0[a-1][b-1]=d[a-1][b-1]=c;
		d[b-1][a-1]=c;
	}

	for(int j=0; j<n; j++){
		for(int k=0; k<n; k++){
			for(int l=0; l<n; l++){
				d[k][l]=min(d[k][l], d[k][j]+d[j][l]);
			}
		}
	}

	int r=0;
	for(int j=0; j<n; j++){
		for(int k=0; k<n; k++){
			if(d0[j][k]!=-1 && d[j][k]<d0[j][k]){
				r++;
			}
		}
	}

	cout << r << endl;

	return 0;

}







Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  char c1 = '.';
  char c2 = '#';
  cin >> A >> B;
  A--;
  B--;

  cout << ((A / 50) + 2 + (B / 50)) * 3 << " " << 100 << endl;

  REP(i, A / 50) {
    REP(j, 100) cout << c2;
    cout << endl;
    REP(j, 100) cout << (j % 2 == 0 ? c2 : c1);
    cout << endl;
    REP(j, 100) cout << c2;
    cout << endl;
  }

  REP(j, 100) cout << c2;
  cout << endl;
  REP(j, (A % 50) * 2) cout << (j % 2 == 0 ? c2 : c1);
  FOR(j, (A % 50) * 2, 100) cout << c2;
  cout << endl;
  REP(j, 100) cout << c2;
  cout << endl;

  REP(i, B / 50) {
    REP(j, 100) cout << c1;
    cout << endl;
    REP(j, 100) cout << (j % 2 == 0 ? c1 : c2);
    cout << endl;
    REP(j, 100) cout << c1;
    cout << endl;
  }

  REP(j, 100) cout << c1;
  cout << endl;
  REP(j, (B % 50) * 2) cout << (j % 2 == 0 ? c1 : c2);
  FOR(j, (B % 50) * 2, 100) cout << c1;
  cout << endl;
  REP(j, 100) cout << c1;
  cout << endl;

  return 0;
}


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

int main(void){
    int x,y;
   while(true){
       cin >> x;
       cin >> y;
       if( x==0 && y==0){
           break;
       }
       if(x<y){
           cout << x << " " << y << endl;
       }
       else{
           cout << y << " " << x << endl;
        }
   }
}


Measured memory_bytes: 2976
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string b;
    in(b);

    string a;
    rep(i, b.size())
    { 
        if (b[i] == 'A')
        {
            a += 'T';
        }
        else if (b[i] == 'T')
        {
            a += 'A';
        }
        else if (b[i] == 'C')
        {
            a += 'G';
        }
        else if (b[i] == 'G')
        {
            a += 'C';
        }
    }

    outl(a);

    return 0;
}

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		int inf = Integer.MAX_VALUE;
		Arrays.sort(s);
		reverse(s);
		List<Integer> list = new ArrayList<>(n2);
		list.add(s[0]);
		s[0] = inf;
		for (int i = 0; i < n; i++) {
			Collections.sort(list, Collections.reverseOrder());
			int size = list.size();
			int idx = 0;
			for (int j = 0; j < size; j++) {
				int sj = list.get(j);
				while (idx < n2 && s[idx] >= sj) {
					idx++;
				}
				if (idx >= n2) {
					System.out.println("No");
					return;
				}
				list.add(s[idx]);
				s[idx] = inf;
				idx++;
			}
		}
		System.out.println("Yes");
	}

	static void reverse(int[] a) {
		int len = a.length;
		int end = len / 2;
		int tmp = 0;
		for (int i = 0; i < end; i++) {
			tmp = a[i];
			a[i] = a[len - 1 - i];
			a[len - 1 - i] = tmp;
		}
	}
}


Measured memory_bytes: 91832
use std::io;
use std::io::{stdin,BufRead,BufReader};
use std::cmp;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n: usize = buf.trim().parse().unwrap();
    let mut map: HashMap<usize, usize> = HashMap::new();
    for (i, l) in BufReader::new(stdin()).lines().enumerate() {
        let l = l.unwrap().trim().parse::<usize>().unwrap();
        map.insert(l - 1, i);
    }
    let mut max_len = 0;
    let mut len = 0;
    for i in 0..(n-1) {
        if map.get(&i).unwrap() < map.get(&(i + 1)).unwrap() {
            len += 1;
        } else {
            max_len = cmp::max(max_len, len + 1);
            len = 0;
        }
    }
    max_len = cmp::max(max_len, len + 1);
    println!("{}", n - max_len);
}


Measured memory_bytes: 16828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var max = 0;

            for(var i=1; i<N - 1; i++)
            {
                var s = S.Substring(0, i);
                var t = S.Substring(i);

                var count = s.Where(a => t.Contains(a)).Distinct().Count();

                max = Math.Max(max, count);
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13396
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
sn = sum([int(i) for i in str(n)])

print("Yes") if n%sn == 0 else print("No")

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

int main(){
    int K,S;
    cin >> K >> S;
    int count = 0;

    for(int x = 0;x <= S;++x){
        for(int y= 0;y <= S-x;++y){
            //Zは自動的に決まる
            int z = S - x - y;
            if(z <= K && x <= K && y <= K) count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int A,B,X;
  cin>>A>>B>>X;
  cout<<(B)/X - A/X +(A%X == 0)<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();

        System.out.println(solve2(N));
    }

    private static int solve2(int N) {
        int[] X = new int[N+1];

        X[1] = 1;
        for (int i=2; i<=N; i++) {
            int min = Integer.MAX_VALUE;

            int power6 = 6;
            while (power6 <= i) {
                min = Math.min(min, X[i-power6]+1);

                power6 *= 6;
            }

            int power9 = 9;
            while (power9 <= i) {
                min = Math.min(min, X[i-power9]+1);

                power9 *= 9;
            }

            for (int j=1; j<10 && j<=i; j++) {
                min = Math.min(min, X[i-j]+j);
            }

            X[i] = min;
            System.err.println("X[" + i + "] = " + min);
        }

        return X[N];
    }

    private static int solve(int N) {
        int x = 0;

        while (N > 0) {
            int max9 = power(N, 9);
            int max6 = power(N, 6);

            System.err.println("N = " + N + ", max9 = " + max9 + ", max6 = " + max6 + ", x = " + x);
            if (max9 > max6 && max9 > 0) {
                N -= max9;
                x++;
            } else if (max6 > max9 && max6 > 0) {
                N -= max6;
                x++;
            } else {
                x += N;
                N = 0;
            }
        }

        return x;
    }

    private static int power(int max, int base) {
        if (max < base) return -1;

        int cur = base;
        while (cur*base < max) {
            cur *= base;
        }

        return cur;
    }
}

Measured memory_bytes: 46940
#include <stdio.h>
#define N 100
int main(){
  int A[N],i,j,num,key;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }

  for(j=0;j<num;j++){
   printf("%d",A[j]);
   if(j!=num-1)printf(" ");
 }
 printf("\n");


 for(i=1;i<num;i++){
   key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }


    
    for(j=0;j<num;j++){
      printf("%d",A[j]);
      if(j!=num-1)printf(" ");
    }
    printf("\n");


 }
    
 return 0;

}
  

Measured memory_bytes: 604
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#x = int(input())
n, d = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(n):
    x, y = map(int, sys.stdin.readline().split())
    dis = math.sqrt(x ** 2 + y ** 2)
    if dis <= d:
        ans += 1
    

print(ans)


Measured memory_bytes: 10152
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll = long long;
int MOD=1e9+7;
using namespace std;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> vec(n+1);
    vec[1]=1;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    for(int i=1;i<=n;i++){
        dp[i][0]=1;
        dp[i][i]=1;
        dp[i][1]=i;
    }
    for(int i=2;i<=n;i++){
        for(int j=2;j<=n;j++){
            dp[i][j]=(dp[i-1][j-1]%MOD+dp[i-1][j]%MOD)%MOD;
        }
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    if(n==2){
        if(k==1){
            cout<<2<<endl;
        }else{
            cout<<1<<endl;
            cout<<0<<endl;
        }
        return 0;
    }
    for(int i=1;i<=k;i++){
        cout<<dp[n-k+1][i]%MOD*dp[k-1][i-1]%MOD<<endl;
    }
    
}

Measured memory_bytes: 31616
module M = Map.Make (struct type t = int let compare = compare end) ;;

Scanf.scanf "%d %d" (fun n m ->

    let rec loop i cur map =
        if i = n then map else
            let a = Scanf.scanf " %d" (fun a -> a) in
            let cur = (cur + a) mod m in
            let map = M.add cur (1 + try M.find cur map with _ -> 0) map in
            loop (i + 1) cur map
    in
    let map = loop 0 0 (M.add 0 1 M.empty) in
    M.fold (fun _ v acc -> acc + v * (v - 1) / 2) map 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 8448