akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

double roundp(double x, int p) {
  double t = pow(10, p);
  return double((int) (x * t + 0.5)) / t;
}

template<typename T>
constexpr T det2(const T &a1, const T &a2, const T &b1, const T &b2) {
  return a1 * b2 - b1 * a2;
}

void solve() {
  int n;
  cin >> n;
  rep(i, n) {
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double d1 = x1 * x1 + y1 * y1, d2 = x2 * x2 + y2 * y2, d3 = x3 * x3 + y3 * y3;
    double npx = det2(d1, d2, y1, y2) + det2(d2, d3, y2, y3) + det2(d3, d1, y3, y1);
    double npy = det2(d2, d1, x2, x1) + det2(d3, d2, x3, x2) + det2(d1, d3, x1, x3);
    double dp  = 2 * (det2(x1, x2, y1, y2) + det2(x2, x3, y2, y3) + det2(x3, x1, y3, y1));
    double px = npx / dp, py = npy / dp;
    double r = hypot(px - x1, py - y1);
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
    #ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,m,p;
    cin>>n>>m>>p;
    vector<pair<ll,pair<ll,ll> > > v;
    for(int i=1;i<=m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        v.pb(mp(p-c,mp(a,b)));
    }

    ll dist[n+5] = {0};
    for(int i=2;i<=n;i++)dist[i]=INF; 
    for(int i=1;i<n;i++){
        for(int j=0;j<m;j++){
            int x = v[j].second.first;
            int y = v[j].second.second;
            ll d = v[j].first;
            if(dist[y]>dist[x]+d){
                dist[y] = dist[x]+d;
            }
       }
    }

    if(dist[n] == INF){cout << "-1\n";return 0;}
    ll ans = dist[n];

    for(int i=1;i<=n-1;i++){
        for(int j=0;j<m;j++){
            int x = v[j].second.first;
            int y = v[j].second.second;
            ll d = v[j].first;
            if(dist[y]>dist[x]+d){
                dist[y] = dist[x] + d;
            }
        }
    }

    if(dist[n]<ans){cout << "-1\n";}
    else {
        cout << max(-dist[n],(ll)0) << "\n";
    }

    return 0;   
}

Measured memory_bytes: 576
#include<stdio.h>
#include<string.h>
int main() {

    char str[21],rev[21];
    int i,j;
    memset(str,'\0', 21);
    scanf("%s",str);
    j=0;
    for (i = 0; i < 21; i++) {
        if (str[20-i]!='\0'){
             rev[j]=str[20-i];
             j++;
         }
    }

    for (i = 0; i < 21-j; i++) {
    rev[i+j]='\0';
    }
    //printf("%s\n",str);
    printf("%s\n",rev);


    return 0;
}

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

class MainClass
{
    static void Main()
    {
        var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];

        long test = M * 1900 + (N - M) * 100;
        Console.WriteLine(test * (long)Math.Pow(2,M));
    }
}

Measured memory_bytes: 28532
import sys
readline = sys.stdin.readline
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt
def shellSort(A, n):
    cnt = 0
    h = 4
    G = [1]
    while h < n:
        G += [h]
        h = 3 * h + 1
    m = len(G)
    for i in range(m - 1, -1, -1):
        cnt = insertionSort(A, n, G[i], cnt)
    print(m)
    print(*G[::-1])
    print(cnt)
    print(*A, sep="\n")
n = int(input())
A = [int(readline()) for _ in range(n)]
shellSort(A, n)



Measured memory_bytes: 53288
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{

    string n;
    cin >> n;
    if(n[0]=='7' || n[1] =='7' || n[2]=='7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
n,m,x=map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

ans = 1234567890123

for bit in range(1<<n):
    syu = [0]*m
    cost = 0
    for i in range(n):
        if (bit>>i)&1:
            cost += ca[i][0]
            for j in range(1,m+1):
                syu[j-1] += ca[i][j]
    ok = True
    if not False in list(map(lambda a: a >= x,syu)):
        ans = min(ans,cost)
print(ans if ans != 1234567890123 else -1)


Measured memory_bytes: 68852
#include <stdio.h>

long long cnt;
int N;
int A[1000000];
int G[20];
int m = 0;

void insertionSort(int A[], int N, int g)
{
    for (int i = g; i < N; i++) {
        int v = A[i];
        int j = i-g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int N)
{
    int h = 1;
    for (int i = 0; ; i++) {
        if (h > N) break;
        G[i] = h;
        h = 3*h + 1;
        m++;
    }

    for (int i = m; i >= 0; i--) {
           insertionSort(A, N, G[i]);
    }
}

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, N);

    printf("%d\n", m);
    for (int i = m-1; i>= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%lld\n", cnt);
    for (int i = 0; i < N; i++) printf("%d\n", A[i]);

    return 0;
}


Measured memory_bytes: 5692
info = list(map(int,input().split()))
k=info[0]
n=info[1]
a = list(map(int,input().split()))
MAX=0

for i in range(n-1):
    if a[i+1]-a[i] > MAX:
        MAX=a[i+1]-a[i]
if a[0]+k-a[n-1] > MAX:
        MAX=a[0]+k-a[n-1]
print(str(k-MAX))

Measured memory_bytes: 26444
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N], Q = new int[N];
		for(int i = 0; i < N; i ++) {
			P[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i ++) {
			Q[i] = sc.nextInt();
		}
	

		long a = ch(N,P), b = ch(N,Q);
		long ans = Math.abs(a-b);
		System.out.println(ans);
	}

	public static long check(int N ,int[] li) {
		ArrayList<Integer> lis = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5,6,7,8));
		long num = 0l;
		int bef = 9;
		for(int i = 0; i < N-1; i++) {
			int x = li[i];
			int m = lis.indexOf(x);
			lis.remove(m);
			long be =0l;
			be = fun(N-i);
			num += be;
		}
		num += 1;
		return num;
	}
	
	public static long ch (int N ,int[] li) {
		ArrayList<Integer> lis = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5,6,7,8));
		int count = 0;
		for(int i = 0; i < N-1; i ++) {
			int x = li[i];
			int m = lis.indexOf(x);
			lis.remove(m);
			count += fun(N-1-i)*m;
		}
		return count;
	}
	
	public static int fun(int n ) {
		int ans = 1;
		for(int i = 0; i < n; i++) {
			ans = ans*(n-i);
		}
		return ans;
	}
}

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int winner = 100;
    rep(i,10000){
        if (a-i*d <= 0 && c-i*b > 0){
            winner = 0;
            break;
        }
        if (a-i*d > 0 && c-i*b <= 0){
            winner = 1;
            break;
        }
    }
    if (winner == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3612
N, M, X = map(int, input().split(' '))
A, C = [], []
for n in range(N):
  inp = list(map(int, input().split(' ')))
  C.append(inp[0])
  A.append(inp[1:])
  
def proceed_step(remained, current_cost, n):
  global N, X
  remained_next = []
  
  if not remained: return current_cost
  if n == N: return float('inf')
  
  for algorithm in remained:
    m, current_sum = algorithm[0], algorithm[1]
    current_sum += A[n][m]
    if current_sum < X:
      remained_next.append([m, current_sum])
      
  return min(proceed_step(remained, current_cost, n+1),
             proceed_step(remained_next, current_cost + C[n], n+1))

remained = [[m, 0] for m in range(M)]
total_cost = proceed_step(remained, current_cost=0, n=0)
if total_cost == float('inf'): print(-1)
else: print(total_cost)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    int ans = r*100 + g*10 + b;
    if (ans % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 892
letters = ["L", "R", "U", "D"]
odd = "RUD"
even = "LUD"
S = input()
i = 0
result = "Yes"
for s in S:
  if i % 2 == 0:
    if s not in odd:
      result = "No"
      break
  else:
    if s not in even:
      result = "No"
      break
  i+=1

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int cnt = 0;
	while (B <= A) {
		cnt++;
		B *= 2;
	}
	while (C <= B) {
		cnt++;
		C *= 2;
	}
	if (cnt <= K) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3596
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str,ptr;


 cin>>n;

    ll ara[n+2];

    input(ara,n);

    for(i=n-2; i>=0; i--)
    {
        if(ara[i]>=ara[i+1])cnt++;

       else{
        ans=max(ans,cnt);
        cnt=0;
       }
    }
    ans=max(cnt,ans);

    cout<<ans<<endl;









}



Measured memory_bytes: 4368
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, K = map(int, input().split())
A = list(map(int, input().split()))
# A.sort()
# print(A)

def is_ok(val):
    cnt = 0
    for a in A:
        if a%val == 0:
            cnt += a//val - 1
        else:
            cnt += a//val
    # ls = ([a//val for a in A])
    # print(ls)
    # cnt = sum(ls)
    # print('val, cnt', val, cnt)
    if cnt <= K:
        return True
    else:
        return False

ng = 0
ok = max(A)
while (abs(ok-ng)>1):
    mid = (ok+ng) // 2
    # print(mid, is_ok(mid))
    if is_ok(mid):
        ok = mid
    else:
        ng = mid
    # return ok
print(ok)



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

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

N = INT()
a = LIST()

dic = defaultdict(int)

for n in a:
	dic[n] += 1

ans = 0
for key in dic.keys():
	if dic[key] < key:
		ans += dic[key]
	else:
		ans += dic[key]-key
print(ans)


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

int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt=0;
    while(a>0 && c>0)
    {
        if(!cnt){c=c-b;cnt=1;}
        else{a=a-d;cnt=0;}
    }
    if(a<=0){cout<<"No";}
    else{cout<<"Yes";}
     return 0;
    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> pl;
const int INF=100000001;

int main(){
  int n,d; cin>>n>>d;
  int ans=n/(2*d+1);
  if(n%(2*d+1)!=0)
  ans++;

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import math
import decimal

# 標準入力 <int><int>
A, B = map(int, input().split())

tax8 = decimal.Decimal('0.08')
tax10 = decimal.Decimal('0.1')

ans = -1

for i in range(1, 1100):
    if math.floor(i * tax8) == A and math.floor(i * tax10) == B:
        ans = i
        break

print(ans)


Measured memory_bytes: 5332
#include <bits/stdc++.h>
#define int long long

using namespace std;

constexpr int MAXN = 1e5 + 5, MOD = 1e9 + 7;

int n, ans, ans2, x, m, arr[MAXN], sum[MAXN], vis[MAXN], sz;

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> x >> m;
    ans += x;
    int i;
    for (i = 1; i < n; i++) {
        x = x * x % m;
        ans2 += x;
        if (x == 0) return cout << ans2 + ans, 0;
        if (!vis[x]) {
            arr[i] = x;
            vis[x] = i;
        } else {
            i--;
            sz = i - vis[x] + 1;
            break;
        }
    }
    if (!sz) return cout << ans2 + ans << endl, 0;
    int cnt = (n - vis[x]) / sz, res = (n - vis[x]) % sz;
    for (int j = 1; j <= i; j++)
        sum[j] = sum[j - 1] + arr[j];
    ans += sum[vis[x] - 1];
    ans += (sum[i] - sum[vis[x] - 1]) * cnt;
    ans += (sum[vis[x] - 1 + res] - sum[vis[x] - 1]);
    cout << ans << endl;
    return 0;
}
//492443256176507
//491945869537148


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	int b[3][3] = {0};
	bool check[3][3] = {false};
	rep (i, 3) rep (j, 3) cin >> b[i][j];
	cin >> n;
	rep (i, n) {
	  int x;
	  cin >> x;
	  rep (j, 3) {
		rep (k, 3) {
		  if (b[j][k] == x) check[j][k] = true;
		}
	  }
	}
	bool ok = false;
	rep (i, 3) {
	  bool tmp = true;
	  rep (j, 3) {
		if (!check[i][j]) tmp = false;
	  }
	  ok |= tmp;
	}
	rep (j, 3) {
	  bool tmp = true;
	  rep (i, 3) {
		if (!check[i][j]) tmp = false;
	  }
	  ok |= tmp;
	}
	if (check[0][0] && check[1][1] && check[2][2]) ok = true;
	if (check[0][2] && check[1][1] && check[2][0]) ok = true;
	cout << (ok ? "Yes" : "No") << endl;
	
    return 0;
}



Measured memory_bytes: 3632
N = int(input())

towns = []
for i in range(N):
    x, y = map(int, input().split())
    towns.append((i, x, y))

# x, y座標の値でソートして、隣接する街の間の道を、隣接リストadjに追加する
adj = [[] for i in range(N)]
for xy in [1, 2]:
    towns.sort(key=lambda t: t[xy])
    for i in range(N - 1):
        t1 = towns[i][0]
        t2 = towns[i + 1][0]
        cost = min(abs(towns[i + 1][1] - towns[i][1]), abs(towns[i + 1][2] - towns[i][2]))#towns[i + 1][xy] - towns[i][xy]
        adj[t1].append((t2, cost))
        adj[t2].append((t1, cost))

# 最小全域木を求める（プリム法）
import heapq
pq = []
heapq.heappush(pq, (0, 0))

done = set()
ans = 0
while pq:
    cost, v_now = heapq.heappop(pq)

    if v_now in done:
        continue

    ans += cost
    done.add(v_now)

    if len(done) == N:
        break

    for v, c in adj[v_now]:
        if v not in done:
            heapq.heappush(pq, (c, v))

print(ans)

Measured memory_bytes: 77376
package main

import "fmt"

func main() {
	var a, b, x int
	fmt.Scanf("%d %d %d", &a, &b, &x)

	if a > x {
		fmt.Println("NO")
	} else if b-(x-a) < 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int k; cin >> k;
  vector<int> a(k);
  for(int i = 0; i < k; i++){
    cin >> a[i];
  }

  auto f = [&](int mid){
    for(int i = 0; i < k; i++){
      mid = (mid / a[i]) * a[i];
    }
    return mid;
  };

  int left = -1,right = (int)1e14;
  while(right - left > 1){
    int mid = (left + right) / 2;

    if(f(mid) >= 2) right = mid;
    else left = mid;
  }
  int ans_l = right;

  auto f2 = [&](int mid){
    for(int i = 0; i < k; i++){
      mid = (mid / a[i]) * a[i];
    }
    return mid > 2;
  };

  left = -1,right = (int)1e14;
  while(right - left > 1){
    int mid = (left + right) / 2;

    if(f2(mid)) right = mid;
    else left = mid;
  }
  int ans_r = right-1;

  if(f(ans_l) != 2){
    cout << -1 << endl;
  }else {
    cout << ans_l << " " << ans_r << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
using namespace std;

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

    string c;
    int d;
    map<string, set<int>> ma;

    for(int i = 0; i < n; i++){
        cin >> c >> d;
        ma[c].insert(d);
    }

    int m;
    cin >> m;

    int now = 0;
    for(int i = 0; i < m; i++){
        cin >> c;
        auto it = ma[c].upper_bound(now);
        if(it == ma[c].end()){
            cout << "No" << endl;
            return 0;
        }
        now = *it;
        ma[c].erase(it);
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 25056
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
R, B = N - K, K
ans = R + 1
print(ans)
for i in range(2, B + 1):
    ans = ans * (R - i + 2) * (B - i + 1) // (i * (i - 1))
    print(ans % MOD)


Measured memory_bytes: 41584
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL N = 1000000007;

LL n,m;

struct edge{
	LL u,v,w;
}s[2005]; LL in[2005] = {0};
bool cmp(edge x,edge y){
	return x.w < y.w;
}

LL pwr(LL x,LL y){
	LL ret = 1LL;
	while(y --) ret = (ret * x) % N; return ret;
}

LL ec = 0, to[8005],nxt[8005],hed[4005] = {0},we[8005],wv[4005];
void add_edge(LL f,LL t,LL cst){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; we[ec] = cst;
}

LL ffa[4005];
LL getf(LL x){
	if(x == ffa[x]) return x;
	return ffa[x] = getf(ffa[x]);
}

LL kruscal(){
	LL ret = 0;
	for(LL i = 1;i <= n;i ++) ffa[i] = i;
	for(LL i = 1;i <= m;i ++){
		if(getf(s[i].u) == getf(s[i].v)) continue;
		ffa[getf(s[i].u)] = getf(s[i].v);
		ret += s[i].w; in[i] = 1;
		add_edge(s[i].u,s[i].v,s[i].w);
		add_edge(s[i].v,s[i].u,s[i].w);
	}
	return ret;
}

LL dep[4005] = {0},fa[4005] = {0};
void dfs(LL u,LL f){
	fa[u] = f;
	dep[u] = dep[f] + 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		wv[v] = we[i];
		dfs(v,u);
	}
}

LL path_max(LL x,LL y){
	LL ret = 0;
	if(dep[x] < dep[y]) swap(x,y);
	while(dep[x] > dep[y]){
		ret = max(ret,wv[x]);
		x = fa[x];
	}
	while(x != y){
		ret = max(ret,max(wv[x],wv[y]));
		x = fa[x]; y = fa[y];
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	LL k,mst,equ = 0,cnt = 0,ans;
	cin >> n >> m >> k;
	for(LL i = 1;i <= m;i ++) cin >> s[i].u >> s[i].v >> s[i].w;
	sort(s + 1,s + 1 + m,cmp); mst = kruscal();
	dfs(1,0);
	
	if(k < mst){
		cout << 0 << endl;
		return 0;
	}
	if(k == mst){
		equ = n - 2;
		for(LL i = 1;i <= m;i ++){
			if(in[i]) continue;
			LL val = s[i].w - path_max(s[i].u,s[i].v);
			if(mst + val == k) equ ++;
			if(mst + val > k) cnt ++;
		}
		ans = (((2LL * pwr(2LL,cnt)) % N) * (pwr(2LL,equ) + N - 1LL)) % N;
	}
	if(k > mst){
		for(LL i = 1;i <= m;i ++){
			if(in[i]) continue;
			LL val = s[i].w - path_max(s[i].u,s[i].v);
			if(mst + val == k) equ ++;
			if(mst + val > k) cnt ++;
		}
		ans = (((2LL * pwr(2LL,cnt)) % N) * (pwr(2LL,equ) + N - 1LL)) % N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    int cnt=0;
    for(auto c:s){
        if(c=='2')cnt++;
    }
    cout<<cnt<<endl;
 return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct dot{
	double x,y;
	double len(){return sqrt(x*x+y*y);}
	dot(double a=0.0,double b=0.0){x=a,y=b;}
	dot operator +(const dot&b)const {return dot(x+b.x,y+b.y);}
	dot operator -(const dot&b)const {return dot(x-b.x,y-b.y);}
	dot operator *(const double&z)const {return dot(x*z,y*z);}
	bool operator <(const dot&b)const {return (x<b.x)||(x==b.x&&y<b.y);}
};
struct line{
	dot x1,x2;
};
double chaji(dot x,dot y){
	return x.x*y.y-x.y*y.x;
}
double neiji(dot x,dot y){
	return x.x*y.x+x.y*y.y;
}
double cos(dot x,dot y){
	if (!x.len()||!y.len())return 0;
	return neiji(x,y)/x.len()/y.len();
}
dot Projection(dot x,line y){//求x关于直线y的投影点（垂足） 
	y.x2=y.x2-y.x1;
	x=x-y.x1;
	double len=cos(x,y.x2)*x.len()/y.x2.len();
	y.x2=y.x2*len;
	return y.x2+y.x1;
}
dot Reflection(dot x,line y){
	dot z=Projection(x,y);
	return z*2-x;
}
int main(){
	line x;int T;
	scanf("%lf%lf%lf%lf",&x.x1.x,&x.x1.y,&x.x2.x,&x.x2.y);
	scanf("%d",&T);
	while (T--){
		dot y;
		scanf("%lf%lf",&y.x,&y.y);
		dot ans=Reflection(y,x);
		printf("%.10lf %.10lf\n",ans.x,ans.y);
	}
	return 0;
}



Measured memory_bytes: 3256
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{
	static int MAX = 222220;
	static boolean[] sieve = new boolean[MAX+1];
	static int[] primes = new int[5637];
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		sieve[0] = true;
		sieve[1] = true;
		for(long i = 2; i <= MAX; i++)
		{
			if(!sieve[(int)i])
				for(long j = i*i; j <= MAX; j+=i)
				{
					sieve[(int)j] = true;
				}
		}
		int f = 55555;
		int pr = 0;
		for(int i = 2; i <= f; i++)
		{
			if(pr >=5637)break;
			if(!sieve[i])
			{
				primes[pr] = i;
				pr++;
			}
		}
//		System.out.println(Arrays.toString(primes));
//		System.out.println(pr);
		
		ArrayList<Integer> l = new ArrayList<>();
		
		StringBuilder sb = new StringBuilder();
		int cur = 0;
		while(l.size()<n)
		{
			long curp = primes[cur];
			while(primes[cur]%5!=1)cur++;
			curp = primes[cur];
			l.add(primes[cur]);
			if(l.size()>1)sb.append(' ');
			sb.append(primes[cur]);
			cur++;
		}
		
		System.out.println(sb);
			
	}

}


Measured memory_bytes: 20052
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

ans = sum(b_list)

for i in range(N - 1):
    if a_list[i] + 1 == a_list[i + 1]:
        ans += c_list[a_list[i]-1]
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>
#include<string.h>
using namespace std;
// log10(x)+1  number of digits 
void bubblesort(int arr[], int n);
int arr2[200001];
int main()
{
	int arr[200001];
	int n;
	cin >> n;
	for (int i = 0; i < n-1; i++)
	{
		cin >> arr[i];
		arr2[arr[i]]++;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << arr2[i] << "\n";
	}
}
void bubblesort(int arr[], int n)
{
	int i = 0, j = 0;
	for (; i < n - 1; i++)
	{
		for (; j < n - 1 - i; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				swap(*&arr[j], *&arr[j + 1]);
			}
		}
	}
}

Measured memory_bytes: 5144
# coding:utf-8

# 解答みながらの復習

S = str(input())
T = str(input())

Sdic = [0 for _ in range(26)]
Tdic = [0 for _ in range(26)]

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",\
    "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

Able = True

for i in range(len(S)):
    si = S[i]
    ti = T[i]
    if Sdic[alphabet.index(si)] == 0:
        Sdic[alphabet.index(si)] = ti
    elif Sdic[alphabet.index(si)] != ti:
        Able = False
        break
    if Tdic[alphabet.index(ti)] == 0:
        Tdic[alphabet.index(ti)] = si
    elif Tdic[alphabet.index(ti)] != si:
        Able = False
        break
        
print("Yes" if Able else "No")

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] suuji = new int[N];
		//初まりの数字もカウントに入れておく
		int count = 1;
		for(int i = 0; i < N ; i++) {
			suuji[i] = sc.nextInt();
		}
		int min = suuji[0];
		for(int i = 1; i<N; i++) {
			if(min > suuji[i]) {
				min = suuji[i];
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 82352
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<vector<int>> edges;
vector<int> shirube;

void bfs() {
    // {cur, prev}
    queue<int> q;
    q.push(0);

    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        for (auto &nv : edges[cur]) {
            if (shirube[nv] < 0) {
                shirube[nv] = cur;
                q.push(nv);
            }
        }
    }
}

int main(void) {
    int N, M;
    cin >> N >> M;

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

    shirube.resize(N, -1);
    shirube[0] = 0;

    bfs();

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << shirube[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 10260
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int zh=2,v1,a[N];
int add(int i,int j)
{
	zh++;
	printf("+ %d %d %d\n",i,j,zh);
	a[zh]=a[i]+a[j];
	//printf("%d\n",a[zh]);
	return zh;
}
int small(int i,int j)
{
	zh++;
	printf("< %d %d %d\n",i,j,zh);
	a[zh]=a[i]<a[j];
	//printf("%d\n",a[zh]);
	return zh;
}
int qp(int i,int x)
{
	while(x--)
		i=add(i,i);
	return i;
}
int neg(int i)
{
	return small(i,v1);
}
int sub(int i,int j)
{
	int dif=add(2,2);
	i=add(i,v1);
	for(int k=29;k>=0;k--)
	{
		int p=qp(v1,k);
		int fl=small(add(j,p),i);
		j=add(j,qp(fl,k));
		dif=add(dif,qp(fl,k));
	}
	return dif;
}
int ifel(int i,int j)
{
	return sub(j,qp(neg(i),30));
}
int mul(int i,int j)
{
	i=add(i,v1);
	int ans=add(2,2),x=add(2,2);
	for(int k=29;k>=0;k--)
	{
		int p=qp(v1,k);
		int fl=small(add(x,p),i);
		int fl2=ifel(fl,j);
		fl=qp(fl,k);
		x=add(x,fl);
		ans=add(ans,qp(fl2,k));
	}
	return ans;
}
int main()
{
	puts("45171");
	a[0]=2,a[1]=3;
	v1=small(2,add(0,1));
	int k=mul(0,1);
	printf("+ %d %d %d\n",k,2,2);
	return 0;
}

Measured memory_bytes: 3740
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};

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

  int64_t N, K;
  cin >> N >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<Pair> A(N);
  // vector<bool> okay(N + 1, false);
  for (int64_t i = 0; i < K; ++i) {
    cin >> A[i].first >> A[i].second;
    // for (int64_t j = A[i].first; j <= A[i].second; ++j) {
    //   okay[j] = true;
    // }
  }
  vector<Mint> dp(N + 1, 0);
  dp[0] = 1;
  for (int64_t i = 1; i <= N; ++i) {
    Mint temp = 0;
    for (int64_t j = 0; j < K; ++j) {
      const int64_t prev_min_m1 = i - A[j].second - 1;
      const int64_t prev_max = i - A[j].first;
      if (prev_max >= 0) {
        if (prev_min_m1 < 0) {
          temp += dp[prev_max];
          // cerr << i << ", " << j << ", a " << dp[prev_max].value << endl;
        } else {
          temp += dp[prev_max] - dp[prev_min_m1];
          // cerr << i << ", " << j << ", b "
          //      << (dp[prev_max] - dp[prev_min_m1]).value << endl;
        }
      }
    }
    dp[i] = dp[i - 1] + temp;
    // cerr << i << ", " << temp.value << endl;
  }
  // sort(A.begin(), A.end());
  cout << (dp[N - 1] - dp[N - 2]).value << endl;
  return 0;
}


Measured memory_bytes: 7944
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int h,w,hi;
    while(true)
    {
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(hi=1;hi<=h;hi++)
        {
            for(int i=1;i<=w;i++)
            {
                if(hi!=1&&hi!=h&&i!=1&&i!=w)
                {
                    cout<<".";
                }
                else
                {
                    cout<<"#";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind tree(N);

    vector<vector<int>> block_lists(N);
    vector<int> friend_sum(N);

    rep(i, M)
    {
        int A, B;
        cin >> A >> B;
        tree.unite(A - 1, B - 1);
        friend_sum[A - 1]++;
        friend_sum[B - 1]++;
    }
    rep(i, K)
    {
        int C, D;
        cin >> C >> D;
        block_lists[C - 1].push_back(D - 1);
        block_lists[D - 1].push_back(C - 1);
    }
    vector<int> tree_sum(N, 0);
    rep(i, N)
    {
        tree_sum[tree.root(i)]++;
    }

    rep(i, N)
    {
        vector<int> block_list = block_lists[i];
        int block_num = block_list.size();
        int eqaul_tree_sum = tree_sum[tree.root(i)];
        int equal_tree_block = 0;
        int equal_tree_friend = friend_sum[i];
        rep(j, block_num)
        {
            if (tree.same(i, block_list[j]))
                equal_tree_block++;
        }
        int ans = eqaul_tree_sum - equal_tree_block - equal_tree_friend;
        cout << ans - 1 << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dp[100010];
int main(){
    vector<int> v;
    v.push_back(1);
    for(int i=6;i<=100010;i*=6){
        v.push_back(i);
    }
    for(int i=9;i<=100010;i*=9){
        v.push_back(i);
    }
    sort(all(v),greater<int>());
    int n;cin>>n;
    fill(dp,dp+n+1,INF);
    dp[0]=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<v.size();j++){
            if(i+v[j]>n)continue;
            dp[i+v[j]]=min(dp[i+v[j]],dp[i]+1);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#include <iostream>

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='3'){
        cout << "bon" << endl;
    }else if(s[s.size()-1]=='0' || s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const double EPS=1e-3;
vector<double>calc(vector<double>x,vector<double>f)
{
	int N=x.size();
	vector<vector<double> >X(N,vector<double>(N)),E(N,vector<double>(N,0));
	for(int i=0;i<N;i++)
	{
		X[i][0]=1;
		for(int j=1;j<N;j++)
		{
			X[i][j]=X[i][j-1]*x[i];
		}
		E[i][i]=1;
	}
	for(int i=0;i<N;i++)
	{
		int id=i;
		while(abs(X[id][i])<EPS)id++;
		if(id!=i)
		{
			swap(X[i],X[id]);
			swap(E[i],E[id]);
		}
		double k=1/X[i][i];
		for(int j=0;j<N;j++)X[i][j]*=k,E[i][j]*=k;
		for(int j=0;j<N;j++)
		{
			if(j==i)continue;
			double l=X[j][i];
			for(int m=0;m<N;m++)
			{
				X[j][m]-=X[i][m]*l;
				E[j][m]-=E[i][m]*l;
			}
		}
	}
	vector<double>ret(N,0);
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			ret[i]+=E[i][j]*f[j];
		}
	}
	return ret;
}
main()
{
	int d;
	while(cin>>d,d)
	{
		vector<double>F(d+3);
		for(int i=0;i<d+3;i++)cin>>F[i];
		for(int i=0;i<d+3;i++)
		{
			vector<double>x(d+1),f(d+1);
			int sz=0;
			double nx,nf;
			for(int k=0;k<d+3;k++)
			{
				if(i==k)continue;
				if(sz==d+1)
				{
					nx=k,nf=F[k];
					break;
				}
				x[sz]=k;
				f[sz]=F[k];
				sz++;
			}
			vector<double>a=calc(x,f);
			double now=0,pp=1;
			for(double p:a)
			{
				now+=pp*p;
				pp*=nx;
			}
			if(abs(now-nf)<EPS)cout<<i<<endl;
		}
	}
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 998244353;
const int inf = mod*mod;
const int d5 = 200100;

template <int mod>
struct ModInt{
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p){
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while (e > 0){
            if (e % 2 == 0){
                p = (p * p) % mod;
                e /= 2;
            }
            else{
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p){
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a){
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;
modint f[d5];

void makef(){
    f[0] = 1;
    for (int i = 1; i < d5; i++)
        f[i] = f[i - 1] * i;
}

modint nCr(int n, int r){
    if (n < r || r < 0)
        return 0;
    return f[n] / (f[r] * f[n - r]);
}

int beki(int a, int b){
    a %= mod;
    if(b==0)return 1;
    int ans=beki(a,b/2);
    ans=ans*ans%mod;
    if(b%2==1)ans=ans*a%mod;
    return ans;
}

int combination(int a, int b){
    if((a==b)||(b==0)) return 1;
    if(a<b) return 0;
    int ret=1;
    for(int i=0;i<b;i++) {
        ret*=(a-i);
        ret%=mod;
        ret*=beki(i+1,mod-2);
        ret%=mod;
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    makef();
    modint res=0;
    for(int i=0;i<=k;i++){
        modint a=modint(m-1).pow(n-i-1);
        a*=nCr(n-1,i);
        a*=m;
        res+=a;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5220
from math import factorial
MOD = 10**9 + 7

def prime_factor(n):
    res = []
    d = 2
    while d * d <= n:
        if n % d == 0:
            cnt = 0
            while n % d == 0:
                cnt += 1
                n //= d
            res.append(cnt)
        d += 1
    if n > 1:
        res.append(1)
    return res

N, M = map(int, input().split())
ans = 1
for c in prime_factor(M):
    for i in range(c):
        ans *= N + i
    ans //= factorial(c)
    ans %= MOD
print(ans)

Measured memory_bytes: 3064
def resolve():

    n,t=map(int,input().split())
    T=list(map(int,input().split()))
    ans=t
    for i in range(1,n):
        if T[i]-T[i-1]>t:
            ans+=t
        else:
            ans+=T[i]-T[i-1]
    print(ans)




resolve()

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

int main() {
    
   vector<int> a(5);
    rep(i, 5) {
     cin >>a.at(i);
    }
    
    rep(i,5) {
      if(a.at(i) == 0){
      cout << i + 1;
      }
    }
    
}

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

int main () {
  string a ;
  cin >> a ;
  
  int pre = 10 ;
  bool x = false , b = false ;
  
  for(int i = 0 ; i < 5 ; i++ ){
    if(a[i] == 'A'){
      x = true ;
      pre = i ;
      break ;
    }
  }
  
  if(a[pre+1] == 'C') b = true ;
  
  if(x&&b) cout << "Yes" << endl ;
  else cout << "No" << endl ;
  
}


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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  
  vector<char> d(k);
  for(int i=0;i<k;i++)
    cin >> d.at(i);
  
  for(int ans=n;ans<n*10;ans++){
    string s=to_string(ans);
    bool jg=false;
    for(auto x:d){
      if(s.find(x)!=-1)
        break;
      if(x==d.at(d.size()-1)){
        jg=true;
        break;
      }
    }
    if(jg){
      cout << ans << endl;
      return 0;
    }
  }
}


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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

#define N 2005
ll g[N][N], h, w;
pll sq[N][N];
string s;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    cin >> h >> w;
    for (ll i=0; i<h; i++) {
        cin >> s;
        for (ll j=0; j<w; j++)
            if (s[j]=='#') g[i][j]=1;
            else g[i][j]=0;
    }

    // for (ll i=0; i<h; i++) {
    //     for (ll j=0; j<w; j++) cout << g[i][j] << ' ';
    //     cout << endl;
    // }

    for (ll i=0; i<h; i++) {
        ll p = 0;
        ll q = 0;
        while (q<w) {
            while (q<w && g[i][q]==1) q++;
            p = q;
            ll ct = 0;
            while (q<w && g[i][q]!=1) {
                ct++;
                q++;
            }
            for (ll j=p; j<q; j++) sq[i][j].X = ct;
            p = q;
        }
    }

    for (ll j=0; j<w; j++) {
        ll p = 0;
        ll q = 0;
        while (q<h) {
            while (q<h && g[q][j]==1) q++;
            p = q;
            ll ct = 0;
            while (q<h && g[q][j]!=1) {
                ct++;
                q++;
            }
            for (ll i=p; i<q; i++) sq[i][j].Y = ct;
            p = q;
        }
    }

    // for (ll i=0; i<h; i++) {
    //     for (ll j=0; j<w; j++) cout << sq[i][j].X << ',' << sq[i][j].Y << ' ';
    //     cout << endl;
    // }

    ll mx = 0;
    for (ll i=0; i<h; i++) {
        for (ll j=0; j<w; j++)
            if ((sq[i][j].X+sq[i][j].Y-1) > mx)
                mx = sq[i][j].X+sq[i][j].Y-1;
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 94464
#include<iostream>
using namespace std;
int main(){
  string c;
  cin>>c;
  string l;
  l="abcdefghijklmnopqrstuvwxyz";
  int a;
  a = l.find(c);
  if(a!=25){
    cout<<l[a+1]<<endl;
  }
  else{
    cout<<"a"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
// PCK2018 Yosen Q6 Bozo sort
// YAMADA Terushige 2018.9.30.

#include <iostream>

using namespace std;

int S;
void check(int *a,int *o,int x){
  if(a[x]<a[x-1]){
    if(o[x-1]==1){
      o[x-1]=0;
      S--;
    }
  }else if(o[x-1]==0){
    o[x-1]=1;
    S++;
  }
  
  if(a[x]>a[x+1]){
    if(o[x]==1){
      o[x]=0;
      S--;
    }
  }else if(o[x]==0){
    o[x]=1;
    S++;
  }
}

void pout(int *a,int *o,int N){
  for(int i=1;i<=N;i++){
    cout << a[i] << " ";
  }
  cout << endl;
  for(int i=1;i<=N;i++){
    cout << o[i] << " ";
  }
  cout << S << endl;
  cout << endl;
}

int main(){
  int N;
  cin >> N;
  int *a = new int[N+2];
  int *o = new int[N+2];
  a[0]=0;
  a[N+1]=1<<30;
  
  for(int i=1;i<=N;i++)
    cin >> a[i];

  S=0;
  o[0]=1;
  for(int i=1;i<=N;i++){
    if(a[i]>a[i+1]){
      o[i]=0;
    }else{
      o[i]=1;
      S++;
    }
  }
  //  pout(a,o,N);
  
  if(S==N) {
    cout << 0 << endl;
    return 0;
  }

  int Q;
  cin >> Q;

  for(int i=1;i<=Q;i++){
    int x,y;
    cin >> x >> y;
    swap(a[x],a[y]);
    check(a,o,x);
    check(a,o,y);
    //    pout(a,o,N);
    if(S==N){
      cout << i << endl;
      delete[] a;
      delete[] o;
      return 0;
    }
  }
  cout << -1 << endl;
  delete[] a;
  delete[] o;

  return 0;
}



Measured memory_bytes: 5232