akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  double N;
  double count = 0;

  cin >> N;

  for (int i = 1; i <= N; i++) {
    if (i % 2 != 0) {
      count++;
    }
  }

  cout << count / N;

  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      char[] S = in.next().toCharArray();
      int K = in.nextInt();
      
      for (int i = 0; i < S.length; ++i) {
        if (S[i] != S[K -1]) {
          S[i] = '*';
        }
      }

      System.out.println(S);
    }
  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[m];
    for(int i = 0; i < m; i++){
      a[i] = sc.nextInt();
    }
    int num = ~Arrays.binarySearch(a, x);
    System.out.println(Math.min(num, m - num));
  }
}

Measured memory_bytes: 23124
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/
#define _USE_MATH_DEFINES
 
#include <cmath>

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

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
  
int main()
{
 
  ll ans=0;
  
  map<ll,ll>mp1,mp2;
  
  sci(n);
  vi v(n);
  ll a;
  int cnt=1;
  rep(i,0,n-1)
  {
    cin>>v[i];
    mp1[i+v[i]]++;
    mp2[i-v[i]]++;
    
  }
  rep(i,0,n-1)
  {
      ans+=mp1[i-v[i]];
      ans+=mp2[i+v[i]];
    }
  
  cout<<ans/2;
   
    return 0;
}


Measured memory_bytes: 50092
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
double startTime;
double getCurrentTime()
{return ((double)clock() - startTime) / CLOCKS_PER_SEC;}
typedef long long int ll;
typedef pair<int,int> ii;
int mod=int(1e9+7);
char arr[1001][1001];
int cnt[1001][1001];
int dp(int m,int n)
{
  if(m<=0||n<=0)return 0;
  if(arr[m-1][n-1]=='#')return 0;
  if(cnt[m][n]!=-1)return cnt[m][n];
  if((m==1&&n==2)||(n==1&&m==2)) return cnt[m][n]=1;
  int ans;
  if(m-1>0&&n-1>0)
  ans=(dp(m-1,n)%mod+dp(m,n-1)%mod)%mod;
  else
  {
    if(m-1>0)
      ans=dp(m-1,n)%mod;
    else
      ans=dp(m,n-1)%mod;
  }

  return cnt[m][n]=ans;
}
int main()
{  
  fast
  startTime = (double)clock();
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      cin>>arr[i][j]; 
    memset(cnt,-1,sizeof(cnt));
   
    cout<<dp(h,w)%mod<<endl;
    //cout<<getCurrentTime()<<endl;

}


Measured memory_bytes: 5248
/*
 * 2639.cc: Yamanote Line
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int R = 60;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ab = a + b;

  int ans = -1;
  for (int t = 0; t < R; t++) {
    int ct = t * R + c;
    int cab = ct % ab;
    if (cab >= 0 && cab <= a) {
      ans = ct;
      break;
    }
  }

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

Measured memory_bytes: 1144
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

long long dp[51][2500 + 1];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, a;
	cin >> n >> a;
	int x[50];
	rep(i, n)cin >> x[i];
	long long ans = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int k = n - 1; k >= 0;k--) {
			rep(j, a*n)if (dp[k][j]) {
				dp[k + 1][j + x[i]] += dp[k][j];
			}
		}
	}
	for (int i = 1; i <= n; i++) ans += dp[i][i*a];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 3e3+2;
int dp[N][N][2];
int a[N];
int n;
int solve(int l,int r,int chance)
{
    if(l>r || l>n || r<1)
        return 0;
    if(dp[l][r][chance]!=-1)
        return dp[l][r][chance];
    if(chance == 0)
    {
        int ans1 = a[l]+solve(l+1,r,chance^1);
        int ans2 = a[r]+solve(l,r-1,chance^1);
        dp[l][r][chance] = max(ans1,ans2);
    }
    else
    {
        int ans1 = solve(l+1,r,chance^1)-a[l];
        int ans2 = solve(l,r-1,chance^1)-a[r];
        dp[l][r][chance] = min(ans1,ans2);
    }
    return dp[l][r][chance];
}
signed main()
{
    fast;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,n,0);
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 int a;
  cin>>a;
  
  string g;
  cin>>g;
  
  if(a%2==0)
  {
    if(g.substr(0,(a/2))== g.substr(a/2,a-1))
      cout<<"Yes";
    
    else
      cout<<"No";
    
  }
  
  else
    cout<<"No";
    
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i < (int)(n); i++)
typedef long long ll;
#define NP next_permutation
#define MP make_pair
#define INT_MAX 1e9

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int mx = h[0];
  int cnt = 0;
  rep(i, n){
  	if(h[i] >= mx) {
  		cnt ++ ;
  		mx = h[i];
  	}
  }
  cout << cnt << endl;
}


/*





















*/
  

Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

class SegmentTree:
    def __init__(self, n, func=lambda x, y: min(x, y), ide=float("inf")):
        self.n = 2 ** (n-1).bit_length()
        self.data = [ide] * (self.n*2)
        self.ide, self.func = ide, func
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def update(self, i, x):
        i += self.n
        self.data[i] = x
        while i > 1:
            i //= 2
            self.data[i] = self.func(self.data[i*2], self.data[i*2+1])

    def query(self, l, r):
        l += self.n; r += self.n 
        res = self.ide
        while l < r:
            if l & 1:
                res = self.func(res, self.data[l])
                l += 1
            if r & 1:
                res = self.func(res, self.data[r-1])
            l >>= 1; r >>= 1
        return res
    
    def get(self, i):
        return self.data[self.n + i]

s = SegmentTree(n, lambda x, y: gcd(x, y), 0)
s.build(a)
ans = 0
for i in range(n):
    ans = max(ans, gcd(s.query(0, i), s.query(i+1, n)))
print(ans)


Measured memory_bytes: 90720
#include<iostream>
#include<string>
using namespace std;
int dp[20][20];
int main(){
    int a,b;
    int n;
    int x[40],y[40];
    while(true){
    cin>>a>>b;
    if(a==0&&b==0)
        break;
    cin>>n;
    for(int i=0;i<20;i++)
        for(int j=0;j<20;j++)
            dp[i][j]=0;
    for(int i=1;i<n+1;i++){
        cin>>x[i]>>y[i];
        dp[y[i]][x[i]]=-1;
    }
    dp[1][1]=1;
    for(int i=1;i<b+1;i++){
        for(int j=1;j<a+1;j++){
            if(dp[i][j]!=-1){
            if(dp[i-1][j]>0)
                dp[i][j]+=dp[i-1][j];
            if(dp[i][j-1]>0)
                dp[i][j]+=dp[i][j-1];
            }
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[b][a]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
n,t = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

res = float("inf")
flag = 0
for i in range(n):
    if l[i][1] <= t:
        if l[i][0] < res:
            res = l[i][0]
            flag = 1
if flag == 1:
    print(res)
else:
    print("TLE") 

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
template <long long Mod> class mod_int{
    public:
    long long x;
    mod_int(long long x=0LL):x((x%Mod+Mod)%Mod){};
    mod_int& operator*=(const mod_int<Mod>a) {(x*=a.x)%=Mod; return *this;}
    friend ostream& operator<<(ostream& os, const mod_int<Mod>& a) { return os<<a.x;}
};

int N,A,hat[3];
int main(){
    cin>>N;
    using mint=mod_int<1000000007>;
    mint ans=1LL;
    for(int i=0;i<N;i++){
        cin>>A;
        ans*=(hat[0]==A)+(hat[1]==A)+(hat[2]==A);
        for(int h=0;h<3;h++)if(hat[h]==A){hat[h]++;break;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
c_grid = [0]*3
for i in range(3):
    c_grid[i] = list(map(int, input().split()))
res = 'No'
for a1 in range(101):
    b1 = c_grid[0][0] - a1
    b2 = c_grid[0][1] - a1
    b3 = c_grid[0][2] - a1
    if b1 < 0 or b2 < 0 or b3 < 0:
        continue
    if b1 > 100 or b2 > 100 or b3 > 100:
        continue
    a2 = c_grid[1][0] - b1
    if a2 < 0 or a2 > 100 or a2 != c_grid[1][1] - b2 or a2 != c_grid[1][2] - b3:
        continue
    a3 = c_grid[2][0] - b1
    if a3 < 0 or a3 > 100 or a3 != c_grid[2][1] - b2 or a3 != c_grid[2][2] - b3:
        continue
    res = 'Yes'
print(res)


Measured memory_bytes: 9132
def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *A, = map(int, input().split())

    dp = [0] * (S + 1)

    ans = 0
    for x in A:
        ans += dp[S]
        if S >= x:
            ans += dp[S - x]
            if S == x:
                ans += 1
            for s in range(S, x, -1):
                dp[s] = (dp[s] + dp[s - x]) % MOD
            dp[x] = (dp[x] + dp[0] + 1) % MOD
        dp[0] += 1
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

#             dp[i + 1][s][0] = (dp[i + 1][s][0] + dp[i][s][0]) % MOD
#             dp[i + 1][s][1] = (dp[i + 1][s][1]
#                                + dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD
#             dp[i + 1][s][2] = (dp[i + 1][s][2]
#                                + dp[i][s][2] +
#                                dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD

#     for i, x in enumerate(A):
#         dp[i + 1][0][0] = dp[i][0][0]
#         for s in range(S, -1, -1):
#             dp[i + 1][s][1] = (dp[i][s][1] + dp[i][s][0]) % MOD
#             dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) % MOD
#
#             if s - x >= 0:
#                 v = dp[i][s - x][1] + dp[i][s - x][0]
#                 dp[i + 1][s][1] = (dp[i + 1][s][1] + v) % MOD
#                 dp[i + 1][s][2] = (dp[i + 1][s][2] + v) % MOD

#         dp[i + 1][0][0] = dp[i][0][0]
#         dp[i + 1][0][1] = (dp[i][0][1] + dp[i][0][0]) % MOD
#         dp[i + 1][0][2] = (dp[i][0][2] + dp[i][0][1] + dp[i][0][0]) % MOD
#         for s in range(S, 0, -1):
#             dp[i + 1][s][1] = dp[i][s][1] % MOD
#             dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1]) % MOD
#             if s - x >= 0:
#                 v = dp[i][s - x][1] + dp[i][s - x][0]
#                 dp[i + 1][s][1] = (dp[i + 1][s][1] + v) % MOD
#                 dp[i + 1][s][2] = (dp[i + 1][s][2] + v) % MOD

#     for x in A:
#         for s in range(S, 0, -1):
#             dp[s][1] += dp[s][0]
#             if s - x >= 0:
#                 v = dp[s - x][0] + (1 if s - x == 0 else 0)
#                 dp[s][0] += v
#                 dp[s][1] += v
#             dp[s][0] %= MOD
#             dp[s][1] %= MOD
#         dp[0][0] += 1
#         dp[0][1] += (dp[0][0] + 1)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  cin >>A>>B>>C>>D;
  Out(min(A,B)+min(C,D));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
vector< int > v ;
bool ok[4000010] ;
int main(){
    int N ;
    int A[2010] ;
    int sum = 0 ;
    cin >> N ;
    for( int i = 1 ; i <= N ; i++ ){
        cin >> A[i] ;
        sum += A[i] ;
    }
    int res = sum / 2 ;
    int ans = sum ;
    sum = 0 ; v.push_back( 0 ) ; ok[0] = true ;
    for( int i = 1 ; i <= N ; i++ ){
        int sz = v.size() ;
        for( int j = 0 ; j < sz ; j++ ){
            int r = v[j] + A[i] ;
            if ( r <= res && !ok[r] ){
                ok[r] = true ;
                v.push_back( r ) ;
            }
        }
    }
    for( int i = res ; i >= 0 ; i-- ){
        if ( ok[i] ){
            cout << ans - i << endl ;
            return 0 ;
        }
    }
}

Measured memory_bytes: 7152
#include<stdio.h>
int main()
{
   char s[10],Good,Bad;
   scanf("%s",s);
   if(s[0]==s[1]){
    printf("Bad");
   }
   else if(s[1]==s[2]){
   printf("Bad");
   }
   else if(s[2]==s[3]){
    printf("Bad");
   }
   else{
    printf("Good");
   }
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    long long int a,b,r;
    char op;
    scanf("%lld %c %lld",&a,&op,&b);
    if(op=='+')
    {
        r=a+b;
    }
    else
        r=a-b;
    printf("%lld\n",r);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        long H = 0;
        for (int i=0;i<n;i++)h[i]=sc.nextInt();
        Arrays.sort(h);
        for (int i=0;i<n-k;i++)H+=h[i];
        System.out.println(H);
    }
}


Measured memory_bytes: 60820
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 4e5 + 5 ; 
int n, m, a[N] ;
signed main()
{
	n = gi(), m = gi() ;
	rep( i, 1, n ) a[i] = gi() ;
	sort( a + 1, a + n + 1 ) ; int sum = 0 ;
	for( re int i = 1; i <= n - m; ++ i ) {
		sum += a[i] ;
	} 
	printf("%lld\n", sum ) ;
	return 0 ;
}


Measured memory_bytes: 1792
H, W, K = map(int, input().split())
c = []
for _ in range(H):
  c.append(input())
 
ans = 0  
for h in range(2 ** H):
  for w in range(2 ** W):
    b = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1 == 0 and (w >> j) & 1 ==0:
          if c[i][j] == '#':
            b += 1
    if b == K:
      ans += 1
print(ans)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;


struct UnionFind{
    vector<int> par;
    vector<ll> S;

    UnionFind(int N):par(N),S(N){
        rep(i,N){
          par[i] = i;
          S[i] = 1;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }
    
    bool same(int x,int y){
      return root(x) == root(y);
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(!same(x,y)){
            S[root(x)] += S[root(y)];
            S[root(y)] = S[root(x)];
        }
        if(rx == ry)return;
        if(S[x] >= S[y]){
          par[ry] = rx;
        }else{
          par[rx] = ry;
        }
    }

    ll SIZE(int x){
        return S[root(x)];
    }
};


ll N,M,K;
ll cnt[100010];
ll Bcnt[100010];

int main(){
    cin >> N >> M >> K;
    UnionFind UFF(N);
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        cnt[a]++;
        cnt[b]++;
        UFF.unite(a,b);
    }
    rep(i,K){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(UFF.same(a,b)){
            Bcnt[a]++;
            Bcnt[b]++;
        }
    }
    rep(i,N){
        cout << max(UFF.SIZE(i) - cnt[i] - Bcnt[i] - 1,0LL) << ' ';
    }
    cout << endl;
}


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

#define rep(i,f,n) for (long long (i) =(f);(i)<(n);(i)++)
#define LL long long 

using namespace std;

int main(){
    LL a,m;
    int n;
    LL y,x,Y,hx;
    int ans=0;
    scanf("%lld %d %lld",&a,&n,&m);
    rep(y,1,10001){
        Y=y;
        hx=0;
        x=1;
        for(int i=0;i<n;i++){
            x=x*(a+y);
        }
        if(x>m)break;
       // cout<<x;
        while(x!=0){
            hx+=x%10;
            x=x/10;
        }
        if(hx==y){
            ans++;
        }
            //    cout<<" "<<y<<" "<<hx<<" "<<ans<<endl;

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



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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 3e5 + 5;
vector<ll> node[N];
ll vis[N], d[N];
void bfs(ll u){
        queue<ll> q;
        q.push(u);
        d[u] = 0;
        vis[u] = 1;
        while (q.size() > 0) {
                ll now = q.front();
                q.pop();
                for (auto j : node[now]){
                        if (vis[j] == 0){
                                vis[j] = 1;
                                d[j] = d[now] + 1;
                                q.push(j);
                        }
                }
        }
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("WALKING.INP", "r")){
                freopen("WALKING.INP", "r", stdin);
                freopen("WALKING.OUT", "w", stdout);
        }
        ll n, m;
        cin >> n >> m;
        for (int i = 1; i <= m; i++){
                ll u, v;
                cin >> u >> v;
                node[u].push_back(v + n);
                node[u + n].push_back(v + n * 2);
                node[u + 2 * n].push_back(v);
        }
        ll s, t;
        cin >> s >> t;
        bfs(s);
        if (d[t] == 0) cout << -1;
        else cout << d[t] / 3;
}


Measured memory_bytes: 21376
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = mutableListOf<String>()

    fun rec(s: String, cur: Int) {
        if (cur == n) {
            ans.add(s)
            return
        }
        for (i in 0..(s.max()!! - 'a' + 1)) {
            rec(s.plus(('a' + i)), cur + 1)
        }
    }

    rec("a", 1)

    println(ans.sorted().joinToString("\n"))
}


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


int main(){
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;cin>>N;
    cout<<a.at(N-1)<<endl;
}







Measured memory_bytes: 256
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define  LL long long
const int maxn = 1e5+55;
const double g = -9.8;
int sum[maxn];

bool f(int x)
{
	if(x==1) return false;
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0) return false;
	}

	return true;
}



int main()
{
	for(int i=1;i<=1e5;i++){
		if(f(i)&&f((i+1)/2)){
			sum[i]=sum[i-1]+1;
		}else{
			sum[i]=sum[i-1];
		}
	}

	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		int l,r;
		scanf("%d %d",&l,&r);
		printf("%d\n",sum[r]-sum[l-1]);
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int ll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int num[2][3];
vector<pii> cmp[2];
int32_t main () {
  int n;
  scanf("%lld", &n);
  FOR(i, 0, 1) FOR(j, 0, 2) scanf("%lld", &num[i][j]);
  FOR(j, 0, 2) {
    if (num[0][j] < num[1][j]) cmp[0].pb({num[0][j], num[1][j]});
    else cmp[1].pb({num[1][j], num[0][j]});
  }
  if (cmp[1].size() == 3) {
    cmp[0] = cmp[1]; cmp[1].clear();
  }

  int ans;
  if (cmp[0].size() == 3) {
    auto u = cmp[0][0], v = cmp[0][1], w = cmp[0][2];
    int mx = 0;
    for (int i = 0; i * u.fi <= n; ++i) {
      for (int j = 0; i * u.fi + j * v.fi <= n; ++j) {
        int rem = n - i * u.fi - j * v.fi;
        mx = max(mx, i * u.se + j * v.se + rem / w.fi * w.se + rem % w.fi);
      }
    }
    ans = mx;
  } else if (cmp[0].size() == 2) {
    auto u = cmp[0][0], v = cmp[0][1];
    auto w = cmp[1][0];
    int mx = 0;
    for (int i = 0; i * u.fi <= n; ++i) {
      int rem = n - i * u.fi;
      mx = max(mx, i * u.se + rem / v.fi * v.se + rem % v.fi);
    }
    ans = mx / w.fi * w.se + mx % w.fi;
  } else {
    auto u = cmp[0][0];
    auto v = cmp[1][0], w = cmp[1][1];
    n = n / u.fi * u.se + n % u.fi;
    int mx = 0;
    for (int i = 0; i * v.fi <= n; ++i) {
      int rem = n - i * v.fi;
      mx = max(mx, i * v.se + rem / w.fi * w.se + rem % w.fi);
    }
    ans = mx;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
// test 

#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;
int n, m;
long long int ans;

char x[16];

bool prime(long long int x)
{
	for (long long int i = 2; i * i <= x; i++){
		if (x % i == 0) return (false);
	}
	return (x != 1);
}

void dfs(int idx)
{
	if (idx == n){
		if (prime(atoll(x))) ans = max(ans, atoll(x));
		return;
	}
	for (int i = '0'; i <= '9'; i++){
		if (idx == 0 && (i != '1' && i != '3' && i != '7' && i != '9')) continue;
		x[idx] = i; x[2 * n - idx] = i;
		dfs(idx + 1);
	}
}

int main()
{	
	scanf("%d %d", &n, &m);
	if (m < 0){
		if (n != 1) for (int i = 0; i < 2 * n; i++) printf("9");
		else printf("11");
		printf("\n");
	}
	else {
		x[2 * n + 1] = 0;
		x[n] = m + '0';
		dfs(0);
		printf("%lld\n", ans);
	}
	return (0);
}



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

int main(){
    int L;
    string s;
    cin>>L>>s;
    int res=0;
    auto calc=[&](char c){
        int l=0;
        int i=0;
        int res=0;
        for(;i<L;i++){
            if(s[i]=='.'){
                l=i+1;
            }
            else if(s[i]!=c){
                if(l==i) l=i+1;
            }
            else{
                res=max(res,i-l-1);
                l=i;
            }
        }
        return res;
    };
    for(int i=0;i<L;i++){
        if(s[i]!='.') continue;
        char c=s[i];
        s[i]='W';
        int wsc=calc('W');
        int bsc=calc('B');
        if(bsc==0){
            res=max(res,wsc);
        }
        s[i]='.';
    }
        
    cout<<res<<endl;
    return 0;
}


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

// 0が入ってきたときの処理が通常のGCDと異なる
ll gcd(ll a, ll b) {
    if (a == 0 || b == 0) return max(a, b);
    if (a % b == 0) return b;
    return (a >= b) ? gcd(b, a % b) : gcd(b, a);
}

// 累積和GCD
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> left(n+1); left[0] = 0;
    vector<ll> right(n+1); right[0] = 0;
    for(int i = 0; i < n; i++) left[i+1] = gcd(left[i], a[i]);
    for(int i = 0; i < n; i++) right[i+1] = gcd(right[i], a[n-1-i]);

    ll max_gcd = 0;
    for(int i = 0; i < n; i++) {
        ll lg = gcd(left[0], left[i]), rg = gcd(right[0], right[n-1-i]);
        max_gcd = max(max_gcd, gcd(lg, rg));
    }
    cout << max_gcd << endl;
    return 0;
}


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

using namespace std;
                     
int main() {              
	int n;
	double t, a;
	scanf("%d%lf%lf", &n, &t, &a);
	int id = 1;
	double hh = 100000000000000.0;
	for (int i = 1; i <= n; i++) {
		double h;
	 	scanf("%lf", &h);
		h = t - h * 0.006;
		h = abs(h - a);
		if (hh > h) {
			id = i;
			hh = h;
		}
	}
	printf("%d\n", id);
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (c >= 10) cout << "error" << endl;
  else cout << c << endl;
}

Measured memory_bytes: 256
import sys
from typing import no_type_check_decorator
sys.setrecursionlimit(2**20)

class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left #左の子ノード
        self.right = right #右の子ノード

def get_all_height(T: dict, H: dict, u: int):
    """
    深さ優先探索で各ノードを巡りながらHに高さ情報を容れる
    """
    h_left, h_right = 0, 0
    if T[u].left is not None:
        h_left = get_all_height(T, H, T[u].left) + 1
    if T[u].right is not None:
        h_right = get_all_height(T, H, T[u].right) + 1
    
    ret = max(h_left, h_right)
    H[u] = ret
    return ret

def get_all_depth(T: dict, D: dict, u: int, p: int):
    """
    D: 深さを格納する辞書
    p: 現在の深さ
    """
    D[u] = p
    if T[u].left is not None:
        get_all_depth(T, D, T[u].left, p+1)
    if T[u].right is not None:
        get_all_depth(T, D, T[u].right, p+1)

def ret_sibling(T: dict, u: int):
    """
    ノードuの兄弟を返す
    """
    parent = T[u].parent
    if parent is None:
        return -1 # root は兄弟なし
    # 自分のparentから見て子ノードはleft or rightの二つ。
    # 自分自身(ノードu)に一致していない方を返す
    ret = T[parent].left if T[parent].left != u else T[parent].right
    if ret is None: #兄弟がいない場合
        return -1
    return ret

def ret_degree(T: dict, u: int):
    ret = 2
    if T[u].left is None:
        ret -= 1
    if T[u].right is None:
        ret -= 1
    return ret


# input
n = int(input())
T = {key: Node(None, None, None) for key in range(n)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != -1:
        T[tmp[0]].left = tmp[1]
        T[tmp[1]].parent = tmp[0]
    if tmp[2] != -1:
        T[tmp[0]].right = tmp[2]
        T[tmp[2]].parent = tmp[0]

for k, v in T.items():
    if v.parent is None:
        ROOT = k # 根を探す
        break 

D = {}
get_all_depth(T, D, ROOT, 0)
H = {}
get_all_height(T, H, ROOT)

def print_for_a_node(u):
    if T[u].parent is None:
        parent = -1
    else:
        parent = T[u].parent
    
    sib = ret_sibling(T, u)
    deg = ret_degree(T, u)
    node_type = "internal node" if deg != 0 else "leaf"
    if parent == -1:
        node_type = "root"
    
    print(
        f"node {u}: parent = {parent}, sibling = {sib}, degree = {deg}, depth = {D[u]}, height = {H[u]}, {node_type}"
    )

for node in range(n):
    print_for_a_node(node)


Measured memory_bytes: 7200
solve :: Int -> String
solve day
  | day == 25 = "Christmas"
  | day == 24 = "Christmas Eve"
  | day == 23 = "Christmas Eve Eve"
  | day == 22 = "Christmas Eve Eve Eve"
  | otherwise = "Not Christmas"

main :: IO ()
main = do
  n <- getLine
  putStr $ solve $ read n


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


int main() {
	int n,ans=0,a[25];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-2;i++){
		int A=a[i],B=a[i+1],C=a[i+2];
		if(A<B&&B<C){
			ans++;
		}
		else if(A>B&&B>C){
			ans++;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int main()
{
    fastio();
    int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    double k=arr[0]*1.0;
    for(int i=1;i<n;++i) 
    {
        k+=arr[i]; k/=2;
    }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
  a=-a if a<0
  b=-b if b<0
  while b > 0
    a, b = b, a%b
  end
  a
end
def lcm(a, b)
  a=-a if a<0
  b=-b if b<0
  a*b/gcd(a, b)
end
def ngcd(*nums)
  d=0
  nums.each{|a| d=gcd(d, a)}
  d
end
def nlcm(*nums)
  l=1
  nums.each{|a| l=lcm(l, a)}
  l
end
class Array
  def gcd
    inject(:gcd) 
  end
  def lcm
    inject(:lcm)
  end
end
#======================================
#Array.gcd
#ngcd(a,b)


N,K=gets.split.map &:to_i
A=gets.split.map &:to_i

A=A.sort.reverse
if A[0]<K
  print("IMPOSSIBLE")
  exit
end

if K%(A.gcd)==0 
print("POSSIBLE") 
else
print("IMPOSSIBLE")
end

Measured memory_bytes: 10112
main = do
  (s:_) <- words <$> getLine
  putStrLn $ yymmormmyy s

yymmormmyy s
  | (s1 >= "01" && s1 <= "12") && (s2 >= "01" && s2 <= "12") = "AMBIGUOUS"
  | not (s1 >= "01" && s1 <= "12") && not (s2 >= "01" && s2 <= "12") = "NA"
  | (s1 >= "01" && s1 <= "12") && not (s2 >= "01" && s2 <= "12") = "MMYY"
  | not (s1 >= "01" && s1 <= "12") && (s2 >= "01" && s2 <= "12") = "YYMM"
  where
   s1 = take 2 s
   s2 = drop 2 s

Measured memory_bytes: 380
package main

import (
	"fmt"
)

var weathers []string = []string{"Sunny", "Cloudy", "Rainy"}

func main() {
	var in string
	fmt.Scanf("%s", &in)

	for i := 0; i < len(weathers); i++ {
		if weathers[i] == in {
			fmt.Printf("%s\n", weathers[(i+1)%len(weathers)])
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;

// TEMPLATE DEFINITIONS END

int n;

void read_input(){
    cin >> n;
}

void solve(){
    int sol = 0;
    for(int i=1;i<=n/2;i++){
        int x = i;
        int y = n - x;
        if(x != y) sol++;
    }
    cout << sol << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(long long K, long long N, vector<long long> A){
    ll ma = -(1e9+9);
    sort(A.begin(), A.end());
    A[N] = A[0] + K;
    rep(i, N) ma = max(ma, A[i+1] - A[i]);
    cout<< K-ma <<endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    cin >> K;
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    solve(K, N, move(A));
}


Measured memory_bytes: 1792
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto STONES = scan!string.to!(char[]);

  long solve() {
    long left = 0;
    long right = N-1;
    long ans;
    while(left <= right) {
      if (STONES[right] != 'R') {
        right--;
        continue;
      }

      if (STONES[left] != 'W') {
        left++;
        continue;
      }

      STONES.deb;
      [ans, left, right].deb;

      STONES[left] = 'R';
      STONES[right] = 'W';
      ans++;
    }
    
    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 4116
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=2e5 + 100;
typedef pair<int,int> pii;
#define fi first
#define se second

int n,m;
pii q[MAXN];
int cnt[MAXN],f[MAXN],a[MAXN];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++) scanf("%d%d",&q[i].fi,&q[i].se);
    for(int i=1;i<=n;i++) cnt[a[i]]++;
    for(int i=1;i<=n;i++){
        if(cnt[i])
            for(int j=max(0,i-cnt[i]);j<i;j++)
                f[j]++;
    }
    int ans=0;
    for(int i=0;i<n;i++) if(!f[i]) ans++;
    for(int i=1;i<=m;i++){
        int x=a[q[i].fi],y=q[i].se;
        a[q[i].fi]=y;
        if(x-cnt[x]>=0){
            f[x-cnt[x]]--;
            if(f[x-cnt[x]]==0) ans++;
        }
        cnt[x]--;
        if(y-cnt[y]-1>=0){
            f[y-cnt[y]-1]++;
            if(f[y-cnt[y]-1]==1) ans--;
        }
        cnt[y]++;
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 5248
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Stack<Integer> stack = new Stack<Integer>();
        while(sc.hasNextInt()){
            int a=sc.nextInt();
            if(a==0){
                System.out.println(stack.pop());
            }else{
                stack.push(a);
            }
        }
    }
}

Measured memory_bytes: 26200
def main():
    N = int(input())
    S = input()

    slime = S[0]
    for i in range(N - 1):
        a = S[i]
        b = S[i + 1]
        if a != b:
            slime += b
    ans = len(slime)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {

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

  string tmp;
  cin >> tmp;

  int q;
  cin >> q;

  int r = 0;
  deque<char> s;  
  for (auto i : tmp)  s.push_back(i);

  while (q--) {
    int c;
    cin >> c;

    if (c == 1) r ^= 1;
    else {
      int f;
      cin >> f;

      char c;
      cin >> c;

      int rr = r;
      if (f == 2) rr ^= 1;

      if (rr) s.push_back(c);
      else s.push_front(c);
    }
  } 

  string ans;   
  while (s.size()) {
    ans += s.front();
    s.pop_front();
  }

  if (r)  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
}


Measured memory_bytes: 1368
if __name__ == '__main__':
    n = int(input())
    assert n >= 2, '输入至少包含两个数'
    a = int(input())
    b = int(input())
    res = b - a
    min_value = min(a, b)
    for _ in range(n - 2):
        tmp = int(input())
        res = max(tmp - min_value, res)
        min_value = min(tmp, min_value)
    print(res)


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;
    int a = 0, b = 0, c = 0, d = 0;

    while (n--) {
        string s; cin >> s;

        if (s == "AC") ++a;
        else if (s == "WA") ++b;
        else if (s == "TLE") ++c;
        else if (s == "RE") ++d;

        
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3644
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e;

    if( a<0)f=d+e*b+(-a)*c;


    if(a==0)f=d+e*b;


    if( a>0)f=(b-a)*e;

    cout<<f<<endl;
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int main() {
	string s; cin >> s;

	set<char> sub;

	for (int i = 'a'; i <= 'z'; i++) {
		char buf = (char)i;
		sub.insert(buf);
	}

	for (char c : s) {
		sub.erase(c);
	}

	int A = 0;
	rep(i, s.length()- 1)A |= s[i] < s[i + 1];

	if (s.length() < 26) {
		cout << s + *sub.begin() << endl;
	}
	else {

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

		string t = s;

		next_permutation(s.begin(), s.end());
		
		for (int i = 0; i < 26; i++) {
			cout << s[i];
			if (s[i] != t[i])break;
		}

		cout <<endl;
	}

	return 0;
}

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

using namespace std;

int main(){
    int x, y; cin >> x >> y;
    int ans=0;
    if(x==1) ans+=3;
    else if(x==2) ans+=2;
    else if(x==3) ans+=1;
    if(y==1) ans+=3;
    else if(y==2) ans+=2;
    else if(y==3) ans+=1;
    if(x==1 && y==1) ans+=4;
    cout << ans*100000 << endl;
    return 0;
}


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

using namespace std;

typedef long long int lli;

int main() {
    lli n, k, a[100000];

    cin >> n >> k;
    for (int i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        //cout << a[i] << endl;
    }
    
    lli zero[41] = {0}, one[41] = {0};
    for (int i=0; i<n; i++) {
        for (int j=0; j<=40; j++){
            lli mask = (lli)1 << j;
            if (a[i] & mask) one[j] += mask;
            else             zero[j] += mask;
        }
    }

    /*
    for (int i=0; i<41; i++) {
        cout << one[i] << " ";
    }
    cout << endl;
    for (int i=0; i<41; i++) {
        cout << zero[i] << " ";
    }
    cout << endl;
    */

    lli best[42] = {0}, effort[42] = {0};
    for (int i=0; i<=40; i++) {
        best[i+1] = best[i] + max(zero[i], one[i]);
        effort[i+1] = effort[i] + ((k&((lli)1<<i)) ? max(zero[i], one[i]) : one[i]);
    }

    /*
    for (int i=0; i<5; i++) {
        cout << best[i] << " ";
    }
    cout << endl;
    for (int i=0; i<41; i++) {
        cout << effort[i] << " ";
    }
    cout << endl;
    */

    lli ans = effort[41];
    for (int i=40; i>=0; i--) {
        lli mask = (lli)1 << i;
        if ((k&mask) == 0) {
            // cout << "i = " << i << " ans = " << ans << endl;
            continue;
        }

        lli tmp = effort[41] - effort[i+1] + one[i] + best[i];
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024