akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

long long GCD(long long a, long long b) {
    long long q;
    while (b) {
        q = a % b;
        a = b;
        b = q;
    }
    return a;
}

vector<long long> PrimeFactorize(long long n) {
    vector<bool> prime(round(sqrt(n)) + 1, 1);
    vector<long long> ans;
    for (long long i = 2; i * i <= n; i++) {
        if (prime[i]) {
            for (long long j = 2 * i; j * j <= n; j += i) {
                prime[j] = 0;
            }
            while (n % i == 0) {
                ans.push_back(i);
                n /= i;
            }
        }
    }
    if (n != 1) ans.push_back(n);
    return ans;
}

/* main */

signed main() {
    ll A, B;
    cin >> A >> B;
    ll X = GCD(A, B);
    auto v = PrimeFactorize(X);
    set<ll> s;
    for (auto x : v) s.insert(x);
    cout << s.size() + 1 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define f(i,x) for(int i=0;i<x;i++)

using namespace std;

long long int a[87] = { 0 };

long long int ryuka(int i) {
	if (a[i] != 0)
		return a[i];
	if (i == 0) {
		a[0] = 2;
		return a[0];
	}
	if (i == 1) {
		a[1] = 1;
		return a[1];
	}
	a[i] = ryuka(i - 1) + ryuka(i - 2);
	return a[i];
}

int main()
{
	long long int ans;
	int n;

	cin >> n;

	ans = ryuka(n);

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    n = int(input())
    mob=np.array(list(map(int,input().split())),dtype=int)
    bra=np.array(list(map(int,input().split())),dtype=int)
    ans=0

    for i in range(n):
        ans += min(mob[i],bra[i])
        ans += min(mob[i+1],bra[i]-min(mob[i],bra[i]))
        mob[i+1]-=min(mob[i+1],bra[i]-min(mob[i],bra[i]))
    print(ans)


if __name__=="__main__":
    main()

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

using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for(int i=0; i<N; ++i) cin >> X[i] >> Y[i];

    double d_s = 0;
    for(int i=0; i<N-1; ++i)
    {
        for(int l=i+1; l<N; ++l)
        {
            d_s += sqrt(pow(X[i] - X[l], 2) + pow(Y[i] - Y[l], 2));
        }
    }
    int p = 1;
    for(int i=N-1; i>0; --i) p*=i;
    cout << fixed << setprecision(7) << 2 * p * d_s / (p * N) << endl;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int xyh[n][3];
    for(int i = 0; i < n; i++)
        cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            int h = -1;
            bool succ = true;
            for(int i = 0; i < n; i++)
                if(xyh[i][2] != 0){
                    if(h == -1)
                        h = abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) + xyh[i][2];
                    else if(abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) + xyh[i][2] != h){
                        succ = false;
                        break;
                    }
                }
            if(succ){
                for(int i = 0; i < n; i++)
                    if(xyh[i][2] == 0 && h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy) > 0){
                        succ = false; 
                        break;
                    }
                if(succ){
                    cout << cx << " " << cy << " " << h << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(A*B);
		sc.close();
	}


}

Measured memory_bytes: 35544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+23;

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=d;i<=r;i+=d){
        if(i>=l) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;


namespace ProconLib{
    class UnionFind{
        int N;
        std::vector<int> par;
        std::vector<int> rank;
        std::vector<int> dat;
        public:
        UnionFind(int N):N(N),par(N),rank(N,0){std::iota(par.begin(),par.end(),0);dat=par;}
        int find(int x);
        void unite(int x,int y);
        void set(int v,int val){dat[find(v)]=val;}
        int get(int v){return dat[find(v)];}
        bool same(int x,int y){return find(x)==find(y);}
    };

    int UnionFind::find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void UnionFind::unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]>=rank[y]){
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }else{
            par[x]=y;
        }
    }
}
using namespace ProconLib;
struct Edge{
    int a,b;
    ll c;
};

bool operator<(Edge lhs,Edge rhs){
    return lhs.c>rhs.c;
}

using Graph=vector<vector<int>>;

vector<int> sz;
int setSZ(int v,const Graph& g){
    if(g[v].size()==0) return sz[v]=1;
    for(auto to:g[v]) sz[v]+=setSZ(to,g);
    return sz[v];
}
int n;
vector<Edge> edges;
vector<ll> res;
void solve(int v,Graph& g,ll sum){
    if(g[v].size()==0){
        res[v]=sum;
        return;
    }
    for(auto to:g[v]){
        solve(to,g,sum+(sz[v]-sz[to])*edges[v-n].c);
    }
}
int main(){
    
    cin>>n;
    edges.resize(n-1);
    for(int i=0;i<n-1;i++){
        int a,b;
        ll c;
        cin>>a>>b>>c;
        a--,b--;
        edges[i]=Edge{a,b,c};
    }

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

    Graph g(2*n-1);
    UnionFind u(n);

    for(int i=0;i<edges.size();i++){
        Edge e=edges[i];
        int l=u.get(e.a);
        int r=u.get(e.b);
        int p=i+n;
        g[p].push_back(l);
        g[p].push_back(r);
        u.unite(e.a,e.b);
        u.set(e.a,p);
    }

    sz.assign(2*n-1,0);
    setSZ(2*n-2,g);
    res.assign(n,-1);
    solve(2*n-2,g,0);
    
    for(int i=0;i<n;i++){
        cout<<res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 20096
N = int(input())
pi = list(map(int, input().split()))
#print(pi)

pis = sorted(pi)
#print(pis)

count = 0
for i in range(N):
    if pi[i] != pis[i]:
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")


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

#define INF 1e9
using namespace std;

int main() {

    long long N; cin >> N;

    long long ans = 0;

    for (long long i = 1; i <= sqrt(N); ++i) {
        if ((N-i)%i == 0 && (N-i)/i > i) {
            ans += (N-i)/i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int k = sc.nextInt();
		int i = 0;
		while(n != 0) {
			n /= k;
			i++;
		}

		System.out.println(i);
		sc.close();
	}
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;


#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

ll ext_gcd(ll a,ll b,ll &x,ll &y){ //ax+gy=gcd(a,b)なるx,y,gcd(an,b)を返す
  if(b == 0){
    x = 1; y = 0; return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a - q * b, x, y);
  ll z = x - q * y;
  x = y; y = z;
  return g;
}

main(){
  int n,k; cin >> n >> k;
  vi a(n); rep(i, n) cin >> a[i];
  int m = 0; rep(i, n) m = max(m, a[i]);
  int g = a[0], x, y; rep(i, n - 1) g = ext_gcd(g, a[i + 1], x, y);
  if(k <= m and k % g == 0) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def root(par, x):
    if par[x] == x:
        return x
    else:
        return root(par, par[x])


def unite(rank, par, x, y):
    x = root(par, x)
    y = root(par, y)

    if x == y:
        par[x] = y

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


def main():
    N, M = map(int, readline().split())
    p = list(map(int, readline().split()))
    m = map(int, read().split())
    XY = list(zip(m, m))

    par = list(range(N))
    rank = [0] * N

    for x, y in XY:
        x -= 1
        y -= 1
        unite(rank, par, x, y)

    d_p = defaultdict(list)
    d_index = defaultdict(list)
    for i in range(N):
        par[i] = root(par, i)
        d_index[par[i]].append(p[i])
        d_p[par[i]].append(i+1)

    cnt = 0
    for i in set(par):
        cnt += len(list(set(d_index[i]) & set(d_p[i])))

    print(cnt)


main()


Measured memory_bytes: 123496
#include<cstdio>
#define N 10001
int c[N],d[N],i,j,k,n,s,t,x,y,z;char a[N],b[N];
int main()
{
	scanf("%d%s%s",&n,a+1,b+1),x=1000000000,s=t=2;
	for(i=1;i<n;i++)if(a[i]!=a[i+1])c[++s]=i;
	for(i=1;i<n;i++)if(b[i]!=b[i+1])d[++t]=i;
	for(a[1]!=b[1]?z=c[1],i=2:(z=0,i=1);i<=s;x=x<y?x:y,z+=c[i++],z+=c[i++])
	{
		for(j=i,k=1,y=z;j<=s&&k<=t;j++,k++)y+=c[j]<d[k]?d[k]-c[j]:c[j]-d[k];
		while(j<=s)y+=n-c[j++];
		while(k<=t)y+=n-d[k++];
	}
	for(a[1]!=b[1]?z=d[1],i=2:(z=0,i=1);i<=t;x=x<y?x:y,z+=d[i++],z+=d[i++])
	{
		for(j=1,k=i,y=z;j<=s&&k<=t;j++,k++)y+=c[j]<d[k]?d[k]-c[j]:c[j]-d[k];
		while(j<=s)y+=n-c[j++];
		while(k<=t)y+=n-d[k++];
	}
	return 0*printf("%d\n",x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,g=0,k=0,l=100000000000000000;
  cin>>N;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    g+=i;
  }
  for(int i=0;i<N;i++){
    k+=A[i];
    l=min(abs(g-k*2),l);
  }
  cout<<l<<endl;
}

Measured memory_bytes: 4824
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	 ios::sync_with_stdio(false);
	 int n;
	 while(cin>>n)
	 {
	 	
	 	if(n<1200&&n>=0) cout<<"ABC\n";
	 	else if(n>=1200&&n<2800)cout<<"ARC\n";
	  else if(n>=2800&&n<=4208) cout<<"AGC\n";
	 }
	 return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.copy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5672
n,x = gets.chomp.split(' ').map(&:to_i)
strs = gets.chomp.split(' ').map(&:to_i)
dist = strs.map{ |num| (x - num).abs }
g = dist[0]
dist.each_with_index do |dis, idx|
  g = g.gcd(dist[idx])
end
print g

Measured memory_bytes: 10244
#include <stdio.h>
#include <string.h>
int main(){
	char S[21], T[21], U[21];
	int A, B;
	scanf("%s %s", &S, &T);
	scanf("%d %d", &A, &B);
	scanf("%s", &U);
	
	if(strcmp(S, U)==0){printf("%d %d", A - 1, B); }
	else if(strcmp(T, U)==0){printf("%d %d", A, B - 1);}
	
	return 0;
}

Measured memory_bytes: 1712
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        Dictionary<int, int> dic = new Dictionary<int, int>();
        for (int i = 0; i < N; i++)
        {
            dic[cin.nextInt()] = 1;
        }

        Console.WriteLine(dic.Count);

    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 13152
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int M=sc.nextInt();
		
		
		
		for(int i=0;i<M;i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			
			if(!map.containsKey(a)) {
				map.put(a, new ArrayList<Integer>());
			}
			if(!map.containsKey(b)) {
				map.put(b, new ArrayList<Integer>());
			}
			map.get(a).add(b);
			map.get(b).add(a);
		}
		
		
		int v[]=new int[N];
		Queue<Integer> qq=new ArrayDeque<>(); 
		
		int sum=0;
		
		qq.add(1);
		while(sum<N&&qq.peek()!=null) {
			int t=qq.poll();
			ArrayList<Integer> cc=map.get(t);
			for(int i:cc) {
				if(v[i-1]==0) {
					v[i-1]=t;
					qq.add(i);
					sum++;
				}
			}
		}
		p("Yes");
		for(int i=1;i<N;i++) {
				p(v[i]);
		}
		
		
	}
	public static Map<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>(20001);	
		
	//static int ans=10000009;
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 85272
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
const long long MOD = 998244353;
long long i, n, m, k, ans;
long long d[100001];
typedef long long ll;

ll modpow(ll a, ll n, ll mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main() {
    scanf(" %lld", &n);
    init(d, n+1, 0);
    scanf(" %lld", &k);
    if (k != 0) {
        printf("0\n"); exit(0);
    }
    d[0]++;
    rep(1,n) {
        scanf(" %lld", &k);
        if (k == 0) {
            printf("0\n"); exit(0);
        } else {
            d[k]++;
        }
    }
    ans = 1;
    rep(1, n) {
        ans = ans * modpow(d[i-1], d[i], MOD) % MOD;
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////
function<LL(LL, LL)> gcdlambda = [](LL n, LL m) { return __gcd(n, m); };

void solve(long long A, long long B, long long K) {
  int cnt = 0;
  for (int i = 100; i >= 1; i--) {
    if (A % i == 0 && B % i == 0) cnt++;
    if (cnt == K) {
      cout << i << endl;
      break;
    }
  }
}

int main() {
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long K;
  scanf("%lld", &K);
  solve(A, B, K);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n;
  cin >> n;
  string s[200005];
  int count[200005]={};
  rep(i,n){
    cin >> s[i];
  }
  sort(s,s +n);
  int maxv = 0,sum = 0;
  rep(i,n){
    sum ++;
    if(s[i] != s[i+1]){
      maxv = max(maxv,sum);
      sum = 0;
    }
  }
  vector<string> vec;
  sum = 0;
  rep(i,n){
    sum++;
    if(s[i] != s[i+1]){
      if(sum == maxv){
	vec.push_back(s[i]);
      }
      sum = 0;
    }
  }
  sort(all(vec));
  rep(i,vec.size()){
    cout << vec[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 14576
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string.h>
using namespace std;

int n,K;
struct Node
{
    int x,y;
    int col;
}node[100005];
char s[15];
int d[1005];

int Abs(int k)
{
    if (k>=0) return k;
    else return -k;
}

int main()
{
    scanf ("%d %d",&n,&K);
    for (int i=1;i<=n;i++)
        {
        scanf ("%d %d",&node[i].x,&node[i].y);
        scanf ("%s",s+1);
        if (s[1]=='B') node[i].col=0;
        else node[i].col=1;
        }
    int ans=0,next=0,reans=0,col;
    for (int i=1;i<=K;i++)
        {
        int anss=0;
        memset(d,0,sizeof(d));

        for (int j=1;j<=n;j++)
            {
            int x,y;
            x=node[j].x/K;
            y=(node[j].y+i-1)/K;

            if ((x+y)%2==0) col=0;
            else col=1;

            if (col==node[j].col)
                {
                d[K-node[j].x%K]--;
                anss++;
                }
            else
                d[K-node[j].x%K]++;
            }
        ans=max(anss,ans);
        reans=max(reans,n-anss);
        for (int j=1;j<K;j++)
            {
            anss+=d[j];
            ans=max(anss,ans);
            reans=max(reans,n-anss);
            }
        }
    printf ("%d",max(ans,reans));
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(1000000)
n,m,k=map(int,input().split())
stock=[[] for i in range(n)]
ter=[0]*n
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    stock[a-1].append(b-1)
    stock[b-1].append(a-1)
    ans[a-1]-=1
    ans[b-1]-=1
def dfs(j,k):
    size[k]+=1
    for next_j in stock[j]:
        if ter[next_j]==0:
            ter[next_j]=k
            dfs(next_j,k)
total=0
size=[0]*(n+1)
for i in range(n):
    if ter[i]==0:
        total+=1
        ter[i]=total
        dfs(i,total)

for i in range(n):
    ans[i]+=size[ter[i]]-1
for i in range(k):
    c, d = map(int, input().split())
    if ter[c-1]==ter[d-1]:
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n-1):
    print(ans[i],end=" ")
print(ans[n-1])


Measured memory_bytes: 49588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a)
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
 
int N,M,m,i,t;
long long s;
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&t);
        s+=t;
        m=i&&m<t?m:t;
        M=i&&M>t?M:t;
    }
    printf("%d %d %lld\n",m,M,s);
    return 0;
}


Measured memory_bytes: 2044
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 500010;
int n, f[N], last;
char s[N];

int main()
{
	scanf("%d%s", &n, s+1);
	if (n <= 2){ puts("0"); return 0; }
	for (int i = 3; i <= n; i ++){
		f[i] = f[i-1];
		if (s[i-2] == '1' && s[i-1] == '0' && s[i] == '1'){
			last = i;
			for (int j = i-2; s[j] != '0' && j; j --)
				f[i] = max(f[i], f[j-1]+i-j-1);
		}
		if (s[i] == '0') last = 0;
		if (last) f[i] = max(f[i], f[last-3]+i-last+1);
	}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;cin>>h>>w>>n;
    ll r0,c0;cin>>r0>>c0;
    string s,t;cin>>s>>t;
    map<char,ll> cnts;
    cnts['L']=c0;
    cnts['R']=w+1-c0;
    cnts['U']=r0;
    cnts['D']=h+1-r0;
    rep(i,n){
        cnts[s[i]]--;
        if(cnts[s[i]]<=0){
            cout << "NO" << endl;
            return 0;
        }
        if(t[i]=='L'&&cnts['R']<w){
            cnts['R']++;
        }else if(t[i]=='R'&&cnts['L']<w){
            cnts['L']++;
        }else if(t[i]=='U'&&cnts['D']<h){
            cnts['D']++;
        }else if(t[i]=='D'&&cnts['U']<h){
            cnts['U']++;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n,ans=0;
    cin>>n;
    for(long long int i =1;i<=n;i++){
        if(i%3!=0 && i%5!=0)
            ans = ans+i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    double a, b, C;
    cin >> a >> b >> C;
    
    double S, L, h;
    
    S = 0.50 * a * b * sin(C * M_PI / 180.0);
    L = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(C * M_PI / 180.0));
    h = b * sin(C * M_PI / 180.0); 
    
    
    cout << fixed << S << " " << L << " " << h;
    
    return 0;
}

Measured memory_bytes: 3556
s = input()
ans = 0
for i in range(len(s)):
    cnt = 0
    for j in range(i, len(s)):
        if s[j] == 'A' or s[j] == 'T' or s[j] == 'G' or s[j] == 'C':
            cnt = cnt + 1
        else:
            break
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3060
def draw(h, w):
    print("#" * w)
    for i in range(h-2):
        print("#" + ("."*(w-2)) + "#")
    print("#" * w)
    print("")
 
while True:
    h, w = map(int, raw_input().split())
    if h == 0 and w == 0:
        break
    draw(h, w)

Measured memory_bytes: 6336
#include <stdio.h>

int main()
{
	int a, b;

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

	if ((a + b) == 3)
	{
		printf("%d\n", 3);
	}

	if ((a + b) == 4)
	{
		printf("%d\n", 2);
	}
	if ((a + b) == 5)
	{
		printf("%d\n", 1);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=2e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)



void solve(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=sz(t);
    int ans=INT_MAX;
    for(int i=0;i<=n-m;i++){
        int cnt=0;
        string now=s.substr(i,m);
        
        for(int i=0;i<m;i++){
            if(now[i]!=t[i]){
                cnt++;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     //freopen("outputf.in", "w", stdout);
    // #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 3656
<?php
//Sの部分文字列になりうる全パターンに対して一致率を算出して一致率が高いパターンに関して
//Tが部分文字列となるのに必要な文字の変更数を算出する
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%s",$t);
$match_count = 0;
$max_match_count = 0;
for($i=0;$i<=strlen($s)-strlen($t);$i++){
  for($j=$i;$j<$i+strlen($t);$j++){
    if($s[$j]==$t[$j-$i]){
      $match_count++;
    }
  }
  $max_match_count = max($match_count,$max_match_count);
  $match_count = 0;
}

echo (strlen($t)-$max_match_count);
 

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

int main()
{

  while( true ) {
    bool bary[ 100 ][ 100 ][ 100 ] = { false };

    int n, x;
    cin >> n >> x;
    if( n == 0 and x == 0 ){
      break;
    }

    int cnt = 0;
    for( int i = 1; i <= n; i++ ) {
      for( int j = 1; j <= n; j++ ) {
        for( int k = 1; k <= n; k++ ) {
          if( i == j or j == k or k == i ) {
            continue;
          }
          if( i + j + k == x ) {
            int ary[3] = { i, j, k };
            sort( ary, ary + 3 );
            int x, y, z;
            x = ary[ 0 ], y = ary[ 1 ], z = ary[ 2 ];
            if( bary[ x ][ y ][ z ] == false ) {
              bary[ x ][ y ][ z ] = true;
              cnt += 1;
//            cout << x << ":" << y << ":" << z << endl;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 4112
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, M;
        cin >> N >> M;
        vector<int> vec(N, 0);
        rep(i, M)
        {
                int a, b;
                cin >> a >> b;
                vec[a - 1]++;
                vec[b - 1]++;
        }
        rep(i, N)
        {
                cout << vec[i] << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int n,m;
using namespace std;
vector<int> h;

struct MyTrail{
  int a;
  int b;
  MyTrail(int in_a, int in_b){
    a = in_a;
    b = in_b;
  }
  bool operator<(const MyTrail& another) const{
    return (a == another.a) ? b < another.b : a < another.a;

  }
};
int cnt = 0;
int tcnt = 0;

bool flg[1000000] = {false};
vector<MyTrail> v;

int main(){
  cin >> n >> m;
  cin.ignore();
  int tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    h.push_back(tmp);
  }
  int tmpa, tmpb;
  for(int i = 0; i < m; i++){
    cin >> tmpa >> tmpb;
    if(tmpa > tmpb){
      tmp = tmpb;
      tmpb = tmpa;
      tmpa = tmp;
    }
    v.push_back(MyTrail(--tmpa, --tmpb));
  }
  sort(v.begin(), v.end());

  for(int i = 0; i < v.size(); i++){
    if(h[v[i].a] < h[v[i].b]) flg[v[i].a] = true;
    else if(h[v[i].b] < h[v[i].a]) flg[v[i].b] = true;
    else {
      flg[v[i].a] = true;
      flg[v[i].b] = true;
    }
  }
  
  for(int i = 0; i < h.size(); i++){
    if(flg[i] == false){
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
  
}


Measured memory_bytes: 4628
#include<stdio.h>
 
int main(void){
int num,a,b;
scanf("%d",&num);
 
a = num/100;
b = num%100;
 
if(1<=a && a<=12)
{
  if(1<=b && b<=12)
  {
    printf("AMBIGUOUS");
  }
  else
  {
    printf("MMYY");
  }
}
else
{
  if(1<=b && b<=12)
  {
    printf("YYMM");
  }
  else
  {
    printf("NA");
  }
}
return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<string>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    int a,b;
	cin>>a>>b;
	if(a<=b)
	cout<<"unsafe";
	else
	cout<<"safe";
    
    
    
    return 0;
}



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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N;
    cin >> N;
    vector<int> A,B,C;
    rep(i,0,N){
        int a;
        cin >> a;
        A.push_back(a);
    }
    rep(i,0,N){
        int a;
        cin >> a;
        B.push_back(a);
    }
    rep(i,0,N){
        int a;
        cin >> a;
        C.push_back(a);
    }

    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0LL;
    rep(i,0,B.size()){
//        cout << lower_bound(all(A),B[i]) - A.begin() << endl;
//        cout << C.end() - upper_bound(all(C),B[i]) << endl;
//        cout << endl;
        ans += 1LL * ( lower_bound(all(A),B[i]) - A.begin() ) * (C.end() - upper_bound(all(C),B[i]));
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
    int N;
    std::cin >> N;
    std::vector<double> v(N);
    for (int i = 0; i < N; i++) {
        std::cin >> v[i];
    }

    for (int i = 0; i < N - 1;i++){
        double val;
        std::sort(v.begin(), v.end());
        
        // for (auto x: v)
        //     std::cout << x << " ";
        // std::cout << std::endl;  
        v.push_back((v[0] + v[1]) / 2.0);
        v.erase(v.begin());
        v.erase(v.begin());
        
        
    }
    // std::cout << v.size() << std::endl;
    std::cout << v[0] << std::endl;

    return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
set<pair<pair<int,int>,int> >st;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	while(true)
	{
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
//		cout<<a<<" "<<b<<" "<<c<<endl;
		if((a&1)||(b&1)||(c&1))
		{
			cout<<cnt<<endl;
			return 0;
		}
		if(st.find(MP(MP(a,b),c))!=st.end())
		{
			cout<<-1<<endl;
			return 0;
		}
		st.insert(MP(MP(a,b),c));
		int na=0,nb=0,nc=0;
		na=b/2+c/2;
		nb=a/2+c/2;
		nc=a/2+b/2;
		a=na;
		b=nb;
		c=nc;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();

            if (Math.abs(c - a) <= d || (Math.abs(b - a) <= d && Math.abs(c - b) <= d)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }
}



Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        bool[] memo = Enumerable.Repeat(true, 60000).ToArray();
        memo[0] = memo[1] = false;
        for (int i = 2; i <= 55555; i++)
        {
            if (!memo[i]) continue;
            for (int x = 2; i * x <= 55555; x++) memo[i * x] = false;
        }
        for (int i = 0; i <= 55555 && N > 0; i++)
            if (memo[i] && i % 5 == 1) { Console.Write(i + " "); N--; }
        Console.WriteLine();
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n;
  cin >> n;

  ll frs = 0;
  multiset<ll> bkq;
  multiset<ll> frms;
  vll as(3*n);
  rep(i, 3*n) {
    ll a;
    cin >> a;
    as[i] = a;
    if (i < n) {
      frs += a;
      frms.insert(a);
    } else {
      bkq.insert(a);
    }
  }
  multiset<ll> bkms;
  ll bks = 0;
  rep(i, n) {
    ll a = *bkq.begin();
    bks += a;
    bkms.insert(a);
    bkq.erase(bkq.begin());
  }

  ll ans = frs - bks;
  ll tmp = ans;
  repLRE(i, n, 2 * n - 1) {
    ll a = as[i];
    // fr
    auto itrf = frms.upper_bound(a);
    if(itrf != frms.begin()){
      auto ifb = frms.begin();
      tmp += a - *ifb;
      frms.insert(a);
      frms.erase(ifb);
    }
    // bk
    auto itrb = bkms.lower_bound(a);
    if(itrb != bkms.end()){
      bkms.erase(a);
      ll inst = *bkq.begin();
      bkq.erase(bkq.begin());
      bkms.insert(inst);
      tmp -= inst - a;
    } else {
      bkq.erase(bkq.lower_bound(a));
    }
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16640
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

int main()
{
    int T, X;
    cin >> T >> X;
    double ans;

    ans = (double)T/X;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[100009],f[100009];
main()
{
    p[1]=1;

    for (int i=2; i<=100000; i++)
    {
        for (int j=2*i; j<=100000; j+=i)
            p[j]=1;
    }
    p[2]=0;
    for (int i=1; i<=100000; i++)//构造前缀和
    {
        if(p[i]==0 && p[(i+1)/2]==0 && i!=2)//如果该数满足要求，前缀和加1；否则不变
            {
                f[i]=f[i-1]+1;
            }
        else f[i]=f[i-1];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<f[r]-f[l-1]<<endl;//对于每组询问，直接输出f[r]-f[l-1]
    }
}

Measured memory_bytes: 1408
#include <cstdio>
using namespace std;
int N;
char s[1000];
int x=0,m=0;
int main(){
  scanf("%d",&N);
  scanf("%s",s);
  for(int i=0;i<N;i++){
    if(s[i]=='I')x++;
    else if(s[i]=='D') x--;
    if(m<x)m=x;
  }
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 128