akhauriyash/Code-Regression huggingface dataset:
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W;
  cin >> H >> W;
  int64_t start_r, start_c;
  cin >> start_r >> start_c;
  start_r--, start_c--;
  int64_t goal_r, goal_c;
  cin >> goal_r >> goal_c;
  goal_r--, goal_c--;

  vector<vector<bool>> is_open(H, vector<bool>(W, false));
  for (int64_t r = 0; r < H; ++r) {
    string s;
    cin >> s;
    for (int64_t c = 0; c < W; ++c) {
      if (s[c] == '.') {
        is_open[r][c] = true;
      }
    }
  }

  // BFS preparation
  // First=row(y), Second=col(x)
  deque<Pair> q;
  vector<vector<int64_t>> distances(H, vector<int64_t>(W, kInf));
  auto UpdateFront = [&](const Pair target, const int64_t distance) -> void {
    if (distance < distances[target.first][target.second]) {
      distances[target.first][target.second] = distance;
      q.emplace_front(target);
    }
  };
  auto UpdateBack = [&](const Pair target, const int64_t distance) -> void {
    if (distance < distances[target.first][target.second]) {
      distances[target.first][target.second] = distance;
      q.emplace_back(target);
    }
  };

  // BFS
  // First=row(y), Second=col(x)
  UpdateFront(Pair(start_r, start_c), 0);
  while (!q.empty()) {
    const Pair target = q.front();
    q.pop_front();
    for (int64_t next_row = target.first - 2; next_row <= target.first + 2;
         ++next_row) {
      for (int64_t next_col = target.second - 2; next_col <= target.second + 2;
           ++next_col) {
        if (next_row >= 0 && next_row < H && next_col >= 0 && next_col < W &&
            is_open[next_row][next_col]) {
          const int64_t mdist =
              abs(next_col - target.second) + abs(next_row - target.first);
          if (mdist == 0) {
            // DO NOTHING
          } else if (mdist <= 1) {
            UpdateFront(Pair(next_row, next_col),
                        distances[target.first][target.second]);
          } else {
            UpdateBack(Pair(next_row, next_col),
                       distances[target.first][target.second] + 1);
          }
        }
      }
    }
  }

  if (distances[goal_r][goal_c] == kInf) {
    cout << -1 << endl;
  } else {
    cout << distances[goal_r][goal_c] << endl;
  }
  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a+b==3) cout << 3 << endl;
  if(a+b==4) cout << 2 << endl;
  if(a+b==5) cout << 1 << endl;
  return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int i = 1; i <= N; i++) {
		double p = 1./N;	
		int s = i;
		while (s < K) {
			s *= 2;
			p *= 0.5;
		}
		ans += p;
	}
	cout << setprecision(12) << ans << endl;

	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>

using namespace std;

int N,Y;
int flag = 0;
int i,j,k;

int main(void){
    cin >> N >> Y;

    //10000 5000 1000
    for(i = 0; i < N+1; i++){
        for(j = 0; j+i < N+1; j++){
            if(10000*i+5000*j+1000*(N-i-j) == Y){
                flag=1;
                break;
            }
        }
        if(flag) break;
    }

    if(flag){
        cout << i << ' '<< j << ' '<< N-i-j <<endl; 
    }else{
        cout << -1 << ' '<< -1 << ' '<< -1 <<endl;
    }
}

Measured memory_bytes: 256
use std::io::{stdin, Read};

fn main() {
    let mut N = String::new();
    stdin().read_line(&mut N);
    let N = N.trim().parse::<i32>().unwrap();
    fn S(N: i32) -> i32 {
        let mut a = N;
        let mut r = 0;
        while a > 0 {
            r += a % 10;
            a /= 10;
        }
        r
    }

    println!("{}", if N % S(N) == 0 { "Yes" } else { "No" });
}


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

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

  for(int x=0; x<=N; x++) {
    for(int y=0; (x+y)<=N; y++) {
      int z = N-x-y;
      if((10000*x+5000*y+1000*z)==Y) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 100020
#define ll long long
char S[N],T[N];
int gcd(int x,int y) {return y?gcd(y,x%y):x;}
int main()
{
	int n,m;ll ans;
	scanf("%d%d%s%s",&n,&m,S+1,T+1);
	ans=1ll*n/gcd(n,m)*m;
//	if (S[1]!=T[1]) return !printf("-1");
	for (ll i=0;i<n;++i)
		if (i*m%n==0&&S[i+1]!=T[i*m/n+1]) return !printf("-1");
	printf("%lld",ans);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int64_t> L(n + 1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i < n + 1; i++)
		L[i] = L[i - 1] + L[i - 2];
	cout << L[n] << endl;
}


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

using namespace std;

int
main()
{
  long long N;
  cin >> N;

  long long m = sqrt(N);

  while (N % m) {
    --m;
  }
  
  cout << floor(log10(N / m)) + 1 << "\n";
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;

int n;
char s[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> s + 1;
    n = strlen(s + 1);
    if(s[1] == '0' || s[n] == '1') {cout << -1; return 0;}
    for(int i = 1; i < n; i++) if(s[i] != s[n - i]) {
        cout << -1; return 0;
    }
    s[n] = '1';
    int rt = 1;
    for(int i = 2; i <= n; i++) if(s[i] == '1') {
        cout << i << ' ' << rt << '\n';
        for(int j = rt + 1; j < i; j++) cout << i << ' ' << j << '\n';
        rt = i;
    }
    return 0;
}


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

bool IsPrime(long long num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (long long i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      return false;
    }
  }

  return true;
}

long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main()
{
  long long A, B; cin >> A >> B;
  long long C = gcd(A, B);
  long long ans = 1;

  for (int i = 2; i < sqrt(C) + 3; i++) {
    if (C % i == 0) {
      ans++;
      do
      {
        C /= i;
      } while (C % i == 0);
    }
  }
  if (C != 1) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
//				.-/+oossssoo+/-.    										
//        `:+ssssssssssssssssss+:`          
//      -+ssssssssssssssssssyyssss+-        
//    .ossssssssssssssssssdMMMNysssso.      
//   /ssssssssssshdmmNNmmyNMMMMhssssss/     
//  +ssssssssshmydMMMMMMMNddddyssssssss+    
// /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/   	
//.ssssssssdMMMNhsssssssssshNMMMdssssssss.  
//+sssshhhyNMMNyssssssssssssyNMMMysssssss+  						
//ossyNMMMNyMMhsssssssssssssshmmmhssssssso  
//ossyNMMMNyMMhsssssssssssssshmmmhssssssso
//+sssshhhyNMMNyssssssssssssyNMMMysssssss+
//.ssssssssdMMMNhsssssssssshNMMMdssssssss.
// /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
//  +sssssssssdmydMMMMMMMMddddyssssssss+
//   /ssssssssssshdmNNNNmyNMMMMhssssss/
//    .ossssssssssssssssssdMMMNysssso.
//      -+sssssssssssssssssyyyssss+-
//        `:+ssssssssssssssssss+:`
//            .-/+oossssoo+/-.
//
//
//
//..............                                     
//            ..,;:ccc,.                             
//          ......''';lxO.                                                      
//           .';;;:::;,,.x,                          
//      ..'''.            0Xxoc:,.  ...              
//  ....                ,ONkc;,;cokOdc',.            
// .                   OMo           ':ddo.          
//                    dMc               :OO;         
//                    0M.                 .:o.       
//                    ;Wd
//                     ;XO,
//                       ,d0Odlc;,..
//                           ..',;:cdOOd::,.
//                                    .:d;.':;.
//                                       'd,  .'
//                                         ;l   ..
//                                          .o
//                                            c
//                                            .'
//                                             .

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>

//using namespace __gnu_pbds;
using namespace std;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

//int ans1[3][3], ans2[3][3], a, b, c , d;

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

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	char ans1[n], ans2[n];
	for(int i= 0;i<n;i++){
		ans1[i] = s[i];
		ans2[i] = t[i];
	}
	for(int i = 0;i<n;i++){
		cout << ans1[i] << ans2[i];
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;
    int n = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pii>> edges(3 * n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].emplace_back(n + v, 1);
        edges[n + u].emplace_back(2 * n + v, 1);
        edges[2 * n + u].emplace_back(v, 1);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    vi dist = dijkstra(s, edges);
    if (dist[t] == numeric_limits<int>::max())
        cout << -1 << "\n";
    else
        cout << dist[t] / 3 << endl;
    return 0;
}

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

int main()
{
int a , b;
cin>>a>>b;
int r=0;
for( int i = a ; i <= b ; i++)
{
int s = i % 10, t = i / 10000 % 10;
int u = i / 10 % 10 , v = i / 1000 %  10;
if ( s == t&&u == v ) r++;

}
cout <<r<<endl;
}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC\n";
    else cout<<"ABC\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 4001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

  int N, K;
  cin >> N >> K;
  vector<LLP> p(N);
  rep(i,N) cin >> p[i].first >> p[i].second;

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

  ll ans = LINF;

  for (int i = 0; i < N; i++) {
    for (int j = i + K - 1; j < N; j++) {
      vector<ll> y;
      for (int k = i; k <= j; k++) y.push_back(p[k].second);
      sort(y.begin(), y.end());
      for (int k = 0; k + K - 1 < y.size(); k++) {
        ll area = (p[j].first - p[i].first) * (y[k + K - 1] - y[k]);
        ans = min(ans, area);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
N, X, T = map(int, input().split())
C= 1
ch = X
if X > 1:
    while True:
        value = int(N / X)
        re = N % X
        if re == 0:
            C = value
            Time= T * C
            break
        else:
            C += value
            Time = T * C
            break
else:
    Time = T * N

print(Time)

Measured memory_bytes: 9092
int main(void)
{
  int kazu;
  int suchi[10001];
  int i;
  long min, max, sum;
 
  scanf("%d", &kazu);
   
  for(i = 0;i < kazu;i++){
    scanf("%d", &suchi[i]);
  }
 
  min = 1000000;
  for(i = 0;i < kazu;i++){
    if(min > suchi[i]){
      min = suchi[i];
    }
  }
 
  max = -1000000;
  for(i = 0;i < kazu;i++){
    if(max < suchi[i]){
      max = suchi[i];
    }
  }
 
  sum = 0;
  for(i = 0;i < kazu;i++){
    sum += suchi[i];
  }
 
  printf("%ld %ld %ld\n", min, max, sum);
 
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int n,capacity;
int w[101],p[101];
long long dp[101][100001];
long long func(int i,int weight)
{
    if(i>n)return 0;
    if(dp[i][weight]!=-1)return dp[i][weight];
    long long ans1=0,ans2=0;
    if(weight+w[i]<=capacity)ans1=p[i]+func(i+1,weight+w[i]);
    else ans1=func(i+1,weight);
    ans2=func(i+1,weight);
    return dp[i][weight]=max(ans1,ans2);
}
int main()
{
      std :: ios :: sync_with_stdio(false);
      cin>>n>>capacity;
      for(int i=1;i<=n;i++)cin>>w[i]>>p[i];
      memset(dp,-1,sizeof(dp));
      long long ans=func(1,0);
      cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 79232
N = int(input())
A = list(int(i) for i in input().split())
A_dict ={}
ans_bool =True
for x in A:
    if x in A_dict:
        ans_bool =False
        break
    else:
        A_dict[x] =1
if ans_bool ==True:
    print('YES')
else:
    print("NO")

Measured memory_bytes: 32944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] ab=reader.readLine().split(" ");
        List<Integer> nums=new ArrayList<Integer>();
        for(int i=0;i<5;i++){
        	nums.add(Integer.parseInt(ab[i]));
        }
        int W=nums.get(0);
        int H=nums.get(1);
        int x=nums.get(2);
        int y=nums.get(3);
        int r=nums.get(4);
        
        if(x<r||x>(W-r)){
    		System.out.println("No");
        }else if(y<r||y>(H-r)){
    		System.out.println("No");
        }else{
    		System.out.println("Yes");
        }
	}
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  int n, k; cin >> n >> k;
  vector<ll> dp(n, linf);
  vector<int> h(n);

  rep(i, n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for(int i = 2; i < n; i++){
    for(int j = 1; j <= k; j++){
      if(i - j >= 0)
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }

  pr(dp[n - 1]);

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    int l;
    cin >> l;
    vector<vector<int>> dbl(21, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        int ni = upper_bound(begin(x), end(x), x[i] + l) - begin(x) - 1;
        dbl[0][i] = ni;
    }
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < n; j++) {
            dbl[i + 1][j] = dbl[i][dbl[i][j]];
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b, a--, b--;
        if (a > b) swap(a, b);
        int cur = a;
        int ans = 0;
        for (int i = 20; i >= 0; i--) {
            if (dbl[i][cur] >= b) continue;
            cur = dbl[i][cur];
            ans += 1 << i;
        }
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 9464
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,m;
  cin >> n >> m;

  vector<ll> a(n,-1),s(m),c(m);

  rep(i,m)
  {
    cin >> s[i] >> c[i];
  }

  ll buf = (n == 1) ? 0 : pow(10,n-1);
  ll buf2 = pow(10,n);
  bool flg2 = false;
  ll ans = LLONG_MAX;
  for(ll i = buf;i < buf2; i++)
  {
    bool flg = true;
    string ss = to_string(i);
    
    rep(j,m)
    {
      if(stol(ss.substr(s[j] - 1,1)) != c[j])
      {
        flg = false;
      }
    }

    if(flg)
    {
      cout << i << endl;
      return 0;      
    }  
  }

  cout << -1 << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d",n)
int main()
{
    int n;
    cin>>n;
    if(n<1000)
        cout<<"ABC"<<el;
    else
        cout<<"ABD"<<el;


    return 0;
}


Measured memory_bytes: 256
#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>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,d;
    cin>>n>>d;
    double x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    int cnt=0;
    rep(i,n){
        if(sqrt(pow(x[i],2)+pow(y[i],2))<=d){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 6984
#include<iostream>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string a;
    cin>>a;
    int b[150] = {0};
    int c=0;
    rep(i,a.size()){
        ++b[a[i]];
        if(b[a[i]] > 1){
            c=1;
            break;
        }
    }
    if(c==0)cout<<"yes";
    else cout<<"no";
}

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

int main() {
	char a[50];

	int c,b;
	cin >> c >> b;
	cin >> a;

	if (a[b - 1] == 'A')a[b - 1] = 'a';
	if (a[b - 1] == 'B')a[b - 1] = 'b';
	if (a[b - 1] == 'C')a[b - 1] = 'c';


	cout << a << "\n";



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int sg[N];
vector<int> g[N];
int n;
void DFS(int u,int fr){
    for(int i:g[u])
        if(i!=fr)
            DFS(i,u),sg[u]^=sg[i];
    sg[u]+=u!=1;
}
int main(){
    scanf("%d",&n);
    for(int i=2,f,t;i<=n;i++) scanf("%d%d",&f,&t),g[f].push_back(t),g[t].push_back(f);
    DFS(1,0);
    puts(sg[1]==0? "Bob":"Alice");
    return 0;
}

Measured memory_bytes: 12416
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#define ll long long
#define qwq 1007
int h,w;
int s1,s2;
int t1,t2;
bool a[qwq][qwq];
std::deque<std::pair<int,int> >que;
int dis[qwq][qwq];
bool flag[qwq][qwq];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1}; 
int main(){
	scanf("%d%d",&h,&w);
	scanf("%d%d",&s1,&s2);
	scanf("%d%d",&t1,&t2);
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			char c;
			c=getchar();
			while(c!='#'&&c!='.')c=getchar();
			if(c=='.')a[i][j]=true;
		}
	}
	memset(dis,0x3f,sizeof(dis));
	dis[s1][s2]=0;
	que.push_back(std::make_pair(s1,s2));
	while(!que.empty()){
		std::pair<int,int> k=que.front();
		int x=k.first,y=k.second;
		que.pop_front();
		if(!a[x][y])break;
		for(int i=0;i<=3;++i){
			int X=x+dx[i];
			int Y=y+dy[i];
			if(X<0||Y<0||X>h||Y>w)continue;
			if(a[X][Y]&&dis[X][Y]>dis[x][y]){
				que.push_front(std::make_pair(X,Y));
				dis[X][Y]=dis[x][y];
			}
		}
		for(int i=-2;i<=2;++i){
			for(int j=-2;j<=2;++j){
				if(i==0&&j==0)continue;
				int X=x+i,Y=y+j;
				if(X<0||Y<0||X>h||Y>w)continue;
				if(a[X][Y]&&dis[X][Y]>dis[x][y]+1){
					que.push_back(std::make_pair(X,Y));
					dis[X][Y]=dis[x][y]+1;
				}
			}
		}
	}
	if(dis[t1][t2]==0x3f3f3f3f)printf("%d\n",-1);
	else printf("%d\n",dis[t1][t2]);
	return 0;
}

Measured memory_bytes: 8812
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define N 10000
int main()
{
unsigned short *X, *Y;

int A[N+1];
int kazu,i,j;
scanf("%d",&kazu);
X=malloc(sizeof(short)*kazu+1);
Y=malloc(sizeof(short)*kazu+1);
for(i=0;i<=N;i++)
A[i]=0;

for(i=0;i<kazu;i++)
{
scanf("%hu",&X[i+1]);
A[X[i+1]]++;
}
for(i=1;i<=N;i++)A[i]=A[i]+A[i-1];

for(j=1;j<=kazu;j++)
{
  Y[A[X[j]]]=X[j];
  A[X[j]]--;
}
for(i=1;i<=kazu;i++)
{
  if(i>1)printf(" ");
  printf("%d",Y[i]);
}
printf("\n");
  return 0;
}



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

int main(){
	int numOfElem;
	cin >> numOfElem;
	int elem[100];

	for(int i = 0; i < numOfElem; i++){
		cin >> elem[i];
	}

	int swapCounter = 0;
	int preSwapCounter = -1;

	for(int i = 0; i < numOfElem; i++){
		for(int j = numOfElem - 1; j - i >= 0; j--){
			if(elem[j] < elem[j-1]){
				int buf = elem[j];
				elem[j] = elem[j-1];
				elem[j-1] = buf;
				swapCounter ++;
			}
		}
		if(swapCounter == preSwapCounter) break;
		preSwapCounter = swapCounter;
	}

	for(int i = 0; i < numOfElem; i ++){
		cout << elem[i];
		if(i + 1 == numOfElem)cout << endl;
		else cout << " ";
	}
	cout << swapCounter << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

int N;
bool G[300][300];
int vnum[300];

int main(){
    cin >> N;
    REP(i,N){
        REP(j,N){
            char c;
            cin >> c;
            G[i][j] = c - '0';
        }
    }

    //fill(vnum, vnum+N, -1);

    int ans = 0;
    bool fail = false;
    REP(i,N){
        int tmp = 0;
        fill(vnum, vnum+N, -1);
        //if(vnum[i] != -1) continue;
        queue<pair<int, int> > que;
        que.push(make_pair(i, tmp+1));
        while(!que.empty()){
            auto p = que.front(); que.pop();
            int v = p.first;
            int n = p.second;
            chmax(tmp, n);
            if((vnum[v] != -1 && vnum[v] != n) || fail) {
                fail = true;
                break;
            }

            if(vnum[v] == -1){
                vnum[v] = n;
                REP(i,N){
                    if(G[v][i]){
                        if(vnum[i] != -1 && vnum[i] % 2 != (n+1) % 2) 
                            fail = true;
                        if(vnum[i] == -1)
                            que.push(make_pair(i, n+1));
                    }
                }
            }
        }
        chmax(ans, tmp);
    }

    if(fail)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int a[100005];
int main(){
  int n; cin >> n;
  a[0] = 0;
  for(int i=1;i<=n;++i) cin >> a[i];
  int sum = 0;
  sum += abs(a[1])+abs(a[n]);
  for(int i=1;i<n;++i) sum += abs(a[i+1]-a[i]);
  for(int i=1;i<=n;++i){
    int ans;
    ans = sum - (abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
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();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        if (e - a > k) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


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

int N,M,Q;
vector<int>a;
vector<int>b;
vector<int>c;
vector<int>d;

int score(vector<int> A){
    int cnt=0;
    for(int i=0;i<Q;i++){if(A[b[i]]-A[a[i]]==c[i]){cnt+=d[i];}}
    return cnt;
}

int ans=0;
int dfs(vector<int> A) {
    if (A.size() == N) {
        return score(A);
    }
    
    int l;
    if(A.empty()==0){l=A.back();}
    else{l=0;}
    for (int i = l; i< M;i++) {
        A.push_back(i);
        ans=max(ans,dfs(A));
        A.pop_back(); 
    }
    return ans;
}

int main() {
    cin>>N>>M>>Q;
    a.resize(Q);b.resize(Q);c.resize(Q);d.resize(Q);
    for(int i=0;i<Q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    vector<int>A;
    cout<<dfs(A)<<endl;;
}


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

int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	char flag;
	ll i;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<ll>> dp(n, vector<ll>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(i=1;i<n;i++){
		dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i]+max(dp[i-1][0], dp[i-1][1]);
	}
	ll ans = dp[n-1][0];
	ans = max(ans, dp[n-1][1]);	
	ans = max(ans, dp[n-1][2]);
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        n /= 4;
        
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            sum += x;
            if (i == n - 1) {
                cout << sum << endl;
            }
        }
    }
}


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

int yakusu(int n) {
  int count = 0;
  for (int i = 1; i <= n; i++)
    if (n % i == 0) count++;
  return count;
}

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 0; i <= n; i++) {
    if (yakusu(i) == 8 && i % 2 == 1) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=(double)acos(-1);
int main()
{
  int n; cin >>n;

  cout<<fixed<<setprecision(12)<<(double)2*(double)n*PI<<endl;
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  lint i,n,x;cin>>n>>x;vint l(n);
  for(i=0;i<n;i++){cin>>l[i];}
  //caricurate
  llint nw=0;
  for(i=0;i<n;i++){
    nw+=l[i];if(nw>x){cout<<(i+1)<<endl;return 0;}
  }
  //output
  cout<<(n+1)<<endl;
}

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

using namespace std;

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

bool solve(int, int);

int ans, n;
int order = 0;
int a[21];
bool solve(int order, int ans) {
  if (ans == 0) return true;
  if (order >= n) return false;
  int res = solve(order + 1, ans) || solve(order + 1, ans - a[order]);
  return res;
}

int main(int argc, char const *argv[]) {
  int q;  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  cin >> q;
  vector<int> b(q);
  rep(i, q) {
    cin >> b[i];
  }
  rep(i, q) {
    if (solve(0, b[i])) {
      cout << "yes" << '\n';
    } else {
      cout << "no" << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 3068
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a_left, a_right = a[0], a.pop()
ans_list = []
for i in range(1, n - 1):
    ans_list.append([[a_right, a_left][a[i] >= 0], a[i]])
    a_right, a_left = a_right - [a[i], 0][a[i] >= 0], a_left - [0, a[i]][a[i] >= 0]
ans_list.append([a_right, a_left])
print(a_right - a_left)
[print(*ans_list[i]) for i in range(n-1)]

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

int main() {
	string l, r;
	cin >> l >> r;
	l += r;
	int num = atoi(l.c_str());
	if (((int)sqrt(num))*((int)sqrt(num)) == num) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<<endl;
	}
	return 0;
}


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

using ll = long long;

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

    ll k, a, b;
    cin >> k >> a >> b;

    if (b - a <= 1 || k - (a - 1) < 2) {
        cout << 1 + k << '\n';
        return 0;
    }

    k -= a - 1;
    ll res = (b - a) * (k / 2) + a;
    if (k & 1) res++;

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,tem,sum=0;
	vi ve;
	cin>>N;

	REP(i,2*N){
		cin>>tem;
		ve.pb(tem);
	}
	DVSORT(ve);

	for(int i=0;i<=2*N;i+=2)
		sum+=min(ve[i],ve[i+1]);

	print(sum);
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = unsigned long long;
using namespace std;

const int maxn = 2e5;
int a[maxn];
int n, k;

int compute(int i) {
  if (i > 0) {
    return a[i] - a[i - 1];
  } else {
    return a[i] + k - a[n - 1];
  }
}
int main() {
  cin >> k >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (n == 2) {
    cout << min(a[1] - a[0], a[0] + k - a[1]) << endl;
    return 0;
  }
  int b = 0;
  for (int i = 1; i < n; i++) {
    if (compute(b) < compute(i)) {
      b = i;
    }
  }
  cout << k - compute(b) << endl;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val l = (0 until n).map {
        sc.nextInt()
    }

    println(abc130b(n, x, l))
}

private fun abc130b(n: Int, x: Int, l: List<Int>): Int {
    val dp = IntArray(n + 1) { 0 }
    dp[0] = 0
    for (i in 1..n) {
        dp[i] = dp[i - 1] + l[i - 1]
    }

    val ans = dp.filter { it <= x }.count()

    return ans
}

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

int main(){

    int num, count, i;
    cin >> num;

    string gacha_name;
    map<string, int> gacha;

    count=0;

    for (i=0; i<num; i++){
        cin >> gacha_name;

         if (gacha[gacha_name] == 0){
             gacha[gacha_name] = 1;
             count++;
         }
         else{
             continue;
         }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N, M;
  cin >> N >> M;
  vll PP(M), Y(M), num(M);
  vector<vector<P>> ken(N, vector<P>(0));
  vector<string> ue(M, ""), shita(M, "");
  for(int i = 0; i < M; i++){
    cin >> PP.at(i) >> Y.at(i);

    ue.at(i) = to_string(PP.at(i));
    while(ue.at(i).size()<6){
      ue.at(i) = '0' + ue.at(i);
    }

    PP.at(i)--;
    ken.at(PP.at(i)).push_back(P(Y.at(i), i));
  }
  for(int i = 0; i < N; i++){
    sort(ALL(ken.at(i)));
    for(int j = 0; j < ken.at(i).size(); j++){
      P x = ken.at(i).at(j);
      shita.at(x.second) = to_string(j+1);
      while(shita.at(x.second).size()<6){
        shita.at(x.second) = '0' + shita.at(x.second);
      }
    }
  }
  for(int i = 0; i < M; i++){
    cout << ue.at(i) << shita.at(i) << endl;
  }
}

Measured memory_bytes: 20224
/*
  サイコロ(サイコロを転がすシミュレーションを行うプログラム)
  2018/03/09
*/

#include<stdio.h>

void move_N(int *a)
{
  int temp;
  temp = a[0];
  a[0] = a[1];
  a[1] = a[5];
  a[5] = a[4];
  a[4] = temp;
}

void move_E(int *a)
{
  int temp;
  temp = a[0];
  a[0] = a[3];
  a[3] = a[5];
  a[5] = a[2];
  a[2] = temp;
}

void move_S(int *a)
{
  int temp;
  temp = a[0];
  a[0] = a[4];
  a[4] = a[5];
  a[5] = a[1];
  a[1] = temp;
}

void move_W(int *a)
{
  int temp;
  temp = a[0];
  a[0] = a[2];
  a[2] = a[5];
  a[5] = a[3];
  a[3] = temp;
}

int main(void)
{
  int num[6];/*各面の整数*/
  int *p;/*ポインタ*/
  char order[101];/*命令を表す1の文字列 + '\0'*/
  int i;

  for(i=0;i<6;i++)
    scanf("%d",&num[i]);
  p=num;
  scanf("  %s",order);
  i=0;
  while(order[i] != '\0'){
    if(order[i] == 'N')
      move_N(p);
    if(order[i] == 'E')
      move_E(p);
    if(order[i] == 'S')
      move_S(p);
    if(order[i] == 'W')
      move_W(p);
    i++;
  }
  printf("%d\n",num[0]);
  return 0;
}


Measured memory_bytes: 2100
program ABC143B
    implicit none
    integer:: N,i,j
    integer:: result=0
    integer,allocatable,dimension(:):: D
    read *, N
    allocate(D(N))
    read*, (D(i),i=1,N)

    do i=1,N-1
        do j=i+1,N
            result=result+D(i)*D(j)
        end do
    end do

    print '(i0)',result
end program ABC143B

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	
	
	public static long A;
	public static long answer = 0;
	public static long MOD=1000000007;
	

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int k) {
		long sum = 1;
		for(int i=1;i<=k;i++) {
			sum = (sum*i)%MOD;
		}
		return sum;
		
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	public static int H,W;
	public static char[][] c;
	public static boolean[][] b;
	
	

    
	
	
 public static void main(String[] args) {
	 
	 Scanner sc=new Scanner(System.in);
	 
	 int N=sc.nextInt();
	 
	 Map<Long,Long> listA=new TreeMap<Long,Long>();
	 
     //System.out.print(x + " = ");
 
     for(int j=2;j<=N;j++) {
    	 int x = j;
    	 for (long i = 2;i <= x;) {
             if (x % i == 0) { 
            	 if(listA.containsKey(i)) {
            		 listA.put(i,listA.get(i)+1);
            	 }else {
            		 listA.put(i,(long)1); 
            	 }
            	 
                 //System.out.print(i);
                 
                 if (x != i);
                     //System.out.print(" * ");
                 x /= i; 
             } else
                 i++;
             
             
         }
    	 
     }
     
     long result = 1;
     
     for (Long nKey : listA.keySet())
     {
    	 result=(result*(listA.get(nKey)+1))%MOD;
         //System.out.println(nKey+" "+(listA.get(nKey)+1));
     }
     
     System.out.println(result%MOD);
	
}
 
 
}

Measured memory_bytes: 21844
import sys
x = int(input())
lis = [1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,121,144,169,196,225,289,324,361,400,441,484,529,576,676,784,841,900,961]
lis.sort(reverse=True)
for nums in lis:
  if nums <= x:
    print(nums)
    sys.exit()

Measured memory_bytes: 3064
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
flag = 0
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)

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

mod = 10 ** 9 + 7

if abs(n - m) >= 2:
    print(0)
else:
    res = 1
    for i in range(1, n+1):
        res = res * i % mod
    for i in range(1, m+1):
        res = res * i % mod

    if abs(n - m) == 1:
        print(res)
    else:
        print(res * 2 % mod)

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


int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n);
    vector<ll> value(n);
    for(ll i=0;i<n;i++)
    {
        cin>>weight[i];
        cin>>value[i];
    }
    vector<vector<ll> > ans(n,vector<ll> (w+1,0));
    for(ll i=weight[0];i<=w;i++)
    ans[0][i]=value[0];
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if((j-weight[i]) >= 0)
            {
                ans[i][j]=max(ans[i-1][j],value[i]+ans[i-1][j-weight[i]]);
            }
            else
            ans[i][j]=ans[i-1][j];
        }
    }
    ll an=0;
    for(ll i=1;i<=w;i++)
    an = max(an,ans[n-1][i]);
    cout<<an;
    return 0;
}

Measured memory_bytes: 79488
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vector<pair<PP,ll>> A;
struct segtree {
	ll N;
	vl dat;
	void init(ll n) {
		N = 1;
		while (N < n) N *= 2;
		dat = vl(N * 2);
		for (int i = 0; i < 2 * N - 1; i++)
			dat[i] = INF;
	}
	// update k th element
	void update(ll k, ll a) {
		k += N - 1; // leaf
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	// min [a, b)
	ll query(ll a, ll b) { return query(a, b, 0, 0, N); }
	ll query(ll a, ll b, ll k, ll l, ll r) {
		if (r <= a or b <= l) return INF;
		if (a <= l and r <= b) return dat[k];
		ll m = (l + r) / 2;
		return min(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
	}

	ll at(ll a) {
		return dat[a + N - 1];
	}
};
void input() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b >> c;
		A.push_back({ {a,b},c });
	}
}
void solve() {
	sort(all(A));
	segtree seg;
	seg.init(n + 1);
	seg.update(1, 0);
	rep(i,m){
		x = A[i].first.first;
		y = A[i].first.second;
		z = A[i].second;
		t = seg.query(x, y + 1);
		h = seg.at(y);
		seg.update(y, min(z + t, h));
	}

	if(seg.at(n)>INF-1){
		cout << -1 << endl;
	}
	else cout << seg.at(n) << endl;
}

int main() {
	input();
	solve();
}

Measured memory_bytes: 5516
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int root[][]=new int[n+1][n+1];
			for(int i=0;i<=n;i++)
				Arrays.fill(root[i], 1000000);
			for(int i=0;i<n;i++)
			{
				int r=in.nextInt();
				int k=in.nextInt();
				for(int j=0;j<k;j++)
					root[r][in.nextInt()]=1;
			}
			for(int i=0;i<=n;i++)
				root[i][i]=0;
			for (int i=1;i<=n;i++)//ワーシャルフロイド
				for(int j=1;j<=n;j++)
					for(int k=1;k<=n;k++)
					{
						//j->kへ行くのにiを経由した方が良いかどうか
						int c=root[j][i]+root[i][k];
						root[j][k]=Math.min(root[j][k],c);
					}
			int p=in.nextInt();
			for(int i=0;i<p;i++)
			{
				int s=in.nextInt(),t=in.nextInt();
				int TTL=in.nextInt();
				int min=root[s][t]+1;
				System.out.println(min<=TTL ? min:"NA");
			}
		}
	}
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n;
  int a;

  scanf("%d", &n);

  vector<vector<int> > v;

  REP(i, 3) {
    vector<int> row_v;
    REP(j, n) {
      scanf("%d", &a);
      row_v.push_back(a);
    }
    v.push_back(row_v);
  }

  REP(i, 3) {
    sort(v[i].begin(), v[i].end());
  }

  LL sum = 0;
  REP(i, n) {
    LL big = lower_bound(v[0].begin(), v[0].end(), v[1][i]) - v[0].begin();
    LL small = v[2].end() - upper_bound(v[2].begin(), v[2].end(), v[1][i]);
    sum += big * small;
  }
  printf("%lld\n", sum);
}


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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> p(a), q(b), r(c);
	rep(i,a) cin >> p[i];
	rep(i,b) cin >> q[i];
	rep(i,c) cin >> r[i];
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	// p(つまり赤)を大きい方からx個食べる
	// q(つまり緑)を大きい方からy個食べる
	ll ans = 0;
	vector<ll> look(x+y);
	rep(i,x){
		ans += p[i];
		look[i] = p[i];
	}
	rep(i,y){
		look[x+i] = q[i];
		ans += q[i];
	}
	sort(look.begin(),look.end());
	int count = 0;
	rep(i,x+y){
		if(look[i] < r[count]){
			ans -= look[i];
			ans += r[count];
			count ++ ;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int N,K;
vector<int> G[2001];

int dfs(int v, int p,int d, int mk) {
  int ans = 1;
  if(d != mk){
    for(int i = 0; i < G[v].size(); i++) {
      int u = G[v][i];
      if(u != p) {
	ans += dfs(u,v,d+1,mk);
	
      }
    }
  }
  return ans;
}
  
int main() {
  cin >> N >> K;

  for(int i = 0; i < N-1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;

  if(K % 2 == 0) {
    for(int i = 0; i < N; i++) {
      ans = max(ans,dfs(i,-1,0,K/2));
    }
     
  }

  else{
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < G[i].size(); j++) {
	int u = G[i][j];
	ans = max(ans,dfs(u,i,0,K/2)+dfs(i,u,0,K/2));
      }
    }
  }
  
  cout << N - ans <<endl;
}
  


Measured memory_bytes: 384