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

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;
typedef pair <int, int> pii;

typedef map <int, int> mii;

typedef set <llong> sl;

const int MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;}

int n;
int ok[2][26];

string s;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> n;
    cin >> s;
    int mx = 0;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < 26; j ++) ok[0][j] = ok[1][j] = 0;
        for (int j = 0; j <= i; j ++) {
            ok[0][s[j] - 'a'] = 1;
        }
        for (int j = i + 1; j < n; j ++) {
            ok[1][s[j] - 'a'] = 1;
        }
        int ans = 0;
        for (int j = 0; j < 26; j ++) {
            if (ok[0][j] == ok[1][j] && ok[1][j] == 1) ans ++;
        }
        mx = max (mx, ans);
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;

}


Measured memory_bytes: 256
// ABC082B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

std::vector<int> parse(int inp) {
  std::vector<int> out(4);
  for(auto &x : out) {
    x = inp % 10;
    inp /= 10;
  }
  std::reverse(out.begin(), out.end());
  return out;
}

class Op
{
public:
  int id;
  Op(int inp_id) {
    id = inp_id > 0 ? 1 : 0;
  }

  Op(){
    id = 0;
  }

  static std::string get_p(Op p) {
    if(p.id == 0) return "+";
    return "-";
  }

  int act(int left, int right) {
    if(id == 0) return left + right;
    return left - right;
  }
};

  std::ostream& operator<< (std::ostream& os, const Op& o) {
    os << Op::get_p(o.id);
    return os;
  }

bool check_seven(std::vector<int> a, std::vector<Op> o) {
  int sum = a[0];
  for(int i = 0; i < 3; i++) {
    sum = o[i].act(sum , a[i + 1]);
  }
  return sum == 7;
}

void parse_op(int pattern, std::vector<Op> &op) {
  for(int i = 0; i < 3; i++) {
    op[i].id = (pattern & (1 << i)) ? 1 : 0;
  }
}

int main(void) {
  int inp;
  std::cin >> inp;
  std::vector<int> abcd = parse(inp);
  std::vector<Op> op(3);

  for(int i = 0;i < 8; i++) {
    parse_op(i, op);
    if(check_seven(abcd, op)) break;
  }

  for(int i = 0; i < 3; i++) {
    std::cout << abcd[i] << op[i];
  }
  std::cout << abcd[3] << "=7" << std::endl;
  return 0;
}


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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b}) << endl;
  return (0);
}


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

int n;
int h[100010];
int dp[100010];

int chmin(int a, int b)
{
	if (a > b)
		return b;
	return a;
}

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		dp[i] = 100000;
		scanf("%d", h+i);
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = chmin(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	printf("%d", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 896
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Deque<Integer> stack = new ArrayDeque<Integer>();
  Scanner in = new Scanner(System.in);
  while (in.hasNext()) {
	int car = in.nextInt();
	if (car == 0) {
	  System.out.println(stack.removeFirst());
	} else {
	  stack.addFirst(car);
	}
  }
}

}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[210000];

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

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    scanf("%s", s);

    vector<int> cnt[2];
    cnt[0] = cnt[1] = vector<int>(n);
    vector<vector<int>> g(n);

    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
      cnt[s[a] - 'A'][b]++;
      cnt[s[b] - 'A'][a]++;
    }

    vector<int> bad;
    vector<bool> is_bad(n);
    for (int i = 0; i < n; i++) {
      if (!cnt[0][i] || !cnt[1][i]) {
        bad.push_back(i);
        is_bad[i] = true;
      }
    }

    for (int i = 0; i < (int)bad.size(); i++) {
      int v = bad[i];
      assert(is_bad[v]);
      for (int u : g[v]) {
        cnt[s[v] - 'A'][u]--;
        if (cnt[s[v] - 'A'][u] == 0 && !is_bad[u]) {
          is_bad[u] = true;
          bad.push_back(u);
        }
      }
    }

    static const char* answers[2] = {"Yes", "No"};

    printf("%s\n", answers[(int)bad.size() == n]);
  }

  return 0;
}


Measured memory_bytes: 12924
round,house_num = map(int,input().split())

distance = list(map(int,input().split()))

min = distance[-1] - distance[0]

for i in range(house_num - 1):
  if round-(distance[i+1]-distance[i]) < min:
    min = round-(distance[i+1]-distance[i])
print(min)

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(all(A));
  int ans_n, ans_r;
  ans_n = A.back();
  vector<pair<int, int>> diff(n);
  for (int i = 0; i < n; i++) {
    diff[i].first = abs(A[i] - (ans_n / 2));
    if (n % 2 == 1) diff[i].first += abs(A[i] - ((ans_n + 1) / 2));
    diff[i].second = A[i];
  }
  sort(all(diff));
  ans_r = diff.front().second;
  cout << ans_n << ' ' << ans_r << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

int n,a[100001],cnt[2][100001];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);

	for(int i=0;i<n;i++) cnt[i%2][a[i]]++;

	int m1=0,m2=0,i1=0,i2=0;
	for(int i=0;i<=100000;i++) {
		if(m1<cnt[0][i]) {
			i2=i1;
			i1=i;
			m2=m1;
			m1=cnt[0][i];
		} else if(m2<cnt[0][i]) {
			i2=i;
			m2=cnt[0][i];
		}
	}

	int ans=n;
	for(int i=1;i<=100000;i++) {
		if(i1==i) {
			ans=min(ans, n-m2-cnt[1][i]);
		} else ans = min(ans, n-m1-cnt[1][i]);
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			if (m == 0) {
				break;
			}
			Graph g = new Graph(10);
			boolean[] use = new boolean[10];
			for(int i=0;i<m;i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				use[a] = use[b] = true;
				g.addEdge(a, b, c);
				g.addEdge(b, a, c);
			}
			int minindex = -1;
			int ans = Integer.MAX_VALUE;
			for(int i=0;i<10;i++) {
				if(!use[i]) {
					continue;
				}
				int[] dist = g.dijkstra(i);
				int sum = 0;
				for(int j=0;j<10;j++) {
					if (use[j]) {
						sum+=dist[j];
					}
				}
				if (sum < ans) {
					minindex = i;
					ans = sum;
				}
			}
			System.out.println(minindex + " " + ans);
		}
	}

}

class Graph {
	public static final int INF = 1<<29;
	int n;
	ArrayList<Edge>[] graph;
	
	@SuppressWarnings("unchecked")
	public Graph(int n) {
		this.n = n;
		this.graph = new ArrayList[n];
		for(int i=0;i<n;i++) {
			graph[i] = new ArrayList<Edge>();
		}
	}
	public void addEdge(int from,int to,int cost) {
		graph[from].add(new Edge(to, cost));
	}
	public int[] dijkstra(int s) {
		int[] dist = new int[n];
		Arrays.fill(dist, INF);
		dist[s] = 0;
		PriorityQueue<Node> q = new PriorityQueue<Node>();
		q.add(new Node(0, s));
		while(!q.isEmpty()) {
			Node node = q.poll();
			int v = node.id;
			if (dist[v] < node.dist) {
				continue;
			}
			for(Edge e:graph[v]) {
				if (dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					q.add(new Node(dist[e.to], e.to));
				}
			}
		}
		return dist;
	}
	class Edge {
		int to;
		int cost;
		public Edge(int to,int cost) {
			this.to = to;
			this.cost = cost;
		}
	}
	class Node implements Comparable<Node>{
		int dist;
		int id;
		public Node(int dist,int i) {
			this.dist = dist;
			this.id = i;
		}
		public int compareTo(Node o) {
			return (this.dist < o.dist) ? -1 : ((this.dist == o.dist) ? 0 : 1);
		}
	}
}

Measured memory_bytes: 19944
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    ll r,g,b,ans=0;
    for(r=0;r<=N/R;r++){
        for(g=0;g<=N/G;g++){
            b=(N-R*r-G*g)/B;
            if(r*R+g*G+b*B==N&&b>=0)ans++;
        }
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;

using namespace std;

bool is_integer(float x){
    return floor(x) == x;
}

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

    for (int x = 1; x <= 50000; x++){
        if((int)floor(x * 1.08) == n){
            cout << x << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>

#define MAX 100000

typedef unsigned long long ULL;

using namespace std;

int main(){
    int N,Q;
    int i;
    ULL *count;
    ULL sum;
    int A,B,C;

    cin >> N;
    count = new ULL[MAX];
    sum = 0;
    for(i=0;i<MAX;i++){
        count[i] = 0;
    }
    for(i=0;i<N;i++){
        cin >> A;
        count[A-1]++;
        sum += A;
    }
    cin >> Q;
    for(i=0;i<Q;i++){
        cin >> B >> C;
        sum += count[B-1] * (C - B);
        count[C-1] += count[B-1];
        count[B-1] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
const int N = 8 + 10;
string s[N];
int n, m, mark[N][N];
int dx[] = {1, 0}, dy[] = {0, 1};
bool isval(int x, int y) {
	if (x >= 0 && y >= 0 && x < n && y < m && s[x][y] == '#') 
		return true;
	return false;
}
void dfs(int x, int y) {
	mark[x][y] = 1;
	for (int i = 0; i < 2; i++) {
		if (isval(x + dx[i], y + dy[i])) {
			dfs(x + dx[i], y + dy[i]);
			return;
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	dfs(0, 0);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#' && !mark[i][j]) {
				cout << "Impossible";
				return 0;
			}		
		}
	cout << "Possible";
	return 0;
}	


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

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

  for (int i = 1; i < s.length(); i++) {
    if (s[i - 1] != s[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
int n,m;
vector<int> g[100010];
int num[100010];
int par[100010];
 
int main(void){
    cin>>n>>m;
    for(int i=0;i<n+m-1;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
        num[y]++;
    }
    queue<int>qu;
    for(int i=0;i<n;i++){
        if(num[i]==0)qu.push(i);
        par[i]=-1;
    }
    while(qu.size()>0){
        int now=qu.front();
        qu.pop();
        for(int i=0;i<(int)g[now].size();i++){
            int next=g[now][i];
            num[next]--;
            if(num[next]==0){
                par[next]=now;
                qu.push(next);
            }
        }
    }
    for(int i=0;i<n;i++)cout<<par[i]+1<<endl;
    return 0;
}

Measured memory_bytes: 7040
#include<iostream>
 
using namespace std;
 
int main(){
  long long int a;
  long long int b;  
  cin >> a >>b;
  
  if(a+b == 15)
    cout << '+'<< endl;
  else if(a*b == 15)
    cout << '*' <<endl;
  else
    cout << 'x' <<endl;
  
  return 0; 
}

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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s,t;
  cin >> s >> t;
  bool ret = false;
  int idx = -1;
  REP(i, s.size()-t.size()+1) {
    bool flag = true;
    REP(j, t.size()) {
      if(s[i+j] == '?' || s[i+j] == t[j]) continue;
      flag = false;
      break;
    }
    if(flag) ret = true, idx = i;
  }
  if(!ret) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  REP(i, t.size()) {
    if(s[i+idx] == '?') s[i+idx] = t[i];
  }
  REP(i, s.size()) {
    if(s[i] == '?') s[i] = 'a';
  }
  cout << s << endl;

  return 0;
}

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

using namespace std;

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

    uint32_t a;
    for (a = 0; a < s.size(); a++) {
        if (s[a] == 'A') break;
    }

    uint32_t z;
    for (z = s.size(); z > 0; z--) {
        if (s[z] == 'Z') break;
    }

    cout << z - a + 1 << endl;
}


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

S = []
T = []
for i in range(N):
    s,t = input().split()
    S.append(s)
    T.append(int(t))
X = input()
id = S.index(X)
ans = 0
for i in range(id+1,N):
    ans += T[i]
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
BC = [list(map(int, input().split(" "))) for _ in range(M)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

i = 0
for b, c in BC:
    for j in range(b):
        A[i] = max(A[i], c)
        i += 1
        if i >= N:
            print(sum(A))
            exit()

print(sum(A))

Measured memory_bytes: 32980
#include<bits/stdc++.h>
#define gc getchar()
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int 
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return  w*s;}
struct node{
	int to,next;
}e[1000010];
int h[1000100],tot;
int X[1000010];
int N;int vis[10000010],prime[1000010],cnt;
int pos1[1000010],num1,pos2[1000010],num2;
int v[660],lk[1010];
inline void add(int from,int to){e[++tot].next=h[from];h[from]=tot;e[tot].to=to;}
inline void Init(int n)
{	vis[1]=1;
	for(rint i=2;i<=n;++i)
	{
		if(!vis[i]) prime[++cnt]=i;
		for(rint j=1;j<=cnt&&prime[j]*i<=n;++j)
		{
			vis[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}vis[2]=1;
}
unordered_map<int,int> mp;
inline void ADD(int x)
{
	if(x&1) pos1[++num1]=x;
	else    pos2[++num2]=x;
}
inline bool DFS(int now)
{
	for(rint i=h[now];i;i=e[i].next)
	{
		int to=e[i].to;
		if(!v[to])
		{
			v[to]=1;
			if(!lk[to]||DFS(lk[to]))
			{
				lk[to]=now;
				return 1;
			}
		}
	}return 0;
}
int main()
{	N=read();
	for(rint i=1;i<=N;++i) X[i]=read(),mp[X[i]]=1;
	Init(1e7);
	for(rint i=1;i<=N;++i)
	{	
		int las=X[i]-1;
		int nxt=X[i]+1;
		if(mp[las]!=mp[X[i]]) ADD(X[i]);
		if(mp[nxt]!=mp[X[i]]) ADD(nxt);
	}
//	for(rint i=1;i<=num1;++i) cout<<pos1[i]<<" ";
//	for(rint i=1;i<=num2;++i) cout<<pos2[i]<<" ";
	for(rint i=1;i<=num1;++i)
	{
		for(rint j=1;j<=num2;++j)
		{
			if(!vis[abs(pos1[i]-pos2[j])])
			{
				add(i,j);
			}
		}
	}int cnt=0;
	for(rint i=1;i<=num1;++i) {memset(v,0,sizeof(v));if(DFS(i)) cnt++;}
	int x=num1-cnt,y=num2-cnt;
	int ans=cnt+(x/2)*2+(y/2)*2+(x&1)*3;
	cout<<ans;
	return 0;
}
/*
by was_n
18.9.25
*/


Measured memory_bytes: 51584
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD2 1000000007
#define MOD 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

string s;
Int k;
Int dp[330][330][330][2];
Int ans;

int main()
{
    cin >> s >> k;
    Int n = s.size();
    dp[0][0][0][0] = 1;
    dp[0][0][0][1] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int l = 0; l <= n; l++) {
                if (s[i] == '0') {
                    (dp[i + 1][j + 1][l][0] += dp[i][j][l][0]) %= MOD; // 0 0
                    (dp[i + 1][j + 1][l][1] += dp[i][j][l][0]) %= MOD; // 0 0
                    (dp[i][j + 1][l][0] += dp[i][j][l][1]) %= MOD;     // 0 1
                    (dp[i][j + 1][l][1] += dp[i][j][l][1]) %= MOD;     // 0 1
                }
                if (s[i] == '1') {
                    (dp[i + 1][j + 1][l][0] += dp[i][j][l][1]) %= MOD; // 1 1
                    (dp[i + 1][j + 1][l][1] += dp[i][j][l][1]) %= MOD; // 1 1
                    if (i < j)
                        (dp[i + 1][j][l + 1][0] += dp[i][j][l][0]) %=
                            MOD; // 1 0
                }
                //                cout << i << " " << j << " " << k << " " <<
                //                dp[i][j][k] << endl;
            }
        }
    }
    for (int i = 0; i <= min(k, n - 1); i++) {
        //        cout << i << " " << dp[n][n][i] << endl;
        (ans += dp[n][n][i][0]) %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 471344
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a=0,f,r,v,n,x=0,y=0,i,j,m;
    cin>>n>>m;
    int A[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    int b[1000];
    for(i=0;i<1000;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            a+=b[j]*A[i][j];
        }
        
        cout<<a<<endl;
        
        a=0;
    }
}



Measured memory_bytes: 3100
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := "No"
    s = SortString(s)
    if s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]{
        ans = "Yes"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

void solve()
{
	int S;
	cin >> S;
	int h = S / 3600;
	S %= 3600;
	int m = S / 60;
	S %= 60;
	int s = S;
	cout << h << ":" << m << ":" << s << endl;
}

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//const ll mx=1e5;
//bool prime[100009];
//void seive()
//{
//    prime[1]=true;
//    for(int i=2;i*i<=mx;i++){
//        if(prime[i]==false){
//            for(int j=i*i;j<=mx;j+=i) prime[j]=true;
//        }
//    }
//}
int main(){
	ll n;
	cin>>n;
	vector<ll>v;
	for(ll i=1;i*1ll*i<=n;i++){
        if(n%i==0){
            v.push_back(i);
            if(i*i!=n)v.push_back(n/i);
        }
	}
	sort(v.begin(),v.end());
	ll sum=0;
	for(auto x:v){
        ll p=n/x-1;
        if(p!=0 && (n/p==n%p))sum+=p;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define vout(i,n,v) for(int i=0;i<(int)n-1;i++){cout<<v[i]<<" ";}cout<<v[n-1]<<"\n";
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define VSORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, std::vector<long long> a){
    RSORT(a);
    ll ans=0, Alice=0, Bob=0;
    for (ll i = 0; i < N; i++) {
        i%2 ? Bob+=a[i] : Alice+=a[i];
    }
    cout << Alice - Bob << "\n";
    // vout(i,N,a);
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;

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

  vector<size_t> L;
  for (size_t i = 0; i < N; i++) {
    size_t l;
    cin >> l;
    L.emplace_back(l);
  }
  sort(L.begin(), L.end());

  size_t sum = 0;
  for (size_t i = 0; i < N - 2; i++) {
    for (size_t j = i + 1; j < N - 1; j++) {
      for (size_t k = j + 1; k < N; k++) {
        if (L[i] + L[j] > L[k]) {
          sum++;
        }
      }
    }
  }
  cout << sum << endl;

  return 0;
}


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

using namespace std;

typedef long long int lint;

vector<string> ss;

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

    string line;
    for(int i=0; i<n; i++){
        cin >> line;
        ss.push_back(line);
    }

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

    for(int i=0; i<ss.size(); i++){
        cout << ss[i];
    }










    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long A, long long B){
  std::cout << min(A*N, B) << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(N, A, B);
  return 0;
}


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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back

const int INF  = 1000000007;

int r,n;
map<int,int> bill;
bool input(){
	cin>>r>>n;
	if(r==0 && n==0)return false;
	
	bill.clear();
	reps(i,-20,20+1){
		bill[i] = 0;
	}
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		
		reps(i,a,b)bill[i]=max(bill[i],c);
	}
	
	return true;
}


double check(int x, int h){
	if(abs(x)>=r)return INF;
	
	double t = h + r - sqrt(r*r-x*x);
	return t;
}

void solve(){
	
	double ans = INF;
	for(map<int,int>::iterator it = bill.begin(); it!=bill.end(); it++){
		int x = it->first;
		int h = it->second;
		
		ans = min(ans, check(x,h));
		ans = min(ans, check(x+1,h));
	}
	
	printf("%.9lf\n",ans);
}

int main(){
	
	while(input())solve();
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll n, m, h[250000], a[150000], b[150000], r;
vector<int> g[250000];

int main() {
  cin >> n >> m;
  rep(i, n) {
    cin >> h[i];
  }
  rep(i, m) {
    cin >> a[i] >> b[i];

    g[a[i] - 1].push_back(b[i] - 1);
    g[b[i] - 1].push_back(a[i] - 1);
  }
  rep(i, n) {
    ll mx = 0;
    rep(j, g[i].size()) {
      mx = max(mx, h[g[i][j]]);
    }
    if (mx < h[i]) {
      r++;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 14616
<?php
$n = trim(fgets(STDIN));
$arr = explode(" ", trim(fgets(STDIN)));

$count = 0;
for($i=1; $i<$n-1; $i++){
    $check = [];
    $check = [$arr[$i-1], $arr[$i], $arr[$i+1]];
    sort($check);
    if($arr[$i] == $check[1]){
        $count++;
    }
}
echo $count;
?>

Measured memory_bytes: 3700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACirclePond solver = new ACirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACirclePond {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int r = s.nextInt();
            out.println(2 * 3.14159 * r);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
  vector<int> P(3);
  for(int i=0;i<3;i++){
    cin >>P.at(i);
  }
  sort(P.begin(),P.end());
  
  cout <<P.at(0)+P.at(1) <<endl;
  return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
  int n; cin >> n;
  string x; cin >> x;
  int k = 0;
  rep(i,n){
    if(x[i] == '1') k++;
  }
  if(k == 1){
    if(x[n-1] == '0'){
      rep(i,n-1){
        if(x[i] =='1'){
          cout << 0 << endl;
        }
        else cout << 1 << endl;
      }
      cout << 2 << endl;
    }
    else{
      rep(i,n-1){
        cout << 2 << endl;
      }
      cout << 0 << endl;
    }
    return 0;
  }
  int now = 0;
  int now2 = 0;
  rep(i,n){
    if(x[i] == '1'){
      now += modpow(2,n-i-1,k+1);
      now %= k+1;
      now2 += modpow(2,n-i-1,k-1);
      now2 %= k-1;
    }
  }
  rep(i,n){
    if(x[i] == '1'){
      int t = now2;
      t -= modpow(2,n-i-1,k-1);
      t %= k-1;
      if(t < 0) t += k-1;
      int ans = 1;
      while(t){
        int s = __builtin_popcount(t);
        t = t%s;
        ans++;
      }
      cout << ans << endl;
    }
    else{
      int t = now;
      t += modpow(2,n-i-1,k+1);
      t %= k+1;
      int ans = 1;
      while(t){
        int s = __builtin_popcount(t);
        t = t%s;
        ans++;
      }
      cout << ans << endl;
    }
  }

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    int cnt = 0;
    FORO(i, M) cin >> B[i];
    FORO(i, N) {
        vector<int> A(M);
        int score = C;
        FORO(j, M) {
            cin >> A[j];
            score += A[j] * B[j];
        }
        if(score > 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int gcd(ull a,ull b){
  if(b > 0) return gcd(b, a % b);
  else return a;
}

int main(){
  ull a,b,c;
	while(cin >> a >> b){
	  c = gcd(a,b);
	  cout << c << " " << (ull)((a * b)/c) << endl; 
	}
  return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	int p[100001];
	for (int i = 0; i < n; ++i) cin >> p[i];
	int ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (i + 1 != p[i]) continue;
		++ans;
		p[i] ^= p[i + 1];
		p[i + 1] ^= p[i];
		p[i] ^= p[i + 1];
	}
	if (p[n - 1] == n) cout << ans + 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
//#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
const int N = 101;
const int W = 1e5 + 10;
int dp[N][W];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , w;
cin>>n>>w;
pi arr[n];
for(int i = 0 ; i < n; i++){
  cin>>arr[i].f>>arr[i].s;
}
for(int i= 0 ; i <= n ;i++){
  dp[i][0] = 0;
}
for(int i =  1 ; i <= w ; i++){
      for(int j = 1 ; j <= n ; j++){
		   dp[j][i] = dp[j-1][i];
			if(i-arr[j-1].f >= 0){
				  dp[j][i] = max(dp[j][i] , arr[j-1].s + dp[j-1][i-arr[j-1].f]); 
			}
	  }
}
cout<<dp[n][w]<<endl;
}



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

ll yakusuu(ll n){
    if(n==1) return 0;
    ll ans=1;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            if(i*i!=n) ans+=2;
            else ans++;
        }
    }
    return ans;
}
int main(void){
    ll n;
    cin>>n;
    ll ans=yakusuu(n-1)+1;
    for(ll k=2;k*k<=n;k++){
        if(n%k==0){
            ll z=n;
            while(z%k==0){
                z/=k;
            }
            if(z%k==1){
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
O = input()
O_2 = list(O)
OLEN = len(O)

E = input()
E_2 = list(E)
ELEN = len(E)

ans = []

if ELEN >= OLEN:
    N = ELEN
else:
    N = OLEN



if OLEN == ELEN:
    for i in range(N):
        ans.append(O_2[i])
        ans.append(E_2[i])

elif OLEN  != ELEN:
    
    for i in range(N):
        if len(ans) == ((OLEN) + (ELEN) -1):
            if OLEN > ELEN:
                ans.append(O_2[-1])
            else:
                ans.append(E_2[-1])
            break
        ans.append(O_2[i])
        ans.append(E_2[i])


for i in ans:
  print(i,end="")

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

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

    l = N.size();
    vector<int> n(l);
    rep(i,l) n[i] = N.at(i) - '0';

    vector<vector<Int>> dp0(l+1,vector<Int>(K+1, 0)), dp1(l+1,vector<Int>(K+1, 0));

    dp0[1][1] = n[0] - 1;
    dp1[1][1] = 1;
    dp0[1][0] = 1;

    rep1(i,l-1) rep(j,K+1) {
        if (n[i] != 0) {
            if (j > 0) dp0[i+1][j] = 9 * dp0[i][j-1] + dp0[i][j] + dp1[i][j-1] * (n[i] - 1) + dp1[i][j];
            else dp0[i+1][j] = dp0[i][j] + dp1[i][j];
        }
        else {
            if (j > 0) dp0[i+1][j] = 9 * dp0[i][j-1] + dp0[i][j];
            else dp0[i+1][j] = dp0[i][j];
        }

        if (n[i] != 0) {
            if (j > 0) dp1[i+1][j] = dp1[i][j-1];
        }
        else dp1[i+1][j] = dp1[i][j];

    }

    cout << dp0[l][K] + dp1[l][K] << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,type=0;
  int64_t ans=1,mod=1e9+7;
  vector<string> s(2);
  cin>>n>>s.at(0)>>s.at(1);
  for(i=0;i<n;i++){
    if(s.at(0).at(i)==s.at(1).at(i)){
      if(type==0) ans=ans*3%mod;
      else if(type==1) ans=ans*2%mod;
      type=1;
    }
    else if(i<n-1&&s.at(0).at(i)==s.at(0).at(i+1)){
      if(type==0) ans=ans*6%mod;
      else if(type==1) ans=ans*2%mod;
      else if(type==2) ans=ans*3%mod;
      type=2;
      i++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, j = 0, s = 0;
    cin >> n;
    int p[n], d[n];
    for (int i = 0; i < n; i++) d[i] = 0;
    for (int i = 0; i < n; i++) 
    {
        cin >> p[i];
        if (p[i] == i + 1) d[j]++;
        else j++;
    }
    for (int i = 0; i < n; i++)
        s = s + (d[i] + 1) / 2;
    cout << s;
}

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

using namespace std;

long long prime = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n >> t;
    int inf = numeric_limits<int>::max();
    int smallest_cost = inf;
    for (int i = 0; i < n; ++i) {
        int c_i, t_i;
        cin >> c_i >> t_i;
        if (t_i <= t) {
            smallest_cost = min(smallest_cost, c_i);
        }
    }
    if (smallest_cost == inf) {
        cout << "TLE" << endl;
    } else {
        cout << smallest_cost << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])
    v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])
    
    if v0[-1][0] != v1[-1][0]:
        print(n-v0[-1][1]-v1[-1][1])
    else:
        if len(v0) == 1 and len(v1) == 1:
            print(n//2)
        else:
            a = (v0[-1][1] + v1[-2][1]) if len(v1) > 1 else 0
            b = (v0[-2][1] + v1[-1][1]) if len(v0) > 1 else 0
            print(n - max(a, b))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 25252
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    ll ans = 0;

    if(n<k) {
        cout << 0 << endl;
        return 0;
    }

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

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

    for (int j = 0; j < k; ++j) {
        h[n-1-j] = 0;
    }
    for (int l = 0; l < n - k; ++l) {
        ans += h[l];
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1792
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0

for i in range(n):
    if i == 0:
        ans = ans + B[A[i]-1]
#        print(ans)
    else:
        ans = ans + B[A[i]-1]
        if A[i]-A[i-1] == 1:
            ans = ans + C[A[i]-2]
#        print(ans)

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;

	void doIt() {
		double L = (double)sc.nextInt();
		L /= 3;
		System.out.println(L * L * L);
	}

	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 20692
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Char

step m x = MP.insertWith (+) x 1 m

step' acc k v
    | k > v = acc + v
    | otherwise = acc + (v - k)

main = do
    n <- readLn :: IO Int
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ MP.foldlWithKey step' 0 $ VU.foldl' step MP.empty as

Measured memory_bytes: 17404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");

		if (cut[1].equals(cut[2])) {
			System.out.println(cut[0]);
		}

		if (cut[0].equals(cut[1])) {
			System.out.println(cut[2]);
		}
		if (cut[0].equals(cut[2])) {
			System.out.println(cut[1]);

		}
	}

}

Measured memory_bytes: 21204
#include<stdio.h>

int main() {
  
  int i, n=0;
  char S[400000], T[400000];
  
  scanf("%s %s", S, T);
  
  for(i=0; S[i]!='\0'; i++) {
    
    if(S[i] != T[i]) {
      
      n++;
      
    }
    
  }
  
 printf("%d", n);
  
  return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

uint32_t set_bit(uint32_t val, int pos, int b)
{
	uint32_t mask = (-1) ^ (1 << pos);
	return (val & mask) | (b << pos);
}

void solve_one(uint32_t a, uint32_t b, vector<uint32_t>::iterator it)
{
	*it = a;
	it++;
	*it = b;
}

void solve(uint32_t a, uint32_t b, uint32_t sel, uint32_t n, vector<uint32_t>::iterator it)
{
	if (n == 1) {
		solve_one(a, b, it);
		return;
	}

	int p = 0;
	while (true) {
		uint32_t mask = (1U << p);
		if (sel & mask && (a ^ b) & mask) {
			break;
		}
		p++;
	}

	int c_p = 0;
	while (!(sel & (1U << c_p)) || p == c_p) {
		c_p++;
	}

	uint32_t n_sel  = sel ^ (1U << p);
	uint32_t c      = a ^ (1U << c_p);
	uint32_t h_size = (1U << (n - 1));

	solve(a, c, n_sel, n - 1, it);
	solve(c, b, n_sel, n - 1, it + h_size);

	for (auto itf = it; itf < it + h_size; itf++) {
		*itf = set_bit(*itf, p, (a >> p) & 1);
	}
	for (auto itl = it + h_size; itl < it + h_size * 2; itl++) {
		*itl = set_bit(*itl, p, (b >> p) & 1);
	}
}

int main() {
	uint32_t n, a, b; cin >> n >> a >> b;

	uint32_t d = a ^ b;
	int bits = 0;

	{
		for (int i = 0; i < 32; i++) {
			if (d & (1U << i)) bits++;
		}
	}

	if ((bits & 1) == 0) {
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;
	vector<uint32_t> series(1 << n);
	solve(a, b, (1U << n) - 1, n, series.begin());
	for (auto it = series.begin(); it != series.end(); it++) {
		cout << *it;
		if (it + 1 != series.end()) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
using namespace std;

const int M=15;
int s[M];
int f;
void dfs(int step,int na,int nb)
{
    if(f)
        return;
    if(step==11)
    {
        f=1;
        return;
    }
    if(na<s[step-1])
        dfs(step+1,s[step-1],nb);
    if(nb<s[step-1])
        dfs(step+1,na,s[step-1]);
}

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        for(int i=0;i<10;i++)
            scanf("%d",&s[i]);
        f=0;
        dfs(1,-1,-1);
        printf("%s\n",f?"YES":"NO");
    }
    return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H-h) * (W - w));
		sc.close();

	}

}


Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a[5];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[1]==a[0]){
		if(a[1]!=a[2]){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
	else if(a[1]==a[2]){
		if(a[1]!=a[0]){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())
cd = c * d // gcd(c, d)
xa =(a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // cd)
xb = b - (b // c + b // d - b // cd)
print(xb - xa)


Measured memory_bytes: 5432
def isPrime(x):
    if x > 2 and x % 2 == 0:
        return False
    if x == 1:
        return True
    for a in range(3,round(x**(1/2))+1,2):
        if x % a == 0:
            return False
    return True

n = int(input())

prime = []
for a in range(n):
    prime.append(int(input()))

count = 0
for a in prime:
    if isPrime(a):
        count += 1

print(count)



Measured memory_bytes: 5976