akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
int a[N],p[N],n;
set<int> s;
ll ans;

int main(){
	read(n);
	rep(i,1,n){
		read(a[i]);
		p[i]=i;
	}
	sort(p+1,p+n+1,[&](int x,int y){
		return a[x]<a[y];
	});
	s.insert(0);
	s.insert(n+1);
	rep(i,1,n){
		auto it=s.lower_bound(p[i]);
		auto pre=it;pre--;
		ans+=(ll)a[p[i]]*(*it-p[i])*(p[i]-*pre);
		s.insert(p[i]);
	}
	cout<<ans<<endl;

	return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    cin >> n;
    int a[n + 1] = {2, 1};
    REP(i, 2, n + 1)
    {
        a[i] = a[i - 1] + a[i - 2];
    }
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


const int N = 1e5+5;

vector<pii> v[N];
int ans[N];

void dfs(int at,int p=0,int lst=0)
{
	int ptr=1;
	tr(v[at],it)
	{
		int id=it->ss,to=it->ff;
		if(to==p)continue;
		if(ptr==lst)ptr++;
		ans[id]=ptr;
		dfs(to,at,ptr);
		ptr++;
	}
}

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,0,n-2)
{
	int a,b;
	cin>>a>>b;
	v[a].pb(mp(b,i));
	v[b].pb(mp(a,i));
}
dfs(1);
int mx=0;
rep(i,0,n-2)mx=max(mx,ans[i]);
ol(mx);on;
rep(i,0,n-2)
{
	ol(ans[i]);on;
}
return 0;
}



Measured memory_bytes: 9344
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    if ( a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

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

    auto count = 0;
    for (int i = a; i < b + 1; ++i){
        if (c % i == 0) ++count;
    }

    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(int argc, char **argv){
	int m,f,r;
	int mf;
	char *result;

	for(;;){
		// Input
		scanf("%d %d %d", &m, &f, &r);
		// Finish Check
		if( m == -1 && f == -1 && r == -1){
			break;
		}
		// Judge and Output
		if( m == -1 || f == -1 ){
			result = "F";
		} else {
			mf = m + f;
			if( mf >= 80 ){
				result = "A";
			} else if( mf >= 65 ){
				result = "B";
			} else if( mf >= 50 ){
				result = "C";
			} else if( mf >= 30 ){
				if( r >= 50 ){
					result = "C";
				} else {
					result = "D";
				}
			} else {
				result = "F";
			}
		}
		// Output
		printf("%s\n",result);
	}

	return 0;
}

Measured memory_bytes: 584
N = int(input())

AC=0
WA=0
TLE=0
RE=0

for i in range(N):
    S = input()
    if S == "AC":
        AC+=1
    elif S == "WA":
        WA+=1
    elif S == "TLE":
        TLE +=1
    else:
        RE +=1

print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 9200
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

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

using namespace std;
using namespace __gnu_pbds;

// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
#define cad static_cast<long double>
#define deb(z) cout << "// " << #z << " = " << z << endl;
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;



int32_t main() {
	ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s, t, u;
	int a, b;
	cin >> s>> t>> a>> b>> u;
	if(u==s) {
		cout << a-1<<' '<<b << endl;
	} else 
	cout << a<< ' '<<b-1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long sum=a+b;
        if(sum%2==0) {
            long ans = sum/2;
            System.out.println(ans);
        }
        else
            System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 20948
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n );
	int a[n], b[n], c[n-1];
  int ans=0;
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	  for(int i=0;i<n;i++){
		scanf("%d", &b[i]);
      	ans += b[i];
	}
  for(int i=0;i<n-1;i++){
		scanf("%d", &c[i]);
	}

	for(int i=1;i<n;i++){
      if(a[i]-a[i-1]==1)	ans+=c[a[i-1]-1];
    }
	printf("%d", ans);

	return 0;
	
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] hw = new char[h][w];
        for (int i = 0; i < h; i++) {
            hw[i] = sc.next().toCharArray();

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

        boolean isSuccess = true;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (hw[i][j] == '.') continue;
                isSuccess = true;
                for (int k = 0; k < 4; k++) {

                    int ni = i + dx[k];
                    int nj = j + dy[k];
                    if (ni < 0 || h <= ni) continue;
                    if (nj < 0 || w <= nj) continue;
                    if (hw[ni][nj] == '#') {
                        isSuccess = true;
                        break;
                    } else {
                        isSuccess = false;

                    }
                }

                if (!isSuccess) {
                    break;
                }
            }
            if (!isSuccess) {
                break;
            }
        }

        if (isSuccess) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main(){
	int h, w;
	cin >> h >> w;
	string s;
	int count[52][52] = {{0}};
	for(int i=0; i < h; i++) {
		cin >> s;
		for(int j=0; j < w; j++) {
			if(s.at(j) != '#')
				continue;
			count[i+1][j+1] = -10;
			for(int k=-1; k <= 1; k++) {
				for(int l=-1; l <= 1; l++) {
					count[i+k+1][j+l+1]++;
				}
			}
		}
	}

	for(int i=1; i <= h; i++) {
		for(int j=1; j <= w; j++) {
			if(count[i][j] < 0)
				cout << '#';
			else
				cout << count[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
 
int main(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	while(n){
		n/=m;ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
string S;
  cin>>S; 
  int N=S.size();
  vector<char>a(N);vector<char>b(N);vector<char>c((N-1)/2);vector<char>d((N-1)/2);
  vector<char>e(N+1-(N+3)/2); vector<char>f(N+1-(N+3)/2);
  rep(i,N){a.at(i)=S.at(i); b.at(i)=S.at(i);}
  rep(i,(N-1)/2){c.at(i)=S.at(i); d.at(i)=S.at(i);}
  Rep(i,(N+3)/2-1,N){e.at(i-(N+3)/2+1)=S.at(i); f.at(i-(N+3)/2+1)=S.at(i);}
  reverse(b.begin(),b.end());
  reverse(d.begin(),d.end());
  reverse(f.begin(),f.end());
  string M;
if(a==b&&c==d&&e==f){M="Yes";}
  else{M="No";}
  cout<<M<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a==0&&b==0) {break;}
			if(a<b) {System.out.println(a+" "+b);}
			else if(b<=a) {System.out.println(b+" "+a);}
		}
	}
}



Measured memory_bytes: 35328
from collections import Counter

def main()->None:
    N = int(input())
    range_N = range(N)
    A = [int(input()) for _ in range_N]

    count_A = Counter(A)

    res = []
    for a in count_A.keys():
        count = count_A[a]
        if count % 2 == 1:
            res.append(a)
    print(len(res))








if __name__ == "__main__":
    main()

Measured memory_bytes: 16640
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

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

int main() {
    ll x;
    cin >> x;
    rep(i, 152) {
        ll a = 1, b = 1;
        rep(p, 5)a *= i;
        rep(j, 151) {
            b = 1;
            rep(q, 5)b *= j;
            if (a - b == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
            if (a + b == x) {
                cout << i << ' ' << -j << endl;
                return 0;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	vector<pii>s(N), l(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		s[i] = make_pair(b, a);
	}
	for (int i = 0; i < N; ++i) {
		int c, d;
		cin >> c >> d;
		l[i] = make_pair(c, d);
	}
	for (int i = 0; i < N; ++i) {
		sort(l.begin(), l.end());
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < l.size(); ++j) {
			sort(s.begin(), s.end(), greater<pii>());
		}
		for (int j = 0; j < s.size(); ++j) {
			if (s[j].second < l[i].first && s[j].first < l[i].second) {
				ans++;
				s.erase(s.begin() + j);
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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



#define NODE_NUM 100
#define MAX_VALUE 10000000

int weight[NODE_NUM][NODE_NUM];


/*
 * ??°??????????????????vertex_idx???????§??????¨???????????????????????????????????¢????±???????
 * ??°?????????????????????????????°???vertex_num
 * ??????distance[i][j]???????????????i???????????????j?????????????????¢???????´??????????
 */
void WarshallFloyd(int vertex_idx, int vertex_num){
    int i,j,k;
    
    for (k=0;k < vertex_num; k++) {
        for (i=0; i < vertex_num; i++) {
            for (j=0; j < vertex_num; j++) {
                if (weight[i][j] > weight[i][k] + weight[k][j]) {
                    weight[i][j] = weight[i][k] + weight[k][j];
                }
            }
        }
    }
}


int main( ){
    
    int i, j, k, v, c, u, n;
    
    scanf("%d", &n);
    
    for (i=0; i<NODE_NUM; i++) {
        for (j=0; j < NODE_NUM; j++) {
            weight[i][j] = MAX_VALUE;
            if (i==j) {
                weight[i][j] = 0;
            }
            
        }
    }
    
    for (i=0; i<n; i++){
        
        scanf("%d", &u);
        scanf("%d", &k);
        
        for (j = 0; j < k; j++) {
            scanf("%d %d", &v, &c);
            weight[u][v] = c;
        }
    }
    
    WarshallFloyd(0, n);
    
    for (i=0; i< n; i++) {
        printf("%d %d\n", i, weight[0][i]);
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,m,fac[1000010],mul,ans=0;

LL fastpow(LL x,LL a)
{
	LL res=x,ret=1;
	while(a>0)
	{
		if((a&1)==1) ret=ret*res%MOD;
		a>>=1;
		res=res*res%MOD;
	}
	return ret;
}

LL C(LL nn,LL mm)
{
	return fac[nn]*fastpow(fac[mm],MOD-2)%MOD*fastpow(fac[nn-mm],MOD-2)%MOD;
}

LL A(LL nn,LL mm)
{
	return fac[nn]*fastpow(fac[nn-mm],MOD-2)%MOD;
}

int main()
{
	cin>>n>>m;
	fac[0]=1;
	repn(i,1000005) fac[i]=fac[i-1]*i%MOD;
	mul=A(m,n);
	rep(i,n+1)
	{
		LL tmp=C(n,i)*A(m-i,n-i)%MOD;
		if(i%2==0) ans=(ans+tmp)%MOD;
		else ans=(ans-tmp+MOD)%MOD;
	}
	cout<<ans*mul%MOD<<endl;
	return 0;
}

Measured memory_bytes: 11428
n,k=map(int,input().split());h=list(map(int,input().split()))
dp=[10**9]*n;dp[0]=0
for i in range(1,n):
  kk=max(0,i-k)
  for j in range(kk,i):dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]))
print(dp[-1])

Measured memory_bytes: 52448
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    int N;
    cin >> N;
    vector<LLONG> As(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> As[i];
    }
    LLONG sum = accumulate(As.begin(), As.end(), 0LL);
    int border = 0;
    LLONG left = 0;
    for (border = 0; border < N; ++border)
    {
        left += As[border];
        if (left >= sum - left)
        {
            break;
        }
    }
    LLONG diff1 = left - (sum - left);
    left -= As[border];
    LLONG diff2 = (sum - left) - left;
    cout << min(diff1, diff2) << endl;
}


Measured memory_bytes: 1792
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

A,B = inpl()

if A%3==0 or B%3==0 or (A+B)%3==0:
	print('Possible')
else:
	print('Impossible')


Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll n , M = 1e9 + 7;
ll a[300005];

ll power ( ll x , ll y ){
    ll res = 1;
    while ( y > 0 ){
        if ( y & 1 )
            res = ( res * x ) % M;
        x = ( x * x ) % M;
        y /= 2;
    }
    return res;
}

ll sumXOR() { 
    ll sum = 0 , i , j; 
    for ( i = 0; i < 60; i++)  { 
        ll zero = 0, one = 0;  
        ll Sum = 0;  
        for ( j = 0; j < n; j++) { 
            if (a[j] % 2 == 0) 
                zero++; 
            else
                one++; 
            a[j] /= 2; 
        } 
        Sum = ( ( one * zero )%M * power(2,i) )%M ;  
        sum = ( sum + Sum ) % M;  
    } 
    return sum; 
}

int main(){
    FAST;
    ll ans = 0, k, m, j = 0, t = 1, x = 0, y = 0, c = 0, i, z = 0;
    cin >> n ;
    for ( i = 0 ; i < n ; i ++ ){
        cin >> a[i];
    }
    cout << sumXOR() ;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

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

A = 0
B = 0
if n%2 == 0:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
else:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
    A += max(a)

print(A-B)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n, m;
    cin >> n >> m;
    vector <pair <ll, ll>> p(n);
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    sort(p.begin(), p.end());

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(m <= 0){
            cout << ans << endl;
            return 0;
        }else if(p[i].second < m){
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        }else if(p[i].second >= m){
            ans += m * p[i].first;
            m = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
hList = list(map(int, input().split()))

ans = 0
cou = 0

hList = [0] + hList

for i in range(N):
    if hList[i] < hList[i+1]:
        cou += (hList[i+1] - hList[i])
    else:
        ans += cou
        cou = 0
ans += cou
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZU {
	class Program {
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }

		static void Main(string[] args) {
			List<string> J = new List<string>();
			string s;
			while (true) {
				s = Console.ReadLine();
				if (string.IsNullOrEmpty(s))
					break;
				J.Add(s);
			}
			Console.WriteLine(J.Count(i=>Palindrome(i)));
		}

		static bool Palindrome(string s) {
			return s==new string(s.Reverse().ToArray());
		}
	}
}

Measured memory_bytes: 9436
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<ll, ll> P;
#define fs first
#define sc second

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

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

    double a[N];
    for(int i = 0; i < N; i++){
        a[i] = (double)(p[i] + 1) / 2.0;
    }

    double sum[N + 1];
    sum[0] = 0;
    for(int i = 0; i < N; i++){
        sum[i + 1] = sum[i] + a[i];
    }

    double ans = 0;
    for(int i = 0; i <= N - K; i++){
        ans = max(ans, sum[i + K] - sum[i]);
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

int main(){
  ll N = 0;
  string S;
  cin >> N >> S;
  rep(i,S.size()){
    char x = S[i];
    int check = x;
    if(check + N > 90){
      x = S[i]+N-26;
      cout << x;
    }
    else{
      x = S[i] + N;
      cout << x;
    }
  }
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

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

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
def f(x):
    a=0
    for i in range(x+1):
        a+=A[i]
    for i in range(x+1,N):
        if 2*a<A[i]:
            return False
        a+=A[i]
    return True
if f(0):
    print(N)
    exit()
mi=0
ma=N-1
while ma-mi>1:
    mid=(ma+mi)//2
    if f(mid):
        ma=mid
    else:
        mi=mid
print(N-mi-1)

Measured memory_bytes: 63856
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
#include <climits>
using namespace std;
vector<int> ans;

struct edge {
	int u, v;
	int w;
	edge() {}
	edge(int _u, int _v) :
		u(_u), v(_v) {}
};

struct node {
	int id; vector<edge> edges;
};

struct graph {
	vector<node> nodes;
	vector<int> dist;
	int n;

	graph(int _n) : n(_n) { nodes.resize(n); dist.resize(n, 0); }

	void add_edge(int u, int v) {
		edge e1(u, v); nodes[u].edges.push_back(e1);
		edge e2(v, u); nodes[v].edges.push_back(e2);
	}

	void bfs(int start) {
		vector<bool> visited(n, 0); 
		queue<int> q; q.push(start); visited[start] = 1;
		dist[start] = 0;
		while (!q.empty()) {
			int cur = q.front(); q.pop();
			for (auto &e : nodes[cur].edges) {
				if (visited[e.v]) { continue; }
				visited[e.v] = 1; q.push(e.v);
				dist[e.v] = dist[e.u] + 1;
				ans[dist[e.v]]++;
			}
		}
	}
};

int main() {
	int N; cin >> N;
	graph g(N);
	for (int i = 1; i < N; i++) {
		g.add_edge(i - 1, i);
	}
	int X, Y; cin >> X >> Y; X--; Y--;
	g.add_edge(X, Y);
	ans.resize(N, 0);
	for (int i = 0; i < N; i++) {
		g.bfs(i);
	}

	for (int i = 1; i < N; i++) {
		cout << ans[i]/2 << endl;
	}
}

Measured memory_bytes: 384
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input


drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6
while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=4):
        # print(ope)
        tmp_board = copy.deepcopy(board)
        for color in itertools.chain(ope, (C - 1,)):
            now_c = tmp_board[0][0]
            if now_c == color:
                continue

            tmp_board[0][0] = color
            stack = [(0, 0)]
            while stack:
                r, c = stack.pop()
                for dr, dc in drc:
                    nr, nc = r + dr, c + dc
                    if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
                        tmp_board[nr][nc] = color
                        stack.append((nr, nc))
        tmp_board[0][0] = -1
        stack = [(0, 0)]
        while stack:
            r, c = stack.pop()
            for dr, dc in drc:
                nr, nc = r + dr, c + dc
                if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == C - 1:
                    tmp_board[nr][nc] = -1
                    stack.append((nr, nc))
        ans = max(ans, sum(row.count(-1) for row in tmp_board))
    print(ans)

Measured memory_bytes: 6628
#include <iostream>

using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int N ;
int Q ;
string S;


int main(){
	cin >> N >> Q >> S;
	int l,r;
	int ans[N+1]={};
	ans[0] =0;
	/*REP(i,N){
		ans[i+1] = ans[i];
		if((S[i+1] =='C' ) and (S[i] ='A')){
			ans[i+1] ++;
		}
		
	}*/
	for (int i = 0; i < N ; i++) {
		ans[i + 1] = ans[i];
		if (S[i] == 'A' && S[i + 1] == 'C') {
			ans[i + 1]++;
		}
	}
	
	REP(i,Q){
		cin >> l >> r;
		cout << ans[r-1] -ans[l-1]<< endl;
		
	}
	

	return 0;
}

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

int main(void) {
    ll n;
    cin >> n;
    
    const int sqn = sqrt(n);
    vector<ll> p;
    vector<int> pn(sqn+2, 0);
    for (int i = 2; i <= sqn; ++i) {
        if (n % i == 0) {
            while (n % i == 0) {
                pn[p.size()]++;
                n /= i;
            }
            p.push_back(i);
        }
    }
    if (n > 1) {
        pn[p.size()]++;
        p.push_back(n);
    }

    int cnt = 0;
    rep(i,p.size()) {
        int d = 1;
        while (pn[i] >= d) {
            pn[i] -= d;
            cnt++;
            d++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 7108
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define F(x) for(int i=1;i<=(x);i++)
#define fer(i,n) for(int i=1;i<=(n);i++)
#define FIN  {freopen("1.in","r",stdin);}
#define FOUT {freopen("1.out","w",stdout);}
#define OUT(x)  {cout<<"#x"<<" : "<<x<<endl;}
#define ERR(x)  {cout<<"#error:"<<x;while(1);}
typedef long long ll;
typedef unsigned long long ull;
#define se second
#define fi first
#define make_pair mkp
#define mid ((l+r)>>1)
const int MaxInt = -1u>>1;
const int Max_ = 0x3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1);
using namespace std;
inline int read()
{
    char ch=getchar();int f=1,g=0;
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isdigit(ch);ch=getchar()) g=g*10+(ch^48);
    return g*f;
}
const int N = 205;
int n,m;
int a[N];
int main()
{
    n=read();
    F(n*2) a[i]=read();
    sort(a+1,a+1+2*n);
    int ans=0;
    F(n) ans+=a[i*2-1];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    _s = list(input())
    _s.sort()
    s.append("".join(_s))
s.sort()
c = 0
ans = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        c += 1
    else:
        ans += (c * (c + 1) // 2)
        c = 0
ans += (c * (c + 1) // 2)
print(ans)


Measured memory_bytes: 10664
// B - 81
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	rp(i, 1, 10){
		rp(j, i, 10){
			if(i*j == N){
				cout<< "Yes" <<endl;
				return 0;
			}
		}
	}
	cout<< "No" <<endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  string s;
  cin >> s;
  int count = 0;

  rep(i,s.length()){
    if(s[i]=='+')count++;
    else count--;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)

memo=a.each_with_object({}){|i,m| m[i]||=0;m[i]+=1}

all_sum = memo.map{|_,x| x*(x-1)/2}.reduce(:+)

a.each{|i|
    x = memo[i]
    print all_sum - x*(x-1)/2 + (x-1)*(x-2)/2 ,"\n"
}


Measured memory_bytes: 29700
A, B, K = map(int, input().split())

if A >= K :
    A = A - K
    B = B
elif A < K :
    if B >= K - A :
        B = B - (K - A)
    elif B < K -A :
        B = 0
    A = 0

print('%d %d' % (A, B))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int cont;
int m,n,l[100000];
int dp[1000000];
main()
{
    cin>>m;
    for(int i=1;i<=m;i++){
        cin>>l[i];
    }
    dp[1]=0;
    dp[2]=abs(l[1]-l[2]);
    for(int i=3;i<=m;i++){
        dp[i]=min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i]-l[i-1]));
    }
   // cout<<dp[1]<<" "<<dp[3]<<" "<<dp[5]<<" ";
    cout<<dp[m];

}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<int> a(n);
  int ans = 0;
  for(int i=0;i<n;++i) {
    cin >> a[i];
    a[i] %= 2;
    ans |= a[i];
  }
  
  cout << (ans ? "first" : "second") << endl;
}


Measured memory_bytes: 640
/*
ID: jerrywcy
TASK: AtCoder ABC 103 Problem A
LINK: https://abc103.contest.atcoder.jp/tasks/abc103_a
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int a1,a2,a3;

int maxv(int x,int y,int z){
	if (x>y)y=x;
	if (y>z)z=y;
	return z; 
}

int minv(int x,int y,int z){
	if (x<y)y=x;
	if (y<z)z=y;
	return z; 
}

int main()
{
	cin>>a1>>a2>>a3;
	cout<<maxv(a1,a2,a3)-minv(a1,a2,a3)<<endl;

	return 0;
}



Measured memory_bytes: 256
(r,c) = [int(i) for i in input().split()]
 
table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])
 
table.append([0 for _ in range(c + 1)])
 
for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]
 
    table[rc].append(row_total)
    table[r][c] += row_total
 
for row in table:
    print(' '.join([str(column) for column in row]))

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

int main() {
	ll n;
	cin >> n;
	ll ans = 1000000;
	for (int i = 1; i <= n / 2; i++) {
		ll a = i;
		ll b = n - a;
		ll res = 0;
		while (a > 0) {
			res += a % 10;
			a /= 10;
		}
		while (b > 0) {
			res += b % 10;
			b /= 10;
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b; cin >> n >> a >> b;
	for(int i = 0; i < 10000000; i++){
		if(a + 1 <= n && a + 1 != b) a++;
		else if(a - 1 >= 1) a--;
		else return !printf("Borys\n");
		if(b - 1 >= 1 && b - 1 != a) b--;
		else if(b + 1 <= n) b++;
		else return !printf("Alice\n");
	}
	assert(0);
	return 0;
}


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

int main() {
	int n, x, step;
	cin >> n >> x;
	int* d = new int[n + 2];
	int* l = new int[n + 1];
	d[1] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> l[i];
		d[i + 1] = d[i] + l[i];
	}
	for (step = 1; step < n + 2; step++) {
		if (d[step] > x) break;
	}
	cout << step - 1 << endl;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    string S;cin>>S;
    ll ans=0;
    char AT[4]={'A','C','G','T'};
    REP(i,S.size()){
        ll cnt=0;
        FOR(j,i,S.size()){
            bool ok=false;
            REP(k,4){
                if(S[j]==AT[k])ok=true;
            }
            if(!ok){
                break;
            }
            cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a > b) swap(a, b);
	if(a < c and c < b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define THIRTEEN 13
#define MOD 1000000007

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

    string S;
    cin >> S;

    // count[i][j] : Sが左からi桁目まで読まれた時、13で割った余りがjである組み合わせの数(をMODで割ったやつ)
    long count[S.size() + 1][THIRTEEN] = {0};
    count[0][0] = 1;

    for (int i = 1; i < S.size() + 1; i++) {
        if (S[i - 1] == '?') {
            for (int m = 0; m < 10; m++) {
                for (int j = 0; j < THIRTEEN; j++) {
                    int idx = (j * 10 + m) % THIRTEEN;
                    count[i][idx] = (count[i][idx] + count[i - 1][j]) % MOD;
                }
            }
        } else {
            int m = S[i - 1] - '0';
            for (int j = 0; j < THIRTEEN; j++) {
                int idx = (j * 10 + m) % THIRTEEN;
                count[i][idx] = (count[i][idx] + count[i - 1][j]) % MOD;
            }
        }
    }

    cout << count[S.size()][5] << "\n";

    return 0;
}


Measured memory_bytes: 10604
#include <iostream>

using namespace std;

struct Dice
{
    int lable1;
    int lable2;
    int lable3;
    int lable4;
    int lable5;
    int lable6;
};

struct Dice num;

void mN(Dice &num)
{
    int tmp = num.lable1;
    num.lable1 = num.lable2;
    num.lable2 = num.lable6;
    num.lable6 = num.lable5;
    num.lable5 = tmp;
    
    return ;
}

void mS(Dice &num)
{
    int tmp = num.lable1;
    num.lable1 = num.lable5;
    num.lable5 = num.lable6;
    num.lable6 = num.lable2;
    num.lable2 = tmp;
    
    return ;
}
    
void mE(Dice &num)
{
    int tmp = num.lable1;
    num.lable1 = num.lable4;
    num.lable4 = num.lable6;
    num.lable6 = num.lable3;
    num.lable3 = tmp;
    
    return ;
}

void mW(Dice &num)
{
    int tmp = num.lable1;
    num.lable1 = num.lable3;
    num.lable3 = num.lable6;
    num.lable6 = num.lable4;
    num.lable4 = tmp;
    
    return ;
}

void mSpin(Dice &num)
{
    int tmp = num.lable2;
    num.lable2 = num.lable4;
    num.lable4 = num.lable5;
    num.lable5 = num.lable3;
    num.lable3 = tmp;
    
    return ;
}

int main()
{
    int cnt = 0;
    int a = 0;
    int b = 0;
    
    cin >> num.lable1 >> num.lable2 >> num.lable3 >> num.lable4 >> num.lable5 >> num.lable6;
    cin >> cnt;
    for (int i = 0; i < cnt; i++)
    {
        cin >> a >> b;
        Dice res = num;
        
        if ((a == res.lable3) || (a == res.lable4))
        {
            mW(res);
        }
        
        while (a != res.lable1)
        {
            mS(res);
        }
        
        while (b != res.lable2)
        {
            mSpin(res);
        }
        
        cout << res.lable3 << endl;
    }
    
    return 0;
}



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

using namespace std;
int b[101];
int a[101];
int main()
{
    int n;
    int s=0;
    scanf("%d",&n);
    for (int i=0;i<n-1;i++) {
        scanf("%d",&b[i]);
    }
    int t=1;
    a[0]=b[0];
    for (int i=0;i<n-1;i++) {
        if (b[i]<=b[i+1]) {
            a[i+1]=b[i];
        }
        else {
            a[i+1]=b[i+1];
        }
    }
    a[n-1]=b[n-2];
    for (int i=0;i<n;i++) {
        s+=a[i];
    }
    printf("%d",s);
}

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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll cnt=0;
	string s,t;
	cin>>s>>t;
	lp(i,0,s.size()-1)
		if(s[i]!=t[i])
			cnt++;
	cout<<cnt<<endl;
	return 0;	
}


Measured memory_bytes: 3796
s = raw_input()
ans = len(s)
for i in range(len(s)):
    mx = i
    p = i
    q = i+1
    while q < len(s):
        if s[p] == s[q]:
            mx = max(q-p-1, mx)
            p = q
        q += 1
    mx = max(q-p-1, mx)
    ans = min(mx, ans)
print ans


Measured memory_bytes: 2568
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, Q, S[int(1e5 + 5)], T;

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", S + i);
  sort(S, S + N);

  scanf("%d", &Q);
  int ans = 0;
  for (int i = 0; i < Q; i++){
    scanf("%d", &T);
    int L = 0, R = N;
    while (R - L > 1){
      int now = (L + R) / 2;
      if (S[now] <= T) L = now;
      else R = now;
    }
    if (S[L] == T) ans++;
  }
  cout << ans << endl;

  return 0;
}



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

using namespace std;

typedef long double ld;
typedef long long ll;

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  ll i, o, t, j, l, s, z;
  cin >> i >> o >> t >> j >> l >> s >> z;

  ll ans = 0;

  for (int k = 0; k < 2; ++k) {
    ll cur = 0;
    bool no = false;
    for (ll x : {i, l, j}) {
      if (x == 0) {
        no = true;
      } else {
        cur += 2 * ((x - k) / 2);
      }
    }

    if (!no)
      cur += k * 3;

    ans = max(ans, cur);
  }

  ans += o;

  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
                int n=int_v(read());
                int[] a=int_arr();
                long[][] dp=new long[n+1][4];
                dp[0][0]=1000l;
                for(int i=1;i<=n;i++){
                    dp[i][2]=dp[i-1][3]+(long)a[i-1]*dp[i-1][1];//sell all
                    dp[i][0]=Math.max(dp[i-1][2],dp[i-1][0]);// doing nothing
                    long max=Math.max(dp[i][0],dp[i][2]);
                    dp[i][1]= max/a[i-1];//buy all
                    dp[i][3]=max-(long)dp[i][1]*a[i-1];
                }
                out.write(Math.max(dp[n][0],dp[n][2])+"");
                out.flush();

    }
}


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

int main() {
	int N, H;
	cin >> N;
	int total = 1;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> H;
		vec.at(i) = H;
	}
	for (int j = 1; j < N; j++) {
		for (int k = 0; k < j; k++) {
			if (vec.at(k) <= vec.at(j) && k == j - 1) {
				total++;
			}
			else if (vec.at(k) <= vec.at(j) && k < j - 1) {
				continue;
			}
			else {
				break;
			}
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3608
S = str(input())

A = ['Yes','No']
k = 0
glist = ['R','U','D']
klist = ['L','U','D']

for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'L':
            k = 1
            break
    else:
        if S[i] == 'R':
            k = 1
            break

print(A[k])


Measured memory_bytes: 3060
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_dict = {}
for i in a:
    if i in cnt_dict:
        cnt_dict[i] += 1
    else:
        cnt_dict[i] = 1
cnt_dict_sorted = sorted(cnt_dict.items(), key=lambda x: x[1])
ans = 0
if len(cnt_dict_sorted) <= k:
    ans = 0
else:
    tmp = len(cnt_dict_sorted) - k
    for j in range(tmp):
        ans += cnt_dict_sorted[j][1]
print(ans)


Measured memory_bytes: 38964
#include <bits/stdc++.h>
using namespace std;
int n,i;
long long int a[200001],x,y,sum=0;
int main(void)
{
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		y+=a[i];
	}
	x=a[0];
	y-=a[0];
	sum=llabs(x-y);
	for(i=1;i<n-1;i++){
		x+=a[i];
		y-=a[i];
		if(llabs(x-y)<sum)sum=llabs(x-y);	
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 998244353;
const int N = 2e5 + 5;

int f[N], finv[N];

int add(initializer_list<int> list) {
    int res = 0;
    for (int x: list)
        res = (res + x) % MOD;
    return res;
}

int mul(initializer_list<int> list) {
    int res = 1;
    for (int x: list)
        res = (1LL * res * x) % MOD;
    return res;
}

int C(int n, int r) {
    if (n < 0 or r < 0 or n < r) return 0;
    return mul({f[n], finv[r], finv[n - r]});
}

int pow_mod(int a, int b, int m = MOD) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = 1LL * res * a % m;
        a = 1LL * a * a % m;
        b >>= 1;
    }
    return res;
}

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

    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = f[i - 1] * i % MOD;
    }

    finv[N - 1] = pow_mod(f[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) {
        finv[i] = finv[i + 1] * (i + 1) % MOD;
    }

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

    int ans = 0;
    for (int r = 1; r <= n - k - 1; r++) {
        ans += mul({C(n - 1, r - 1), m, pow_mod(m - 1, r - 1)});
        ans %= MOD;
    }

    ans = pow_mod(m, n) - ans + MOD;
    cout << ans % MOD;
}

Measured memory_bytes: 6772
#include <cstdio>

int main()
{
	int a, b;
	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;

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

			for(int j = 0; j < b; j++){

				if((i % 2) == 0){
					if((j % 2) == 0) printf("#");
					else printf(".");
				}
				else {
					if((j % 2) == 0) printf(".");
					else printf("#");
				}

			}

			printf("\n");
		}

		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000