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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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; }

VVI attack(int r, int c, VVI av) {
    REP(i, 8) {
        av[i][c] ^= 1;
        av[r][i] ^= 1;
    }
    FOR(i, -8, 8) {
        if (0 <= r + i  && r + i <= 7 && 0 <= c + i && c + i <= 7) {
            av[r+i][c+i] ^= 1;
        }
        if (0 <= r - i  && r - i <= 7 && 0 <= c + i && c + i <= 7) {
            av[r-i][c+i] ^= 1;
        }
    }
    return av;
}
void Main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans = max({a*c, a*d, b*c, b*d});
    cout << ans << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
int h, w;
int i, j;
while(1){
scanf("%d %d", &h, &w);
if (h == 0 && w == 0)break;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}


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

using namespace std;

int main()
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r ;
	if(0<=(x-r) && (x+r)<=W && 0<=(y-r) && (y+r)<=H) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int ipow(int a, int b) {
    int temp = 1;

    for (int i = 0; i < b; i++) {
        temp *= a;
    }
    return temp;
}

int main() {
    int c[6][6];
    int h, w, k;
    int all = 0;
    cin >> h >> w >> k;

    char temp;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> temp;
            if (temp == '.') {
                c[i][j] = 0;
            } else {
                c[i][j] = 1;
                all++;
            }
        }
    }

    int ans = 0;

    vector<int> tate;
    vector<int> yoko;
    int a,aa;
    int b,bb;
    int cou,coud;

    for (int i = 0; i < ipow(2, h); i++) {
        a = 0;
        b = i;
        tate.clear();
        while (true)
        {
            if (b % 2 == 1) {
                tate.push_back(a);
            }
            a++;
            if (b < 2)break;
            b /= 2;
        }
        for (int j = 0; j < ipow(2, w); j++) {
            aa = 0;
            bb = j;
            yoko.clear();
            while (true)
            {
                if (bb % 2 == 1) {
                    yoko.push_back(aa);
                }
                aa++;
                if (bb < 2)break;
                bb /= 2;
            }
            cou = 0;
            coud = 0;
            for (int k = 0; k < tate.size(); k++) {
                for (int l = 0; l < yoko.size(); l++) {
                    if (c[tate[k]][yoko[l]] == 1) {
                        coud++;
                    }
                }
            }
            for (int k = 0; k < tate.size(); k++) {
                for (int l = 0; l < w; l++) {
                    if (c[tate[k]][l] == 1)cou++;
                }
            }
            for (int k = 0; k < yoko.size(); k++) {
                for (int l = 0; l < h; l++) {
                    if (c[l][yoko[k]] == 1)cou++;
                }
            }
            if (k == all -(cou - coud))ans++;
        }
    }

    cout << ans;



    return 0;
}

Measured memory_bytes: 3624
// in the name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 3011 ;
const ll INF = 1e18 ;

#define f first
#define s second

ll n , mod = 1e9 + 7 , dp[maxn][maxn] , per[maxn][maxn] ;
string s1 ;
char a[maxn][maxn] ;

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

 cin >> n >> s1 ;
 for(int i = 0 ; i < n-1 ; i ++)a[i+1][i+2] = s1[i] ;

 dp[1][1] = 1 ;
 per[1][1] = dp[1][1] ;

 for(int i = 2 ; i <= n ; i ++){
    for(int j = 1 ; j <= i ; j ++){
        if(a[i-1][i] == '>'){
           dp[i][j] = per[i-1][j-1]%mod ;
           //for(int k = j-1 ; k > 0 ; k --)dp[i][j] = (dp[i][j] + (dp[i-1][k]%mod))%mod ;
        }
        else{
           dp[i][j] = (per[i-1][i-1] - per[i-1][j-1] + mod)%mod ;
           //for(int k = j+1 ; k <= i ; k ++)dp[i][j] = (dp[i][j] + (dp[i-1][k-1]%mod))%mod ;
        }
        per[i][j] = (per[i][j-1] + dp[i][j])%mod ;
    }
 }

 ll ans = 0 ;
 for(int i = 1 ; i <= n ; i ++)ans = (ans + (dp[n][i]%mod))%mod ;
 cout << ans%mod ;


    return 0;
}


Measured memory_bytes: 150528
#! /usr/bin/python

num_inputs = int(raw_input())

limit = 100000000000000000000000000000000000000000000000000000000000000000000000000000000

count = 0
while count < num_inputs:
	num1 = int(raw_input())
	num2 = int(raw_input())

	if num1 >= limit or num2 >= limit:
		print('overflow')
	else:
		num = num1 + num2
		if num >= limit:
			print('overflow')
		else:
			print(num)

	count += 1

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int mx = 0, cur = 0;
    for (int i = 1; i < n; i++) {
        if (v[i] <= v[i - 1])cur++;
        else mx = max(mx, cur), cur = 0;
    }
    mx = max(mx, cur), cur = 0;
    cout << mx << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int n, m;
int main() {
    scanf("%d %d", &n, &m);
    if( m > n )
        for (int i = 1; i <= m; ++i)
            printf("%d", n);
    else
        for (int i = 1; i <= n; ++i)
            printf("%d", m);
    return 0;
}

Measured memory_bytes: 128
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int v[500*500+500]={};
int v2[500*500+500]={};
int a[505][505];
int b[505][505];
bool used[505][505]={};
int main()
{
	while(1)
	{
		int r;
		int w1,h1,x1,y1;
		scanf("%d",&r);if(!r) return 0;
		scanf("%d %d %d %d",&w1,&h1,&x1,&y1);
		for(int i=1;i<=h1;i++)
		{
			for(int j=1;j<=w1;j++)
			{
				scanf("%d",&a[j][i]);
			}
		}
		int w2,h2,x2,y2;
		scanf("%d %d %d %d",&w2,&h2,&x2,&y2);
		for(int i=1;i<=h2;i++)
		{
			for(int j=1;j<=w2;j++)
			{
				scanf("%d",&b[j][i]);
			}
		}
		memset(used,0,sizeof(used));
		priority_queue<P1,vector<P1>,greater<P1> >que;
		que.push(mp(1,mp(x1,y1)));
		int cur=0;
		int now=0;
		while(!que.empty())
		{
			P1 p=que.top(); que.pop();
			int x=p.second.first;
			int y=p.second.second;
			if(used[x][y]) continue;
			used[x][y]=true;
			now=max(now,p.first);
			v[++cur]=now;
			int dx[4]={0,1,0,-1};
			int dy[4]={1,0,-1,0};
			for(int i=0;i<4;i++)
			{
				int nx=x+dx[i];
				int ny=y+dy[i];
				if(!(1<=nx && nx<=w1)) continue;
				if(!(1<=ny && ny<=h1)) continue;
				if(used[nx][ny]) continue;
				que.push(mp(a[nx][ny],mp(nx,ny)));
			}
		}
		memset(used,0,sizeof(used));
		que.push(mp(1,mp(x2,y2)));
		cur=now=0;
		while(!que.empty())
		{
			P1 p=que.top(); que.pop();
			int x=p.second.first;
			int y=p.second.second;
			if(used[x][y]) continue;
			used[x][y]=true;
			now=max(now,p.first);
			v2[++cur]=now;
			int dx[4]={0,1,0,-1};
			int dy[4]={1,0,-1,0};
			for(int i=0;i<4;i++)
			{
				int nx=x+dx[i];
				int ny=y+dy[i];
				if(!(1<=nx && nx<=w2)) continue;
				if(!(1<=ny && ny<=h2)) continue;
				if(used[nx][ny]) continue;
				que.push(mp(b[nx][ny],mp(nx,ny)));
			}
		}
//for(int i=0;i<=w1*h1;i++) printf("%ds ",v[i]);
 
//for(int i=0;i<=w2*h2;i++) printf("%ds ",v2[i]); 
		int ret=INF;
		for(int i=max(0,r-w2*h2);i<=min(r,w1*h1);i++)
		{
			ret=min(ret,v[i]+v2[r-i]);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 6104
d = {}
d[1] = 1
d[2] = 3
d[3] = 1
d[4] = 2
d[5] = 1
d[6] = 2
d[7] = 1
d[8] = 1
d[9] = 2
d[10] = 1
d[11] = 2
d[12] = 1
x,y = map(int,input().split())
ans = 'No'
if d[x] == d[y]:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
-- Branch on Condition - Circle in a Rectangle

import Control.Applicative

main :: IO ()
main = do
  xs <- map read . words <$> getLine
  putStrLn $ if (check xs) then "Yes" else "No"

check :: [Int] -> Bool
check [w, h, x, y, r] = check' [x, r, w] && check' [y, r, h]
  where check' [a, b, c] = (0 <= a - b) && (a + b <= c)



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll ans[100000+1],val[100000+1];
vector<ll>v[100000+1];
void find(ll i){
    ll temp=0;
    fo(j,v[i].size()){
        if(ans[v[i][j]]==-1){
            find(v[i][j]);
        }
        temp=max(temp,ans[v[i][j]]);
    }
    ans[i]=temp+1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   
    //cin>>t;
    t=1;
    while(t--){
        cin>>n>>m;
        
        fo(i,n+1)ans[i]=-1,val[i]=0;
        fo(i,m){
            ll a,b;
            cin>>a>>b;
            v[a].pb(b);
            val[b]++;
        }
        fo1(i,n){
            if(ans[i]==-1)find(i);
        }
        ll maxi=0;
        fo1(i,n)maxi=max(maxi,ans[i]);
        cout<<maxi-1;

        

        
    }

    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;

  cout << (a + b) % 24 << endl;
}

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

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

    vector<vector<char> > a(n,vector<char>(m));

    vector<vector<char> > b(n,vector<char>(m));

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>b[i][j];
        }
    }

    int count=0;

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(a[i][j] != b[i][j]) count++;
        }
    }

    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 10804
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<u32>();
    let notices = read_vec2::<i32>(n);
    let mut bs = Vec::new();
    for _ in 0..4 {
        bs.push(vec![0i32; 10 * 3]);
    }

    for nt in notices {
        let b = nt[0] as usize;
        let f = nt[1] as usize;
        let r = nt[2] as usize;
        let v = nt[3];

        bs[b - 1][10 * (f - 1) + (r - 1)] += v;
    }

    let mut first = true;
    for b in bs {
        if first {
            first = false;
        } else {
            println!("{}", (0..20).map(|_| '#').collect::<String>());
        }
        for i in 0..3 {
            for j in 0..10 {
                print!(" {}", b[i * 10 + j]);
            }
            println!("");
        }
    }
}



Measured memory_bytes: 5044
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

sys.setrecursionlimit(10**7)

k = int(input())
data = [1,2,3,4,5,6,7,8,9]
def dfs(prenum,numberstr):
  if int(numberstr) > 3234566667:return
  if prenum - 1 >= 0:
    data.append(int(numberstr+str(prenum-1)))
    dfs(prenum-1,numberstr+str(prenum-1))
  data.append(int(numberstr+str(prenum)))
  dfs(prenum,numberstr+str(prenum))
  if prenum +1 <= 9:
    data.append(int(numberstr+str(prenum+1)))
    dfs(prenum+1,numberstr+str(prenum+1))
for i in range(1,10):
  dfs(i,str(i))
data.sort()
print(data[k-1])
# print(data[:20])
# print(len(data))

Measured memory_bytes: 68572
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
// #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
bool desc_sort(const int & lhs,const int & rhs)
{
    return lhs>rhs;
}
bool desc_pii_sort(const pii & lhs , const pii & rhs)
{
    return lhs>rhs;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.F = lhs.S;
    a.S = lhs.F;
    b.F = rhs.S;
    b.S = rhs.F;
    return a<b;
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif


// #define int long long
#define modd 1e0



inline ll fast_expo(ll base,ll power,ll modulo=modd){
    base%=modulo;
    if (base<0LL) base+=modulo;
    ll x=base,cnt=power,ans=1LL;
    while(cnt){
        if (cnt&1LL) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1LL;
    }
    // int tmp=ans;
    return ans;
}
inline ll inv(ll base,ll modulo=modd){
    return fast_expo(base,modulo-2LL,modulo);
}



signed main()
{
    #ifdef _SUBLIME
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    fio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*d,b*c)))<<endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] A= new int[3];
		A[0]=sc.nextInt();
		A[1]=sc.nextInt();
		A[2]=sc.nextInt();
		
		int ans=Math.min(Math.abs(A[0]-A[1]), Math.abs(A[0]-A[2]))+Math.abs(A[1]-A[2]);;
		for(int i=0;i<3;i++){
				int a,b;
				if(i==0){
					a=A[1];
					b=A[2];
				}else if(i==1){
					a=A[0];
					b=A[2];
				}else{
					a=A[0];
					b=A[1];
				}
				int ans1=Math.min(Math.abs(A[i]-b), Math.abs(A[i]-a))+Math.abs(a-b);
				ans=Math.min(ans1, ans);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
long long int c(int n, int r){
  int re=1;
  for(int i=0; i<r; i++){
    re*=n-i;
    re/=r-i;
  }
  return re;
}
int main(void){
  int n,m;
  cin>>n>>m;
  long long int ans=0;
  int ok=n-m;
  /*for(int i=0; i<=m; i++){
    long long int pre=0;
    pre+=100*ok;
    pre+=1900*m;
    pre*=c(m,i);
    ans+=pre;
  }*/
  ans+=ok*100;
  ans+=m*1900;
  ans*=pow(2,m);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int ele1,ele2;
int s[1000][1000];
int s_pointer[1000];

void func_print(int s[][1000],int s_size,int s_num)
{
    printf("%d\n",s_num);
    for (int i=0; i<s_num; ++i)
    {
        printf("%d ",s_size);
        for (int j=0; j<s_size; ++j)
            printf("%d ",s[i][j]);
        printf("\n");
    }
}
void func_cal(int n,int s_size,int s_num)
{
    int tail=1;
    for (int i=0; i<s_num; ++i)
    {
        int size_tmp=0;
        for (int j=0; j<i; ++j)
            s[i][size_tmp++]=s[j][s_pointer[j]++];
        while (size_tmp<s_size)
            s[i][size_tmp++]=tail++;
        s_pointer[i]=(i==0)?0:s_pointer[i-1];
    }
}

int main()
{
    cin>>n;
    ele1=int(trunc(sqrt(2*n)));
    ele2=2*n/ele1;
    if (ele1*ele2!=2*n || (ele2-ele1!=1)) {cout<<"No"<<endl; return 0;} else cout<<"Yes"<<endl;
    func_cal(n,ele1,ele2);
    func_print(s,ele1,ele2);
    return 0;
}
    


Measured memory_bytes: 3200
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <fstream>
using namespace std;

#define maxn 500010
#define inf 1000000000
#define ll long long
#define mod 1000000007

int n;
long long free_sum, free_total, inv2;
int aib[maxn], gr[maxn], sm[maxn];
long long fac[maxn];
bool fre[maxn];
int p[maxn];

int LSB(int i) {
    return i&-i;
}

int query(int aib[], int i) {
    int s = 0;
    for (; i > 0; i -= LSB(i)) {
        s += aib[i];
    }
    return s;
}

void update(int aib[], int i, int val) {
    for (; i <= n; i += LSB(i)) {
        aib[i] += val;
    }
}

void precalc() {
    fac[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fac[i] = fac[i-1] * i % mod;
    }

    free_total = 0;
    free_sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (fre[i]) {
            ++free_total;
            free_sum = (free_sum + (i-1)) % mod;
        }
        sm[i] = free_total;
    }
    for (int i = 1; i <= n; ++i) {
        gr[i] = free_total - sm[i];
    }
    inv2 = mod/2+1;
}

int main() {
    // freopen("test.in", "r", stdin);
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        fre[i] = true;
    }

    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        fre[p[i]] = false;
    }

    precalc();

    long long ans = 0;
    long long running_free = 0;
    long long running_sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (!p[i]) {
            ans = (ans + fac[free_total-1] * free_sum % mod * fac[n-i] % mod) % mod;
            long long in_order = (fac[free_total] * inv2 % mod * running_free % mod + running_sum * fac[free_total-1] % mod) % mod;
            ans = (ans - in_order * fac[n-i] % mod) % mod;
            if (ans < 0)
                ans += mod;
            ++running_free;
        } else {
            ans = (ans + fac[free_total] * (p[i]-1) % mod * fac[n-i] % mod) % mod;
            long long in_order = (fac[free_total] * query(aib, p[i]) % mod + (free_total >= 1 ? (running_free * sm[p[i]] % mod * fac[free_total-1] % mod) : 0)) % mod;
            ans = (ans - in_order * fac[n-i] % mod) % mod;
            if (ans < 0)
                ans += mod;
            running_sum = (running_sum + gr[p[i]]) % mod;
            update(aib, p[i], 1);
        }
    }

    ans = (ans + fac[free_total]) % mod;

    cout << ans;
}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  ll N,ans=0ll,cnt=0ll;
  cin>>N;
  ll A[N],DP[N+1][N+1];
  REP(i,N) cin>>A[i];
  REP(i,N+1){
    REP(j,N+1){
      DP[i][j]=0;
    }
  }
  
  vector<pair<ll,ll>> P;
  REP(i,N) P.push_back(make_pair(A[i],i));
  SORT(P);
  REVERSE(P);
  
  for(int i=0; i<N; ++i){
    for(int j=0; j<=i; ++j){
      DP[j+1][i-j]=max(DP[j+1][i-j],DP[j][i-j]+P[i].first*abs(P[i].second-j));
      DP[j][i-j+1]=max(DP[j][i-j+1],DP[j][i-j]+P[i].first*abs(P[i].second-N+i-j+1));
    }
  }
  
  for(int i=0; i<=N; ++i){
    if(ans<DP[i][N-i]) ans=DP[i][N-i];
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 34984
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int a[60], b[60], c[60], d[60];
signed main() {
    int N, M; cin >> N >> M;
    rep(i,0,N) {
        cin >> a[i] >> b[i];
    }
    rep(i,0,M) {
        cin >> c[i] >> d[i];
    }

    int ans[60] = {};
    rep(i,0,N) {
        int mi = INF;
        rep(j,0,M) {
            int x = abs(c[j] - a[i]);
            int y = abs(d[j] - b[i]);
            if(mi > x + y) {
                mi = x + y;
                ans[i] = j+1;
            }
        }
    }

    rep(i,0,N) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#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;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}


int main() {

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

	Int N;
	cin >> N;

	string S;
	cin >> S;

	auto dp = make_vec(N + 1, 4, 1000, char(0));//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 100; k++) {
				if (dp[i][j][k] == 0) {
					continue;
				}
				//i文字目を選択する場合
				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = 1;
			
				//i文字目を選択しない場合
				dp[i + 1][j][k] = 1;
			}
		}
	}

	Int ans = 0;
	vector<char> seen(1000,0);
	for (Int i = 1; i <= N; i++) {
		for (Int k = 0; k < 1000; k++) {
			if (dp[i][3][k] != 0) {
				if (seen[k] != 0) {
					continue;
				}
				ans++;
				seen[k] = 1;
			}
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 122368
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


def solve(n):
  Sn = str(n)
  div = 0
  for c in Sn:
    div += int(c)

  if n%div == 0:
    return True
  else:
    return False

N = int(input())
if solve(N):
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

#define int long long

signed main()
{
    int ans = 0;
    int N, D;
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 0x3f3f3f3f
#define endl "\n"
#define MAXN 100010
#define F first
#define S second
#define abs(a, b) ((a > b) ? a-b : b-a)
#define rep(i, a, b) for(int i = (a); i <= (b); i++)

typedef long long int ll;

bool is(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return (s == t);
}

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

	double l; cin >> l;
	double lado = l/3.0;
	double vol = lado*lado*lado;

	cout << fixed << setprecision(9) << vol << endl;	

	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<pair<int, int>> seg;
ll solve(int X) { //go left first
	ll ans = 0;
	set<pair<int, int>> l, r;
	for (int i = 0; i < n; i++)
		l.insert( { seg[i].first, i }), r.insert( { seg[i].second, i });

	ll cur = 0;
	for(int i = 0; i < n; i++) {
		if(X^(i&1)) {
			auto t = *r.begin();
			ans += max(cur-t.first, 0ll);
			cur = min((ll)t.first, cur);
			r.erase(t);
			l.erase({seg[t.second].first, t.second});
		} else {
			auto t = *l.rbegin();
			ans += max(t.first-cur, 0ll);
			cur = max((ll)t.first, cur);
			l.erase(t);
			r.erase({seg[t.second].second, t.second});
		}
	}
	return ans+abs(cur);
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	seg.resize(n);
	for (auto &i : seg)
		cin >> i.first >> i.second;
	cout << max(solve(0), solve(1));
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define int long long

int kumi(int a,int b,int c){
    
    if(a>=b){
        if(b==0)return 1;
        int t=b;
        if(c==0)t=a;
        
    for(int i=1;i<b;i++){
        t=(t*(a-i))%1000000007;
    }
    
    return t;
    }
    else{
        return 0;
    }

}
signed main(){
   int n,m,l;
   cin >> n >>m;
   priority_queue< int, vector<int>, greater<int> > a,b;
   for(int i=0;i<n;i++){
       cin >>l;
       a.push(l);
   }
   for(int i=0;i<m;i++){
       cin >> l;
       b.push(l);
   }
   int ans=1;
   int tukau=0;
   int a0=-1,b0=-1;
   cerr << b.top()<<endl;
   while((!a.empty())&&(!b.empty())){
       if(a0==a.top()||b0==b.top()){
           ans=0;
           break;
       }
       if(a.top()<b.top()){
           ans= ans*kumi(a.top()-tukau,m,1)%(1000000007);
           cerr << ans <<a.top()<<endl;
           tukau+=m;
           n-=1;
           a0=a.top();
           a.pop();
       }else{
           if(a.top()>b.top()){
               ans= ans*kumi(b.top()-tukau,n,1)%(1000000007);
            cerr << ans  <<b.top()<<endl;
            tukau+=n;
            m-=1;
            b0=b.top();
           b.pop();
           }else{
               tukau+=1;
               ans=ans*kumi(a.top()-tukau,m-1,0)%(1000000007);
               cerr << ans  <<a.top()<<endl;
               tukau+=m-1;
                 ans= ans*kumi(b.top()-tukau,n-1,0)%(1000000007);
                 cerr << ans  <<b.top()<<endl;
                 tukau+=n-1;
                 n-=1;
                 m-=1;
                 a0=a.top();
                 b0=b.top();
                 a.pop();
                 b.pop();
           }
       }
   }
   cout << ans;
   

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int d, t, s;
	cin >> d >> t >> s;
	cout << (d <= t * s ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3664
#include<stdio.h>
using namespace std;

int main()
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	if ((A - B) % 2 == 0) {
		printf("Alice");
	}
	else {
		printf("Borys");
	}
	return 0;
}

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

int main() {
	const int size = 3;
	int nums[size];
	int buf;

	for (int i = 0; i < size; i++)cin >> nums[i];

	for (int i = 0; i < size; i++) {
		for (int j = size -1; j > 0; j--) {
			if (nums[j - 1] > nums[j]) {
				buf = nums[j - 1];
				nums[j - 1] = nums[j];
				nums[j] = buf;
			}
		}
	}

	cout << nums[0] << " " << nums[1] << " " << nums[2] << endl;


}


Measured memory_bytes: 3100
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(int), cmpAsc);
    int f = 1;
    rep(i, 1, n){
        if(a[i] == a[i-1]){
            f = 0;
        }
    }
    if(f){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
using namespace std;

char ps[233];

int main()
{
	scanf("%s",ps); int l=strlen(ps);
	bool flag=true;
	for(int i=0; i<l/2; i++) if(ps[i]!=ps[l-i-1])
	{
		flag=false; break;
	}
	for(int i=0; i<(l-1)/2; i++) if(ps[i]!=ps[(l-1)/2-i-1])
	{
		flag=false; break;
	}
	for(int i=(l+3)/2-1; i<l; i++) if(ps[i]!=ps[l+(l+3)/2-2-i])
	{
		flag=false; break;
	}
	if(flag==true) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<int> l1,l2;
int main()
{
    int n,c,k;
    string s;
    cin>>n>>k>>c;
    cin>>s;
    int last=-1e9;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='o'&&last+c<i)
        {
            l1.push_back(i);
            last=i;
        }
        if(l1.size()==k) break;
    }
    int stock=1e9;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='o'&&stock>=c)
        {
            stock=0;
            l2.push_back(i);
        }
        else stock++;
        if(l2.size()==k) break;
    }
    reverse(l2.begin(),l2.end());
    for(int i=0;i<k;i++) if(l1[i]==l2[i]) cout<<l1[i]+1<<endl;
}

Measured memory_bytes: 3448
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    string n;
    cin >> n;
    int mod = 0;
    rep(i, n.size()){
        int num = n[i] - '0';
        mod += num;
        mod %= 9;
    }
    if(mod == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3760
#include <stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==B && A!=C && B!=C)
        printf("Yes\n");
    else if(B==C && A!=B && A!=C)
        printf("Yes\n");
    else if(C==A && B!=C && B!=A)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s, t, d = LI()
    w = LI()
    sumw = sum(w)
    sb = s
    mins = s
    for i in range(d):
        sb += w[i]
        mins = min(mins, sb)
        if sb <= t:
            print(i + 1)
            return
    if sumw >= 0:
        print(-1)
    else:
        ans = ((mins - t) // abs(sumw)) * d
        #print(ans, s, d, t, sumw)
        s += ans // d * sumw
        i = 0
        while 1:
            if s <= t:
                print(ans + i)
                return
            s += w[i%d]
            i += 1
        print(ans+i+1)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()



Measured memory_bytes: 19168
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}





void solve()
{
int n,i;
    cin>>n;
    vector<int>a(n);
    unordered_map<int,int>mp;
    for(int &x:a){cin>>x;mp[x]++;}
    int cnt=0;
    
    for(int x:a)
    {
     vector<int>v;
        for(i=1;i*i<=x;i++)
        {
         if(x%i==0)
         {
             if(x/i==i)
                 v.pb(i);
             else
             {
              v.pb(i);
                 v.pb(x/i);
             }
         }
        }
        bool flag=true;
        int entry=0;
        for(int y:v)
        {
       if(y!=x)
         {
          if(mp[y])
          {
           flag=false;
              break;
          }
         }
          else if(y==x&&mp[y]>1)
          {
           flag=false; break;   
          }
        }
        if(flag)cnt++;
        
    }
    cout<<cnt<<endl;
    
}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;

     int t=1;
   //  cin>>t;
     while(t--)
    	solve();
    return 0;
}



Measured memory_bytes: 32540
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
#define mod 1e9+7
typedef long long ll;

void Main()
{
  	ll N;
	cin >> N;
  	ll ans = 1;
  	ll MOD = (ll)mod;
  	for(ll i = 1; i<=N; i++){
      	ans = ((ans%MOD) * (i%MOD))%MOD;
    }
  	cout << ans << endl;
  
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
/*using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;*/

int main(){
  int n;
  std::cin >> n;
  std::set<std::string> s;
  rep(i,n){
    std::string S;
    std::cin >>  S;
    s.insert(S);
  }

  int ans = s.size();
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
long long f[200010],a[200010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	long long n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		f[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	s+=f[i]*(f[i]-1)/2;
	for(int i=1;i<=n;i++)
	cout<<s-f[a[i]]+1<<"\n";
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int a, int b) {
return b ? gcd(b, a%b) : a;
}

int main(){
    ll N,M;
    cin >> N>> M;
    string s,t;
    cin >> s >> t;
    ll lms = N*M / gcd(N,M);
    ll p = lms / N, q= lms / M;
    for(ll i=0; i<N/q; i++){
        if(s[i*q] != t[i*p]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << lms <<endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int M,N;
char fie[1001][1001];
char flag[3][3];
int ok[1001][1001];
int dx[]={-1,0,-1,0};
int dy[]={-1,-1,0,0};
char dc[]="JOI";
bool check(int x,int y){
if( x<0 || y<0 ) return false;
bool f=true;
for(int k=0;k<2;k++){
for(int l=0;l<2;l++){
if( fie[x+k][y+l] != flag[k][l] ) f=false;
}
}
return f;
}
int main(){
cin >> M >> N;
for(int i=0;i<M;i++){
for(int j=0;j<N;j++){
cin >> fie[j][i];
}
}
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
cin >> flag[j][i];
 
int sum = 0;
for(int i=0;i<M;i++){
for(int j=0;j<N;j++){
if( check(j,i) ){
ok[j][i]=1;
sum++;
}
}
}
 
int res = sum;
for(int i=0;i<M;i++){
for(int j=0;j<N;j++){
char tmp = fie[j][i];
for(int c=0;c<3;c++){
int ret=sum;
fie[j][i] = dc[c];
for(int k=0;k<4;k++){
int nx = j+dx[k],ny = i+dy[k];
if( check(nx,ny) ){
if( ok[nx][ny] == 0 ) ret++;
} else {
if( nx>=0 && nx>=0 && ok[nx][ny] == 1 )ret--;
}
}
res = max(res,ret);
}
fie[j][i] = tmp;
}
}
cout << res << endl;
}

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

using namespace std;

int main()
{
    string s;
    vector<string> v;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '0')
        {
            v.push_back("0");
        }
        if (s[i] == '1')
        {
            v.push_back("1");
        }
        if (s[i] == 'B')
        {

            if (!v.empty())
            {
                v.pop_back();
            }
        }
    }

    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i];
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   char a;
   cin >> a;
   if('a'<=a&&a<='z'){
      cout << 'a' << endl;
   }
   else{
      cout << 'A' << endl;
   }
   return 0;
}


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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

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

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

// a + b = x
// a + 2b = y / 2
// b = y / 2 - x
// a = 2x - y / 2

int32_t main() {
	int x, y;
	cin >> x >> y;
	if(y & 1) {
		cout << "No" << '\n';
		return 0;
	}
	int a = 2*x - y/2, b = y/2 - x;
	assert(a + b == x);
	assert(2*a + 4*b == y);
	if(a >= 0 && b >= 0) {
		cout << "Yes" << '\n';
	}
	else
		cout << "No" << '\n';
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  vector< pair<int,int> > X;
  for(int i = 0; i < Q; ++i){
    int x;
    cin >> x;
    X.emplace_back(x,i);
  }
  sort(X.begin(), X.end());
  long long s = 0;
  for(int i = N/2; i < N; ++i) s += A[i];
  vector<long long> ans(Q);
  int l = 0, r = N/2;
  long long c[] = {0,0};
  for(int i = 0; i < Q; ++i){
    int x = X[i].first, id = X[i].second;
    while(r < N and abs(x-A[l]) > abs(x-A[r])){
      c[l%2] += A[l];
      s -= A[r];
      ++l,++r;
    }
    //cerr << x << " " << A[l] << " " << A[r] << endl;
    while(N-r < r-l){
      if(abs(A[l]-x) > abs(x-A[r-1])){
        c[l%2] += A[l];
        ++l;
      }else{
        s += A[r-1];
        --r;
      }
    }
    //cerr << N-r << " " << r-l << endl;
    //if(N-r > r-l and l > 0) --l, c[l%2] -= A[l];
    // cerr << x << " " << A[l] << " " << A[r] << endl;
    // cerr << c[0] << " " << c[1] << endl;
    ans[id] = s + c[1-N%2];
  }
  for(int i = 0; i < Q; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main(void) {
	int n;
	cin >> n;
	if (n <= 2) {
		cout << 0 << endl;
	} else {
		cout << n / 3 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace tenki
{
    class Program
    {
        static void Main(string[] args)
        {
           string yohou = Console.ReadLine();
            string tenki = Console.ReadLine();
            int count = 0;
            for(int i = 0; i < 3; i++)
            {
                if (yohou[i] == tenki[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }

    }
}

Measured memory_bytes: 13140
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    string s;
    cin >> s;
    for(int i = 0 ; i < s.size() ; i += 2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512