akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
using namespace std;

int main() {
	string s,t;
	cin>>s>>t;
	int k=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
		{
			k++;
		}
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if i<k:
        for j in range(1, 18):
            if i*(2**j) >= k:
                e = j
                break
    else:
        e = 0

    ans += (1/n)*(2**(-e))

print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long

int main(void){
	int N;
	cin >> N;
	vector<ll> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	if(a[0] != 0 ){
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	for(int i=1;i<N;i++){
		if(a[i]==a[i-1]){
			ans += a[i];
		}else if(a[i] == a[i-1] + 1){
			ans += 1;
		}else if(a[i] > a[i-1]+1){
			cout << -1 << endl;
			return 0;
		}else if(a[i]==1){
			ans ++;
		}else{
			ans += a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
		int n=sc.nextInt();
		int x=sc.nextInt();
		int t=sc.nextInt();
		
		double c=(double)n/x;
		int v=n/x;
		
		if(c==(double)v) System.out.println(v*t);
		else System.out.println((v+1)*t);
    	
    }
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;
const ll MAX_N=3e5,MOD=998244353;

ll N,A,B,K;
ll fact[MAX_N+1];

ll mpw(ll n,ll m){
	ll ret=1;
	if (m==0){
		return 1;
	}
	ret=mpw(n,m/2);
	ret*=ret;
	ret%=MOD;
	if (m%2==1){
		ret*=n;
		ret%=MOD;
	}
	return ret;
}

ll inv(ll n){
	return mpw(n,MOD-2);
}

ll comb(ll n,ll m){
	return fact[n]*inv(fact[m])%MOD*inv(fact[n-m])%MOD;
}

int main(){
	fact[0]=1;
	FOR(i,1,MAX_N+1)
		fact[i]=fact[i-1]*i%MOD;
	
	ll ans=0;
	cin>>N>>A>>B>>K;
	REP(i,N+1){
		if ((K-A*i)>=0 && (K-A*i)%B==0){
			ll j=(K-A*i)/B;
			if (j<=N){
				ans+=comb(N,i)*comb(N,j)%MOD;
				ans%=MOD;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> hasOkashi(n, false);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            a--;
            hasOkashi[a] = true;
        }
    }
    int ans = 0;
    for (auto e : hasOkashi) {
        if (!e) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int ver[30];
    int verCount;
    int horCount;
    int a,b;
    
    scanf("%d", &verCount);
    for (int i=0;i<verCount;i++){
        ver[i]=i+1;
    }
    scanf("%d", &horCount);
    
    for(int i=0;i<horCount;i++) {
        scanf("%d,%d", &a, &b);
        
        int tmp = ver[a-1];
        ver[a-1] = ver[b-1];
        ver[b-1] =tmp;
    }
    
    for(int i=0;i<verCount;i++) {
        printf("%d\n", ver[i]);
    }
    
    return 0;
}



Measured memory_bytes: 1988
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int H,W,N;
  cin>>H>>W>>N;
  int sx,sy;
  cin>>sx>>sy;
  string S,T;
  cin>>S;
  cin>>T;

  int up=1;
  int dw=H;
  for(int i=N-1;i>=0;i--){
    if(T[i]=='U') dw=min(H,dw+1);
    else if(T[i]=='D') up=max(1,up-1);

    if(S[i]=='U') up=up+1;
    else if(S[i]=='D') dw=dw-1;

    if(up>dw||up>H||dw<1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(sx<up||sx>dw){
    cout<<"NO"<<endl;
    return 0;
  }

  int lef=1;
  int rig=W;
  for(int i=N-1;i>=0;i--){
    if(T[i]=='L') rig=min(W,rig+1);
    else if(T[i]=='R') lef=max(1,lef-1);

    if(S[i]=='L') lef=lef+1;
    else if(S[i]=='R') rig=rig-1;
    if(lef>rig||lef>W||rig<1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(sy<lef||sy>rig){
    cout<<"NO"<<endl;
    return 0;
  }

  cout<<"YES"<<endl;

  return 0;
}


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

int main(){

    int a, b;
    scanf("%d %d", &a, &b);
    if ((a > 9) || (b > 9)){
        printf("-1\n");
    } else {
        printf("%d\n", a * b);
    }

    return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main {

	private static int[][] square = new int[10][10];
	private static int mostDeep = 0;
	private static int whiteTiles = 0;

	/**
	 * 標準入力された値を受け取り、インクのサイズによって滲む範囲を切り分ける。
	 * すべての入力が終了した後にまだインクが滲んでいないマスの数と、最も濃いマスを判定し、出力する。
	 *
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		String[] inputString;
		String readLine = "";

		Scanner input = new Scanner(System.in);

		while (input.hasNext()) {

			readLine = input.next();

			// 受け取った一行をカンマ毎に区切る
			inputString = readLine.split(",", 0);

			switch (Integer.parseInt(inputString[2])) {
			case 1:
				smallInk(Integer.parseInt(inputString[0]),
						Integer.parseInt(inputString[1]));
				break;
			case 2:
				mediumInk(Integer.parseInt(inputString[0]),
						Integer.parseInt(inputString[1]));
				break;
			case 3:
				largeInk(Integer.parseInt(inputString[0]),
						Integer.parseInt(inputString[1]));
				break;
			}
		}

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (square[i][j] == 0) {
					whiteTiles++;
				} else {
					if (square[i][j] > mostDeep) {
						mostDeep = square[i][j];
					}
				}
			}
		}
		System.out.println(whiteTiles + "\r\n" + mostDeep);
	}

	/**
	 * インクが小の場合の処理
	 *
	 * @param x
	 * @param y
	 */
	static void smallInk(int x, int y) {

		if (x - 1 >= 0) {
			square[x - 1][y]++;
		}

		if (x + 1 <= 9) {
			square[x + 1][y]++;
		}

		square[x][y]++;

		if (y - 1 >= 0) {
			square[x][y - 1]++;
		}

		if (y + 1 <= 9) {
			square[x][y + 1]++;
		}

	}

	/**
	 * インクが中の場合の処理
	 *
	 * @param x
	 * @param y
	 */
	static void mediumInk(int x, int y) {

		for (int i = x - 1; i <= x + 1; i++) {
			for (int j = y - 1; j <= y + 1; j++) {
				if (i >= 0 && i <= 9) {
					if (j >= 0 && j <= 9) {
						square[i][j]++;
					}
				}
			}
		}
	}

	/**
	 * インクが大の場合の処理
	 *
	 * @param x
	 * @param y
	 */
	static void largeInk(int x, int y) {

		if (x - 2 >= 0) {
			square[x - 2][y]++;
		}

		if (x + 2 <= 9) {
			square[x + 2][y]++;
		}

		for (int i = x - 1; i <= x + 1; i++) {
			for (int j = y - 1; j <= y + 1; j++) {
				if (i >= 0 && i <= 9) {
					if (j >= 0 && j <= 9) {
						square[i][j]++;
					}
				}
			}
		}

		if (y - 2 >= 0) {
			square[x][y - 2]++;
		}

		if (y + 2 <= 9) {
			square[x][y + 2]++;
		}
	}
}

Measured memory_bytes: 17156
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char s1[100],s2[100],s3[100];
	scanf("%s %s %s",s1,s2,s3);
	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
	s3[0] = toupper(s3[0]);

	printf("%c%c%c\n",s1[0],s2[0],s3[0]);
	
   	return 0;
}

Measured memory_bytes: 2152
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define MAX_N 100000
#define MAX_AN 3 * MAX_N
#define MAX_A 1000000000
#define MINF -1000000000000000

int main() {
    int N;
    cin >> N;
    static int a[MAX_AN+1];
    for (int i = 0; i < 3*N; i++) cin >> a[i];

    priority_queue<int, vector<int>, greater<int>> pqf;
    long long fsum[N+1] = {0};
    for (int i = 0; i < N; i++) {
        pqf.push(a[i]);
        fsum[0] += a[i];
    }
    int fcnt = 1;
    for (int k = N; k < 2*N; k++ ) {
        pqf.push(a[k]);
        int mina = pqf.top();
        pqf.pop();
        fsum[fcnt] = fsum[fcnt-1] + a[k] - mina;
        fcnt++;
    }

    priority_queue<int> pqb;
    long long bsum[N+1] = {0};
    for (int i = 2*N; i < 3*N; i++) {
        pqb.push(a[i]);
        bsum[N] += a[i];
    }
    int bcnt = N-1;
    for (int k = 2*N-1; k >= N; k--) {
        pqb.push(a[k]);
        int maxa = pqb.top();
        pqb.pop();
        bsum[bcnt] =bsum[bcnt+1] + a[k] - maxa;
        bcnt--;
    }

    long long  maxval = MINF;
    for (int i = 0; i < N+1; i++) {
        maxval = max(maxval, fsum[i] - bsum[i]);
    }
    cout << maxval << endl;
    return 0;
}


Measured memory_bytes: 4088
#include<stdio.h>
int main(void)
{
    long int n,a[200],i,j,k=0;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    while(1){
        j=0;
        for(i=0;i<n;i++){
            if(a[i]%2==0)
                j++;
        }
        if(j==n){
            for(i=0;i<n;i++)
                a[i]=a[i]/2;
            k++;
        }
        if(j!=n)
            break;
    }
    printf("%ld\n",k);
    return 0;
}

Measured memory_bytes: 128
def z;gets.split.map &:to_i;end
def x a,b;a[0]*b[1]-b[0]*a[1]end
def v a;[a[2]-a[0],a[3]-a[1]]end
while(n=z)!=[0]*4
a=[n,z,z]
q=a.zip(a.rotate).map{|b,c|(d=x(v(b),v(c))).abs>0&&(s,t=[b,c].map{|i|x(v(b[0,2]+c[0,2]),v(i))}
[s,d-s,t,d-t].all?{|i|d<0?i<=0:i>=0}&&[0,1].map{|i|b[i]+t*(b[i+2]-b[i])/d.to_f})}
puts %w(dai-kichi chu-kichi kichi syo-kichi kyo)[q.all?&&(y=x(v(q[0]+q[1]),v(q[1]+q[2])).abs/1e5)>0&&[38,20,2,0].index{|i|1e-9>i-y}||4]end

Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

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

#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 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 VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

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);
  } else {
    return (n * POW(n, m - 1));
  }
}

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 N, A, B;
  cin >> N >> A >> B;
  cout << max(0LL, (B * (N - 2)) + 1 - (A * (N - 2))) << endl;
  return 0;
}


Measured memory_bytes: 3628
using System;

class B
{
	static void Main()
	{
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var x = new int[11];
		x[0] = a[2];
		for (int i = 1; i <= 10; i++)
		{
			x[i] = a[0] * x[i - 1] - a[1];
			Console.WriteLine(x[i]);
		}
	}
}


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

int main() {
    int H, W; cin >> H >> W;
    int h, w; cin >> h >> w;
    cout << (H*W - W*h - (H*w - w*h)) << endl;
}

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

int main(void)
{
  while (true){
    int n;
    int a_ans = 0, b_ans = 0;
    int a, b;

    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++){
      cin >> a >> b;

      if (a > b){
        a_ans += a + b;
      }
      else if (a < b){
        b_ans += a + b;
      }
      else{
        a_ans += a;
        b_ans += b;
      }
    }

    cout << a_ans << " " << b_ans << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  ll N, K;
  cin >> N >> K;
  ll ans {N - K*(N/K)};
  mins(ans, std::abs(ans-K));
  mins(ans, std::abs(K-ans));
  cout << ans << '\n';
}


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

const int MAXN = 110;
int n;
char s[MAXN], t[MAXN];

int main() {
	int i, j, k;
	cin >> n;
	scanf("%s", s+1);
	scanf("%s", t+1);
	for(i = 0; i <= n; i++) {
		for(j = 1; j+i <= n; j++) 
			if(s[i+j] != t[j]) break;
		if(j+i <= n) continue;
		break;
	}
	printf("%d\n", i+n);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

temp = 0
cnt = 0
for i in range(n-1):
    #print(temp)
    if A[i] < A[i+1]:
        if temp == 0:
            temp = 1
        elif temp == -1:
            temp = 0
            cnt += 1
        else:
            pass
    elif A[i] > A[i+1]:
        if temp == 0:
            temp = -1
        elif temp == 1:
            temp = 0
            cnt += 1
        else:
            pass
    else:
        pass
else:
    cnt += 1
print(cnt)

Measured memory_bytes: 62704
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, t;
  cin>>n>>t;
  vector<ll> a(n); rep(i, n) cin>>a[i];
  ll res = t;
  rep(i, n-1) res += min(a[i+1]-a[i], t);
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			int x = scan.nextInt();
			if(n == 0 && x == 0){
				scan.close();
				break;
			}
			int cnt = 0;
			for(int i = n; i >= 3; i--){
				for(int j = i - 1; j >= 2; j--){
					for(int k = j - 1; k >= 1; k--){
						if(i + j + k == x){
							//System.out.println(i + " + " + j + " + " + k + " = " + x);
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt);
		}
	}
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}


void Main() {
	ll A, B;
	cin >> A >> B;
	cout << (A * B) << endl;
}


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string str;
	
	while (getline(cin, str)) {
	
		for (int i=0; i<26; i++) {
			if (str.find("the")!=str.npos || str.find("this")!=str.npos || str.find("that")!=str.npos) break;
			for (int j=0; j<(int)str.size(); j++) {
				if (str[j] == '.' || str[j] == ' ') continue;
				str[j] = 'a' + (str[j] - 'a' + 1)%26;
			}
		}
	
		cout << str << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    REP(b, 1, N+1){
      ans += max(0LL, b - K) * (N/b) + max(0LL, N % b - K + 1);
    }
    if(K == 0) ans = N * N;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n,m;
    cin>>n>>m;
    LL h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    LL flg[n];
    for(int i=0;i<n;i++){flg[i]=1;}
    for(int i=0;i<m;i++){
        LL a,b;
        cin>>a>>b;
        a=a-1;
        b=b-1;
        if(h[a]>=h[b]){flg[b]=0;}
        if(h[b]>=h[a]){flg[a]=0;}
    }
    LL ans=0;
    for(int i=0;i<n;i++){
        if(flg[i]==1){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b) swap(a,b);
    cout<<(max(0,b-a-w))<<endl;
    return 0;
}

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

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	string s;
	cin>>s;
	set<string>res;
	priority_queue<pair<string,int>,vector<pair<string,int>>,greater<pair<string,int>>>pq;
	int K;
	cin>>K;
	rep(i,0,sz(s)){
		pq.push(mp(s.substr(i,1),i));
	}
	while(sz(res)<K){
		auto cur=pq.top();
		pq.pop();
		res.insert(cur.F);
		cur.S++;
		if(cur.S<sz(s))cur.F.pb(s[cur.S]),pq.push(cur);
	}
	cout<<*res.rbegin();
}

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

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int a[100001];
int res[100001];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&a[i]);
	}
	if(m==1){
		printf("%d\n",a[0]);
		if(a[0]==1){
			printf("%d\n",1);
			printf("%d\n",1);
			return 0;
		}
		printf("%d\n",2);
		printf("%d %d\n",a[0]-1,1);
	}
	if(m==2){
		printf("%d %d\n",a[0],a[1]);
		if(a[0]==1){
			printf("%d\n",1);
			printf("%d\n",a[0]+a[1]);
			return 0;
		}
		printf("%d\n",2);
		printf("%d %d\n",a[0]-1,a[1]+1);
	}
	if(m>=3){
		int cnt=0;
		for(int i=0;i<m;i++){
			if(a[i]%2==1)cnt++;
		}
		if(cnt>2){
			printf("Impossible\n");
			return 0;
		}
		int p=min(cnt,1);
		cnt=0;
		for(int i=0;i<m;i++){
			if(a[i]%2==1){
				if(cnt==0)res[0]=a[i];
				else res[m-1]=a[i];
				cnt++;
			}else{
				res[i+p-cnt]=a[i];
			}
		}
		if(res[0]==1){
			for(int i=0;i<m;i++){
				printf("%d%c",res[i],i+1==m?'\n':' ');
			}
			printf("%d\n",m-1);
			res[m-1]++;
			for(int i=1;i<m;i++){
				printf("%d%c",res[i],i+1==m?'\n':' ');
			}
			return 0;
		}
		for(int i=0;i<m;i++){
			printf("%d%c",res[i],i+1==m?'\n':' ');
		}
		printf("%d\n",m);
		res[0]--;
		res[m-1]++;
		for(int i=0;i<m;i++){
			printf("%d%c",res[i],i+1==m?'\n':' ');
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mx=(1<<18)-1;
struct aaa{
	ll x,y;
}a[15000010];
ll n,m,k,S,T,ha,ans,c[101][101],b[101],cnt[500010];
bool cmp(aaa a,aaa b){
	return a.x<b.x||a.x==b.x&&a.y<b.y;
}
int main(){
	ll i,j,w,hh,flag;
	scanf("%lld%lld%lld%lld",&n,&k,&S,&T);
	for(i=0;i<=n;i++)c[i][0]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=i;j++)c[i][j]=c[i-1][j]+c[i-1][j-1];
	for(i=1;i<=n;i++){
		for(j=1;j<=min(i,k);j++)b[i]=b[i]+c[i][j];
	}
	for(i=1;i<=mx;i++)cnt[i]=cnt[i>>1]+(i&1);
	//mx=1ll<<18;mx--;
	for(j=0;j<18;j++){
		if((S&(1ll<<j))&&!(T&(1ll<<j)))return puts("0"),0;
		if((S&(1ll<<j))==(T&(1ll<<j)))ha|=1ll<<j;
	}
	for(i=1;i<=n;i++){
		scanf("%lld",&w);
		flag=0;
		for(j=0;j<18;j++)if((ha&(1ll<<j))&&(w&(1ll<<j))!=(S&(1ll<<j))){
			flag=1;break;
		}
		if(flag)continue;
		//printf("%lld\n",i);
		for(j=0;j<=mx;j++)if(!(ha&j)){
			hh=w&j;
			a[++m].x=j;a[m].y=hh;
			//printf("%lld %lld\n",j,hh);
		}
	}
	sort(a+1,a+m+1,cmp);
	for(i=1;i<=m;i++)if(i==1||(a[i].x!=a[i-1].x||a[i].y!=a[i-1].y)){
		j=i;
		while(j<=m&&a[i].x==a[j].x&&a[i].y==a[j].y)j++;
		//printf("%lld %lld %lld %lld\n",i,j-1,a[i].x,a[i].y);
		w=b[j-i];
		if(cnt[a[i].x]%2)ans-=w;
		 else ans+=w;
	}
	printf("%lld",ans);
}

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

typedef long long ll;

int main() {
    int N, A;
    cin >> N;
    vector<int> ans(N, 0);
    rep(i, N - 1) {
        cin >> A;
        ans[A - 1]++;
    }
    rep(i, N) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  map<char,int> a;
  for(int i=0;i<s.size();i++)
    a[s.at(i)]++;
  cout<<(a['a']==1&&a['b']==1&&a['c']==1?"Yes":"No")<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
   public:
    int dp[1000009][2];
    void solve() {
        string s;
        cin >> s;
        dp[0][0] = 0;
        dp[0][1] = 1;
        for (int i = 1; i <= s.size(); ++i) {
            int num = s[i - 1] - '0';
            dp[i][0] = min(dp[i - 1][1] + 10 - num, dp[i - 1][0] + num);
            if (num != 9) {
                num++;
                dp[i][1] = min(dp[i - 1][1] + 10 - num, dp[i - 1][0] + num);
            } else {
                dp[i][1] = dp[i - 1][1];
            }
        }
        cout << dp[s.size()][0] << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

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

    cout << ((n + 1) / 2) << endl;
    return (0);
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
    long int dogn = 0;
    char name[16] = { 0 };
    int i = 0;

    scanf("%ld", &dogn);
    dogn--;

    while (dogn > -1) {
        name[i] = dogn % 26 + 'a';
        dogn = dogn / 26;
        i++;
        dogn--;
    }

    while (i--) {
        printf("%c", name[i]);
    }
    printf("\n");

    return 0;
}

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

int main(){
  long long int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  rep(i,n,0){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.rbegin(), b.rend());
  
  rep(i,n,0){
    if(a[i] == b[0]) cout << b[1] << endl;
    else cout << b[0] << endl;
  }
}

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

vector<int> h(100);
vector<int> a(100);
int counts = 0;
int n;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h.at(i);

    int maxh = 0;
    for (int i = 0; i < n; ++i)
    {
        maxh = max(h.at(i), maxh);
        a.at(i) = maxh;
    }

    for (int i = 0; i < n; ++i)
    {
        if (h.at(i) >= a.at(i))
        {
            counts++;
        }
    }

    cout << counts << endl;
}

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

using namespace std;

using ll = long long;

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

    int n, m;
    cin >> n >> m;

    constexpr int INF = 1000 * 1000;
    vector<tuple<int, int, int>> edges(m);
    vector<vector<int>> d(n, vector<int>(n, INF));
    for (int v = 0; v < n; ++v) d[v][v] = 0;

    for (int i = 0; i < m; ++i) {
        cin >> get<0>(edges[i]) >> get<1>(edges[i]) >> get<2>(edges[i]);
        const int u = --get<0>(edges[i]);
        const int v = --get<1>(edges[i]);
        d[u][v] = d[v][u] = get<2>(edges[i]);
    }

    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i) {
            if (INF <= d[i][k]) continue;
            for (int j = 0; j < n; ++j) {
                if (INF <= d[k][j]) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }

    int res = 0;
    for (auto e : edges)
        if (d[get<0>(e)][get<1>(e)] < get<2>(e)) ++res;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+2;
const int LOG=30;
const int mod=1e9+7;
void add(int &a,int b){
	a+=b;
	if(a>=mod){
		a-=mod;
	}
}
void sub(int &a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
}
int mul(int a,int b){
	return (1ll*a*b)%mod;
}
int mat[LOG][3][3],dp[3],dp1[3],ar[N],mat1[3][3];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,m,temp;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>ar[i];
	}
	ar[m+1]=n;
	dp[0]=1;
	mat[0][0][0]=2;
	mat[0][0][1]=2;
	mat[0][0][2]=1;
	mat[0][1][0]=1;
	mat[0][1][1]=1;
	mat[0][1][2]=1;
	mat[0][2][0]=1;
	mat[0][2][2]=1;
	mat1[0][0]=1;
	mat1[0][1]=2;
	mat1[0][2]=1;
	mat1[1][1]=1;
	mat1[1][2]=1;
	mat1[2][2]=1;
	for(i=1;i<LOG;i++){
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				for(l=0;l<3;l++){
					add(mat[i][j][k],mul(mat[i-1][j][l],mat[i-1][l][k]));
				}
			}
		}
	}
	for(i=1;i<=m+1;i++){
		temp=ar[i]-ar[i-1]-1;
		for(j=0;j<LOG;j++){
			if((1<<j)&temp){
				for(k=0;k<3;k++){
					dp1[k]=0;
				}
				for(k=0;k<3;k++){
					for(l=0;l<3;l++){
						add(dp1[k],mul(dp[l],mat[j][l][k]));
					}
				}
				for(k=0;k<3;k++){
					dp[k]=dp1[k];
				}
			}
		}
		for(k=0;k<3;k++){
			dp1[k]=0;
		}
		for(k=0;k<3;k++){
			for(l=0;l<3;l++){
				add(dp1[k],mul(dp[l],mat1[l][k]));
			}
		}
		for(k=0;k<3;k++){
			dp[k]=dp1[k];
		}
//		for(j=0;j<3;j++){
//			cout<<dp[j]<<' ';
//		}
//		cout<<endl;
	}
	cout<<dp[2];
}

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

int main(){
   ll x,y;
   cin >> x >> y;
   ll ans = 0;
   while(x <= y){
      ans++;
      x*=2;
   }
   cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t A, B, M;
  cin >> A >> B >> M;

  vector<uint64_t> a(A), b(B);
  N_TIMES(i, A) { cin >> a[i]; }
  N_TIMES(j, B) { cin >> b[j]; }

  uint64_t S = *min_element(a.begin(), a.end()) 
             + *min_element(b.begin(), b.end());

  N_TIMES(m, M) {
    uint64_t x, y, c;
    cin >> x >> y >> c;
    --x; --y;

    S = min(S, a[x] + b[y] - c);
  }

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int a,b,t;

    cin>>a>>b>>t;

    cout<<(t/a)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	ll n, a, b;
	cin >> n >> a >> b;
	if(a%2 == b%2){
		cout << abs(a-b)/2 << endl;
	} else {
		ll ans = min(
			(a-1)/2 + (b-1)/2 + 1,
			(n-a)/2 + (n-b)/2 + 1
		);
		cout << ans << endl;
	}
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_H 110
#define MAX_W 10

// n を size 桁の二進数文字列表現 string にして返す
string Binf(int n, int size) {
    string res = "";
    REP(i, size) {
        if((n >> i) & 1) { res += '1'; }
        else { res += '0'; }
    }
    reverse(res.begin(), res.end());
    return res;
}

ll dp[MAX_H][MAX_W] = {};
ll H, W, K;
vector<ll> all_pat;

// 現在 i 行 j 列にいるときのパターン数
ll dfs(ll i = 0, ll j = 0) {
    if(i >= H) {
        if(j == K) { return 1; }
        return 0;
    }

    ll& ret = dp[i][j];
    if(~ret) { return ret; }
    ret = 0;

    for(auto& pat : all_pat) {
        if(j > 0 && ((pat >> (j-1)) & 1) ) {
            // 左に移動するパターン
            ret += dfs(i+1, j-1);
            ret %= MOD;
        } else if(j < W-1 && ((pat >> (j)) & 1) ) {
            // 右に移動するパターン
            ret += dfs(i+1, j+1);
            ret %= MOD;
        } else {
            ret += dfs(i+1, j);
            ret %= MOD;
        }
    }

    return ret;
}

signed main()
{
    cin >> H >> W >> K;
    MINUS(dp);
    K--;

    // all_pat の作成
    for(int pat = 0; pat < (1 << (W-1)); ++pat) {
        // 隣り合うビットが 1 のものはダメ
        bool isOk = true;
        for(int i = 0; i < W-2; ++i) {
            if( ((pat >> i) & 1) && ((pat >> (i+1)) & 1) ) {
                isOk = false;
                break;
            }
        }
        if(isOk) { all_pat.push_back(pat); }
    }

    printf("%lld\n", dfs());
    return 0;
}


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

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (h[i] <= 0) {
			continue;
		}
		int w = h[i];
		ans += w;
		for (int j = i; j < N; j++) {
			if (h[j] < w) {
				w = h[j];
			}
			h[j] -= w;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
mn = 1e10

for i in range(n+1):
    ans = 0
    a, b = i, n-i

    di, mo = divmod(a, 6)
    ans += mo
    while di>=6:
        di, mo = divmod(di, 6)
        ans += mo
    ans += di

    di, mo = divmod(b, 9)
    ans += mo
    while di>=9:
        di, mo = divmod(di, 9)
        ans += mo
    ans += di

    mn = min(mn, ans)
print(mn)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    int a=read(),b=read();
    if(a>0)cout<<"Positive";
    else if(b>=0)cout<<"Zero";
    else if((b-a)&1)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int W, Q;
	while(cin >> W >> Q, W || Q)
	{
		vector<int> W_used(W);
		for(int i = 0; i < W; ++i)
		{
			W_used[i] = -1;
		}
		for(int i = 0; i < Q; ++i)
		{
			char c;
			cin >> c;
			if(c == 's')
			{
				int id, w;
				cin >> id >> w;
				
				int width = 0;
				int max_width = 0;
				vector<P> empties;
				bool flag = false;
				int pos = 0;
				for(int j = 0; j < W; ++j)
				{
					if(W_used[j] == -1)
					{
						if(!flag)
						{
							pos = j;
							flag = true;
						}
						++width;
						if(max_width < width)
						{
							max_width = width;
						}
					}
					else
					{
						empties.push_back(P(pos, width));
						width = 0;
						flag = false;
					}
				}
				if(width > 0)
				{
					empties.push_back(P(pos, width));
				}
				if(w <= max_width)
				{
					for(int j = 0; j < empties.size(); ++j)
					{
						if(empties[j].second >= w)
						{
							cout << empties[j].first << endl;
							for(int k = empties[j].first; k < empties[j].first + w; ++k)
							{
								W_used[k] = id;
							}
							break;
						}
					}
				}
				else
				{
					cout << "impossible" << endl;
				}
			}
			else if(c == 'w')
			{
				int id;
				cin >> id;
				for(int j = 0; j < W; ++j)
				{
					if(W_used[j] == id)
					{
						W_used[j] = -1;
					}
				}
			}
		}
		cout << "END" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>

#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971

using namespace std;

int n; 
int a; 
int mi = 123456789; 
int sum; 

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n; 
	for (int i = 0; i < n; i++)
	{
		cin >> a; 
		sum += a; 
		if (a % 10) mi = min(a, mi); 
	}
	
	if (sum % 10) cout << sum << endl; 
	else
	{ 
		if (mi != 123456789) cout << sum - mi << endl; 
		else cout << 0 << endl; 
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RI(X) scanf("%d", &(X))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define PB push_back
#define MS1(X) memset((X), -1, sizeof((X)))
typedef long long LL;
using namespace std;
const int MOD=1e9+7;
const int SIZE=1e6+10;
int input[SIZE][3],ma[SIZE],an[SIZE],bfs[SIZE];
vector<int> e[SIZE];
void go(int in[]){
    int x=in[0]-1,dd=in[1],v=in[2];
    if(dd<=ma[x])return;
    ma[x]=dd;
    bfs[0]=x;
    int rr=1;
    REP(i,rr){
        int x=bfs[i];
        if(!an[x])an[x]=v;
        if(!ma[x])continue;
        REP(j,SZ(e[x])){
            int y=e[x][j];
            int nd=ma[x]-1;
            if(nd>ma[y]){
                ma[y]=nd;
                bfs[rr++]=y;
            }
        }
    }
}
int main(){
    DRII(N,M);
    REP(i,M){
        DRII(x,y);x--;y--;
        e[x].PB(y);
        e[y].PB(x);
    }
    DRI(Q);
    REP(i,Q)REP(j,3)RI(input[i][j]);
    MS1(ma);
    for(int i=Q-1;i>=0;i--){
        go(input[i]);
    }
    REP(i,N)printf("%d\n",an[i]);
    return 0;
}

Measured memory_bytes: 36856
N = int(input())
count = N
out = ''
dict = {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 0: 'z'}

while count > 0:
    out = str(dict[count%26]) + out
    if count%26 == 0:
        count = count - 1
    count = int(count/26)

print(out)

Measured memory_bytes: 9236
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
a = LIST()

cnt = 0
for i in range(N):
	if a[a[i]-1] == i+1:
		cnt += 1

print(cnt//2)


Measured memory_bytes: 15956
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

std::vector<std::vector<int> > G;
int N,color[202],num[202];

bool is_bipartite(){
  for(int i=0;i<N;i++) color[i]=-1;
  color[0]=0;
  std::queue<int> que;
  que.push(0);
  while(que.size()){
    int v=que.front();
    que.pop();
    for(int& u:G[v]){
      if(color[u]==-1){
        color[u]=(color[v]+1)%2;
        que.push(u);
      }else{
        if(color[u]==color[v]){
          return false;
        }
      }
    }
  }
  return true;
}

int solve(int s){
  for(int i=0;i<N;i++) num[i]=-1;
  num[s]=1;
  int max_num=1;
  std::queue<int> que;
  que.push(s);
  while(que.size()){
    int v=que.front();
    que.pop();
    for(int& u:G[v]){
      if(num[u]!=-1) continue;
      num[u]=num[v]+1;
      max_num=std::max(max_num,num[u]);
      que.push(u);
    }
  }
  return max_num;
}
    
int main(){
  std::cin>>N;
  G.resize(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      char c;
      std::cin>>c;
      if(c=='1') G[i].push_back(j);
    }
  }
  if(!is_bipartite()){
    std::cout<<"-1\n";
    return 0;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans=std::max(ans,solve(i));
  }
  std::cout<<ans<<std::endl;
  return 0;
}

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    if (n % 2 != 0) {
        cout << "No";
        return 0;
    }
    
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            cout << "No";
            return 0;
        }
    }
    
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
let solve h w c =
  for j = 0 to w - 1 do
    c.(0).(j) <- 1 - c.(0).(j);
    for i = 1 to h - 1 do
      c.(i).(j) <- if c.(i).(j) = 1 then 0 else c.(i-1).(j) + 1
    done
  done;
  let rec duduwa ans i j k = function
    | [] -> (ans, [(c.(i).(j), k)])
    | (ch, cj) :: y' when ch >= c.(i).(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) i j cj y'
    | ys -> (ans, (c.(i).(j), k) :: ys) in
  let rec doit ans = function
    | (i, _, xs) when i = h -> ans
    | (i, j, xs) when j = w -> doit (List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs) (i + 1, 0, [])
    | (i, j, []) -> doit ans (i, j + 1, [(c.(i).(j), j)])
    | (i, j, ((ch, _) :: _ as xs)) when ch < c.(i).(j) -> doit ans (i, j + 1, (c.(i).(j), j) :: xs)
    | (i, j, ((ch, _) :: _ as xs)) when ch > c.(i).(j) ->
      let (ans, ys) = duduwa ans i j j xs in
      doit ans (i, j + 1, ys)
    | (i, j, xs) -> doit ans (i, j + 1, xs) in
  doit 0 (0, 0, [])

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read () = List.map int_of_string (split_on_char ' ' (read_line ()))

let () =
  match read () with
  | [h; w] ->
    let c = Array.make_matrix h w 0 in
    for i = 0 to h - 1 do
      let rec doit j = function
        | [] -> ()
        | x::xs ->
          c.(i).(j) <- x;
          doit (j + 1) xs in
      doit 0 (read ())
    done;
    Printf.printf "%d\n" (solve h w c)
  | _ -> ()

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

int main()
{

    int n;
    cin >> n;
    long long a[100];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    sort(a, a + n);
    for (int i = 0; i < n - 2; i++)
        for (int j = i + 1; j < n - 1; j++)
            for (int k = j + 1; k < n; k++)
            {
                long long mx = max({a[i], a[j], a[k]});
                long long sum = a[i] + a[j] + a[k];
                if (sum > 2 * mx && a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                    ans++;
            }
    cout << ans;
}

Measured memory_bytes: 3632