akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

int main()
{
  int N, P[42], T[42];
  while(cin >> N, N) {
    P[0] = 0, T[0] = 0;
    for(int i = 1; i <= N; i++) {
      cin >> P[i] >> T[i];
    }
    P[++N] = 0, T[N++] = INF;

    int dp[2][4] = {{}};
    int *cur = dp[0], *nxt = dp[1];
    bool f = true;

    for(int i = 1; i < N; i++, swap(cur, nxt)) {
      nxt[0] = nxt[1] = nxt[2] = nxt[3] = INF;
      for(int j = 3; j > 0; j--) {
        if(T[i - 1] + (j + 1) * P[i - 1] + P[i] <= T[i])
          nxt[1] = min(nxt[1], cur[j] + P[i - 1] + P[i]);
        if(T[i - 1] + j * abs(P[i - 1] - P[i]) <= T[i])
          nxt[j] = min(nxt[j], cur[j - 1] + abs(P[i - 1] - P[i]));
      }
      if(*min_element(nxt, nxt + 4) == INF) {
        f = false;
        cout << "NG " << i << endl;
        break;
      }
    }
    if(f) {
      cout << "OK " << *min_element(cur, cur + 4) << endl;
    }
  }
}

Measured memory_bytes: 1156
K, N = map(int, input().split())
A=list(map(int, input().split()))
#A.sort()
#sub = []
mi=-1
m=-1
for i in range(N):
    if i==N-1:
        if m <= K+A[0]-A[i]:
            m=K+A[0]-A[i]
            mi=i
        #sub.append(N+A[0]-A[i])
    else:
        if m <= A[i+1]-A[i]:
            m=A[i+1]-A[i]
            mi=i
        #sub.append(A[i+1]-A[i])
if mi==N-1:
    print(A[-1]-A[0])
else:
    print(K-A[mi+1]+A[mi])

Measured memory_bytes: 33328
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,tag=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)tag+=a[i];
    cout<<tag;

}



Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num[] = new int[3];
        num[0] = sc.nextInt();
        num[1] = sc.nextInt();
        num[2] = sc.nextInt();

        Arrays.sort(num);

        System.out.printf("%d %d %d\n", num[0], num[1], num[2]);

    }
}


Measured memory_bytes: 26224
/*

#include<iostream>
//#include<array>
using namespace std;
int main(void){

int num_info;
cin >> num_info;

int house[4][3][10];

//house????????????
for (int k = 0; k < 4; k++){
for (int j = 0; j < 3; j++){
for (int i = 0; i < 10; i++){
house[k][j][i]=0;
}
}
}

for (int i = 0; i < num_info; i++){
int b, f, r, v;
cin >> b >> f >> r >> v;
house[b-1][f-1][r-1] += v;

}

for (int k = 0; k < 4; k++){
for (int j = 0; j < 3; j++){

for (int i = 0; i < 10; i++){
cout << house[k][j][i];
}

cout<<endl;
}

if (k == 3){ break; }
cout << "####################" << endl;
}
//system("pause");

return 0;
}
*/

#include <iostream>

using namespace std;

int main(void){
	int a[4][3][10] = { 0 };
	int n;
	int b, f, r, v;
	cin >> n;
	for (int x = 0; x < n; x++){
		cin >> b >> f >> r >> v;
		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 3; j++){
				for (int k = 0; k < 10; k++){
					if (i == b - 1 && j == f - 1 && k == r - 1){
						a[b-1][f-1][r-1] += v;
					}
				
				}
			
			}
		
		}
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i != 3)cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import math
import sys

n, m = map(int, input().split())
#print(n)
#print(m)

a = input().split()
l_si_i = [int(b) for b in a]
#print(l_si_i)

#print(max(l_si_i))
#print(sum(l_si_i))

#border = math.floor(sum(l_si_i) / (4 * m))
border = sum(l_si_i) / (4 * m)
#print(border)

check = 0
for i in range(n):
  if l_si_i[i] >= border:
    check += 1
    
  if check >= m:
    print("Yes")
    sys.exit()
    
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 52;
const int maxk = 102;
int v[maxn], f[maxn][maxn][maxk];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int t = 1; t <= k; ++t)
		for (int i = 1; i <= n; ++i)
			for (int j = i; j <= n; ++j)
				f[i][j][t] = INT_MIN;

	for (int t = 1; t <= k; ++t)
		for (int j = 1; j <= n; ++j)
			for (int i = j; i > 0; --i) {
				f[i][j][t] = f[i][j][t-1];
				if (t > 1)
					f[i][j][t] = max(f[i][j][t], max(f[i+1][j][t-2], f[i][j-1][t-2]));
				if (f[i+1][j][t-1] != INT_MIN)
					f[i][j][t] = max(f[i][j][t], f[i+1][j][t-1] + v[i]);
				if (f[i][j-1][t-1] != INT_MIN)
					f[i][j][t] = max(f[i][j][t], f[i][j-1][t-1] + v[j]);
			}

	cout << f[1][n][k] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		cout<<0<<endl;
	}
	else cout<<min(a*b,min(a*c,b*c))<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a[100], b[100];
	int i = 0;
	int max = 0;
	int maxbox = 0;
	char shop[] = { 'A','B','C','D','E' };

	while (1) {

		for (i = 0; i < 5; i++) {
			scanf("%d %d", &a[i], &b[i]);

			if (a[i] == 0 && b[i] == 0) {
				break;
			}
			if (i >= 1) {
				if (a[i] + b[i] > max) {
					max = a[i] + b[i];
					maxbox = i;
				}
			}
			else {
				max = a[i] + b[i];
				maxbox = i;
			}
		}
		if (a[i] == 0 && b[i] == 0) {
			break;
		}
		switch (maxbox) {
		case 0:
			printf("%c %d\n", shop[maxbox], max);
			break;
		case 1:
			printf("%c %d\n", shop[maxbox], max);
			break;
		case 2:
			printf("%c %d\n", shop[maxbox], max);
			break;
		case 3:
			printf("%c %d\n", shop[maxbox], max);
			break;
		case 4:
			printf("%c %d\n", shop[maxbox], max);
			break;
		default:
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 2652
import java.util.Scanner;

public class Main {

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

		sc.close();

		if ((double) D / T <= S) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

	}

}


Measured memory_bytes: 35684
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
#include <math.h>

int main() {
	int n;
	std::cin >> n;
	if (n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || n == 6 || n == 7 || n == 8 || n == 9 || n == 10 || n == 12 || n == 14 || n == 15 || n == 16 || n == 18 || n == 20 || n == 21 || n == 24 || n == 25 || n == 27 || n == 28 || n == 30 || n == 32 || n == 35 || n == 36 || n == 40 || n == 42 || n == 45 || n == 48 || n == 49 || n == 54 || n == 56 || n == 63 || n == 64 || n == 72 || n == 81) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
blst = [i for i in map(int, input().split())]
alst = []
for i in range(N):
    alst.append([j for j in map(int, input().split())])

ans = 0
for i in range(N):
    score = C
    for j in range(M):
        score += alst[i][j] * blst[j] 
    if score > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import deque

# BFS

def main():
    BLACK = 1
    WHITE = 0
    EDGE = 0
    WEIGHT = 1
    N = int(input())
    graph = [[] for i in range(N+1)]
    colors = [-1] * (N + 1)

    for i in range(N-1):
        u, v, w = map(int, input().split())
        graph[u].append((v, w))
        graph[v].append((u, w))

    q = deque()
    q.append(1)
    colors[1] = WHITE
    visited = [False] * (N + 1)
    visited[1] = True

    while len(q) != 0:
        n = q.popleft()

        for v, w in graph[n]:
            if visited[v]:
                continue

            if w % 2 == 0:
                colors[v] = colors[n]
            else:
                # print(~colors[n], colors[n])
                colors[v] = BLACK if colors[n] == WHITE else WHITE

            visited[v] = True
            q.append(v)

    for i in colors[1:]:
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75936
#include<stdio.h>
#include<math.h>

int main(){
  double a,b,c,cosC,sinC,S;
  scanf("%lf%lf%lf",&c,&b,&a);
  cosC=(a*a+b*b-c*c)/(2.0*a*b);
  sinC=sqrt(1.0-(cosC*cosC));
  S=a*b*sinC/2.0;
  printf("%d\n",(int)(S+0.5));
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N],vis[N];
int main()
{
    int n,x;scanf("%d%d",&n,&x);
    if(x==1||x==2*n-1){printf("No\n");return 0;}
    printf("Yes\n");
    if(n==2){printf("1\n2\n3\n");return 0;}
    if(x==2*n-2)a[n-1]=x-2,a[n]=x,a[n+1]=x+1,a[n+2]=x-1,vis[x-2]=1;
    else a[n-1]=x+2,a[n]=x,a[n+1]=x-1,a[n+2]=x+1,vis[x+2]=1;
    vis[x]=vis[x+1]=vis[x-1]=1;
    int k=1;
    for(int i=1;i<=2*n-1;i++)
    {
        if(a[i])continue;
        while(vis[k])k++;a[i]=k;vis[k]=1;
    }
    for(int i=1;i<=2*n-1;i++)printf("%d\n",a[i]);
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	int n,a[10005],b[10005];
	ll suma=0,sumb=0,temp=0,num=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
	scanf("%d",&a[i]);
	suma+=a[i];
    }
	for(int j=0;j<n;++j)
	{
	 scanf("%d",&b[j]);
	 sumb+=b[j];
    }
	for(int i=0;i<n;++i)
	{
		if(a[i]>=b[i])temp+=a[i]-b[i];
		else num+=(b[i]-a[i])/2;
	}
	if(suma+temp>sumb)puts("No");
	else if(num<temp)puts("No");
	else puts("Yes");
	return 0;
}

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

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

    int res = S.at(0) - '0';
    string ans = S.substr(0,1);
    // cout << ans << endl;
    for(int tmp=0; tmp<(1 << 3); tmp++){
        bitset<4> bit(tmp);
        for(int i=0; i<3; i++){
            if(bit.test(i)){
                res = res + S.at(i+1) - '0';
                ans = ans + "+" + S.substr(i+1, 1);
            }else{
                res = res - (S.at(i+1) - '0');
                ans = ans + "-" + S.substr(i+1, 1);
            }
        }
        // cout << "res = " << res << endl;
        // cout << ans << endl;
        if(res == 7){
            ans = ans + "=7";
            break;
        }else{
            res = S.at(0) - '0';
            ans = S.substr(0,1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	string S, T;
	cin >> S >> T;

	swap(S[0], S[2]);

	if (S==T) co("YES");
	else co("NO");
	Would you please return 0;
}

Measured memory_bytes: 764
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function root(par::Vector{Int},x::Int)
    index=par[x]
    while par[index]!=index
        index=par[index]
    end
    return index
end

function unite(par::Vector{Int},x::Int,y::Int)
    rx,ry=root(par,x),root(par,y)
    if rx==ry
        return
    elseif rx>ry
        rx,ry=ry,rx
    end
    par[ry]=rx
end

function same(par::Vector{Int},x::Int,y::Int)
    return root(par,x)==root(par,y)
end

function main()
    n,k,l=parseMap(split(readline()))
    road=[i for i in 1:n]
    rail=[i for i in 1:n]
    for i in 1:k
        p,q=parseMap(split(readline()))
        unite(road,p,q)
    end
    for i in 1:l
        r,s=parseMap(split(readline()))
        unite(rail,r,s)
    end
    ans=[0 for i in 1:n]
    cnt=Dict{Tuple{Int,Int},Int}()
    for i in 1:n
        rx,ry=root(road,i),root(rail,i)
        if haskey(cnt,(rx,ry))
            cnt[(rx,ry)]+=1
        else
            cnt[(rx,ry)]=1
        end
    end
    for i in 1:n
        rx,ry=root(road,i),root(rail,i)
        println(cnt[(rx,ry)])
    end
end
main()

Measured memory_bytes: 172688
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rreq(i,n) for(ll i = n;i >= 1;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1e9+7;
int main(void) {
    string s; cin >> s;
    int ans = s.size(),n = s.size();
    req(i, n - 1) {
        if (s[i-1] != s[i]) {
            ans = min(ans, max(i, n - i));
        }
    }cout << ans << endl;
}

Measured memory_bytes: 3776
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B = map(int, input().split())

print("Yes" if A * B % 2 == 1 else "No")

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

#define min(a, b) ((a) > (b) ? (b) : (a))

int main(void) {
  long count = 0;
  long N, A, B;
  scanf("%ld %ld %ld", &N, &A, &B);
  count = N / (A + B) * A + min(A, N % (A + B));
  printf("%ld\n", count);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
		    uft.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		    sc.nextInt();
		}
		System.out.print(uft.getCount());
	}
	
	static class UnionFindTree {
	    int[] parents;
	    
	    public UnionFindTree(int size) {
	        parents = new int[size];
	        for (int i = 0; i < size; i++) {
	            parents[i] = i;
	        }
	    }
	    
	    public int find(int x) {
	        if (parents[x] == x) {
	            return x;
	        } else {
	            return parents[x] = find(parents[x]);
	        }
	    }
	    
	    public void unite (int x, int y) {
	        int xx = find(x);
	        int yy = find(y);
	        if (xx == yy) {
	            return;
	        }
	        parents[xx] = yy;
        }

	    public int getCount() {
	        int count = 0;
	        for (int i = 0; i < parents.length; i++) {
	            if (parents[i] == i) {
	                count++;
	            }
	        }
	        return count;
	        
	    }
	}
}


Measured memory_bytes: 91680
function main()
	N,W=map(x->parse(Int,x),split(readline()))
	wa=-1
	V=[Int[] for _=1:4]
	for s=readlines()
		w,v=map(x->parse(Int,x),split(s))
		if wa<0
			wa=w
		end
		push!(V[w-wa+1],v)
	end
	S=[Int[] for _=1:4]
	for i=1:4
		sort!(V[i])
		reverse!(V[i])
		now=0
		push!(S[i],0);
		for v=V[i]
			now+=v
			push!(S[i],now);
		end
	end
	L=[length(V[i]) for i=1:4]
	ans=0
	for i1=0:L[1],i2=0:L[2],i3=0:L[3],i4=0:L[4]
		if i1*wa+i2*(wa+1)+i3*(wa+2)+i4*(wa+3)>W
			continue
		end
		ans=max(ans,S[1][i1+1]+S[2][i2+1]+S[3][i3+1]+S[4][i4+1])
	end
	println(ans)
end
main()


Measured memory_bytes: 155648
// OURL: https://atcoder.jp/contests/abc134/tasks/abc134_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int r;
	cin >> r;
cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<climits>

using namespace std;

int main (void) {
    int n, a, b;
    pair<int, int> min = {INT_MAX, 0}, max = {INT_MIN, 0};
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> a >> b;
        if (a < min.first) min = {a, b};
        if (a > max.first) max = {a, b};
    }
    cout << min.first + max.second + max.first - min.first << endl;
}

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

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

    int W;   //考えやすいように重さとする
    cin >> W;

    vector<int> weight;
    weight.emplace_back(1);
    for(int i = 6; i <= W; i *= 6){
        weight.emplace_back(i);
    }
    for(int i = 9; i <= W; i *= 9){
        weight.emplace_back(i);
    }
    sort(weight.begin(), weight.end());

    int n = (int)weight.size();

    vector<int> dp(W + 1, 1e9);
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int w = weight[i]; w <= W; w++){
            dp[w] = min(dp[w], dp[w - weight[i]] + 1);
            /*
            -考えたこと
            w = 1 全てのdp配列は1になる
            w = 6 dp[6]から更新していく。dp[6]は1に更新される（6円の一回で下せるから）
            w = 36 （29行目から）min(dp[36], d[30] + 1) dp[30]は5になってるので5 + 1に更新
            …というのを6, 9の累乗と1で埋めていく
            */
            //cout << weight[i] << " " << w << " " << dp[w] << endl;
        }
    }
    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 640
#!python3.8
# -*- coding: utf-8 -*-
# abc172/abc172_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    T = i2s()
    n = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            n += 1
    print(n)
    return

main()


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

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int board[1000][1000], sum[1001][1001], msum[1001][1001];

int main() {
    int N, K, x, y, dup = 0;
    char c;
    cin >> N >> K;
    REP(i, N) {
        cin >> x >> y >> c;
        int add = 1;
        if (c == 'B') add *= -1;
        if (x % (2 * K) >= K) add *= -1;
        if (y % (2 * K) >= K) add *= -1;
        x = x % K;
        y = y % K;
        if (board[y][x] * add < 0)
            dup++;
        board[y][x] += add;
    }
    REP(i, K) {
        int line_sum = 0;
        int line_msum = 0;
        REP(j, K) {
            if (board[i][j] > 0)
                line_sum += board[i][j];
            else
                line_msum += board[i][j];
            sum[i + 1][j + 1] = sum[i][j + 1] + line_sum;
            msum[i + 1][j + 1] = msum[i][j + 1] + line_msum;
        }
    }

    int ans = 0;
    REP(i, K) REP(j, K) {
        ans = max(ans, abs(sum[K][K] - sum[i][K] - sum[K][j] + 2 * sum[i][j] - msum[i][K] - msum[K][j] + 2 * msum[i][j]));
        ans = max(ans, abs(msum[K][K] - msum[i][K] - msum[K][j] + 2 * msum[i][j] - sum[i][K] - sum[K][j] + 2 * sum[i][j]));
    }
    cout << ans + dup << endl;

    return 0;
}

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

int main()
{
    string w;
    cin >> w;
    int maxr = 0;
    if (w == "RRR")
    {
        maxr = 3;
    }
    else if (w == "RRS" || w == "SRR")
    {
        maxr = 2;
    }
    else if (w == "SRS" || w == "RSR" || w == "SSR" || w == "RSS")
    {
        maxr = 1;
    }

    cout << maxr << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

main(){
	fastio;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W;
char F[111][111];
int D[111][111];

void MAIN() {
    scanf("%d%d", &H, &W);
    REP (i, H) scanf("%s", F[i]);

    memset(D, 0x3f, sizeof D);
    if (F[0][0] == '.') {
	D[0][0] = 0;
    } else {
	D[0][0] = 1;
    }

    REP (i, H) REP (j, W) {
	if (i) {
	    if (F[i-1][j] == '.' && F[i][j] == '#') {
		amin(D[i][j], D[i-1][j]+1);
	    } else {
		amin(D[i][j], D[i-1][j]);
	    }
	}
	if (j) {
	    if (F[i][j-1] == '.' && F[i][j] == '#') {
		amin(D[i][j], D[i][j-1]+1);
	    } else {
		amin(D[i][j], D[i][j-1]);
	    }
	}
    }

    int ans = D[H-1][W-1];
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int n = Integer.parseInt(W);

		W = in.readLine();
		String[] p = W.split(" ");

		int ans =0;
		for(int i=2;i<p.length;i++){
			if(Integer.parseInt(p[i-2]) < Integer.parseInt(p[i-1]) && Integer.parseInt(p[i-1]) < Integer.parseInt(p[i])){
				ans++;
			}else if(Integer.parseInt(p[i-2]) > Integer.parseInt(p[i-1]) && Integer.parseInt(p[i-1]) > Integer.parseInt(p[i])){
				ans++;
			}

		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 22612
#include<stdio.h>
#define N 100
#define INF 1<<21

int G[N][N],p[N],H[N],L[N];

int min(int c,int r){
  if(c<r) return c;
  else return r;
  
}


int main(){
  
  int x,i,j,l,a,b,c;
  
  scanf("%d",&x);
  
  for(i=1;i<=x;i++){
    G[i][i]=0;
  }
for(i=1;i<=x;i++){
scanf("%d%d",&H[i],&L[i]);
}

  

 p[0]=H[1];
 p[1] = L[1];

 for(i=2;i<=x;i++){
   p[i] = L[i];
 }
  
  for(i=2;i<=x;i++){
    for(j = 1;j<=x-i+1;j++){
      a=j+i-1;
      G[j][a] = INF;
      for(l = j;l<=a-1;l++){
	b = G[j][l] + G[l+1][a] + p[j-1]*p[l]*p[a];
	G[j][a] = min(G[j][a],b);
      }
    }
  }
      
  printf("%d\n",G[1][x]);


return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    cout << "2018";
    rep(i,4,s.length()) cout << s[i];
    cout << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main(void){
    
	int N, M;

    vector<int> p;
    vector<string> s;
    int ac_count = 0; //正答
    int penalty = 0;

    cin >> N >> M;
    for(int i = 1; i <= M; i++){
        int ptmp;
        string stmp;
        cin >> ptmp;
        cin >> stmp;
        p.push_back(ptmp);
        s.push_back(stmp);
    }
//input end

//　ペナルティ　→　ずっとWAの場合には加算されない
// 正答メモを作成
    int isac[N+1] = {false};
    int wa_count[N+1] = {0};
    for(int i = 0; i < M; i++){
        if(s[i] == "AC"){
            if(isac[p[i]] == false){
                isac[p[i]] = true;
                ac_count++;
                penalty += wa_count[p[i]];
            }
            else{
                //do nothing.
            }
        }
        else if(s[i] == "WA"){
            if(isac[p[i]] == false){
                wa_count[p[i]]++;
            }
            else{
                //do nothing.
            }
        }
    }

    cout << ac_count << " " << penalty << endl; 

    return 0;
}

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

int main()
{
    int n,c;
    unsigned b;
    scanf("%d",&n);
    c=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b);
        if(b%2!=0) c++;
    }
    if(c%2==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;


signed main(){
    cin >> n;
    map<string,int> d;
    REP(i,n){
        string s;
        cin >> s;
        if(s == "insert"){
            cin >> s;
            d.insert(make_pair(s,1));
        }
        else{
            cin >> s;
            auto it = d.find(s);
            (it==d.end())? print("no") : print("yes");
        }
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




Measured memory_bytes: 36444
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int type, a, b, Q;
multiset<int, greater<int> > maxh;
multiset<int, less<int> > minh;

long long maxh_sum = 0, minh_sum = 0;
long long B = 0;

void update_ds() {
  B += b;
  int maxh_sz = maxh.size();
  int minh_sz = minh.size();

  if(maxh_sz == 0) {
    maxh.insert(a);
    maxh_sum += a;
  } else if(maxh_sz == minh_sz) {
    auto it = maxh.begin();
    if(a <= *it) {
      maxh.insert(a);
      maxh_sum += a;
    } else {
      minh.insert(a);
      minh_sum += a;
      auto it = minh.begin();
      minh_sum -= *it;
      maxh_sum += *it;
      maxh.insert(*it);
      minh.erase(it);
    }
  } else {
    auto it = maxh.begin();
    if(a >= *it) {
      minh.insert(a);
      minh_sum += a;
    } else {
      maxh.insert(a);
      maxh_sum += a;
      auto it = maxh.begin();
      maxh_sum -= *it;
      minh_sum += *it;
      minh.insert(*it);
      maxh.erase(it);
    }
  }
}

long long find_answer() {
  long long maxh_sz = maxh.size();
  long long minh_sz = minh.size();
  long long val = *maxh.begin();
  //cout << "\n" << maxh_sum << ":" << minh_sum << ":" << val << endl;
  //cout << maxh_sz << "::" << endl;
  return (maxh_sz * val) - maxh_sum + minh_sum - (minh_sz * val) + B;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> Q;
  while(Q--) {
    cin >> type;
    if(type == 2) cout << *maxh.begin() << " " << find_answer() << endl;
    else {
      cin >> a >> b;
      update_ds();
    }
  }

  return 0;
}


Measured memory_bytes: 9600
while (n = gets.to_i) != 0
  oct = n.to_s(8)
  res = ""
  oct.chars.each do |x|
    x = x.to_i
    if x < 4
      res << x.to_s
    elsif x == 4
      res << '5'
    else
      res << (x+2).to_s
    end
  end
  puts res
end

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  vector<int> r(n);
  rep(i, n) r[p[i]-1] = i+1;
  vector<ll> a(n), b(n);
  rep(i, n) {
    a[i] = 30000*(i+1);
    b[i] = 30000*(n-i-1) + r[i];
  }
  line_out(a);
  line_out(b);
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
int a[200010];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=k;i<n;i++)
	{
		scanf("%d",&a[i]);
		puts((a[i]>a[i-k])?("Yes"):("No"));
	}
	return 0;
}

Measured memory_bytes: 4540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
ll gcd(ll a, ll b) { return (b > 0) ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a*b/gcd(a, b); }

using ipair = pair<ll, ll>;

int main()
{
  priority_queue<ipair, vector<ipair>, greater<ipair>> que;
  ll N, sum=0, d;
  cin >> N;
  rep(i, N){
    ll a;
    ll b;
    cin >> a >> b;
    que.push(make_pair(b, a));
  }
  ipair tmp;
  rep(i, N){
    tmp = que.top();
    tmp.first -= sum;
    d = tmp.first-tmp.second;
    if(d < 0){
      cout << "No" << "\n";
      return(0);
    }
    else{
      sum += tmp.second;
      que.pop();
    }
  }
  cout << "Yes" << "\n";
}


Measured memory_bytes: 6512
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

const ll MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}


long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(long long X, long long Y){
  COMinit();
  if(2*Y-X < 0 or (2*Y-X)%3!=0) {
    std::cout << 0 << std::endl;
    return;
  }
  ll A = (2*Y-X)/3;
  std::cout << COM(Y-A, A) << std::endl;

}

int main(){
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  solve(X, Y);
  return 0;
}



Measured memory_bytes: 119808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		Counter c1 = new Counter();
		Counter c2 = new Counter();
		int n = readNum();
		for (int i=0; i<n; i++) {
			String line = readLine();
			c1.add(line);
		}
		int m = readNum();
		for (int i=0; i<m; i++) {
			String line = readLine();
			c2.add(line);
		}
		int ans = 0;
		for (Object k : c1.keySet()) {
			int v1 = c1.get(k);
			int v2 = c2.get(k);
			ans = max(ans, v1 - v2);
		}
		pln(ans);
	}

	class Counter {
		Map<Object, Integer> map = new HashMap<>();

		void add(Object o) {
			Integer v = map.get(o);
			if (v == null) {
				map.put(o, 1);
			} else {
				map.put(o, v + 1);
			}
		}

		int get(Object o) {
			Integer v = map.get(o);
			if (v == null) {
				return 0;
			} else {
				return v;
			}
		}
		
		Set<Object> keySet() {
			return map.keySet();
		}
	}
	
	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21076
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int a,b,c,temp;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		if(a>b){temp=a;a=b;b=temp;}
		if(b>c){temp=b;b=c;c=temp;}
		if(a>b){temp=a;a=b;b=temp;}
		printf("%d\n",c-a);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
char box[8][8];
char search(const int i,const int j){
	if(box[i][j+1]=='1' && box[i+1][j]=='1' && box[i+1][j+1]=='1') return('A'); 
	else if(box[i+1][j]=='1' && box[i+2][j]=='1' && box[i+3][j]=='1') return('B') ;
	else if(box[i][j+1]=='1' && box[i][j+2]=='1' && box[i][j+3]=='1') return('C') ;
	else if(box[i+1][j]=='1' && box[i+1][j-1]=='1' && box[i+2][j-1]=='1') return('D');
	else if(box[i][j+1]=='1' && box[i+1][j+1]=='1' && box[i+1][j+2]=='1') return('E');
	else if(box[i+1][j]=='1' && box[i+1][j+1]=='1' && box[i+2][j+1]=='1') return('F');
	else if(box[i][j+1]=='1' && box[i+1][j]=='1' && box[i+1][j-1]=='1') return('G'); 
	else return('0');
}

int main(){
	while(cin>>box[0][0]){
		for(int i=1;i<8;i++) cin >> box[0][i] ;
	char ans='0';bool flag=false;
	for(int i=1;i<8;i++)
		for(int j=0;j<8;j++) cin >> box[i][j] ;
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			if(box[i][j]=='0') continue;
			if(ans=='0' && box[i][j]=='1') ans=search(i,j);
		};
	};
	cout << ans << '\n' ;
	};
}

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

#define MAX 1024

char *tolowerstr(char *s){
    int i;
    
    for(i = 0; s[i] != '\0'; ++i){
        s[i] = tolower(s[i]);
    }
    
    return s;
}

int main(){
    char w[MAX], t[MAX];
    int c = 0;
    
    scanf("%s", w);
    tolowerstr(w);
    
    while(scanf("%s", t), strcmp(t, "END_OF_TEXT") != 0){
        if(strcmp(w, tolowerstr(t)) == 0){
            ++c;
        }
    }
    
    printf("%d\n", c);
    
    return 0;
}


Measured memory_bytes: 2040
import sys
sys.setrecursionlimit(10**6)

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
readline = sys.stdin.readline
A = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 0

for a in A:
    if sum([i*j for i,j in zip(a,b)]) + c > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll h, w;
	cin >> h >> w;
	if(h == 1 || w == 1) { cout << 1 << endl; return 0; }
	cout << ((h+1)/2)*((w+1)/2) + (h/2)*(w/2) << endl;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<vector<int>>kuro(4*k, vector<int>(4*k, 0));
  for(int i=0; i<n; i++){
    int x, y;
    char c;
    cin >> x >> y >> c;
	if(c=='W')x+=k;
    kuro[x%(2*k)][y%(2*k)]++;
    kuro[x%(2*k)+2*k][y%(2*k)]++;
    kuro[x%(2*k)][y%(2*k)+2*k]++;
    kuro[x%(2*k)+2*k][y%(2*k)+2*k]++;
  }
  vector<vector<int>>kuror(4*k+1, vector<int>(4*k+1, 0));
  for(int i=1; i<=4*k; i++){
    for(int j=1; j<=4*k; j++){
      kuror[i][j]=kuror[i-1][j]+kuror[i][j-1]-kuror[i-1][j-1]+kuro[i-1][j-1];
    }
  }
  int ret=0;
  for(int x=0; x<2*k; x++){
    for(int y=0; y<k; y++){
      int s1, s2;
      s1 = kuror[x+k][y+k]-kuror[x][y+k]-kuror[x+k][y]+kuror[x][y];
      s2 = kuror[x+2*k][y+2*k]-kuror[x+k][y+2*k]-kuror[x+2*k][y+k]+kuror[x+k][y+k];
      ret = max(ret, s1+s2);
    }
  }
  cout << ret;
  return 0;
}

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

int main() {
    int N, K,sum;
    cin >> N;
    cin >> K;
    sum = 1;
    for(int i = 0; i < N;i++){
        if(sum * 2 < sum + K){
            sum = sum * 2;
        }
        else{
            sum = sum + K;
        }
        
    }

    cout << sum << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#define MOD 998244353
int a,b;
int x[3010];
long long int check[3010][3010];
long long int func(int s, int t)
{
	if(t>b) return 0;
	if(t==b) return (a-s+2);
	if(s>a) return 0;
	if(check[s][t]!=-1) return check[s][t];
	
	long long int s1 = func(s+1,t+x[s]);
	long long int s2 = func(s+1,t);
	return check[s][t] = (s1+s2)%MOD;
}
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=0;i<=a+1;i++) for(int j=0;j<=b;j++) check[i][j] = -1;
	
	long long int ans = 0;
	for(int i=1;i<=a;i++)
	{
		long long int s = func(i+1,x[i]);
		ans += (s*i)%MOD;
		ans %= MOD;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  vector<ll> x(n),y;
  rep(i,n){
  	cin>>x[i];
  }
  y=x;
  sort(all(x));
  rep(i,n){
  	if(x[n/2]>y[i]){
  		cout<<x[n/2]<<endl;
  	}else{
  		cout<<x[n/2-1]<<endl;
  	}
  }
  return 0;
}

Measured memory_bytes: 5376
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    long X = scan.nextLong();
    long K = scan.nextLong();
    long D = scan.nextLong();

    long ans = 0;
    long prevprev = 0;
    long prev = 0;
    long times = 0;
    if(X > 0){
      if(X/D < K) {
        K -= X/D;
        X = X - D * (X/D);
      } else {
        X = X - D*K;
        K = 0;
      }
    } else {
      if(-1*X/D < K) {
        K -= -1*X/D;
        X = X + D*(X/D);
      } else {
        X = X + D*K;
        K = 0;
      }
    }

    while(K > 0) {
      if(X > 0) {
        X -= D;
      } else {
        X += D;
      }
      K--;
      times++;
      if(times == 1)
        prevprev = X;
      else if(times == 2)
        prev = X;

      if(times >= 3) {
        if((X > 0 && prev <= 0 && prevprev >0) || (X <=0 && prev > 0 && prevprev <= 0)) {
          if(K % 2 == 1){
            if(X > 0) {
              X -= D;
            } else {
              X += D;
            }
          }
          break;
        }


        prevprev = prev;
        prev = X;
      }
    }

    os.println(Math.abs(X));
  }
}


Measured memory_bytes: 27140
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int gcd(int a, int b)
{
	int temp;

	while (b != 0)
	{
		a %= b;

		temp = a;
		a = b;
		b = temp;
	}

	return a;
}

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

	scanf("%d %d %d", &a, &b, &c);

	printf("%d\n", a*b<c?a*b:c);

	return 0;
}

Measured memory_bytes: 128