akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long n,m,v[110],w[110],dp[110][100100];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
	{
		for(int o=1;o<=m;o++)
		{
			dp[i][o]=dp[i-1][o];
			if(o>=w[i])
				dp[i][o]=max(dp[i][o],dp[i-1][o-w[i]] + v[i]);
		}
	}	
	cout<<dp[n][m]<<endl;
} 

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

int l;
double a = 0, b = 0, c = 0;

int main () {

    cin >> l;

    a = l / 3.0;
    b = a;
    c = b;

    double d = a * b * c;

    cout.precision(6);
    cout << fixed << d;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int a[5005];
int sa[5005];
bool dp[5005][5005];
int n, k;

bool isok(int idx) {
	if (sa[idx] >= k)return false;
	memset(dp, 0, sizeof(dp));
	dp[idx][0] = true;
	FOR(i, idx, n) {
		REP(j, k + 1) {
			if (dp[i][j] == false)continue;
			dp[i + 1][j] = true;
			if (j + a[i] <= k)dp[i + 1][j + a[i]] = true;
		}
	}
	FOR(i, k - sa[idx], k) {
		if (dp[n][i])return false;
	}
	return true;
}

int main() {
	scanf("%d%d", &n, &k);
	REP(i, n)scanf("%d", &a[i]);
	sort(a, a + n);
	REP(i, n) {
		if (a[i] > k) {
			n = i;
			break;
		}
	}
	REP(i, n)sa[i + 1] = sa[i] + a[i];
	if (sa[n] < k) {
		printf("%d\n", n);
		return 0;
	}
	int l = 0, r = n;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		if (isok(mid))l = mid;
		else r = mid;
	}
	printf("%d\n", isok(l)?l:r);
	return 0;
}

Measured memory_bytes: 24704
from sys import stdin
from functools import lru_cache
n = int(stdin.readline().rstrip())
@lru_cache(maxsize=86)
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas(n-1)+lucas(n-2)

print(lucas(n))

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

using namespace std;

char s[105];

int cnt[55][30];

int main()
{
	
	int n;
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%s",s);
		for(int j = 0; j < strlen(s); j++)
		{
			cnt[i][s[j] - 'a']++;
		}
	}

	string s = "";
	for(int i = 0 ; i < 26; i++)
	{
		int aux = 200;
		for(int j = 0 ; j < n ; j++)
		{
			aux = min(aux,cnt[j][i]);
		}
		for(int j = 0 ; j < aux; j++)
			s += char( i + 'a');
	}
	printf("%s\n",s.c_str());
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, m;
	int d[200010], t[200010];
	cin >> n;
	rep(i, n) cin >> d[i];
	cin >> m;
	rep(i, m) cin >> t[i];
	sort(d, d+n);
	sort(t, t+m);
	int tmp=0;
	int muri=0;
	rep(i, m)
	{
		while(t[i]>d[tmp] && tmp<n-1) tmp++;
		if(tmp==n-1 && i==m-1 && t[i]==d[tmp])
		{
			muri=0;
			break;
		}
		if(t[i]!=d[tmp])
		{
			muri=1;
			break;
		}
		else tmp++;
	}
	if(muri==0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1792
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

template<class T>
T pow(long long a, long long b, T mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        T d = pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*pow(a,b-1,mod)%mod;
}

template<class T>
T comb(long long n,long long r,T mod){
    if(r > n) return 0LL;
    if(n == r || r == 0) return 1LL;
    long long fact1 = 1LL,fact2 = 1LL;
    for(long long i = n; i >= n-r+1; --i) fact1 = fact1*i%mod;
    for(long long i = r; i >= 1; --i) fact2 = fact2*i%mod;
    fact1 %= mod; fact2 %= mod;
    return fact1*pow(fact2,mod-2,mod)%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll MOD = 1e9+7;
    ll n,a,b; cin >> n >> a >> b;
    if(n == 2){
        cout << 0 << endl;
        return 0;
    }
    cout << ((pow(2,n,MOD)-comb(n,a,MOD)+MOD)%MOD-comb(n,b,MOD)-1+MOD)%MOD << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] h = new long[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextLong();
		}
		Arrays.sort(h);
		long ans = 10000000000L;
		for (int i = 0; i < N - K + 1; i++) {
			long temp = h[i+K-1] - h[i];
			if (ans > temp) {
				ans = temp;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 2e5 + 5;
LL a[MAXN], f[MAXN], n, k;

LL Check(LL k) {
  LL re = 0;
  for (RI i = 1; i <= n; ++i) {
    int j = n - i + 1;
    re += max(0ll, a[i] - k / f[j]);
  }
  return re;
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  read(n), read(k);
  for (RI i = 1; i <= n; ++i) read(a[i]);
  for (RI i = 1; i <= n; ++i) read(f[i]);
  sort(a + 1, a + 1 + n);
  sort(f + 1, f + 1 + n);
  LL l = 0, r = 1e12, mid, ans;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (Check(mid) <= k) ans = mid, r = mid - 1;
    else l = mid + 1;
  }
  printf("%lld\n", ans);

  return 0;
}

// created by Daniel yuan


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

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int g, p;
string s;

int main()
{
	cin >> s;
	
	int res = 0;
	for (auto u : s)
		if (p < g)
		{
			p ++ ;
			if (u == 'g') res ++ ;
		}
		else
		{
			g ++ ;
			if (u == 'p') res -- ;
		}
		
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_x,int arg_y,int arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}
	int x,y,z;
};

int diff_x[6] = {1,-1,0,0,0,0},diff_y[6]={0,0,1,-1,0,0},diff_z[6] = {0,0,0,0,1,-1};

int main(){

	ll A,B,C;
	int N;

	scanf("%lld %lld %lld %d",&A,&B,&C,&N);

	ll ans = 2*(A*B+B*C+C*A);

	vector<Info> V;
	int x,y,z,adj_x,adj_y,adj_z,adj_removed_num;

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&x,&y,&z);

		adj_removed_num = 0;

		for(int p = 0; p < 6; p++){
			adj_x = x+diff_x[p];
			adj_y = y+diff_y[p];
			adj_z = z+diff_z[p];
			if(adj_x < 0 || adj_y < 0 || adj_z < 0 || adj_x >= A || adj_y >= B || adj_z >= C){
				adj_removed_num++;
			}else{
				for(int k = 0; k < V.size();k++){
					if(V[k].x == adj_x && V[k].y == adj_y && V[k].z == adj_z)adj_removed_num++;
				}
			}
		}
		ans += 6-2*adj_removed_num;
		V.push_back(Info(x,y,z));
	}

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

	return 0;
}

Measured memory_bytes: 3240
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 100005
ll sum[2*MAX];
void solve_(){
	ll i;
	for(i=1;i<2*MAX-2;++i){
		sum[i]=sum[i-1]+i;
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve_();
    ll n,k,i,ans=1;
    cin>>n>>k;
    for(i=k;i<=n;++i){
    	ans=(ans+(sum[n]-sum[n-i])-sum[i-1]+1+mod)%mod;
	}
    cout<<ans%mod;
}

Measured memory_bytes: 5208
NO = "UNRESTORABLE"
S = input()
N = len(S)
T = input()
M = len(T)

candidates = []
for i in range(N - M + 1):
    if all(S[i + j] == "?" or S[i + j] == T[j] for j in range(M)):
        candidates.append((S[:i] + T + S[i + M :]).replace("?", "a"))
if candidates:
    candidates.sort()
    print(candidates[0])
else:
    print(NO)


Measured memory_bytes: 9064
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
int n;
ll k;
int a[200004],cycle_at;
std::vector<int> vis(200004,0);
void dfs(int s){
    vis[s]=1;
    if(vis[a[s]]){
        cycle_at=s;
        return;
    }
    else
    dfs(a[s]);
}
void solve(){
    cin>>n>>k;
    fr(i,1,n+1){
        cin>>a[i];
    }
    dfs(1);
    int s=1;
    while(k>0&&s!=cycle_at){
        s=a[s];
        k--;
    }
    // he is currently at cycle start
    ll len=1;
    int t=a[s];
    while(t!=cycle_at){
        len++;
        t=a[t];
    }
    k%=len;
    while(k--){
        s=a[s];
    }
    cout<<s;

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

}


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

int H, W;

int main(){	
	while(1){
		scanf("%d %d", &H, &W);
		if(H==0 && W==0){
			break;
		}else{
			for(int i=0; i<H; ++i){
				for(int j=0; j<W; ++j){
					if(i == 0 || i == H-1 || j==0 || j==W-1){
						printf("#");	
					}else{
						printf(".");	
					}	
				}
				printf("\n");
			}
			printf("\n");
		}
	}
}


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

int main()
{
    int n;
    long long t=0;
    cin>>n;
    string s[n],m;
    int l[n];
    for(int i=0;i<n;i++) cin>>s[i]>>l[i],t+=l[i];
    cin>>m;
    //if(m==s[n-1]) {cout<<0<<endl;return 0;}
    for(int i=0;i<n;i++)
    {
        if(m==s[i]) {t-=l[i];break;}
        else t-=l[i];
    }
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  string S, T; cin >> S >> T;
  int ans = 0;
  for(int i=0; i<3; i++){
    if (S[i]==T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(A):
  s,d,v = A
  C = [-1 for _ in [0]*(n+1)]
  c = 1
  C[s] = c
  SP = M[s]
  while 1:
    if SP==[]: return "NA"
    c += 1
    X = []
    for p in SP:
      if C[p]>0: continue
      C[p] = c
      for e in M[p]:
        if C[e]<0 and e not in SP: X.append(e)
      if p==d:
        if C[p]>v: return "NA"
        else: return C[p]
    SP = X

n = int(raw_input())
M = {}

for _ in [0]*n:
  x = map(int, raw_input().split())
  M[x[0]]=x[2:]
for _ in [0]*int(raw_input()):
  print solve(map(int,raw_input().split()))

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	ll n,k;cin>>n>>k;


	map<ll,ll> mp;

	rep(i,n){
		int a, b; cin>>a>>b;

		if(mp[a] <=k){mp[a] += b;}
	}



	for(auto e: mp){
		k -=e.second;

		if(k <=0){
			writeln(e.first);
			return 0;
		}
	}
}


Measured memory_bytes: 4224
N = int(input())
As = list(map(int,input().split()))
n = sum(x<0 for x in As)
ans = 0
if n%2 == 0:
    for i in range(N):
        ans += abs(As[i])
else:
    abs_list = []
    for i in range(N):
        abs_list.append(abs(As[i]))
        ans += abs(As[i])
    ans = ans-2*min(abs_list)
print(ans)

Measured memory_bytes: 14284
import java.util.*;

public class Main{


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


    dfs(0,0,0,0);

    System.out.println(count);

  }


  static int count = 0;
  static int flag3 , flag5 , flag7;
  static int n;

  static void dfs(long a,int f3,int f5, int f7){
    //System.out.println("a:"+a);
    if(f3>0&&f5>0&&f7>0&&(a <= n) ){

            //System.out.println(a);
            //System.out.println(f3+":"+f5+":"+f7);
            count++;

    }
    if(a > n){
    }else{
      if(a*10<n){
        dfs(a*10+3,f3+1,f5,f7);
        dfs(a*10+5,f3,f5+1,f7);
        dfs(a*10+7,f3,f5,f7+1);
      }
      //System.out.println("**"+ans);

    }



  }
}

Measured memory_bytes: 21972
n=int(input())
sp=[ [0,0,0] for i in range(n)]
for i in range(n):
    ss,pp = input().split()
    sp[i] = [ss,int(pp),i+1]
    

keys = sorted(set(s[0] for s in sp))

for k in keys:
    for ss in sorted([s[1:] for s in sorted(sp) if s[0]==k], reverse=True):
        print(ss[1])

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

int main() {
    int N;
    cin >> N;
    vector<int> data(N);
    for (int i=0; i<N; i++) {
        cin >> data.at(i);
    }

    int count = 0;
    while (true) {
        for (int j=0; j<N; j++) {
            if (data.at(j)%2 != 0) {
                cout << count << endl;
                exit(0);
            }
            data.at(j) /= 2;
        }
        count++;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    int m = 0;
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        m += num;
    }
    cout << m - N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


void solve(int W,int N){
//    cout << w << " " << n << endl;
    vector<int> v(N),w(N);
    char c;
    rep(i,N) cin>>v[i]>>w[i];

    vector<vector<int>> dp(N+10,vector<int>(W+10,0));
    for(int i=0;i<N;i++){
        // use v[i],w[i]
        for(int j=0;j<=W;j++){
            if(j+w[i]<=W){
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            }else{
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            }
        }
    }

//    for(int i=0;i<=w;i++) if(dp[n][i]==dp[n][w]){
//        printf("%d\n%d\n",dp[n][w],i);
//        return;
//    }
//    for(int i=0;i<=n;i++){
//        for(int j=0;j<=w;j++){
//            printf("%2d ",dp[i][j]);
//        }
//        cout << endl;
//    }
    cout << dp[N][W] << endl;
    //assert(false);
}

int main(){
    int w,n;
    int cnt=0;
    while(1){
        cin>>w;
        if(w==0) break;
        cin>>n;
//        printf("case %d:\n",++cnt);
        solve(n,w);
        break;
    }
}

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

constexpr int MAX_N = 100000;

int N, M;
std::vector<int> edges[MAX_N];
bool flag[MAX_N];

void dfs(int n, int prev);

int main(){

	std::cin >> N >> M;

	for(int i = 0; i < M; ++i){

		int x, y, z;

		std::cin >> x >> y >> z;

		--x, --y;

		edges[x].push_back(y);
		edges[y].push_back(x);
	}

	int ans = 0;

	for(int i = 0; i < N; ++i){
		if(!flag[i]){
			flag[i] = true;
			dfs(i, i);
			++ans;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

void dfs(int n, int prev){

	for(auto & edge : edges[n]){
		if(edge != prev && !flag[edge]){
			flag[edge] = true;
			dfs(edge, n);
		}
	}
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long n,i,j,a[100005],b[100005],m,k,bz[100005][65],x;
double c[100005];
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();
   	for(i=1;i<=n;i++)
		a[i]=read();
   	m=read();k=read();
   	for(i=1;i<n;i++)
   		bz[i][0]=i;
   	while(m--){
   		x=read();
   		swap(bz[x-1][0],bz[x][0]);
	}
	for(j=1;j<=59;j++)
		for(i=1;i<n;i++)
			bz[i][j]=bz[bz[i][j-1]][j-1];
	b[0]=a[1];
	c[0]=b[0];
	for(i=1;i<n;i++)
		a[i]=a[i+1]-a[i];
	for(i=1;i<n;i++){
		x=i;
		for(j=59;j>=0;j--)
			if((1LL<<j)&k)
				x=bz[x][j];
		b[i]=a[x];
	}
	for(i=1;i<n;i++){
		b[i]+=b[i-1];
		c[i]=b[i];
	}
	for(i=0;i<n;i++)
		printf("%.1lf\n",c[i]);
    return 0;
}

Measured memory_bytes: 54528
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int i, l, cnt;
    string s, t;

    cin >> s >> t;

    cnt = s.size();
    l = t.size();

    for(i = 0; i < l; i++)
        if(s[i] == t[i])
            cnt--;
    cout << cnt;

    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=100001;
	int n;
	cin>>n;
	ll a[MAX]={};
	ll b[MAX]={};
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	ll count1=0;
	if(a[0]<=0){
		count1+=abs(a[0])+1;
		a[0]=1;
	}
	for(int i=1;i<n;i++){
		if(a[i-1]>0 && a[i-1]+a[i]>=0){
			int temp=abs(a[i-1]+a[i])+1;
			count1+=temp;
			a[i]-=temp;
		}
		if(a[i-1]<0 && a[i-1]+a[i]<=0){
			int temp=abs(a[i-1]+a[i])+1;
			count1+=temp;
			a[i]+=temp;
		}
		a[i]+=a[i-1];
	}
	for(int i=0;i<n;i++){
		a[i]=b[i];
	}
	ll count2=0;
	if(a[0]>=0){
		count2+=abs(a[0])+1;
		a[0]=-1;
	}
	for(int i=1;i<n;i++){
		if(a[i-1]>0 && a[i-1]+a[i]>=0){
			int temp=abs(a[i-1]+a[i])+1;
			count2+=temp;
			a[i]-=temp;
		}
		if(a[i-1]<0 && a[i-1]+a[i]<=0){
			int temp=abs(a[i-1]+a[i])+1;
			count2+=temp;
			a[i]+=temp;
		}
		a[i]+=a[i-1];
	}
	cout<<min(count1,count2)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
vi adj[mx];
int dp[mx], vis[mx] = {0};
void dfs(int u)
{
    vis[u] = 1;
    int res = 0;
    for(int i=0; i<adj[u].size(); i++){
        int v = adj[u][i];
        if(vis[v]==0)
            dfs(v);
        res = max(res, 1 + dp[v]);
    }
    dp[u] = res;
}
int main()
{
    int n,m,a,b;
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d",&a, &b);
        adj[a].push_back(b);
    }
    for(int i=1; i<=n; i++) if(vis[i]==0) dfs(i);
    int ans = 0;
    for(int i=1; i<=n; i++) ans= max(ans, dp[i]);
    printf("%d\n",ans);
}



Measured memory_bytes: 9216
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#define MN 200
#define ll long long
#define mod 1000000007
#define Mod 4179340454199820289LL
using namespace std;
map<ll,int> mp;vector<pair<ll,ll> >s[MN*MN+5];
int n,f[MN+5][MN+5],pos[MN+5][MN+5],rk[MN+5],ans,same[MN+5],num;
ll K,a[MN+5],v[MN+5];
bool cmp(int a,int b){return v[a]<v[b];}
int main()
{
	cin>>n>>K;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int j=0;j<=60;++j) 
	{
		same[j]=1;
		for(int i=2;i<=n;++i) if(((a[i]>>j)&1)!=((a[i-1]>>j)&1)) same[j]=0;	
	}
	for(int i=0;i<=60;++i)
	{
		for(int j=1;j<=n;++j) v[j]=a[j]&((1LL<<i)-1),rk[j]=j;
		sort(rk+1,rk+n+1,cmp);
		for(int j=1;j<=n;++j) pos[i][rk[j]]=j;
	}
	memset(f,40,sizeof(f));f[0][0]=0;
	for(int i=1;i<=60;++i)
	{
		f[i][0]=i;
		for(int j=0;j<=n;++j)
		{
			int p1=0,p2=0;
			for(int k=1;k<=n;++k)
			{
				int v=(a[k]>>i-1)&1;
				if(v-(pos[i-1][k]<=j)<0) p1=max(p1,pos[i][k]);
				if(v-(pos[i-1][k]<=j)-1<0) p2=max(p2,pos[i][k]);	
			}
			f[i][p1]=min(f[i][p1],f[i-1][j]+1);
			f[i][p2]=min(f[i][p2],f[i-1][j]+2);
		}
	}
	for(int i=0;i<=60;++i) for(int j=0;j<=n;++j) if(f[i][j]<1000&&f[i][j]<=K)
	{
		int flag=1;
		for(int k=1;k<=n;++k)
		{
			v[k]=(a[k]>>i)-(pos[i][k]<=j?1:0);
			if(v[k]<0) flag=0;
		}
		if(!flag) continue;
	//	cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
		sort(v+1,v+n+1);ll ha=0;
		for(int k=2;k<=n;++k) ha=(7*ha+v[k]-v[1])%Mod;
		if(!mp[ha]) mp[ha]=++num;
		ll maxdec=min(v[1],K-f[i][j]);
		s[mp[ha]].push_back(make_pair(v[1]-maxdec,v[1]));
	//	cout<<"ha="<<ha<<" "<<v[1]-maxdec<<" "<<v[1]<<endl;
	}
	for(int i=1;i<=num;++i)
	{
		sort(s[i].begin(),s[i].end());
		ll l=0,r=-1;
		for(int j=0;j<s[i].size();++j)
			if(s[i][j].first>r) ans=(ans+r-l+1)%mod,l=s[i][j].first,r=s[i][j].second;
			else r=max(r,s[i][j].second);
		ans=(ans+r-l+1)%mod;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 2304
import Text.Printf
main :: IO()
main = do
  doLines

doLines :: IO()
doLines = do
  input <- getLine
  let [x,y] = map (\i -> read i :: Int) $ words input
  if [x,y] == [0,0]
  then
      return()
  else do
      putStrLn $ mySort x y
      doLines

mySort :: Int -> Int -> String
mySort x y
    | x <= y = printf "%d %d" x y
    | x >  y = printf "%d %d" y x

Measured memory_bytes: 4196
import java.util.*;

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

    int n = sc.nextInt();
    long[] a = new long[n];
    long sum = 0;

    for(int i = 0; i < n; i++){
      a[i] = sc.nextLong();
      sum += a[i];
    }

    Arrays.sort(a);

    System.out.println(a[0] + " " + a[n - 1] + " " + sum);
  }
}



Measured memory_bytes: 41972
package main

import(
	"fmt"
)

func main(){
	var x, n, max int
	var s string

	fmt.Scan(&n)
	fmt.Scan(&s)

	for _, r := range s {
		if r == 'I' {
			x++
		}else if r == 'D' {
			x--
		}
		
		if max < x {
			max = x
		}
	}


	fmt.Println(max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int n, t[400000];

void build() {  // build the tree
  for (int i = n - 1; i > 0; --i) t[i] = min(t[i<<1],t[i<<1|1]);
}

int query(int l, int r) {
  int res = n+1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = min(res,t[l++]);
    if (r&1) res = min(res,t[--r]);
  }
  return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	ll x = 0;
	F0R(i,n) cin >> t[n+i];
	build();
	F0R(i,n) {
	    int l = 0, r = i;
	    while (l != r) {
	        if (query((l+r-1)/2,i+1) == t[n+i]) r = (l+r-1)/2;
            else l = (l+r-1)/2+1;
	    }
	    ll ans = i-l+1;
	    l = i, r = n-1;
	    while (l != r) {
	        if (query(i,(l+r+1)/2+1) == t[n+i]) l = (l+r+1)/2;
            else r = (l+r+1)/2-1;
	    }
	    ans *= (r-i+1);
	    x += ans*t[n+i];
	}
	cout << x;
}

Measured memory_bytes: 1792
n = int(input())
sis = list(map(int,input().split(" ")))
cou = 0
li = []
for i in range(n-2):
    for j in range(i+1,n-1):
        if sis[j] != sis[i]:
            for k in range(j+1,n):
                if sis[j] != sis[k] and sis[k]!= sis[i]:
                    if sis[k] < (sis[j] + sis[i]) and sis[j] < (sis[k] + sis[i]) and sis[i] < (sis[j] + sis[k]):
                        li.append((sis[i],sis[j],sis[k]))
                        cou += 1
                        
print(cou)

Measured memory_bytes: 20420
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>


int main(int argc, char **argv) {
    long long N;
    long long t[5];
    std::cin >> N;
    for (int i = 0; i < 5; i++) {
        std::cin >> t[i];
    }

    long long min = 10000000000000000;
    for (int i = 0; i < 5; i++) {
        min = std::min(min, t[i]);
    }
    long long groups = (N % min == 0) ? N / min : N / min + 1;

    std::cout << 5 + groups - 1 << std::endl;
    return 0;
}

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

int main()
{
	int m, f, r;

	while (true){
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)
			break;

		else if (m == -1 || f == -1)
			cout << "F" << endl;

		else if ((m + f) >= 80)
			cout << "A" << endl;

		else if ((m + f) >= 65)
			cout << "B" << endl;

		else if ((m + f) >= 50)
			cout << "C" << endl;

		else if ((m + f) >= 30){

			if (r >= 50)
				cout << "C" << endl;

			else
				cout << "D" << endl;
		}

		else
			cout << "F" << endl;


	}
	return 0;
}

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

typedef long long ll;
using namespace std;

int main(){
	ll a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ans=a[2]-a[1];
	a[1]+=ans;
	a[0]+=ans;
	if((a[2]-a[0])%2==0){
		ans+=(a[2]-a[0])/2;
	}
	else{
		ans+=(a[2]-a[0])/2+2;
	}
	cout << ans<<endl;
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,h[101],count=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  count+=h[0];
  for(int i=1; i<n; i++){
    if(h[i-1]<h[i]){
      count+=h[i]-h[i-1];
    }
  }
  cout<<count<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define nl '\n'
 using namespace std;

const int mod = 998244353;
const int N = 3E5 + 1;
int n, k;
int a[N], tree[4 * N];

void update(int node, int st, int en, int idx, int val){
   if(st == en){
      tree[node] = val;
      return;
   }
   int mid = (st + en) / 2;
   if(idx <= mid)
     update(2 * node, st, mid, idx, val);
   else
     update(2 * node + 1, mid + 1, en, idx, val);

   tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

int query(int node, int st, int en, int l, int r){
    if(l <= 0 || r > N || l > r || st > r || en < l)
       return 0;

    if(l <= st && en <= r)
       return tree[node];
     
    int mid = (st + en) / 2;
    int left = query(2 * node, st, mid, l, r);
    int right = query(2 * node + 1, mid + 1, en, l, r);

    return max(left, right); 
}

int32_t main() 
{

  cin >> n >> k;

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

  // memset(dp, -1, sizeof dp);
 
  for(int i = 1; i <= n; i++){
      int x = a[i];
      int l = max(1LL, x - k), r = min(N, x + k);
      int mx = query(1, 1, N, l, r);
      update(1, 1, N, x, 1 + mx);
  }

  int ans = query(1, 1, N, 1, N);
 
  cout << ans;

  return 0;
}



Measured memory_bytes: 14176
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> submit(N, vector<int>(2));
    int ok = 0, wa = 0;
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "WA") {
            submit[p][0]++;
        } else {
            if(!submit[p][1]) {
                ok++;
                wa += submit[p][0];
            }
            submit[p][1]++;
        }
    }
    cout << ok << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
 
int N, a[105], b[105];
long long ans;
int main()
{
    cin >> N;
    for(int i = 0; i < 102; ++i) a[i] = 1e9 + 5;
    for(int i = 1; i < N ; ++i) cin >> b[i];
    b[0] = b[N] = 1e9 + 5;
    for(int i = 1; i < N; ++i)
        a[i] = min(b[i], b[i - 1]);
    a[N] = b[N - 1];
    for(int i = 1; i <= N; ++i)
        ans += a[i];
    cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge
{
    int v,w,nxt;
}e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w)
{
    e[++ecnt].v = v;
    e[ecnt].w = w;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
long long dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st)
{
    que.push(st);
    inq[st] = true;
    dist[st] = 0;
    long long curmax = 0,curmin = 0;
    while(!que.empty())
    {
        int u = que.front();
        que.pop();
        for(int i = head[u];i;i = e[i].nxt)
        {
            int v = e[i].v;
            if(dist[v] == 12345678987654321)
            {
                dist[v] = dist[u] + e[i].w;
                curmax = max(curmax,dist[v]);
                curmin = min(curmin,dist[v]);
                if(curmax - curmin > 1000000000)
                    return false;
                vis[v] = 1;
                if(!inq[v])
                    que.push(v);
            }
            else if(dist[v] != dist[u] + e[i].w)
                return false;
        }
        inq[u] = false;
    }
    return true;
}

int main()
{
    for(int i = 1;i <= 100000; ++ i)
        dist[i] = 12345678987654321;
    scanf("%d%d",&N,&M);
    for(int i = 1;i <= M; ++ i)
    {
        scanf("%d%d%d",&l[i],&r[i],&d[i]);
        adde(l[i],r[i],d[i]);
        adde(r[i],l[i],-d[i]);
    }
    for(int i = 1;i <= N; ++ i)
    {
        if(!vis[i])
        {
            vis[i] = 1;bool l = spfa(i);
            if(!l)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 9088
S = list(input())
T = list(input())
flag1 = 1
for i in range(len(S) - len(T), -1, -1):
    flag2 = 1
    for j in range(len(T)):
        if S[i+j] != '?' and S[i+j] != T[j]:
            flag2 = 0
    if flag2:
        S[i:i+len(T)] = T[:]
        flag1 = 0
        break

if flag1:
    print('UNRESTORABLE')
else:
    for i in range(len(S)):
        if S[i] == '?':
            S[i] = 'a'
    print(''.join(S))

Measured memory_bytes: 3064
A=int(input())
count=0
for i in range(int((A+1)/2)):
    B=i*2+1
    div=[]
    for j in range(1,B):
        if B%j==0:
            div.append(j)
        else:
            pass
    else:
        div.append(B)
    if len(div)==8:
        count+=1
    else:
        pass
else:
    print(count)
    

Measured memory_bytes: 3060
import copy


class Line:
    def __init__(self, a, b):
        self.a = a
        self.b = b


def can_goal(start, end, line_map, memo):
    if start == end:
        return True
    _can_goal = False
    if start in line_map:
        for next_start in line_map[start]:
            if memo[start][next_start] or memo[next_start][start]:
                continue
            memo[start][next_start] = True
            memo[next_start][start] = True
            _can_goal = can_goal(next_start, end, line_map, memo)
            if _can_goal:
                break
    return _can_goal


N, M = map(int, input().split())
lines = []
for _ in range(M):
    a, b = map(int, input().split())
    lines.append(Line(a, b))

line_map = {}
memo = {}
for line in lines:
    if line.a in line_map:
        line_map[line.a].append(line.b)
        memo[line.a][line.b] = False
    else:
        line_map[line.a] = [line.b]
        memo[line.a] = {}
        memo[line.a][line.b] = False
    if line.b in line_map:
        line_map[line.b].append(line.a)
        memo[line.b][line.a] = False
    else:
        line_map[line.b] = [line.a]
        memo[line.b] = {}
        memo[line.b][line.a] = False

cnt = 0
for line in lines:
    m = copy.deepcopy(memo)
    start = line.a
    end = line.b
    m[end][start] = True
    m[start][end] = True
    if not(can_goal(start, end, line_map, m)):
        cnt += 1
print(cnt)


Measured memory_bytes: 3572
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[200005];
char str1[200005];

void solve()
{
    scanf("%s%s", str0, str1);
    int n = strlen(str0);
    int cnt = 0;
    int i;
    for (i = 0; i < n; i++) {
        if (str0[i] != str1[i]) cnt++;
    }
    printf("%d\n", cnt);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

int main() {
    int n, tmp;
    
    std::vector<std::string> vec;
    
    std::cin >> n >> tmp;
    
    vec.reserve(n);
    
    std::string str;
    for(int i = 0; i < n; ++i) {
        std::cin >> str;
        
        vec.emplace_back(str);
    }
    
    std::sort(vec.begin(), vec.end());
    
    for(auto&& str : vec) 
        std::cout << str;
    
    std::cout << std::endl;
}

Measured memory_bytes: 764
program prob4
    character(len=100005)::S
    character::m(3)=(/'a','b','c'/)
    integer::cnt(4)
    integer::a,b,c,l,i,j
    read(*,*) S
    l = len_trim(S)
    cnt = 0

    do i = 1, l
        do j = 1, 3
            if(S(i:i) .eq. m(j)) then
                cnt(j) = cnt(j) + 1
            end if
        end do
    end do
    cnt(4) = cnt(1)

    do i = 1,3
        if(abs(cnt(i+1) - cnt(i)) > 1) then
            write(*,*) "NO"
            stop
        end if
    end do
    write(*,*) "YES"

    stop
end program

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

int main() {
    int N, R;
    int ans = 0;
    cin >> N >> R;

    if (N >= 10) {
        ans = R;
    }else {
        ans = R + 100 * (10 - N);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 2005;

int n, m, x, ans, A[MAXN][MAXN], H[MAXN][MAXN], V[MAXN][MAXN];
char s[MAXN];

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

    for (int i = 0; i < n; i++) {
        scanf(" %s", s);

        for (int j = 0; j < m; j++) {
            A[i][j] = s[j] == '#';
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (A[i][j] == 1) {
                H[i][j] = V[i][j] = 0;
            } else {
                if (!H[i][j]) {
                    x = 1;

                    while (j + x < m && A[i][j + x] == 0) {
                        x++;
                    }

                    for (int k = 0; k < x; k++) {
                        H[i][j + k] = x;
                    }
                }

                if (!V[i][j]) {
                    x = 1;

                    while (i + x < n && A[i + x][j] == 0) {
                        x++;
                    }

                    for (int k = 0; k < x; k++) {
                        V[i + k][j] = x;
                    }
                }

                ans = max(ans, H[i][j] + V[i][j] - 1);
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
typedef struct{
    ll from;
    ll to;
    ll cost;
} edge;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L;
    cin >> L;
    ll n = 0;
    rep(i,0,20){
        if(L < (1LL<<i)) break;
        n = i;
    }
    vector<edge> lp;
    rep(i,1,n+1){
        edge e1 = {i, i+1, 0};
        edge e2 = {i, i+1, (1<<(i-1))};
        lp.push_back(e1);
        lp.push_back(e2);
    }
    ll l = L;
    l -= (1<<n);
    ll t = n-1;
    ll num = L;
    while(l > 0){
        if(l >= (1<<t)){
            edge e = {t+1, n+1, L - l};
            l -= (1<<t);
            lp.push_back(e);
        }
        t--;
    }
    cout << n+1 << " " << lp.size() << endl;
    rep(i,0,lp.size()){
        cout << lp[i].from << " " << lp[i].to  << " " << lp[i].cost << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int A[15][15];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;
		for(int j=0;j<a;j++)
		{
			int x,y;cin>>x>>y;
			x--;
			A[i][x]=y==1?1:-1;
		}
	}
	int ans=0;
	for(int i=1;i<1<<N;i++)
	{
		int c[15]={};
		bool flag=true;
		for(int j=0;j<N;j++)
		{
			if(!(i>>j&1))continue;
			for(int k=0;k<N;k++)
			{
				if(A[j][k]==0)continue;
				if(c[k]==0)c[k]=A[j][k];
				else if(c[k]!=A[j][k])
				{
					flag=false;
				}
			}
		}
		for(int j=0;j<N;j++)
		{
			if((i>>j&1)&&c[j]==-1||!(i>>j&1)&&c[j]==1)flag=false;
		}
		if(flag)ans=max(ans,__builtin_popcount(i));
	}
	cout<<ans<<endl;
}


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

int main(void){
    vector<int> prime;
    prime.push_back(2);
    for(int i=3; i<= 1e5; i+=2){
        bool flag = true;
        for(int j=2; j<=sqrt(i); j++){
            if(i%j == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            prime.push_back(i);
        }
    }
    
    vector<int> like2017;
    for(int i=0; i<prime.size(); i++){
        if(lower_bound(prime.begin(), prime.end(), ((prime.at(i)+1)/2)) != upper_bound(prime.begin(), prime.end(), ((prime.at(i)+1)/2))){
            like2017.push_back(prime.at(i));
        }
    }

    int q;
    cin >> q;
    vector<int> ans(q);
    for(int i=0; i<q; i++){
        int l, r;
        cin >> l >> r;
        ans.at(i) = (upper_bound(like2017.begin(), like2017.end(), r) - lower_bound(like2017.begin(), like2017.end(), l));
    }

    for(int i=0; i<q; i++){
        cout << ans.at(i) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u
 
#include <stdio.h>
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int  tr['T'+1];
char f[33554432];
 
int main()
{
    int n, k, c;
 
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2992
# -*- coding: utf-8 -*-
import heapq as hq
def main():
    N,M = map(int,input().split())
    A=[-int(j) for j in input().split()]
    hq.heapify(A)
    for _ in range(M):
        tmp = hq.heappop(A)
        hq.heappush(A,(-((-tmp)//2)))
    print(-sum(A))
if __name__ == '__main__':
    main()

Measured memory_bytes: 14180
#include <stdio.h>

int main(){
    long long int h,w;
    scanf("%lld %lld",&h,&w);
    if(h==1||w==1){
        printf("%d\n",1);
    }else if(h%2==0||w%2==0) {
        printf("%lld\n",(h*w)/2);
    }else{
        printf("%lld\n",(h*w+1)/2);
    }
    return 0;
}

Measured memory_bytes: 128