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

int main()
{
    ll i,j,n;

    cin >> n;

    string s;

    cin >> s;
    ll r[n+10];
    ll g[n+10];
    ll b[n+10];
    ll ans = 0;
    if(n<=3)
        return cout<<0<<endl,0;

    for(i=n-1; i>=0; i--)
    {
        if(i==n-1)
        {
            if(s[i]=='R')
                r[i]=1;
            else
                r[i]=0;
        }
        else
        {
            if(s[i] == 'R')
                r[i]=1+r[i+1];
            else
                r[i]=r[i+1];
        }
    }
    for(i=n-1; i>=0; i--)
    {
        if(i==n-1)
        {
            if(s[i]=='G')
                g[i]=1;
            else
                g[i]=0;
        }
        else
        {
            if(s[i] == 'G')
                g[i]=1+g[i+1];
            else
                g[i]=g[i+1];
        }
    }
    for(i=n-1; i>=0; i--)
    {
        if(i==n-1)
        {
            if(s[i]=='B')
                b[i]=1;
            else
                b[i]=0;
        }
        else
        {
            if(s[i] == 'B')
                b[i]=1+b[i+1];
            else
                b[i]=b[i+1];
        }
    }
    char ch,bh,kh;

    for(i=0; i<n-1; i++)
    {
        ch = s[i];
        for(j=i-1; j>=0; j--)
        {
            if(s[j]==ch)
                continue;
            bh = s[j];
            kh = '#';
            if(ch == 'R' && bh == 'G')
                kh = 'B';
            if(ch == 'G' && bh == 'R')
                kh = 'B';

            if(ch == 'G' && bh == 'B')
                kh = 'R';
            if(ch == 'B' && bh == 'G')
                kh = 'R';

            if(ch == 'R' && bh == 'B')
                kh = 'G';
            if(ch == 'B' && bh == 'R')
                kh = 'G';

            if(kh == 'R')
            {
                ans += r[i];
                if((i+(i-j))<n)
                    if(s[i+(i-j)]=='R')ans -= 1;
            }
            if(kh == 'G')
            {
                ans += g[i];
                if((i+(i-j))<n)
                    if(s[i+(i-j)]=='G')ans -= 1;
            }
            if(kh == 'B')
            {
                ans += b[i];
                if((i+(i-j))<n)
                    if(s[i+(i-j)]=='B')ans -=1;
            }


        }
    }

    cout << ans << endl;
}


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

int main(){
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
}


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

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,lar=0,temp=0;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i])lar=l;
  else lar=i;
  if(r<=H&&A[r]>A[lar])lar=r;
  if(lar!=i){
    temp=A[i];
    A[i]=A[lar];
    A[lar]=temp;
    maxHeapify(lar);
  }
}
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=H;i++){
    printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}



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

int main() {
  int h,w;
  string str;
  
  cin >> h >> w;
  
  vector<vector<string>> vec(h+2, vector<string>(w+2));
  
  for(int i = 0; i < h+2; i++){
    if(i == 0 || i == h+1){
      for(int j = 0; j < w+2; j++){
        vec.at(i).at(j) = ".";
        continue;
      }
    }else{ 
      cin >> str;
      for(int j = 0; j < w+2; j++){
        if(j == 0 || j == w+1){
          vec.at(i).at(j) = ".";
        }else{
          vec.at(i).at(j) = str.substr(j-1,1);
        }
      }
    }
  }
  
  int cnt;
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      cnt = 0;
      
      if(vec.at(i).at(j) == "#"){
        cout << "#";
        continue;
      }
      
      if(vec.at(i-1).at(j-1) == "#") cnt++;
      if(vec.at(i-1).at(j) == "#") cnt++;
      if(vec.at(i-1).at(j+1) == "#") cnt++;
      if(vec.at(i).at(j-1) == "#") cnt++;
      // if(vec.at(i).at(j) == "#") cnt++; // 自分
      if(vec.at(i).at(j+1) == "#") cnt++;
      if(vec.at(i+1).at(j-1) == "#") cnt++;
      if(vec.at(i+1).at(j) == "#") cnt++;
      if(vec.at(i+1).at(j+1) == "#") cnt++;
      
      cout << cnt;
    }
    cout << endl;
  }
}


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

int main(){
  int n, m, a, b;
  cin >> n >> m;
  vector<int> v[n];
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for(int i = 0; i < n; i++) cout << v[i].size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a;

    scanf("%d", &a);

    if(a==3){
        printf("YES\n");
    } else if(a==5) { printf("YES\n");
    } else if(a==7) {printf("YES\n");
    } else{ printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
a1 = A[::2]
a2 = A[1::2]

count1 = dict()
count2 = dict()

for a in a1:
    if a in count1.keys():
        count1[a] += 1
    else:
        count1[a] = 1

for a in a2:
    if a in count2.keys():
        count2[a] += 1
    else:
        count2[a] = 1

kf = lambda x: -x[1]

A1 = sorted(count1.items(), key=kf)
A2 = sorted(count2.items(), key=kf)

if A1[0][0] == A2[0][0]:
    if len(A1) == 1:
        if len(A2) == 1:
            keep = A1[0][1]
        else:
            keep = A1[0][1] + A2[1][1]
    else:
        keep = max([A1[1][1], A2[1][1]]) + A1[0][1]
else:
    keep = A1[0][1] + A2[0][1]

print(N - keep)


Measured memory_bytes: 23264
def main():
    N = int(input())
    take_dish = list(map(int,input().split()))
    dish_point = list(map(int,input().split()))
    bonus_dish_point = list(map(int,input().split()))
    result = 0

    for index,dish in enumerate(take_dish):
        result += dish_point[dish-1]
        if(index!=0 and (take_dish[index-1]+1 == dish)):
            result += bonus_dish_point[take_dish[index-1]-1]
    
    print(result)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    ll n,m; cin>>n>>m;
    ll l1 = 1, l2 = 1;
    int p = -1;
    for(int i = 0; i < n; i++){
        ll k; cin>>k;
        k>>=1;
        l1 = l1*k/__gcd(l1,k);
        int cnt = 0;
        while(k%2==0){
            k/=2;
            cnt++;
        }
        if(!i){
            p = cnt;
        }
        if(p!=cnt){
            cout<<0<<endl;
            return 0;
        }
        
    }

    cout<<m/l1 - m/(2*l1)<<endl; 
    return 0;
}

Measured memory_bytes: 3656
MODINT = 10**9 + 7

N, K = map(int, input().split())

ans = 0
q = [0] * (K + 1)

for i in range(K, 0, -1):
    q[i] = pow(K//i, N, MODINT)
    for j in range(i*2, K+1, i):
        q[i] -= q[j]
        
    ans += (q[i]*i) % MODINT
    
print(ans % MODINT)

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(all(c)); c.erase(unique(all(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string s;
    cin >> s;

    int ans = INT_MAX;
    string chars = s; sort_uniq(chars);
    
    if (chars.size() == 1) {
        ans = 0;
    } else {
        for (auto ch : chars) {
            string t = s;
            for (int i = 0; i < s.size() - 1; i++) {
                for (int j = 0; j < s.size() - i - 1; j++) {
                    if (t[j+1] == ch) t[j] = ch;
                }
                t.pop_back();
                if (all_of(all(t), [&](char c) { return c == ch; })) {
                    chmin(ans, i + 1);
                }
            }
        }
    }
    
    cout << ans << endl;    
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;

/*
 * @title StronglyConnectedComponents
 */
class StronglyConnectedComponents{
	int num,is_2sat,half,max_id,cnt;
	vector<vector<int>> edge;
	vector<int> label,order,low;
    stack<size_t> st;
	inline int rev(int i) { return i < half ? i + half : i - half; }
    inline void dfs(int& from) {
        low[from]=order[from]=cnt++;
        st.push(from);
        for(int& to:edge[from]) {
            if(order[to]==-1) {
                dfs(to);
                low[from]=min(low[from],low[to]);
            }
            else {
                low[from]=min(low[from],order[to]);
            }
        }
        if (low[from] == order[from]) {
            while(st.size()) {
                int u = st.top();st.pop();
                order[u] = num;
                label[u] = max_id;
                if (u == from) break;
            }
            max_id++;
        }
    }
public:
	StronglyConnectedComponents(const int n, bool is_2sat=0):num(n),max_id(0),cnt(0),is_2sat(is_2sat){
		if(is_2sat) num<<=1;
		edge.resize(num);
		label.resize(num);
        order.resize(num,-1);
        low.resize(num);
        half=(num>>1);
	}
	inline int operator[](int idx) {
		return label[idx];
	}
	inline void make_edge(const int from,const int to) {
		edge[from].push_back(to);
	}
    //xがflg_xならばyがflg_y
	inline void make_condition(int x, bool flg_x, int y, bool flg_y) {
		if (!flg_x) x = rev(x);
		if (!flg_y) y = rev(y);
		make_edge(x, y);
		make_edge(rev(y), rev(x));
	}
    //is_2sat=1のときに、2satを満たすかを返却する
	inline bool solve(void) {
        for (int i = 0; i < num; i++) if (order[i] == -1) dfs(i);
        for (int& id:label) id = max_id-1-id;
		if(!is_2sat) return true;
		for (int i = 0; i < num; ++i) if (label[i] == label[rev(i)]) return false;
		return true;
	}
    vector<vector<int>> topological_sort(void) {
        vector<vector<int>> ret(max_id);
        for(int i=0;i<num;++i) ret[label[i]].push_back(i);
        return ret;
    }
	int is_true(int i) {
		return label[i] > label[rev(i)];
	}
	void print(void) {
		for(auto id:label) cout << id << " ";
		cout << endl;
	}
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,D; cin >> N >> D;
    StronglyConnectedComponents scc(N,1);
    vector<int> X(2*N);
    for(int i=0;i<N;++i) cin >> X[i] >> X[i+N];
    for(int i=0;i<2*N;++i) {
        for(int j=0;j<2*N;++j) {
            if(i==j||abs(i-j)==N) continue;
            if(abs(X[i]-X[j])<D) scc.make_condition(i%N,(i<N),j%N,!(j<N));
        }
    }
    bool f=scc.solve();
    if(f) {
        cout << "Yes\n";
        for(int i=0;i<N;++i) {
            cout << (scc.is_true(i)?X[i]:X[i+N]) << "\n";
        }
    }
    else{
        cout << "No\n";
    }
    return 0;
}


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

int main(){
    int a[100], n;
    
    cin >> n;
    for(int i = 0 ; i < n ; i++ ){
        cin >> a[i];
    }
    for(int i = n - 1 ; i >= 0 ; i--){
        cout << a[i];
        if(i){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
int main() 
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n,x,y=0;
    cin>>n;
while(n--)
{
cin>>x;
y+=(x-1);
}
cout<<y;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;

  for(v = 0; v < n; v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u = 0; u < n; u++) color[u] = WHITE;
  tt = 0;

  for(u = 0; u < n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u = 0; u < n; u++){
    printf("%d %d %d\n", u+1, d[u], f[u]);
  }
}

int main(){
  int u, v, k,i, j;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <math.h>

double stack[200];
int sp;

void push(double n)
{
	stack[sp++] = n;
}

double pop(void)
{
	return (stack[--sp]);
}

int main(void)
{
	char str[1000];
	char *p;
	double a, b;
	
	while (fgets(str, 1000, stdin) != NULL){
		p = str;
		sp = 0;
		while (*p != '\0' && *p != '\n'){
			switch (*p){
			  case '+':
			    a = pop();
				b = pop();
				push(b + a);
			  	p++;
				break;

			  case '*':
			    a = pop();
				b = pop();
				push(b * a);
			  	p++;
				break;

			  case '/':
			    a = pop();
				b = pop();
				push(b / a);
			  	p++;
				break;
		
			  case ' ':
  			  case '\n':
			  	p++;
				break;

			  case '-':
			    if ('0' <= *(p + 1) && *(p + 1) <= '9'){
//				    a = atof(p);
//					push(a);
					push(atoi(p));
					p++;
					while ('0' <= *p && *p <= '9'){
						p++;
					}
				}
				else {
				    a = pop();
					b = pop();
					push(b - a);
					p++;
				}
				break;

			  default:
//			    a = atof(p);
//				push(a);
				push(atoi(p));
				while ('0' <= *p && *p <= '9'){
					p++;
				}
				break;
			}
		}
//		printf("%f\n", stack[0]);
		printf("%lf\n", pop());
	}
	return (0);
}

Measured memory_bytes: 0
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,k,x,m,curr;
	cin >> n >> x;
	int rose = 1;
	int now = 0;
	for(i=1;i<=n;i++)
    {
        cin >> curr;
        now += curr;
        if(now <= x)
        {
            rose++;
        }
        else
            break;
    }
    cout << rose << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}		
		int t;
		for (int h = 0; h < n; h++) {
			for (int i = 0; i < n - h - 1; i++) {
				if (l[i] < l[i + 1]) {
					t = l[i];
					l[i] = l[i + 1];
					l[i + 1] = t;
				}
			}
		}
		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum = sum + l[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
A, B = map(int, input().split())

grid = []
for _ in range(50):
    grid.append(["#"] * 100)
for _ in range(50):
    grid.append(["."] * 100)


div, mod = divmod(A - 1, 50)
for d in range(div):
    h = 0 + d * 2
    for w in range(0, 100, 2):
        grid[h][w] = "."
if mod:
    h = 0 + div * 2
    for w in range(0, mod * 2, 2):
        grid[h][w] = "."

div, mod = divmod(B - 1, 50)
for d in range(div):
    h = 51 + d * 2
    for w in range(0, 100, 2):
        grid[h][w] = "#"
if mod:
    h = 51 + div * 2
    for w in range(0, mod * 2, 2):
        grid[h][w] = "#"

print(100, 100)
for g in grid:
    print("".join(g))

Measured memory_bytes: 3192
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;

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

    vector<int> v;
    for (int i = 1; i <= N && i < K; i++) {
        int cnt = 0;
        while ((i << cnt) < K)
            cnt++;
        
        v.push_back(cnt);
    }

    sort(v.begin(), v.end());

    double ans = 0;
    for (int i = 0; i < (int)v.size(); i++)
        ans += 1.0 - pow(2.0, -v[i]);
    ans /= N;
    ans = 1.0 - ans;

    cout << fixed << setprecision(50) << ans << endl;

    return 0;
}


Measured memory_bytes: 384
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

m,k=MI()

if k>=2**m or (m,k)==(1,1):
    print(-1)
elif (m,k)==(1,0):
    print('0 0 1 1')
else:
    a=[]
    for i in range(2**m):
        if i!=k: a.append(i)
    ans=[k]+a+[k]+a[::-1]
    print(*ans)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	int l[60];
	cin >> n >> k;
	for (int i = 0; i < n; i++)  cin >> l[i];
	
	sort(l, l + n);
	reverse(l, l + n);
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += l[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int n,r;
    scanf("%d%d",&n,&r);
    if (n>=10){
        printf("%d\n",r);
    }
    else {
        printf("%d\n",100*(10-n)+r);
    }
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<climits>
int main()
{
	int X;
	std::cin >> X;
	if(X < 4)
	{
		std::cout << 1 << std::endl;
	}
	else
	{
		int dis = INT_MAX;
		for(int b = 2;; b++)
		{
			for(int p = 2;; p++)
			{
				int pow_bp = 1;
				for(int i = 0; i < p; i++)
				{
					pow_bp *= b;
				}
				if(X - pow_bp >= 0)
				{
					if( X - pow_bp < dis)
					{
						dis = X - pow_bp;
					}
				}
				else
				{
					break;
				}
			}
			if(b * b > X)
			{
				break;
			}
		}
		std::cout << X - dis << std::endl;
	}
	return 0;
}

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

int main() {
    ll A, B;
    cin >> A >> B;

    if (A == 1 and B == 2) {

    }

    if (B%A != 0) {

        ll tmp = 2;
        while (A*tmp <= B) tmp++;

        if (A*tmp > B and (A*tmp-B) > tmp-1) {
            cout << A*tmp << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    else {
        cout << -1 << endl;
    }
}



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

int main(){
    string s;
    cin >> s;
    vector<int> num;
    char now = '.';
    int tmp = 0;
    for (int i = 0; i < s.size(); i++){
        if (now != s[i]) {
            num.push_back(tmp);
            now = s[i];
            tmp = 1;
        }
        else tmp++;
    }
    num.push_back(tmp);
    bool flag = false;
    int ans = 0;
    for (int i = 0; i < num.size(); i++){
        if (num[i] == 0) continue;
        if (num[i] % 3 == 0){
            if (flag) ans += 2 * (num[i] / 3);
            else ans += 2 * (num[i] / 3);
        }
        else if (num[i] % 3 == 1){
            ans += 2 * (num[i] / 3) + 1;
            flag = false;
        }
        else {
            if (flag) ans += 2 * (num[i] / 3) + 2, flag = false;
            else ans += 2 * (num[i] / 3) + 1, flag = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1532
import sys
readline = sys.stdin.buffer.readline

def main():
    N, X = map(int, readline().rstrip().split())
    M = [int(readline()) for _ in range(N)]

    X -= sum(M)
    ans = N
    ans += X // min(M)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include <array>
int main(void){
		std::array<int, 3> num;
		std::cin >> num[0] >> num[1] >> num[2];

		std::sort(num.begin(),num.end());

		std::cout << num[0] <<" "<< num[1] <<" "<< num[2] << std::endl;
		return 0;
}

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

int main(){

  int N=0;
  cin>>N;
  int L[N];

  rep(i,N){
    cin>>L[i];
  }
  sort(L, L + sizeof(L)/sizeof(L[0]));
  
  int count=0;
  
  rep(i,N){
   	for(int j=i+1;j<N;j++){
    
      for(int k=j+1;k<N;k++){
        if((L[i]+L[j])>L[k])count++;
        else break;
      }
    }
  }
  
  cout<<count;

}



Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
struct Int {
  using type = T;
  static type identity_zero() { return T(0); }
  static type identity_one() { return T(1); }
};

template <typename Semiring>
struct Matrix {
  using T = typename Semiring::type;
  size_t n_row, n_col;
  T zero = Semiring::identity_zero(), one = Semiring::identity_one();
  std::vector<std::vector<T>> data;

  Matrix() {}
  Matrix(size_t n, size_t m)
      : n_row(n), n_col(m), data(n, std::vector<T>(m, zero)) {}
  Matrix(size_t n) : n_row(n), n_col(n), data(n, std::vector<T>(n, zero)) {}
  Matrix(std::vector<std::vector<T>> &arr) : n_row(arr.size()) {
    n_col = arr.size() ? arr[0].size() : 0;
    data.resize(n_row);
    for (size_t row = 0; row < n_row; row++) data[row] = arr[row];
  }

  inline const std::vector<T> &operator[](int k) const { return data.at(k); }

  static Matrix<Semiring> Identity(size_t n) {
    Matrix<Semiring> mat(n);
    for (size_t i = 0; i < n; i++) mat[i][i] = Semiring::identity_one();
    return mat;
  }

  Matrix operator*(const Matrix &B) {
    size_t n = n_row, m = B.n_col, p = n_col;
    assert(p == B.n_row);
    std::vector<std::vector<T>> C(n, vector<T>(m, zero));
    for (size_t i = 0; i < n; i++)
      for (size_t j = 0; j < m; j++)
        for (size_t k = 0; k < p; k++)
          C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]);
    return Matrix(C);
  }
};

void aoj() {
  // https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/all/ITP1_7_D
  int N, M, L;
  cin >> N >> M >> L;
  Matrix<Int<long long>> mat1(N, M), mat2(M, L);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) std::cin >> mat1.data[i][j];
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < L; j++) std::cin >> mat2.data[i][j];
  }
  Matrix<Int<long long>> res = mat1 * mat2;
  for (size_t i = 0; i < res.n_row; i++) {
    for (size_t j = 0; j < res.n_col; j++) {
      std::cout << res.data[i][j] << (j + 1 == res.n_col ? '\n' : ' ');
    }
  }
}

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  aoj();
  return 0;
}


Measured memory_bytes: 3436
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEN 1000000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
P u[LEN+1];
int head, tail, n;

int isEmpty(){
  if( head ==tail) return 1;
  else return 0;
}

void enqueue(P x){
  Q[tail] = x;
      tail++;
}

void initialize(){
  head = 0;
  tail = n+1;
}
  
int main(){
  int count = 1, c,tmp=0;
  int i, q;
  scanf("%d %d", &n, &q);
  int a[n+1];

for(i =1 ;i<=n ;i++){
    u[i].t = 0;
    }
  
  for (i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  initialize();
  
  i=1;
  while(count != n+1){
    if(Q[i].t >q){
      Q[i].t=(Q[i].t - q);
      tmp += q;
      enqueue(Q[i]);
      i++;
    }
    else if(Q[i].t <=q) {
      tmp +=Q[i].t;
      u[count].t=tmp;
      strcpy(u[count].name ,Q[i].name);
      i++;
      count++;
	}
  }
  for(i =1 ;i<=n ;i++){
  printf("%s %d\n",u[i].name,u[i].t);
  }
  return 0;
}



Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0;i < n;++i) {
		cin >> a[i];
		--a[i];
	}
	for (int i = 0;i < n;++i) {
		cin >> b[i];
	}
	for (int i = 1;i < n;++i) {
		cin >> c[i];
	}
	int answer = 0;
	for (int i = 0;i < n;++i) {
		answer += b[a[i]];
		if (i > 0 && a[i] == a[i - 1] + 1) {
			answer += c[a[i]];
		}
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = np.array(read().split(), np.int64)

def main(A):
    N = len(A)
    if N % 2 == 0:
        S = np.bitwise_xor.reduce(A)
        return A ^ S
    return A

B = main(A)
print(' '.join(map(str, B.tolist())))

Measured memory_bytes: 52540
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll findXORofRange(ll m, ll n)
{


    if(m % 2 == 0)
    {
        ll  patternTracker[]= {n, 1, n^1, 0};
        return patternTracker[(n-m) % 4];
    }
    else
    {
        ll patternTracker []= {m, m^n, m-1, (m-1)^n};
        return patternTracker[(n-m) % 4];
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll x,y;
    cin>>x>>y;

    cout<<findXORofRange(x,y)<<endl;


    return 0;
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <stdlib.h>
#include <time.h>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long
#define INF 2000000000

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	a -= c;
	cout << a / (b+c) << endl;
	return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vi a(n + 1);

	for (int i = 0; i < k; ++i) {
		int v;
		cin >> v;

		for (int j = 0; j < v; ++j) {
			int x;
			cin >> x;
			a[x]++;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] == 0) ans++;
	}
	cout << ans << endl;
}


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

int h,n,p,m,k,a,b;
double ans[501][101][101];
bool check[501];
bool amida[501][100];
double prob;
int use[501];

int main(){
  cin >> h >> n >> p >> m >> k;

  for(int i=1;i<=h;i++){
    check[i] = false;
    for(int j=1;j<n;j++)amida[i][j] = false;
  }

  for(int i=0;i<m;i++){
    cin >> a >> b;
    check[a] = true;
    amida[a][b] = true;
  }

  int tmp = 0;
  for(int i=1;i<=h;i++){
    if(!check[i])tmp++;
    use[i] = tmp;
  }

  for(int i=0;i<=h;i++){
    for(int j=1;j<=n;j++){
      for(int l=0;l<=k;l++)ans[i][j][l] = 0.0;
    }
  }

  ans[h][p][k] = 1.0;

  for(int i=h;i>0;i--){
    for(int j=1;j<=n;j++){
      for(int l=0;l<=k;l++){
	if(check[i]){
	  if(j<n && amida[i][j])ans[i-1][j][l] = ans[i][j+1][l];
	  else if(j>1 && amida[i][j-1])ans[i-1][j][l] = ans[i][j-1][l];
	  else ans[i-1][j][l] = ans[i][j][l];
	}else{
	  if(j<n && l>0)ans[i-1][j][l-1] += ( (double)l/use[i] ) * ans[i][j+1][l] / (n-1);
	  if(j>1 && l>0)ans[i-1][j][l-1] += ( (double)l/use[i] ) * ans[i][j-1][l] / (n-1);
	  ans[i-1][j][l-1] += ( (double)(n-3)/(n-1) ) * ( (double)l/use[i] ) * ans[i][j][l];
	  if(j==1 || j==n)ans[i-1][j][l-1] += (1.0/(n-1) ) * ( (double)l/use[i] ) * ans[i][j][l];
	  ans[i-1][j][l] += ( (double)(use[i]-l)/use[i] ) * ans[i][j][l];
	}
      }
    }
  }

  double res = 0.0;

  for(int i=1;i<=n;i++)res = max(res,ans[0][i][0]);
  
  printf("%.8lf\n",res);
}

Measured memory_bytes: 39000
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x - i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

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

int main() {

	int n; cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			int a = l[i];
			int b = l[j];
			int tmp_b = lower_bound(l.begin(), l.end(), a + b) - l.begin(); //a +  b より小さいものの個数
			int tmp = tmp_b - (j + 1);
			ans += max(0, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, c = map(int, input().split())
program = [[] for _ in range(c)]

for i in range(n):
  s, t, cc = map(int, input().split())
  program[cc-1].append((s, t))

count = [0]*(10**5+1)
for i in range(c):
  program[i].sort()
  l = len(program[i])
  judge = True
  for j in range(l-1):
    if judge:
      count[program[i][j][0]-1] += 1
    if program[i][j][1] == program[i][j+1][0]:
      judge = False
    else:
      judge = True
    if judge:
      count[program[i][j][1]] -= 1
  if l == 0:
    continue
  if judge:
    count[program[i][l-1][0]-1] += 1
  count[program[i][l-1][1]] -= 1

ans = 0
for i in range(10**5+1):
  if i != 0:
    count[i] += count[i-1]
  if ans < count[i]:
    ans = count[i]
print(ans)
      

Measured memory_bytes: 23900
/*
https://blog.csdn.net/weixin_30466421/article/details/97091246
如果 (color[x]±1 \mod 3 =color[u]) 且 (x,u) 在同一连通块内,则一定有边存在 （这个可以想明白，大概是一些箭头的指来指去？然后同一联通块里箭头同一方向的块，每个这样的块是符合这个性质的，相邻块间又有一个交错的点，就全连起来了。。。）
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1e5 + 10;
typedef long long ll;
int n, m, vis[N], col[N], ff;
int lnk[N], to[N << 1], nxt[N << 1], cnt = 1, val[N << 1], vise[N];
ll ans, sz, tot, num[3];

void add(int x, int y, int z) {
    to[++cnt] = y, nxt[cnt] = lnk[x], lnk[x] = cnt, val[cnt] = z;
}

void dfs(int x) {
    vis[x] = 1;
    ++sz;
    num[col[x]]++;
    for (int i = lnk[x]; i; i = nxt[i]) {
        int y = to[i];
        if (!vise[i >> 1]) {  // 只能算一次！！！
            vise[i >> 1] = 1;
            tot++;
            if (!vis[y]) {
                col[y] = (col[x] + val[i] + 3) % 3;
                dfs(y);
            } else ff |= (col[y] != ((col[x] + val[i] + 3) % 3));
        }
    }
}

int main() {
    cin >> n >> m;
    rep(i, 1, m) {
        int x, y; cin >> x >> y;
        add(x, y, 1), add(y, x, -1);  // 两条边在统计边数时只能算一次！看上面！！
    }
    rep(i, 1, n) if (!vis[i]) {
        sz = tot = ff = 0; rep(j, 0, 2) num[j] = 0;
        dfs(i);
        if (ff)  // 有点被染上相同颜色
            ans += sz * sz;
        else if (!num[0] || !num[1] || !num[2])  // 只有 <=2 种颜色
            ans += tot;
        else
            ans += num[0] * num[1] + num[1] * num[2] + num[2] * num[0];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 7296
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	S := getString()
	T := getString()
	
	cnt := 0
	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			cnt++
		}
	}
	
	fmt.Println(cnt)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    for(int i=10;i<1e6;i++){
        if(i*8/100==a&&i/10==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> mat(n,vector<int>(m));
  REP(i,n){
    REP(j,m){
      cin >> mat[i][j];
    }
  }
  vector<int> vec(m);
  REP(i,m) cin >> vec[i];
  REP(i,n){
    int sum = 0;
    REP(j,m){
      sum += vec[j] * mat[i][j];
    }
    cout << sum <<endl;
  }

  return 0;
}



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

int main() {
  
  int N;
  int A;
  
  cin >> N;
  cin >> A;
  
  if ( N % 500 <= A ) {
    cout << "Yes" << endl;
  }
  
  else if ( N % 500 > A ) {
    cout << "No" << endl;
  }
}
  
  
    
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

template <typename T>
T modpow(T base, T exp, T modulus) {
    base %= modulus;
    T result = 1;
    while (exp > 0) {
        if (exp & 1) result = (result * base) % modulus;
        base = (base * base) % modulus;
        exp >>= 1;
    }
    return result;
}


const int MOD = 1e9 + 7;

ll factorial(ll n, int mod){
    ll res = 1;
    for(int i = 2; i <= n; i++){
        res = (res * i) % MOD;
    }
    return res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
////    CLion Standard Input for DEBUG
////    --------------------------------------------------------------------------
//    ifstream in("./in.txt");
//    cin.rdbuf(in.rdbuf());
////    --------------------------------------------------------------------------

    int m, n;
    cin >> m >> n;
    if(abs(m-n) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;

    ans = factorial(n, MOD) * factorial(m, MOD) % MOD;
    if(n == m) ans = ans * 2 % MOD;
    cout << ans << endl;

    return 0;

}


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

#define ll long long
#define ar array
 
using namespace std;


int main() {
	
	int n,t,ci[100000],ti[100000];
	
	cin >> n >> t;
	
	for(int i=0;i<n;i++){
		cin >> ci[i] >> ti[i];
	}
	int base=ci[0],ans=-1;
	for(int i=0;i<n;i++){
		if(ci[i]<=base && ti[i]<=t){
			base = ci[i];
			ans=i;
		}
	}
	if(ans==-1){
		cout<<"TLE"<<endl;
	}else{
		cout<<ci[ans]<<endl;
	}
	
	
   	return 0;
}
   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int kou,sou=114514810,H,W;
int main(){
    cin>>H>>W;
    char HW[H][W];
    for(int i=0;i<H;i++){ for(int o=0;o<W;o++){ scanf(" %c",&HW[i][o]); }}
    for(int i=1;i<H-1;i++){
        for(int j=1;j<H-i;j++){
            kou=0;
            for(int o=0;o<i;  o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='W'){kou++;} } }
            for(int o=i;o<i+j;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='B'){kou++;} } }
            for(int o=i+j;o<H;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='R'){kou++;} } }
            if(kou<sou){sou=kou;}
        }
    }
    cout<<sou<<endl;
}

Measured memory_bytes: 3148
N, Y = map(int, input().split())
count = 0
yen = [0] * 3

for i in reversed(range(Y // 10000 + 1)):
    for j in range(Y // 5000 + 1):
        temp = N - i - j
        if Y - 10000 * i - 5000 * j < 0 or temp < 0:
            break
        elif Y - 10000 * i - 5000 * j == 1000 * temp:
            yen[0] = i
            yen[1] = j
            yen[2] = temp
            print(' '.join(map(str, yen)))
            exit()
        else:
            continue
print('-1 -1 -1')

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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector< vector<ll> > a(n, vector<ll>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	vector<ll> score(1 << n, 0);
	for (int i = 1; i < (1 << n); i++) {
		for (int k = 0; k < n; k++) {
			if (!(i & (1 << k))) continue;
			for (int l = 0; l < k; l++) {
				if (!(i & (1 << l))) continue;
				score[i] += a[k][l];
			}
		}
	}

	vector<ll> dp(1 << n, 0);
	for (int i = 1; i < (1 << n); i++) {
		for (int j = i; j > 0; j = (j - 1) & i) {
			dp[i] = max(dp[i], dp[i ^ j] + score[j]);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,y,a[3000];
	cin>>n>>x>>y;
	memset(a,0,sizeof(a));
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;++j)
		{
			int t=min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)));
			a[t]++;
		}
	}
	for(int i=1;i<n;++i)
		cout<<a[i]<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("aa_input.txt", "r", stdin);

    string str;
    cin>>str;
    sort(str.begin(), str.end());
    if(str[0]==str[1] && str[2] == str[3] && str[0] != str[3]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    
    return 0;
}
/*

riaadmorshed@gmail.com

*/

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int i,j;
  int count = 0;
  int max = 0;
  string target_n,before_n;
  for(i = 1;i < N;i++){
    for(j = 0;j < i;j++){
      target_n = S[j];
      if(S.substr(i).find(target_n) != string::npos){
        if(before_n.find(target_n) == string::npos){
          before_n+= S[j];
          count++;
        }
      }
    }
    before_n = "";
    if(max < count) max = count;
    count = 0;
  }

  cout << max << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
stack<int> s[1010];
int main()
{
	int n, m;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int x;
		scanf("%d",&x);
		if(x == 0)
		{
			int y, z;
			scanf("%d%d",&y,&z);
			s[y].push(z);
		}
		else if(x == 1)
		{
			int y;
			scanf("%d",&y);
			if(s[y].size())printf("%d\n",s[y].top());
			//else printf("\n");
		}
		else if(x == 2)
		{
			int y;
			scanf("%d",&y);
			if(s[y].size())s[y].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 4424
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
static const int INF = 10000000;

pair<vector<int>, bool>
bellman_ford(const vector<vector<vector<int> > >& rules, const vector<int>& seed)
{
  const int N = seed.size();
  vector<int> dist(N, INF);
  for (int i = 0; i < N; i++) {
    if (seed[i]) {
      dist[i] = 1;
    }
  }

  for (int i = 0; i < N; i++) {
    for (int u = 0; u < N; u++) {
      for (vector<vector<int> >::const_iterator it = rules[u].begin(); it != rules[u].end(); ++it) {
        vector<int> v;
        for (vector<int>::const_iterator jt = it->begin(); jt != it->end(); ++jt) {
          v.push_back(dist[*jt]);
        }
        sort(v.begin(), v.end(), greater<int>());
        int d = 0;
        for (vector<int>::const_iterator jt = v.begin(); jt != v.end(); ++jt) {
          d = max(d, int(*jt + (jt - v.begin())));
        }
        dist[u] = min(dist[u], d);
      }
    }
  }

  for (int i = 0; i < N; i++) {
    for (int u = 0; u < N; u++) {
      for (vector<vector<int> >::const_iterator it = rules[u].begin(); it != rules[u].end(); ++it) {
        vector<int> v;
        for (vector<int>::const_iterator jt = it->begin(); jt != it->end(); ++jt) {
          v.push_back(dist[*jt]);
        }
        sort(v.begin(), v.end(), greater<int>());
        int d = 0;
        for (vector<int>::const_iterator jt = v.begin(); jt != v.end(); ++jt) {
          d = max(d, int(*jt + (jt - v.begin())));
        }
        if (d < dist[u]) {
          return make_pair(dist, false);
        }
      }
    }
  }
  return make_pair(dist, true);
}

int main()
{
  int N, E, T;
  cin >> N >> E >> T;
  --T;
  vector<int> seed(N);
  for (int i = 0; i < N; i++) {
    cin >> seed[i];
  }
  vector<vector<vector<int> > > rules(N);
  for (int i = 0; i < E; i++) {
    int g, c;
    cin >> g >> c;
    --g;
    vector<int> r(c);
    for (int j = 0; j < c; j++) {
      cin >> r[j];
      --r[j];
    }
    rules[g].push_back(r);
  }

  const pair<vector<int>, bool> r = bellman_ford(rules, seed);
  if (r.second && r.first[T] < INF) {
    cout << r.first[T] << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}

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

int main(){
	int n, l;
	cin >> n >> l;
	vector<int> vec(n);
	int sum = 0;
	for (int i=0;i<n;i++){
		sum += l + i;
		vec.at(i) = l + i;
	}
	int eat = 0;
	if (vec.at(0)>0){
		eat = vec.at(0);
	}
	else if (vec.at(n-1)<0){
		eat = vec.at(n-1);
	}
	cout << sum - eat << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

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

int main(){
    ll n;
    cin >> n;
    ll ans;
    ans = n*(n-1)/2;

    cout << ans << endl;
}

Measured memory_bytes: 256