akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<map>
#include<cstring>
#define N 500001
#define mod1 1000000007
#define mod2 998244353
using namespace std;
long long thn[N],ans,qz[N],a[N],target1[N],p1[N];
char st[N];
int where[N];
int n;
struct node
{
	long long x;long long y;
};
bool operator<(node x,node y)
{
	if (x.x<y.x) return true;
	if (x.x>y.x) return false;
	if (x.y<y.y) return true;
	return false;
}
map< node ,long long > maps;
long long ksmi(long long x,long long y,long long mod)
{
	long long total=1,ab=x,p=y;
	while (p)
	{
		if (p%2==1) total=total*ab%mod;
		ab=ab*ab%mod;
		p/=2;
	}
	return total;
}
long long abs(long long x)
{
	if (x<0) return -x;
	return x;
}
int main()
{
	scanf("%d\n",&n);
	thn[0]=1;
	for (int i=1;i<=2*n;i++) thn[i]=thn[i-1]*(2*n)%mod1;
	scanf("%s",st+1);
	int nowp=n;
	where[0]=n;
	qz[0]=0;
	for (int i=1;i<=2*n;i++)
		qz[0]=(qz[0]+thn[i-1]*n%mod1)%mod1;
	for (int i=1;i<=n;i++)
	{
		qz[i]=qz[i-1];
		if (st[i]=='+')
		{
			a[nowp]++;
			qz[i]=(qz[i]+thn[nowp-1])%mod1;
		}
		if (st[i]=='-')
		{
			a[nowp]--;
			qz[i]=(qz[i]-thn[nowp-1]+mod1)%mod1;
		}
		if (st[i]=='>') nowp++;
		if (st[i]=='<') nowp--;
		where[i]=nowp;
	}
	unsigned long long a_hash=0;
	for (int i=1;i<=n*2;i++) a_hash=(a_hash+(a[i]+n)*thn[i-1])%mod1;
	for (int i=n;i>=1;i--)
	{
		long long target=(a_hash-qz[0]+mod1)%mod1;
		if (where[i-1]<where[0])
			target=target*ksmi(thn[abs(where[i-1]-where[0])],mod1-2,mod1)%mod1;
		else	target=target*thn[abs(where[0]-where[i-1])]%mod1;
	//	maps[qz[i]]++;
		target+=qz[i-1];
		target%=mod1;
		target1[i]=target;
	}
	for (int i=1;i<=n;i++) p1[i]=qz[i];
	
	memset(qz,0,sizeof(qz));
	thn[0]=1;
	for (int i=1;i<=2*n;i++) thn[i]=thn[i-1]*(2*n)%mod2;
	nowp=n;
	where[0]=n;
	qz[0]=0;
	for (int i=1;i<=2*n;i++)
		qz[0]=(qz[0]+thn[i-1]*n%mod2)%mod2;
	memset(a,0,sizeof(a));
	for (int i=1;i<=n;i++)
	{
		qz[i]=qz[i-1];
		if (st[i]=='+')
		{
			a[nowp]++;
			qz[i]=(qz[i]+thn[nowp-1])%mod2;
		}
		if (st[i]=='-')
		{
			a[nowp]--;
			qz[i]=(qz[i]-thn[nowp-1]+mod2)%mod2;
		}
		if (st[i]=='>') nowp++;
		if (st[i]=='<') nowp--;
		where[i]=nowp;
	}
	a_hash=0;
	for (int i=1;i<=n*2;i++) a_hash=(a_hash+(a[i]+n)*thn[i-1])%mod2;
	for (int i=n;i>=1;i--)
	{
		if (i==1)
		{
			n++;n--;
		}
		long long target=(a_hash-qz[0]+mod2)%mod2;
		if (where[i-1]<where[0])
			target=target*ksmi(thn[abs(where[i-1]-where[0])],mod2-2,mod2)%mod2;
		else	target=target*thn[abs(where[0]-where[i-1])]%mod2;
		node s;
		s.x=p1[i];s.y=qz[i];
		maps[s]++;
		target+=qz[i-1];
		target%=mod2;
		s.x=target1[i];s.y=target;
		ans=(ans+maps[s]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 51364
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string s;
    ll cnt = 1;
    cin >> s;
    rep0(i, s.size() - 1){
        if (s[i] != s[i + 1]) {
            ++cnt;
        }
    }
    cout << cnt - 1 << endl;
    return 0;
}


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

int main() {
    ll h, w;
    scanf("%lld%lld", &h, &w);
    if (h == 1 || w == 1) {
        printf("1\n");
        return 0;
    }
    ll ans = h * w / 2ll;
    if (h % 2 == 1 && w % 2 == 1) ans = ans + 1ll;
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int arr[n];
	int dp[n];
	dp[n-1] = 0;
	for(int i=0; i<n; i++){
	    cin >> arr[i];
	}
	dp[n-2] = abs(arr[n-1]-arr[n-2]);
	for(int i=n-3; i>=0; i--){
	    dp[i] = min((abs(arr[i]-arr[i+1])+dp[i+1]),(abs(arr[i]-arr[i+2])+dp[i+2]));
	}
	cout << dp[0] << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAX_N 100002

typedef struct { char *p; int tm; } Q;
Q que[(MAX_N<<1)+2]; int top, end;
char name[MAX_N][20];

char buf[20], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int  n, q, tm, i;
	Q  t;

	fgets(p=buf, 20, stdin);
	n = in(), q = in();
	for (i = 0; i < n; i++) {
		fgets(p=name[i], 20, stdin);
		while (*p > ' ') p++; *p++ = 0;
		que[i].p = name[i], que[i].tm = in();
	}

	tm = 0, top = 0, end = n;
	while (top != end) {
		t = que[top]; if (++top == MAX_N) top = 0;
		if (t.tm <= q) {
			printf("%s %d\n", t.p, tm+t.tm);
			tm += t.tm;
		} else {
			t.tm -= q;
			que[end] = t; if (++end == MAX_N) end = 0;
			tm += q;
		}
	}
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 100000;
int A[MAX_N + 10];
ll B[MAX_N + 10];

int main2() {
  int N = nextInt();
  int K = nextInt();
  REP(i, N) {
    A[i] = nextInt();
    B[i] = nextInt();
  }
  ll ans = 0;
  {
    ll here = 0;
    REP(i, N) {
      if ((K | A[i]) == K) {
        here += B[i];
      }
    }
    chmax(ans, here);
  }
  for (int b = 30; b >= 0; b--) {
    if (K >> b & 1) {
      ll here = 0;
      int p = (K >> b) ^ 1;
      REP(i, N) {
        int q = A[i] >> b;
        if( (p | q) == p ) {
          here += B[i];
        }
      }
      chmax(ans, here);
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int AC = 0;
        int WA = 0;
        int TLE = 0;
        int RE = 0;

        for (int i = 0;i<n; i++){
            String a = sc.next();

            if (a.equals("AC"))
                AC++;
            if (a.equals("WA"))
                WA++;
            if (a.equals("TLE"))
                TLE++;
            if (a.equals("RE"))
                RE++;
        }
        System.out.println("AC x " + AC);
        System.out.println("WA x " + WA);
        System.out.println("TLE x " + TLE);
        System.out.println("RE x " + RE);
    }
}

Measured memory_bytes: 59336
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    ll Z = n*(n+1)/2LL;

    if(sum%Z != 0) {
        cout << "NO" << endl;
        return 0; 
    }

    ll k = sum/Z;

    vector<ll> d(n);
    rep(i, n-1) {
        d[i] = a[i+1] - a[i];
    }
    d[n-1] = a[0] - a[n-1];

    rep(i, n) {
        ll e = d[i] - k;
        if(e > 0 || e%n != 0) {
            cout << "NO" << endl;
            return 0; 
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1920
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 


		signed main()
		{
			int n;
			cin>>n;
			int cnt=0,ans=0;
			
			while(n%2==0)
			{
				cnt++;
				n/=2;
			}
			ans+=(-1+sqrt(1+4*2*cnt))/2;
			for(int i=3;i*i<=n;i+=2)
			{
				cnt=0;
				while(n%i==0)
				{
					cnt++;
					n/=i;
				}
				ans+=(-1+sqrt(1+4*2*cnt))/2;
			}
			if(n>2)
			{
				cnt=1;
				ans+=(-1+sqrt(1+4*2*cnt))/2;
			}
			cout<<ans;
		}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    while(a%2==0){
      cnt++;
      a/=2;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;
    if (a < b)
        printf("Bob\n");
    else if (a > b)
        printf("Alice\n");
    else
        printf("Draw\n");
    return 0;
}

Measured memory_bytes: 128
use proconio::input;
use std::cmp::*;
use std::collections::BinaryHeap;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
struct State {
    cost: i64,
    n: i64,
    min_div: i64,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.cost.cmp(&self.cost).then(other.n.cmp(&self.n)) // BinaryHeapはmax-heapなので、costは逆方向に比較する
    }
}
impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn f(n: i64, a: i64, b: i64, c: i64, d: i64) -> i64 {
    let mut q: BinaryHeap<State> = BinaryHeap::new();
    q.push(State {
        n: n,
        cost: 0,
        min_div: 2,
    });
    let mut min_cost = 1000000000i64 * 1000;
    let mut last_n = 0;
    let mut last_cost = 0;

    while let Some(State { n, cost, min_div }) = q.pop() {
        if n == 0 {
            min_cost = cost;
            break;
        }
        if n < 0 {
            continue;
        }
        if n == last_n && cost==last_cost {
            continue;
        }
        last_n = n;
        last_cost = cost;

        //println!("{} {} {}", n, cost, min_div);
        {
            let tmp = cost as i128 + n as i128 * d as i128;
            if tmp < min_cost as i128 {
                min_cost = tmp as i64;
                q.push(State {
                    n: 0,
                    cost: tmp as i64,
                    min_div: 6,
                });   
            }
        }

        let mut ff = |n, cost, div| {
            if n % div == 0 {
                q.push(State {
                    n: n / div,
                    cost: cost + if div==2 {a} else if div==3 {b} else {c},
                    min_div: div,
                })
            }
        };

        if min_div <= 2 {
            ff(n, cost, 2);
        }
        if min_div <= 3 {
            ff(n, cost, 3);
        }
        ff(n, cost, 5);

        ff(n + 1, cost + d, 2);
        ff(n - 1, cost + d, 2);
        ff(n + 1, cost + d, 3);
        ff(n - 1, cost + d, 3);
        ff(n + 1, cost + d, 5);
        ff(n - 1, cost + d, 5);

        ff(n + 2, cost + d * 2, 3);
        ff(n - 2, cost + d * 2, 3);
        ff(n + 2, cost + d * 2, 5);
        ff(n - 2, cost + d * 2, 5);

        ff(n + 3, cost + d * 3, 5);
        ff(n - 3, cost + d * 3, 5);
        
        ff(n + 4, cost + d * 4, 5);
        ff(n - 4, cost + d * 4, 5);
    }
    //while let Some(s) = q.pop() {
    //    println!("{:?}", s);
    //}
    return min_cost;
}

//#[proconio::fastout]
fn main() {
    input! {
        t:usize,
    }
    for _i in 0..t {
        input! {
            n:i64,
            a:i64,
            b:i64,
            c:i64,
            d:i64,
        }
        println!("{}", f(n, a, b, c, d));
    }
}


Measured memory_bytes: 4180
#include <stdio.h>

int main(){
  int i,j;
  int minj;
  int N;
  int a;
  int count=0;

  scanf("%d",&N);
  int A[N];

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

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj]){
	minj=j;
      }
    }
    a=A[i];
    A[i]=A[minj];
    A[minj]=a;
    if(i!=minj)count++;
  }

  for(i=0;i<N;i++){
    if(i==N-1){
      printf("%d\n",A[i]);
      printf("%d\n",count);
    }
    else printf("%d ",A[i]);
  }
    
  return 0;
}



Measured memory_bytes: 2140
#include<cstdio>
int main() {
	int k,x=0;
	scanf("%d",&k);
	for(register int i=1;i<=50000000;++i) {
		x=(x*10+7)%k;
		if(x==0) {printf("%d\n",i);return 0;}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
const int maxn=500020;
using namespace std;
int n,m,x,y,c,cnt;
map<int,int>g[100020];
int get(int x,int y){
	if(g[x].count(y)){
		return g[x][y];
	}
	return g[x][y]=++cnt;
}
struct edge{
	int to,w,next;
}e[maxn*20];
int sz=0,head[maxn*10],dis[maxn*10],vis[maxn*10];
void insert(int u,int v,int w){
	e[++sz].to=v;e[sz].w=w;e[sz].next=head[u];head[u]=sz;
	e[++sz].to=u;e[sz].w=w;e[sz].next=head[v];head[v]=sz;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		get(i,0);
	}
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&x,&y,&c);
		int x0=get(x,0),xc=get(x,c);
		int y0=get(y,0),yc=get(y,c);
		insert(xc,yc,0);
		insert(x0,xc,1);
		insert(y0,yc,1);
	}
	memset(dis,-1,sizeof(dis));
	typedef pair<int,int>pii;
	priority_queue<pii,vector<pii>,greater<pii> >q;
	dis[1]=0;
	q.push(make_pair(0,1));
	while(!q.empty()){
		int u=q.top().second;
		q.pop();
		if(vis[u]) continue;
		vis[u]=1;
		for(int i=head[u];i;i=e[i].next){
			int v=e[i].to;
			if(dis[u]+e[i].w<dis[v]||dis[v]==-1){
				dis[v]=dis[u]+e[i].w;
				q.push(make_pair(dis[v],v));
			}
		}
	}
	printf("%d\n",dis[n]>>1);
	return 0;
}

Measured memory_bytes: 74104
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = 10 ** 10


def main():
    S = input()
    for c in ascii_lowercase:
        if c not in S:
            print(c)
            return
    else:
        print("None")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,mod=1e9+7,inf=1e9+10;
vector<int>good;
bool mark[4*1000*1000+10];
int a[M];
main()
{
	int n;
	cin>>n;
	int ans=inf,sum=0;
	for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
	if(sum%2==1)sum++;
	sum/=2;
	good.pb(0);
	mark[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=(int)good.size()-1;j>=0;j--)
		{
			if(!mark[good[j]+a[i]])good.pb(good[j]+a[i]),mark[good[j]+a[i]]=1;
		}
	}
	for(int i=0;i<good.size();i++)
	{
		if(good[i]>=sum)ans=min(ans,good[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 21864
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    long h = sc.nextLong();
    long w = sc.nextLong();
    long ans = 1;

    if(w == 1 || h == 1){
      ans = 1;
    } else if(w % 2 == 0){
      ans = (h * w) / 2;
    } else if(h % 2 == 0){
      ans = h * (w / 2) + (h / 2);
    } else {
      ans = h * (w / 2) + ((h / 2) + 1) ;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

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

    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    sort(x.begin(), x.end());

    int ans = INF;
    for(int p = x[0]; p <= x[n-1]; ++p){
        int tmp = 0;
        for(int i = 0; i < n; ++i){
            tmp += (x[i]-p)*(x[i]-p);
        }
        ans = min(ans, tmp);

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

    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  combination c(2 * n + 1);
  mint ans = 1;
  rep2(i, 1, min(n, k + 1)) ans += c(n, i) * c(n - 1, n - i - 1);
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(){

  long A, B, K;
  
  cin>>A>>B>>K;
  
  if(K>(A+B))cout<<0<<" "<<0;
  
  else if(K<A || K==A){
	cout<<A-K<<" "<<B;
  }

  else cout<<0<<" "<<B-K+A;
}

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

int main() {
  uint64_t t[1000];
  t[0] = 1;
  for (int i = 1; i < 1000; i++) {
    t[i] = t[i - 1] + (i + 1);
  }
  int a, b;
  std::cin >> a >> b;

  std::cout << t[b - a - 1] - b << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

signed main() {
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];
  vector<vector<ll>> cumx = vector<vector<ll>>(h, vector<ll>(w, 0));
  vector<vector<ll>> cumy = vector<vector<ll>>(h, vector<ll>(w, 0));
  REP(y, h) {
    int left = 0;
    REP(x, w) {
      if(s[y][x] == '#') {
        REP_FROM(i, left, x) {
          cumx[y][i] = x - left;
        }
        left = x+1;
      }
    }
    if(s[y][w-1] == '.') {
      REP_FROM(i, left, w) {
        cumx[y][i] = w - left;
      }
    }
  }
  REP(x, w) {
    int left = 0;
    REP(y, h) {
      if(s[y][x] == '#') {
        REP_FROM(i, left, y) {
          cumy[i][x] = y - left;
        }
        left = y+1;
      }
    }
    if(s[h-1][x] == '.') {
      REP_FROM(i, left, h) {
        cumy[i][x] = h - left;
      }
    }
  }
  ll ans = 0;
  REP(i, h) {
    REP(j, w) {
      ans = max(ans, cumx[i][j] + cumy[i][j] - 1);
    }
  }
  // REP(y, h) {
  //   REP(x, w) {
  //     cout << cumx[y][x] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // REP(y, h) {
  //   REP(x, w) {
  //     cout << cumy[y][x] << " ";
  //   }
  //   cout << endl;
  // }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67200
import math
n = int(input())
l = list(map(int, input().split()))

av = sum(l)/n
af = math.floor(av)
ac = math.ceil(av)

sf = 0
sc = 0

for i in l:
    sf += (abs(i-af))**2
    sc += (abs(i-ac))**2

print(min(sf,sc))


Measured memory_bytes: 62184
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<int,int> P;

vector<int> g[100];
int ans[100][2]; //[i][0] 到着　　[i][1] 終了
bool used[100];

int dfs(int v,int t){
	used[v] = true;
	ans[v][0] = t++;
	for(int i=0;i<g[v].size();i++){
		if(!used[g[v][i]]) t = dfs(g[v][i],t);
	}
	ans[v][1] = t;
	return t + 1;
}

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

	int n;
	cin >> n;
	
	for(int i=0;i<n;i++){
		int u, nume;
		cin >> u >> nume;

		int v;
		for(int j=0;j<nume;j++){ //jは回数数えるだけ
			cin >> v;
			g[u-1].push_back(v-1);
		}
	}

	int t=1;
	for(int i=0;i<n;i++){
		if(!used[i]){
			t = dfs(i,t);
		}
	}

	for(int i=0;i<n;i++){
		cout << i+1 << " " << ans[i][0] << " " << ans[i][1] << "\n";
	}

	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>

using namespace std;

int ctoi(char c) {
    if (c >= '0' && c <= '9') return c - '0';
    return 0;
}

int main() {
    string x;
    while(true) {
        cin >> x;
        if(x == "0") return 0;
 
        long sum = 0;
        int p = 0;
        if(x[0] == '-') p = 1;
        for(int i=p; i < x.size(); i++) {
            int x_int = ctoi(x[i]);
            //cout << "x_int: " << x_int << endl;
            sum += x_int;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String n = sc.next();
		int ans = 0;

		for (int i = 0; i < 4; i++) {
		if (n.substring(i, i + 1).equals("+")) {
			ans++;
		} else { 
			ans--;
		}
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21332
A = int(input())
B = int(input())
C = int(input())
X = int(input())

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

print(ans)





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

int main() {
    int a, b;
    int aa, bb, ab;
    cin >> a;
    cin >> b;
    aa = a + a - 1;
    bb = b + b - 1;
    ab = a + b;
    cout << max(aa, max(ab, bb));
    return 0;
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    ans = float('inf')
    for h in range(1, H):
        S1 = h*W
        S2 = ((H-h)//2) * W
        S3 = ((H-h+1)//2) * W
        dif = max(S1, S2, S3) - min(S1, S2, S3)
        ans = min(ans, dif)
        S2 = (H-h) * (W//2)
        S3 = (H-h) * ((W+1)//2)
        dif = max(S1, S2, S3) - min(S1, S2, S3)
        ans = min(ans, dif)
    tmp = H
    H = W
    W = tmp
    for h in range(1, H):
        S1 = h*W
        S2 = ((H-h)//2) * W
        S3 = ((H-h+1)//2) * W
        dif = max(S1, S2, S3) - min(S1, S2, S3)
        ans = min(ans, dif)
        S2 = (H-h) * (W//2)
        S3 = (H-h) * ((W+1)//2)
        dif = max(S1, S2, S3) - min(S1, S2, S3)
        ans = min(ans, dif)
    print(ans)


if __name__ == "__main__":
    main()


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

int main(void) {
    int A,B,X;
    cin >> A >> B >> X;
    if((A <= X) && ((A+B) >= X)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
mod = 10**9+7
li = [int(i) for i in range(N+1)]
suma = [0]*(N+1)
for i in range(1,N+1):
    suma[i] = suma[i-1]+li[i]
ans = 0
for i in range(K,N+1):
    m = suma[i-1]
    M = suma[-1] - suma[-(i+1)]
    ans += M-m+1
    ans %= mod
ans +=1
ans %= mod
print(ans)

Measured memory_bytes: 27256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.Nf\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 8;

int h, w, k;
ll m[N][N], e[N][N], tmp[N][N], fib[N] = {1,1,2,3,5,8,13,21};
void merge(ll a[N][N], ll b[N][N], ll c[N][N]){
  FOR(i, 0, w)FOR(j, 0, w){
    ll g = 0;
    FOR(k, 0, w) g = (g + a[i][k] * b[k][j]) % mod;
    tmp[i][j] = g;
  }
  FOR(i, 0, w)FOR(j, 0, w) c[i][j] = tmp[i][j];
}
ll n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w >> k;
  FOR(i, 0, w)FOR(j, -1, 2){
    if(i+j < 0 || i+j >= w) continue;
    m[i][i+j] = fib[min(i, i+j)] * fib[w-max(i, i+j)-1];
  }
  FOR(i, 0, w) e[i][i] = 1;
  while(h > 0){
    if(h%2)merge(e, m, e);
    merge(m, m, m);
    h >>= 1;
  }
  cout << e[0][k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

    // AtCoder Beginner Contest 162
    // B - FizzBuzz Sum

    $n = in_int();

    $sum = 0;
    for ($i = 1; $i <= $n; $i++) {
        if ($i % 3 != 0 && $i % 5 != 0) {
            $sum += $i;
        }
    }

    out($sum);


    // -----------------------------------------------------
    function in() { return trim(fgets(STDIN)); }
    function in_int() { return (int)in(); }
    function in_vals() { return explode(' ', in()); }
    function in_ints() { return array_map('intval', in_vals()); }
    function out($s) { echo $s . PHP_EOL; }
    function yes() { out('Yes'); }
    function no() { out('No'); }


Measured memory_bytes: 16256
#include <iostream>

using namespace std;

int main()
{
    long long int n,a,b;
    cin >> n >> a >> b;
    if(a == 0)
        cout << "0" << endl;
    else if(a > 0)
    {
        long long int sum = a+b;
        long long int k = n/sum;
        long long int ans = k*a;
        ans += min(n%sum,a);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	char a[50];
	cin>>a;
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]==',') cout<<' ';
		else cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){//
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0){
        cout << "1" << endl;
        return 0;
    }
    if(x2 == 0){
        cout << "2" << endl;
        return 0;
    }
    if(x3 == 0){
        cout << "3" << endl;
        return 0;
    }
    if(x4 == 0){
        cout << "4" << endl;
        return 0;
    }
    if(x5 == 0){
        cout << "5" << endl;
        return 0;
    }

    
}

Measured memory_bytes: 3548
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	map<Int, Int> cnt;
	Int a;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		cnt[a]++;
	}

	bool flag = false;

	if (1==cnt.size()) {
		if (N==cnt[0]) {//全部0の時
			flag = true;
		}
	}
	else if (0==N%3) {
		if (2==cnt.size()) {//N/3個0の時
			if (cnt[0]==N/3) {
				flag = true;
			}
		}
		else if (3==cnt.size()) {//3種類の時
			Int temp = 0;
			Int num = 0;
			for (const auto& e : cnt) {
				temp ^= e.first;
				num += abs(N / 3 - e.second);
			}
			if (temp==0&&num==0) {
				flag = true;
			}
		}
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 5120
N = gets.to_i
An = gets.split.map(&:to_i).first(N)
count = 0

while !An.size.zero? do
  prev, current = An.shift(2)

  while prev == current do
    prev = current
    current = An.shift
  end

  break count += 1 unless current

  updown = prev > current ? '>=' : '<='

  loop do
    _next = An.first
    break count += 1 unless _next
    break count += 1 unless current.send(updown, _next)
    current = An.shift
  end
end

puts count


Measured memory_bytes: 11020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)==4)
    {
        int flag=0;
        if(fabs(a-b)>d)
        {
            if(fabs(a-c)>d)
                flag=0;
            else
                flag=1;
        }
        else
        {
            if(fabs(b-c)>d)
            {
                if(fabs(a-c)>d)
                    flag=0;
                else
                    flag=1;
            }
            else
                flag=1;
        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int main(){
    int n, data[1000];

    while(1){
        cin >> n;
        if (n == 0) break;
        
        for (int i = 0; i < n; i++) cin >> data[i];

        int sum = 0;

        for (int i = 0; i < n; i++) sum += data[i];

        double av = 1.0 * sum / n ;

        double dist = 0.0;

        for (int i = 0; i < n; i++) {
            dist += (av-data[i])*(av-data[i]);
        }

        printf("%lf\n", sqrt(dist/n));

        
    }

    
}



Measured memory_bytes: 3160
n=int(input())
for i in range(max(1,n//4),3501):
  for j in range(max(1,n//4+1),3501):
    if 4*i*j-i*n-j*n!=0:
      num1=i*j*n/(4*i*j-i*n-j*n)
      num2=i*j*n//(4*i*j-i*n-j*n)
      if num1==num2 and num1>0:
        print(i,j,num2)
        exit()  

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long dp[3][2][32000] = {};
int main() {
	string s;
	cin >> s;
	long long x, y;
	cin >> x >> y;
	vector<long long> xe,ye;
	long long now = 0;
	long long pe = 0;
	for (int i = 0;i < s.length();++i) {
		if (s[i] == 'T') {
			if (pe == 0) {
				xe.push_back(now);
				pe = 1;
			}
			else {
				ye.push_back(now);
				pe = 0;
			}
			now = 0;
		}
		else now++;
	}
	if (pe == 0) {
		xe.push_back(now);
		pe = 1;
	}
	else {
		ye.push_back(now);
		pe = 0;
	}
	if (xe.size() != 0) {
		dp[0][1][16000 + xe[0]] = 1;
		for (int i = 1;i < xe.size();++i) {
			for (int q = 8000;q <= 24000;++q) {
				if (dp[0][i % 2][q] == 1) {
					dp[0][(i + 1) % 2][q - xe[i]] = 1;
					dp[0][(i + 1) % 2][q + xe[i]] = 1;
					dp[0][i % 2][q] = 0;
				}
			}
		}
		if (dp[0][xe.size() % 2][16000 + x] == 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		if (x != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (ye.size() != 0) {
		dp[1][0][16000] = 1;
		for (int i = 0;i < ye.size();++i) {
			for (int q = 8000;q <= 24000;++q) {
				if (dp[1][i % 2][q] == 1) {
					dp[1][(i + 1) % 2][q - ye[i]] = 1;
					dp[1][(i + 1) % 2][q + ye[i]] = 1;
					dp[1][i % 2][q] = 0;
				}
			}
		}
		if (dp[1][ye.size() % 2][16000 + y] == 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		if (y != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define Yes_Or_No(flag) if (flag) \
  { cout << "Yes" << endl; } \
  else \
  { cout << "No" << endl; }

int main() {
  int N;
  cin >> N;
  
  bool flag = false;
  
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if ((i * j) == N) {
        flag = true;
      }
    }
  }

  Yes_Or_No(flag);
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll N,M;
    cin >> N >> M;
    ll fib[100011];
    fib[0] = 1;
    fib[1] = 1;
    for2(i,2,100010) {
        fib[i] = (fib[i-1] + fib[i-2]) % 1000000007;
    }
    ll ans = 1;
    ll pre = -1;
    ll a;
    for1(i,M) {
        cin >> a;
        if (pre == a) continue;
        if (pre + 1 == a) {
            cout << 0 << endl;
            return;
        }
        ll b = fib[(a-1) - (pre+1)];
        //cout << b << endl;
        ans *= (b % 1000000007);
        ans %= 1000000007; 
        pre = a;
    }
    a = N+1;
    if (pre + 1 == a) {
        cout << 0 << endl;
        return;
    }
    ll b = fib[(a-1) - (pre+1)];
    //cout << b << endl;
    ans *= (b % 1000000007);
    ans %= 1000000007; 

    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

void solve(){
   string s; cin >> s;
   bool ans = false;
   if(s[0]=='7'||s[1]=='7'||s[2]=='7') ans = true;
   cout << (ans?"Yes":"No");
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;

    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        cnt += 1ll * i * (n - i + 1);
    }

    for (int i = 1; i < n; ++i) {
        int u, v; cin >> u >> v;

        if (u > v) {
            swap(u, v);
        }

        cnt -= 1ll * u * (n - v + 1);
    }
    cout << cnt << endl;
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll n,cnt = 0;
	cin >> n;
	string s;
	cin >> s;
	
	rep(i,0,n-2){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
	}
	
	cout << cnt << endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> dp(N+1);
  for(int i=0; i<M; i++){
    int a;
    cin >> a;
    dp.at(a)=-1;
  }
  dp.at(0)=1;
  if(dp.at(1)!=-1) dp.at(1)=1;
  for(int i=2; i<N+1; i++){
    if(dp.at(i)==-1) continue;
    if(dp.at(i-2)==-1 && dp.at(i-1)==-1) break;
    else if(dp.at(i-2)==-1) dp.at(i)=dp.at(i-1)%1000000007;
    else if(dp.at(i-1)==-1) dp.at(i)=dp.at(i-2)%1000000007;
    else dp.at(i)=(dp.at(i-1)+dp.at(i-2))%1000000007;
  }
  cout << dp.at(N) << endl;
}

Measured memory_bytes: 640
//  Copyright 2019 Nikita Golikov

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  std::vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  int64_t ans = 0;
  for (int left = 0; left <= std::min(n, k); left++) {
    for (int right = 0; left + right <= std::min(n, k); right++) {
      for (int drop_left = 0; drop_left <= left && left + right + drop_left
      <= k; drop_left++) {
        int max_drop_right = std::min(right, k - left - right - drop_left);
        std::vector<int> b = a;
        std::nth_element(b.begin(), b.begin() + drop_left, b.begin() + left);
        int64_t res = 0;
        for (int i = drop_left; i < left; i++) {
          res += b[i];
        }
        int right_from = n - right;
        std::nth_element(b.begin() + right_from, b.begin() + right_from + max_drop_right, b
        .end());
        for (int i = right_from + max_drop_right; i < n; i++) {
          res += b[i];
        }
        for (int i = right_from; i < right_from + max_drop_right; i++) {
          if (b[i] > 0) {
            res += b[i];
          }
        }
        ans = std::max(ans, res);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


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

typedef long long ll;

const ll mod = 1'000'000'007;

ll powmod(ll x, ll n){
    x %= mod;
    ll res = 1;
    while (n){
        if (n & 1) res = (res * x) % mod;
        n >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

inline ll submod(ll x, ll y){
    x %= mod; y %= mod;
    return (x + mod - y) % mod;
}

inline ll addmod(ll x, ll y){
    x %= mod; y %= mod;
    return (x + y) % mod;
}

inline ll mulmod(ll x, ll y){
    x %= mod; y %= mod;
    return (x * y) % mod;
}

ll K, N;
string S;
ll fac[2000006], ifac[2000006];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> K;
    cin >> S; N = S.length() + K;
    ll ans = powmod(26, N);
    fac[0] = 1;
    for (ll i=1; i<=2000000; i++) fac[i] = mulmod(fac[i-1], i);
    ifac[2000000] = powmod(fac[2000000], mod-2);
    for (ll i=2000000; i; i--) ifac[i-1] = mulmod(ifac[i], i);
    for (ll i=0; i<S.length(); i++){
        ll cur = powmod(25, N-i);
        ll binom = mulmod(mulmod(fac[N], ifac[i]), ifac[N-i]);
        cur = mulmod(binom, cur);
        ans = submod(ans, cur);
    }
    cout << ans << endl;
}

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

int main() {
    int D, T, S; cin >> D >> T >> S;
    if (S * T >= D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ca, cb = 0, 0
for a, b in zip(A, B):
    if a > b:
        ca += a - b
    if a < b:
        cb += (b - a) // 2

if cb >= ca:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

vector<long> makePrimes(const long upper=1000000){
    vector<long> primes;
    long p[upper+1];
    for(long i=0;i<upper;i+=2){
        p[i] = 0;
        p[i+1] = i+1;
    }
    p[1] = 0;
    p[2] = 2;
    primes.push_back(2);
    for(long i=3;i<upper;i+=2){
        if(p[i]==0){
            continue;
        }
        primes.push_back(i);
        for(long j=i*i;j < upper;j+=(2*i)){
            p[j] = 0;
        }
    }
    return primes;
}

vector<long>primes = makePrimes();

unordered_map<long,int> factorize(long n){
    unordered_map<long,int> factors;

    for(auto p:primes){
        if(n == 1){
            return factors;
        }else if(n % p == 0){
            int e=1;
            for(;n % p==0;e++,n /= p);
            factors[p] = e;
        }
    }
    factors[n] = 1; // n is a prime number!!
    return factors;
}

vector<long> getDivisors(long n){
    unordered_map<long,int> factors = factorize(n);
    vector<long> d1={1};
    vector<long> d2;
    for(auto it=factors.cbegin();it != factors.cend();++it){
        d2.clear();
        long p = 1;
        for(int e=0;e < it->second;++e){
            for(auto d : d1){
                d2.push_back(p*d);
            }
            p *= it->first;
        }
        d1.swap(d2);
        d2.clear();
    }
    sort(d1.begin(),d1.end());
    return d1;
}

int main(){
    long n;
    cin >> n;
    vector<long> ds = getDivisors(n);
    long ans = n;
    for(auto d1:ds){
        if(d1*d1 > n){
            break;
        }
        auto d2 = n / d1;
        if(d1+d2-2 < ans){
            ans = d1+d2-2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

vector<int> eds[120000];
int was[120000];
int n;

int dfs1(int v) {
    was[v] = 1;
    int ans = 0;
    for (int u: eds[v]) {
        if (!was[u]) {
            int x = dfs1(u);
            x += 1;
            ans ^= x;
        }
    }
    return ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        eds[a].push_back(b);
        eds[b].push_back(a);
    }
    int x = dfs1(0);
    if (x)
        cout << "Alice\n";
    else
        cout << "Bob\n";
    return 0;
}




Measured memory_bytes: 9728