akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {

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

	for (size_t i = 0; i < n; i++)
	{
		for (int j = i - 1; j >= 0; j--)
		{
			if (a[j] <= a[j + 1]) break;
			swap(a[j], a[j + 1]);
		}
		for (size_t k = 0; k < n; k++)
		{
			if (k > 0) cout << " ";
			cout << a[k];
		}
		cout << endl;

	}

}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer x = nil;
  while(1){
      x = x->next;
      if(x == nil){
        return nil;
      }
      if(x->key == key){
        return x;
      }
    }
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil){
       break;
    }
    if(isf == 0){
       printf(" ");
    }
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  NodePointer p,n;

  p = t->prev;
  n = t->next;
  p->next = n;
  n->prev = p;
  free(t);
}
 
void deleteFirst(){
  NodePointer t = nil->next;
  if(t == nil){
    return;
  }
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t = nil->prev;
  if( t == nil){
    return;
  }
  deleteNode(t);
}
 
void delete(int key){
  NodePointer x = listSearch(key);
  if(x != nil){
    deleteNode(x);
  }
}
 
 
void insert(int key){
  NodePointer x, y;
  x = malloc(sizeof(struct node));
  x->key = key;
  y = nil->next;
  nil->next = x;
  x->prev = nil;
  y->prev = x;
  x->next = y;
}
 
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F'){
          deleteFirst();
        }else if(com[6] == 'L'){
          deleteLast();
        }
    }else{
      delete(key);
      nd++; 
      }
    size--;
    }
  }
  printList();

  return 0;
}

Measured memory_bytes: 31788
##input##
D,G = map(int,input().split())
p_c_list=[]
for i in range(D):
    p,c = map(int,input().split())
    p_c_list.append([p,c])
answer_sum = 99999
#print(p_c_list)

##syori##
for i in range(2**D):
    total = 0
    answer = 0
    moji = format(i,'b').zfill(D)
    #print(moji[D-1])
    ##total kanzen keisan
    for k in range(D):
        if int(moji[k]) == 1:
            total += (k+1)*100*p_c_list[k][0] + p_c_list[k][1]
            answer += p_c_list[k][0]
            
    if total >= G:
        if answer_sum >= answer:
            answer_sum = answer
    else:
        D_remain = moji.rfind('0')
        p_remain = int((G-total)/((D_remain+1)*100)+0.9999)
        if p_remain < p_c_list[D_remain][0]:
            answer += p_remain
            if answer_sum >= answer:
                answer_sum = answer
print(answer_sum)

Measured memory_bytes: 3064
a=str(input())
b=len(a)
x=0
y=0
for i in range(b):
    if a[i]=="A" or a[i]=="T" or a[i]=="G" or a[i]=="C":
        x +=1
    else:
        x=0
    if (x > y):
        y=x
print(y)

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define endl '\n'

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int maxn = 3e5+10;
const int mod = 1e9+7;

ll v[maxn];

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	for(int i=0;i<60;++i){
		ll cnt=0;
		for(int j=0;j<n;++j){
			if((v[j]&(1LL<<i)))
				cnt++;
		}
		ll one_bit = (cnt*(n-cnt))%mod;
		ll to_dec = (((1LL<<i)%mod)*one_bit)%mod;
		ans = (ans+to_dec)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
int main()
{
    string s;
    cin >> s;
    int price = 700;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o'){
            price += 100;
        }
    }
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product
S=input()
ans=0
for p in product(range(2),repeat=len(S)-1):
    tmp=''
    for i in range(len(S)-1):
        if p[i]==1:
            tmp+=S[i]+'+'
        else:
            tmp+=S[i]
    ans+=eval(tmp+S[-1])
print(ans)

Measured memory_bytes: 3060
v, e = map(int, input().split())   #ユーザ数、関係性の数
edge = [[] for _ in range(v)]      #お隣さんリスト


#連結成分作成部分のコード（各頂点を一度ずつ訪問して隣接リスト内の辺を訪問）
for _ in range(e):                 #関係性の数だけ
  s, t = map(int, input().split()) #始点と終点を入れる
  edge[s].append(t)                #sのお隣さんリストにtを
  edge[t].append(s)                #tのお隣さんリストにsを

group = [-1]*v                     #グループというリストを作る（こいつの値であとで友達か照合）
cnt = 0                            #グループ番号


#隣接リストに入っている同じエッジをスタックに入れてグループ化する
for i in range(v):
  if group[i] == -1:
    group[i] = cnt                 #カウントの値を入れる
    stack = [i]                    #エッジ番号を入れる
    while stack:
      v = stack.pop()              #エッジを代入　ー①
      for c in edge[v]:            #①のエッジのお隣さんリストを辿っていく
        if group[c] == -1:         #お隣さんのグループが初期化状態なら
          group[c] = cnt          #グループリストにカウントを入れる
          stack.append(c)          #スタックにお隣さんを入れる
    cnt += 1                       #お隣さんの訪問が終わったらグループ番号を変える

#クエリのコード
for _ in range(int(input())):
  s, t = map(int, input().split())
  print('yes' if group[s] == group[t] else 'no')



Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	static ll n,k,a[110],ans=0;
	cin>>n>>k;
	REP(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(k<a[i]){
			break;
		}
		if(i==n-1){
			if(k!=a[i])break;
		}
		k-=a[i];
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
pair < int , pair < int , int > > a[5005];
int dp[5005][5005], INF = 1e18;
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i].s.f >> a[i].s.s;
		a[i].f = a[i].s.f + a[i].s.s;
	}
	sort(a + 1 , a + n + 1);
	for(int i = 0; i <= n + 1; i++)
    	for(int j = 1; j <= n + 1; j++)
    	    dp[i][j] = INF;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++){
			dp[i][j] = dp[i - 1][j];
			if(dp[i - 1][j - 1] <= a[i].s.f)
			    dp[i][j] = min(dp[i][j]	, dp[i - 1][j - 1] + a[i].s.s);
		}
	}
	for(int i = n; i >= 0; i--){
		if(dp[n][i] < INF){
		        cout << i << endl;
		        return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 196096
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// 区間加算にも対応したBinary Index Tree(1-indexで使うことに気をつける)
template <class Abel> struct BIT {

    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    // 区間[a,b)にxを加算する(a, bは1-index)
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    // 区間[a,b)の総和を計算する(a, bは1-index)
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};

int main() {
    ll n, d, a;
    cin >> n >> d >> a;

    vector<P> p(n);
    rep(i, n) {
        ll x, h;
        cin >> x >> h;
        p[i] = make_pair(x, h);
    }
    sort(all(p));

    vl x(n), h(n);
    rep(i, n) {
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    
    BIT<ll> bit(n+10);
    rep(i, n) {
        bit.add(i+1, i+2, h[i]);  // bit[i]をh[i]で初期化
    }
    
    ll ans = 0;
    exrep(i, 1, n) {  // BITは1-indexで使う
        ll hp_i = bit.sum(i, i+1);  // モンスタiの体力
        if(hp_i <= 0) {  // モンスタiの体力が0以下の場合
            continue;  // モンスタiはおしまい
        }
        ll cnt = (hp_i + a - 1)/a;  // モンスタiを倒すのに必要な操作回数
        //　モンスタiのいる座標を左端とした爆発が届く範囲を求める
        ll right = x[i-1] + 2*d;  // 爆発が届く右端の座標
        ll id = upper_bound(all(x), right) - x.begin();  // 爆発が届かないモンスタの中で最も左にいるモンスタの番号 
        id++;
        bit.add(i, id, -a*cnt);  // モンスタiからモンスタid-1の体力をa*need減らす
        ans += cnt;
    }

    out(ans);
    re0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;
int main(){
  vector<int> x(5);
  REP(i, 5){
    cin >> x[i];
  }
  REP(i, 5){
    if(x[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int jug(string ptr){
	int f=1;
	int len=ptr.length();
	for(int i=0;i<ptr.length()/2;i++){
		if(ptr[i]==ptr[len-1-i]){
		}else{
			f=0;
		}
	}
	return f;
} 
int main(){
	string a,ptr;
	ptr=" ";
	cin>>a;
	int len=a.length();
	ptr=ptr+a;
	if(len%2!=0){
		int f=1;//输出的标志
		//一个是本身
		string a1=ptr.substr(1,(len-1)/2);
		string a2=ptr.substr((len+3)/2,len);
		string a3=a;
		if(jug(a3)&&jug(a1)&&jug(a2)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{//是偶数 
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
import sys
N=int(input())
A=list(map(int,input().split()))
c=1+N//2
ans=[-1 for _ in range(N+1)]
c_box=[]
total=0
b=[]
for i in range(c,N+1):
    ans[i]=A[i-1]
    if A[i-1]==1:
        c_box.append(i)
        total+=1
    
for i in range(c-1,0,-1):
    tmp=0
    for j in range(i*2,N+1,i):
        tmp+=ans[j]
    if tmp%2==0 and A[i-1]==0 or tmp%2==1 and A[i-1]==1:
        ans[i]=0
    elif tmp%2==1 and A[i-1]==0 or tmp%2==0 and A[i-1]==1:
        ans[i]=1
        c_box.append(i)
        total+=1
    else:
        print(-1)
        exit()
    
print(total)   
if total>0:
    print(" ".join(map(str,sorted(c_box))))
    
    
    
    


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

int main(){
	while(1){
		int k;
		long ans=0;
		
		scanf(" %d", &k);
		if(k==0) break;
		for(int i=0; i<k*(k-1)/2; ++i){
			int a;
			scanf(" %d", &a);
			ans += a;
		}
		
		printf("%ld\n", ans/(k-1));
	}	
	return 0;
}

Measured memory_bytes: 1188
INF=float("inf")
def main():
    H,W=map(int, input().split())
    A=[input()for _ in range(H)]
    D=[[0 if A[h][w]=="#" else INF for w in range(W)] for h in range(H)]
    for h in range(H):
        for w in range(1,W):
            D[h][w]=min(D[h][w],D[h][w-1]+1)
        for w in range(W-2, -1, -1):
            D[h][w]=min(D[h][w],D[h][w+1]+1)
    for w in range(W):
        for h in range(1,H):
            D[h][w]=min(D[h][w],D[h-1][w]+1)
        for h in range(H-2, -1, -1):
            D[h][w]=min(D[h][w],D[h+1][w]+1)
    print(max(d for dd in D for d in dd))

if __name__ == "__main__":
    main()

Measured memory_bytes: 98524
import java.util.Scanner;

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

		if (A!=2 && B !=2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22868
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
typedef pair <ll , ll> ii;
void in(ll &x);
const ll N = 5005;
ll n,k,nxt[N],price[N],ps[2 * N];
bool vis[N];
vector <ll> v[N];

void dfs(ll u , ll cur) {
   if (vis[u]) return;
   vis[u] = 1;
   v[cur].pb(price[u]);
   dfs(nxt[u] , cur);
   return;
}

ll rsum(ll l , ll r) {
   if (l > r) return 0;
   if (l == 0) return ps[r];
   return ps[r] - ps[l - 1];
}

int main() {
   in(n); in(k);
   for (ll u = 1, nn ; u <= n ; u++) {
      in(nn);
      nxt[u] = nn;
   }
   for (ll i = 1 ; i <= n ; i++) {
      in(price[i]);
   }
   ll idx = 0;
   for (ll u = 1 ; u <= n ; u++) {
      if (!vis[u]) {
         dfs(u , idx++);
      }
   }
   for (ll i = 0 ; i < idx ; i++) {
      ll vz = v[i].size();
      for (ll j = 0 ; j < vz ; j++) {
         v[i].pb(v[i][j]);
      }
   }
   ll sol = LLONG_MIN;
   for (ll i = 0 ; i < idx ; i++) {
      ll vz = v[i].size();
      ps[0] = v[i][0];
      for (ll j = 1 ; j < vz ; j++) {
         ps[j] = ps[j - 1] + v[i][j];
      }
      for (ll j = 0 ; j < vz ; j++) {
         for (ll len = 1 ; len <= min(vz / 2 , k) ; len++) {
            if (j + len - 1 >= vz) continue;
            sol = max(sol , rsum(j , j + len - 1));
         }
         if (k > vz / 2) {
            if (k % (vz / 2) == 0) {
               for (int len = 0 ; len <= vz / 2 ; len++) {
                  if (j + len - 1 >= vz) continue;
                  if (j + (vz / 2) - 1 >= vz) continue;
                  sol = max(sol , rsum(j , j + (vz / 2) - 1) * ((k / (vz / 2)) - 1) + rsum(j , j + len - 1));
               }
            } else {
               for (ll len = 0 ; len <= k % (vz / 2) ; len++) {
                  if (j + len - 1 >= vz) continue;
                  if (j + (vz / 2) - 1 >= vz) continue;
                  sol = max(sol , rsum(j , j + (vz / 2) - 1) * (k / (vz / 2)) + rsum(j , j + len - 1));
               }
            }
         }
      }
   }
   printf("%lld\n" , sol);
   return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 4168
#include <iostream>
#include <stack>

int main(){
	std::stack<int> st;

	int num = 0;
	while(std::cin >> num){
		if(num == 0){
			std::cout << st.top() << std::endl;
			st.pop();
		} else {
			st.push(num);
		}
	}
}

Measured memory_bytes: 3028
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int main(void) {
  lld n, m, c = 0, min, max;
  scanf("%lld%lld", &n, &m);
  for (lld i = m; i <= n + 1; i++) {
    min = (i - 1) * i / 2;
    max = n * i - min;
    c += max - min + 1;
    c %= 1000000007;
  }
  printf("%lld\n", c);
}

Measured memory_bytes: 1732
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int cnta = 0;
      	int cntb = 0;
      	int cntc = 0;
      	for(int i=0;i<3;i++){
        	if(S.charAt(i)=='a'){
            	cnta++;
            }else if(S.charAt(i)=='b'){
            	cntb++;
            }else if(S.charAt(i)=='c'){
            	cntc++;
            }
        }
      	if(cnta==1 && cntb ==1 && cntc==1){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> q.at(i);
    }
    vector<int> a(n);
    for(int i=0;i<n;i++){
        a.at(i) = i+1;
    }

    map<vector<int>,int> mp;
    do {
        mp[a] = mp.size();
    } while(next_permutation(a.begin() ,a.end()));
    int ans = abs(mp[p]-mp[q]);
    cout << ans << endl;

}

Measured memory_bytes: 5248
import sys
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

INF = 1 << 60
cost = [- INF] * (N + 1)
cost[1] = 0

for i in range(N):
    for n, nn, c in edge:
        if cost[nn] < cost[n] + c:
            # ワーシャルフロイド法の性質より、N回目に更新があるならinf
            if i == N - 1 and nn == N:
                print("inf")
                sys.exit()
            cost[nn] = cost[n] + c

print(cost[N])

Measured memory_bytes: 9348
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * (N + 1)
memo = {}
while pointer < len(queue):
    x, y, z = queue[pointer]
    # print(x, y, z)
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if q < N + 1:
        add = 1
        if x == y and y == z:
            add = 1
        elif x == y or y == z or z == x:
            add = 3
        else:
            add =6
        answers[q] += add

        if x+1>=y and y >=z and (x+1,y,z) not in memo:
            memo[(x+1,y,z)] = 0
            queue.append((x + 1, y, z))
        if x >= y +1 and y + 1 >= z and (x, y+1, z) not in memo:
            memo[(x,y+1,z)] = 0
            queue.append((x, y + 1, z))
        if x >= y and y >= z+1 and (x, y, z+1) not in memo:
            memo[(x,y,z+1)] = 0
            queue.append((x, y, z + 1))
    pointer += 1

        
for a in answers[1:N + 1]:
    print(a)


Measured memory_bytes: 18592
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
 
//#define int ll
 
typedef int64_t ll;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,0,1,-1}, dy4[4] = {1,-1,0,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) signed((a).size())
#define LEN(a) signed((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end());reverse((c).begin(),(c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

signed main(){
    int N;
    cin >> N;
    vector<int> A; 
    vector<int> B;
    REP(i,N){
        int x;
        scanf("%d",&x);
        A.PB(x);
        B.PB(x);
    }
    SORT(B);

    int M = B[N-1];
    B.erase(B.begin()+N-1);
    vector<int>::iterator it = LB(ALL(B),(M+1)/2);
    if(it==B.begin()){
        printf("%d %d\n",M,*it);
    } else if(it==B.end()){
        printf("%d %d\n",M,*(it-1));
    } else {
        auto it2 = it-1;
        int a;
        if(M%2){
            int m = M/2+1;
            int m2 = M/2;
            if(min(abs(m-*it),abs(m2-*it))>min(abs(m2-*it2),abs(m2-*it))) a = *it2;
            else a = *it;
        } else {
            int m = M/2;
            if(abs(m-*it)>abs(m-*it2)) a = *it2;
            else a = *it;
        }
        printf("%d %d\n",M,a);
    }

    return 0;
}








Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// #define pb push_back
// #define all(v) v.begin(), v.end()
// #define fi first
// #define se second
// #define bigger (char)toupper
// #define smaller (char)tolower
using namespace std;
// typedef pair<int, int> pii;
// typedef vector<int> vi;
// typedef vector<vi> vii;
typedef long long ll;
// typedef unsigned long long ull;

int main()
{
  int N, M;
  cin >> N >> M;
  bool *ac = new bool[N];
  int *pe = new int[N];

  for (int n = 0; n < N; n++)
  {
    ac[n] = false;
    pe[n] = 0;
  }

  for (int m = 0; m < M; m++)
  {
    int p;
    string S;
    cin >> p >> S;
    if (S[0] == 'A')
    {
      ac[p - 1] = true;
    }
    else if (ac[p - 1] == false)
    {
      pe[p - 1] += 1;
    }
  }

  int sac = 0;
  int spe = 0;
  for (int n = 0; n < N; n++)
  {
    if (ac[n])
    {
      sac++;
      spe += pe[n];
    }
  }

  cout << sac << " " << spe << endl;

  return 0;
}

Measured memory_bytes: 768
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize, c: usize
    }
    println!("{} {} {}", c, a, b);
}


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

int main(){
	
	int n,m;
	cin >> n >> m;
	int a[100][100];
	int b[100];
	int c[100];

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

	for(int j = 0; j < m; j++){
		cin >> b[j];
//		cout << endl;
	}

	for(int i = 0; i < n; i++){
		c[i] = 0;
		for(int j = 0; j < m; j++){
			c[i] += a[i][j] * b[j];
		}
	}

	for(int i = 0; i < n; i++){
		cout << c[i] << endl;
	}
	cin >> n >> m;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ln=s.size();
    int flag=0;
    for(int i=0,j=1; i<ln; i+=2,j+=2)
    {
        if(s[i]=='L' || s[j]=='R')
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<< "No\n";
    else
        cout<< "Yes\n";

}


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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a, b;
    cin >> a >> b;
    int tap   = 1;
    int count = 0;
    if (tap >= b) { cout << "0" << endl; return 0; }
    while (1) {
        tap = tap + (a - 1);
        count++;
        if (tap >= b) { break; }
    }
    cout << count << endl;

    return 0;
}


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

int main(){
  int n,m,a,i;
  cin >> n >> m;
  vector<int> broken(n+1,1);
  for(i=0;i<m;i++){
    cin >> a;
    broken.at(a)=0;
  }
  
  vector<ll> s(n+1,0);
  ll p=1000000007;
  s.at(0)=1;
  s.at(1)=1*broken.at(1);
  for(i=2;i<=n;i++){
    s.at(i)=(s.at(i-1)+s.at(i-2))%p*broken.at(i);
  }
  
  cout << s.at(n) << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, K;
int a[1111];
vec<int> cand;
int dp[1111111];
int use[44];

int cntt(int a) {
   int ret = 0;
   for (int x : cand) {
      if ((x & a) == a) {
         ret++;
      }
   }
   return ret;
}

signed main() {
   cin >> N >> K;
   rep (i, N) { cin >> a[i]; }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int mask = 0;

   for (int i = 40; i >= 0; i--) {
      if (cntt(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }

   cout << mask << endl;

   return 0;
}

Measured memory_bytes: 6640
#include<bits/stdc++.h>
using namespace std;
long long n,t,a[202020],b[202020],dp[55],ans;
vector<long long>v0;
vector<pair<long long,long long> >v1;
bool cmp(pair<long long,long long>a,pair<long long,long long>b)
{
	return (a.first-1)*b.second>a.second*(b.first-1);
}
int main()
{
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		if(a[i]==0)
		{
			v0.push_back(b[i]+1);
		}
		else
		{
			v1.push_back(make_pair(a[i]+1,b[i]+1));
		}
	}
	sort(v0.begin(),v0.end());
	sort(v1.begin(),v1.end(),cmp);
	for(int i=0;i<30;i++)
	{
		dp[i]=1e9+3;
	}
	dp[0]=1;
	for(int i=0;i<v1.size();i++)
	{
		for(int j=29;j>0;j--)
		{
			dp[j]=min(dp[j],dp[j-1]*v1[i].first+v1[i].second);
			if(dp[j]<0)
			{
				dp[j]=1e9+3;
			}
		}
	}
	for(int i=0;i<30;i++)
	{
		long long nw=dp[i]-1,cnt=i*1ll;
		if(nw>t)
		{
			continue;
		}
		if(v0.size()!=0)
		{
			int p=0;
			while(p<v0.size() && nw+v0[p]<=t)
			{
				nw+=v0[p];
				cnt++;
				p++;
			}
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 8560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const ll MOD = 1e9 + 7;
const int INF = 1e9 + 7;

#define DEBUG 1

ll dp[2055][2055];

int main() {

	
	ll n, m;
	cin >> n >> m;
	vector<int> s(n+10,0), t(m+10,0);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> t[i];
	}

	dp[0][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j] += dp[i][j];
				dp[i][j + 1] += dp[i][j];
				dp[i + 1][j] += MOD;
				dp[i][j + 1] += MOD;

				dp[i + 1][j] %= MOD;
				dp[i][j + 1] %= MOD;
			}
			else
			{
				dp[i + 1][j] += dp[i][j];
				dp[i][j + 1] += dp[i][j];
				dp[i + 1][j] += MOD;
				dp[i][j + 1] += MOD;

				dp[i + 1][j] %= MOD;
				dp[i][j + 1] %= MOD;

				dp[i + 1][j + 1] -= dp[i][j];
				dp[i + 1][j + 1] += MOD;
				dp[i + 1][j + 1] %= MOD;
			}
		}
	}

	

	cout << dp[n][m]%MOD << endl;



	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll a,b,x; cin>>a>>b>>x;
    if(x-a>=0&&a+b>=x) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC044
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Console.ReadLine();

            if (w.Length % 2 == 1)
            {
                Console.Write("No");
                return;
            }

            var dic = new Dictionary<char, int>();
            foreach (var c in w)
            {
                if (!dic.ContainsKey(c)) dic.Add(c, 0);
                dic[c]++;
            }

            var result = dic.All(pair => pair.Value % 2 == 0)
                ? "Yes"
                : "No";
            Console.Write(result);
        }
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  repz(i, 1, 10) {
    repz(j, 1, 10) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
//~ int const MOD = 1000000007;
int const MOD = 1000003;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
inline int add(int a, int b, int mod = MOD) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int mpow(int base, long long ex, int mod = MOD) {
  int res = 1;
  while (ex > 0) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
    ex >>= 1;
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return mpow(a, mod - 2, mod);
}
int32_t main() {

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

  vector<int> fac(MOD);
  fac[0] = 1;
  for (int i = 1; i < MOD; ++i) {
    fac[i] = mul(i, fac[i - 1]);
  }
  int q; cin >> q;
  while (q--) {
    int x, d, n, ans;
    cin >> x >> d >> n;
    if (x == 0) {
      cout << 0 << '\n';
      continue;
    }
    if (d == 0) {
      cout << mpow(x, n, MOD) << '\n';
      continue;
    }
    int b = MOD - x;
    int lim = mul(b, inv(d));
    if (n > lim) {
      ans = 0;
    } else {
      ans = mpow(d, n, MOD);
      int a = mul(x, inv(d));
      if (a + n - 1 < MOD) {
        ans = mul(ans, fac[a + n - 1]);
        ans = mul(ans, inv(fac[a - 1]));
      } else {
        ans = 0;
      }
    }
    cout << ans << '\n';
  }

  return 0;
}


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

int main()
{
   int a,b,c,d;
   cin >>a;
   cin >>b;
   c=(a*b);
   d=(c%2);
   if (d==0)
   {
     cout << "Even"<< endl;
   }
   else 
   {
     cout << "Odd"<< endl;
   }
   return 0;
}

Measured memory_bytes: 3484
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S;
	int K;
	cin >> K >> S;
	int len = S.size();
	if (len <= K)cout << S;
	else {
		rep(i, K)cout << S[i];
		cout << "...";
	}
}

Measured memory_bytes: 3624
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
#define deg_to_rad(deg)			(((deg)/180)*M_PI)
#define rad_to_deg(rad)			((rad*180)/M_PI)
#define prique(T)				priority_queue<T, vector<T>, greater<T>>

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<int, int> P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

int main()
{
	int N, i;
	cin >> N;

	vector<int> H(N);
	REP(i, N) cin >> H[i];
	
  	H[0]--;
	for (i = 0; i < N - 1; i++) {
		if (H[i] < H[i + 1]) {
			H[i + 1]--;
		}
	}
	
	bool res = true;
	for (i = 0; i < N - 1; i++) {
		if (H[i] > H[i + 1]) {
			res = false;
			break;
		}
	}

	if (res) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int[] p = new int[3];
        int[] j = new int[2];
        p[0] = stdIn.nextInt();
        p[1] = stdIn.nextInt();
        p[2] = stdIn.nextInt();
        j[0] = stdIn.nextInt();
        j[1] = stdIn.nextInt();
        Arrays.sort(p);
        Arrays.sort(j);
        System.out.println(p[0]+j[0]-50);
    }
}

Measured memory_bytes: 17176
import datetime

l = list(map(int, input().split()))
A = l[0]
B = l[1]
H = l[2]
M = l[3]
K = l[4]

m1 = A*60 + B
m2 = H*60 + M
delta = m2-m1 
answer = delta - K
print(answer)


Measured memory_bytes: 9396
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(8)<<x<<"\n";
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll mod1 = 2000000011;
ll mod2 = 2000000033;


ll rui1(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui1(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod1;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod1;
        }
        return number3;
    }
}

ll rui2(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui2(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod2;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod2;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[200005];
char s[500005];
//vector<ll> G[550010];


int main(){
    cin >> n;
    bool dame = false;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        if(x[i] % 2 == 0 && x[i] % 3 != 0 && x[i] % 5 != 0)dame = true;
    }
    if(dame){
        p("DENIED");
    }else{
        p("APPROVED");
    }
    return 0;
}











Measured memory_bytes: 2304
#define mod 1000000007
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=4e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
int st[4][2]={1,0,0,1,-1,0,0,-1};
int t,cas;
int k;
ll inv(ll a)
{
	return a==1?1:((mod-mod/a)*inv(mod%a))%mod;
}
ll c(ll a,ll b)
{
	if(a-b<b)b=a-b;
	ll u=1,d=1;
	for(ll i=0;i<b;i++)
	{
		u=(u*(a-i))%mod;
		d=(d*(i+1))%mod;
	}
	return (u*inv(d))%mod;
}
int main()
{
	ll m,n,cnt,ans,sum;
	while(~scanf("%lld%lld",&n,&m))
	{
		sum=0;
		ans=1;
		for(ll i=2;i*i<=m;i++)
		{
			if(m%i==0)
			{
				cnt=0;
				while(m%i==0)
				{
					cnt++;
					m/=i;
				}
				ans=(ans*c(cnt+n-1,n-1))%mod;
			}
		}
		if(m!=1)
		{
			ans=(ans*n)%mod;
		}
		printf("%lld\n",ans);
	}
}



Measured memory_bytes: 256