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

#define ll              long long int
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fast_io         ios_base::sync_with_stdio(false); cin.tie(NULL);


int dfs(vector<vector<int>> &adjList, vector<int> &dp, int i){
	dp[i] = 1;
	int ans = 0;

	for(auto child:adjList[i]){
		if(dp[child] == 0){
			ans = max(ans, dfs(adjList, dp, child));
		}
		else{
			ans = max(ans, dp[child]);
		}
	}

	dp[i] += ans;
	return dp[i];
}


int main(){
    fast_io;
    
    int n, m;
    cin >> n >> m;

    if(n == 0 or m == 0){
    	cout<<"0\n";
    	return 0;
    }

    vector<vector<int>> adjList(n+1);
    int u, v;

    for(int i=0; i<m; i++){
    	cin >> u >> v;
    	adjList[u].pb(v);
    }

    vector<int> dp(n+1, 0);
    int ans = 1;

    for(int i=1; i<=n; i++){
    	if(dp[i] == 0){
    		int temp = dfs(adjList, dp, i);
    	}
    	ans = max(ans, dp[i]);
    }

    cout << (ans-1) << "\n";
    
	return 0;
}

Measured memory_bytes: 9600
fun main(args:Array<String>):Unit {
    val n = readLine()!!.toInt()
    for (i in 0 until factorial(n)){
        println(toPermutation(n, i).joinToString(" "))
    }
}
fun factorial(n:Int):Int{
    return when(n){
        0 -> 1
        else -> n * factorial(n - 1)
    }
}
fun toPermutation(length:Int, value:Int):Array<Int>{
    val res = Array(length){it + 1}
    var num = value
    for (i in 0 until length){
        val n = num / factorial(length - 1 - i)
        val temp = res[i + n]
        for (j in n downTo 1) res[i + j] = res[i + j - 1]
        res[i] = temp
        num %= factorial(length - 1 - i)
    }
    return res
}
fun toRank(array:Array<Int>):Int {
    val res = Array(array.size){it + 1}
    var num = 0
    for (i in 0 until array.size){
        val n = res.indexOfFirst { it == array[i] } - i
        num += n * factorial(array.size - 1 - i)
        val temp = res[i + n]
        for (j in n downTo 1) res[i + j] = res[i + j - 1]
        res[i] = temp
    }
    return num
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 500;
ll N;
ll C[MAX_N], S[MAX_N], F[MAX_N];


ll arrival_time(ll i, ll t){
   if(i == N - 1){
      //already arrived
      return t;
   }
   else{
      ll temp;
      (t <= S[i]) ? temp = S[i] + C[i] : temp = ((t + F[i] - 1) / F[i]) * F[i] + C[i];
      return arrival_time(i + 1, temp);
   }
}

int main(){
   cin >> N;
   REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];
   REP(i, N) cout << arrival_time(i, 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n, x;
    cin >> n;
    for (int i=1; i<=n; i++){
        x = i;
        if (x%3 == 0){
            cout << " " << i;
        } else {
            while (x){
                if (x%10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int flag = 1;
	for(int i=0;i<s.length();i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
			continue;
		else flag = 0;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,ans=0;
    cin >> n;
    ll x[n],sum=0;
    for (ll i=0;i<n;i++){
        cin >> x[i];
        sum+=x[i];
    }
    for (ll i=0;i<n;i++){
        ans+=x[i]*(sum-x[i]);
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s="1974";
	string t;
	rep(i,4){
		string n;cin>>n;
		t+=n;
	}
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	if(s==t)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
#include <stdio.h>

//構造体
typedef struct dice
{
	int Upper;
	int South;
	int East;
	int West;
	int North;
	int Under;
} Dice;

//構造体を初期化する
Dice InitDice(void);
//配列を初期化する
void InitOpe(char* ope, int n);
//要素を入れ替える
Dice ChangeNum_East(Dice Dice);
Dice ChangeNum_West(Dice dice);
Dice ChangeNum_North(Dice dice);
Dice ChangeNum_South(Dice dice);

#define opeMax 100
#define diceFace 6

int main(void)
{
	Dice dice = InitDice();
	char ope[opeMax];
	int arr[diceFace];
	int i;

	InitOpe(ope, opeMax);

	//ラベルにデータを入力する
	for (i = 0; i < 6; i++)
	{
		arr[i] = 0;
		scanf("%d", &arr[i]);
	}

	dice.Upper = arr[0];
	dice.South = arr[1];
	dice.East = arr[2];
	dice.West = arr[3];
	dice.North = arr[4];
	dice.Under = arr[5];

	//命令を入力する
	scanf("%s", ope);


	for (i = 0; ope[i] != '\0'; i++)
	{
		switch (ope[i])
		{
		case 'E':
			dice = ChangeNum_East(dice);
			break;
		case 'N':
			dice = ChangeNum_North(dice);
			break;
		case 'S':
			dice = ChangeNum_South(dice);
			break;
		case 'W':
			dice = ChangeNum_West(dice);
			break;
		default:
			break;
		}
	}

	printf("%d\n", dice.Upper);

	return 0;
}

//構造体を初期化する
Dice InitDice(void)
{
	Dice di;
	di.Upper = 0;
	di.South = 0;
	di.East = 0;
	di.West = 0;
	di.North = 0;
	di.Under = 0;
	return di;
}

//配列を初期化する
void InitOpe(char* ope, int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		ope[i] = '\0';
	}
}

//E方向に転がしたとき
Dice ChangeNum_East(Dice dice)
{
	Dice di = InitDice();
	di.Upper = dice.West;
	di.South = dice.South;
	di.East = dice.Upper;
	di.West = dice.Under;
	di.North = dice.North;
	di.Under = dice.East;
	return di;
}

//W方向に転がしたとき
Dice ChangeNum_West(Dice dice)
{
	Dice di = InitDice();
	di.Upper = dice.East;
	di.South = dice.South;
	di.East = dice.Under;
	di.West = dice.Upper;
	di.North = dice.North;
	di.Under = dice.West;
	return di;
}

//N方向に転がしたとき
Dice ChangeNum_North(Dice dice)
{
	Dice di = InitDice();
	di.Upper = dice.South;
	di.South = dice.Under;
	di.East = dice.East;
	di.West = dice.West;
	di.North = dice.Upper;
	di.Under = dice.North;
	return di;
}

//S方向に転がしたとき
Dice ChangeNum_South(Dice dice)
{
	Dice di = InitDice();
	di.Upper = dice.North;
	di.South = dice.Upper;
	di.East = dice.East;
	di.West = dice.West;
	di.North = dice.Under;
	di.Under = dice.South;
	return di;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
unsigned long long INF=999999999999999999;
int n,k;
int h[999999];
long long dp[100007];
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=1;i<n;i++){
        dp[i]=INF;
        for(int j=1;j<=k;j++){
            if(i-j>=0) dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1408
n, m = gets.split.map(&:to_i)

count = 0
price = 0
shops = n.times.map do
  gets.split.map(&:to_i)
end
shops.sort_by{|a, b| a}.each do |a, b|
  if m > count + b
    price += a * b
    count += b
  else
    price += (m-count)*a
    break
  end
end

puts price

Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k,ans=1;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		ans*=k;
		if(i==0){
			k--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int n, long long k, vector< pair<int,int> > vpi) {
    sort(vpi.begin(), vpi.end());
    int counter = 0;
    long long num_from_min = 0;
    while (k > num_from_min) {
        num_from_min += vpi[counter].second;
        counter++;
    }
    counter--;
    std::cout << vpi[counter].first << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;
    long long k;

    gettimeofday(&start,NULL);

    std::cin >> n >> k;
    vector< pair<int,int> > vpi(n);
    for (int i = 0; i < n; i++) {
        std::cin >> vpi[i].first >> vpi[i].second;
    }
    solve(n, k, vpi);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdlib.h>
using namespace std;

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

	if ((b-1) % (a-1) == 0)
		cout << (b-1) / (a-1) << endl;
	else if (b == 1)
		cout << 0 << endl;
	else
		cout << ((b-1) / (a-1)) + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define P pair <int ,int>
#define int LL
using namespace std;
const int N   = 1e5+10;
//const int mod = ;
const int INF =numeric_limits<int >::max();

#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
P st[3*N];
int n,tp,a[N],b[N],c[N],f[N*3],x,cnt[4],bo[3*N];
LL ans;
signed main()
{
	read(n);
	rep(i,1,n) read(a[i]),st[++tp]=mp(a[i],1);
	rep(i,1,n) read(b[i]),st[++tp]=mp(b[i],2);
	rep(i,1,n) read(c[i]),st[++tp]=mp(c[i],-3);
	sort(a+1,a+1+n);sort(b+1,b+1+n);sort(c+1,c+1+n);
	for (int i=n,j=n; i; i--){	
		for (; j && c[j]>b[i]; j--);	
		f[i]=f[i+1]+n-j;
	}
	for (int i=n,j=n; i; i--){
		for (; j && b[j]>a[i]; j--);
		ans+=f[j+1];
	}
	return printf("%lld",ans),0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	llint a, b;
	cin >> a >> b;
	llint x = GCD(a, b);
	llint ans = 1;
	for (llint i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			ans++;
			while (x % i == 0)x /= i;
		}
	}
	if (x != 1)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.Array.IO               as AM
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt

  as <- VM.new n
  bs <- VM.new n
  cs <- VM.new n
  forM_ [0..n-1] $ \i -> do
    [a, b, c] <- getIntList
    VM.write as i a
    VM.write bs i b
    VM.write cs i c

  dp <- AM.newArray ((0,0),(n-1,2)) 0 :: IO (AM.IOUArray (Int,Int) Int)

  a0 <- VM.read as 0
  b0 <- VM.read bs 0
  c0 <- VM.read cs 0
  AM.writeArray dp (0,0) a0
  AM.writeArray dp (0,1) b0
  AM.writeArray dp (0,2) c0

  forM_ [1..n-1] $ \i -> do
    ai <- VM.read as i
    bi <- VM.read bs i
    ci <- VM.read cs i
    dp0 <- AM.readArray dp (i-1, 0)
    dp1 <- AM.readArray dp (i-1, 1)
    dp2 <- AM.readArray dp (i-1, 2)
    AM.writeArray dp (i,0) (max dp1 dp2 + ai)
    AM.writeArray dp (i,1) (max dp2 dp0 + bi)
    AM.writeArray dp (i,2) (max dp0 dp1 + ci)

  dp0 <- AM.readArray dp (n-1, 0)
  dp1 <- AM.readArray dp (n-1, 1)
  dp2 <- AM.readArray dp (n-1, 2)

  let ans = max dp0 (max dp1 dp2)
  print ans

Measured memory_bytes: 6524
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  co((A - 1) * (B - 1));
}

Measured memory_bytes: 256
k = int(input())

f = 0
now = 0
a = [0] * k

for i in range(k):
    now = (now * 10 + 7) % k
    if(now == 0):
        print(i+1)
        f = 1
        break
    if(a[now] == 1): break
    a[now] = 1

if f == 0:
    print(-1)

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

int main () {
  int N, a1000, a100, a10, a1;
  cin >> N;
  a1000 = N / 1000;
  a100 = (N - a1000 * 1000) / 100;
  a10 =  (N - a1000 * 1000 - a100 * 100) / 10;
  a1 =  (N - a1000 * 1000 - a100 * 100 - a10 * 10);
  
  if (((a1000 == a100) && (a100 == a10)) ||((a100 == a10) && (a10 == a1))){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

int main(){
    int L;
    cin >> L;
    cout << fixed;
    cout << setprecision(12) << (L*L*L/27.0) << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

struct state{
  int v,r,d;
};

bool operator<(const state &a,const state &b){
  return a.d > b.d;
}

int n,m,C;
string src,dst;
int S,T;
map<string,int> idx;
vector<P> g[6000];
bool aru[6000];
int dist[6000][2010];
int V=0;

int getidx(string s){
  if(idx.find(s)!=idx.end())return idx[s];
  idx[s]=V++;
  return idx[s];
}

int main(){
  while(1){
    cin>>m>>n>>C;
    if(m==0&&n==0)break;

    idx.clear();
    rep(i,6000)g[i].clear();
    memset(aru,0,sizeof(aru));
    V=0;

    cin>>src>>dst;
    S=getidx(src);
    T=getidx(dst);
    rep(i,m){
      string a,b;
      int d;
      cin>>a>>b>>d;
      g[getidx(a)].push_back(P(getidx(b),d));
      g[getidx(b)].push_back(P(getidx(a),d));
    }
    rep(i,n){
      string a;
      cin>>a;
      aru[getidx(a)]=true;
    }

    priority_queue<state> que;
    que.push((state){S,C*10,0});
    rep(i,V)rep(j,C*10+1)dist[i][j]=INF;
    while(que.size()){
      state s=que.top(); 
      que.pop();
      if(dist[s.v][s.r]!=INF)continue;
      dist[s.v][s.r]=s.d;
      for(P e : g[s.v]){
        if(s.r<e.se)continue;
        que.push((state){e.fi,s.r-e.se,s.d+e.se});
      }
      if(s.r<C*10&&aru[s.v]){
        que.push((state){s.v,C*10,s.d});
      }
    }

    int res=INF;
    rep(j,C*10+1)minch(res,dist[T][j]);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}



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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)

// void solve() 
// {


//     return;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // int t=1;
    // cin>>t;
    // while(t--)
    // {
    //     solve();     
    // }

   int a,b,k;
    cin>>k>>a>>b;
    b=b/k;
    if(a%k==0)
        a=a/k-1;
    else a=a/k;
    if(b-a>0)
        cout<<"OK";
    else cout<<"NG";



}
 

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i , L , R) for( i = L ; i < R ; i++)
#define per(i,L,R) for( i = L; i >= R; i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] << (i==R?'\n':' ')
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

int main()
{
   SPEED
//   ll q,i,l,r;
//   string s;
//   cin>>s;
//   ll n = s.length();
//   ll a[n+1]={0};
//   rep(i,0,n-1)
//   {
//       if(s[i]==s[i+1])
//        a[i+1]=1;
//   }
//   printa(a,0,n+1);
//   cout<<"\n";
//   rep(i,1,n+1)
//   {
//       a[i]=a[i]+a[i-1];
//   }
//
//  // printa(a,0,n);
//   cin>>q;
//   while(q--)
//   {
//       cin>>l>>r;
//       cout<<a[r-1]-a[l-2]<<"\n";
//   }
     ll a,b,i,s=0;
     cin>>a>>b;
     ll n = gcd(a,b);
     set <ll> st;
      while (n % 2 == 0)
    {
        //cout << 2 << " ";
        st.insert(2);
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            //cout << i << " ";
            st.insert(i);
            n = n/i;
        }
    }
    if (n > 2)
        st.insert(n);
    cout<<st.size()+1<<"\n";
        //cout << n << " ";
}












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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	int ans = N;
	for (int i = 0; i < M; i++){
		cin >> A[i];
		ans -= A[i];
	}
	
	cout << (ans < 0 ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 3668
# _*_ coding:utf-8 _*_

import sys

input = sys.stdin.readline().replace('\n','')
ans  = 1000

for c in input:
	s = input.split(c)
	ma = 0
	for i in range(len(s)):
		if ma < len(s[i]):
			ma = len(s[i])
	
	if ans > ma:
		ans = ma
		
print(ans,end='') 

Measured memory_bytes: 3060
#include<iostream>

using namespace std;


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

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long N = B - A + 1; 
    long long count = 0;
    long long  LCM = C * D / gcd(C, D);

    A -= 1;
    long long  c = B / C - A / C;
    long long  d = B / D - A / D;
    long long  lcm = B / LCM - A / LCM;
    cout << N - (c + d -lcm) << endl;
/*
    if(LCM < A){
        cout << N - (B / LCM - A / LCM) << endl; 
    }
    else if(A <= LCM && LCM <= B){
        int c = B / C - A / C;
        int d = B / D - A / D;
        cout << N - (B / LCM + c + d) << endl;
    }
    else{
        int c = B / C - A / C;
        int d = B / D - A / D;
        cout << N - (c + d) << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  int n,q,k;
  string s;
  cin>>n>>s>>q;
  rep(_,q){
    cin>>k;
    ll ans=0LL;
    ll d=0,m=0,dm=0;
    rep(i,n){
      if (i-k>=0){
        if (s[i-k]=='D') {--d;dm-=m;}
        if (s[i-k]=='M') --m;
      }
      if (s[i]=='D') ++d;
      if (s[i]=='M') {++m;dm+=d;}
      if (s[i]=='C') ans+=dm;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
string a,b;
int ans;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	getline(cin,a);
	b="CODEFESTIVAL2016";
	for(int i=0;i<16;i++)
	{
		if(a[i]!=b[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAXN 100100

using namespace std;
long long mod = 1000000000;

int main(){
	int dp[MAXN], h[MAXN];
	int n;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> h[i];
		dp[i] = mod;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		if(i + 1 < n){
			dp[i + 1] = min(dp[i] + abs(h[i] - h[i + 1]), dp[i + 1]);
		}
		if(i + 2 < n){
			dp[i + 2] = min(dp[i] + abs(h[i] - h[i + 2]), dp[i + 2]);
		}
	}
	cout << dp[n - 1] << "\n";
	}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;
int a,b;
int main(){
    cin >> a >> b;
    if((a+b)%2 == 1)
        puts("IMPOSSIBLE");
    else
        cout << (a+b)/2 << "\n";
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
class Sieve2: #√nまでの素因数で試し割り 前処理O(√nloglogn+√n/logn)
    def __init__(self,n):
        self.primes=[]
        self.f=[0]*(int(n**0.5)+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,int(n**0.5)+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,int(n**0.5)+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入

    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        for p in self.primes:
            if p*p>x:break
            while x%p==0:
                x//=p
                fact_dict[p]=fact_dict.get(p,0)+1
        if x>1:fact_dict[x]=fact_dict.get(x,0)+1
        return fact_dict

def main():
    n = int(input())
    Sieve = Sieve2(n)
    prime_dict = Sieve.prime_fact(n)
    ans = 0
    for fact in prime_dict.values():
        f = fact
        x = 1
        while f > 0:
            if f >= x:
                ans += 1
            f -= x
            x += 1
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 20216
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let quadro = function
| [|a; b; c; d|] -> (a,b,c,d)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,M,Q) = readTriple int int int ()

let abcd = [| for _ in 1..Q -> reads int () |> quadro |]

let rec A n m =
  if n=0 then Seq.singleton []
  else seq {
    for a in m..M do
      yield!
        A (n-1) a
        |> Seq.map (fun l -> a::l)
  }

A N 1
|> Seq.map (List.toArray >> (fun s ->
  let r =
    abcd
    |> Array.fold (fun sum (a,b,c,d) -> sum + if (s.[b-1]-s.[a-1])=c then d else 0) 0
  r
))
|> Seq.max
|> printfn "%d"


Measured memory_bytes: 43136
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int sum=0;
  int N=s.size();
  vector<int>vec(N);
  reverse(s.begin(),s.end());
  for(int i=0;i<N;i++)vec[i]=s[i]-'0';
  for(int i=0;i<N;i++){
    if(vec[i]<5)sum+=vec[i];
    else if(vec[i]==5){
      if(i!=N-1 &&vec[i+1]>=5){
        vec[i+1]++;
        sum+=5;
      }
      else sum+=5;
    }
    else {
      
      sum+=10-vec[i];
      if(i!=N-1)vec[i+1]++;
      else sum++;
    }
  }
  
    cout<<sum<<endl;
  }
 


Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    string s;
    cin>>s;
    bool x=true;
    REP(i,s.length()/2){
        if(s[i]-s[s.length()-1-i]!=0) x=false;
    }
    REP(i,s.length()/4){
        if(s[i]-s[s.length()/2-1-i]!=0) x=false;

    }

    for(int i=0;i<(s.length()-(s.length()+3)/2)/2;i++){
        if(s[(s.length()+3)/2-1+i]-s[s.length()-1-i]!=0) x=false;

    }
    if(x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long a,b,n,s,i,j;
while(cin>>a){
cin>>b>>n;
while(a>=b)a-=b;
for(s=i=0;i<n;i++){
a*=10;
for(j=0;j<9;j++){if(a<b)break;a-=b;}
s+=j;
}
cout<<s<<endl;
}
return 0;
}

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  
const ll INF =1e18L + 5;

void solve() {
    ll n, W;
    cin >> n >> W;
    vector<ll> value(n), weight(n);
    for (ll i = 0; i < n; ++i) {
        cin >> weight[i] >> value[i];
    }
    ll sum = 0;
    for (auto x : value) sum += x;
    vector<ll> dp(sum + 1, INF);
    dp[0] = 0;
    for (ll i = 0; i < n; ++i) {
        for (ll j = sum - value[i]; j >= 0; --j) {
            dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= sum; ++i) {
        if (dp[i] <= W) {
            ans = max(ans, i);
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

//  freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr); 
//  freopen ("out.txt", "w", stdout);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3960
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 500005
#define sentinel 2000000000

int L[maxn/2+2],R[maxn/2+2];
long long cnt;

void _merge(int a[],int n,int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;++i)
        L[i]=a[left+i];
    for(int i=0;i<n2;++i)
        R[i]=a[mid+i];
    L[n1]=R[n2]=sentinel;
    int i=0,j=0;
    for(int k=left;k<right;++k)
    {
        cnt++;
        if(L[i]<R[i])
            a[k]=L[i++];
        else
            a[k]=R[j++];
    }
}
void mergesort(int a[],int n,int left,int right)
{
    if(left+1<right)
    {
        int mid=(left+right)>>1;
        mergesort(a,n,left,mid);
        mergesort(a,n,mid,right);
        _merge(a,n,left,mid,right);
    }
}
int a[maxn],n;
int main()
{
    cin>>n;
    for(int i=0;i<n;++i)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;++i)
    {
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    mergesort(a,n,0,n);


    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	int N;
	cin >> N;

	string A, B, C;
	cin >> A >> B >> C;

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int dif = 0;
		if (A[i] != B[i]) {
			dif++;
		}
		if (!(A[i] == C[i] || B[i] == C[i])) {
			dif++;
		}
		ans += dif;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k, ans = 0;
	cin >> n >> k;
	while(n--) {
		int x;
		cin >> x;
		ans += x >= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int, input().split()))
ans=0
a=min(x)
b=max(x)
for i in range(n):
    ans+=(x[i]-a)**2
for i in range(a+1,b+1):
    buf=0
    for j in range(n):
        buf+=(x[j]-i)**2
    if buf<=ans:
        ans=buf
print(ans)

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

int main() {

  int m, n;
  while( cin >> m, m ) {
    int x[m], y[m];
    int ans_x, ans_y;
    for(int i=0; i<m; i++) {
      cin >> x[i] >> y[i];
    }

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

    for(int i=0; i<n; i++) {
      int diff_x = x_[i] - x[0], diff_y = y_[i] - y[0];
      bool flag = true;

      for(int j=1; j<m; j++) {
	bool flag_n = false;
	for(int k=0; k<n; k++) {
	  if( x_[k] - x[j] == diff_x && y_[k] - y[j] == diff_y ) {
	    flag_n = true; 
	    break;
	  }
	}
	if( !flag_n ) {
	  flag = false;
	  break;
	}
      }

      if( flag ) {
	ans_x = diff_x; ans_y = diff_y;
	break;
      }
    }
    
    cout << ans_x << " " << ans_y << endl;
  }
} 

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#define PI 3.1415926

using namespace std;

int main()
{
    int a,b,c,d,f;
    cin>>f;
    a=f/1000;
    b=f/100-a*10;
    c=f/10-a*100-b*10;
    d=f%10;
    if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;return 0;}
    if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;return 0;}
    if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;return 0;}
    if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;return 0;}
    if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;return 0;}
    if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;return 0;}
    if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;return 0;}
    if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;return 0;}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,D;
  	scanf("%d%d%d%d", &A,&B,&C,&D);
  for(int i=0;C-B*(i-1)>0&&A-D*(i-1)>0;i++){
	    if(C-B*i<=0){
	        printf("Yes");
	    }else if(A-D*i<=0){
	        printf("No");
	    }
}
}

Measured memory_bytes: 3228
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();

  let err = String::from("error");

  println!("{}", if a + b < 10 { (a + b).to_string() } else { err })
}



Measured memory_bytes: 4352
X, N = map(int, input().split())
P = set(list(map(int ,input().split())))

for i in range(200):
    if X-i not in P:
        print(X-i)
        exit()
    elif X+i not in P:
        print(X + i)
        exit()
    else:
        continue

print(X)

Measured memory_bytes: 9172
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define EPS 1e-15
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const long long INF = 1LL << 60;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int N, W;

ll w[110];
ll v[110];
ll dp[110][110000];

int main()
{
    cin >> N >> W;
    rep(i, N)
    {
        cin >> w[i] >> v[i];
    }
    rep(i, 110)
    {
        rep(j, 110000)
        {
            dp[i][j] = 0;
        }
    }

    rep(i, N)
    {
        rep(sum_w, W + 1)
        {
            if (sum_w >= w[i]) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << "\n";
}


Measured memory_bytes: 94720
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    string s; cin >> s;

    int depth = 0, ans;
    for (char c : s) {
        if (c == '(') ++depth;
        if (c == ')') --depth;
        if (c == '*') ans = depth;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3236
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val v = readLine()?.split(" ")?.map(String::toDouble) ?: return
    val q = PriorityQueue(v)
    while(q.size > 1){
        val a = q.poll()
        val b = q.poll()
        q.offer((a+b)/2)
    }
    println(q.poll())
}

Measured memory_bytes: 36036
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

void forward(const string& S, int& B) {
    if (S[B+1] != '#') {
        B++;
        return;
    } else if (S[B+2] != '#') {
        B+=2;
        return;
    }
    cout << "No" << endl;
    exit(0);
}

int main() {
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    string S; cin >> S;

    if (A < B && C > D) { // Must jump over
        while (B < D && (S[B-1] == '#' || S[B+1] == '#')) forward(S, B);
        if (B == D) S[B] = '#';
        if (B > D) {
            cout << "No" << endl;
            return 0;
        }
        while (A != C) forward(S, A);
        S[C] = '#';
    }

    if (B != D) {
        while (B != D) forward(S, B);
    }
    if (A != C) {
        while (A != C) forward(S, A);
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int A,B,C;
	cin>>A>>B>>C;
	cout<<(C/A)*B;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  ll mod=998244353;
  ll mp[n],comb[n],inv[n];
  mp[0]=1; comb[0]=1; inv[1]=1;
  mp[1]=m-1; comb[1]=n-1;
  for(int i=2;i<n;i++){
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    mp[i]=(mp[i-1]*(m-1))%mod;
    comb[i]=(comb[i-1]*(n-i))%mod;
    comb[i]=(comb[i]*inv[i])%mod;
  }
  ll ans=0;
  rep(i,k+1){
    ans+=(mp[n-1-i]*comb[i])%mod;
    ans%=mod;
  }
  cout<<(ans*m)%mod;
}


Measured memory_bytes: 8208
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include <stdio.h>

int main()
{
  int n,l,i,sum=0;
  scanf("%d %d",&n,&l);
  int a[n];
  for(i=0;i<n;i++){
    a[i]=l+i;
    sum=sum+a[i];
  }
  if(a[0]>0){
    sum=sum-a[0];
  }else if(a[n-1]<0){
    sum=sum-a[n-1];
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
  int n,l0=2,l1=1;
  long long l_minus2,l_minus1,l;
  cin >> n;
  if(n==1) cout << l1;
  else{
    l_minus1 = 1;
    l_minus2 = 2;
    for(int i=1;i<n;i++){
      l = l_minus1 + l_minus2;
      // ここ逆にするとl_minus1に先にlの値が入ってしまうので注意.
      l_minus2 = l_minus1;
      l_minus1 = l;
    }
    cout << l;
  }
  return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    int n; cin >> n;
    vector<int> x( n ), y( n );
    REP( i, n ){
        cin >> x[i] >> y[i];
    }

    map<P, int> sa;
    REP( i, n ){
        REP( j, n ){
            if( i == j ) continue;
            sa[MP( x[i] - x[j], y[i] - y[j] )]++;
        }
    }

    int t = 0;
    for( auto v : sa ){
        if( v.first.first == 0 && v.first.second == 0 ) continue;
        chmax( t, v.second );
    }

    cout << n - t << endl;
}


Measured memory_bytes: 384
if __name__ == '__main__':
    N,M_a,M_b=list(map(int,input().split()))
    A,B,C=[],[],[]
    for i in range(N):
        a,b,c=list(map(int,input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    dp=[[[1e10 for i in range(sum(B)+max(B)+1)] for j in range(sum(A)+max(A)+1)] for k in range(N+1)]
    dp[0][0][0]=0

    for i in range(N):
        for c_a in range(sum(A)+1):
            for c_b in range(sum(B)+1):
                if dp[i][c_a][c_b]==1e10:
                    continue
                dp[i+1][c_a][c_b]=min(dp[i+1][c_a][c_b],dp[i][c_a][c_b])
                dp[i+1][c_a+A[i]][c_b+B[i]]=min(dp[i+1][c_a+A[i]][c_b+B[i]],dp[i][c_a][c_b]+C[i])
    ans_list=[1e10]
    for c_a in range(1,sum(A)+1):
        for c_b in range(1,sum(B)+1):
            if c_a*M_b==c_b*M_a:
                ans_list.append(dp[N][c_a][c_b])
    ans=min(ans_list)
    if  ans==1e10:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 96440