akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r[4005], g[4005], b[4005];
    r[0] = g[0] = b[0] = 0;
    for(int i = 1; i <= n; i++){
        r[i] = r[i - 1];
        g[i] = g[i - 1];
        b[i] = b[i - 1];
        if(s[i - 1] == 'R') r[i]++;
        if(s[i - 1] == 'G') g[i]++;
        if(s[i - 1] == 'B') b[i]++;
    }
    ll ans = 0;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'R'){
            ans += g[i] * b[i];
            for(int j = 1; i - j * 2 >= 0; j++){
                if(s[i - j] != 'R' && s[i - j * 2] != 'R' && s[i - j] != s[i - j * 2]) ans--;
            }
        }
        if(s[i] == 'G'){
            ans += r[i] * b[i];
            for(int j = 1; i - j * 2 >= 0; j++){
                if(s[i - j] != 'G' && s[i - j * 2] != 'G' && s[i - j] != s[i - j * 2]) ans--;
            }
        }
        if(s[i] == 'B'){
            ans += g[i] * r[i];
            for(int j = 1; i - j * 2 >= 0; j++){
                if(s[i - j] != 'B' && s[i - j * 2] != 'B' && s[i - j] != s[i - j * 2]) ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
  int N;
  int sum = 0;

  cin >> N;
  int A[N];
  int B[N];
  int C[N];

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N-1; i++) {
    cin >> C[i];
  }

  for (int i = 0; i < N; i++) {
    sum += B[A[i]-1];
    if (i > 0 && ((A[i] - 1) == A[i - 1])) {
      sum += C[A[i-1]-1];
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, d;

void read() {
  cin >> n >> d;
}

void solve() {
  d *= 2;
  ++d;
  int sol = n / d;
  if (n % d != 0)
    ++sol;
  cout << sol;
}


int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  read();
  solve();
  return 0;
}


Measured memory_bytes: 384
N = int(input())
FizzBuzz = []
Fizz = []
Buzz = []
ano = []
plus = 0
for i in range(N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBuzz.append(i)
    elif i % 3 == 0:
        Fizz.append(i)
    elif i % 5 == 0:
        Buzz.append(i)
    else:
        ano.append(i)
for a in ano:
    plus += a

print(plus)

Measured memory_bytes: 48672
S = input()[::-1]
T = ['maerd' ,'remaerd' ,'esare' ,'resare']
i, j = 0, 0
while True:
    if i == 4:
        break
    if T[i] == S[j:j+len(T[i])]:
        j += len(T[i])
        i = 0
    else:
        i += 1
print("YES" if len(S)==j else "NO")

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] ary = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1 };
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (search(ary, a) == search(ary, b)) {
			System.out.println("Draw");
		} else if (search(ary, a) > search(ary, b)) {
			System.out.println("Alice");
		} else {
			System.out.println("Bob");
		}

	}

	public static int search(int[] ary, int s) {
		int ret = -1;
		for (int i = 0; i < ary.length; i++) {
			if (ary[i] == s) {
				ret = i;
				break;
			}
		}
		return ret;
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main(){
    int n,m;
    cin>>n>>m;
    if(n>=10){cout<<m<<endl;}
    else cout<<m+(100*(10-n))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
ll const MAX = 100005;
ll a[MAX];
ll b[MAX];
ll c[MAX] = {};
int main() {
	ll n; cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	SORT(a, n);
	if (n % 2 == 0) {
		REP(i, 1, n) {
			if (i % 2 == 1) {
				b[i] = a[n / 2 + i / 2+1];
			}
			else {
				b[i] = a[i / 2];
			}
		}
	}
	else {
		REP(i, 1, n) {
			if (i % 2 == 1) {
				b[i] = a[n / 2 + 1 - i / 2];
			}
			else {
				b[i] = a[n + 1 - i / 2];
			}
		}
		swap(b[3], b[n]);
	}
	ll ans = 0;
	REP(i, 1, n-1) {
		ans += abs(b[i + 1] - b[i]);
	}
	if (n % 2 == 1) {
		for (ll i = 2; i <= n; i += 2) {
			swap(b[i], b[i + 1]);
		}
	}
	ll ans2 = 0;
	REP(i, 1, n - 1) {
		ans2 += abs(b[i + 1] - b[i]);
	}

	cout << max(ans,ans2) << endl;
}



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

int main(void){
    int n,m;
    double a[10000],b=0.0;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++){
        scanf("%lf",&a[i]);
        b += a[i];
    }
    for (int j=1;j<=n-1;j++){
        for (int k=j+1;k<=n;k++){
            if (a[j] < a[k]){
                int tmp = a[j];
                a[j] = a[k];
                a[k] = tmp;
            }
        }
    }
    if (a[m] >= b/(4*m)){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx, dy;
    dx = tx - sx;
    dy = ty - sy;
    rep(i,dy) cout << "U";
    rep(i,dx) cout << "R";
    rep(i,dy) cout << "D";
    rep(i,dx+1) cout << "L";
    rep(i,dy+1) cout << "U";
    rep(i,dx+1) cout << "R";
    cout << "DR";
    rep(i,dy+1) cout << "D";
    rep(i,dx+1) cout << "L";
    cout << "U" << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	int n,m; cin>>n>>m;
	int a[100]={0}, b[100]={0}, c[100]={0}, d[100]={0};
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	for(int i=0;i<m;i++) cin>>c[i]>>d[i];

	for(int i=0;i<n;i++){
		ll val = INF;
		int k;
		for(int j=0;j<m;j++){
			ll tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if(tmp < val){
				val = tmp;
				k = j + 1;
			}
			//cout<<"val:"<<val;
		}
		//cout<<endl;

		printf("%lld\n", k);
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=3e5+5,P=1e9+7;

int n;
char s[N];

int Q[N][2];
vector<int> S={0,1,2,4,3,5,6,7};//7

int f[N][8];

int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    Q[0][1]=2;
    Q[0][0]=1;
    Q[2][1]=3;
    Q[2][0]=4;
    Q[1][1]=5;
    Q[1][0]=6;
    Q[6][1]=1;
    Q[6][0]=1;
    Q[5][1]=2;
    Q[5][0]=1;
    Q[4][1]=2;
    Q[4][0]=7;
    Q[3][1]=3;
    Q[3][0]=3;
    Q[7][1]=4;
    Q[7][0]=4;

    f[0][0]=1;
    FOR(i,0,n){
        if(s[i+1]!='1'){
            for(int x:S){
                (f[i+1][Q[x][0]]+=f[i][x])%=P;
            }
        }
        if(s[i+1]!='0'){
            for(int x:S){
                (f[i+1][Q[x][1]]+=f[i][x])%=P;
            }
        }
    }
    printf("%d\n",(f[n][2]+f[n][3])%P);
    return 0;
}


Measured memory_bytes: 10752
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=105;
int n,m,f[N][N];
char s[N][N];

signed main(){
	read(n,m);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		if(i==1&&j==1) {f[i][j]=s[i][j]=='#';continue;}
		f[i][j]=1e9;
		if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(s[i][j]=='#'&&s[i-1][j]=='.'));
		if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j]=='#'&&s[i][j-1]=='.'));
	}
//	for(int i=1;i<=n;i++,puts("")) for(int j=1;j<=m;j++) write(f[i][j]),putchar(' ');return 0;
	write(f[n][m]);
}

Measured memory_bytes: 3796
#include <iostream>
 
int n;
int e[102];
 
size_t num(int m) {
	size_t out = 0;
	for (int i = 0; i < n; ++i)
		if (e[i] >= m - 1)
			++out;
	return out;
}
 
int main() {
	std::cin >> n;
	for (int i = 2; i < n + 1; ++i) {
		int cur = i;
		for (int j = 2; j < i + 1; ++j)
			while (cur%j == 0) {
				e[j] += 1;
				cur /= j;
			}
	}
 
	std::cout << num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
		+ num(5) * (num(5) - 1) * (num(3) - 2) / 2 << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split(' '))


if x >= a**2 * b / 2:
    t = 2*x/a**2 - b
    print(180 * math.atan2(b-t,a) / math.pi)
else:
    t = 2*x / (a*b)
    print(180 * math.atan2(b,t) / math.pi)


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	string S, T; cin >> S >> T;

	int ans = 10000;

	for (int i = 0; i < (int)S.size() - (int)T.size()+1; i++) {
		int cnt = 0;
		for (int j = 0; j < (int)T.size(); j++) {
			if (T[j] != S[i + j])cnt++;
		}
		ans = min(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int N;
vector<P> ball;
int b[2100];   //それぞれの番号が何番目にあるか
int w[2100];
int w_offset[2100][2100];
int b_offset[2100][2100];
int dp[2100][2100];

int main(){
    cin >> N;
    for(int i = 0; i < 2*N; i++){
        char c; cin >> c;
        int a;  cin >> a;
        if(c == 'W'){
            w[a] = i+1;
            ball.emplace_back(P(0, a));
        }
        else{
            b[a] = i+1;
            ball.emplace_back(P(1, a));
        }
    }
    for(int i = 0; i <= N; i++){
        fill(w_offset[i], w_offset[i]+N+10, 0);
        fill(b_offset[i], b_offset[i]+N+10, 0);
        fill(dp[i], dp[i]+N+10, 0);
    }

    for(int i = 1; i <= N; i++) {
        int w_plus = 0;
        int b_plus = 0;
        for (int j = i - 1; j > 0; j--) {
            if (w[i] < w[j]) {
                w_plus++;
            }
            if (b[i] < b[j]) {
                b_plus++;
            }
        }
        w_offset[0][i] = w_plus;
        b_offset[0][i] = b_plus;
    }

    // bがiだけ進んだ時にwがどれくらいずれるか
    for(int i = 1; i <= N; i++){
        int b_pos = b[i];
        for(int j = 1; j <= N; j++){
            if(b_pos > w[j]){
                w_offset[i][j] = w_offset[i-1][j] + 1;
            }
            else{
                w_offset[i][j] = w_offset[i-1][j];
            }
        }
    }
    // wがiだけ進んだ時にbがどれくらいずれるか
    for(int i = 1; i <= N; i++){
        int w_pos = w[i];
        for(int j = 1; j <= N; j++){
            if(w_pos > b[j]){
                b_offset[i][j] = b_offset[i-1][j] + 1;
            }
            else{
                b_offset[i][j] = b_offset[i-1][j];
            }
        }
    }

    for(int w_i = 1; w_i <= N; w_i++){
        int move = w[w_i] + w_offset[0][w_i] - w_i;
        // cout << w_i << " " << w_offset[0][w_i] << " " << move << endl;
        dp[w_i][0] = dp[w_i-1][0] + move;
    }
    for(int b_i = 1; b_i <= N; b_i++){
        int move = b[b_i] + b_offset[0][b_i] - b_i;
        // cout << b_i << " " << w_offset[0][b_i] << " " << move << endl;
        dp[0][b_i] = dp[0][b_i-1] + move;
    }
    for(int b_i = 1; b_i <= N; b_i++){
        for(int w_i = 1; w_i <= N; w_i++){
            //w_i+b_i番目に置く。
            int w_move = w[w_i] + w_offset[b_i][w_i] - (w_i+b_i);  //wを置くとき。
            int b_move = b[b_i] + b_offset[w_i][b_i] - (w_i+b_i);  //bを置くとき。
            dp[w_i][b_i] = min(dp[w_i-1][b_i] + w_move, dp[w_i][b_i-1] + b_move);
            // cout << dp[w_i][b_i] << " ";
        }
        // cout << endl;
    }

    cout << dp[N][N] << endl;


    return 0;

}



Measured memory_bytes: 51584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision
using namespace std;

int main()
{
  string S, T, sub;
  cin >> S >> T;
  int best = T.length(), cnt;
  for(int i = 0; i <= S.length() - T.length(); i++) {
    sub = S.substr(i, T.length());
    cnt = 0;
    for(int j = 0; j < T.length(); j++) {
      if(sub[j] != T[j]) {
        cnt++;
      }
    }
    best = min(best, cnt);

  }
  cout << best << endl;
}


Measured memory_bytes: 3184
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	string s,t;
	cin>>s>>t;
	bool flag=true;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
			flag=false;
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,B,N,M,K,X,Y,Z,C;
  string S,T,U;
  cin >> A >> B >> C;

    if(((A == B)&&(A != C))||
       ((A == C)&&(A != B))||
       ((B == C)&&(A != B))){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A, B, C = read_ints()
if A < C < B or B < C < A:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			int min = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			int cp = 1;
			for (int j = 1; j < M; j++) {
				int num = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(num < min) {
					cp = j + 1;
					min = num;
				}
			}
			System.out.println(cp);
		}
	}
}

Measured memory_bytes: 23252
import math
from collections import defaultdict

def check(x,y,z):
  return int(x*(x+y)+y*(y+z)+z*(z+x))

N = int(input())
# for n in range(1,N+1):
r = int(math.sqrt(N))+1
s = defaultdict(lambda:0)
for x in range(1,r):
  for y in range(1,r):
    for z in range(1,r):
      s[check(x,y,z)] += 1
for i in range(1,N+1):
  print(s[i])

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

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

#define loop1(i,n) for(int i=1; i<=n; i++)

#define ll long long

#define ld long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define pld pair<ld,ld>

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;



int main()
{
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i,n)
	{
		string s;
		cin >> s;
		mp[s] ++;
	}
	vector<pair<int,string>> v;
	for(auto i = mp.begin();i!=mp.end();++i)
	{
		v.push_back(make_pair(i->second,i->first));
	}
	sort(ALL(v));
	for(int i = v.size()-1;i>0;i--)
	{
		if(v[i-1].first<v[i].first)
		{
			for(int j=i;j<v.size();j++)
			{
				cout<<v[j].second<<endl;
			}
			return 0;
		}
	}
	rep(i,v.size())
	{
		cout<<v[i].second<<endl;
	}
   return 0;
}

Measured memory_bytes: 29296
#写経
#16133681

import sys
input = lambda: sys.stdin.readline().rstrip()
h,w=map(int,input().split())
ch,cw=map(int,input().split())
ch-=1
cw-=1
stack=[(ch,cw)]
dh,dw=map(int,input().split())
dh-=1
dw-=1
b=[w*[-1]for _ in range(h)]
for i in range(h):
  for j,t in enumerate(input()):
    if t=="#":b[i][j]=10**10
b[ch][cw]=0
dxy=((-1,0),(1,0),(0,-1),(0,1))
for ans in range(10**6):
  for x,y in stack:
    b[x][y]=1
    if x==dh and y==dw:
      print(ans)
      exit()
    for dx,dy in dxy:
      if 0<=x+dx<h and 0<=y+dy<w:
        if b[x+dx][y+dy]==10**10:continue
        if b[x+dx][y+dy]==-1:
          stack.append((x+dx,y+dy))
          b[x+dx][y+dy]=1
  stackk=[]
  for x,y in stack:
    for xx in range(max(0,x-2),min(h,x+3)):
      for yy in range(max(0,y-2),min(w,y+3)):
        if b[xx][yy]==-1:stackk.append((xx,yy))
  stack=stackk
print(-1)

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

const int N = 3005;

int n, mod;
int pw1[N * N], pw2[N * N], C[N][N];
int stirling[N][N];
int res[N];

void add(int &x, int y) {
	x += y; while(x >= mod) x -= mod; while(x < 0) x += mod;
}

int binpow(int a, int b) {
	int ret = 1;
	while(b) {
		if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ret;
}

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

	cin >> n >> mod;

	// prepare
	pw1[0] = pw2[0] = 1;
	for (int i = 1; i < N * N; ++i) {
		pw1[i] = 2LL * pw1[i - 1] % mod;
		pw2[i] = 2LL * pw2[i - 1] % (mod - 1);
	}
	for (int i = 0; i < N; ++i) C[i][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1; j <= i; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	}

	stirling[0][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			stirling[i][j] = (1LL * (j + 1) * stirling[i - 1][j] + (j > 0 ? stirling[i - 1][j - 1] : 0)) % mod;
		}
	}

	// solve
	for (int k = 0; k <= n; ++k) {
		for (int i = 0; i <= k; ++i) {
			add(res[k], 1LL * stirling[k][i] * pw1[(n - k) * i] % mod);
		}
		res[k] = 1LL * res[k] * binpow(2, pw2[n - k]) % mod;
	}

	// inclusive-exclusive
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int cur = 1LL * res[i] * C[n][i] % mod;
		if (i % 2 == 0) add(ans, cur);
		else add(ans, -cur);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 141312
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int x = sc.nextInt();
	    	if (x == 3 || x == 5 || x == 7) {
	    		System.out.println("YES");
	    	} else {
	    		System.out.println("NO");
	    	}
	}
}


Measured memory_bytes: 23252
n, m = map(int, input().split())

C = list(map(int, input().split()))

# nまで
dp = [float('inf')] * (n + 1)
dp[0] = 0
for i in range(m):
    for j in range(n + 1):
        if j >= C[i]:
            dp[j] = min(dp[j - C[i]] + 1, dp[j])

print(dp[n])



Measured memory_bytes: 7524
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let r = get!(usize);
    println!("{}", 3*r*r);
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int sum = 0;
    rep(i,n) {
        int h;
        cin >> h;
        if (h >= k) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>
#include <atcoder/all>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

using mint = atcoder::modint998244353;

struct S{
    mint value;
    int size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b){ return {a.value + mint(10).pow(a.size) * b.value, a.size+b.size}; }
S e(){ return {mint(0), 0}; }
S mapping(F f, S x){
    if(f != ID) {
        x.value = (mint(10).pow(x.size) - 1)*mint(9).inv()*mint(f);
    }
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

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

    ll N, Q;
    cin >> N >> Q;
    vector<S> v(N, {mint(1), 1});
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    while (Q--) {
        ll L, R, D;
        cin >> L >> R >> D;
        ll l = N - R;
        ll r = N - L + 1;
        seg.apply(l, r, D);
        // Rep (i, N) {
        //     cout << seg.get(i).value << " \n"[i==N-1];
        // }
        // Rep (i, N) {
        //     cout << seg.get(i).d << " \n"[i==N-1];
        // }
        cout << seg.all_prod().value.val() << "\n";
    }
}

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

int main(){
  long int x;
  cin >> x;
  long int i;
  double deposit = 100.0;
  for(i=1;i<=1000000000000;i++){
    deposit = floor(deposit*1.01);
    if(deposit >= x){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X), D = abs(D);
  ll N = X / D;
  ll ans{};
  if (N >= K) {
    ans = X - K * D;
  } else {
    K = (K - N) % 2;
    if (K) {
      ans = N * D - X + D;
    } else {
      ans = X - N * D;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{

	int n;
	int k;
	int num = 1;
	cin >> n;
	cin >> k;
	for (int i = 0; i < n; ++i) {
		if (num + k > num * 2) {
			num = num * 2;
		}
		else {

			num = num + k;
		}
	}


	cout << num << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10,M=1e5+10,oo=1e9;
int n,m,tree[M];
struct Node{
	int l,r,len;
	bool operator<(Node k)const{return len<k.len;}
}p[N];
void upd(int x,int d){
	while(x<=m){
		tree[x]+=d;
		x+=x&(-x);
	}
	return;
}
int que(int x){
	int temp=0;
	while(x>0){
		temp+=tree[x];
		x-=x&(-x);
	}
	return temp;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i].l,&p[i].r),p[i].len=p[i].r-p[i].l+1;
	sort(p+1,p+n+1);
	p[n+1].len=oo;
	int point=1,temp=0;
	for(int i=1;i<=m;i++){
		while(p[point].len<i){
			upd(p[point].l,1);
			upd(p[point].r+1,-1);
			point++;
		}
		temp=0;
		for(int j=i;j<=m;j+=i) temp+=que(j);
		printf("%d\n",temp+n-point+1);
	}
	return 0;
}

Measured memory_bytes: 4864
from collections import deque
deck=deque()

n, m=map(int, input().split())
tsuuro_list=[[] for i in range(n)]
saiteki=[-1 for i in range(n)]
saiteki[0]=0
for i in range(m):
    a, b=map(int, input().split())
    tsuuro_list[a-1].append(b-1)
    tsuuro_list[b-1].append(a-1)


not_visited=[1 for i in range(n)]
not_visited[0]=0

deck.append(0)
while len(deck)!=0:
    target=deck.popleft()
    tsuuro=tsuuro_list[target]
    for node in tsuuro:
        if not_visited[node]:
            not_visited[node]=0
            deck.append(node)
            saiteki[node]=target

if sum(not_visited)!=0:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(saiteki[i]+1)


Measured memory_bytes: 95352
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 4e5 + 5, M = 2 * N + 5;

int n, m, a[N];
vector<int> adj[N];

int main(){
    scanf("%d %d", &n, &m);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    while(m--){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[--u].emplace_back(--v);
        adj[v].emplace_back(u);
    }
    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        bool ok = true;
        for(auto v : adj[i])
            if(a[v] >= a[i])ok = false;
        ans += ok;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 16348
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
BT = [[bc[i] for bc in B] for i in range(l)]

for i in range(n):
    for j in range(l):
        print(sum([a * b for a, b in zip(A[i], BT[j])]), end='')
        if not j == l - 1:
            print(' ', end='')
    print()



Measured memory_bytes: 6648
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << (s < t ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i <= N; i += 4) {
    if ((N - i) % 7 == 0) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int X,Y,Z;
	scanf("%d %d %d",&X,&Y,&Z);

	printf("%d %d %d\n",Z,X,Y);

	return 0;
}


Measured memory_bytes: 256
if True:
    n = int(input())
else:
    n = 100000;
    # n=15
# print(n)

count =0
list_old = [1,2,3,4,5,6,7,8,9]
count = len(list_old)
if count >= n:
    print(list_old[n-1])
    exit()

while(count < n):
    list_new = []
    keta = len(str(list_old[0]))
    # print("keta")
    # print(keta)
    for num in list_old:
        str_num = str(num)
        last_num = int(str_num[len(str_num) - 1]);
        # print("==========")
        # print(str_num)
        # print(last_num)
        if last_num == 0:
            list_new.append(num*10 + last_num)
            list_new.append(num*10 + 1)
        elif last_num == 9:
            list_new.append(num*10 + 8)
            list_new.append(num*10 + last_num)
        else:
            list_new.append(num*10 + last_num-1)
            list_new.append(num*10 + last_num)
            list_new.append(num*10 + last_num+1)
    # print(count)
    # print(list_new)
    if count + len(list_new) < n:
        list_old = list_new
        count += len(list_old)
    else:
        print(list_new[n-count-1])
        break
        # list_old = list_new
        # count += len(list_old)

# print("====")
# print(list_new)
# print(list_old)
# print(count)
# print(count-1-n)
# print(list_old[count-1-n]);

Measured memory_bytes: 10760
import itertools
mod=10**9+7

def inverse(r,inv):
    return -(mod//i)*inv[mod%i]%mod
        

N=int(input())
A=list(map(int,input().split()))

fact=[1,1]
inv=[0,1]
for i in range(2,N+1):
    fact.append(fact[i-1]*i%mod)
    inv.append(inverse(i,inv)%mod)
ifact = list(itertools.accumulate(inv))

ans=0
for j in range(1,N+1):
    ans+=(ifact[j]+ifact[N-j+1]-1)*A[j-1]*fact[N]%mod
    ans%=mod
    
ans%=mod
print(ans)

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

using namespace std;

#define MAX_N 8
#define MAX_M 30
#define INF (1<<29)

int N,M,a,b,t[MAX_N];
int d[MAX_M][MAX_M];
double dp[1<<MAX_N][MAX_M];

void solve(){
  for(int i = 0 ; i < 1<<N ; i++){
    fill(dp[i],dp[i]+M,INF);
  }
  dp[(1<<N)-1][a-1] = 0;
  double res = INF;
  for(int S = (1<<N)-1 ; S >= 0 ; S--){
    res = min(res,dp[S][b-1]);
    for(int v = 0 ; v < M ; v++){
      for(int i = 0 ; i < N ; i++){
	if(S >> i & 1){
	  for(int u = 0 ; u < M ; u++){
	    if(d[v][u] >= 0){
	      dp[S & ~(1<<i)][u] = min(dp[S & ~(1<<i)][u],dp[S][v]+(double)d[v][u]/t[i]);
	    }
	  }
	}
      }
    }
  }
  if(res == INF){
    puts("Impossible");
  }else{
    printf("%.3f\n",res);
  }
}

int main(){
  int p;
  while(true){
    scanf("%d%d%d%d%d",&N,&M,&p,&a,&b);
    if(!N && !M && !p && !a && !b) break;
    memset(d,-1,sizeof(d));
    for(int i = 0 ; i < N ; i++){
      scanf("%d",&t[i]);
    }
    for(int i = 0 ; i < p ; i++){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      d[x-1][y-1] = d[y-1][x-1] = z;
    }
    solve();
  }

  return 0;
}

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

using namespace std;
using ll=long long;
double mod = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}


int main() {
    ll N = 0, M = 0, al_num = 1000, tmp = 0;
    string answer = "";
    char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                         's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    int num = 26;
    int al[26];
    string s, S[60];
    cin >> N;
    REP(i, N)cin >> S[i];
    REP(i, num) {
        REP(j, N) {
            tmp = count(S[j].cbegin(), S[j].cend(), alphabet[i]);
            if (al_num > tmp)al_num = tmp;
        }
        al[i] = al_num;
        al_num = 1000;
    }
    REP(i, num) {
        int n = al[i];
        REP(j, n) {
            answer += alphabet[i];
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
import io,sys
sys.setrecursionlimit(10**6)


def main():
    X,Y = map(int,sys.stdin.readline().rstrip().split())

    y = (Y-2*X)/2
    x = X-y

    if y>=0 and y == int(y) and x >= 0:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 
                89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,
                181, 191, 193, 197, 199};
long long calc(int x) {
  int zohe[46] = {};
  long long ans = 1;
  
  int i = 0, n = x;
  
  while (primes[i] * primes[i] <= x) {
    if (n % primes[i] == 0) {
      n /= primes[i];
      zohe[i]++;
    }
    else {
      i++;
    }
  }
  
  for (int i = 0; i < 46; i++) {
    ans *= (zohe[i] + 1);
  }
  return ans;
}

int main(void) {
  int n, ans = 0;
  cin >> n;
  
  for (int i = 1; i <= n; i += 2) {
    long long temp = calc(i);
    if (temp == 8) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


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

int n;
ll b[100001];

ll find(int s) {
	ll res = 0;
	for (int i = s; i > 0; i = i & (i - 1))
		res = max(res, b[i]);
	return res;
}

void update(int s, ll val) {
	for (int i = s; i <= n; i += (i & -i))
		b[i] = max(b[i], val);
}

int main()
{
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 0, x; i < n; i++) {
		scanf("%d", &x);
		sum += x;
		update(x, find(x - 1) + x);
	}
	printf("%lld\n", sum - find(n));
	return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
int main(){
long long int a,b,mdc,i,ans=0;
cin>>a>>b;
mdc=__gcd(a,b);
if(mdc%2==0){ ans++;
while(mdc%2==0){
  mdc/=2; }
}
//cout << mdc<<" "<<ans<<endl;
for(i=3;i<=sqrt(mdc);i=i+2){
  if(mdc%i==0){
    ans++;//cout << i<<endl;
    while(mdc%i==0){   mdc/=i;   }
  }
}
if(mdc>2){
  ans++;
}
cout <<ans+1<<endl;
















}


Measured memory_bytes: 256
N = int(input())
S = input()

sum = S.count("R")*S.count("G")*S.count("B")

for i in range(N):
   for j in range(i+1,N-1):
      k = 2*j-i
      if(k<N):
         if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            sum-=1
print(sum)




Measured memory_bytes: 9116
N = int(input())
d = {}
S = []
for i in range(N):
    s,t = map(str,input().split())
    d[s] = i
    r = int(t)
    S.append(r)
X = input()
x = d[X]
ans = 0
for i in range(x+1):
    ans += S[i]
ans = sum(S) - ans
print(ans)

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

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

  if(n>=30)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';


  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

ll pattern(ll x){
  if(x == 1 || x == 2){
    return 1;
  }else{
    ll b,bb,nex;
    bb = 1;
    b = 1;
    for(ll i=3;i<=x;i++){
      nex = bb+b;
      if(nex>=1000000007){
        nex = nex%1000000007;
      }
      bb = b;
      b = nex; 
    }
    return b;
  }
}
int main() {
  ll N,M,check,ans;
  vl a;
  cin >> N>> M;
  REP(i,M){
		int x;
		cin >> x;
		a.push_back(x);
	}
  if(M==0){
    cout << pattern(N+1)<<endl;
  }else{
    if(M==0){
      cout <<ans<<endl;
    }else{
      check =0;
      REP(i,M-1){
        if(a[i+1]==a[i]+1){
          check = 1;
        }
      }
      if(check == 1){
        cout << 0<< endl;
      }else{
        ans = pattern(a[0]);
        a.push_back(N+1);
        REP(i,M){
          ans = ans*pattern(a[i+1]-a[i]-1);
          if(ans>=1000000007){
            ans = ans%1000000007;
          }
        }
        cout << ans<< endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

main()
{
	int a,b;
	scanf("%d %d", &a, &b);
	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
const double pi=acos(-1);
 
int main(){
    long double a,b,x;
    cin>>a>>b>>x;
    
    if(x/a>a*b/2){
        cout<<setprecision(10)<<atan(-2*(x-a*a*b)/pow(a,3))*180/pi<<endl;
    }else{
        cout<<setprecision(10)<<atan(a*b*b/(2*x))*180/pi<<endl;
    }
}

Measured memory_bytes: 640
from sys import exit, setrecursionlimit
setrecursionlimit(10**6)

def array2D(row, col ,val=0):
    return [[val]*col for i in range(row)]

a,b,c = map(int, input().split())
a,b = b,a
a,c = c,a
print(a,b,c)

Measured memory_bytes: 2940
s=input()
t=input()
x=len(s)
y=len(t)
ans=1050
for i in range(x-y+1):
    a=s[i:i+y]
    cnt=0
    for j in range(y):
        if a[j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 67612
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
using namespace std;
int main()
{
    ll i,j,k,n,t,a;
    string b;
    cin>>a>>b;
    k=0;
    for(i=0;i<b.length();i++)
    {
        if(b[i]!='.')
        {
            k=k*10+b[i]-'0';
        }
    }
    j=(a*k)/100;
    cout<<j<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;
const ll MOD=1e9+7;

struct UnionFind {
    vector<int> par,rank;
    vector<ll> cnt;
    UnionFind(int n):par(n),rank(n,0),cnt(n,1){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]){
            par[rx]=ry;
            cnt[ry]+=cnt[rx];
        }else{
            par[ry]=rx;
            cnt[rx]+=cnt[ry];
        }
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int count(int x){
        return cnt[root(x)];
    }
};
struct edge{
    int a,b,y;
    edge(){};
    edge(int a,int b,int y):a(a),b(b),y(y){};
    bool operator<(const edge& rhs){
        return y<rhs.y;
    }
};
int main(){
    int X,Y,Z,K;cin>>X>>Y>>Z>>K;
    vector<ll> A(X),B(Y),C(Z);
    for(int i=0;i<X;++i) cin>>A[i];
    for(int i=0;i<Y;++i) cin>>B[i];
    for(int i=0;i<Z;++i) cin>>C[i];
    sort(A.begin(),A.end(),greater<ll>());
    sort(B.begin(),B.end(),greater<ll>());
    sort(C.begin(),C.end(),greater<ll>());
    vector<ll> tmp,ans;
    for(int i=0;i<X;++i){
        for(int j=0;j<Y;++j){
            tmp.push_back(A[i]+B[j]);
        }
    }
    sort(tmp.begin(),tmp.end(),greater<ll>());
    for(int i=0;i<min(K,X*Y);++i){
        for(int j=0;j<Z;++j){
            ans.push_back(tmp[i]+C[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    for(int i=0;i<K;++i){
        cout<<ans[i]<<endl;
    }
    return 0;
}



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

#define N_MAX 100002
#define B_MAX 18

using namespace std;

int n, step, k;

int x[N_MAX];

int dp[N_MAX][B_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> x[i];
    cin >> step >> k;
    for(int i = 1; i < n; i++)
    {
        int l = i, r = n;
        while(l < r)
        {
            int mid = (l + r + 1) / 2;
            if(x[mid] - x[i] > step)
                r = mid - 1;
            else
                l = mid;
        }
        dp[i][0] = l;
    }
    dp[n][0] = n + 1;
    for(int bit = 1; bit <= 16; bit++)
    {
        for(int i = 1; i < n; i++)
        {
            if(dp[i][bit - 1] == n + 1)
                dp[i][bit] = n + 1;
            else
                dp[i][bit] = dp[dp[i][bit - 1]][bit - 1];
        }
        dp[n][bit] = n + 1;
    }
    while(k--)
    {
        int a, b;
        cin >> a >> b;
        if(a > b)
            swap(a, b);
        int ans = 0;
        for(int bit = 16; bit >= 0 && a < b; bit--)
            if(dp[a][bit] <= b)
            {
                ans += (1 << bit);
                a = dp[a][bit];
            }
        if(a < b)
            ans++;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 8320
s = input()

small_mode = s[0] == '<'
initial_small_mode = small_mode
idx = 0
nums = []
while idx < len(s):
    if small_mode:
        num = 0
        while idx < len(s) and s[idx] == '<':
            num += 1
            idx += 1
        nums.append(num)
        if idx >= len(s):
            break
        else:
            small_mode = not small_mode
    elif not small_mode:
        num = 0
        while idx < len(s) and s[idx] == '>':
            num += 1
            idx += 1
        nums.append(num)
        if idx >= len(s):
            break
        else:
            small_mode = not small_mode

seq = []


if initial_small_mode:
    seq.append(0)
else:
    seq.append(nums[0])

for idx, run in enumerate(nums):
    if initial_small_mode:
        for i in range(1, run + 1):

            if i == run and idx < len(nums) -1 and nums[idx + 1] > run:
                seq.append(nums[idx + 1])
            else:
                seq.append(i)
    else:
        for i in range(run - 1, -1, -1):
            seq.append(i)
    initial_small_mode = not initial_small_mode

# print(nums)
# print(sum(nums))
# print(seq)
# print(len(seq))
print(sum(seq))

# 0<@3>2>1>@0<1<@2>0<1<2<3<4<5>2>1>0<1

Measured memory_bytes: 79304
#include <stdio.h>

typedef struct {
	double x, y;
} Coord;

double area_poly( Coord *coord, int n ) {
	int i;
	double sum = 0.0;

	for ( i = 1; i <= n; i++ )
		sum += coord[ i - 1 ].x * coord[ i % n ].y - coord[ i - 1 ].y * coord[ i % n ].x;

	return -sum / 2.0;
}

int main( void ) {
	int i;
	int n, cnt;
	Coord coord[ 100 ];

	cnt = 0;
	while ( scanf( "%d", &n ), n ) {
		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf", &coord[ i ].x, &coord[ i ].y );

		printf( "%d %.1f\n", ++cnt, area_poly( coord, n ) );
	}

	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ul;
const int MOD = 1000000007;
const ll INF = 1e18;
using namespace std;
int i,j,k;
int N;
int x[100];
int y[100];
int h[100];
int t;
int H;
int X,Y;
bool flag;
inline void solve(){
  INPUT(N);
  REP(i,N){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0){
      t=i;
    }
  }
  REP(X,101)REP(Y,101){
    H=h[t]+abs(x[t]-X)+abs(y[t]-Y);
    flag=true;
    REP(i,N){
      if(i==t)continue;
      if(h[i]!=max(H-abs(x[i]-X)-abs(y[i]-Y),0)){
        flag=false;
        break;
      }
    }
    if(flag){
      OUTPUT3(X,Y,H);
      return;
    }
  }
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;
int main(void){

  long N;
  cin >> N;

  double n = sqrt(N);

  //long nup = n;
  long ans = 0;
  long k = N;
  long i = 1;

  while(k > n && i < N){
    k = (N - i) / i;
    if((N - i) % i == 0 && k > n){
      ans += k;
    }
      i++;
}

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256