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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a[3],z,z1;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[1]%2!=0&&a[0]%2!=0)||(a[1]%2==0&&a[0]%2==0))
    {
        z=(a[1]-a[0])/2;
        cout<<z+a[2]-a[1]<<endl;
    }
    else if((a[1]%2!=0&&a[0]%2==0)||(a[1]%2==0&&a[0]%2!=0))
    {
        z=(a[2]-a[1])/2;
        z1=(ceil)(a[2]-a[0])/2;
        cout<<z+z1+2<<endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

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

 
    

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  string N;
  cin >> N;

  ll sum = 0;
  for (char n : N)
    sum += (n - '0');

  cout << (sum % 9 == 0 ? "Yes" : "No");
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> prob(n, false);
	vector<int> w(n);
	int wa = 0;
	int ac = 0;
	rep(i, m) {
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (prob[p]) continue;
		if (s == "AC") {
			prob[p] = true;
			ac++;
		}
		else {
			w[p]++;
		}
		
	}
	rep(i,n){
		if (prob[i]) wa += w[i];
	}

	pf(ac);
	pf(wa);

	return 0;
}

Measured memory_bytes: 3768
/// if diameter of tree%3== 0 or 2, first. else second.

#include <bits/stdc++.h>
using namespace std;

vector<int> adjl[200005];
vector<int> children[200005];
int longest_[200005];
int secondLongest_[200005];
int longestchild[200005];
int parent[200005];
int n;

void dfs(int node){
for (int x : adjl[node]){
    if (x==parent[node]) continue;
    parent[x] = node;
    dfs(x);
}
}

int longest(int node){
if (longest_[node] !=-1) return longest_[node];
if (children[node].size()==0) return 0;
else{
    int ans = 0;
    for (int x : children[node]){
        if (longest(x)+1>ans){
            ans = longest(x) +1;
            longestchild[node] = x;
        }
    }

return longest_[node] = ans;
}}

int secondLongest(int node){
longest(node);
if (secondLongest_[node]!=-1) return secondLongest_[node];
if (children[node].size()<2) return 0;
int ans = 0;
for (int x : children[node]){
    if (x == longestchild[node]){
        continue;
    }
    ans = max(ans,longest(x)+1);
}
return secondLongest_[node] = ans;
}

int diameter(){
int ans = 0;
for (int x = 0; x<n; x++){
    ans = max(ans,longest(x) + secondLongest(x));
}
return ans;
}

int main(){
memset(longest_,-1,sizeof(longest_));
memset(secondLongest_,-1,sizeof(secondLongest_));

scanf("%d",&n);
int a,b;
for (int x = 0; x<n-1; x++){
    scanf("%d%d",&a,&b);
    a--;b--;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
}
parent[0] = -1;
dfs(0);

for (int x = 0; x<n; x++){
    for (int y : adjl[x]){
        if (y!=parent[x]){
            children[x].push_back(y);
        }
    }
}
/*
printf("%d\n",diameter());
for (int x = 0; x<n; x++){
    printf("longest (%d) = %d, secondlongest = %d\n",x,longest(x),secondLongest(x));
}*/

if (diameter()%3==1){
    printf("Second");
}
else printf("First");




}


Measured memory_bytes: 34176
def f(a,b):
    c=max(a,b)
    i=0
    while c>=10**i:
        i +=1
    return i
n=int(input())
for i in range(int(n**(0.5)),0,-1):
    if n%i == 0:
        j=n//i
        break
print(f(j,i))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int ctoi(char c){return c - '0';}

bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  string s;cin>>s;
  int w = 0;
  int b = 0;

  rep(i,n)if(s[i]=='.')++w;
  int ans = w;
  rep(i,n){
    if(s[i]=='.')w--;
    else b++;
    ans = min(ans,w+b);
  }
  
  print(ans);
  return 0;
} 

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  string a,b,c;cin>>a>>b>>c;
  a = toupper(a[0]);
  b = toupper(b[0]);
  c = toupper(c[0]);
  cout<<a<<b<<c;
}


Measured memory_bytes: 256
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{

	private void solve() {
		int n=gInt(),a[]=ints(n).toArray();

		long r=0;
		for(int i:rep(n)) {
			r+=a[i]/2;
			a[i]%=2;
			if(i<n-1&&a[i]==1&&a[i+1]>0) {
				++r;
				--a[i];
				--a[i+1];
			}
		}
		System.out.println(r);
	}


	public static void main(String[]$){
		new Main().solve();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}


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

using namespace std;

int main() {
	int R;
	cin >> R;
	double pi = acos(-1);
	double length = 2 * R * pi;
	cout << fixed << setprecision(2) << length << endl;
	return 0;
}

Measured memory_bytes: 3656
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin>>N;
    vs W(N); REP(i, N) cin >> W[i];

    bool ok = true;
    set<string> st;
    string s = W[0];
    st.insert(s);
    FOR(i,1,N) {
        string ns = W[i];
        if (st.count(ns)>0 ||
            ns[0]!=s[s.size()-1]) {
            ok = false;
            break;
        }
        st.insert(ns);
        s = ns;
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

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

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

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

    if (a[0] != 0) {
        cout << -1 << '\n';
        return 0;
    }

    long long res = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i] == a[i - 1] || (a[i] - a[i - 1] < 0  && a[i] > 0)) {
            res += a[i];
        } else if (a[i] - a[i - 1] == 1) {
            res++;
        } else if (a[i] - a[i - 1] > 1) {
            res = -1;
            break;
        }
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<vector<int>> dp_left(N+1, vector<int>(K));
    vector<vector<int>> dp_right(N+1, vector<int>(K));
    dp_left[0][0] = dp_right[N][0] = 1;
    REP(i, N) {
        REP(j, K) {
            dp_left[i+1][j] = dp_left[i][j];
            if (j >= a[i]) dp_left[i+1][j] |= dp_left[i][j-a[i]];
            dp_right[N-i-1][j] = dp_right[N-i][j];
            if (j >= a[N-i-1]) dp_right[N-i-1][j] |= dp_right[N-i][j-a[N-i-1]];
        }
    }
    int ans = 0;
    REP(i, N) {
        vector<int> cum(K+1);
        REP(j, K) cum[j+1] = cum[j] + dp_right[i+1][j];
        bool ok = true;
        REP(j, K) {
            if (!dp_left[i][j]) continue;
            if (cum[K-j] - cum[max(0, K-a[i]-j)] > 0) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 196096
def hex(x , y):

    ans = ""

    if int(x, 16) < int(y, 16):
        ans = "<"
    elif int(x, 16) > int(y, 16):
        ans = ">"
    else:
        ans = "="

    return ans

def main():
    x , y = map(str , input().split())
    print(hex(x , y))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
	int n,m,i,j;
	int mni=2147483647;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]); 
	}
	for (i=1;i<=n-m+1;i++)
	{
		int l=a[i];
		int r=a[i+m-1];
		int t;
		if (r<0)
		{
			t=-l;
		}
		else
		if (l<0)
		{
			t=min(2*(-l)+r,2*r-l);
		}
		else
		{
			t=r;
		}
		mni=min(mni,t);
	}
	cout<<mni<<endl;
	return 0;
} 

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

#define pc(x) __builtin_popcount((x))

const int maxn = 30;
int n, ban[maxn];

void dfs(int k, int a, int b)
{
	if(k == 1) { printf("%d %d ", a, b); return ; }
	for(int i = 0; i < n; ++i) if(((a >> i) ^ (b >> i)) & 1)
	{
		ban[i] = 1;
		int mid = a;
		for(int j = 0; j < n; ++j) if(!ban[j]) { mid ^= (1 << j); break; }
		dfs(k - 1, a, mid); dfs(k - 1, mid ^ (1 << i), b);
		ban[i] = 0;
		break;
	}
}

int main()
{

	n = read(); int a = read(), b = read();
	if((pc(a) ^ pc(b)) & 1) { puts("Yes"); dfs(n, a, b); }
	else puts("No");

	return 0;
}


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

int ans;

void solve(int n,int s,int m){
	rep(i,m+1,10){
		if(n==1&&s==i){
			ans++;
			break;
		}
		solve(n-1,s-i,i);
	}
}

int main(){
	int n,s;
	while(1){
		cin>>n>>s;
		if(n==0&&s==0) break;
		ans=0;
		solve(n,s,-1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    bitset<64> b;
    int q;cin>>q;while(q--){
        int op;cin>>op;
        int x=0;
        switch (op)
        {
        case 0:
            cin>>x;
            cout<<b.test(x)<<endl;
            break;
        case 1:
            cin>>x;
            b.set(x);
            break;
        case 2:
            cin>>x;
            b.reset(x);
            break;
        case 3:
            cin>>x;
            b.flip(x);
            break;
        case 4:
            cout<<b.all()<<endl;
            break;
        case 5:
            cout<<b.any()<<endl;
            break;
        case 6:
            cout<<b.none()<<endl;
            break;
        case 7:
            cout<<b.count()<<endl;
            break;
        case 8:
            cout<<b.to_ulong()<<endl;
            break;
        default:
            break;
        }
    }
}
/* 
- test(i): Print 1 if ii-th flag is ON, otherwise 0
- set(i): Set ii-th flag to ON
- clear(i): Set ii-th flag to OFF
- flip(i): Inverse ii-th flag
- all: Print 1 if all flags are ON, otherwise 0
- any: Print 1 if at least one flag is ON, otherwise 0
- none: Print 1 if all flags are OFF, otherwise 0
- count: Print the number of ON flags
- val: Print the decimal value of the state

 */


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int x;
	cin >> x;
	if (x >= 30)
		puts("Yes");
	else
		puts("No");
}

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

	solve();
}


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

int main(void)
{
	int a, b;
	int n;
	int i, j;
	int work;
	int x[10000];
	
	scanf("%d%d", &a, &b);
	
	if(a <= 5) {
		printf("0\n");
	} else if(a >= 13) {
		printf("%d\n", b);
	} else {
		printf("%d\n", b / 2);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


int main(){
	int n,m;
	cin>>n>>m;
	vi know(m+1);
	rep(i,0,m) cin>>know[i];
	know[m]=1e8;
	int MAX=0,l=0,r=1;
	rep(i,1,n+1){
		if(i==know[r]){
			l=r; r++;
		}
		int tmp=min(know[r]-i,abs(i-know[l]));
		MAX=max(tmp,MAX);
	}
	o(MAX);
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int h,w;
    cin >> h >> w;

    vector<string> s;

    rep(i,h){
        string tmps;
        cin >> tmps;
        s.pback(tmps);
    }

    vector<int> hcount;
    vector<int> wcount;

    rep(i,h) hcount.pback(0);
    rep(i,w) wcount.pback(0);

    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#'){
                hcount[i]++;
                wcount[j]++;
            }
        }
    }

    rep(i,h){
        if(hcount[i] > 0){
            rep(j,w){
                if(wcount[j] > 0){
                    cout << s[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] arr = new int[3][n];
		for (int i = 0; i < n; i++) {
			arr[0][i] = sc.nextInt();
			arr[1][i] = sc.nextInt();
			arr[2][i] = sc.nextInt();
		}
		int[][] ans = new int[3][n];
		ans[0][0] = arr[0][0];
		ans[1][0] = arr[1][0];
		ans[2][0] = arr[2][0];
		for (int i = 1; i < n; i++) {
			ans[0][i] = Math.max(ans[1][i - 1], ans[2][i - 1]) + arr[0][i];
			ans[1][i] = Math.max(ans[2][i - 1], ans[0][i - 1]) + arr[1][i];
			ans[2][i] = Math.max(ans[0][i - 1], ans[1][i - 1]) + arr[2][i];
		}
		System.out.println(Math.max(Math.max(ans[0][n - 1], ans[1][n - 1]), ans[2][n - 1]));
	}
}


Measured memory_bytes: 94140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	int t[100010], x[100010], y[100010];
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> t[i] >> x[i] >> y[i];
	}
	t[0] = 0; x[0] = 0; y[0] = 0;
	int dt;
	bool can = true;
	for (int i = 0; i < N; ++i) {
		dt = t[i + 1] - t[i];
		if (dt < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) {
			can = false;
		}
		if (dt % 2 != (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]))%2) {
			can = false;
		}
	}
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	set<string> st;
	int n; cin>>n;
	for(int i=0; i<n; i++){
		string s; cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
//vector<pair<int,int> > adj[400];
int dist[400][400];
void floydWarshall (int graph[][100])
{
    /* dist[][] will be the output matrix that will finally have the shortest 
      distances between every pair of vertices */
    int i, j, k;
 
    /* Initialize the solution matrix same as input graph matrix. Or 
       we can say the initial values of shortest distances are based
       on shortest paths considering no intermediate vertex. */
    for (i = 0; i < 10; i++)
        for (j = 0; j < 10; j++)
            dist[i][j] = graph[i][j];
 
    /* Add all vertices one by one to the set of intermediate vertices.
      ---> Before start of a iteration, we have shortest distances between all
      pairs of vertices such that the shortest distances consider only the
      vertices in set {0, 1, 2, .. k-1} as intermediate vertices.
      ----> After the end of a iteration, vertex no. k is added to the set of
      intermediate vertices and the set becomes {0, 1, 2, .. k} */
    for (k = 0; k < 10; k++)
    {
        // Pick all vertices as source one by one
        for (i = 0; i < 10; i++)
        {
            // Pick all vertices as destination for the
            // above picked source
            for (j = 0; j < 10; j++)
            {
                // If vertex k is on the shortest path from
                // i to j, then update the value of dist[i][j]
                if (dist[i][k] + dist[k][j] < dist[i][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
}
int main()
{
 int h,w,c[100][100],a[400][400],ans=0;
 cin>>h>>w;
 for(int i=0;i<10;i++)
 {
 	for(int j=0;j<10;j++)
 	{
 		cin>>c[i][j];
 	}
 }
 for(int i=0;i<h;i++)
 {
 	for(int j=0;j<w;j++)
 	{
 		cin>>a[i][j];
 	//	adj[i].push_back(make_pair(j,a[i][j]));
 	//	adj[j].push_back(make_pair(j,a[i][j]));
 	}
 }
 floydWarshall(c);
 for(int i=0;i<h;i++)
 {
 	for(int j=0;j<w;j++)
 	{
 		if(a[i][j]!=1&&a[i][j]!=-1)
 		{
          ans+=dist[a[i][j]][1];
 		}
 	}
 }
 cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 640
# コードテストする
from fractions import gcd
K = int(input())
ans = 0
gcd_list = {}
for i in range(1, K+1):
    for j in range(1, K+1):
        gcd_list[i, j] = gcd(i, j)

for i in range(1, K+1):
    for j in range(1, K+1):
        hoge = gcd_list[(i, j)]
        for k in range(1, K+1):
            ans += gcd_list[(hoge, k)]
print(ans)


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

const int MAX = 500005;
int n,q;
int a[500005];
int bit[MAX];
// structure to store queries
struct Query
{
    int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}
Query queries[500005];
// updating the bit array
void update(int idx, int val, int n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}

// querying the bit array
int query(int idx, int n)
{
    int sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int n, int q)
{
    // initialising bit array
    

    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));
    // answer for each query
    int ans[q];
    int query_counter = 0;
    for (int i=0; i<n; i++)
    {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[a[i]] !=-1)
            update (last_visit[a[i]] + 1, -1, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[a[i]] = i;
        update(i + 1, 1, n);

        // If i is equal to r of any query  store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, n)-
                     query(queries[query_counter].l,n);
            query_counter++;
        }
    }

    // print answer for each query
    for (int i=0; i<q; i++)
        cout << ans[i] << endl;
}

// driver code
int main()
{

    cin>>n>>q;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<q;i++)
    {
        int lt,rt;
        cin>>lt>>rt;
        lt--;rt--;
        queries[i].l=lt;
        queries[i].r=rt;
        queries[i].idx=i;

    }
    sort(queries, queries+q, cmp);
    answeringQueries(n, q);
    return 0;
}


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

int main(){
  int n,d,ans = 0;
  cin >> n >> d;
  if(n%(d*2+1) == 0)cout << n/(d*2+1) << endl;
  else cout << n/(d*2+1) + 1<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
    unsigned short *A, *B;
    int C[VMAX + 1];
    int n, i, j;

    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    /* your code */
    for (i = 0; i <= VMAX; i++)
        C[i] = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &A[i + 1]);
        C[A[i + 1]]++;
    }
    for (i = 1; i <= VMAX; i++)
        C[i] = C[i] + C[i - 1];

    for (j = 1; j <= n; j++)
    {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for (i = 1; i <= n; i++)
    {
        if (i > 1)
            printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 9708
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
lld ar[100005];
lld n,k;
lld dp[100005];
lld change(lld a)
{
    if(a>=n)
        return 0;
    if(a==n-1)
        return 0;
    if(dp[a]!=-1)
        return dp[a];
    else
    {
        lld c=INT_MAX,i;
        for(i=1;i<=k;i++)
        {
            if(a<n-i)
            c=min(c,change(a+i)+abs(ar[a]-ar[a+i]));
            else
                break;
        }
        dp[a]=c;
        return c;
    }
}
int main()
{

    cin>>n>>k;
    lld i,j;
    for(i=0;i<=n;i++)
        dp[i]=-1;
    for(i=0;i<n;i++)
    cin>>ar[i];
    cout<<change(0);
}


Measured memory_bytes: 6528
N,M,C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = 0
for i in range(N):
  a = C
  A = [int(x) for x in input().split()]
  for j in range(M):
    a +=  A[j]*B[j]
  if a>0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
nn = int(input())
dd = list(map(int,input().split()))
nof_op = 0
finish = 0
while True:
    for ind in range(nn):
        if (dd[ind] % 2) == 1:
            finish = 1
            break
        else:
            dd[ind] = dd[ind] / 2
    if finish == 1:
        break
    else:
        nof_op += 1
print(nof_op)

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 384
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])

def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)
    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        j = 0
        jM = len(cur)
        for k in range(len(S)):
            if flag[k] and S[k]<cur[j]:
                cur.append(S[k])
                j+=1
                flag[k] = False
                if j==jM:
                  break
        else:
            return("No")
        cur.sort(reverse=True)
    return("Yes")

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 113868
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 100005
using namespace std;
char ch[MN];int n;
int main(){
	scanf("%s",ch+1);n=strlen(ch+1);
	for(int i=1,j=n-1;i<=j;i++,j--)if(ch[i]!=ch[j])return 0*puts("-1");
	if(ch[n]=='1'||ch[1]=='0')return 0*puts("-1");	
	int lst=1;
    for(int i=2;i<=n;i++)if(ch[i]=='1'){
		printf("%d %d\n",i,lst);
		for(int j=lst+1;j<i;j++)printf("%d %d\n",i,j);
		lst=i;
    }printf("%d %d\n",n,n-1);
}

Measured memory_bytes: 1408
//Created Time:2019年10月27日 星期日 20时09分40秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define db double
#define N 602

using namespace std;

int n, m;
db mat[N][N], deg[N], ans[N], tmp[N];
bool mp[N][N];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		int u, v; scanf("%d%d", &u, &v);
		mp[u][v] = true; deg[u] += 1.0;
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j)
			if(mp[i][j])
				mat[i][j] = -1.0 / deg[i];
		mat[i][i] = 1.0; mat[i][n + 1] = 1.0;
	}
	mat[n][n + 1] = 0;
	for(int i = 1; i <= n; ++i){
		int mx = i;
		for(int j = i + 1; j <= n; ++j)
			if(fabs(mat[j][i]) > fabs(mat[mx][i])) mx = i;
		if(i != mx) swap(mat[i], mat[mx]);
		db div = mat[i][i];
		for(int j = i; j <= n + 1; ++j) mat[i][j] /= div;
		for(int j = i + 1; j <= n; ++j){
			div = mat[j][i];
			for(int k = i; k <= n + 1; ++k) mat[j][k] -= mat[i][k] * div;
		}
	}	
	for(int i = n; i; --i){
		ans[i] = mat[i][n + 1];
		for(int j = n; j > i; --j) ans[i] -= ans[j] * mat[i][j];
	}
	
	memcpy(tmp, ans, sizeof tmp);
	db res = ans[1];
	for(int i = 1; i <= n; ++i)
		if(deg[i] > 1.0){
			double mx = 0.0, sum = 0.0;
			for(int j = i + 1; j <= n; ++j)
				if(mp[i][j]) sum += ans[j], mx = max(mx, ans[j]);
			ans[i] = (sum - mx) / (deg[i] - 1) + 1;
			for(int j = i - 1; j; --j){
				ans[j] = 0.0;
				for(int k = j + 1; k <= n; ++k)
					if(mp[j][k]) ans[j] += ans[k];
				ans[j] /= deg[j]; ans[j] += 1.0;
			}
			res = min(res, ans[1]); memcpy(ans, tmp, sizeof ans);
		}
	printf("%.6lf", res);
	return 0;
}


Measured memory_bytes: 3456
"""
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m, ans = 10**9 + 7, 0
    for s in map(lambda x: x.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
"""
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans += s * (n - s) * pow(2, i, m) % m
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 53464
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        if i + 1 == a[a[i]-1]:
            cnt += 1
    print(cnt // 2)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 52908
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, M);
  VEC(int, A, N);
  double d = accumulate(all(A), 0) / (double)(4 * M);
  int c = 0;
  each(x, A) {
    if (x >= d) {
      c++;
      if (c == M) {
        print("Yes");
        return;
      }
    }
  }
  print("No");
}


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

int main()
{
	int n;
	while(scanf("%d",&n) != EOF) {
		int cnt=0;
		for(int a=0;a<10;++a) {
			if(n-a>27) continue;
			for(int b=0;b<10;++b) {
				if(n-a-b>18) continue;
				for(int c=0;c<10;++c) {
					if(n-a-b-c>9) continue;
					for(int d=0;d<10;++d) {
						if(n == (a+b+c+d)) {
							++cnt;
						}
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1024
S = input()
S = S.replace('BC', 'S')

ans = 0
T = []

def solve(S):
    f = -1
    res = 0
    for i, s in enumerate(S):
        if f != -1 and s == 'S':
            res += i - f
            f += 1
        elif f == -1 and s == 'A':
            f = i

    return res

for s in S:
    if s == 'B' or s == 'C':
        ans += solve(T)
        T = []
    else:
        T.append(s)

ans += solve(T)

print(ans)

Measured memory_bytes: 59948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int divNum = 0;
		for (int i = 0; i < N.length(); i++) {
			divNum += Integer.parseInt(N.substring(i, i+1));
		}
		if (Integer.parseInt(N) % divNum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 21972
from copy import deepcopy


def round_robin(l, q):
    work = deepcopy(l)
    res = []
    time = 0
    while len(work):
        if work[0][1] > q:
            work[0][1] -= q
            work.append(work.pop(0))
            l.append(l.pop(0))
            time += q
        else:
            time += work[0][1]
            work.pop(0)
            res.append(l.pop(0))
            res[-1][1] = time
    return res


if __name__ == '__main__':
    n, q = list(map(int, input().split()))
    d = [list(map(lambda x: int(x) if x.isnumeric() else x, input().split())) for _ in range(n)]
    res = round_robin(d, q)
    for i in res:
        print(i[0],i[1])



Measured memory_bytes: 25064
#include "stdio.h"

int r,c;
int i,j;
int matrix[100][100];
int gyosum[100]={};
int retsusum[100]={};
int migisita=0;;
int main(void){
	
		scanf(" %d %d",&r,&c);
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				scanf("%d",&matrix[j][i]);
			}
		}
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				gyosum[i]+=matrix[j][i];
			}
		}
		for(i=0;i<c;i++){
			for(j=0;j<r;j++){
				retsusum[i]+=matrix[i][j];
			}
		}
		for(i=0;i<r;i++) migisita+=gyosum[i];
		
		for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				printf("%d ",matrix[j][i]);
			}
			//1行おわり,行の合計書く
			printf("%d\n",gyosum[i]);
		}
		//列合計かく
		for(i=0;i<c;i++) printf("%d ",retsusum[i]);
		//右下
		printf("%d\n",migisita);
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
int main(void){
  int N,A[100],i,CHECK = 0;
  std::cin >> N;
  for(i = 0;i<N;i++){
    std::cin >> A[i];
    if(A[i]%2 == 0){
      if((A[i]%3 != 0) && (A[i]%5 != 0))
        CHECK = 1;
    }
  }
  if(CHECK == 1)
    printf("DENIED");
  else
    printf("APPROVED");
}


Measured memory_bytes: 256
<?php



fscanf(STDIN,"%d %d",$N,$T);
$input = explode(' ',trim(fgets(STDIN)));

for ($i=0; $i < $N; $i++) {
    $t[$i] = (int)$input[$i];   
}

sort($t);

for ($i=0; $i < $N - 1; $i++) {

    if ($t[$i+1] < $T + $t[$i]) {
        $sumExptN += $t[$i+1] - $t[$i];
    } else {
        $sumExptN += $T;
    }
}

echo ($sumExptN + $T).PHP_EOL;


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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    vector<ll> A(N,0);
    map<ll, ll> a;
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);

        if(!a.count(A.at(i))) {
            a[A.at(i)] = 0;
        }
        a.at(A.at(i))++;
    }
    ll ans = 1;
    ll c = 0;
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    for(ll i = 0; i < N; i++) {
        if(a.at(A.at(i))/2) {
            ans *= A.at(i);
            a.at(A.at(i)) -= 2;
            c++;
        }
        if(c == 2) {
            cout << ans << endl;
            return 0;
        }
    }

    cout << 0 << endl;


    return 0;
}

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

bool func(pair<int, int> a, pair<int, int> b)
{
  return a.second - a.first > b.second - b.first;
}

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n)
    cin >> s[i];
  vector<pair<int, int>> g1, g2;
  rep(i, n)
  {
    int disp = 0;
    int mini = 0;
    for (char j : s[i])
      if (j == '(')
        disp++;
      else
      {
        disp--;
        mini = min(mini, disp);
      }
    if (disp >= 0)
      g1.emplace_back(mini, disp);
    else
      g2.emplace_back(mini, disp);
  }
  sort(g1.begin(), g1.end(), greater<pair<int, int>>());
  sort(g2.begin(), g2.end(), func);
  int crt = 0;
  for (auto [m, d] : g1)
  {
    if (crt + m < 0)
    {
      cout << "No\n";
      return 0;
    }
    crt += d;
  }
  for (auto [m, d] : g2)
  {
    if (crt + m < 0)
    {
      cout << "No\n";
      return 0;
    }
    crt += d;
  }
  if (crt != 0)
  {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 42404
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int length(int p, int q){
    if(p>q){
        return p-q+1;
    }else{
        return q-p+1;
    }
}

int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    vector<int> r(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        sum += length(r[i], l[i]);
    }
    //cout << 100000 - sum << endl;
    cout << sum << endl;
    return 0;
}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i = 1; i < 10; i++){
        for(int j = 0; j < 10; j++){
            if(i*j == a){
                out("Yes");
                return 0;
            }
        }
    }
    out("No");
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int64_t mod=998244353;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin >> D.at(i);
  }
  if(D.at(0)!=0){
    cout << 0 << endl;
    return 0;
  }
  sort(D.begin(),D.end());
  if(D.at(1)!=1){
    cout << 0 << endl;
    return 0;
  }
  map<int,int64_t> m;
  for(int i=1;i<N;i++){
    if(m.count(D.at(i))){
      m.at(D.at(i))++;
    }else{
      m[D.at(i)]=1;
    }
  }
  int64_t count=1;
  int64_t ans=1;
  int64_t pref=0;
  for(auto p:m){
    if(p.first-pref!=1){
      cout << 0 << endl;
      return 0;
    }
    for(int i=1;i<=p.second;i++){
      ans*=count;
      ans%=mod;
    }
    count=p.second;
    pref=p.first;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = 2e5 + 10;

typedef long long ll;

map<ll, int> cnt;

ll sum, ans;

int n;

int main() {
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; ++ i) {
        ll x;
        scanf("%lld", &x);
        sum += x;
        if(sum == 0) ans ++;
        if(i > 1) {
            ans += cnt[sum];
        }
        cnt[sum] ++;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N, A;
  cin >> N >> A;
  vector<ll> X(N);
  for (ll i = 0; i < N; ++i) {
    cin >> X.at(i);
  }
  vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(2501, 0)));
  dp.at(0).at(0).at(0) = 1;
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j < N; ++j) {
      for (ll k = 0; k < 2501; ++k) {
        if (dp.at(i).at(j).at(k) == 0) {
          continue;
        }
        dp.at(i + 1).at(j).at(k) += dp.at(i).at(j).at(k);
        dp.at(i + 1).at(j + 1).at(k + X.at(i)) += dp.at(i).at(j).at(k);
      }
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; ++i) {
    ans += dp.at(N).at(i).at(i * A);
  }
  cout << ans << "\n";
}


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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long a[100005],sum,count,zero,min;
  char str[2000005],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atol(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    a[i]=atol(p);
  }
  
  for(i=0,count=0,zero=0;i<N;i++){
    if(a[i]<0){
      count++;
    }
    if(a[i]==0){
      zero++;
    }
  }
  for(i=0;i<N;i++){
      sum+=labs(a[i]);
    }
  
  if(zero!=0 || count%2==0){
    printf("%ld\n",sum);
    return 0;
  }
  
  if(count%2==1){
    for(i=0,min=labs(a[0]);i<N;i++){
      if(labs(a[i])<min){
        min=labs(a[i]);
      }
    }
    printf("%ld\n",sum-2*labs(min));
    return 0;
    
  }

  
}


Measured memory_bytes: 2944
import string

n = int(input())
alpha = string.ascii_lowercase

l = 0
ts = 0

while n > ts:
  l += 1
  ts += 26 ** l

for i in range(l):
  n -= 26 ** i

ans = ""
for i in range(l):
  ans += alpha[(n // (26 ** (l - 1 - i))) % 26]

print(ans)

Measured memory_bytes: 9988
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  string s1, s2;

  cin >> s;
  ans = INF;

  FOR(i,0,s.length()) {
	cnt = 0;
	s1 = s;
	s2 = s;
	while (1) {
	  if (s1 == string(s1.length(), s[i])) {
		break;
	  }
	  cnt++;

	  s2 = "";
	  FOR(j, 0, s1.length() - 1) {
		if (s1[j] == s[i] || s1[j + 1] == s[i]) {
		  s2 += s[i];
		}
		else {
		  s2 += s1[j];
		}
	  }
	  s1 = s2;
	}
	ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

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

int main(void){
    int a, b;
    cin >> a >> b;
    int sa=0,sb=0;
    rep(i,b){
        sa*=10;
        sa+=a;
    }
    rep(i,a){
        sb*=10;
        sb+=b;
    }
    if(sa<sb) cout << sb << endl;
    else cout << sa << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n,d;
    cin >> n >> d;
    int v[n][d];
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin >> v[i][j];
        
    int pw[1000];
    for(int i=0;i<1000;i++){
        pw[i] = i*i;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int dist = 0;
            for(int k=0;k<d;k++){
                dist+= (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            for(int k=0;k<1000;k++){
                if(dist==pw[k]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long long N,A,B;

  cin>>N>>A>>B;


  long long ans = (B - A) * (N - 2) + 1;
  if (ans > 0)
    cout << ans <<endl;
  else
    cout << 0 <<endl;

  return 0;
}



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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n;
	int k;
	cin >> n>>k;
	vector<string> p(n);
	REP(i, n)
		cin >> p[i];
	int a[26];
	REP(i, 26)
		a[i] = 0;
	REP(i, n) {
		a[p[i][0] - 'A']++;

	}
	priority_queue <int> q;
	REP(i, 26)
		q.push(a[i]);
	
	int cnt = 0;
	
	while (q.top() != 0) {
		stack<int> s;
		bool isok = true;
		for (int i = 0; i < k; i++) {
			int now = q.top();
			if (now == 0) {
				isok = false;
				break;
			}
			q.pop();
			now--;
			s.push(now);
		}
		if (!isok) {
			break;

		}
		cnt++;
		for (int i = 0; i < k; i++) {
			q.push(s.top());
			s.pop();
		}

	}
	cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	while (1) {
		c = c - b;
		if (c <= 0) {
			printf("Yes\n");
			return 0;
		}
		a = a - d;
		if (a <= 0) {
			printf("No\n");
			return 0;
		}
	}
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector <int > v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int max = -1, ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] >= max) {
			ans++;
			max = v[i];
		}
	}
	cout << ans;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;
  int ans = 0;
  for(int i=sz(S)-1;i>=1;i--){
    string str=S.substr(0,i);
    if(sz(str)%2==0&&str.substr(0,sz(str)/2-1)==str.substr(sz(str)/2,sz(str)/2-1)){
      ans=i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3580