akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int dmin = INT_MAX;

    rep01(i, s.length() - t.length()) {
        int dif = 0;
        rep(j, t.length()) {
            if (s[i + j] != t[j]) dif++;
        }
        dmin = min(dmin, dif);
    }

    cout << dmin << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1e18;
const double PI = acos(-1);
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main()
{
    int n;
    cin >> n;

    ll a = 1;
    ll b = 1;
    ll c = 1;
    rep(i, n) {
        a = (a * 10) % mod;
        b = (b * 9) % mod;
        c = (c * 8) % mod;
    }

    mint ans(0);
    ans += a;
    ans -= 2 * b;
    ans += c;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

ll po[POW_MAX + 2];

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}

int N;
ll X;
ll b[51], p[51];

int main() {
  scanf("%d %lld", &N, &X);

  b[0] = 1;
  p[0] = 1;
  FOR(i, 1, N + 1) {
    b[i] = 3 + b[i - 1] * 2;
    p[i] = 1 + p[i - 1] * 2;
  }

  ll eat = 0;
  int n = N;
  while (n >= 0) {
    if (n == 0) {
      if (X > 0) eat++;
      break;
    }

    ll piv = b[n] / 2 + 1;
    if (X == piv) {
      eat += p[n - 1] + 1;
      break;
    } else if (X > piv) {
      eat += p[n - 1] + 1;
      X -= piv;
      n--;
    } else {
      X--;
      n--;
    }
  }
  printf("%lld\n", eat);
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
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; }
//forとか代入しない場合は++iでもi++でも同じ

// 入力
int N,M;
vector<vector<int>> G;//グラフ

//メモ化再帰
int dp[100100];

int rec(int v){
    if(dp[v] != -1) return dp[v];//すでにメモ済み

    int res = 0;
    //一番最後のノードがres=0となってどんどん返ってくる、メモしてるので余計なやつはすぐ返ってくるのがよい
    for(auto nv : G[v]){
        chmax(res,rec(nv) + 1);
    }

    return dp[v] = res;//しっかりメモに入れてリターン
}

int main() {
  cin >> N >> M;
  G.assign(N,vector<int>());

  for (int i = 0; i < M; i++)
  {
     int x,y;
     cin >> x >> y;
     --x,--y;//0からスタートするようにする
     G[x].push_back(y);
  }

  //初期化
  for (int v = 0; v < N; v++)
  {
      dp[v] = -1;//maxを求めたいので
  }
   
  int res = 0;
  //N個のノード,再帰だからノードの順番は別にどうでもいい
  for (int v = 0; v < N; v++)
  {//全部のノードをここで試しているのでトポロジカルソートはいらない、自動的にどこからスタートすれば最長になるかわかる
      chmax(res,rec(v));
  }

  cout << res << endl;
  
  
  
}




Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)

int main(){
    string s;
    cin >> s;
    int mae=0,usiro=0;
    string t;
    t = "keyence";
    REP(i,min(7,int(s.size()))){
        if(s[i] == t[i]) mae ++;
        else break;
    }
   
    REP(i,min(7,int(s.size()))){
        if(s[s.size() - i - 1] == t[6-i]) usiro ++;
        else break;
    }   
    
    if(mae + usiro >= 7){
        cout  << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 333

typedef long long ll;
typedef long double ld;

ll w[maxn][maxn];
ll sh[maxn][maxn];

vector<pair<int, pair<int, int> > > v;

int main(){
	int n;
	bool ok = 1;
	ll total = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			scanf("%lld", sh[i] + j);
			w[i][j] = INF;
			v.pb(mp(sh[i][j], mp(i, j)));
		}
		w[i][i] = 0;
	}

	sort(v.begin(), v.end());
	for(int i = 0; i < v.size(); i++){
		int l = v[i].se.fi;
		int d = v[i].se.se;
		
		for(int k = 0; k < n; k++)
			w[l][d] = min(w[l][d], w[l][k] + w[k][d]);

		if(w[l][d] < sh[l][d])
			ok = 0;

		if(w[l][d] > sh[l][d]){
			w[l][d] = w[d][l] = v[i].fi;
			total += v[i].fi;
			//cout << v[i].fi << "  " << l << "  " << d << endl;
		}
	}

	if(!ok){
		printf("-1\n");
		return 0;
	}

	printf("%lld\n", total);
	return 0;
}

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        x: i64,
        mut a: [i64;n],
    }
    a.sort();
    let mut ans:usize = 0;
    let mut sum:i64 =0;
    for i in 0..n {
        sum+=a[i];
        if sum > x {
            ans = i;
            break;
        }
        if i==n-1 {
            if sum==x {
                ans = n;
            }else{
                ans = n-1;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    ll p=a/b;
    ll ra=a%b;
    ll rx;
    if(n<b){
        rx=n;
    }
    else{
        rx=b-1;
    }
    ll ans=ra*rx/b;
    ans+=rx*p;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll k,a,b; cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    int A=0, B=0, K=0;
    cin >> A >> B >> K;

    int i=gcd(A,B), count=1;
    while(count<K){
        --i;
        if(!(A%i)&&!(B%i)) ++count;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;;
	vector<list<int>> vl;
	rep(i, 3) {
		list<int> l;
		cin >> s;
		rep(j, s.size()) {
			l.push_back(s[j] - 'a');
		}
		vl.push_back(l);
	}
	int t = 0, tt = 0;;
	while (vl[t].size()) {
		tt=vl[t].front();
		vl[t].pop_front();
		t = tt;
	}
	cout << (char)(t + 'A') << endl;


}	


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int m;
    cin >> m;
    cout << 24 - m + 24 << endl;

    return 0;
}



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

namespace AtTest.AGC_027
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            long x = long.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var array = new long[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = long.Parse(input[i]);
            }
            Array.Sort(array);
            for(int i = 0; i < n; i++)
            {
                if (x < array[i])
                {
                    Console.WriteLine(i);
                    return;
                }
                x -= array[i];
                if (i == n - 1 && x > 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(n);
        }
    }
}


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

int main() {
  ll n;
  cin >> n;

  vector<ll> ans;
  ll sum = 0;
  for (int i = 1; i < 10000000; i++) {
    sum += i;
    ans.push_back(i);
    if (sum >= n) break;
  }

  ll over = sum - n;
  for (auto i : ans) {
    if (i == over) continue;
    printf("%ld\n", i);
  }
}


Measured memory_bytes: 3804
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::collections::{BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::collections::BinaryHeap;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        a: i32,
        s: String,
    }
    if a >= 3200 {
        println!("{}", s);
    }else {
        println!("red");
    }
    
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)
	mnt := h*60 + m
	ap := mnt * math.Pi / 360
	bp := mnt * math.Pi / 30
	x := a*math.Cos(ap) - b*math.Cos(bp)
	y := a*math.Sin(ap) - b*math.Sin(bp)
	fmt.Println(math.Sqrt(x*x + y*y))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1824
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    p_list=[int(x) for x in input().split()]

    p_sorted = sorted(p_list)

    cnt = 0
    for i, p in enumerate(p_list):
        if p_sorted[i] != p:
            cnt += 1
    if cnt == 0 or cnt == 2:
        print('YES')
    else:
        print('NO')


# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc135","b",main)

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

using namespace std;

const int INF = 1001001001;
int dist[100005][3];

int main(int argc, char *argv[])
{
	int N, M;

	cin>> N >> M;
	vector<vector<int>> to(N);
	
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
	}

	int sv, tv;
	cin >> sv >> tv;
	sv--;
	tv--;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			dist[i][j] = INF;
		}
	}
	queue<pair<int ,int>> q;
	q.push(make_pair(sv, 0));
	dist[sv][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (int u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) {
				continue;
			}
			dist[u][nl] = dist[v][l] + 1;
			q.push(make_pair(u, nl));
		}
	}
	int ans = dist[tv][0];
	if(ans == INF) {
		ans = -1;
	} else {
		ans /= 3;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6912
nData = []
nData  = input().rstrip().split(' ')

X = int(nData[0])
Y = int(nData[1])


nFlag = 0

Check = X%Y

if Check != 0:
    N = 10**18//X
    for i in range(N):
        if i<2:
            continue
        Ans = X * i
        Check = Ans%Y
        if Check !=0:
            nFlag = 1
            break
        
    
if nFlag == 0:
    print('-1')
else:
    print(Ans)




Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>

using namespace std;
const int MAXN = 100001;
const int MAXK = 100001;
const int MOD = 1e9+7;
vector<int> adjList[MAXN];
long long dp[MAXN][2];

long long f(int i, int c, int p)
{
    if(dp[i][c]!=-1) return dp[i][c];
    long long product = 1;
    for(int j : adjList[i])
    {
        if(j==p) continue;
        long long sum = 0;
        if(c!=1) sum+=f(j,1,i);
        sum+=f(j,0,i);
        sum%=MOD;
        product*=sum;
        product%=MOD;
    }
    return dp[i][c] = product;
}

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++)
    {
        int x, y;
        cin >> x >> y;
        adjList[x].push_back(y);
        adjList[y].push_back(x);
    }
    for(int i = 1; i <= N; i++)
    {
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    cout << (f(1,0,-1) + f(1,1,-1))%MOD;
}

Measured memory_bytes: 15616
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a = [INT() for _ in range(n)]
    a_ = a.copy()
    a_.sort()
    m1, m2=a_[-1], a_[-2]

    for x in a:
        if x == m1:
            print(m2)
        else:
            print(m1)

if  __name__=='__main__':
    main()

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

int main() {
  int N , M ;
 
  int T= 0  ; 
  
  cin >> N >> M ; 
  vector<int> A(M) ;
  
  for (int i = 0 ; i < M ; i++){
    cin >> A.at(i) ; 
    T = T + A.at(i) ; 
  }

  
  if( N < T){
    cout << "-1" << endl ; 
  }
  else {
    cout << N - T << endl ;
  }
}

Measured memory_bytes: 3560
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }
    let x = x / 50;

    let mut dp = vec![0; x + 1];
    dp[0] = 1;

    for (s, t) in &[(a, 10), (b, 2), (c, 1)] {
        for i in (0..=x).rev() {
            for j in 1..=*s {
                if j * t <= i {
                    dp[i] += dp[i - j * t]
                }
            }
        }
    }

    println!("{}", dp[x])
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	long double w , h , x , y ; cin >> w >> h >> x >> y ;
	if(x == w / 2 && y == h / 2) cout << (w * h ) / 2 << " " << 1 << endl ;
	else cout << (w * h) / 2 << " " << 0 << endl; 
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll t;cin >>t;
    for (int i = 0; i < t; ++i) {
        ll n;
        bool flg=true;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        string s;
        cin >> s;
        vector<ll> basis;
        for (int i = n - 1; i >= 0; --i) {
            for (auto b:basis) {
                a[i] = min(a[i], a[i] ^ b);
            }
            if (a[i]) {
                if (s[i] == '0') {
                    basis.push_back(a[i]);
                } else {
                    puts("1");
                    flg=false;
                    break;
                }
            }
        }
        if(flg) {
            puts("0");
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;

/*
 * 方針
 * 1 <= X <= Kについて, 最大公約数がXとなるgcd(A1,...,AN) = Xの組を求める
 * このとき, A1,..,ANが皆Xの倍数になればいいが, aXの倍数(a >= 2)にはなってはいけない
 */

ll mod(ll a) {
	return ((a %= MOD) >= 0) ? a : a + MOD;
}

ll modPow(ll a, ll b) {
	ll res = 1;
	while(b > 0) {
		if(b & 1) res = res * a % MOD;
		if(res==0) res = MOD;
		a = a * a % MOD;
		if(a==0) a = MOD;
		b >>= 1;
	}
	return res;
}


int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> count(K+1, 0);

	ll ans = 0;
	for(int i=K;i>=1;i--) {
		count[i] = modPow(K / i, N);
		for(int j=2*i;j<=K;j+=i) {
			count[i] = mod(count[i] - count[j]);
		}
		ans = mod(ans + i * count[i]);
	}
	cout << ans << endl;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            int cnt = 0;
            for(int i = a ; i <= b ; i++)
            {
                if(Check(i)) cnt++;
            }
            Console.WriteLine(cnt);
        }
        public static bool Check(int target)
        {
            string s = target.ToString();
            char[] c = s.ToCharArray();
            
            string s2 = "";
            for(int i = s.Length-1; i >= 0 ;i--)
            {
                s2 += c[i];
            }

            if(s == s2) return true;
            else return false;
        }
    }
}

Measured memory_bytes: 15292
#include <stdio.h>
#include <string.h>

int main()
{
	int H1, M1, H2, M2, K;
	scanf("%d%d%d%d%d", &H1, &M1, &H2, &M2, &K);

	int t1 = H1 * 60 + M1;
	int t2 = H2 * 60 + M2;
	printf("%d\n", t2 - t1 - K);

	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll a[100001] = {};
ll b[100001] = {};

int main() {
	ll N; cin >> N;
	repe(i, 1, N) {
		cin >> a[i];
		b[a[i]]++;
	}

	if (N % 2 == 1) {
		repe(i, 1, N) {
			if (i == 0 && b[i] != 1) {
				cout << 0 << endl;
				return 0;
			}
			else if (i % 2 == 0 && b[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			else if (i % 2 == 1 && b[i] != 0) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else {
		repe(i, 1, N) {
			if (i % 2 == 1 && b[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			else if (i % 2 == 0 && b[i] != 0) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	ll t = 1;
	rep(i, 0, N / 2) {
		t = t * 2 % 1000000007;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1792
def calc(n)
  n.to_f / n.to_s.split("").map{|m| m.to_i }.inject(:+)
end
n = gets.chomp.to_i
order = cnt = 1
n.times {|m|
  puts cnt
  if calc(cnt + 10 ** (order - 1)) > calc(cnt + 10 ** order)
    order += 1
  end
  cnt += 10 ** (order - 1)
}


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2*1e5+10;
int w[N],f[N],cnt[20],res,n,st,sxr[N],S;

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n-1){ri u=read()+1,v=read()+1,va=read();w[u]^=va;w[v]^=va;}rp(i,1,n)cnt[w[i]]++;
	rp(i,1,15)res+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);
	S=(1<<15)-1;
	rp(i,1,S)f[i]=f[i>>1]+(i&1);rp(i,1,S-1)--f[i];
	rp(i,1,S){rp(j,0,14)if((i>>j)&1)sxr[i]^=(j+1);}
	rp(i,1,S)
	{
		if(!sxr[i])for(int k=(i-1)&i;k;k=(k-1)&i)if(!sxr[k])f[i]=min(f[i],f[k]+f[i^k]);
	}
	printf("%d",res+f[st]);
	return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int X,K,D;

signed main(){
    cin>>X>>K>>D;
    X=abs(X);
    int C=X/D;
    if(C>=K){
        cout<<abs(X-K*D)<<endl;
    }
    else {
        X=abs(X-C*D);
        K-=C;
        if(K%2==0)cout<<X<<endl;
        else cout<<abs(X-D)<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
string s;
int main(){FAST;
cin>>s;
if(s[2] == s[3] and s[4] == s[5]){
  cout<<"Yes";
}
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
program main
  implicit none

  integer ::n, m, i, s
  integer, allocatable :: a(:)

  read *, n, m
  allocate(a(m))
  read *, a

  s = 0
  do i = 1, m
     s = s + a(i)
  end do

  if (s <= n) then
     print *, n-s
  else
     print *, '-1'
  end if
  
  stop
end program main


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

using namespace std;

typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }



int n, m;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }


    int a, b,c;
    cin >>a>>b>>c;


        cout << ((b -a)==(c-b)?"YES":"NO") << endl;



    return 0;
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll X;
    cin>>X;
    if(X>=30){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
extension String: CollectionType {
    func toInts() -> [Int64] {
        return self.split(" ").map {Int64($0)!}
    }
    
    func toUInts() -> [UInt64] {
        return self.split(" ").map {UInt64($0)!}
    }
    
    func toStrings() -> [String] {
        return self.split(" ")
    }
}

let values = readLine()!.toUInts()
let N = Int(values[0])
let x: UInt64 = values[1]

var cs = readLine()!.toUInts()
var count: UInt64 = 0

if x < cs[0] {
    count += cs[0] - x
    cs[0] = x
}

(0 ..< N - 1).forEach { i in
    if x < cs[i] + cs[i + 1] {
        count += cs[i + 1] + cs[i] - x
        cs[i + 1] = x - cs[i]
    }
}

print(count)


Measured memory_bytes: 7244
#include <bits/stdc++.h>  // ver2.2.5
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  int a=sqrt(n);
  repreq(i,a,1){
    if(n%i==0) {
      cout << i + n/i -2 << endl;
      return 0;
    }
  }
  return 0;
}

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

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

  sort(x.begin(),x.end(),greater<int>());
  sort(y.begin(),y.end());
  if(X < Y && X < y[0] && x[0] < Y && x[0] < y[0]){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;


int main(){
	llint max = 1000000007;
	llint n;
	cin >> n;
	llint ans = 1;
	for (llint i = 1; i <= n; i++){
		ans *= i;
		ans %= max;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
int main()
 {
    ll N;
    scanf("%lld", &N);
    for(ll h = 1; h <= 3500; ++h) {
        for(ll n = 1; n <= 3500; ++n) {
            ll ans1 = N*h*n;
            ll ans2 = n*h*4 - N*(n+h);
            if(ans2 <= 0) continue;
            if(ans1 % ans2 == 0) {
                printf("%lld %lld %lld\n", h, n, ans1 / ans2);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 128
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n;
vector<int> edge[300000];

int d[300000];
vector<int> q;

int main()
{
	int i, j, k, l;
	cin>>n;
	for(i=0;i<n-1;i++)
	{
		int x, y;
		scanf("%d%d", &x, &y), x--, y--;
		edge[x].push_back(y), edge[y].push_back(x);
	}
	memset(d, -1, sizeof(d));
	q.push_back(0);
	d[0]=0;
	for(i=0;i<q.size();i++)
	{
		int x=q[i];
		for(auto e : edge[x])
		{
			if(d[e] == -1)
			{
				d[e]=d[x]+1;
				q.push_back(e);
			}
		}
	}
	int s=q.back();
	q.clear();
	memset(d, -1, sizeof(d));
	q.push_back(s);
	d[s]=0;
	for(i=0;i<q.size();i++)
	{
		int x=q[i];
		for(auto e : edge[x])
		{
			if(d[e] == -1)
			{
				d[e]=d[x]+1;
				q.push_back(e);
			}
		}
	}
	int u=d[q.back()];
	if(u%3 == 1) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}
//*/

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

#define int long long int

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif
//!

int32_t main()
{
	GO
	//fioe();
	int n;
	cin>>n;
	int arr[n+2];
	map<int,int> m;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		m[arr[i]]++;
	}
	int ans = 0;
	for(auto x:m){
		if(x.second >= 2){
			int h = x.second;
			ans += (h*(h-1))/2;
		}
	}
	int actual = ans;
	for(int i=0;i<n;i++){
		ans = actual;
		int frq = m[arr[i]];
		if(frq >= 2)
			ans -= (frq*(frq-1))/2;
		frq --;
		if(frq >= 2)
			ans += (frq*(frq-1))/2;
		cout<<ans<<" ";
	}
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int min_count = 100000;
  for(int i_s = 0;i_s <= S.size() - T.size();++i_s){
    int cur_count = 0;
  	for(int j_s = 0;j_s<T.size();++j_s){
    	if(T[j_s] != S[i_s + j_s]){
        	cur_count++;
        }
    }
    min_count = min(min_count, cur_count);
  }
  cout<<min_count<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

static void printArray(int A[], int N) {
  for (int i = 0; i < N; i++) {
    cout << (i != 0 ? " " : "") << A[i];
  }
  cout << endl; 
}


static void inputArray(int A[], int num) {
  for (int i = 0; i < num; i++) {
    scanf("%d", &A[i]);
  }
}

static int selectionSort(int A[], int N) {
  int minj, count = 0;
  for (int i = 0; i < N; i++) {
    minj = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minj]) {
    	minj = j;
      }
    }
    if (A[i] != A[minj]) {
        swap(A[i], A[minj]);
        count++;
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;

  array<int, 100> A;
  inputArray(A.data(), N);

  int count = selectionSort(A.data(), N);

  printArray(A.data(), N);
  cout << count << endl;
  
  return 0;
}



Measured memory_bytes: 3260
import numpy as np
N,M = map(int,input().split())
S = np.array(input().split(), dtype = np.int32)
T = np.array(input().split(), dtype = np.int32)
dp = np.ones(M+1, dtype = np.int64)
for s in S:
  dp[1:] = ((dp[:-1] * (T == int(s))).cumsum() + dp[1:]) % (10**9 + 7)
print(dp[M])

Measured memory_bytes: 12484
import * as fs from 'fs';

namespace AtCoder.abc093 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const s: string = this.args[0];
            const sorted: string = s.split('').sort().join('');
            if (sorted === 'abc') {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc093.Program(args);
prg.main();


Measured memory_bytes: 7372
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let s: Vec<char> = input::<String>().chars().collect();

    let mut group = vec![];
    let mut i = 0;
    while i < n {
        let cur = s[i];
        let mut cnt = 0;
        while i < n && s[i] == cur {
            i += 1;
            cnt += 1;
        }
        group.push((cur, cnt));
    }

    let z = group.iter().filter(|&&(c, _)| c == '0').count();
    if z <= k {
        println!("{}", n);
        return;
    }

    if group[0].0 == '0' {
        group.insert(0, ('1', 0));
    }
    if group[group.len() - 1].0 == '0' {
        group.push(('1', 0));
    }

    let mut ans = 0;
    let mut i = 0;
    for g in group.windows(2 * k + 1) {
        i += 1;
        if i & 1 == 0 {
            continue;
        }
        let temp: i32 = g.iter().map(|&(_, c)| c).sum();
        ans = std::cmp::max(ans, temp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
s = sorted([int(input()) for _ in range(N)])

if sum(s)%10 != 0:
  print(sum(s))
else:
  for i in range(N):
    if s[i] %10 != 0:
      print(sum(s)-s[i])
      exit()
  print(0)

Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val k = sc.nextInt()

    var idx = 1

    while (n >= Math.pow(k, idx)) {
      idx = idx + 1
    }

    val ans = idx

    println(ans)
  }
}


Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

#define A first
#define B second

const int MAXN = 140000;

vector<pii> dp[MAXN], g[MAXN];
ll n, t;
vector<pii> v1, v2, v3;
vector<pii> emp;

vector<pii> merge(vector<pii> a, vector<pii> b) {
    if (a.size() == 0 || b.size() == 0)
        return emp;
    v1.clear();
    v2.clear();
    int r = -1;
    for (pii u : a) {
        while (r != b.size()-1 && b[r+1].A+u.B <= t)
            r++;
        if (r != -1)
            v1.push_back(pii(u.A, b[r].B));
    }

    r = -1;
    for (pii u : b) {
        while (r != a.size()-1 && a[r+1].A+u.B <= t)
            r++;
        if (r != -1)
            v2.push_back(pii(u.A, a[r].B));
    }

    v3.clear();
    ll mini = (1LL<<60);
    int l = 0; r = 0;

    //maintain pareto frontier
    while (true) {
        if (l == v1.size() && r == v2.size())
            break;
        if (l == v1.size()) {
            if (v2[r].B < mini) {
                v3.push_back(v2[r]);
                mini = v2[r].B;
            }
            r++;
        } else if (r == v2.size()) {
            if (v1[l].B < mini) {
                v3.push_back(v1[l]);
                mini = v1[l].B;
            }
            l++;
        } else if (v1[l] < v2[r]) {
            if (v1[l].B < mini) {
                v3.push_back(v1[l]);
                mini = v1[l].B;
            }
            l++;          
        } else {
            if (v2[r].B < mini) {
                v3.push_back(v2[r]);
                mini = v2[r].B;
            }
            r++;            
        }
    }

    return v3;
}

void dfs(int v) {
    if (g[v].size() == 0) {
        dp[v].push_back(pii(0, 0));
        return;
    }

    for (pii u : g[v]) {
        int w = u.A;
        dfs(w);
        for (int i = 0; i < dp[w].size(); ++i) {
            dp[w][i].A += u.B;
            dp[w][i].B += u.B;
        }
    }

    dp[v] = merge(dp[g[v][0].A], dp[g[v][1].A]);
}

bool check(ll checkit) {
    t = checkit;
    for (int i = 0; i < n; ++i)
        dp[i].clear();

    dfs(0);
    return (dp[0].size() > 0);
}

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

    cin >> n;
    for (int i = 1; i < n; ++i) {
        int x, w;
        cin >> x >> w;
        g[x-1].push_back(pii(i, w));
    }

    ll lo = 0, hi = (1LL<<40);
    while (lo != hi) {
        ll mid = (lo + hi)/2;
        if (check(mid))
            hi = mid;
        else
            lo = mid+1;
    }

    cout << lo << endl;
}

Measured memory_bytes: 36460