akhauriyash/Code-Regression huggingface dataset:
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	ll r,g,b,n;
	cin>>r>>g>>b>>n;
	ll ans=0;
	rep(i,0,n+1)
	{
		rep(j,0,n+1)
		{
			ll rem=(n-(r*i+g*j));
			if(rem>=0 && !(rem%b))
			{
				ans++;
			}
		}
	}
	cout<<ans;
	
}

Measured memory_bytes: 256
import math


def main():
    N, A = map(int, input().split())
    ans = float("inf")
    for i in range(41):
        x = int(math.pow(N, 1/(i+1)))
        k = 0
        while x**(i+1-k) * (x+1)**k < N:
            k += 1
        y = x * (i+1-k) + (x+1) * k + A * i
        ans = min(ans, y)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
using System;

namespace Airplane{
	class Airplane{
		static void Main(string[] args){
			int[] PQR = new int[3];
			string[] Input = Console.ReadLine().Split(' ');
			for(int i = 0 ; i < 3 ; i ++){
				PQR[i] = int.Parse(Input[i]);
			}
			Array.Sort(PQR);
			Console.WriteLine("{0}",PQR[0]+ PQR[1]);
		}
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
#define N 2000000
int A[N],B[N],C[N];
int main(void){
 
  int i,j,k=0,n;
    
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    C[A[i]]=C[A[i]]+1;
    if(k<A[i])k=A[i];
  }
 
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  
  for(i=0;i<n;i++){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
 
  for(i=0;i<n;i++){
    if(i!=n-1){
      printf("%d ",B[i]);
  }
    else printf("%d\n",B[i]);
      
  }
  return 0;
}

Measured memory_bytes: 18288
#include<bits/stdc++.h>
using namespace std;
int n,a[1001],ans;
int main (){
	cin>>n;
	for(int i=1;i<=2*n;i++){
		cin>>a[i];
    }
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2){
    	ans+=a[i];
    }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

ll _count[2000] = { 0 };
int main() {
	cin >> N >> A >> B;
	for (int i = 1; i < N; i++) {
		queue<ll> que;
		que.push(i);
		ll visited[2001] = { false };
		ll range[2001] = { 0 };
		visited[i] = true;
		while (!que.empty()) {
			int curr = que.front(); que.pop();
			if (!visited[curr + 1] && curr != N) {
				visited[curr + 1] = true;
				que.push(curr + 1);
				range[curr + 1] = range[curr] + 1;
			}
			if (!visited[curr - 1] && curr - 1 != 0) {
				visited[curr - 1] = true;
				que.push(curr - 1);
				range[curr - 1] = range[curr] + 1;
			}
			if (curr == A && !visited[B]) {
				visited[B] = true;
				que.push(B);
				range[B] = range[A] + 1;
			}
			if (curr == B && !visited[A]) {
				visited[A] = true;
				que.push(A);
				range[A] = range[B] + 1;
			}
		}
		for (int j = i+1; j <= N; j++) {
			_count[range[j]]++;
		}
	}
	for (int i = 1; i < N; i++) {
		cout << _count[i] << endl;
	}
}



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

using namespace std;

int main() {
  int n;
  int taro[200];
  while (true) {
    set<int> cards[2];
    int top = 0;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> taro[i];
    }
    cards[0].clear();
    cards[1].clear();
    for (int i = 0; i < n; ++i) {
      cards[0].insert(taro[i]);
    }
    for (int i = 1; i <= 2 * n; ++i) {
      if (cards[0].count(i) == 0) {
        cards[1].insert(i);
      }
    }
    for (int i = 0; cards[0].size() * cards[1].size() > 0; ++i) {
      set<int>::iterator iter = upper_bound(cards[i % 2].begin(), cards[i % 2].end(), top);
      if (iter == cards[i % 2].end()) {
        top = 0;
      } else {
        top = *iter;
        cards[i % 2].erase(iter);
      }
    }
    cout << cards[1].size() << endl << cards[0].size() << endl;
  }
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc137/tasks/abc137_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 後ろの日にちから考える。（前から考えてはいけない(戒め））
 
 M-1日目にアルバイトをしようとした時、Aが1以下のアルバイトで最も報酬の多いアルバイトを行えばいい
 同様に
 M-i日目にアルバイトをしようとした時、Aがi以下のアルバイトで最も報酬の多いアルバイトを行えばいい
 
 これはpriority_queue等で高速に計算できる。
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<vector<ll>> C(100005);
    for(int i = 0; i < N;i++){
        ll A,B; cin >> A >> B;
        C[A].push_back(B);
    }
    
    priority_queue<ll> pq;
    for(int i = 1; i <= M;i++){
        for(auto v:C[i]){
            pq.push(v);
        }
        
        if(pq.size()){
            res += pq.top(); pq.pop();
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MAX_N = 100000;

// vector<int> dp(100000, 1e9);

int main()
{
    // string S,T,U;
    ll N,M;
    ll ans = 0;
    cin >> N>>M ;
    // scanf("%lld%lld", &A,&B);
    // cin >> U;
    ans = (N*(N-1)+M*(M-1)) / 2;
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

bool isPrime(ll n) {
    if(n < 2) return false;
    else {
        for (ll i = 2; i * i <= n; i++) {
            if (n%i == 0) return false;
        }
        return true;
    }
}


int main(){
	ll a,b,ta,tb;
	cin >> a >> b;
	ta = a,tb = b;
	vector<ll> c;
	c.push_back(1);
	for(ll i = 2; i*i <= max(ta,tb); i++){
		if(a%i == 0 && b%i == 0){
			c.push_back(i);
			while(a%i == 0) a /= i;
			while(b%i == 0) b /= i;
		}
		while(a%i == 0) a /= i;
		while(b%i == 0) b /= i;
	}
 
	if(a < b) swap(a,b);
	if(a%b == 0 && isPrime(a) && isPrime(b)){
		c.push_back(a);
	}
 
	//for(auto cc : c) cout << cc << endl;
	cout << c.size() << endl;
 
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
abc = input()
 
OP = ['+','-']
ans = 0
for op1 in OP:
    for op2 in OP:
        for op3 in OP:
            if eval(abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]) == 7:
                ans = abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]
print(ans+'=7')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int count = 0;
		int N = scan.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt() - 1;
		}
		for(int i = 0; i < N; i++) {
			if(i == p[i]) {
				count++;
				i++;
			}
		}
		System.out.println(count);
		scan.close();
	}

}


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

answer=0
if N==K:
    print(1)
elif K!=2:
    if A.index(1)==0 or A.index(1)==N-1:
        if N-K>K:
            if (N-K)%(K-1) == 0:
                answer=int(1+((N-K)/(K-1)))
            else:
                answer=int(((N-K)/(K-1))+2)
        else:
            answer=2
        print(answer)
    else:
        left_items=A.index(1)
        right_items=(N-1)-A.index(1)
        if left_items<K or right_items<K:
            if (N-K)%(K-1) == 0:
                answer=int(1+((N-K)/(K-1)))
            else:
                answer=int(((N-K)/(K-1))+2)
            print(answer)

        left=left_items%(K-1)
        right=right_items%(K-1)
        if left+right+1 == K:
            answer=1+(int(left_items/(K-1))+int(right_items/(K-1)))
            print(answer)
        else:
            answer=1+(int(left_items/(K-1))+int(right_items/(K-1)))+1
elif K==2:
    answer=N-1
    print(answer)

Measured memory_bytes: 14008
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int a, b, k;
  readf("%s %s %s\n", &a, &b, &k);

  int[int] cnt;
  foreach (i; a..min(a+k, b+1)) {
    cnt[i]++;
  }
  foreach (i; max(a, b-k+1)..b+1) {
    cnt[i]++;
  }

  auto keys = cnt.keys;
  keys.sort();
  foreach (e; keys) {
    e.writeln;
  }
}


Measured memory_bytes: 256
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    x = list(map(int, input().split()))
    for i in range(len(x)):
        if x[i] == 0:
            print(i + 1)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 27132
#include<iostream>
#include<cstdio>

using namespace std;

int A,B;
int a[5001],b[5001];
int dp[5001];
int ans=0;
int main(void){
	scanf("%d%d",&A,&B);
	for(int i=0;i<A;i++)scanf("%d",&a[i]);
	for(int i=0;i<B;i++)scanf("%d",&b[i]);
	for(int i=0;i<B;i++){
		int c=i;
		for(int j=0;j<A;j++){
			if(b[c]==a[j])dp[i]++,c++;
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------
// べき乗を計算　指数を計算
ll llpow(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

const int MAX = 1000000;
// fac[i] = iの階乗
// finv[i] = iの階乗 の逆元
// inv[i] = iの逆元
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    cout << n + n * n + n * n * n << endl;


    return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int h, w, k;
	cin >> h >> w >> k;
	char c[10][10];
	rep(i, h) cin >> c[i];
	vector<int> a(h), b(w);
	rep(i, h) rep(j, w) {
		if (c[i][j] == '#') {
			a[i]++;
			b[j]++;
		}
	}
	int cnt = 0;
	rep(i, h) cnt += a[i];
	int ans = 0;
	rep(H, 1 << h) {
		rep(W, 1 << w) {
			vector<int> p, q;
			rep(i, h) {
				if (H >> i & 1) p.push_back(i);
			}
			rep(i, w) {
				if (W >> i & 1) q.push_back(i);
			}
			int P = p.size(), Q = q.size();
			int now = cnt;
			for (auto i : p) now -= a[i];
			for (auto i : q) now -= b[i];
			for (auto i : p) {
				for (auto j : q) {
					if (c[i][j] == '#') now++;
				}
			}
			if (now == k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,k;
  cin>>n>>k;
  if(k%2) cout<<(n/k)*(n/k)*(n/k)<<endl;
  else{
    k/=2;
    n/=k;
    cout<<(n/2)*(n/2)*(n/2)+(n-n/2)*(n-n/2)*(n-n/2)<<endl;
  }
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
x = np.empty(N,dtype=np.int)
y = np.empty(N,dtype=np.int)
h = np.empty(N,dtype=np.int)
for n in range(N):
    (x[n],y[n],h[n]) = map(int,input().split())

M = 100

grads = np.array([[1,1],[-1,1],[-1,-1],[1,-1]],dtype=np.int)
def height(x,y,h,i,j,d):
    # d=0-3
    return (h + grads[d,0]*(i-x) + grads[d,1]*(j-y))

def quadrant(x,y):
    if x > 0 and y >= 0:
        return 0
    elif y > 0:
        return 1
    elif x < 0:
        return 2
    else:
        return 3

Clist = [(Cx,Cy) for Cy in range(M+1) for Cx in range(M+1)]
k = h.argmax()
for (Cx,Cy) in Clist:
    H = height(x[k],y[k],h[k],Cx,Cy,quadrant(Cx-x[k],Cy-y[k]))
    for n in range(N):
        Hn = height(x[n],y[n],h[n],Cx,Cy,quadrant(Cx-x[n],Cy-y[n]))
        if h[n] == 0:
            if Hn < H:
                break
        else:
            if Hn != H:
                break
    else:
        break

print(Cx,Cy,H)

Measured memory_bytes: 12780
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n,m;
	static int x[100010],y[100010];
	scanf("%d%d",&n,&m);
	rep(i,m){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	static bool a[100010];
	static int b[100010];
	rep(i,100010){
		a[i] = false;
		b[i] = 1;
	}
	a[1] = true;
	
	rep(i,m){
		a[y[i]] |= a[x[i]];
		if(b[x[i]] == 1){
			a[x[i]] = false;
		}
		b[x[i]] --;
		b[y[i]] ++;
	}
	
	int ret = 0;
	rep(i,100010)if(a[i])ret ++;
	cout << ret << endl;
}



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

long L[90];

long lucas(int n){
    if (L[n])
        return L[n];
    else
        return L[n] = lucas(n-1) + lucas(n-2);
}

int main(){
    int n;
    L[0] = 2;
    L[1] = 1;

    cin >> n;
    cout << lucas(n) << endl;
}

Measured memory_bytes: 256
program a

integer(8) :: n,k,i,j,jj,j1,jj1,b,c,cou=0
double precision :: su1,su2

read(*,*) k


b = 2
c = 0

do

	su1 = 0
	su2 = 0
	j = b * 10 ** c - 1
	jj = (b+9) * 10 ** c - 1
	j1 = b * 10 ** c - 1
	jj1 = (b+9) * 10 ** c - 1
	
	do 
		su1 = su1 + mod(j,10)
		if(j <= 9) then
			goto 100
		else
			j = j / 10
		endif
	enddo
	100 continue
	
	do 
		su2 = su2 + mod(jj,10)
		if(jj <= 9) then
			goto 200
		else
			jj = jj / 10
		endif
	enddo
	
	200 continue
	su1 = j1 / su1
	su2 = jj1 / su2
	
	if(su1 > su2) then
		b = b / 10 + 1
		c = c + 1
	else
		b = b + 1
		cou = cou + 1
		write(*,*) j1
		if(cou == k) then
		goto 300
		endif
	endif

enddo

300 continue


end program

Measured memory_bytes: 896
def main():
    n, m = map(int, input().split())
    l = []
    r = []
    ans = 0
    for i in range(m):
        a, b = map(int, input().split())
        l.append(a)
        r.append(b)
    ml = max(l)
    mr = min(r)
    for i in range(1, n+1):
        if i >= ml and i <= mr:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N;

  while(cin >> N){
    vector<i64> A(N); cin >> A;

    vector<pair<i64, int>> b(N);
    REP(i,N) b[i] = make_pair(A[i], i);
    sort(RALL(b));

    auto dp = make_vector<i64>(N+1, N+1, 0);

    REP(i,N){
      auto &[v, k] = b[i];
      
      REPE(j,i){
        int l = i-j;
        int r = j;
        
        chmax(dp[l+1][r], dp[l][r] + v * abs(l-k));
        chmax(dp[l][r+1], dp[l][r] + v * abs(N-1-r-k));
      }
    }
    /*
    REPE(i,N){
      REPE(j,N){
        cerr << setw(3) << dp[i][j] << " ";
      }
      cerr << "\n";
    }
    */
    i64 ans = 0;

    REPE(i,N){
      chmax(ans, dp[i][N-i]);
    }
    
    pout(ans);
  }


  return 0;
}


Measured memory_bytes: 34620
N = int(input())
happy = [[] for _ in range(3)]

for _ in range(N):
	a, b, c = list(map(int, input().split()))
	happy[0].append(a)
	happy[1].append(b)
	happy[2].append(c)
	
dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(1, N + 1):
	dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + happy[0][i - 1]
	dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + happy[1][i - 1]
	dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + happy[2][i - 1]
print(max(dp[N]))

Measured memory_bytes: 80424
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    string a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    int dp[n][m];
    rep(i, 0, n) {
        rep(j, 0, m) {
            dp[i][j] = inf;
            if (i == 0 && j == 0) {
                dp[i][j] = 0;
            } else {
                if (i > 0) {
                    setmin(dp[i][j], dp[i - 1][j] + (a[i][j] != a[i - 1][j]));
                }
                if (j > 0) {
                    setmin(dp[i][j], dp[i][j - 1] + (a[i][j] != a[i][j - 1]));
                }
            }
        }
    }
    if (a[0][0] == '#' && a[n - 1][m - 1] == '#') {
        cout << dp[n - 1][m - 1] / 2 + 1 << "\n";
    } else {
        cout << (dp[n - 1][m - 1] + 1) / 2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] list = new long[n + 1];
		long[] sum = new long[n + 1];
		sum[0] = 0;
		for(int i = 1; i < n + 1; i++) {
			list[i] = sc.nextLong();
			sum[i] = sum[i - 1] + list[i];
		}
		long ans = 0;
		int l = 1;
		int r = 1;
		long tmp = 0;
		while(l < n + 1) {
			while(r < n + 1 && (tmp ^ list[r]) == tmp + list[r]) {
				tmp += list[r];
				r++;
			}
			ans += r - l;
			tmp -= list[l];
			l++;
		}
		System.out.println(ans);
	}

}


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

int main() {
  for(int N; cin >> N && N;) {
    vector<vector<int> > G(N, vector<int>(N));
    for(int i = 0; i < N; ++i) {
      int M; cin >> M;
      while(M--) {
        int p; cin >> p;
        --p;
        G[i][p] = 1;
      }
    }
    int K; cin >> K;
    vector<int> A(N);
    while(K--) {
      int l; cin >> l;
      --l;
      A[l] = 1;
    }
    vector<int> res;
    for(int i = 0; i < N; ++i) {
      bool flag = true;
      for(int j = 0; j < N; ++j) {
        if(A[j] && !G[i][j]) {
          flag = false;
          break;
        }
      }
      if(flag) res.push_back(i);
    }
    if(res.size() == 1) {
      cout << res[0]+1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 100000 + 5;

int num[MAXN];
bool ok[MAXN];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::fill(num + 1, num + n + 1, 1);
  ok[1] = 1;
  For(i, 1, m) {
    int x, y;
    scanf("%d%d", &x, &y);
    -- num[x], ++ num[y];
    ok[y] |= ok[x];
    if (!num[x]) {
      ok[x] = 0;
    }
  }
  int answer = 0;
  For(i, 1, n) {
    answer += ok[i];
  }
  printf("%d\n", answer);
  return 0;
}

Measured memory_bytes: 768
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 12) << endl;

}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tl = sc.nextInt();
        int cost[] = new int[n];
        int min = 1001;
        for(int i = 0; i < n; i++){
        	cost[i] = sc.nextInt();
            if(sc.nextInt() <= tl && cost[i] < min){
            	min = cost[i];
            }
        }
        if(min == 1001){
        	System.out.println("TLE");
        }else{
        	System.out.println(min);
        }
    }
}

Measured memory_bytes: 36012
def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if s[h][w] != '#':
                continue
            flg = False
            for dh, dw in zip([-1, 0, 0, 1], [0, -1, 1, 0]):
                if h + dh >= 0 and H > h + dh and \
                    w + dw >= 0 and W > w + dw and \
                        s[h + dh][w + dw] == '#':
                    flg = True
                    break
            if flg is False:
                print('No')
                exit()

    print('Yes')


main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<long long> a;
int main(){
	int n,k;
	cin>>n>>k;
	long long count=0;
	for(int i=0;i<n;i++){
		long long h;
		cin>>h;
		a.push_back(h);
	}
	if(k>=n){
		cout<<0;
		return 0;
	}
	sort(a.begin(),a.end());
	for(int i=n-k-1;i>=0;i--){
		count+=a[i];
	}
	cout<<count;

} 

Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int C = scan.nextInt();
    if(A == B){
      System.out.println(C);
    }
    else if(B == C){
      System.out.println(A);
    }
    else{
      System.out.println(B);
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <numeric>

int main() {
  unsigned int N, M;
  std::cin >> N >> M;
  std::vector<unsigned long> H_array(N);
  for (unsigned int i = 0; i < N; ++i) {
    std::cin >> H_array.at(i);
  }

  std::vector<int> ans_array(N, 1);
  for (unsigned int i = 0; i < M; ++i) {
    unsigned int a, b;
    std::cin >> a >> b;
    a -= 1;
    b -= 1;
    if (H_array.at(a) < H_array.at(b)) {
      ans_array.at(a) = 0;
    } else if ((H_array.at(a) > H_array.at(b))) {
      ans_array.at(b) = 0;
    } else {
      ans_array.at(a) = 0;
      ans_array.at(b) = 0;
    }
  }

  std::cout << std::accumulate(ans_array.begin(), ans_array.end(), 0) << std::endl;

  return 0;
}


Measured memory_bytes: 4580
N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N - 1)]
for n in range(N - 1):
  t = 0
  for i in range(n, N - 1):
    if t < CSF[i][1]:
      t = CSF[i][1]
    elif not (t % CSF[i][2] == 0):
      t += CSF[i][2] - (t % CSF[i][2])
    t += CSF[i][0]
  print(t)
print(0)


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
string str;
map<string, int>vis;
LL cnt[5];
int n;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		cin >> str;
		if(!vis[str]) {
			if(str[0] == 'M')cnt[0]++;
			else if(str[0] == 'A')cnt[1]++;
			else if(str[0] == 'R')cnt[2]++;
			else if(str[0] == 'C')cnt[3]++;
			else if(str[0] == 'H')cnt[4]++;
		}
		vis[str] = 1;
	}
	int p = 0;
	for(int i = 0; i <= 4; i++)if(cnt[i])p++;
	if(p >= 3) {
		LL sum = 0;
		for(int i = 0; i <= 4; i++)
			for(int j = i + 1; j <= 4; j++)
				for(int k = j + 1; k <= 4; k++)
					if(cnt[i] && cnt[j] && cnt[k])
						sum += cnt[i] * cnt[j] * cnt[k];
		printf("%lld\n", sum);
	}
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define read(n) scanf("%lld",&n)
#define write(x) printf("%lld",x)
#define F(i,n) for(int i = 0;i < n;i++)
#define ll long long
#define MX 100005
#define MOD 1000000007
#define INF 1000000009
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;
ll n, parent[MX], dp[MX][2];
vector<vector<ll> > adj;
void dfs(int u){
	for(ll v:adj[u]){
		if(v != parent[u]){
			parent[v] = u;
			dfs(v);
		}
	}
}
ll solve(ll u, bool color){
	if(dp[u][color] == -1){
		ll ans = 1;
		for(ll v:adj[u]){
			if(v == parent[u]) continue;
			if(color)
				ans *= solve(v, 0);
			else{
				ans *= (solve(v, 0) + solve(v, 1));
				ans %= MOD;
			}
			ans %= MOD;
		}
		dp[u][color] = ans;
	}
	return dp[u][color];
}
int main(){

	read(n);

	adj = vector<vector<ll> >(n, vector<ll>());

	F(i, n - 1){
		ll u, v;
		read(u), read(v);
		adj[u - 1].push_back(v - 1);
		adj[v - 1].push_back(u - 1);
	}

	dfs(0);

	set_dp(dp);

	ll ans = (solve(0, 0) + solve(0, 1)) % MOD;

	write(ans);

	return 0;
}


Measured memory_bytes: 14976
n=int(input())
#al=list(map(int,input().split()))
bl=list(map(int,input().split()))	
#cl=list(map(int,input().split()))	

al=[0 for i in range(n)]


al[0]=bl[0]
al[1]=bl[0]

for i in range(1,n-1):
  if bl[i] >= bl[i-1]:
    al[i]=bl[i-1]
    al[i+1]=bl[i]
  else :
    al[i]=bl[i]
    al[i+1]=bl[i]
print(sum(al))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(100);
ll n;
ll a[2000009];
bool check(string s,string t)
{
    int n1=s.length(),n2=t.length(),j=0;
    for(int i=0;i<n1;i++)
    {
    if(s[i]==t[j])
            j++;
        if(j==n2)
            return 1;
    }
    return 0;
}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:52
   int n,s=0;
   cin>>n;

   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       s+=a[i];
   }
   if(s%10)
    return cout<<s,0;
   sort(a,a+n);
   for(int i=0;i<n;i++)
   {
       int u=s;
       if(a[i]%10)
        return cout<<s-a[i],0;
   }
   cout<<0;
}


Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class KStones {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            boolean[][] memo = new boolean[k + 1][2];
            for (int i = 0; i <= k; i++)
                memo[i][1] = true;
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            for (int i = 1; i <= k; i++) {
                for (int player = 0; player < 2; player++) {
                    if (player == 0) {
                        for (int j = 0; j < n; j++)
                            if (arr[j] <= i)
                                memo[i][player] |= memo[i - arr[j]][player ^ 1];
                    } else {
                        for (int j = 0; j < n; j++)
                            if (arr[j] <= i)
                                memo[i][player] &= memo[i - arr[j]][player ^ 1];
                    }
                }
            }
            pw.println(memo[k][0] ? "First" : "Second");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 29348
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[6];
int main(){
  rd(S);
  sort(S,S+4);
  if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190626-1

// --- original code ---
// char S[6];
// {
//   rd(S);
//   sort(S,S+4);
//   wt(if[S[0]==S[1] && S[1]!=S[2] && S[2]==S[3], "Yes", "No"]);
// }


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

bool cmp(pair<ll,ll>a,pair<ll,ll>b)
{
	return a.first>b.first;
}

int main()
{
	int n,k;
	cin >> n >> k;
	vector<pair<ll,ll>> cmt,a,b;
	map<ll,ll> mp;
	for(int i = 0;i<n;i++)

	{
		ll x,y;
		cin >> x >> y;
		cmt.emplace_back(y,x);
	}
	sort(cmt.begin(),cmt.end(),cmp);
	for(int i = 0;i<n;i++)
	{
		ll x;
		x = cmt[i].second;
		ll y ;
		y = cmt[i].first;
		if(mp[x]==0)
		{
			a.emplace_back(y,x);
			mp[x] = true;
		}
		else
		{
			b.emplace_back(y,x);
		}
	}
	set<int> st;
	
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end(),cmp);
	vector<ll> asum(a.size()+1),bsum(b.size()+1);
	for(int i = 0;i<a.size();i++)
	{
		asum[i+1] += a[i].first+asum[i];
	}
	for(int i = 0;i<b.size();i++)
	{
		bsum[i+1] += b[i].first+bsum[i];
	}
	ll ans = 0;
	set<ll> A,B;
	
	for(int i = 1;i<=k;i++)
	{
		ll now = 0;

		if(i<asum.size())
		{
			now += asum[i];
			A.insert(a[i-1].second);
			if(B.find(a[i-1].second)!=B.end())
			{
				B.erase(B.find(a[i-1].second));
			}
		}
		else continue;
		if(k-i<bsum.size())
		{
			now += bsum[k-i];
			if(A.find(a[i-1].second)==A.end())B.insert(b[i-1].second);
		}
		else continue;
		ll x = A.size()+B.size();
		now += x*x;
		ans = max(ans,now);
	}
	cout<<ans<<endl;


}

Measured memory_bytes: 12784
N, X, Y = gets.chomp.split(" ").map(&:to_i)

A = Array.new(N*N)

1.upto(N-1) do |k|
  ans = 0
  1.upto(N-1) do |i|
    c0 = i + k
    if c0 <= N
      if A[i * N + c0].nil?
        A[i * N + c0] = k
        ans += 1
      end
      if (i <= X && i + k > X) || (i > X && i - X < k)
        s = k - ((X - i).abs + 1)
        cs = [Y+s, Y-s]
        cs = [Y] if s.zero?
        cs.select{|v| v <= N && v != i && (v - i).abs > k }.each do |c|
          a, b = [i, c]
          a, b = [b, a] if a > b
          if A[a * N + b].nil?
            A[a * N + b] = k
            ans += 1
          end
        end
      end
    end
  end
  puts ans
end


Measured memory_bytes: 33788
// Popular Vote

func main() {
    let m = readLine()!.split(separator: " ").map{Int($0)!}[1]
    let a = readLine()!.split(separator: " ").map{Int($0)!}.sorted(by: >)
    
    let sum = a.reduce(0, +)

    if a[m-1] * 4 * m < sum {
        print("No")
    } else {
        print("Yes")
    }
}

main()

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

const int C = 26;
const int D = 365;

int d;
int c[C];
int s[D][C];

vector<int> t;

void read() {
  scanf("%d", &d);
  for (int i = 0; i < C; ++i) scanf("%d", &c[i]);
  for (int i = 0; i < d; ++i) {
    for (int j = 0; j < C; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
}

int score[D];
int lst[D];
int eval(vector<int> t) {
  int cur = 0;
  for (int i = 0; i < D; ++i) lst[i] = -1;
  for (int i = 0; i < t.size(); ++i) {
    cur += s[i][t[i]];
    lst[t[i]] = i;
    for (int j = 0; j < C; ++j) {
      cur -= (i - lst[j]) * c[j];
    }

    score[i] = cur;
  }

  return cur;
}

void solve() {
  for (int i = 0; i < d; ++i) {
    t.push_back(0);
    for (int j = 1; j < C; ++j) {
      vector<int> nt = t;
      t.back() = j;

      if (eval(nt) > eval(t)) {
        t = nt;
      }
    }
  }

  for (int k = 50; k > 0; k >>= 1) for (int kk = 0; kk < 5; ++kk) {
    vector<int> v(d);
    iota(v.begin(), v.end(), 0);
    random_shuffle(v.begin(), v.end());
    v.resize(k);

    vector<int> nt = t;
    for (int u: v) {
      while (nt[u] == t[u]) nt[u] = rand() % 26;
    }
    if (eval(nt) > eval(t)) t = nt;
  }

  for (int k = 0; k < 15; ++k) {
    for (int i = 0; i < d; ++i) {
      for (int j = 0; j < C; ++j) {
        vector<int> nt = t;
        nt[i] = j;
        if (eval(nt) > eval(t)) t = nt;
      }
    }
  }
}

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

void printScore() {
  eval(t);
  for (int i = 0; i < d; ++i) printf("%d\n", score[i]);
}

int main() {
  read();
  solve();
  print();
  // cerr << eval(t) << endl;
  // printScore();
  return 0;
}


Measured memory_bytes: 3940
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
ll n;
vector<ll> g[N];
class Dist{
  public:
  ll d[N];
  void dfs(ll x,ll from,ll dep){
    d[x]=dep;
    for(auto y:g[x])if(y!=from){
      dfs(y,x,dep+1);
    }
  }
  ll main(ll s){
    dfs(s,0,0);
    ll ma=0,pnt=0;
    for(int i=1;i<=n;i++){
      if(d[i]>ma)ma=d[i],pnt=i;
    }
    return pnt;
  }
};
vector<ll> path;
bool dfs(ll x,ll from,ll p){
  path.push_back(x);
  if(x==p)return 1;
  for(auto y:g[x])if(y!=from){
    if(dfs(y,x,p))return 1;
  }
  path.pop_back();
  return 0;
}

ll ans[N];
void solve(){
    ans[1]=1; ll t=1;
    for(int i=1;i<path.size()-1;i++){
      ll k=g[path[i]].size()-2;
      ans[t+k+1]=t+1;
      for(int j=1;j<=k;j++)ans[t+j]=t+1+j;
      t+=k+1;
    }
    ans[n]=n;
}
ll res[N];
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
      ll a,b;cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    Dist A,B;
    ll a=A.main(1);
    ll b=B.main(a);
    dfs(a,0,b);
    ll sum=path.size();
    for(int i=1;i<path.size()-1;i++){
      sum+=g[path[i]].size()-2;
    }
    
    if(sum!=n){
      cout<<-1<<endl;
      return 0;
    }
    solve(); for(int i=1;i<=n;i++)res[i]=ans[i];
    reverse(path.begin(),path.end());
    solve();
    //for(int i=1;i<=n;i++)cout<<res[i]<<" ";cout<<endl;
    //for(int i=1;i<=n;i++)cout<<ans[i]<<" ";cout<<endl;
    bool smaller=0;
    for(int i=1;i<=n;i++){
      if(res[i]<ans[i]){smaller=1;break;}
      if(res[i]>ans[i])break;
    }
    if(smaller)for(int i=1;i<=n;i++)ans[i]=res[i];
    for(int i=1;i<=n;i++){
      if(i>1)cout<<" ";
      cout<<ans[i];
    }cout<<endl;
    return 0;
}



Measured memory_bytes: 16628
n,m=map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
for i in range(len(make_divisors(m))):
  if make_divisors(m)[i]<=(m//n):
    break
print(make_divisors(m)[i])

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

int w, a, b;

int get_space(int a, int b){
    return max(0, b - a);
}

int main(){
    scanf("%d %d %d", &w, &a, &b);
    if(a > b) swap(a,b);
    int competitor[] = {get_space(a,b), get_space(a,b+w), get_space(a+w,b), get_space(a+w,b+w)};
    printf("%d\n", *min_element(competitor, competitor + 4));
    return 0;
}

Measured memory_bytes: 256
# 2019/05/12
# AtCoder Beginner Contest 098 - A

# Input
a, b = map(int, input().split())

# Calc
c_max = a + b
mi = a - b
ti = a * b

if c_max < mi:
    c_max = mi
if c_max < ti:
    c_max = ti
    
# Output
print(c_max)


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d;
long long max(long long a, long long b, long long c, long long d)
{
	long long res = max(a, b);
	res = max(res, c);
	res = max(res, d);
	return res;
}
int main() {
	cin >> a >> b >> c >> d;
	vector<int> possibleVals;
	
	long long res = max(a * c, a * d, b * c, b * d);
	cout << res;
	return 0;
}

Measured memory_bytes: 3520