akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

namespace uf {
    vector<int> par, rank;
    vector<int> memo;
    int num;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        memo.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            memo[i] = 1;
        }
        num = n;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            memo[y] += memo[x];
        } else {
            par[y] = x;
            memo[x] += memo[y];
            if (rank[x] == rank[y])rank[x]++;
        }
        num--;
    }

    int size(int x) {
        return memo[root(x)];
    }

    int size() {
        return num;
    }
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N, M;
    cin >> N >> M;
    uf::init(N);
    while (M--) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        uf::unite(x, y);
    }
    cout << uf::size() << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	string s;
	cin >> s;
	if(s[0]=='A' && s[1]>='a' && s[1]<='z'){
		int Cnum=0;
		bool flg=true;
		for(int i=2; i<s.size(); i++){
			if(i<s.size()-1 && s[i]=='C')
				Cnum++;
			else if(s[i]<'a' || s[i]>'z')
				flg=false;
		}
		if(Cnum==1 && flg){
			cout << "AC" << endl;
			return 0;
		}
	}
	cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int a[]=new int[n];
		int sum=0;
		int c[]=new int[n-1];
		for(int i=0;i<n;i++)a[i]=scan.nextInt();
		for(int i=0;i<n;i++)sum+=scan.nextInt();
		for(int i=0;i<n-1;i++)c[i]=scan.nextInt();
		scan.close();

		for(int i=1;i<n;i++) {
			if(a[i-1]==a[i]-1)sum+=c[a[i]-2];
		}
		System.out.println(sum);
	}

}

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

int main(){
  string s;
  cin>>s;
  string a[16]={"AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHBAR","AKIHBR","KIHBR","KIHABR"};
  for(int i=0;i<16;i++){
    if(a[i]==s){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)

using namespace std;

typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> pii;

void perform() {
  string s; cin >> s; int n = s.length();
  bool flag = true;
  for (int i = 0; i < ((n-1)/4 + 1); i++) {
    //cout << s[i] << " " << s[((n-1)/2)-i-1]<< " ";
    //cout << s[n - i - 1] << " " << s[((n+3)/2)+i-1] << endl;;
    if (s[i] == s[((n-1)/2)-i-1] && s[i] == s[n - i - 1] && s[i] == s[((n+3)/2)+i-1]);
    else flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}



Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		while(n != 0){
			Station[] s = new Station[m];
			for(int i = 0; i < m ; i++){
				s[i] = new Station(m);
			}
			for(int i = 0 ; i < n ; i++){
				int[] abct = new int[4];
				for(int j = 0 ; j < 4 ; j++){
					abct[j] = sc.nextInt();
				}
				for(int j = 0 ; j < 2 ; j++){
					s[abct[0]-1].costs[abct[1]-1][j] = abct[j+2];
					s[abct[1]-1].costs[abct[0]-1][j] = abct[j+2];
				}
			}
			int k = sc.nextInt();
			for(int i = 0 ; i < k ; i++){
				int p = sc.nextInt()-1;
				int q = sc.nextInt()-1;
				int r = sc.nextInt();
				System.out.println(search(s,p,q,r));
			}
			n = sc.nextInt();
			m = sc.nextInt();
		}
		sc.close();
	}
	static int search(Station[] s, int p, int q, int r){
		for(int i = 0 ; i < s.length ; i++){
			s[i].cost = 0;
		}
		ArrayList<Station> open = new ArrayList<Station>();
		open.add(s[p]);
		while(!open.isEmpty()){
			Station o = (Station)open.get(0);
			if(s[q].cost == 0 || o.cost < s[q].cost){
				for(int i = 0 ; i < s.length; i++){
					if(i != p && o.costs[i][r] != 0){
						int tcost = o.cost + o.costs[i][r];
						if(s[i].cost == 0 || s[i].cost > tcost){
							s[i].cost = tcost;
							open.add(s[i]);
						}
					}
				}
			}
			open.remove(0);
		}
		return s[q].cost;
	}
}
class Station{
	int cost;
	int[][] costs;
	Station(int m){
		costs = new int[m][2];
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
ll a, b, c, d;

int main() {
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	ll p = __gcd(c, d);
	ll lcm = c * d / p;
	ll dd = 0;
	if(a % lcm == 0) dd++;
	ll ans = (b - a + 1) + (b / lcm - a / lcm + dd);
	ll x = 0, y = 0;
	if(a % c == 0) x++;
	if(a % d == 0) y++;
	ans -= (b / c - a / c + x) + (b / d - a / d + y);
	printf("%lld\n", ans);
	return 0;
}

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;

using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf(“%I64d", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;
const int inf = 0x3f3f3f3f;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase   

int32_t main(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x,j,y,z,k,n;

cin>>n;
db p;
if(n==1){
	cout<<"1.0000000000";
	exit(0);
}
if(n&1){
	p=(int(n/2)+1)/(n*1.00000);
}
else{
	p=0.5000000000;
}
ce(p)
}


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

static const int W_MAX = 10000;

int min_all = W_MAX;

int solve(int weight[], int n)
{
    int ans = 0;

    /* 準備 */
    int sorted_array[n]; // 元の配列をソートした配列を別途用意
    bool is_used[n]; // 各要素が使われたかどうか
    int point[W_MAX + 1]; // 元の配列の各要素の行き先(添え字)を表す
    for(int i = 0; i < n; i++) // 初期化
    {
        sorted_array[i] = weight[i];
        is_used[i] = false;
    }
    sort(sorted_array, sorted_array + n);
    for(int i = 0; i < n; i++)
    {
        point[sorted_array[i]] = i;
    }

    /* 各要素に対しサイクルを求める */
    for(int i = 0; i < n; i++)
    {
        if(!is_used[i]) // 未使用である要素だけサイクルを調べる
        {
            int sum_cycle = 0; // サイクル内の重みの総和
            int min_cycle = W_MAX; // サイクル内の重みの最小値
            int size_cycle = 0; // サイクル内の要素数
            int current = i; // 現在の要素のindex

            /* サイクル開始(1.と2.を繰り返し，3.で終了) */
            while(true)
            {
                is_used[current] = true; // 1.現在の要素を使用するので二度とこないようにtrueに
                size_cycle++;
                int w = weight[current]; // 1.現在の要素の重みを調べる
                sum_cycle += w;
                min_cycle = min(min_cycle, w);
                current = point[w]; // 2.現在の要素の重みの行き先へ移動
                if(is_used[current]) // 3.元に戻ってきたらloopを抜ける(サイクル完了)
                    break;
            }
            ans += min(sum_cycle + (size_cycle - 2) * min_cycle,
                    sum_cycle + min_cycle + (size_cycle + 1) * min_all);
        }
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    int weight[n];
    for(int i = 0; i < n; i++)
    {
        cin >> weight[i];
        min_all = min(min_all, weight[i]);
    }
    cout << solve(weight, n) << endl;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n), c(n);
	rep(i,n) {
		cin >> p[i];
		p[i]--;
	}
	rep(i,n) {
		cin >> c[i];
	}
	ll ans = -1001001001;
	rep(i,n) {
		vector<ll> v; // loopを保持
		vector<ll> u; // 累積pointを保持
		v.push_back(p[i]);
		u.push_back(c[p[i]]);
		for (int j = 0;; j++) {
			ll np = p[v[j]];
			ll nc = c[np];
			if (np == v[0]) break;
			v.push_back(np);
			u.push_back(nc + u[j]);
		}
		ll r = u[u.size() - 1]; // 1ループで得られる値
		ll t = k / u.size();
		ll temp = -1001001001;
		if (t > 0) {
			if (r < 0) {
				ll mx = -1001001001;
				rep(j, u.size()) {
					mx = max(u[j], mx);
				}
				temp = mx;
			} else {
				ll tmp1;
				ll mx = 0;
				rep(j, u.size()) {
					mx = max(u[j], mx);
				}
				tmp1 = (t - 1) * r + mx;

				ll tmp2;
				ll mx2 = 0;
				rep(j, k % u.size()) {
					mx2 = max(u[j], mx2);
				}
				tmp2 = t * r + mx2;
				temp = max(tmp1, tmp2);
			}
		} else {
			ll mx = -1001001001;
			rep(j, k) {
				mx = max(u[j], mx);
			}
			temp = mx;
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3808
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;

	long[char] cnt;
	foreach (c; S)
	{
		++cnt[c];
	}

	bool ans;
	auto keys = cnt.keys;
	if (keys.length == 2)
	{
		if (cnt[keys[0]] == cnt[keys[1]])
			ans = true;
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs,itertools as it
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""



n = onem()

a = tuple(input().split())
b = tuple(input().split())

aa = sorted(a)

po = list(it.permutations(aa))

coa = 0
cob = 0
for i in range(len(po)):
    if a == po[i]:
        coa = i
    if b == po[i]:
        cob = i
print(abs(coa-cob))








Measured memory_bytes: 8180
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String h = sc.next();
        String brock[] = h.split("");
        int iti = 0,zero = 0;
        for(int i = 0;i < h.length();i++){
          if(brock[i].equals("1")){
            iti += 1;
          }else{
            zero += 1;
          }
        }
        if(iti <= zero){
          System.out.println(iti * 2);
        }else{
          System.out.println(zero * 2);
        }

        
    }
}

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

int main(){
      int ans = 0;
      int minn = INT_MAX;
      bool flag = false;
      for(int i = 0;i < 5;i++){
            int t;cin >> t;
            ans += t;
            if(t % 10 != 0){
                  ans += 10 - (t % 10);
                  if(t % 10 < minn){
                        minn = t % 10;
                        flag = true;
                  }
            }
      }
      if(flag)ans -= 10 - minn;
      cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
char c;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>c;
    cout<<char('a' + int(c - 'a' + 1));
    return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (auto& x : a) {
        cin >> x;
        sum += x;
    }

    ll avg = sum / n;
    ll ans = 1e18;
    for (ll v = avg - 2; v <= avg + 2; ++v) {
        ll cur = 0LL;
        for (auto& x : a) {
            ll d = x - v;
            cur += d * d;
        }

        ans = min(ans, cur);
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;

my $n = <>;
chomp $n;
my $in = <>;
chomp $in;
my @data = split(/ /, $in);
@data = sort {$b <=> $a} @data;

foreach(1..$n){
	pop @data;
}

my $sum = 0;
my $i = 0;
foreach (@data){
	if (($i & 1) == 1){
		$sum += $_;
	}
	$i++;
}

print $sum."\n";

exit;


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    string s,t;
    cin>>s>>t;

    Vec a(26);
    Vec b(26);

    if(s.length()!=t.length()){
        Yes(false);
        return 0;
    }

    rep(i,s.length()){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }

    sort(ALL(a));
    sort(ALL(b));

    bool can = true;
    rep(i,26){
        if(a[i]!=b[i]){
            can = false;
        }
    }

    Yes(can);
    return  0;
}


Measured memory_bytes: 916
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007, Inv2 = (Mod + 1) / 2;
const int MN = 3005;

int N, Q, A[MN], p1[MN], p2[MN];
int dp[MN][MN], Coef, Sum;

int main() {
        scanf("%d%d", &N, &Q), Coef = 1;
        for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
        for (int i = 1; i <= Q; ++i) {
                scanf("%d%d", &p1[i], &p2[i]);
                /* if (p1[i] > p2[i]) std::swap(p1[i], p2[i]); */
        }
        for (int i = 1; i <= N; ++i)
                for (int j = 1; j <= N; ++j)
                        dp[i][j] = A[i] > A[j];
        for (int i = 1; i <= Q; ++i) {
                static int tmp[MN][MN];
                for (int x = 1; x <= N; ++x)
                        if (x != p1[i] && x != p2[i]) {
                                tmp[x][p1[i]] = (LL)Inv2 * (dp[x][p1[i]] + dp[x][p2[i]]) % Mod;
                                tmp[p1[i]][x] = (LL)Inv2 * (dp[p1[i]][x] + dp[p2[i]][x]) % Mod;
                                tmp[x][p2[i]] = (LL)Inv2 * (dp[x][p2[i]] + dp[x][p1[i]]) % Mod;
                                tmp[p2[i]][x] = (LL)Inv2 * (dp[p2[i]][x] + dp[p1[i]][x]) % Mod;
                        }
                for (int x = 1; x <= N; ++x)
                        if (x != p1[i] && x != p2[i]) {
                                dp[x][p1[i]] = tmp[x][p1[i]];
                                dp[p1[i]][x] = tmp[p1[i]][x];
                                dp[x][p2[i]] = tmp[x][p2[i]];
                                dp[p2[i]][x] = tmp[p2[i]][x];
                        }
                dp[p2[i]][p1[i]] = dp[p1[i]][p2[i]] = (LL)Inv2 * (dp[p1[i]][p2[i]] + dp[p2[i]][p1[i]]) % Mod;
                Coef = 2ll * Coef % Mod;
        }
        for (int x = 1; x < N; ++x)
                for (int y = x + 1; y <= N; ++y)
                        Sum = (Sum + dp[x][y]) % Mod;
        printf("%lld\n", (LL)Coef * Sum % Mod);
        return 0;
}

Measured memory_bytes: 73672
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int count =0;
		int sum =0;
		int [] hairetuB = new int[M];
		for(int i=0;i<M;i++){
			hairetuB[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				int A =sc.nextInt();
				sum = sum +hairetuB[j]*A;
			}
			if(sum+C>0){
				count++;
			}
			sum=0;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 24404
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T>
constexpr bool chmin(
    T a, T b, function<bool(T, T)> f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T a, T b) {
  return chmin(a, b, [](T a, T b) { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << *i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vector<vector<int>> G(n);
  for (int i = 0; i < n - 1; i++) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[x].push_back(y);
  G[y].push_back(x);
  vector<int> ans(n - 1, 0);
  // cout << "Input OK\n";
  for (int i = 0; i < n; i++) {
    queue<int> q;
    q.push(i);
    vector<int> dis(n, 1 << 29);
    dis[i] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto nv : G[v]) {
        if (dis[nv] > dis[v] + 1) {
          dis[nv] = dis[v] + 1;
          q.push(nv);
        }
      }
    }
    // cout << "BFS OK\n";
    // print_ite(all(dis));
    for (int j = 0; j < n; j++) {
      if (i < j)
        continue;
      if (dis[j] > 0)
        ans[dis[j] - 1]++;
    }
    // cout << "Count OK\n";
  }
  print_ite(all(ans));
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n,m;
   cin>>n>>m;
   vector<ll> b(n+10);
   vector<ll> a(n+10,0);

   rep(i,m){
      int x;
      cin>>x;
      a[x]=1;
   }
   b[0]=1;
   b[1]=1; 
   if(a[1]!=0){
      b[1]=0;
   }

   for(int i=2;i<=n;i++){
      b[i]=b[i-1]+b[i-2];
      if(a[i]!=0){
         b[i]=0;
      }
      b[i]=b[i]%1000000007;
   }
   cout<<b[n]<<endl;
   
   return 0;
}


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

int main(){
  int h,w,hi; cin>>h>>w;
  char wi = 'A';
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      string s; cin >> s;
      if(s=="snuke") {
        wi+=j;
        hi=i+1;
      }
    }
  }
  cout << wi << hi << endl;
}

Measured memory_bytes: 256
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    int q;
    cin>>q;
    string s1="";
    int fl1=0,fr=0;
    deque <char> que;
    forn(i,s.size())que.push_back(s[i]);
    forn(i,q){
        int t1;
        cin>>t1;
        if(t1==1){
            fl1=1-fl1;
        }
        else{
            int f1;
            char ch;
            cin>>f1>>ch;
            if(f1==1){
                if(fl1==1)que.push_back(ch);
                else que.push_front(ch);
            }
            else{
                if(fl1==0)que.push_back(ch);
                else que.push_front(ch);
            }
        }
    }
    string ans="";
    for(auto it=que.begin();it!=que.end();it++)ans+=*it;
    if(fl1==0)cout<<ans;
    else{
        for(int i=ans.size()-1;i>-1;i--)cout<<ans[i];
    }

	return 0;
}


Measured memory_bytes: 1368
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  vector<ll> L(n + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= n; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }

  cout << L[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; ll a[N]; map<ll, int>mp;
  rep(i, N){
    cin >> a[i]; mp[a[i]]++;
  }
  int ans = 0;
  sort(a, a+N, greater<ll>());
  rep(i, N){
    if(mp[a[i]]<=0) continue;
    ll k = 1;
    while((ll)pow(2, k)<=a[i]){
      k++;
    }
    ll P = (ll)pow(2, k) - a[i];
    if(mp[P]>0 && P!=a[i]){
      mp[P]--; mp[a[i]]--; ans++;
    }
    else if(mp[P]>1){
      mp[P]-=2; ans++;
    }
    else continue;
  }
  cout << ans << endl;
}

Measured memory_bytes: 26752
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<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++)
const long long INF =  999999999;

ll h,n,a[100010];

int main(){
    cin>>h>>n;
    ll p=h;
    REP(i,n){
      cin>>a[i];
      p-=a[i];
    }
    if(p<=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
// code.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>


using namespace std;

int main()
{
long int H,A;
cin>>H>>A;
if(H%A==0){
	cout<<H/A;
}
else{
	cout<<(H/A)+1;
}
}
	


Measured memory_bytes: 256
#34
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cou = 0


for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                cou += 1
                
print(cou)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm> 
using namespace std;
int main(){
	int N; 
	int n[4];
	while(true){
		int cnt=0;
		cin >> N;
		if(N==0) break;
		if(N%1111==0) {
			cout << "NA\n";
			continue;
		}
		while(N!=6174){
			n[0]=N/1000;
			n[1]=(N/100)%10;
			n[2]=(N/10)%10;
			n[3]=N%10;
			sort(n,n+4);
			int L = n[3]*1000+n[2]*100+n[1]*10+n[0];
			int S = n[0]*1000+n[1]*100+n[2]*10+n[3];
			N=L-S;
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		if( N>81 ){
			System.out.println("No");
		}else{
			for( int i=1; i<=9; i++ ){
				if( N%i==0 && N/i<10 ){
					System.out.println("Yes");
					break;                  
				}
				if( i==9 ){
					System.out.println("No");
				}
			}
		}
	}
}


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

#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=2e5+10, mod=1e9+7;


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

  // #ifndef ONLINE_JUDGE
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  // #endif

  int n,k,s;
  cin>>n>>k>>s;
  for(int i=0;i<k;i++)cout<<s<<" ";
  	
  if( s==1e9 ) s--;
  else s=1e9;

  for(int i=k;i<n;i++)cout<<s<<" ";

  


  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
using P = pair<ll,ll>;
const ll INF = 1e15;

int main(){
  int n;
  cin >> n;
  ll l[n], r[n];
  P d[n];
  rep(i,n) {
    ll x, a;
    cin >> x >> a;
    l[i] = x-a;
    r[i] = x+a;
    d[i] = P(r[i],i);
  }
  sort(d,d+n);
  ll p = -INF;
  int ans = 0;
  rep(i,n) {
    if(l[d[i].second] >= p) {
      ans++;
      p = d[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>

int main(void) {
  int a, b;
  std::cin >> a >> b;
  std::cout << (a * b % 2 == 0 ? "Even" : "Odd") << std::endl;

  return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;
	for(long long i = 0; i < s.size(); ++i) cout << "x";

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 2147483648;
const int maxn = 4e5 + 5;
vector<int> vv;
int s[maxn];
ll t[maxn];
char a[maxn];
int main()
{
    for (int i = 1; i <= 2e5; i ++ )
    {
        int ans = 0;
        int x = i;
        while(x)
        {
            int temp = 0;
            int t = x;
            while(t)
            {
                if(t & 1)
                    temp ++ ;
                t >>= 1;
            }
            x %= temp;
            ans ++ ;
        }
        s[i] = ans;
    }
    int n;
    scanf("%d%s",&n,a + 1);
    int s1 = 0;
    for (int i = 1; i <= n; i ++ )
    {
        if(a[i] == '1')
            s1 ++ ;
    }
    t[s1] = 0;//intf("11111111\n");
    for (int i = 1; i <= n; i ++ )
    {
//        printf("%d\n",i);
        for (int k = max(0,s1 - 1); k <= s1 + 1; k ++ )
        {
            //printf("%d\n",k);
            if(k > 0)
            {
                t[k] = (t[k] * 2 % k + (a[i] - '0')) % k;
            }
        }
    }

    for (int i =1; i <= n; i ++ )
    {
        int k = n - i;
        int y;
        if(a[i] == '1')
        {
            y = s1 - 1;
            if(y == 0)
            {
                printf("0\n");
                continue;
            }
            ll ss = qpow(2,k,y);
            printf("%d\n",s[((t[y] - ss) % y + y )% y]  + 1);
        }
        else
        {
            y = s1 + 1;
            ll ss = qpow(2,k,y);
            printf("%d\n",s[(t[y] + ss) % y] + 1);
        }
    }
}


Measured memory_bytes: 4164
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::min;

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();

    let mut h = vec![0; n+k];
    for i in 0..n {
        h[i] = read::<i64>();
    }
    let mut dp = vec![100_000_000_000; n+k];
    dp[0] = 0;
    for i in 0..n {
        for j in 1..k+1 {
            let w = h[i+j] - h[i];
            dp[i+j] = min(dp[i+j], dp[i] + w.abs());
        }
    }

    println!("{}", dp[n-1])
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n;cin>>n;
    
    cout<<((n+1)/2+.0)/n<<endl;
    return 0;
}

Measured memory_bytes: 3792
#include<cstdio>
#include<algorithm>
using namespace std;
int n,i,pre,x,ans=0,ty=0;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(pre==0)ans++;
		else
		{
			if(ty==0)
			{
				if(x>pre)ty=1;
				if(x<pre)ty=-1;
			}
			else if((ty==-1&&x>pre)||(ty==1&&x<pre))ans++,ty=0;
		}
		pre=x;	
	}
	printf("%d",ans);
	return 0;
} 

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

int main(int argc, char const *argv[])
{
	int x;
	cin>>x;
	if (x==3||x==5||x==7)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
list_len = int(input().rstrip())
num_list = list(map(int, input().rstrip().split()))

for i in range(list_len):
    v = num_list[i]

    j = i - 1
    while j >= 0 and num_list[j] > v:
        num_list[j + 1] = num_list[j]
        j -= 1
    num_list[j+1] = v
    
    output_str = ' '.join(map(str, num_list))
    print(output_str)

Measured memory_bytes: 7688
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  ll curmax = 0;
  ll ans = 0;
  rep(i, n) {
    ll h;
    cin >> h;
    if (h >= curmax) ans++;
    curmax = max(curmax, h);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,a=map(int,input().split())
x=list(map(int,input().split()))
stack=[0]*5001
stack[2500]=1
for i in range(len(x)):
  x[i]-=a
for i in x:
  stack2=[i for i in stack]
  for j in range(5001):
    if 0<=j+i<=5000:
      stack2[j+i]+=stack[j]
  stack=[i for i in stack2]
print(stack[2500]-1)

Measured memory_bytes: 3188
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>

#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#include<iomanip>
#include<fstream>
#include<chrono>
using namespace std;
using namespace __gnu_pbds;

#define int          long long
#define pii          pair<int,int>
#define vi           vector<int>
#define peque        priority_queue
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       x.begin(),x.end()
#define ball(x)      x.rbegin(),x.rend()
#define mem(x,y)     memset(x,y,sizeof(x))
#define oset         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main()
{
    VR46 ofstream out("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU THODE TEST CASE BNAKE TEST KRLE
    int t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        int n;
        cin>>n;
        cout<< n*n <<"\n";
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll     long long int 
#define pb     push_back
#define umap   unordered_map
#define mod    1000000007
#define all(x) (x).begin(), (x).end()
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int n;cin>>n;
 int x=n%10;
 if(x==1 || x==3 || x==7 || x==9)
 {
  int y=1;
  ll rem=7%n;
  for(int k=1;k<=1e6;k++)
  {
     if(rem==0)
       {cout<<k;y=0;break;}
     else
       {
        rem=((((rem*10)%n)+(7%n))%n);
       }
  }
  if(y)
    cout<<-1;
 }
 else
 {
  cout<<-1;
 }
}

Measured memory_bytes: 3596
n = int(input())
graph = [[] for _ in range(n)]
cnt = [0] * (n)
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

C = list(map(int, input().split()))
C.sort(reverse=True)
num = sum(C[1:])

ans = [0] * (n)

start = 0
par = [-1] * n
stack = [start]
idx = 0
ans[0] = C[idx]
idx += 1
while stack:
    v = stack.pop()
    for u in graph[v]:
        if u == par[v]:
            continue
        par[u] = v
        ans[u] = C[idx]
        idx += 1
        stack.append(u)
    # print(stack)

print(num)
print(*ans, sep=" ")


Measured memory_bytes: 71696
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(int a, int b)
{
   return a < b;
}
std::priority_queue<int, std::vector<int>, std::function<bool(int, int)>> pq(Compare);

int r,c,k; 
int val[3005][3005];
int dp[3005][3005][4];

int rec(int curr_r, int curr_c,int num){
  if(curr_r == r || curr_c == c) return 0;
  if(dp[curr_r][curr_c][num]!=-1) return dp[curr_r][curr_c][num];
  int a=LLONG_MIN;
  if(num==3) {
		a=max(a,rec(curr_r,curr_c+1,num));
        a=max(a,rec(curr_r+1,curr_c,0));
  }else{
    a=max(a,rec(curr_r,curr_c+1,num));
    a=max(a,rec(curr_r+1,curr_c,0)+val[curr_r][curr_c]);
    a=max(a,rec(curr_r,curr_c+1,num+1)+val[curr_r][curr_c]); 
  }
  return dp[curr_r][curr_c][num]=a;
}

void solve(){
  cin>>r>>c>>k;
   f(i,0,k){
    int a,b,c; cin>>a>>b>>c;
    --a; --b; val[a][b]=c;
  }
  f(i,0,r) f(j,0,c) f(k,0,4) dp[i][j][k]=-1;
  cout<<rec(0,0,0)<<"\n";
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 356328
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7

Acc = [0] * N
Acc[0] = A[0]
for i in range(1, N):
    Acc[i] = (Acc[i - 1] + A[i]) % MOD

ans = 0
for i in range(N - 1):
    ans = (ans + Acc[i] * A[i + 1]) % MOD
print(ans)


Measured memory_bytes: 31940
/*
 *  Created on: 23 / 4 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n)
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(20);
    Eslam__Waheed
        ss s; cin >> s;
    //int a = s.find('7');
    //int b = s.find('7');
    //cout << a << ' ' << b << endl;
    if (s.find('7') < sz(s) && s.find('7') >= 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3600
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m;
	cin >> n >> m;
	map<int, pair<bool, int>> answers;
	while(m--)
	{
		int p;
		cin >> p;
		string s;
		cin >> s;
		if(!answers.count(p)) answers[p] = {false, 0};
		if(!answers[p].ff)
		{
			if(s == "AC") answers[p].ff = true;
			else ++answers[p].ss;
		}
	}
	int accepted = 0, penalties = 0;
	for(auto &answer : answers)
		if(answer.ss.ff)
		{
			++accepted;
			penalties += answer.ss.ss;
		}
	cout << accepted << ' ' << penalties << '\n';
}

Measured memory_bytes: 9892