akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
  off;
  
  int t;
  //cin>>t;
  t=1;
  while(t--){  
    int a,b,t;
    cin>>a>>b>>t;
    double x=t+0.5;
     x/=a;
     cout<<b*floor(x)<<'\n';
  }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s;
  cin >> s;
  int mmax = -1;
  for (int i = 0; i < s.size(); ++i) {
    int start = 0;
    for (int j = i; j < s.size(); ++j) {
      if (s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T') start += 1;
      else break;
    }

    mmax = max(start, mmax);
  }

  cout << mmax << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
 
int main()
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int difx = tx-sx;
  int dify = ty-sy;
  REP(i,difx){
    cout << "R";
  }
  REP(i,dify){
    cout << "U";
  }
  REP(i,difx){
    cout << "L";
  }
  REP(i,dify){
    cout << "D";
  }
  cout << "D";
  REP(i,difx+1){
    cout << "R";
  }
  REP(i,dify+1){
    cout << "U";
  }
  cout << "L";
  cout << "U";
  REP(i,difx+1){
    cout << "L";
  }
  REP(i,dify+1){
    cout << "D";
  }
  cout << "R" << endl;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

for i in range(N):
    key = a[i]
    j = i-1
    while j>=0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = key
    for k in range(N):
        arra = ' '.join([str(n) for n in a])

    print(arra)



Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi adj[(int)2e5];
vi start((int)2e5);
vi len((int)2e5, -1);
pii intersect(int i, int j){
   if(len[i] == -1 && len[j] == -1)return mp(0, -1);
   if(len[i] == -1)return mp(start[j], len[j]);
   if(len[j] == -1)return mp(start[i], len[i]);
   if(start[i] % 2 != start[j] % 2)return mp(0, 0);
   int s = max(start[i],start[j]);
   int e = min(start[i] + len[i]*2 - 2, start[j] + len[j]*2 -2);
   if(e < s)return mp(0, 0);
   return mp(s, (e- s)/2 + 1);
}
void calc(int i, int k){
    //need to adjust the range for the child
    if(len[i] != -1)start[i]--,len[i]++;
    pii temp = intersect(i, k);
    if(len[i] != -1)start[i]++,len[i]--;
    start[k] = temp.first;
    len[k] = temp.second;
}
bool check(int cur, int P){
    for(int child: adj[cur]){
        if(child != P){
            if(check(child, cur))return true;
            calc(child, cur);
        }
    } 
//    cout << cur << " " << start[cur] << " " << len[cur]  <<endl;
    if(len[cur] == 0)return true;
    return false;
}
void dfs(int cur, int P){
    if(P != -1){
        int pval = start[P];
        if(len[cur] == -1)start[cur] = pval + 1;
        else{
            if(start[cur] < pval)start[cur] = pval -1;
            else start[cur] = pval+1;
        }
        len[cur] = 1;
    }
    for(int child: adj[cur]){
        if(child != P){
            dfs(child, cur);
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n;cin >> n;
    int x, y;
    FOR(i, n -1){
        cin >>x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int k;cin >> k;
    FOR(i, k){
        cin >>x >> y;
        start[x] = y;
        len[x] = 1;
    }
    if(check(1, -1))cout << "No";
    else{
        cout << "Yes" << endl;
        //assuming start[1] = 0 if not set otherwise the set value will be used
        len[1] = 1;
        dfs(1, -1);
        FOR1(i, n){
            cout << start[i] << endl;
        }
    }
}




Measured memory_bytes: 16512
import numpy as np
n,m=map(int,input().split())
post_b = 0
post_c = n
for i in range(m):
    b,c=map(int,input().split())
    if post_b < b:
        post_b = b
    if post_c > c:
        post_c = c

if (post_c - post_b + 1)<0:
    print("0")
else:
    print(post_c - post_b + 1)


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

const int N = 305;

int n, K, mod;
int f[N][N], c[N][N], prf[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> K >> mod; n++, K++;
	for (int i = 0;i <= n;++i){
		c[i][0] = 1;
		for (int j = 1;j <= i;++j) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
	}
	for (int i = 1;i <= n;++i) {
		for (int j = 1;j <= K;++j) {
			if (i == 1) f[i][j] = 1;
			else for (int k = 1;k < i;++k) {
				int cur = 1LL * c[i - 2][k - 1] * f[k][j] % mod;
				cur = 1LL * cur * prf[i - k][j - 1] % mod;
				f[i][j] = (f[i][j] + cur) % mod;
			} 
			prf[i][j] = (prf[i][j - 1] + f[i][j]) % mod;
		}
	}
	cout << f[n][K] << '\n';
}

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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  int amax = 0;
  int cnt = 0;
  rep(i,n) {
    cin >>a[i];
    if(a[i]>amax) {
      amax = a[i];
      cnt = 0;
    }
    if(a[i]==amax) cnt++;
  }
  int apmax = 0;
  rep(i,n){
    if(a[i]>apmax && a[i]!=amax) apmax = a[i];
  }
  rep(i,n){
    if(a[i]!=amax) cout << amax << endl;
    else if(a[i]==amax && cnt==1) cout << apmax << endl;
    else if(a[i]==amax && cnt>1) cout << amax << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int N,M;
vector<int> tonari[100010];
int ans[100010];


void solve(int ca){
    int a,b;
    cin>>N>>M;
    for (int i = 0; i < M; ++i) {
        cin>>a>>b;
        --a; --b;
        tonari[a].push_back(b);
        tonari[b].push_back(a);
    }

    memset(ans,-1,sizeof(ans));

    queue<int> q;
    ans[0]=0;
    q.push(0);
    while(!q.empty()){
        int n=q.front();
        q.pop();
        for(auto i:tonari[n]){
            if(ans[i]>=0) continue;
            ans[i]=n+1;
            q.push(i);
        }
    }

    cout<<"Yes"<<endl;
    for (int i = 1; i < N; ++i) {
        cout<<ans[i]<<"\n";
    }


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 10512
#include <stdio.h>

int CheckPattern(int n,int x)
{
	int i, j, k, count = 0;

	for (i = 1; i <= n; i++) {
		for (j = i + 1; j <= n; j++) {
			for (k = j + 1; k <= n; k++) {
				if ((i + j + k) == x) {
					count++;
				}
			}
		}
	}

	return count;
}

int main(void)
{
	int n, x, ans;

	while(1){
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) {
			break;
		}
		ans=CheckPattern(n, x);
		printf("%d\n", ans);
	}


	return 0;
	
}

Measured memory_bytes: 600
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char str1[101], str2[101];
	int n, tp = 0, hp = 0;
	cin >> n;
	while (n--) {
		cin >> str1 >> str2;
		if (strcmp(str1, str2) > 0) {
			tp += 3;
		} else if (strcmp(str1, str2) < 0) {
			hp += 3;
		} else {
			tp++; hp++;
		}
	}
	cout << tp << ' ' << hp << endl;
	return 0;
}

Measured memory_bytes: 1164
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion


	
static int a[100001];
static int c[100000];
	int main(void) {
		int n, i;

		scanf("%d\n", &n);
		for (i = 0; i < n; i++)
			scanf("%d", &a[i]);

		qsort(a, n, sizeof(int), i_asort);

		int j = 0; c[0] = 1;
		for (i = 0; i < n; i++) {
//			printf("%d ", a[i]);
			if (a[i] == a[i + 1])
				c[j]++;
			else {
				j++; c[j] = 1;
			}
		}
//		printf("j:%d\n", j);
//		for (i = 0; i < j; i++) 
//			printf("%d ", c[i]);
//		printf("\n");

		int ans = 0;
		for (i = 0; i < j; i++) {
			if (c[i] % 2) ans++;
		}

	printf("%d\n", ans);
	return 0;

}




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

int main(){
    int n,m;
    string dic[100000];
    string words[100000];
    map<string, string> mp;
    while(true){
        cin >> n;
        if(n==0){
            return 0;
        }
        string result = "";
        for(int i=0;i<n;i++){
            cin >> dic[i];
            cin >> mp[dic[i]];
        }
        cin >> m;
        for(int k=0;k<m;k++){
            cin >> words[k];
            for(int j=0;j<n;j++){
                if(words[k]==dic[j]){
                    words[k]=mp[dic[j]];
                    break;
                }
            }
            result = result + words[k];
            
        }
        cout << result << "\n";
    }
    return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

string to_str(ll n) {
  return to_string(n);
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int ans = 0;
  rep(i, N) {
    if (((i+1)%2 == 1) && (a[i]%2 == 1)) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[2] - '0') * 10 + (s[3] - '0');
    if(a >= 1 && a <= 12) {
        if(b >= 1 && b <= 12) {
            cout << "AMBIGUOUS";
        } else {
            cout << "MMYY";
        }
    } else {
        if(b >= 1 && b <= 12) {
            cout << "YYMM";
        } else {
            cout << "NA";
        }
    }
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

class Main{           
  
   public static void main(String[] args){
         Scanner sc = new Scanner(System.in);  
       
         HashSet<String> set = new HashSet<String>();
         
         int N = sc.nextInt();
         
         for(int i = 0;i < N;i++){
             set.add(sc.next());
         }
         
         int M = sc.nextInt();
         
         boolean flag = false;
         
         for(int i = 0;i < M;i++){
           String t = sc.next(); 
           if(!set.contains(t)){
               System.out.println("Unknown "  + t);
           }else{
               if(!flag){
                   System.out.println("Opened by " + t);
                   flag = !flag;
               }else{
                   System.out.println("Closed by " + t);
                   flag = !flag;
               }
           }       
         }
       
       
   }     
 }
  

        
        

Measured memory_bytes: 28248
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vi results;
  vi triangular{0};
  for (int i = 1 ; triangular[i-1] <= 1000 ; i++) {
    triangular.push_back(triangular[i-1] + i);
  }

  while(true) {
    int n;
    cin >> n;
    if (n==0) { break; }
    int pattern = 0;
    int max_number = distance(triangular.begin(), upper_bound(triangular.begin(), triangular.end(), n)) - 1;

    for (int number = 2 ; number <= max_number ; number++) {
      if (number % 2 == 1 && n % number == 0 && n/number - number/2 > 0) {
        pattern += 1;
        continue;
      }
      if ((number % 2) == 0 && n%number == number/2 && n/number - number/2 >= 0) {
        pattern += 1;
      }
    }
    results.push_back(pattern);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

Measured memory_bytes: 3080
import sys

input = sys.stdin.readline


def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))

    x.insert(0, 0)

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[N][j][A * j]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 58484
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long 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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(void){
    ll n;
    cin >> n;
    mint all=10,a=9,a09=8;
    cout << all.pow(n)-a.pow(n)*2+a09.pow(n);
    return 0;
}

Measured memory_bytes: 3608
N,X = list(map(int,input().split()))
x = list(map(int,input().split()))

def gcd(x,y):
    if x > y:
        x, y = y, x
    d = 0
    while(True):
        if y % x == 0:
            return x
        else:
            d = x
            x = y % x
            y = d

ans = abs(x[0] - X)
for i in range(1, N):
    ans = gcd(ans, abs(x[i] - X))
print(ans)


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


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll ans=0;
  rep(i,n-1) {
    for(int j=i+1; j<n; j++) {
      if(a[i]>a[j]) ans+=(ll)(k+1)*k/2%MOD;
      ans%=MOD;
    }
  }
  rep(i,n) {
    for(int j=0; j<i; j++) {
      if(a[i]>a[j]) ans+=(ll)k*(k-1)/2%MOD;
      ans%=MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int oh, fh, th;
  int num, kin;

  cin >> num >> kin;
  
  for(int i = 0; i <= num; i++){
    for(int j = 0; j <= num; j++){
      for(int k = 0; k <= num; k++){
        if(i+j+k > num) break;
        if(i*1000 + j*5000 + k*10000 == kin){
          if(i+j+k == num){
            cout << k << " " << j << " " << i;
            return 0;
          }else if(i+j+k > num) break;
        }
      }
      if(i+j > num) break;
    }
  }
  
  cout << -1 << " " << -1 << " " << -1;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vi32> cnt(n + 1, vi32(n + 1));
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    l -= 1;
    cnt[l][r] += 1;
  }
  vector<vi32> sums(n + 1, vi32(n + 1));
  reps(s, n) rep(i, n) {
    int r = i + 1;
    if (r - s >= 0) sums[s][i + 1] += cnt[r - s][r];
    sums[s][i + 1] += sums[s][i];
  }
  vector<vi32> ans(n + 1, vi32(n + 1));
  rep(l, n) repic(r, l + 1, n) reps(s, r - l) {
    ans[l][r] += sums[s][r] - sums[s][l + s - 1];
  }
  rep(qi, q) {
    int p, q;
    cin >> p >> q;
    p--;
    cout << ans[p][q] << endl;
  }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s; cin>>s;
  	int count=0;
  	for (int i=0;i<3;i++){
    	if(s.at(i)=='1'){
        	count++;
        }
    }
  	cout<<count<<endl;
}

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

int dp[105][4][2];

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int K;
	cin >> K;
	dp[0][0][0] = 1;
	rep(i, n)rep(j, 4)rep(k, 2) {
		int tmp = s[i] - '0';
		rep(d, 10) {
			int ni = i + 1, nj = j, nk = k;
			if (d != 0) nj++;
			if (nj > K) continue;
			if (k == 0) {
				if (tmp > d) nk = 1;
				if (tmp < d) continue;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	cout << dp[n][K][0] + dp[n][K][1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  double N, M, D;
  cin >> N >> M >> D;
  
  if(D==0) {
    printf("%.10f\n", (M-1)/N);
  }else {
    printf("%.10f\n", (N-D)*2*(M-1)/(N*N));
  }
  
}







Measured memory_bytes: 768
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    cin>>x>>n;
    if(500*x >= n) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

int main(){
  string S; cin >> S;
  int ans;
  if(S=="SUN"){
    ans=7;
  }else if(S=="MON"){
    ans=6;
  }else if(S=="TUE"){
    ans=5;
  }else if(S=="WED"){
    ans=4;
  }else if(S=="THU"){
    ans=3;
  }else if(S=="FRI"){
    ans=2;
  }else{
    ans=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  std::cout << setprecision(20) << fixed;
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
  dp[0][0] = 1.0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i + 1][j + 1] += dp[i][j] * p[i];
      dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
    }
  }

  double ans = 0;
  for (int i = n / 2 + 1; i <= n; i++) {
    ans += dp[n][i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(){
int n,m,l;
cin>>n>>m>>l;
 int a[100][100];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) cin>>a[i][j];

int b[100][100];
for(int i=0;i<m;i++)
for(int j=0;j<l;j++) cin>>b[i][j];
long long c[100][100] = {};
for(int i=0;i<n;i++)
for(int j=0;j<l;j++)
for(int k=0;k<m;k++) c[i][j] += a[i][k] *b[k][j];

for(int i=0;i<n;i++){
for(int j=0;j<l;j++){
if(j) cout<<" ";
cout<<c[i][j];
}
cout<<endl;
}return 0;
}


Measured memory_bytes: 3244
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	ll ile = (n / 500) * 1000;
	n %= 500;
	ile += (n / 5)	* 5;
	cout << ile << endl;
	return 0;
}
 


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

int N, p[5009], x[5009], dp[5009], dp2[5009], dpv[5009]; vector<int>X[5009]; bool flag = false;

void dfs(int pos) {
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i]);
	for (int i = 0; i < 5009; i++) { dp2[i] = (1 << 29); dpv[i] = (1 << 29); }dp2[0] = 0;
	for (int i = 0; i < X[pos].size(); i++) {
		for (int j = x[X[pos][i]]; j < 5009; j++) { dpv[j] = min(dpv[j], dp2[j - x[X[pos][i]]] + dp[X[pos][i]]); }
		for (int j = dp[X[pos][i]]; j < 5009; j++) { dpv[j] = min(dpv[j], dp2[j - dp[X[pos][i]]] + x[X[pos][i]]); }
		for (int j = 0; j < 5009; j++) { dp2[j] = dpv[j]; dpv[j] = (1 << 29); }
	}
	int minx = (1 << 30); for (int i = 0; i <= x[pos]; i++) minx = min(minx, dp2[i]);
	dp[pos] = minx; if (minx == (1 << 29)) flag = true;
}

int main() {
	cin >> N;
	for (int i = 2; i <= N; i++) { cin >> p[i]; X[p[i]].push_back(i); }
	for (int i = 1; i <= N; i++) cin >> x[i];
	dfs(1);
	if (flag == false) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

ll arr[300010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vector<ll> a(3*N);
    REP(i,3*N) cin >> a[i];
    {
      priority_queue<ll, vector<ll>, greater<ll>> q;
      
      ll mx = 0;
      for(int i=0; i<N; i++){
        q.push(a[i]);
        mx += a[i];
      }
      arr[N-1] = mx;
      for(int i=N; i<2*N; i++){
        q.push(a[i]);
        ll mi = q.top();
        q.pop();
        mx -= mi;
        mx += a[i];
        arr[i] = mx;
      }
    }

    ll ans = 0;
    {
      priority_queue<ll> q;
      ll mi = 0;
      for(int i=2*N; i<3*N; i++) {
        q.push(a[i]);
        mi += a[i];
      }
      ans = arr[2*N-1] - mi;

      for(int i=2*N-1; i>=N; i--){
        q.push(a[i]);
        ll mx = q.top();
        q.pop();
        mi -= mx;
        mi += a[i];
        ans = max(ans, arr[i-1] - mi);
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8152
import java.util.Scanner;

public class Main{
	static int co=0;
	static int K;
	static boolean ok = false;
	static long ans = 0;
	
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			 K= scan.nextInt();
			
			int count=0;
			int keta = 0;
		
			
			do {
				keta++;
				
				for(int i = 1;i<=9;i++) {
					po(i,keta,""+i+"");
				}
			}while(ok==false);
			
			
			
			
		}
		
		
	}
	
	
	private static void po(int n,int count,String s) {
		
		if(count==1) {
			co++;
			//System.out.print(s);
			//System.out.print(" ");
			//System.out.println(co);
			if(K==co) {
				ans = Long.valueOf(s);
				ok=true;
				System.out.println(ans);
				
			}
			
		}else {
			if(n==0) {
				po(n,count-1,s+""+n+"");
				po(n+1,count-1,s+""+(n+1)+"");
			}else if(n==9) {
				po(n-1,count-1,s+""+(n-1)+"");
				po(n,count-1,s+""+n+"");
				
			}else{
				po(n-1,count-1,s+""+(n-1)+"");
				po(n,count-1,s+""+n+"");
				po(n+1,count-1,s+""+(n+1)+"");
			}
		}
		
		
	}
		

}

Measured memory_bytes: 43644
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;
    if (B%A == 0) cout << A+B << endl;
    else cout << B-A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,M; cin >> N >> M;
    int count[M];
    REP(i,M)
    {
        count[i] = 0;
    }
    REP(i,N)
    {
        int tmp;
        cin >> tmp;
        REP(j,tmp)
        {
            int food;
            cin >> food;
            dump(food)

            count[food-1]++;
        }
    }
    int ans = 0;
    REP(i,M)
    {
        dump(count[i])
        if(count[i] == N) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.*;

public class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        BigDecimal base = new BigDecimal("1");
//        long m = (long) Math.pow(10,18);
//        BigDecimal mm = new BigDecimal(m);
//
//        for (int i = 0;i<n;++i)
//        {
//            BigDecimal a = sc.nextBigDecimal();
//            //System.out.println(base+" * "+a);
//            base = a.multiply(a);
//            if (base.compareTo(mm) > 0)
//            {
//                base = new BigDecimal(-1);
//                break;
//            }
//        }
//
//        System.out.println(base);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        BigDecimal ans = a.multiply(b);
        System.out.println(ans.setScale(0,BigDecimal.ROUND_DOWN));

        sc.close();
    }
}

Measured memory_bytes: 37536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b == 15){
        cout << "+" << endl;
    }else if(a * b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val array = Array(n, {0})
    for(i in 0..n-1){
        array[i] = scanner.nextInt()
    }
    array.sort()
    val index = array.size/2-1
    if(array[index] === array[index+1]) {
        println(0)
        return
    }
    println(array[index+1]-array[index])
}

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

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

    int p[n], q[n];

    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];

    int pNum = 0;
    int qNum = 0;

    int v[n];
    for(int i = 0; i < n; i++) v[i] = i + 1;

    int num = 1;
    do {
        if(equal(p, p + n, v)) pNum = num;
        if(equal(q, q + n, v)) qNum = num;
        num++;
    } while(next_permutation(v, v + n));
  
    cout << abs(pNum - qNum) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
 
ans = 'No'
for i in range(N-2):
  if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
    ans = 'Yes'
    break
    
print(ans)

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  for(int i=1;i<=150;i++){
    if(a*i%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main() {
	int n,b_1=0,b_2=0,b_4=0;
	long long int input;
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> input;
		if(input%4==0){
			b_4++;
		}else if(input%2==0){
			b_2++;
		}else{
			b_1++;
		}
		
	}
	
	if(b_2==0){
		if(b_1<=b_4+1){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}else{
		if(b_1<=b_4){
			cout << "Yes";
		}else{
			cout << "No";
		}
	}
	
	
	return 0;
}

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

typedef long long ll;

const int MAX_N = 2e5+5;

int n;
ll a[MAX_N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0LL;
    ll prv = 0LL;

    for (int i = 1; i <= n; i++) {
        if (a[i] >= prv) {
            prv = a[i];
            continue;
        }
        ans += prv - a[i];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5180
/* ITP1_2_B */

import java.io.*;
import java.util.*;

public class Main {
  public static void main (String[] args) throws java.lang.Exception {
    // 入力された値をゲット
   Scanner sc = new Scanner(System.in);

   int a = sc.nextInt();  // 1個目をaにセット
   int b = sc.nextInt();  // 1個目をbにセット
   int c = sc.nextInt();  // 1個目をcにセット

   if((a < b) && (b < c)) {
       System.out.println("Yes");
   } else {
       System.out.println("No");
   }
 }
}



Measured memory_bytes: 26148
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

vector<string> ans;

void fun(string s, int k, int dist, int n) {
	if (k == n) {
		ans.push_back(s);
	}
	else {
		for (int i = 0; i < dist; ++i) {
			string temp = s + (char)('a' + i);

			if (i == dist - 1) {
				fun(temp, k + 1, dist + 1, n);
			}
			else {
				fun(temp, k + 1, dist, n);
			}
		}
	}

	return;
}

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

	string s = "a";

	fun(s, 1, 2, n);

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

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

	return 0;
}

Measured memory_bytes: 7796
#include <stdio.h>

#define N 5

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    unsigned int f = 0;
    int d[ N ];

    for ( i = 0; i < N; ++i )
    {
      scanf ( "%d", d + i );
      if ( !d[ i ] )  goto BREAKK;
      f |= 1 << ( d[ i ] - 1 );
    }

    for ( i = 0; i < 5; ++i )
    {
      if ( f == 0x01 || f == 0x02 || f == 0x04 || f == 0x07 )
      {
        puts ( "3" );
      }
      else
      {
        printf ( "%d\n", 2 - !!( f & ( 1 << ( d[ i ] % 3 ) ) ) );
      }
    }
  }
BREAKK:

  return ( 0 );
}

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

using namespace std;
long long int n,dau = 1,cuoi = -1,K,giua,k; long long int a[10000001];
bool check ( int M)
{
   long long int sl= 0;
    for (long long int i = 1;i <=n;i++)
    {
        sl += a[i]/M;
        if ( a[i] % M ==0)
        {
            sl--;
        }
    }
    return sl<= K;
}

int main()
{
//freopen("test.inp","r",stdin);
    cin >> n >> K;
    for (long long int i = 1;i <= n;i++)
    {
        cin >> a[i];
        cuoi = max(cuoi,a[i]);
    }
    while (dau <= cuoi)
    {
        giua = (dau +cuoi)/2;
        if (check(giua) == true)
        {
            k = giua;
            cuoi = giua -1;
        }
        else
        {
            dau= giua+1;
        }
    }
    cout <<k << endl;
    return 0;
}


Measured memory_bytes: 5112
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	unsigned long long int a, b,x; cin >> a >> b>>x;
	unsigned long long int count = 0;
	
	unsigned long long int ans = b / x - a / x;
	if (a%x == 0)ans++;
	cout << ans << endl;
}


    

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int h, w;
    cin >> h >> w;
    string s;
    for(int i = 0; i < h; i++){
        cin >> s;
        cout << s << endl << s << endl;
    }
    return 0;
}


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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 1; i < s.length(); i++) {
    ans += (s[i-1] != s[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main(){
    int N;
    scanf("%d",&N);
    char S[10101];
    getchar();
    scanf("%[^\n]", S);
    
    for (int i = 0; S[i] != '\0'; i++){
        if(S[i] >= 'A' && S[i] <= 'Z'){
            S[i] += N;
            if(S[i] > 90){
                S[i] -= 26;
            }
            printf("%c",S[i]);
        }
    }
	return 0;
}

Measured memory_bytes: 1648
package main

import (
	"fmt"
	"sort"
)

var ws = []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)

	as := make([]int, m)

	for i := range as {
		fmt.Scanf("%d", &as[i])
	}

	DP := make([]int, n+1)

	for i := 1; i < len(DP); i++ {
		var k = -1000
		for _, j := range as {
			if i-ws[j] < 0 {
				continue
			}
			y := DP[i-ws[j]]
			if k < y {
				k = y
			}
		}
		DP[i] = k + 1
	}

	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	ret := make([]int, 0, DP[n])
L:
	for _, a := range as {
		for {
			if n-ws[a] < 0 {
				break
			}
			if DP[n-ws[a]] == DP[n]-1 {
				ret = append(ret, a)
				n -= ws[a]
			} else {
				continue L
			}
		}
	}
	for _, i := range ret {
		fmt.Print(i)
	}
	fmt.Println()
}

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

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

    if(a==b&&b==c&&a==c){
        cout<<1<<endl;
    }

    else if (a==b||b==c||a==c) {
        cout<<2<<endl;

    }
    else {
        cout<<3<<endl;
    }
}


Measured memory_bytes: 256