akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

struct S {
  int t;
  int x;
  int y;
};

int n;

vector<S> a;

void input() {
  cin >> n;

  a.resize(n + 1);

  a[0] = {0, 0, 0};

  for (int i = 1; i < (int)a.size(); ++i) {
    cin >> a[i].t >> a[i].x >> a[i].y;
  }
}

void bad() {
  cout << "No\n";

  exit(0);
}

void solve() {
  int cur = a[0].t;
  int x = a[0].x;
  int y = a[0].y;

  for (int i = 1; i < (int)a.size(); ++i) {
    int req = abs(x - a[i].x) + abs(y - a[i].y);

    if (a[i].t - cur < req)
      bad();

    x = a[i].x;
    y = a[i].y;
    cur += req;

    if (cur != a[i].t && (a[i].t - cur) % 2 != 0)
      bad();
  }

  cout << "Yes\n";
}

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

  preambule();
  input();
  solve();
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a >=13){
        cout << b << endl;
    }else if(a >= 6 && a <= 12){
        cout << b/2 << endl;
    }else if (a <=5){
        cout << 0 << endl;
    }
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    bool ok = (a.back() == b[0] && b.back() == c[0]);
    cout << (ok ? "YES" : "NO");
}

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

int N;
string s;

int main(){
    cin >> N;
    if(!N)puts("0");
    while(N){
        s = (N & 1 ? "1" : "0") + s;
        N -= N & 1;
        N /= -2;
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

double limit(double mn,double d,double mx){
  return max(mn,min(mx,d));
}

int main(){
  for(int W,H,N;cin>>W>>H>>N,W|H|N;){
    int x[223],y[223];
    vector<double> ev{0,H*1.};
    for(int i=0;i<2*N;i++){
      cin>>x[i]>>y[i];
      if(W-x[i]){
	ev.push_back(y[i]*1./(W-x[i])*W);
	ev.push_back((y[i]-H)*1./(W-x[i])*W+H);
      }
      for(int j=0;j<i;j++){
	if(x[j]-x[i]){
	  ev.push_back(y[i]-(y[j]-y[i])*1./(x[j]-x[i])*x[i]);
	}
      }
    }
    sort(begin(ev),end(ev));
    double ans=0;
    for(int i=0;i<ev.size()-1;i++){
      double m=(ev[i]+ev[i+1])/2;
      if(m<0||H<m)continue;
      vector<double> pr;
      for(int j=0;j<2*N;j++){
	if(x[j]){
	  pr.push_back((y[j]-m)/x[j]*W+m);
	}else{
	  pr.push_back((y[j]>m)?1e9:-1e9);
	}
      }
      sort(begin(pr),end(pr));
      ans+=(ev[i+1]-ev[i])*(limit(0,pr[N],H)-limit(0,pr[N-1],H))/H/H;
    }
    cout.precision(9);
    cout<<fixed<<ans<<endl;
  }
}

Measured memory_bytes: 1668
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		new Main().run();
	}

	int INF = 1 << 28;

	void run() {
		while (true) {
			int c, n, m, s, d;
			c = sc.nextInt();
			n = sc.nextInt();
			m = sc.nextInt();
			s = sc.nextInt();
			d = sc.nextInt();
			if ((n | m | c | s | d) == 0)
				break;

			@SuppressWarnings("unchecked")
			List<Edge>[] es = new ArrayList[n];
			for (int i = 0; i < n; i++) {
				es[i] = new ArrayList<Edge>();
			}
			for (int i = 0; i < m; i++) {
				int a, b, f;
				a = sc.nextInt() - 1;
				b = sc.nextInt() - 1;
				f = sc.nextInt();
				es[a].add(new Edge(f, b));
				es[b].add(new Edge(f, a));
			}
			Queue<Node> q = new PriorityQueue<Node>();
			q.add(new Node(0, s - 1, c));
			boolean visited[][] = new boolean[n][c + 1];
			int ans = INF;
			while (!q.isEmpty()) {
				Node node = q.poll();
				int cost = node.cost;
				int v = node.v;
				int cnt = node.cnt;
				if (visited[v][cnt])
					continue;
				visited[v][cnt] = true;
				if (v == d - 1) {
					ans = Math.min(ans, cost);
				}
				for (Edge e : es[v]) {
					q.add(new Node(cost + e.cost, e.to, cnt));
					if (cnt > 0) {
						q.add(new Node(cost + e.cost / 2, e.to, cnt - 1));
					}
				}
			}
			System.out.println(ans);
		}
	}
}

class Node implements Comparable<Node> {
	int cost;
	int v;
	int cnt;

	Node(int cost, int v, int cnt) {
		this.cost = cost;
		this.v = v;
		this.cnt = cnt;
	}

	public int compareTo(Node n) {
		return cost - n.cost;
	}
}

class Edge {
	int to;
	int cost;

	Edge(int cost, int to) {
		this.to = to;
		this.cost = cost;
	}
}

Measured memory_bytes: 61136
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- sort <$> readInts
	print $ which a c $ b == c


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

int main(){
    string str;
    cin >> str;
    map<string, int> days;
    days["SUN"] = 7;
    days["MON"] = 6;
    days["TUE"] = 5;
    days["WED"] = 4;
    days["THU"] = 3;
    days["FRI"] = 2;
    days["SAT"] = 1;
    cout << days[str] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>

using namespace std;

int main(){
  
  int A, B;
  scanf("%d%d", &A, &B);
  
  std::cout << std::max(std::max(A+B, A-B), A*B);
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i, j, temp;
	int A[10];

	for(i=0; i<10; i++){
		scanf("%d", &A[i]);
	}

	for(i=0; i<9; i++){
		for(j=i+1; j<10; j++){
			if(A[i] < A[j]){
				temp = A[i];
				A[i] = A[j];
				A[j] = temp;
			}
		}
	}
	
	for(i=0; i<3; i++){
		printf("%d\n", A[i]);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

ll ans[200005];
ll cnt[200005];
bool visit[200005];

void dfs(int node, ll cost, vector<vector<int>>& g){
    if(visit[node]){
        return;
    }
    visit[node] = true;
    if(node != 0){
        cnt[node] += cost;
    }
    ans[node] += cnt[node];
    for(auto v : g[node]){
        dfs(v, cnt[node], g);
    }
}

int main() {

    int n, q;
    cin >> n >> q;
    vector<vector<int>> graph(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    rep(i, q){
        int p, x;
        cin >> p >> x;
        cnt[--p] += x;
    }

    dfs(0, cnt[0], graph);

    rep(i, n){
        cout << ans[i] << endl;
    } 

    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define precision(x) fixed << setprecision(x)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double PI = acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    double r, s, l;
    cin >> r;
    s = r * r * PI;
    l = 2 * r * PI;
    cout << precision(6) << s << " " << l << endl;
}


Measured memory_bytes: 3296
# 9th

n,y = [int(i) for i in input().split()]
def numbers_possible(n,y):
    for i in range(n+1):
        for j in range(n-i+1):
            if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
                return print(i,j,n-i-j)
    return print(-1,-1,-1)
numbers_possible(n,y)

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

using namespace std;


int main() {
    int N, M;

    cin >> N >> M;
    int sum = 0;

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

    int cnt = 0;

    for (int x: A) {
        if (x * 4 * M >= sum) {
            cnt++;
        }
    }

    cout << (cnt >= M ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	using namespace std;
	int n, y,loop = true;
	cin >> n >> y;
	for (int i = 0; i <= n && loop; i++)
		for (int j = 0; i + j <= n && loop; j++)
			for (int k = 0; i + j + k <= n && loop; k++) {
				if (i * 10000 + j * 5000 + k * 1000 == y && i+j+k == n) {
					cout << i << " " << j << " " << k;
					loop = false;
				}
			}
	if (loop)
		cout << -1 << " " << -1 << " " << -1;
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int tmp=0,sum=0;
  for(int i=0;i<n;i++){
    if(a[i]==a[i+1]) tmp++;
    else{
      sum+=tmp;
      tmp=0;
    }
  }

  cout<<n-sum-sum%2<<endl;
  return 0;
}


Measured memory_bytes: 640
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

ll modpow(ll a, ll p, ll m){
	ll ret = 1;
	while(p){
		if(p%2) ret = ret * a  % m;
		a = a * a % m;
		p >>= 1;
	}
	return ret;
}

ll rec(ll m, ll ans){
	if(m==0) return ans;
	else return rec(m%__builtin_popcount(m), ans+1);
}

int main(){
	int n;
	scanf("%d", &n);
	char s[n+1];
	scanf("%s", s);
	int cnt = 0;
	REP(i, 0, n) cnt += (s[i]=='1');

	if(cnt==0){
		REP(i, 0, n) puts("1");
		return 0;
	}else if(cnt==1){
		ll val_inc = 0, bi_inc = 1;
		REP(i, 0, n){
			if(s[n-i-1]=='1'){
				val_inc = (val_inc + bi_inc) % (cnt+1);
			}
			bi_inc = bi_inc * 2 % (cnt+1);
		}

		REP(i, 0, n){
			if(s[i]=='1') puts("0");
			else{
				ll m = (val_inc + modpow(2, n-i-1, cnt+1)) % (cnt+1);
				printf("%ld\n", rec(m, 1));
			}
		}
		return 0;
	}


	ll val_inc = 0, val_dec = 0, bi_inc = 1, bi_dec = 1;
	REP(i, 0, n){
		if(s[n-i-1]=='1'){
			val_dec = (val_dec + bi_dec) % (cnt-1);
			val_inc = (val_inc + bi_inc) % (cnt+1);
		}
		bi_dec = bi_dec * 2 % (cnt-1);
		bi_inc = bi_inc * 2 % (cnt+1);
	}

	REP(i, 0, n){
		ll m, ans = 1;
		if(s[i]=='1') m = (val_dec - modpow(2, n-i-1, cnt-1) + (cnt-1)) % (cnt-1);
		else m = (val_inc + modpow(2, n-i-1, cnt+1)) % (cnt+1);
		printf("%ld\n", rec(m, ans));
	}

	return 0;
}



Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
	
  	int a,b,c;
  	int n;
  	int ans=0;
  	cin >>a>>b>>c>>n;
  	
  	while(a>=b) {
    	b*=2;
      	ans+=1;
    }
  	
  	while(b>=c) {
    	c*=2;
      	ans+=1;
    }
    if(ans<=n) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

constexpr int64_t MOD = 1000000007;

using namespace std;

class AAtCoderContestScheduling {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        int64_t D = 0;
        cin >> D;
        vector<int64_t> c_vec(26);
        for (int i = 0; i < 26; ++i) cin >> c_vec[i];
        vector<vector<int64_t>> s_vec(D, vector<int64_t>(26));
        for (int i = 0; i < D; ++i)
            for (int j = 0; j < 26; ++j) cin >> s_vec[i][j];

        for (int i = 0; i < D; ++i) {
            int64_t tmp = 0;
            int64_t index = 0;
            for (int j = 0; j < 26; ++j) {
                if (tmp < s_vec[i][j]) {
                    tmp = s_vec[i][j];
                    index = j;
                }
            }
            cout << index + 1 << endl;
        }
    }
};


int main() {
    AAtCoderContestScheduling solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define first f
#define second s
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int k;  
  string s;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
    int t='z'-s[i]+1;
    if(s[i]=='a')continue;
    if(k-t<0)continue;
    else k-=t,s[i]='a';
  }
  if(k>0)s[s.size()-1]=(s[s.size()-1]-'a'+k)%26+'a';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;


int main()
{
	//cout<<fast_power(3,2)<<"::::" <<endl;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll n,r,ans=0;
	cin>>n>>r;
	if(n>=10)
	{
		ans=r;
		}
	else
	{
		ll z=100*(10-n);
		ans=r+z;
		}
		
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[110000];
int main(){
	int a;scanf("%d",&a);
	while(a--){
		scanf("%s",str);
		if(strlen(str)==1){
			printf("Yes\n");continue;
		}
		bool ok=false;
		char L,R;
		bool OK;
		L=str[0];
		R=str[1];
		OK=true;
		for(int i=2;str[i];i++){
			if(R=='L'||L=='R')OK=false;
			if(i%2==0)L=str[i];
			else R=str[i];
		}
		if(R=='L'||L=='R')OK=false;
		if(OK)ok=true;
		L=str[1];
		R=str[0];
		OK=true;
		for(int i=2;str[i];i++){
			if(R=='L'||L=='R')OK=false;
			if(i%2==0)R=str[i];
			else L=str[i];
		}
		if(R=='L'||L=='R')OK=false;
		if(OK)ok=true;
		for(int i=0;str[i+1];i++)if(str[i]==str[i+1])ok=false;
		if(ok)printf("Yes\n");
		else printf("No\n");
	}
}

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

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();
		
		double a = (y2 - y1) / (x2 - x1);
		double b = y1 - a * x1;
		
		int q = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<q; i++) {
			double xp = sc.nextDouble();
			double yp = sc.nextDouble();
			
			double x = 0;
			double y = 0;
			if(y1 == y2) {
				x = xp;
				y = y1;
			} else if(x1 == x2) {
				x = x1;
				y = yp;
			} else {
				x = (yp + xp / a - b) / (a + 1 / a);
				y = yp + xp / a - x / a;
			}
			
			x += x - xp;
			y += y - yp;
			
			ans.append(x);
			ans.append(" ");
			ans.append(y);
			ans.append("\n");
		}
		
		System.out.print(ans);
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int n, m;
    cin >> n >> m;
    int minv = INF, maxv = -INF;
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        minv = min(minv, r);
        maxv = max(maxv, l);
    }
    int ans = minv + 1 - maxv;
    if (ans < 0)cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}


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

int main() {
    int N,C,K;
    cin>>N>>C>>K;
    vector<int> T(N);
    for(int i=0; i<N; i++)
        cin>>T[i];
    
    int bus=0;
    int passenger=0;
    int first_wait;
    sort(T.begin(), T.end());
    for(int i=0; i<N;) {
        passenger=1;
        first_wait=T[i++];
        while(i<N && passenger<C && T[i]-first_wait<=K) {
            passenger++;
            i++;
        }
        bus++;
    }
    cout<<bus<<endl;
}

Measured memory_bytes: 640
from collections import deque

# BFSで、B/Wそれぞれのスタート地点から拡張点への距離を取得
def bfs(s, distance):
    visited = [False] * N
    q = [(s, 1)]
    visited[s] = True

    while q:
        u, dist = q.pop()
        for v in graph[u]:
            if not visited[v]:
                visited[v] = True
                distance[v] = dist
                q.append((v, dist+1))

#    print(distance)


N = int(input())
graph = [deque() for i in range(N)]
distance = [[0] * N for i in range(2)]

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

#print(graph)

bfs(0, distance[0])
bfs(N-1, distance[1])

# 各頂点について、より近いほうが塗れたことに
b = w = 0
for i in range(1, N-1):
    if distance[0][i] <= distance[1][i]:
        b += 1
    else:
        w += 1
if b <= w:
    print('Snuke')
else:
    print('Fennec')


Measured memory_bytes: 81252
program main
      implicit none
      integer :: n, i
      character(100) :: s, t
      character(200) :: ans

      read *, n
      read *, s, t

      n = len_trim(s)

      do i = 1, n
        ans(2*(i-1)+1:2*(i-1)+1) =  s(i:i)
        ans(2*i:2*i) =  t(i:i)
      end do

      print *, ans(1:2*n)

end program main


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    s = input()


    cnt = 0
    right = 0
    flag = 1
    j = k + 1 if s[0] == '1' else k
    for i in range(n - 1):
        if s[i]  == '1' and s[i + 1] == '0':
            cnt += 1
        if cnt == j:
            right = i + 1
            flag = 0
            break


    if flag:
        return n


    left = 0
    ret = right - left
    flag = 0

    while True:
        while True:
            if right + 1 >= n:
                flag = 1
                break
            if s[right] == '1' and s[right + 1] == '0':
                right += 1
                break
            right += 1
        while True:
            if s[left] == '0' and s[left + 1] == '1':
                left += 1
                break
            left += 1
        if flag:
            right += 1
        ret = max(ret, right - left)
        if flag:
            break
    return ret


print(main())

Measured memory_bytes: 40688
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
   // FI(); /// skip this line for compile
    int n,k;
    cin >> n;
    k = (n*100)/108;
    if((k*108)/100==n) cout << k << endl;
    else if(((k-1)*108)/100==n) cout << k-1 << endl;
    else if(((k+1)*108)/100==n) cout << k+1 << endl;
    else cout << ":(" << endl;
    return 0;
}



Measured memory_bytes: 3632
import math
k = int(input())
sum = 0

def gcd(a,b,c):
    return(math.gcd(math.gcd(a,b),c))

for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            if i==j==l:
                sum += i
            elif i==j or j==l or l==i:
                sum += gcd(i,j,l)*3
            else:
                sum += gcd(i,j,l)*6

print(sum)


Measured memory_bytes: 9080
'''
Created on 2020/08/27

@author: harurun
'''
def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  a,b,x=map(int,pin().split())
  if 2*x>a*a*b:
    print(math.degrees(math.atan((2*b*a*a-2*x)/(a*a*a))))
  else:
    print(math.degrees(math.atan(a*b*b/(2*x))))
  return 

main()

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

int main()
{
    long long N, K;
    cin >> N >> K;
    long long A[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    sort(A, A + N);
    long long count = 1;
    for (long long i = 0; i < N - 1; ++i)
    {
        if (A[i] == A[i + 1])
        {
            ++count;
        }
        else
        {
            break;
        }
    }
    long long tmp = (N - count) % (K - 1) == 0 ? 0 : 1;
    long long ans = ((N - count) / (K - 1)) + tmp;
    cout << ans << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(A, B);
  SCIN(S);
  bool ok = true;
  REP(i, A) {
    ok &= ('0' <= S[i] && S[i] <= '9');
  }
  ok &= (S[A] == '-');
  FOR(i, A + 1, A + B + 1) {
    ok &= ('0' <= S[i] && S[i] <= '9');
  }
  OK(ok);

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 3");
            WillReturn.Add("1 2 3 4");
            WillReturn.Add("1 3");
            WillReturn.Add("2 3");
            WillReturn.Add("2 4");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6 5");
            WillReturn.Add("8 6 9 1 2 1");
            WillReturn.Add("1 3");
            WillReturn.Add("4 2");
            WillReturn.Add("4 3");
            WillReturn.Add("4 6");
            WillReturn.Add("4 6");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        int[] HArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        var LinkListDict = new Dictionary<int, List<int>>();
        foreach (string EachStr in InputList.Skip(2)) {
            SplitAct(EachStr);
            wkArr[0]--;
            wkArr[1]--;

            if (LinkListDict.ContainsKey(wkArr[0]) == false) {
                LinkListDict[wkArr[0]] = new List<int>();
            }
            if (LinkListDict.ContainsKey(wkArr[1]) == false) {
                LinkListDict[wkArr[1]] = new List<int>();
            }
            LinkListDict[wkArr[0]].Add(wkArr[1]);
            LinkListDict[wkArr[1]].Add(wkArr[0]);
        }

        int Answer = 0;
        for (int I = 0; I <= HArr.GetUpperBound(0); I++) {
            if (LinkListDict.ContainsKey(I) == false) {
                Answer++;
                continue;
            }
            if (LinkListDict[I].Exists(pX => HArr[pX] >= HArr[I])) {
                continue;
            }
            Answer++;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 71068
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	string s;
	cin >> s;
	rep(i, 0, s.size()) {
		cout << "x";
	}cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <limits>

using namespace std;

namespace {

static int Merge(int* A, int left, int mid, int right) {
  const int n1 = mid - left;
  const int n2 = right - mid;

  // When sorting large arrays, allocating L and R in heap for
  // each Merge call makes a bit the program slower.
  //
  // In the real application, we should use std::vectors instead of
  // fixed sized arrays, though.
  // vector<int> L(n1+1);
  // vector<int> R(n2+1);
  int L[n1 + 1];
  int R[n2 + 1];

  for (int i = 0; i < n1; ++i) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; ++i) {
    R[i] = A[mid + i];
  }

  static const int kInf = numeric_limits<int>::max();
  L[n1] = kInf;
  R[n2] = kInf;

  int i = 0;
  int j = 0;
  for (int k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
  return right - left;
}

inline int MergeSortInternal(int* A, int left, int right) {
  if (left + 1 >= right) return 0;

  const int mid = (left + right) / 2;
  int ret = MergeSortInternal(A, left, mid);
  ret += MergeSortInternal(A, mid, right);
  return ret + Merge(A, left, mid, right);
}

inline int MergeSort(int* A, int n) {
  return MergeSortInternal(A, 0, n);
}
} // namespace

int main() {
  int n;
  int S[500000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }

  const int swapped = MergeSort(S, n);
  for (int i = 0; i < n; ++i) {
    if (i > 0) printf(" ");
    printf("%d", S[i]);
  }
  printf("\n");
  printf("%d\n", swapped);

  return 0;
}

Measured memory_bytes: 4940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<deque>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
////////////////////////////

int const N = 541;
ll const INF = 1e9;

ll a[N][N];
ll POS, NEG;
int H, W, h, w;

void findV(){
	ll cnt = h * w - 1;
	POS = INF / cnt;
	if(POS * cnt == INF) --POS;
	NEG = -(POS * cnt + 1);
}

void check(ll v){
	assert(v >= -INF && v <= INF);
}

void solve(){
	cin >> H >> W >> h >> w;
	if(h == w && h == 1){
		cout << "No" << endl;
		return;
	}
	findV();
	rep(i, 0, H) rep(j, 0, W) a[i][j] = POS;
	for(int x=w-1;x<W;x+=w){
		for(int y=h-1;y<H;y+=h){
			a[y][x] = NEG;
		}
	}
	ll sum = 0;
	rep(i, 0, H) rep(j, 0, W) sum += a[i][j];
	if(sum > 0){
		cout << "Yes" << endl;
		rep(i, 0, H){
			rep(j, 0, W){
				cout << a[i][j] << " ";
				assert(a[i][j]);
			}
			cout << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

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

	solve();

	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        String S = br.readLine();
        String T = br.readLine();

        String[] T_array = T.split("");

        int ans = T.length();

        for(int i = 0; i < S.length() - T.length() + 1; i++) {
            String str = S.substring(i, i + T.length());
            String[] str_array = str.split("");

            int tmp = 0;

            for(int j = 0; j < str_array.length; j++) {
                if(!str_array[j].equals(T_array[j])) {
                    tmp += 1;
                }
            }

            if(ans > tmp) ans = tmp;
        }

        pw.println(ans);
        br.close();
        pw.close();
    }
}

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

int main(){
	int x,y;
	bool flag = false;
	cin >> x >> y;
	for(int i=2*x;i<=4*x;i=i+2){
		if(i==y){
           flag = true;
           break;
		}
	}
	if(flag){
		cout << "Yes" <<endl;
	}
	else{
		cout<< "No" << endl;
	}
return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).rbegin(), (x).rend()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N,H;
    cin >> N >> H;
    vec<int> a(N);
    vec<int> b(N);
    rep(i,N) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    int maxA = a[0];
    int ans =0;
    rep(i,N){
        if(b[i]>maxA){
            H-=b[i];
            ++ans;
        } else {
            break;
        }

        if(H<=0) break;
    }
    if(H<=0) {
        cout << ans << endl;
    } else {
        ans+=((H+maxA-1)/maxA);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = s; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 30;
const int mod = 1e9 + 7;

int main() {
   int n, K;
   cin >> n >> K;
   vector<int> h(n);
   rep(i, 0, n) { cin >> h[i]; }
   vector<int> dp(n, inf);
   dp[0] = 0;
   rep(i, 0, n) {
      rep(j, 1, K + 1) {
         if (i - j >= 0)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
      }
   }
   cout << dp[n - 1] << endl;
   return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  static int top = 0;
  static int[] number = new int[200];

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ",0);
    for(int i = 0; i<str.length; i++){
      if(str[i].equals("+")) {
        int a = pop();
        int b = pop();
        push(b+a);
        continue;
      }
      if(str[i].equals("-")) {
        int a = pop();
        int b = pop();
        push(b-a);
        continue;
      }
      if(str[i].equals("*")) {
        int a = pop();
        int b = pop();
        push(b*a);
        continue;
      }
      push(Integer.parseInt(str[i]));
    }
    System.out.println(pop());
  }
  public static int pop() {
    top--;
    return number[top+1];
  }
  public static void push(int i) {
    top++;
    number[top] = i;
  }
}

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

int main() {
    ll t;
    cin >> t;
    ll ans = t;
    ll up = 0;
    ll down = 0;
    ll tm = 0;
    for (ll speed=1; speed<t; speed*=3) {
        up += speed;
        tm++;
        if (speed > 3) {
            down += speed/3;
            tm++;
        }
        ll tmptm = tm;
        ll tmpt = t - up - down;
        if (tmpt < 0) break;
        for (ll sp=speed; sp>=1; sp/=3) {
            if (tmpt / sp >= 1) {
                tmptm += tmpt / sp;
                tmpt -= sp * (tmpt/sp);
            }
        }
        ans = min(ans, tmptm);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3128
# include "cstdio"
# include "algorithm" 
 
const int maxm=1000+10; 
 
int n,	//n个蛋糕 
	m; 	//取出m个蛋糕 
 
long long 
	dp[5][maxm], 
	ans,now1,now2; 
 
inline long long read(){
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

inline long long max(long long x,long long y){
	return x>y?x:y; 
} 

inline bool comp(long long x,long long y){
	return x>y?true:false; 
} 

int main(){
	long long x,y,z;
	register int i,j; 
	n=read(),m=read();
	for(i=1;i<=n;i++){
		x=read(),y=read(),z=read(); 
		dp[1][i]=x+y+z; //-x-y-z
		dp[2][i]=x+y-z;	//-x-y+z
		dp[3][i]=x-y+z;	//-x+y-z
		dp[4][i]=x-y-z;	//-x+y+z
	}
	for(i=1;i<=4;i++){
		std::sort(dp[i]+1,dp[i]+1+n,comp);
		now1=now2=0; 
		for(j=1;j<=m;j++){
			now1+=dp[i][j];
			now2+=dp[i][n-j+1]; 
		}
		now1=now1>0?now1:-now1;
		now2=now2>0?now2:-now2; 
		ans=max(ans,max(now1,now2)); 
	}
	printf("%lld",ans); 
	return 0; 
} 

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n;
	cin >> n;
	while(1){
		ll c = 0;
		for(ll i = 2; i * i <= n; i++){
			if(n%i == 0){
				c = 1;
				break;
			}
		}
		if(c)n++;
		else{
			cout << n << nl;
			return;
		}
	}
}

int main(){ 
#ifndef ONLINE_JUDGE
 //   freopen("input1.txt","r",stdin);
  //  freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
     //cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



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

using namespace std;

long long Calories(const vector<pair<long long, int>> &v, long long C) {
    int n = v.size();

    vector<long long> pref_sum(n);
    pref_sum[0] = v[0].second;
    for (int i = 1; i < n; ++i) {
        pref_sum[i] = pref_sum[i-1] + v[i].second;
    }
    
    vector<int> best_pref[2];
    //best_pref[0].resize(n);
    //best_pref[1].resize(n);

    long long best[2] = {0, 0};

    for (int i = 0; i < n; ++i) {
        long long s[2] = {0, 0};
        s[0] = pref_sum[i] - v[i].first;
        s[1] = pref_sum[i] - 2 * v[i].first;
        //cerr << s[0] << " " << s[1] << "\n";
        //cerr << best[0] << " " << best[1] << "\n";
        for (int j = 0; j < 2; ++j) {
            if (s[j] > best[j]) {
                //cerr << "WTF\n";
                best_pref[j].push_back(i);
                best[j] = s[j];
            }
        }
    }

    long long best_res = 0;
    if (best_pref[0].size() > 0) {
        best_res = pref_sum[best_pref[0].back()] - v[best_pref[0].back()].first;
    }

    //cerr << best_res << "\n";

    long long suf_res[2] = {0, 0};

    for (int i = n-1; i >= 0; --i) {

        suf_res[0] += v[i].second + v[i].first - ((i == n-1) ? C : v[i+1].first);
        suf_res[1] += v[i].second + 2 * (v[i].first - ((i == n-1) ? C : v[i+1].first));
        //cerr << suf_res[0] << " " << suf_res[1] << "\n";
        //cerr << v[i].second << " " << v[i].first << "\n";
        for (int j = 0; j < 2; ++j) {
            int k = 1 - j;
            long long res = suf_res[j];

            auto it = lower_bound(begin(best_pref[k]), end(best_pref[k]), i);
            if (it != begin(best_pref[k])) {
                --it;
                res += pref_sum[*it] - v[*it].first;
                if (k == 1) res -= v[*it].first;
            }
            best_res = max(best_res, res);
        }
    }
    
    return best_res;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    long long c;

    
    cin >> n >> c;

    vector<pair<long long, int>> v(n);

    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }

    cout << Calories(v, c) << "\n";

    return 0;
}

Measured memory_bytes: 3580
n = int(input())

nums = []
for i in range(4):
    nums.append([])
    for j in range(3):
        nums[i].append([])
        for k in range(10):
            nums[i][j].append(0)


for _ in range(n):
    b,f,r,v = map(int, input().split())
    nums[b-1][f-1][r-1] += v

for i, building in enumerate(nums):
    for floor in building:
        print('', ' '.join(map(str, floor)))
    if i != 3:
        print('#'*20)

Measured memory_bytes: 7696
#include <stdio.h>

int main( )
{
  int w,h,x,y,r;

  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

  if(x + r <= w && y + r <= h && x - r >= 0 && y - r >= 0)printf("Yes\n");
  else printf("No\n");

  return 0;
}
  

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n;
struct node{
	int val;
	int id;
	bool operator<(node x)const{
		return val>x.val;
	}
}a[2010];
int dp[2010][2010];
signed main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].val;
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			const int k=i+j+1;
			if(k>n)
				break;
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]+a[k].val*abs(a[k].id-(i+1)));
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]+a[k].val*abs(a[k].id-(n-j)));
		}
	int maxv=0;
	for(int i=0;i<=n;++i)
		maxv=max(maxv,dp[i][n-i]);
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 26228
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;
//fibonacci
int binet(int n)
{
	return (pow((1+sqrt(5)),n-1)-pow((1-sqrt(5)),n-1))/(pow(2,n-1)*sqrt(5));
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll i,j,k,l,m,n;
	string str;
	cin>>str;
	set <char> a;
	for(i=0;i<str.length();i++)
	{
		a.insert(str[i]);
	}
	set<char>::iterator itr;
	itr=a.end();
	k=0;
	for(i=97;i<=122;i++)
	{
		if(a.count((char)i)==0)
		{
			k=1;
			break;
		}
	}
	if(k==0)
		cout<<"None"<<"\n";
	else
		cout<<(char)i<<"\n";

	return 0;
}
	

Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

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

		int x = sc.nextInt();

		int i = 1;
		while(true){
			if(x*i%360 == 0){
				System.out.println(i);
				return;
			}
			i++;
		}
	}
}


Measured memory_bytes: 26936
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
bool cmp(const pair<int,int>&a , const pair<int,int>&b){
  if(a.second != b.second) return a.second < b.second;
  return a.first < b.first;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int n , k;
  string s;
  cin >> s;
  map<char , int>mp;
  set<int>st;
  for(int i=0;i<s.size();i++){
    mp[s[i]]++;
    st.insert(s[i]);
  }
  for(auto i : st){
    if(mp[i]!=2){
      cout <<"No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';

}

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

int main() {
	int N, ans = 0, tmp = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; ++i) {
		if (S[i] == '#') ++tmp;
		else {
			if (tmp) {
				++ans;
				--tmp;
			}
		}
	}
	/*for (int i = 0; i < N - 1; ++i) {
		if (S[i] == '#' && S[i + 1] == '.') ++ans;
	}*/
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main(){
  string S,T,ans;
  ans = "Yes";
  cin >> S >> T;
  rep(i,0,S.size()){
    if(S[i] != T[i]){ans = "No";}
  }
  co(ans);
}

Measured memory_bytes: 3624
package main

import "fmt"

func searchArray(t int, a []int) bool {
	for i := 0 ; i < len(a) ; i++ {
		if a[i] == t {
			return false
		}
	}
	return true
}

func main() {
	var n,temp,count int
	fmt.Scan(&n)
	a := make([]int,n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&temp)
		if searchArray(temp,a) {
			a[count] = temp
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[10];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    bool flag=1;
    rep(i,6){
        int x;
        cin>>x;
        nums[x]++;
        if(nums[x]>2){
            flag=0;
        }
    }
    if(flag){
        cout1("YES")
    }else{
        cout1("NO")
    }
    
}

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

"""
解説参考
・まず素因数分解で階乗全部バラす
・そこからいい感じの組み合わせを探して数える
"""

N = int(input())

# 階乗の素因数分解：ひとつずつ分解したものを合算
e = [0] * (N+1)
# 階乗の各値ループ
for i in range(2, N+1):
    num = i
    # 素因数分解するループ
    for j in range(2, N+1):
        while num % j == 0:
            num //= j
            e[j] += 1

# 約数75(各指数+1をかける)を取りうる素因数の組み合わせを探していく
nums = set()
# 指数が4, 4, 2
for p in range(2, N+1):
    for q in range(2, N+1):
        for r in range(2, N+1):
            if (e[p] >= 4 and e[q] >= 4 and e[r] >= 2
                    and p != q and q != r and r != p):
                nums.add(pow(p, 4) * pow(q, 4) * pow(r, 2))
# 指数が14, 4 or 24, 2
for p in range(2, N+1):
    for q in range(2, N+1):
        if e[p] >= 14 and e[q] >= 4 and p != q:
            nums.add(pow(p, 14) * pow(q, 4))
        if e[p] >= 24 and e[q] >= 2 and p != q:
            nums.add(pow(p, 24) * pow(q, 2))
# 指数が74
for p in range(2, N+1):
    if e[p] >= 74:
        nums.add(pow(p, 74))  

print(len(nums))


Measured memory_bytes: 3064
from collections import deque
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
l = a[0]
r = a[-1]
ll = deque([l])
rl = deque([r])
for i in range(1,n-1):
    l = gcd(l,a[i])
    r = gcd(r,a[-(i+1)])
    ll.append(l)
    rl.appendleft(r)

llas = ll.pop()
rlas = rl.popleft()

res = max(llas,rlas)
for i in range(n-2):
    res = max(res, gcd(ll.pop(), rl.pop()))
print(res)


Measured memory_bytes: 16112
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007
#define MAX 510000

long int FAC[MAX],FINV[MAX],INVE[MAX];
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
long int POW(long int a,long int b){//a^b
  long int c=1;
  for(a%=MOD;b;a=PROD(a,a),b>>=1)if(b&1)c=PROD(a,c);
  return c;
}
long int INV(long int a){return a<MAX?INVE[a]:POW(a,MOD-2);}//a^-1
long int QUOT(long int a,long int b){return PROD(a,INV(b));}//a/b
void init_inv(long int a){//make inv list
  INVE[1]=1;
  for(long int i=2;i<=a;i++)INVE[i]=SUM(0,-PROD(INVE[MOD%i],MOD/i));
}
void init_com(long int a){//make fac and facinv list
  FAC[0]=FAC[1]=1;
  FINV[0]=FINV[1]=1;
  init_inv(a);
  for(long int i=2;i<=a;i++){
    FAC[i]=PROD(FAC[i-1],i);
    FINV[i]=PROD(FINV[i-1],INV(i));
  }
}
long int COM(long int a,long int b){return PROD(PROD(FAC[a],FINV[a-b]),FINV[b]);}

int main(){
  int n,a[100001],i,x,y;
  scanf("%d",&n);
  init_com(n+1);
  for(i=1;i<=n;i++)a[i]=-1;
  for(i=0;i<=n;i++){scanf("%d",&y);if(a[y]==-1)a[y]=i;else {x=a[y];y=i;break;}}
  printf("%d\n",n);
  for(i=2;i<n+2;i++){if(n-y+x>i-2)printf("%ld\n",SUM(COM(n+1,i),-COM(n-y+x,i-1)));else printf("%ld\n",COM(n+1,i));}
}


Measured memory_bytes: 10496