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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

using Seg = pair<PII,PII>;
int dot(PII p1, PII p2){
  return p1.FF * p2.FF + p1.SS * p2.SS;
}
int cross(PII p1, PII p2){
  return p1.FF * p2.SS - p1.SS * p2.FF;
}
PII operator-(const PII& l, const PII& r){
  return PII(l.FF - r.FF, l.SS - r.SS);
}
  
bool isp(Seg s1, Seg s2){
  return s1.FF == s2.FF || s1.FF == s2.SS || s1.SS == s2.FF || s1.SS == s2.SS;
}
bool on(PII p, Seg s){
  return p != s.FF && p != s.SS && cross(s.FF-p, s.SS-p) == 0 && dot(s.FF-p, s.SS-p) < 0;
}
bool ist(Seg s1, Seg s2){
  return on(s1.FF, s2) || on(s1.SS, s2) || on(s2.FF, s1) || on(s2.SS, s1);
}

void dfs(int u, VVI& ps, VVI& ts, vector<bool>& use, PII& res, VI& buf){
  buf.PB(u);
  use[u] = true;
  for(int v: ps[u]){
	++res.FF;
	if(!use[v])
	  dfs(v, ps, ts, use, res, buf);
  }
  for(int v: ts[u]){
	++res.SS;
	if(!use[v])
	  dfs(v, ps, ts, use, res, buf);
  }
}

bool istwo(Seg s1, Seg s2){
  if(s1.SS != s2.FF) swap(s1.FF, s1.SS);
  if(s1.SS != s2.FF) swap(s2.FF, s2.SS);
  if(s1.SS != s2.FF) swap(s1.FF, s1.SS);
  return cross(s1.SS-s1.FF, s2.SS-s2.FF) < 0;
}

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

  int N;
  while(cin>>N,N){
	vector<Seg> ss(N);
	REP(i,N) cin >> ss[i];

	VVI isps(N), ists(N);
	REP(i,N) REP(j,i){
	  if(isp(ss[i], ss[j])){
		isps[i].PB(j);
		isps[j].PB(i);
	  }
	  else if(ist(ss[i], ss[j])){
		ists[i].PB(j);
		ists[j].PB(i);
	  }
	}

	vector<bool> use(N);
	VI ans(10);
	REP(i,N){
	  if(use[i]) continue;
	  VI buf;
	  PII tmp;
	  dfs(i, isps, ists, use, tmp, buf);
	  tmp.FF /= 2;
	  tmp.SS /= 2;
// 0 1 2 3 4 5 6 7 8 9
//lines:
// 4 1 5 4 3 5 5 3 5 4
//points:
// 4 0 4 2 1 4 4 2 4 3
//touching:
// 0 0 0 1 1 0 1 0 2 1
	  switch(SZ(buf)){
	  case 1:
		ans[1]++; break;
	  case 3:
		ans[(tmp.FF==1?4:7)]++; break;
	  case 4:
		if(tmp.FF==4) ans[0]++;
		else if(tmp.FF==2) ans[3]++;
		else ans[9]++;
		break;
	  case 5:
		if(tmp.SS==1) ans[6]++;
		else if(tmp.SS==2) ans[8]++;
		else{
		  int e1 = -1;
		  for(int x:buf) if(SZ(isps[x]) == 1) e1 = x;
		  int e2 = isps[e1][0];
		  ans[(istwo(ss[e1], ss[e2])?2:5)]++;
		}
		break;
	  }
	}

	REP(i,10) cout << (i?" ":"") << ans[i]; cout << endl;
  }

  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 1e5+5;

ll n, m;

int  main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    ll diff = abs(n-m), ans = 1;
    for(ll i=1; i<=n; i++)ans = ans*i%mod;
    for(ll i=1; i<=m; i++)ans = ans*i%mod;
    if(diff > 1)puts("0");
    else if(diff == 1)cout<<ans<<endl;
    else cout<<ans*2%mod<<endl;
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#define pi 2*asin(1)
using namespace std;

int dpm[10009];
int dpl[10009];
int xia[10009];
struct node
{
    int s,e,l,m;
} a[10009];
int main()
{
    int i,j;

    while(~scanf("%d%d",&i,&j),(i||j))
    {
        if(i%2==0||j%2==0)
            printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

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

int main() {
    string s,t;cin>>s>>t;
    int m = s.size();
    int n = t.size();
    rep(i,m){
    cout<<s[i];
    if(i<n)cout<<t[i];
    }
    cout<<endl;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            int n = line[0], m = line[1], l = line[2];

            var firstMatrix = CreateMatrix(n);
            var secondMatrix = CreateMatrix(m);

            var resultMatrix = CreateBlankMatrix(n, l);

            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < l; j++)
                {
                    var sum = 0L;
                    for (var k = 0; k < m; k++)
                    {
                        sum += firstMatrix[i][k] * secondMatrix[k][j];
                    }

                    resultMatrix[i][j] = sum;

                }
            }

            foreach (var ans in resultMatrix)
            {
                Console.WriteLine(string.Join(" ", ans));
            }

        }

        static int[][] CreateMatrix(int n)
        {
            var array = new int[n][];
            for (var i = 0; i < n; i++)
            {
                array[i] = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            }

            return array;
        }

        static long[][] CreateBlankMatrix(int n, int m)
        {
            var array = new long[n][];
            for (var i = 0; i < n; i++)
            {
                array[i] = new long[m];
            }

            return array;
        }

    }

}



Measured memory_bytes: 18500
n=int(input())
def count(num):
    total=0
    if int(num)>n:
        return 0
    if ("3" in num and "5" in num and "7" in num):
        total+=1
        #print(num)
    for i in "357":
        total+=count(num+i)
    return total
print(count("0"))

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,ans=0;
	cin>>n;
	ll d[n];
	forn(i,n){
		cin>>d[i];
	}
	forn(i,n){
		for(ll j = i+1; j<n; j++){
			ans+=d[i]*d[j];
		}
	}
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3536
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> C(h, vector<char>(w));
  vector<vector<char>> C_copy(h, vector<char>(w));

  rep1(i, h){
    rep1(j, w){
      cin >> C[i][j];
    }
  }

  int ans = 0;

 

  for (int bit1 = 0; bit1 < (1<<h); ++bit1) {
    for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
      //bit全探索の度に初期化
      rep1(i, h){
        copy(C[i].begin(), C[i].end(), C_copy[i].begin());
      }

      //横行を赤塗り
      for (int i = 0; i < h; i++) {
        if (bit1 & (1<<i)) { // 列挙に i が含まれるか
          rep1(k, w){
            C_copy[i][k] = ' ';
          }
        }
      }

      //縦列を赤塗り
      for (int j = 0; j < w; j++) {          
        if (bit2 & (1<<j)) { // 列挙に j が含まれるか
          rep1(l, h){
            C_copy[l][j] = ' ';
          }
        }
      }

      int tem = 0;
      //countチェック
      rep1(i, h){
        rep1(j, w){
          if(C_copy[i][j] == '#') tem += 1;
        }
      }
      if(tem == k) ans += 1;
    }

  }
  cout << ans;

}



Measured memory_bytes: 3620
from operator import itemgetter

n=int(input())
a=[int(x) for x in input().split()]
a_cm=[0]*n
a_i=[0]*n
for i in range(n):
    a_cm[i]=[i+1,a[i]]

a_cm.sort(key=itemgetter(1))
for i in range(n):
    a_i[i]=a_cm[i][0]

string=" ".join(map(str,a_i))
print(string)


Measured memory_bytes: 28516
import sys


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    results = {}
    p_list = []
    y_list = []
    cnt = 0
    for i in range(m):
        p, y = map(int, input().split())
        p_list.append(p)
        y_list.append(y)
        if results.get(p) is None:
            results[p] = [y]
        else:
            results[p].append(y)
    for i, p in results.items():
        p_sorted = sorted(p)
        results[i] = p_sorted

    for i, p in enumerate(p_list):
        import bisect
        print('{:006}'.format(p) + '{:006}'.format(bisect.bisect_left(results[p], y_list[i]) + 1))


if __name__ == "__main__":
    main()


Measured memory_bytes: 32460
#include <stdio.h>
 
int main(void) {
  int total = 0;
  char number;
  while (1) {
    number = getchar();
    if (number == EOF || number == '\n')
      break;
  	total += (number - '0');
  }
  if (total % 9 == 0)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1604
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  int x, h;
  double s, r;
  while (1){
    cin >> x >> h;
    if (x == 0){
      break;
    }
    s = x * x;
    r = (x / 2.0) * (x / 2.0) + h * h;
    r = sqrt(r);
    s += 2.0 * (r * x);
    printf("%f\n", s);
  }

  return 0;
}
    

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define rep(i, x, y) for (int i = (x); i <= (y); i ++)
#define down(i, x, y) for (int i = (x); i >= (y); i --)
#define mid ((l+r)/2)
#define lc (o<<1)
#define rc (o<<1|1)
#define pb push_back
#define mp make_pair
#define PII pair<int, int>
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long LL;
//head

const int N = 200010;
int n, m;
int tong[N];

const bool cmp(const int x, const int y){ return x > y; }

int main()
{
	scanf("%d%d", &n, &m); 
	rep(i, 1, n){ int x; scanf("%d", &x); tong[x] ++; }
	sort(tong+1, tong+1+n, cmp);
	int sum = 0;
	rep(i, 1, m) sum += tong[i];
	printf("%d\n", n - sum);
	return 0;
}

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

int main(){

    int n,a,b;
    cin >>n >> a>> b;

    cout << min(b,a*n) << endl;

    return 0;
}

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

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

	vector<int> h(n , 0);
	for(int &i : h){
		cin >> i;
	}

	vector<bool> is(n , true);

	for(int i = 0 ; i < e ; i++){
		int a ,b;
		cin >> a >> b;
		a--;b--;

		is[a] = is[a] && (h[a] > h[b]);
		is[b] = is[b] && (h[b] > h[a]);

		//cout << "a :: " << a << " is[a] :: " << is[a] << endl;
		//cout << "b :: " << b << " is[b] :: " << is[b] << endl;
	}

	/*
	cout << "array :: " ;
	for(int i = 0 ; i < n ; i++){
		cout << is[i] << " ";
	}
	cout << endl;
	*/

	int counter = 0;
	for(int i = 0 ; i < n ; i++){
		if (is[i]){counter++;}
	}

	cout << counter << endl;

	return 0;
}


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

string era;
int y,m,d;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> era,era!="#"){
        cin >> y >> m >> d;
        if (y==31&&4<m||31<y) era="?",y-=30;
        cout << era << ' ' << y << ' ' << m << ' ' << d << endl;
    }
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

ll pow(ll k) {
    ll res = 1;
    for(ll i = 0; i < k; i++) {
        res *= 2;
    }
    return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll N, M; cin >> N >> M;
    cout << ((N - M) * 100 + M * 1900) * pow(M) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  
  bool flag = false;
  for(int i = a; i <= b; i++){
    if(i % k == 0) flag = true;
  }
  if(flag){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#define rep(i,n) for (int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;

int main() {
  ll N, power=1;
  cin >> N;

  rep(i, N) power = power*i%(int)(1e9+7);
  cout << power <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

template<typename T>
struct Bellman {
  int n;
  Edges<T> es;
  vector<T> dist;
  vector<int> prev;
  UnWeightedGraph g1;
  UnWeightedGraph g2;
  vector<bool> r1;
  vector<bool> r2;
  bool is_negative = false;
  Bellman(int _n, Edges<T> _es) {
    init(_n, _es);
  }
  void init(int _n, Edges<T> _es) {
    n = _n; es = _es;
  }
  void reset() {
    dist.assign(n, inf);
    prev.assign(n, -1);
    is_negative = false;
  }
  void run(int s) {
    reset();
    dist[s] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      for (int i=0; i<(int)es.size(); i++) {
        edge<T> e = es[i];
        if (dist[e.src] == inf) continue;
        if (dist[e.to] > dist[e.src] + e.cost) {
          dist[e.to] = dist[e.src] + e.cost;
          prev[e.to] = e.src;
          upd = true;
        }
      }
      step++;
      if (step > n) {
        is_negative = true;
        return;
      }
    }
  }
  vector<int> getpath(int t) {
    vector<int> path;
    for (; t!=-1; t=prev[t]) path.push_back(t);
    return path;
  }
  void dfs(int s) { if (r1[s]) return; r1[s] = true; for (auto v:g1[s]) dfs(v); }
  void rdfs(int s) { if (r2[s]) return; r2[s] = true; for (auto v:g2[s]) rdfs(v); }
  void remove_unneccessary_edges(int s, int t) {
    g1.assign(n, vector<int>()); g2.assign(n, vector<int>());
    r1.assign(n, false); r2.assign(n, false);
    for (auto e:es) {
      g1[e.src].push_back(e.to);
      g2[e.to].push_back(e.src);
    }
    dfs(s); rdfs(t);
    Edges<T> new_es;
    for (auto e:es) {
      if (!(r1[e.src]&&r2[e.src]) || !(r1[e.to]&&r2[e.to])) continue;
      new_es.push_back(e);
    }
    es = new_es;
  }
};

int main()
{
  ll n,m,p; cin>>n>>m>>p;
  Edges<ll> es;
  rep(i, m) {
    int a,b; ll c;
    cin>>a>>b>>c;
    a--; b--;
    es.push_back(edge<ll>{a,b,p-c});
  }
  Bellman<ll> bl(n, es);
  bl.remove_unneccessary_edges(0, n-1);
  bl.run(0);
  if (bl.is_negative) {
    cout << -1 << endl;
    return 0;
  }
  cout << max(0LL, -bl.dist[n-1]) << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, x;
  x = 0;
  cin >> N;
  for( int i=0; i<N; i++){
    int l, r;
    cin >> l >> r;
    x += (r-l+1);}
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int R,G,B;
  cin>>R>>G>>B;
  int K;
  cin>>K;
  int t=0;
  while(G<=R){
    t++;
    G*=2;
  }
  while(B<=G){
    t++;
    B*=2;
  }
  if(t<=K)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD 1000000007

int main(){
    int N,pos,form; cin >> N;
    string S1,S2;
    ll ans;
    cin >> S1 >> S2;
    if(S1[0] == S2[0]){
        ans = 3;
        pos = 1;
        form = 0;
    }
    else{
        ans = 6;
        pos = 2;
        form = 1;
    }
    while(pos < N){
        if(S1[pos] == S2[pos]){
            if(form == 0) ans *= 2;
            ans %= MOD;
            form = 0;
            pos++;
        }
        else{
            if(form == 0) ans *= 2;
            else ans *= 3;
            ans %= MOD;
            form = 1;
            pos += 2;
        }
    }
    cout << ans << endl;
}	

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=1000005;
const int MOD=998244353;
int n,m;
int a[N];
long long c[N];
long long f[N];
int mu[N];
int prime[N],tot;
bool isprime[N];
void init(int n=1000000)
{
	for(int i=1;i<=n;i++)
		isprime[i]=true;
	isprime[1]=false;
	mu[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(isprime[i]) prime[++tot]=i,mu[i]=-1;
		for(int j=1;j<=tot&&i*prime[j]<=n;j++)
		{
			isprime[i*prime[j]]=false;
			if(i%prime[j]==0)
			{
				mu[i*prime[j]]=0;
				break;
			}
			mu[i*prime[j]]=-mu[i];
		}
	}
	for(int i=1;i<=n;i++)
		c[a[i]]=(c[a[i]]+a[i])%MOD;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			f[i]=(f[i]+c[j])%MOD;
	return;
}
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	init();
	m=1000000;
	long long ans=0;
	for(int d=1;d<=m;d++)
	{
		long long id=ksm(d,MOD-2);
		for(int t=1;t<=m/d;t++)
			ans=(ans+(id*mu[t]+MOD)*f[t*d]%MOD*f[t*d]%MOD)%MOD;
	}
	for(int i=1;i<=n;i++)
		ans=(ans-a[i]+MOD)%MOD;
	ans=ans*ksm(2,MOD-2)%MOD;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 25312
#include <iostream>

using namespace std;

int main () {
	int A, B, K;
	cin >> A >> B >> K;
	
	for (int i=0; ;) {
		++i;
		if (A % 2 == 0) {
			A = A/2;
		} else if (A == 2) {
			A = 1;
		} else {
			A = (A-1)/2;
		}
		B += A;
		if (i == K) break;
		++i;
		if (B % 2 == 0) {
			B = B/2;
		} else if (B == 2) {
			B = 1;
		} else {
			B = (B-1)/2;
		}
		A += B;
		if (i == K) break;
	}
	cout << A << " " << B << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    itn n;
    cin >> n;
    ll a[n];
    inrep(n,a);
    sort(a,a+n);
    int nn = a[n-1];
   
    int id = 0;
    rep(i,0,n-1){
	int aa = min(a[i], nn-a[i]);
	int bb = min(a[id],nn-a[id]);
	if(aa > bb){
	    id = i;
	}
    }

    PS(nn);
    P(a[id]);
    
    return  0;
}


Measured memory_bytes: 1024
require 'prime'

n = gets.to_i

primes = Hash.new(0)
(2..n).each { |i|
  i.prime_division.each { |p, n|
    primes[p] = primes[p] + n
  }
}

p primes.values.inject(1) { |mem, var| mem * (var + 1) } % (10 ** 9 + 7)


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

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

int lcs(char s1[],char s2[],int m,int n){
  int c[1001][1001];
  int i,j;
  int maxl = 0;

  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  for(j=1;j<=n;j++){
    c[0][j] = 0;
  }

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i-1] == s2[j-1]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }

  return maxl;
}


int main(){
  int n;
  int i;
  char s1[1001],s2[1001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1,s2,strlen(s1),strlen(s2)));
  }
  return 0;
}

Measured memory_bytes: 4512
using System;
using System.Collections.Generic;
using System.Linq;
using static CompetitiveProgramming.Utilities;

public class Program
{
    public static void Main(string[] args)
    {
        var A = Input.NextInt();
        var B = Input.NextInt();
        var C = Input.NextInt();

        if (A < C && C < B)
        {
            Console.WriteLine("Yes");
            return;
        }
        A = -A;
        B = -B;
        C = -C;
        if (A < C && C < B)
        {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

namespace CompetitiveProgramming
{
    public static class Utilities
    {
        public static IEnumerable<int> Range(int start, int count) => Enumerable.Range(start, count);
        public static IEnumerable<int> RangeTo(int start, int end) => Enumerable.Range(start, end - start);
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextLong();
        }
        int maxMove = 0;
        int move = 0;
        for (int i = 0; i < n - 1; i++) {
            if (h[i] >= h[i + 1]) {
                move++;
                maxMove = Math.max(maxMove, move);
                continue;
            }
            move = 0;
        }
        System.out.println(maxMove);
    }

}


Measured memory_bytes: 58964
#include<stdio.h>
int main(void)
{
	int n, x;
        int i, j, k;
	
    while (1) {
    	int count = 0;
        scanf("%d %d",&n,&x);
        if (n == 0 && x == 0){
        	break;
        }
        for (i=1; i<=n; i++) {
            for (j=i+1; j<=n; j++) {
                for (k=j+1; k<=n; k++) {
                    if (i+j+k==x){
                    	 count++;
                    	}
                   }
                  }
                }

        printf("%d\n", count);
    }
    
    
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;

  return 0;
}


Measured memory_bytes: 256
s = str(input())

if len(s)%2 == 0:
  a = s[:len(s)//2]
  b = s[len(s)//2:]
else:
  a = s[:len(s)//2]
  #_ = s[len(s)//2]
  b = s[(len(s)//2)+1:]
  
cnt = 0
for i,j in zip(a,b[::-1]):
  if i!=j:
    cnt += 1
  
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
const int N = 1e5+5;
using namespace std;
int n;
struct Node{
	int x;
	int y;
	int id;
	void show(){
		cout << this->x <<" "<<this->y<<" "<<this->id<<"\n";
	}
}a[N];
bool cmp1(const Node &a, const Node &b){
	if(a.x < b.x) return 1;
	if(a.x == b.x) return a.y < b.y;
	return 0;
}
bool cmp2(const Node &a, const Node &b){
	if(a.y < b.y) return 1;
	if(a.x == b.x) return a.x < b.x;
	return 0;
}
struct cmpp{
	bool operator()(const Node &a, const Node &b){
		if(a.x > b.x) return 1;
		if(a.x == b.x) return a.y > b.y;
		return 0;
	}
};
priority_queue<tuple<int,int,int>, vector<tuple<int,int,int>>, greater<tuple<int,int,int>> > pq;

int counting;
vector<int> par, children;

void Start(int n){
	counting = n;
 	par.assign(n+1,-1);
	children.assign(n+1,1);
	for(int i = 1; i <= n; ++i){
		par[i] = i;
	}
	return;
}

int Find(int i){
	if(par[i] != i) par[i] = Find(par[i]);
	return par[i];
}

bool Union(int i, int j){
	i = Find(i);
	j = Find(j);
	if(i != j){
		if(children[i] < children[j]){
			par[i] = j;
			children[j] += children[i];	
		}else{
			par[j] = i;
			children[i] += children[j];
		}
		counting--;
	}else return 0;
	return 1;
}

signed main(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i].x >> a[i].y;
		a[i].id = i; 
		
	}
	
	sort(a+1, a+1+n, cmp1);
	for(int i = 1; i <= n; ++i){
		if(i!=1) pq.push(make_tuple(abs(a[i].x - a[i-1].x), a[i].id, a[i-1].id));
	}

	sort(a+1, a+1+n, cmp2);
	for(int i = 1; i <= n; ++i){
		if(i!=1) pq.push(make_tuple(abs(a[i].y - a[i-1].y), a[i].id, a[i-1].id));
	}
	int ans = 0, dist, u, v;
	Start(n);
	while(pq.size()){
		if(counting == 1) break;
		tie(dist, u, v) = pq.top();
		pq.pop();
		if(Union(u, v)){ 
			ans += dist;
		}
	}
	cout << ans <<"\n";
}


Measured memory_bytes: 6004
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int S,W;
    cin >> S >> W;
    if(W>=S) cout << "unsafe";
    else cout << "safe";
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ll F(ll N,ll &A,ll &B,ll &C,ll &D,Map &M){
    if(M[N])return M[N];
    if(N==0)return 0;
    if(N==1)return D;
    ll a2=INF,a3=INF,a5=INF;
    ll b2,b3,b5;
    ll c2,c3,c5;
    b2=N%2;b3=N%3;b5=N%5;
    c2=N-b2;c3=N-b3;c5=N-b5;
    a2=b2*D+A+F(c2/2,A,B,C,D,M);
    a3=b3*D+B+F(c3/3,A,B,C,D,M);
    a5=b5*D+C+F(c5/5,A,B,C,D,M);
    if(c2/2+1<N){
        chmin(a2,(2-b2)*D+A+F(c2/2+1,A,B,C,D,M));
        double r=(double)(2-b2)+(double)(A/D);
        if(r>(N-(c2/2+1)))
        chmin(a2,D*(N-(c2/2+1))+F(c2/2+1,A,B,C,D,M));
    }
    if(c3/3+1<N){
        chmin(a3,(3-b3)*D+B+F(c3/3+1,A,B,C,D,M));
        double r=(double)(3-b3)+(double)(B/D);
        if(r>(N-(c3/3+1)))
        chmin(a3,D*(N-(c3/3+1))+F(c3/3+1,A,B,C,D,M));
    }
    if(c5/5+1<N){
        chmin(a5,(5-b5)*D+C+F(c5/5+1,A,B,C,D,M));
        double r=(double)(5-b5)+(double)(C/D);
        if(r>(N-(c5/5+1)))
        chmin(a5,D*(N-(c5/5+1))+F(c5/5+1,A,B,C,D,M));
    }
    return M[N]=(min(a2,min(a3,a5)));
}

int main(){
    ll T;
    cin >> T;
    for(ll i=0;i<T;i++){
        Map M;
        ll N,A,B,C,D;
        cin>>N>>A>>B>>C>>D;
        print(F(N,A,B,C,D,M))
    }
    return 0;
}


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

int main() {

	int a, b; cin >> a >> b;
	int ans;
	if (a <= 5) ans = 0;
	else if (13 <= a) ans = b;
	else ans = b / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3488
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a==0&&b==0){
				break;
			}
			if(a>b){
				System.out.println(b+" "+a);
			}
			else{
				System.out.println(a+" "+b);
			}
		}
	}
}


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

int x, ans;

int main(){
    /*
    cin >> ans;
    while(1){
        if(ans % 10 == (ans%100-ans%10)/10 && ans % 10 == (ans-ans%100)/100){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
    */
   cin >> x;
   for(int i = 0; i += 111; i <= 999){
       if(i >= x){
           cout << i << endl;
           return 0;
       }
   }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin>>N>>L;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    a.at(i)=L+i;
  }
  int s=0;
  for(int i=0;i<N;i++){
    s+=a.at(i);
  }
  int ans=1e9;
  for(int i=0;i<N;i++){
    int t=s-a.at(i);
    if(abs(t-s)<abs(ans-s)){
      
    ans=t;
    }
  }
  cout<<ans<<endl;
  return 0;
}


  
  


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

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

Measured memory_bytes: 3584
module String = struct
  include String
  let to_list s =
    let rec loop acc = function
      | 0 -> acc
      | n -> loop (s.[n - 1] :: acc) (n - 1) in
    loop [] (String.length s)
end

let () =
  let n, a, b = Scanf.scanf "%d %d %d\n" (fun n a b -> n, a, b) in
  let s = Scanf.scanf "%s\n" (fun s -> s) in
  String.to_list s
    |> List.fold_left (fun (accepted, foreigners) -> function
      | 'a' ->
          if accepted < a + b then begin
            print_endline "Yes";
            (accepted + 1, foreigners)
          end else begin
            print_endline "No";
            (accepted, foreigners)
          end
      | 'b' ->
          if accepted < a + b && foreigners < b then begin
            print_endline "Yes";
            (accepted + 1, foreigners + 1)
          end else begin
            print_endline "No";
            (accepted, foreigners + 1)
          end
      | 'c' -> print_endline "No"; (accepted, foreigners)) (0, 0)
    |> ignore

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  if(B / A >= C)
  {
    cout << C << endl;
  }
  else
  {
    cout << B / A << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<int,int>
#define MAX 100006
#define CASE(i) printf("Case %d:\n", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)

using namespace std;

int arr[100005], cnt[100005];
int current[100005];

int main()
{
    int n, l;
    scanf("%d %d", &n, &l);
    int flag = -1;
    for(int i=1; i<=n; i++)
    {
        scanf("%d", arr+i);
        if(i>1){
            if(arr[i] + arr[i-1]>=l)  flag = i-1;
        }
    }

    if(flag == -1){
        printf("Impossible");
    }
    else{
        printf("Possible\n");
        for(int i=1; i<flag; i++) printf("%d\n", i);
        for(int i=n-1; i>flag; i--) printf("%d\n", i);
        printf("%d", flag);
    }
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d%d",&x,&y)
#define cin3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main(){
	int m,d;
	cin2(m,d);
	int ans=0;
	while(d){
		int d1=d/10;
		int d10=d%10;
		d--;
		if(d1==0 || d10==0 || d1<2 || d10<2)
			continue;
		int mm=d1*d10;
		if(mm<=m){
//			cout<<mm<<" "<<d1<<" "<<d10<<"\n";
			ans++;
		}
	}
	cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder.Beginner141
{
    public static class A
    {
        public static void Main()
        {
            string today = Console.ReadLine();
            string tomorrow = "";
            switch (today)
            {
                case "Sunny":
                    tomorrow = "Cloudy";
                    break;
                case "Cloudy":
                    tomorrow = "Rainy";
                    break;
                case "Rainy":
                    tomorrow = "Sunny";
                    break;
            }
            Console.WriteLine(tomorrow);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    if(a==7){
        cout<<"YES";
    }else if(a==5){
        cout<<"YES";
    }else if(a==3){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}

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

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

    int h, w;
    cin >> h >> w;
    char C[h][w];
    int Dist[h][w] = {};
    int sc = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
            sc += (C[i][j] == '#');
            Dist[i][j] = 1e9;
        }
    }
    Dist[0][0] = 1;

    int dx[2] = {0, 1};
    int dy[2] = {1, 0};

    queue<pair<int, int>> q;
    q.push({0, 0});

    while(!q.empty()){
        pair<int, int> p = q.front();
        q.pop();

        int x = p.first;
        int y = p.second;
        for(int i = 0; i < 2; i++){
            int nx = dx[i] + x;
            int ny = dy[i] + y;
            if(nx < 0 or ny < 0 or nx >= h or ny >= w) continue;
            if(C[nx][ny] == '.') continue;
            if(Dist[nx][ny] > Dist[x][y] + 1){
                Dist[nx][ny] = Dist[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }

    if(Dist[h - 1][w - 1] == -1 or sc - Dist[h - 1][w - 1] != 0) cout << "Impossible" << endl;
    else cout << "Possible" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int a, b, n;
    while (cin >> a >> b >> n) {
        int sum = 0;
        a %= b;
        for (int i=0; i<n; ++i) {
            a *= 10;
            sum += a / b;
            a %= b;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
bool Bingo(vector<vector<int> >&A) 
{
    for (int i = 0; i < 3; i++) {
        if (A.at(0).at(i) == A.at(1).at(i) && A.at(1).at(i) == A.at(2).at(i) && A.at(2).at(i) == 0) return true;
        else if (A.at(i).at(0) == A.at(i).at(1) && A.at(i).at(1) == A.at(i).at(2) && A.at(i).at(2) == 0) return true;
    }
    if (A.at(0).at(0) == A.at(1).at(1) && A.at(1).at(1) == A.at(2).at(2) && A.at(2).at(2) == 0) return true;
    else if (A.at(2).at(0) == A.at(1).at(1) && A.at(1).at(1) == A.at(0).at(2) && A.at(0).at(2) == 0) return true;

    return false;
}
int main() {
    vector<vector<int> >A(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int>B(N);
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (A.at(j).at(k) == B.at(i)) A.at(j).at(k) = 0;
            }
        }
    }
    if (Bingo(A)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000010
#define int long long
using namespace std;
struct data
{
	int a,b;
	bool operator<(const data&e)const
	{
		if(a!=e.a)return a<e.a;
		return b<e.b;
	}
};
int to[N<<1],val[N<<1],nxt[N<<1],head[N],cnt,a1,b1,a2,b2,dis[N],size[N],fa[N],n,x,y,l,r,ans;
vector<data> g[N],o;
void adde(int x,int y,int z)
{
	to[++cnt]=y;
	nxt[cnt]=head[x];
	val[cnt]=z;
	head[x]=cnt;
}
int get(int u,int v,int z)
{
	int ll=0,rr=g[v].size()-1,anss=0;
	while(ll<rr-1)
	{
		int mid=(ll+rr)/2;
		a2=g[v][mid].a;
		b2=g[v][mid].b;
		if(b1+a2+dis[u]+dis[v]<=z)
		{
			ll=mid;
		}else{
			rr=mid;
		}
	}
	a2=g[v][rr].a,b2=g[v][rr].b;
	if(b1+a2+dis[u]+dis[v]<=z)return rr;
	a2=g[v][ll].a,b2=g[v][ll].b;
	if(b1+a2+dis[u]+dis[v]<=z)return ll;
	return -1;
}
void merge(int u,int z)
{
	int lson=0,rson=0;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=fa[u])
		{
			if(!lson)
			{
				lson=v;
			}else{
				rson=v;
			}
		}
	}
	if(size[lson]>size[rson])
	{
		swap(lson,rson);
	}
	int lenl=g[lson].size(),lenr=g[rson].size();
	if(!lenl||!lenr)
	{
		return;
	}
	o.clear();
	for(int i=0;i<lenl;i++)
	{
		a1=g[lson][i].a;
		b1=g[lson][i].b;
		if(get(lson,rson,z)==-1)
		{
			continue;
		}
		o.push_back((data){
		a1+dis[lson],b2+dis[rson]	
		});
		o.push_back((data){
		b2+dis[rson],a1+dis[lson]	
		});
	}
	sort(o.begin(),o.end());
	int leno=o.size(),minn=0x7fffffffffffffff;
	for(int i=0;i<leno;i++)
	{
		if(o[i].b<minn)
		{
			minn=o[i].b;
			g[u].push_back(o[i]);
		}
	}
}
void dfs(int u,int faa,int z)
{
	int son=0;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v!=faa)
		{
			fa[v]=u;
			dis[v]=val[i];
			dfs(v,u,z);
			son++;
			size[u]+=size[v];
			if(son==2)
			{
				merge(u,z);
			}
		}
	}
	if(!son)
	{
		g[u].push_back((data){
			0,0
		});
	}
}
bool check(int len)
{
	for(int i=1;i<=n;i++)
	{
		g[i].clear();
	}
	dfs(1,-1,len);
	if(g[1].size()>0)
	{
		return 1;
	}
	return 0;
}
signed main()
{
    scanf("%lld",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		adde(i+1,x,y);
		adde(x,i+1,y);
		r+=y;
	}
	while(l<r-1)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			r=mid;
		}else{
			l=mid;
		}
	}
	if(check(l))printf("%lld",l);
	else printf("%lld",r);
	return 0;
} 

Measured memory_bytes: 70004
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
input:
    ll n;
    cin >> n;
    ll x[n], y[n];
    rep(i, n) { cin >> x[i] >> y[i]; }

calculate:
    ll route[n];
    rep(i, n) { route[i] = i; }

    ll count = 0;
    double total = 0;
    do {
        count++;
        double path = 0;
        rep(i, n - 1) {
            double x_double = x[route[i + 1]] - x[route[i]];
            x_double *= x_double;
            double y_double = y[route[i + 1]] - y[route[i]];
            y_double *= y_double;

            total += sqrt(x_double + y_double);
        }
    } while (next_permutation(route, route + n));

    double ave = total / count;

    printf("%.10f\n", ave);
    return 0;
}



Measured memory_bytes: 256
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Time to solve: 
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long[] dp = new long[N];
         Arrays.fill(dp, Integer.MAX_VALUE);
         dp[0] = 0;
         for(int i=0; i < N; i++)
         {
            if(dp[i] == Integer.MAX_VALUE)
               continue;
            if(i+1 < N)
               dp[i+1] = Math.min(dp[i+1], dp[i]+Math.abs(arr[i]-arr[i+1]));
            if(i+2 < N)
               dp[i+2] = Math.min(dp[i+2], dp[i]+Math.abs(arr[i]-arr[i+2]));
         }
         System.out.println(dp[N-1]);
      }
   }

Measured memory_bytes: 31888
s = list(input())

a = []
k = 0
for z in s:
  if z == "T":
    a += [k]
    k = 0
  else:
    k += 1
a += [k]
# print(a)

l = [a[0]]
for k in a[2::2]:
  if k == 0:
    continue
  l = [t+k for t in l] + [t-k for t in l]
  l = list(set(l))

m = [0]
for k in a[1::2]:
  if k == 0:
    continue
  m = [t+k for t in m] + [t-k for t in m]
  m = list(set(m))

x,y = map(int,input().split())
print("Yes" if x in l and y in m else "No")


Measured memory_bytes: 3904
MAX_INT = int(10e10)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W,N = IL()
Sr,Sc = IL()
s = S()
t = S()

U = s.count("U")
D = s.count("D")
L = s.count("L")
R = N - (U+D+L)

if U >= Sr:
    cnt = Sr
    for i in range(N):
        if s[i] == "U":
            cnt -= 1
        if cnt == 0:
            print("NO")
            exit()
        if t[i] == "D":
            cnt = min(cnt+1,H)

if D >= H-Sr+1:
    cnt = Sr
    for i in range(N):
        if s[i] == "D":
            cnt += 1
        if cnt == H+1:
            print("NO")
            exit()
        if t[i] == "U":
            cnt = max(cnt-1,1)

if L >= Sc:
    cnt = Sc
    for i in range(N):
        if s[i] == "L":
            cnt -= 1
        if cnt == 0:
            print("NO")
            exit()
        if t[i] == "R":
            cnt = min(cnt+1,W)

if R >= W-Sc+1:
    cnt = Sc
    for i in range(N):
        if s[i] == "R":
            cnt += 1
        if cnt == W+1:
            print("NO")
            exit()
        if t[i] == "L":
            cnt = max(cnt-1,1)

print("YES")

Measured memory_bytes: 42912