akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  int n,height;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T ti,E ei):
    f(f),g(g),h(h),ti(ti),ei(ei){init(n_);}
  void init(int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    dat.assign(2*n,ti);
    laz.assign(2*n,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  inline T reflect(int k){
    return g(dat[k],laz[k]);
  }
  inline void eval(int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    dat[k]=reflect(k);
    laz[k]=ei;
  }
  inline void thrust(int k){
    for(int i=height;i;i--) eval(k>>i);    
  }
  inline void recalc(int k){    
    while(k>>=1)
      dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
  }
  void update(int a,int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
    recalc(a);
    recalc(b);
  }
  void set_val(int a,T x){
    thrust(a+=n);
    dat[a]=x;laz[a]=ei;
    recalc(a);
  }
  T query(int a,int b){
    thrust(a+=n);
    thrust(b+=n-1);
    T vl=ti,vr=ti;
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,reflect(l++));
      if(r&1) vr=f(reflect(--r),vr);
    }
    return f(vl,vr);
  }
};

//INSERT ABOVE HERE
signed main(){
  int n,k;
  string s,t;
  cin>>n>>k>>s>>t;

  auto f=[](int a,int b){return min(a,b);};
  auto g=[](int a,int b){return a+b;};

  const int ti=1e7,ei=0;
  SegmentTree<int, int> seg(n+1,f,g,g,ti,ei);

  s='$'+s;
  t='$'+t;
  
  vector<int> dp(n+1,ti);
  dp[0]=0;
  seg.set_val(0,dp[0]*2+2);
  
  for(int i=1;i<=n;i++){
    seg.update(0,i-1,t[i-1]!=t[i]);
    seg.update(i-1,i,1);
    
    chmin(dp[i],seg.query(max(0,i-k),i)/2);
    chmin(dp[i],dp[i-1]+(s[i]!=t[i]));
    seg.set_val(i,dp[i]*2+2);
  }
  
  cout<<dp[n]<<endl;
  return 0;
}



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


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long X = sc.nextLong();
    long Y = sc.nextLong();
    
    long nowX = X;
    long nowY = Y;
    long sumX = X;
    long sumY = Y;
    while (nowX > 1 || nowY > 1) {
      sumX += nowY / 2;
      sumY += nowX / 2;

      long nextY = nowY % 2 + nowX / 2;
      long nextX = nowX % 2 + nowY / 2;

      nowX = nextX;
      nowY = nextY;
    }
    
    sumX /= 2;
    sumY /= 2;

    if ((sumX ^ sumY) == 0) {
      System.out.println("Brown");
    } else {
      System.out.println("Alice");
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else 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 isEOS() {
		return this.eos;
	}

	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() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

vector<int> gt[MAXN];
int dp[MAXN];
int gr[MAXN];
int vis[MAXN];
int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		gr[a]++;
		gt[b].pb(a);
	}
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(gr[i]==0){dp[i] = 1;q.push(i);}
		
	}
	while(!q.empty()){
		int cur = q.front();
		q.pop();
		if(vis[cur])continue;
		vis[cur] =1 ;
		for(int i=0;i<gt[cur].size();i++){
			int to = gt[cur][i];
			dp[to] = max(dp[to],dp[cur]+1);
			gr[to]--;
			if(gr[to]==0)q.push(to);
		}

	}
	
	int res=0;
	for(int i=1;i<=n;i++){
		res = max(res,dp[i]-1);
	}
	cout<<res<<endl;
	
	
}

Measured memory_bytes: 8064
//abc117_a.cpp
//Thu Feb  7 21:16:00 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	double t,x;
	cin >> t >> x;
	double ans = t/x;
	printf("%.8f\n",ans);
}

Measured memory_bytes: 256
class Array
	def accum
		ac = Array.new(size + 1)
		ac[0] = 0
		(1..size).each do |i|
			ac[i] = ac[i-1] + self[i-1]
		end
		ac
	end
end

class Heap
	require 'forwardable'
	extend Forwardable

	def initialize
		@keys = []
		@items = []
		@index = {}
	end

	def add(item, key)
		@items << item
		@keys << key
		@index[item] = @keys.size - 1
		lift_up(@keys.size - 1)
	end

	def swap(i, j)
		u = @items[i]
		v = @items[j]
		@index[u], @index[v] = j, i
		@keys[i], @keys[j] = @keys[j], @keys[i]
		@items[i], @items[j] = @items[j], @items[i]
	end

	def lift_up(i)
		return if i == 0
		j = (i - 1) / 2
		if (@keys[i] <=> @keys[j]) < 0
			swap(i, j)
			lift_up(j)
		end
	end

	def del_min
		raise "heap is empty!" if empty?
		min_key = @keys[0]
		min_item = @items[0]
		if size > 1
			swap(0, @keys.size-1)
			@keys.pop
			@items.pop
			lift_down(0)
		else
			@keys.pop
			@items.pop
		end
		@index.delete(min_item)
		[min_item, min_key]
	end

	def update_key(obj, new_key)
		i = @index[obj]
		return unless i
		return if (new_key <=> @keys[i]) >= 0
		@keys[i] = new_key
		lift_up(i)
	end

	def lift_down(i)
		j = 2 * i + 1
		k = j + 1
		if k >= size
			return if j >= size
			if (@keys[i] <=> @keys[j]) > 0
				swap(i, j)
				lift_down(j)
			end
		else
			l = ((@keys[j] <=> @keys[k]) < 0 ? j : k)
			if (@keys[i] <=> @keys[l]) > 0
				swap(i, l)
				lift_down(l)
			end
		end
	end

	def include?(obj)
		@index.include?(obj)
	end

	def key(obj)
		@keys[@index[obj]]
	end

	def_delegators :@keys, :empty?, :size
end

dij = [
	[-1, 0],
	[0, 1],
	[1, 0],
	[0, -1],
]

loop do
	h, w, n = gets.split.map(&:to_i)
	break if h == 0
	commands = gets.chomp

	foo = commands.each_char.map {|c| (c.ord - 79) / 3}.accum.map {|x| x % 4}
	bar = [{}]
	n.times do |i|
		hash = bar[0].dup
		hash[foo[n-i]] = n-i
		bar.unshift hash
	end

	a = (0..h-1).map { gets.chomp.split("") }

	si, sj, gi, gj = nil
	(0..h-1).each do |i|
		(0..w-1).each do |j|
			if a[i][j] == ?S
				si, sj = i, j
			end
			if a[i][j] == ?G
				gi, gj = i, j
			end
		end
	end

	pq = Heap.new

	i, j = si, sj
	loop do
		pq.add([i, j], 0)
		i -= 1
		break if i < 0 || a[i][j] == ?#
	end

	min_command = {}
	while !pq.empty?
		u, c = pq.del_min
		min_command[u] = c
		i, j = u
		if i == gi && j == gj
			break
		end

		bar[c].each do |dir, k|
			next if dir == foo[c]

			di, dj = dij[dir]
			step = 1
			loop do
				new_i, new_j = i + step * di, j + step * dj
				step += 1
				break if new_i < 0 || new_i >= a.size
				break if new_j < 0 || new_j >= a[0].size
				break if a[new_i][new_j] == ?#
				v = [new_i, new_j]

				break if min_command[v]

				if pq.include?(v)
					break if pq.key(v) <= k
					pq.update_key(v, k)
				else
					pq.add(v, k)
				end
			end
		end
	end

	if min_command[[gi, gj]]
		puts 'Yes'
	else
		puts 'No'
	end
end

Measured memory_bytes: 267956
#include<bits/stdc++.h>
 
#define rep(i,a,b) for( int i = a; i < b; i++ )
#define F first
#define S second
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define mp make_pair
#define pb push_back
#define debugM(M, l, c ) rep( i, 0, l ){ rep( j, 0, c ){ cout << M[i][j] << " "; } cout << endl; }
#define debugP(p) cout << #p << " = " << p.x << " --- " << #p << " = " << p.y << endl;
 
using namespace std;

int main(){
	
	string s, t;
    
	cin >> s;
	t = s;
	reverse(s.begin(), s.end());
	
	(s == t)? cout << "Yes\n" : cout << "No\n";
	
    return 0;   
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int x; cin >>x;

	if(x%105 == 0){
		cout << 1 << endl;
		return;
	}

	int kosu = x/105 + 1;

	if(x >= 100*kosu && x <= 105*kosu){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]){

        Scanner s=new Scanner(System.in);
        String u= s.next();
        String t= s.next();
        int a= s.nextInt();
        int b= s.nextInt();
        String v= s.next();
        if(v.equals(u)){
            System.out.println(a-1+" "+b);
        }else {
            System.out.println(a+" "+(b-1));

        }
    }

}

Measured memory_bytes: 23124
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

if (x in a and y in a) or (x in b and y in b) or (x == y == 2):
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main(){
    IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout); 
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        map<int,int> m;
        for (int i = 0; i < n; ++i)
        {
            cin>>a[i];
            m[a[i]]++;
        }
        int ans=0;
        for(auto i:m){
            ans+=((i.second)*(i.second-1))/2;
        }
        for (int i = 0; i < n; ++i)
        {
            int x=ans-((m[a[i]])*(m[a[i]]-1))/2;
            x+=((m[a[i]]-1)*(m[a[i]]-2))/2;
            cout<<x<<endl;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        String s = sc.next();

        int head = 0;
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == ')') {
                if (tmp > 0) {
                    tmp--;
                } else {
                    head++;
                }
            } else {
                tmp++;
            }
        }

        int foot = 0;
        tmp = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (s.charAt(i) == '(') {
                if (tmp > 0) {
                    tmp--;
                } else {
                    foot++;
                }
            } else {
                tmp++;
            }
        }

        for (int i = 0; i < head; i++) {
            System.out.print("(");
        }
        System.out.print(s);
        for (int i = 0; i < foot; i++) {
            System.out.print(")");
        }
        System.out.println("");
    }

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> a(n);
	f(i,0,n) cin >> a[i];
	if(is_sorted(all(a))){
		cout << "YES\n";
		return 0;
	}
	f(i,0,n){
		f(j,i+1,n){
			swap(a[i],a[j]);
			if(is_sorted(all(a))){
				cout << "YES\n";
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	cout << "NO\n";
	return 0;
} 

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

int main(){
  int n,m;
  int d,p;
  pair<int,int> v[10010];

  while(cin >> n >> m, n||m){
    for(int i=0;i<n;i++){
      cin >> d >> p;
      v[i] = make_pair(p,d);
    }
    sort(v,v+n);

    int cnt = n-1;
    while(0<=cnt && m){
      if(v[cnt].second>m){
	v[cnt].second -= m;
	m = 0;
      }else{
	m -= v[cnt].second;
	v[cnt].second = 0;
      }
      cnt--;
    }

    int ans = 0;
    for(int i=0;i<n;i++)ans += v[i].first * v[i].second;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static int MAX = 510000;
	public static int MOD = 1000000007;

	public static long[] f = new long[MAX];
	public static long[] finv = new long[MAX];
	public static long[] inv = new long[MAX];

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

	public static long Com(int n, int k) {
		if(n < k)
			return 0;
		if(n < 0 || k < 0)
			return 0;
		return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ComInit();
		String n = sc.next();
		int k = sc.nextInt();
		long ans = 0;
		for(int i = 1; i < n.length(); i++) {
			if(i >= k) {
				ans += (Com(i - 1, k - 1) * Math.pow(9, k));
			}
		}
		for(int i = 0; i < n.length(); i++) {
			int top = Integer.valueOf(String.valueOf((n.charAt(i))));
			if(top != 0) {
				top--;
				ans += (Com(n.length() - (i + 1), k - 1) * Math.pow(9, k - 1) * top);
				if(i != 0) {
					ans += (Com(n.length() - (i + 1), k) * Math.pow(9, k));
				}
				k--;
			}
			if(k == 0) {
				ans++;
				break;
			}
		}
		System.out.println(ans);
	}

}


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

void solve() {
	long long a, b, n;
	cin >> a >> b >> n;
	long long x = (n / b * b) - 1;
	if (x <= 0) x = n;
	cout << (a * x / b) - a * (x / b) << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
inline void PrintYes() { cout << "YES\n"; }
inline void PrintNo() { cout << "NO\n"; }

const int NMax = 1005;

int main(){
    //debugMode();

    string s;
    cin >> s;

    int start = 0;
    int fin = (int)s.size() - 1;
    int ans = 0;

    while(start <= fin) {
        if(s[start] == s[fin]) {
            start++;
            fin--;
        } else {
            if(s[start] == 'x') {
                start++;
                ans++;
            } else {
                if(s[fin] == 'x') {
                    fin--;
                    ans++;
                } else {
                    cout << -1;
                    return 0;
                }
            }
        }
    }

    cout << ans;
    return 0;
}

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

int main(){
    int N ;
    cin >> N;
    vector<int> L(N);
    int max = -1;
    int sum = 0;
    int num = 0;

    for(int i = 0;i < N; i++){
        cin >> num;
        // L.at(i) = num;
        if(max < num){
            max = num;
        }
        sum += num;
    }

    if(max < sum - max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3636
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    t = 0
    x = 0
    y = 0

    ans = True

    for _ in range(n):
        next_t, next_x, next_y = map(int, input().split())

        dist = abs(next_x - x) + abs(next_y - y)

        if next_t - t == dist:
            t, x, y = next_t, next_x, next_y
        elif next_t - t > dist and ((next_t - t) - dist) % 2 == 0:
            t, x, y = next_t, next_x, next_y
        else:
            ans = False
            break

    if ans:
        print('Yes')
    else:
        print('No')




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
3 1 2
6 1 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
2 100 100"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
5 1 1
100 1 1"""
        output = """No"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5636
import sys
readline = sys.stdin.readline
write = sys.stdout.write
dp = [0]*601
dp[0] = 1
V = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289]
for v in V:
    for k in range(300, -1, -1):
        x = dp[k]
        w = v
        while k+w <= 300:
            dp[k+w] += x
            w += v

while 1:
    N = int(readline())
    if not N:
        break
    write("%d\n" % dp[N])


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
#include<algorithm>
//
using namespace std;
int n,ans;
int a[2005]; 
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
	for(int j=i+1;j<=n;++j)
	for(int k=j+1;k<=n;++k)
	if(a[i]+a[j]>a[k])ans++;
	else break;
	printf("%d\n",ans); 
	return 0;
} 


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>p(n);
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  UnionFind tree(n);
  for(int i = 0;i < m;i++){
    int x,y;
    cin >> x >> y;
    tree.unite(x-1,y-1);
  }
  int cnt = 0;
  for(int i = 0;i < n;i++){
    if(tree.same(i,p[i]-1)){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

vector<vector<ll>> dp;

void solve(){
    ll N;
    cin >> N;

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

    dp.resize(N, vector<ll>(2));
    ll x = A[0], y = A[N-1];
    for (int i = 0; i < N; i++) {
        x = gcd(x, A[i]);
        dp[i][0] = x;
    }
    for (int i = N-1; i >= 0; i--) {
        y = gcd(y, A[i]);
        dp[i][1] = y;
    }

    // for (int i = 0; i < N; i++) {
    //     cout << dp[i][0] << " " << dp[i][1] << endl;
    // }

    ll ans = dp[N-1][0]; // gcd(A0, ..., A_N-1)
    // cout << ans << endl;
    ans = max(ans, dp[N-2][0]); // gcd(A0, ..., A_N-2)
    // cout << ans << endl;
    ans = max(ans, dp[1][1]); // gcd(A1, ..., A_N-1)
    // cout << ans << endl;
    for (int i = 0; i < N-2; i++) {
        ans = max(ans, gcd(dp[i][0], dp[i+2][1]) );
        // cout << gcd(dp[i][0], dp[i+1][1]) << endl;
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 6528
N,M=map(int,input().split())
T=[input().split()for _ in range(M)]
class U(list):
 def __init__(self,n):
  super().__init__(range(n))
 def f(self,i):
  if i==self[i]:return i
  self[i]=self.f(self[i])
  return self[i]
 def u(self,i,j):
  self[self.f(i)]=self.f(j)
c=0
for i in range(M):
 u=U(N)
 for j in range(M):
  if i!=j:p,q=T[j];u.u(int(p)-1,int(q)-1)
 for j in range(N):
  u.f(j)
 c+=len(set(u))==2
print(c)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string s;
  set<char> st;
  cin >> s;
  rep(i, s.size()) st.insert(s[i]);
  cout << ((s.size() == st.size()) ? "yes" : "no") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool t[999999] = {false};
int main()
{
	int n, c, i, j, d;
	t[0] = true;
	for (i = 2; i * i <= 999999; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 999999; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 5; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

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

int main()
{
	int n, k, x, y, cost = 0;
	cin >> n >> k >> x >> y;
	if(n >= k){
		for (int i = 0; i < k; i++) {
			cost += x;
		}
		for (int i = 0; i < n - k; i++) {
			cost += y;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			cost += x;
		}
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, _ := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()
	sum := 0
	for _, v := range A {
		sum += v
	}
	B := N - sum
	if B >= 0 {
		fmt.Println(B)
	} else {
		fmt.Println(-1)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> p(N);
    vector<double> d(N);
    rep(i, N) { 
        cin >> p[i];
        d[i] = (p[i] * (p[i]+1)) / 2 / (double)p[i];
    }
    double sum = 0.;
    double ma = 0.;
    rep(i, K) {
        sum += d[i];
    }
    ma = sum;
    rep(i, N-K) {
        sum -= d[i];
        sum += d[i+K];
        ma = max(ma, sum);
    }
    print(setprecision(20) << ma);
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    int nx = x;

    for (int i = 0; i < 10; i++) {
      System.out.println((r * nx) - d);
      nx = (r * nx) - d;
    }

  }
}

Measured memory_bytes: 35748
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
// 最初の文字の固まりを整数値と想定して読み込む 
for (int i = 1; ; i++) {
int x = sc.nextInt();
// xが0の時を考慮しながら、 Case i: x の形式で出力しよう!
if (x == 0) {
                break;
            } else {
                System.out.println("Case " + i + ": " + x);
            }
} }
}


Measured memory_bytes: 42384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main() {
    cin>>N;
    double ans = 0;
    double D;
    rep(i,N){
        cin>>D>>S;
        if(S == "JPY"){
            ans += D;
        }else{
            ans += D * 380000.0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    high, width, d = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(high)]

    land_dic = defaultdict(tuple)
    for i in range(high):
        for j in range(width):
            num = data[i][j]
            land_dic[num] = (i, j)

    dp = [0 for i in range(high * width + 1)]
    for i in range(d + 1, high * width + 1):
        now_num = i
        pre_num = i - d
        now_place = land_dic[now_num]
        pre_place = land_dic[pre_num]
        dist = abs(now_place[0] - pre_place[0]) + abs(now_place[1] - pre_place[1])
        dp[i] = dp[i - d] + dist

    q_num = int(input())
    for i in range(q_num):
        start, goal = map(int, input().split())
        print(dp[goal] - dp[start])





if __name__ == '__main__':
    main()


Measured memory_bytes: 67548
#include <iostream>

using namespace std;

int main()
{
    int a, b, sum, digit, div;

    while(cin >> a >> b){
        sum = a + b;

        digit = 1;
        div = 10;

        while(sum / div){
            ++digit;
            div *= 10;
        }
	cout << digit << endl;
    }
}

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

#define N 10
#define INF 1000000
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)

int main() {
	int n, cost[N][N], ans, num, sum, m, a, b, c;
	while(1) {
		cin >> n;
		if(!n) break;
		for(int i=0; i<N; ++i) for(int j=0; j<N; ++j) {
			cost[i][j] = (i==j?0:INF);
		}
		m = 0;
		for(int i=0; i<n; ++i) {
			cin >> a >> b >> c;
			cost[a][b] = cost[b][a] = c;
			m = max(m, max(a, b));
		}
		for(int k=0; k<=m; ++k) {
			for(int i=0; i<=m; ++i) {
				for(int j=0; j<=m; ++j) {
					cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
				}
			}
		}
		ans = INF; num = -1;
		for(int i=0; i<=m; ++i) {
			sum = 0;
			for(int j=0; j<=m; ++j) {
				sum += cost[i][j];
			}
			if(ans>sum) {
				num = i;
				ans = sum;
			}
		}
		cout << num << " " << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }


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

  //ll h,w,m; cin >> h >> w >> m;
	string s,t; cin >> s >> t;

	ll ans = s.size();
	rep(i,s.size()-t.size()+1){ 
	  ll a = 0;
	  rep(j,t.size()) {
	    if (s[i+j] != t[j]) a++;
		}
		chmin(ans, a);
	}

	cout <<ans << endl;
}



Measured memory_bytes: 3592
s = input()
left = s[0]
ans = 0

if int(s[0]) % 2 == 0:
    num = 0
else:
    num = 1
    
for i in range(1, len(s)):
    if left == s[i]:
        ans += 1
    left = str((i + num) % 2)

print(ans)    

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

int main()
{
    int n, k, b;
    cin >> n >> k;
    vector<int> subset(k);

    for(int i = 0; i < k; i++)
         cin >> subset[i];

    for(int i = 0; i < 1<<n; i++)
    {
        bool includes = true;
        for(int j : subset)
             if(1<<j & ~i)
                 includes = false;
        
        if(!includes)
             continue;
        
        vector<int> res;

        for(int j = 0; j < n; j++)
             if(i & 1<<j)
                 res.push_back(j);
        
        cout << i << ':';
        for(int j : res)
             cout << " " << j;

        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3152
N = int(input())
A = list(map(int, input().split()))

# 全要素の因数に2が何個あるかを数える問題

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
count = 0
for a in A:
    count += collections.Counter(prime_factorize(a))[2]
    
print(count)

Measured memory_bytes: 10044
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int m=1000000007 ;
int power(int a,int b)
{ 
 int t=b,p=1,v=a;
    while(t)
    {if((t&1)==1)
     p= (p*v)%m;
        
        v= (v*v)%m;
        t>>=1;
    }
    return p;
}

int32_t main()
{int n,ans;
 cin>>n;
 ans= (power(10,n)+power(8,n))%m;
 ans= (ans- (2*power(9,n))%m +m)%m;
   cout<<ans;
 return 0;
}

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

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch (Node u, int k ){
	if (u == NIL || u->key == k ) return u;
	else
	if (u->key < k ){
		return treeSearch (u->right, k );
	}else{
		return treeSearch (u->left, k );
	} 
}

void treeDelete (Node z ){
	Node y;
	Node x;
}

void insert (int k ){
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc (sizeof (struct node ) );
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	if (x == NIL ){
		root = z;
	}else{
		do{
			if (x->key < k ){
				y = x->right;
			}else{
				y = x->left;
			}

			if (y != NIL ){
				y->parent = x;
			}else{
				if (x->key < k )
					x->right = z;
				else
					x->left = z;
			}
			x = y;
		}while (x != NIL );
	}
}

void inorder (Node u ){
	if (u == NIL ) return;
	inorder (u->left );
	printf (" %d", u->key );
	inorder (u->right );
}

void preorder (Node u ){
	if (u == NIL ) return;
	printf (" %d", u->key );
	preorder (u->left );
	preorder (u->right );
}

int main()
{
	int n, i, x;
	char com[20];

	root = NIL;
	scanf ("%d", &n );
	for (i = 0; i < n; i++ ){
		scanf ("%s", com );
		if (com[0] == 'i' ){
			scanf ("%d", &x );
			insert (x );
		}else
		if (com[0] == 'p' ){
			inorder (root );
			printf ("\n" );
			preorder (root );
			printf ("\n" );
		}else
		if (com[0] == 'f' ){
			scanf ("%d", &x );
			Node t = treeSearch (root, x );
			if ( t != NIL ) printf ("yes\n" );
			else printf ("no\n" );
		}
	}
	return 0;
}



Measured memory_bytes: 20476
n = input()
h = sorted(input() for i in range(n))[:4]
h = map(str, h)
ans = []
for i in range(3):
    for j in range(i+1, 4):
        ans.append(int(h[i]+h[j]))
        ans.append(int(h[j]+h[i]))
print sorted(ans)[2]

Measured memory_bytes: 4724
s = list(input())
s = list(set(s))
s.sort()
if len(s) == 26:
    print("None")
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(26):
    if len(s) <= i:
        print(l[i])
        break
    if s[i] != l[i]:
        print(l[i])
        break


Measured memory_bytes: 9728
n1, n2, n3 = [int(i) for i in input().split()]

n4 = min(n1, n2)
c5 = 0
r6 = 0
for i1 in range(n4):
    if (n1 % (n4 - i1) == 0) and (n2 % (n4 - i1) == 0):
        c5 += 1
        if c5 == n3:
            r6 = (n4 - i1)
            break

print(r6)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<n<<":";
	int t=2;
	while(true){
		if(n%t==0){
			cout<<" "<<t;
			n/=t;
		}
		else{
			t++;
			if(t*t>n)break;
		}
	}
	if(n!=1)cout<<" "<<n;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

vvi g;
vi ans;

void dfs(int now, int par){
    for(int i = 0; i < g[now].size(); i++){
        int ne = g[now][i];
        if(ne != par){
            ans[ne] += ans[now];
            dfs(ne,now);
        }
    }

}

signed main(void) {
    int n,q;
    cin >> n >> q;
    g = vvi(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans = vi(n,0);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0,-1);
    rep(i,n)cout << ans[i] << " \n"[i == n-1];
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int n;
    cin>>n;
    int a[n+1],prefix[n+1]={0};
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        prefix[i] = prefix[i-1] + a[i];
    }
    int minval = 100000000;
    for(int i=1;i<=n;i++){
        int val = abs(prefix[i] - (prefix[n]-prefix[i]));
        //cout<<val<<" "<<i<<"\n";
        if(val < minval){
            minval = val;
        } 
    }
    cout<<minval<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

   


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int d=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)d++;
        }
        if(d==8)ans++;
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string n;
    cin >> n;

    if((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>

using namespace std;

constexpr auto MAX_W = 1000;
constexpr auto MAX_N = 10000;

auto W = 0;
auto N = 0;

int value[MAX_N] = {};
int weight[MAX_N] = {};
int dp[MAX_N+1][MAX_W+1] = {};

auto solve() -> void {
    for (auto i = 0; i < N; i++) {
        for (auto j = 0; j <= W; j++) {
            if (j < weight[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
            }
        }
    }
}

auto main(int argc, char const *argv[]) -> int {
    auto count = 0;
    while (cin>>W, W) {
        count++;
        cin>>N;
        for (auto i = 0; i < N; i++) {
            scanf("%d,%d", &value[i], &weight[i]);
        }

        cout<<"Case "<<count<<":"<<endl; 
        solve();
        cout<<dp[N][W]<<endl;
        for(auto i = 0; i <= W; i++) {
            if(dp[N][W] == dp[N][i]) {
                printf("%d\n",i);
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 7156
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

pair<int, int> arr[MAXN];

pair<int, int> fc[MAXN];

int ans[MAXN];

int n, m, t;

void solve() {
	scanf("%d %d %d", &n, &m, &t);

	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &arr[i].fi, &arr[i].se);

		if (arr[i].se == 2) {
			arr[i].se = -1;
		}

		fc[i] = mp(((arr[i].fi + arr[i].se * t) % m + m) % m, i);		
	}

	sort(fc, fc + n);    

	int cur = 0;

	for (int i = 1, x; i < n; ++i) {
		if (arr[i].se == arr[0].se) {
			continue;
		}

		if (arr[0].se == 1) {
			x = (arr[i].fi - arr[0].fi + m) % m;		
		}
		else {
			x = (arr[0].fi - arr[i].fi + m) % m;
		}

		if (x <= t * 2) {
			int k = (t * 2 - x) / m + 1;
			cur = ((cur + k * arr[0].se) % n + n) % n;
		}	
	}

	int ps = 0;

	for (int i = 0; i < n; ++i) {
		if (fc[i].se == 0) {
			ps = i;
		}
	}

	if (fc[(ps + 1) % n].fi == fc[ps].fi && arr[0].se == 1) {
		ps = (ps + 1) % n;
	}

	for (int i = 0; i < n; ++i) {
		ans[(cur + i) % n] = fc[(ps + i) % n].fi;
	}

	for (int i = 0; i < n; ++i) {
		printf("%d\n", ans[i]);
	}
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3200
//
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    if(x-y<=-2||x-y>=2)printf("Alice");
    else printf("Brown");
    return 0;
}


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

long long memo[100010];

int main(){
    long long N,K;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        memo[a]+=b;
    }
    long long cnt=0;
    for(int i=1;i<=100000;i++){
        cnt+=memo[i];
        if(cnt>=K){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm> 
using namespace std;
int n,i,p[200050];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		int x;scanf("%d",&x);p[x]=i;
	}int gh=1,ans=0;
	for (i=2;i<=n;i++) if (p[i]<p[i-1]) ans=max(ans,gh),gh=1;else gh++;
	ans=max(ans,gh);
	printf("%d\n",n-ans);
	return 0;
}

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

int main(){
  int n,m;

  while(cin>> n>>m && (n||m)){
    vector<int> v;
    int tmp;
    for(int i=0;i<n;i++){
      cin >> tmp;
      v.push_back(tmp);
    }
    for(int i=0;i<m;i++){
      cin >> tmp;
      v.push_back(tmp);
    }
    v.push_back(0);

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

    int ans = 0;
    for(int i=0;i<(int)v.size()-1;i++){
      ans = max(ans,v[i+1]-v[i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int a,b,c,pp,t,ct,ca,cb,n,nr,i,tt,bb,aa;
int main()
{
    cin>>n>>t>>a>>b;
    nr=a+b;if(nr%2==t%2&&nr<=t)pp=1;ct=t;ca=a,cb=b;
    for(i=2;i<=n;++i){
        cin>>t>>a>>b;a-=ca,b-=cb,t-=ct;ca=a,cb=b,ct=t;nr=a+b;if(nr<0)nr=0-nr;
        if(nr%2==t%2&&nr<=t)pp;else pp=0;}

    if(pp==1)cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 256