akhauriyash/Code-Regression huggingface dataset:
from collections import deque

# 頂点数、辺数
N, M = list(map(int, input().split()))

# 隣接リスト表現
repn = [[[] for l in range(3)] for u in range(N)]
for j in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    repn[a][0].append((b, 1))
    repn[a][1].append((b, 2))
    repn[a][2].append((b, 0))

# 気にする頂点、０オリジンなのでちょっといじった
S, T = list(map(int, input().split()))
s = S - 1
t = T - 1

# ＳからＴまで３の倍数でたどり着く最短経路を求めたい
# 「３の倍数」の条件が無ければBFSで片付く
# そこでグラフを３層にして「３の倍数」の条件を外す

# 具体的にはグラフの頂点を (u, l) = {頂点uで階層lの点（l = 0, 1, 2）}
# グラフの辺を(u, l) -> (v, l+1)と読み替える
# 求めるのは(S, 0) -> (T, 0)の最短経路
# 後はただのBFS

color = [['WHITE' for l in range(3)] for u in range(N)]
d = [[-1, -1, -1] for u in range(N)]
Q = deque([])

color[s][0] = 'GRAY'
d[s][0] = 0
Q.append((s, 0))

while len(Q) != 0:
    u, l = Q.popleft()
    for x in repn[u][l]:
        v, r = x
        if color[v][r] == 'WHITE':
            color[v][r] = 'GRAY'
            d[v][r] = d[u][l] + 1
            Q.append(x)
    color[u][l] = 'BLACK'

print(d[t][0] // 3)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K; cin >> N >> K;
	K = min(K, 200);
	vint A(N); cin >> A;	
	for (int q = 0; q < K; q++) {
		vint cnt(N+1, 0);
		for (int i = 0; i < N; i++) {
			int l = max(i - A[i], 0);
			int r = min(i + A[i] + 1, N);
			cnt[l]++;
			cnt[r]--;
		}
		for (int i = 1; i <= N; i++) {
			cnt[i] += cnt[i-1];
		}
		for (int i = 0; i < N; i++) {
			A[i] = cnt[i];
		}
	}
	cout << A << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4972
#include <bits/stdc++.h>
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
const int sqrtN = 512;

struct Node{
	int data;
	
	Node(int data) : data(data) {};
	
	Node operator *(const Node r) const{
		return data + r.data;
	}
} e(0);

struct SqrtDecomposition{
	vector<Node> data;
	vector<Node> bucket;
	int N, K;
	
	SqrtDecomposition(int n) : N(n){
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, e);
		bucket.assign(K, e);
	}
	
	void add(int k, Node x){
		data[k] = data[k] * x;
		k = k / sqrtN;
		
		Node ret = e;
		for(int i = k * sqrtN; i < (k + 1) * sqrtN; i++){
			ret = ret * data[i];
		}
		
		bucket[k] = ret;
	}
	
	int get(int a, int b){
		return _get(a, b).data;
	}
	
	Node _get(int a, int b){
		Node ret = 0;
		for(int k = 0; k < K; k++){
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			
			if(b<=l||r<=a) continue;
			if(a<=l&&r<=b) ret = ret * bucket[k];
			else{
				for(int i = max(a, l); i < min(b, r); i++){
					ret = ret * data[i];
				}
			}
		}
		
		return ret;
	}
};

int main(){
	int n,q; cin >> n >> q;
	SqrtDecomposition data(n);
	REP(i,0,q){
		int a,b,c; cin >> a >> b >> c;
		
		if(a == 0) data.add(b, c);
		else if(a == 1) cout << data.get(b, c + 1) << endl;
	}

	return 0;
}



Measured memory_bytes: 3348
# https://atcoder.jp/contests/agc044/submissions/13542551

def main():
    from heapq import heappush, heappop

    T = int(input())
    for _ in range(T):
        N, A, B, C, D = map(int, input().split())

        h = [(0, N)]  # cost,value
        checked = set()

        ans = N * D + 1
        while h:
            cost, x = heappop(h)
            if cost >= ans: continue
            if x in checked: continue
            checked.add(x)

            # 0まで1ずつ減らす
            if ans > cost + x * D:
                ans = cost + x * D

            for d, c in ((2, A), (3, B), (5, C)):
                # すでにheapqからnxがpopしていれば
                # より低コストでnxを生成できているので
                # nxの生成は不要
                nx, r = divmod(x, d)
                if nx not in checked:
                    heappush(h, (cost + r * D + c, nx))
                if (nx + 1) not in checked:
                    heappush(h, (cost + (d - r) * D + c, nx + 1))

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12056
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int m = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static int[] arr;
    static string s = "";
    static string[] ss;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static long Max(long a, long b)
    {
        return Math.Max(a, b);
    }
    static long Min(long a, long b)
    {
        return Math.Min(a, b);
    }
    static long Abs(long a)
    {
        return Math.Abs(a);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(int num = -1)
    {
        arr = new int[n];
        if(num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        ss = rls();
        for (int i = 0; i < n; i++)
        {
            min = Min(min, Int(ss[i]));
            max = Max(max, Int(ss[i]));
        }
        wl(max - min);
    }


}



Measured memory_bytes: 11220
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(void){

  int n;
  cin>>n;
  ll ans = 0;

  int c1[10][10];
  
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      c1[i][j] = 0;
    }
  }

  for(int i=1;i<=n;i++){
    string s;
    s = to_string(i);
    int first = s[0] - '0';
    int second = s[s.size()-1] - '0';
    c1[first][second]++;
  }

  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      ans += c1[i][j] * c1[j][i]; 
    }
  }

  

  // for(int x=1;x<10;x++){
  //   for(int y = 1;y<10;y++){
  //     int count1 = 0;
  //     int count2 = 0;
  //     for(int k=1;k<=n;k++){
  //         string s;
  //         s = to_string(k);
  //         int first = s[0] - '0';
  //         int second = s[s.size()-1] - '0';
          
  //         if(first == x && second == y){
  //           count1++;
  //         }
  //         if(x == second && y == first){
  //           count2++;
  //         }
  //         //cout<<count<<endl;
  //     }
  //     ans += count1 * count2;
  //   }
 // }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import permutations
def fuctorial(n):
    if n <= 1:
        return 1
    else:
        return n * fuctorial(n - 1)


N = int(input())
zahyou = []
for _ in range(N):
    x, y = map(int, input().split())
    zahyou.append([x, y])


indice = list(range(N))
indices = permutations(indice, N)
res = 0
for ic in indices:
    for i in range(1, N):
        x1, y1 = zahyou[ic[i - 1]]
        x2, y2 = zahyou[ic[i]]
        res += ((x1 - x2)**2 + (y1 - y2)**2)**0.5


print(res/fuctorial(N))


Measured memory_bytes: 40684
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for(int i=0; i<N; i++) {
        cin >> x.at(i);
    }
    for(int j=0; j<M; j++) {
        cin >> y.at(j);
    }
    x.push_back(X);
    y.push_back(Y);

    if(*max_element(x.begin(), x.end()) < *min_element(y.begin(), y.end())) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>> n;ll a[n],ans=0;
  for(ll i=0;i<n;i++){
    cin>> a[i];
  }
  sort(a,a+n);
  for(ll i=0;i<n-1;i++){
    if(a[i]==a[i+1]){ans=1;}
  }
  if(ans==0){
    cout << "YES"<<endl;
  }else{
    cout << "NO"<<endl;
  }
}
  

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main(){

    input!{
        l: usize,
        r: usize,
        d: usize,
    }

    let mut cnt = 0;

    for i in l..r+1 {
        if i%d==0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 2084
#include <iostream>

using namespace std;

int main(void){

  int L,A,B,C,D,count = 0;

  cin >> L >> A >> B >> C >> D;


 for(; ;){

   if( A <= 0 && B <= 0)  break;

   A -= C;
   B -= D;

   count++;

 }

 cout << L - count << endl;

 return 0;

}

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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[111111],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[111111];
int l[111115];
int j[111115];
int e[111111];


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[311111];
stack<int> s;
//set<int> s[222][22];
//priority_queue<P> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[2];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


int main()
{
    scanf("%d %d",&a,&b);
//    q.push({1,0});
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    for(int t=2;t<=a;t++)
    {
        //for(;q.top().x+b<t;q.pop());
        l[t]=1000654321;
        for(int n=max(1,t-b);n<t;n++)
        l[t]=min(l[t],l[n]+max(o[n]-o[t],o[t]-o[n]));
    }
    printf("%d",l[a]);
}





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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll c = 0, x, y;
    cin >> x >> y;
    while(x > 0){
    	x -= y;
    	c++;
    }
    cout << c << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
}


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

int main(){
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(i, k+1) {
        rep(j, k+1) {
            int x, y, z;
            x = i;
            y = j;
            z = s-(x+y);
            if (z <= k && z >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>


typedef struct _TARGETDATA
{
    int a;
    int b;
    int c;
} TARGETDATA, *LPTARGETDATA;

class AscendingOrderBase
{
public:
    /**
    * @brief デストラクタ
    */
    virtual ~AscendingOrderBase() {}

public:
    /**
    * @fn void printAns()
    * @brief 標準出力に書き出す
    */
    virtual void printAns() = 0;
};

class AscendingOrder final : public AscendingOrderBase
{
    typedef AscendingOrderBase super;

public:
    /**
    * @brief デストラクタ
    */
    ~AscendingOrder() {}

public:
    /**
    * @fn void printAns()
    * @brief "Yes"を出力する
    */
    void printAns() { std::cout << "Yes" << std::endl; }
};

class NotAscendingOrder final : public AscendingOrderBase
{
public:
    /**
    * @brief デストラクタ
    */
    ~NotAscendingOrder() {}

public:
    /**
    * @fn void printAns()
    * @brief "No"を出力する
    */
    void printAns() { std::cout << "No" << std::endl; }
};

/**
* @brief コントロール
*/
class ITP1_2_B
{
private:
    //! 出力切り替え
    AscendingOrderBase* ascendingOrder;

public:
    /**
    * @brief コンストラクタ
    */
    ITP1_2_B() : ascendingOrder(NULL) {}

    /**
    * @brief デストラクタ
    */
    ~ITP1_2_B() { delete ascendingOrder; }

public:
    /**
    * @fn bool executeEx(TARGETDATA& target)
    * @brief targetが昇順に並んでいれば"Yes"を出力し、そうでなければ"No"を出力する
    * @param[in] target 比較対象
    * @return bool targetが入力範囲内ならtrueを、そうでなければfalseを返す
    */
    bool executeEx();

private:
    /**
    * @fn bool check(TARGETDATA& target)
    * @brief 入力範囲をチェックする
    * @param[in] target チェック対象
    * @return bool targetが入力範囲内ならtrueを、そうでなければfalseを返す
    */
    bool check(TARGETDATA& target);

    /**
    * @fn bool confirm(TARGETDATA& target)
    * @brief targetが昇順かどうか確認する
    * @param[in] target 確認対象
    * @return bool targetが昇順ならtrueを、そうでなければfalseを返す
    */
    bool confirm(TARGETDATA& target);
};

class Reader
{
public:
    /**
    * @fn void read(TARGETDATA& target)
    * @brief 標準入力から読み込む
    * @param[out] target 入力データ
    */
    void read(TARGETDATA& target);
};

//------------------------------------------------------------------------------------
bool ITP1_2_B::executeEx()
{
    TARGETDATA data = { 0, 0, 0 };

    Reader().read(data);

    if (!check(data))
        return false;

    if (confirm(data))
        ascendingOrder = new AscendingOrder;
    else
        ascendingOrder = new NotAscendingOrder;

    assert(NULL != ascendingOrder);

    ascendingOrder->printAns();

    return true;
}

bool ITP1_2_B::check(TARGETDATA& target)
{
    static const int Min = 0;
    static const int Max = 100;

    if ((Min > target.a || Max < target.a) ||
        (Min > target.b || Max < target.b) ||
        (Min > target.c || Max < target.c))
        return false;

    return true;
}

bool ITP1_2_B::confirm(TARGETDATA& target)
{
    if ((target.a < target.b) &&
        (target.b < target.c))
        return true;

    return false;
}

void Reader::read(TARGETDATA& target)
{
    std::cin >> target.a >> target.b >> target.c;

    //scanf("%d %d %d", &target.a, &target.b, &target.c);
}

/**
* @fn int main()
* @brief エントリポイント
*/
int main()
{
    ITP1_2_B().executeEx();
}



Measured memory_bytes: 3112
#include <cstdio>
using namespace std;
const int mapSize = 1e6 + 5, mod = 1e9 + 7;
int fac[mapSize * 2], inv[mapSize * 2];
void Init() {
	fac[1] = inv[1] = 1;
	for (int i = 2; i <= (int) 2e6 + 1; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		int res = mod % i, div = mod / i;
		inv[i] = 1ll * inv[res] * (mod - div) % mod;
	}
	for (int i = 2; i <= (int) 2e6 + 1; ++i)
		inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
	fac[0] = inv[0] = 1;
}
int C(int down, int up) {
	return 1ll * fac[down] * inv[up] % mod * inv[down - up] % mod;
}
int rowSum(int rowId, int colL, int colR) {
//	printf("rowId + colL : %d colL - 1 : %d\n", rowId + colL, colL - 1);
	int tmp1, tmp2, ret = ((tmp1 = (C(rowId + 1 + colR, colR)) - (tmp2 = C(rowId + colL, colL - 1))) % mod + mod) % mod;
//	printf("tmp1 : %d tmp2 : %d\n", tmp1, tmp2);
	return ret;
}
int main() {
	Init();
	int r1, c1, r2, c2;
	scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	int ans = 0;
	for (int rowId = r1; rowId <= r2; ++rowId) {
		ans = (ans + rowSum(rowId, c1, c2)) % mod;
//		printf("ans : %d\n", ans); 
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else {
		s[k - 1] = 'c';
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main (){
	int a,b;

	std::cin >> a >> b;

	if(a==b){
		std::cout <<"a == b"<< std::endl;
	} else if(a > b){
		std::cout <<"a > b"<< std::endl;
	}else {
		std::cout <<"a < b"<< std::endl;
	}

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  long long ans = (N / (A+B))*A;
  long long bara = N % (A+B);
  ans += min(A,bara);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, G = 3;
int n, m;
int dp[210][8010];
int f[32010], g[32010];
int rev[32010];
inline int power(int a, int b) {
    long long res = a, ans = 1;
    for (; b; b >>= 1, res = res * res % mod) if (b & 1) ans = ans * res % mod;
    return ans;
}
inline void getrev(int l) {
    for (int i = 1; i < 1 << l; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (l - 1));
}
inline void NTT(int *a, int n, int type) {
    for (int i = 1; i < n; i++) if (i < rev[i]) swap(a[i], a[rev[i]]);
    for (int p = 1; p < n; p <<= 1) {
        int wn = power(G, type == 1 ? mod / 2 / p : mod - 1 - mod / 2 / p);
        for (int s = 0; s < n; s += p << 1) {
            int w = 1;
            for (int i = 0; i < p; i++) {
                int h1 = a[s + i], h2 = 1ll * w * a[s + p + i] % mod;
                a[s + i] = (h1 + h2) % mod;
                a[s + p + i] = (h1 - h2 + mod) % mod;
                w = 1ll * w * wn % mod;
            }
        }
    }
    if (type == -1) {
        int inv = power(n, mod - 2);
        for (int i = 0; i < n; i++) a[i] = 1ll * a[i] * inv % mod;
    }
}
inline void mult(int *a, int sizea, int *b, int sizeb, int *c, int sizec) {
    int l = 0;
    for (; 1 << l < sizea + sizeb; l++);
    getrev(l);
    for (int i = 0; i < 1 << l; i++) {
        f[i] = i < sizea ? a[i] : 0;
        g[i] = i < sizeb ? b[i] : 0;
    }
    NTT(f, 1 << l, 1);
    NTT(g, 1 << l, 1);
    for (int i = 0; i < 1 << l; i++) f[i] = 1ll * f[i] * g[i] % mod;
    NTT(f, 1 << l, -1);
    for (int i = 0; i < sizec; i++) c[i] = f[i];
}
int fac[8010];
int facinv[8010];
int tmp[8010];
int main() {
    scanf("%d%d", &n, &m);
    fac[0] = 1;
    for (int i = 1; i <= n + 2; i++) fac[i] = 1ll * i * fac[i - 1] % mod; 
    facinv[n + 2] = power(fac[n + 2], mod - 2);
    for (int i = n + 2; i > 0; i--) facinv[i - 1] = 1ll * i * facinv[i] % mod;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) tmp[i] = facinv[i + 2];
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j <= n; j++) dp[i - 1][j] = 1ll * dp[i - 1][j] * facinv[j] % mod;
        mult(dp[i - 1], n + 1, tmp, n + 1, dp[i], n + 1);
        for (int j = 0; j <= n; j++) dp[i - 1][j] = 1ll * dp[i - 1][j] * fac[j] % mod;
        for (int j = 0; j <= n; j++) dp[i][j] = (1ll * dp[i][j] * fac[j + 2] + 1ll * (1 + j * (j + 1) / 2) * dp[i - 1][j]) % mod;
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) ans = (ans + 1ll * fac[n] * facinv[i] % mod * facinv[n - i] % mod * dp[m][i]) % mod;
    return cout << ans << endl, 0;
}

Measured memory_bytes: 6784
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int tmp,common;

	scanf("%d",&tmp);

	if(tmp >= N){
		common = calc(tmp,N);
	}else{
		common = calc(N,tmp);
	}

	for(int loop = 1; loop < M; loop++){
		scanf("%d",&tmp);
		if(tmp >= common){
			common = calc(tmp,common);
		}else{
			common = calc(common,tmp);
		}
	}

	if(common == 1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main(){
  int a[5], k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  if(a[4]-a[0]<=k) cout << "Yay!";
  else cout <<":(";
  return 0;
}


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

ll par[100100];
ll ran[100100];
ll size[100100];
ll N, M;

void init(ll n) {
    for(ll i = 0; i < n; i++) {
        par[i] = i;
        ran[i] = 0;
        size[i] = 1;
    }
}

ll find(ll x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(ran[x] < ran[y]) {
        par[x] = y;
        size[y] += size[x];
    } else {
        par[y] = x;
        size[x] += size[y];
        if(ran[x] == ran[y]) ran[x] ++;
    }
}

bool same(ll x, ll y) {
    return find(x) == find(y);
}

int main() {
    cin >> N >> M;
    ll  A[100100], B[100100]; for(ll i = 0; i < M; i++) cin >> A[i] >> B[i];
    reverse(A, A + M); reverse(B, B + M);

    ll ans[100100];
    ans[0] = N * (N - 1) / 2;

    init(N);

    for(ll i = 0; i < M - 1; i++) {
        if (find(A[i]) != find(B[i])){
            ans[i + 1] = ans[i] - size[find(A[i])] * size[find(B[i])];
        } else ans[i + 1] = ans[i];
        unite(A[i], B[i]);
    }

    reverse(ans, ans + M);

    for(ll i = 0; i < M; i++) {
        ll sum = ans[i];
        printf("%lld\n", sum);
    }
}


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

int step(char c) {
  if (c == 'a') return 0;
  return 'z' - c + 1;
}

int main(void) {
  string s;
  int k;
  cin >> s >> k;

  for (int i = 0; i < s.size(); i++) {
    int n = step(s[i]);
    if (n <= k) {
      s[i] = 'a';
      k -= n;
    }
  }

  for (int i = 0; i < k % 26; i++) {
    s[s.size()-1]++;
  }

  cout << s << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++){
        if (s[i] == '1') s[i] = '9';
        else if (s[i] == '9') s[i] = '1';
    }
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3652
from math import gcd

a = int(input())

def main():
    for i in range(1, a+1):
        for j in range(i, a+1):
            ab = gcd(i, j)
            for k in range(j, a+1):
                x = len({i, j, k})
                if x == 1:
                    x = 1
                elif x == 2:
                    x = 3
                else:
                    x = 6
                yield gcd(ab, k) * x

print(sum(main()))



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
struct Edge { int from; int to; long long weight; };
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;
typedef std::pair<long long, int> P;

std::vector<long long> dijkstra(const Graph& g, int src) {
	std::vector<long long> d(g.size(), std::numeric_limits<long long>::max());
	d[src] = 0;
	//vector<int> prev(g.size());
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	q.push({ 0, src });
	while (!q.empty()) {
		auto p = q.top(); q.pop();
		int v = p.second;
		if (p.first > d[v]) continue;
		for (int i = 0; i < (int)g[v].size(); ++i) {
			Edge e = g[v][i];
			if (d[e.to] > d[v] + e.weight) {
				d[e.to] = d[v] + e.weight;
				q.push({ d[e.to],e.to });
				//prev[e.to] = v;
			}
		}
	}
	return d;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;
	Graph g(n);
	REP(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back({ a,b,1 });
		g[b].push_back({ b,a,1 });
	}
	auto a = dijkstra(g, s), b = dijkstra(g, t);
	ll d = a[t];
	vl cnta(n), cntb(n);
	REP(i, n) {
		if (a[i] == numeric_limits<ll>::max())continue;
		cnta[a[i]]++;
		cntb[b[i]]++;
	}
	ll ans = 0;
	REP(i, d - 1) {
		ans += cnta[i] * cntb[d - i - 2];
	}
	cout << ans << endl;


}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int r;
	cin >> r;
	cout << fixed << setprecision(7) << 2 * acos(-1.0) * r << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 3792
#include <stdio.h>

int main(void){
    long long int n, a[200000+5], cnt[200000+5]={0};
    scanf("%lld", &n);
    for(int i=0; i<n; i++)scanf("%lld", &a[i]), cnt[a[i]]++;
    
    long long int sum=0;
    for(int i=1; i<=n; i++)sum+=cnt[i]*(cnt[i]-1)/2;
    
    for(int i=0; i<n; i++)printf("%lld\n", sum-(cnt[a[i]]-1));
}

Measured memory_bytes: 5764
#include <iostream>
#include <set>
using namespace std;
int main(){
    string s;
    int n;
    cin >> n;
    cin >> s;
    int sum = 1;
    for(int i =0 ;i<n -1;i++){
        if(s[i] != s[i+1])sum++;
    }
    cout << sum << endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    REP(i, N){
        ll a;
        cin >> a;
        fw.add(i, a);
    }
    while(Q--){
        ll t;
        cin >> t;
        if(t){
            ll l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << "\n";
        }else{
            ll p, x;
            cin >> p >> x;
            fw.add(p, x);   
        }
    }

    return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
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; }

//---------------------------------------------------------------------------------------------------
void _main() {
    string S,T; cin >> S >> T;
    if (S.size() + 1 == T.size() && equal(all(S), begin(T))) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

long long bourrin(long long a) {
    if(a==0) return 0;

    int p = __builtin_popcount(a);
    a%=p;
    return 1 + bourrin(a);
}


long long fastPow(long long N, long long mod) {
    if(N==0) return 1;
    if(N==1) return 2;
    long long t = fastPow(N/2,mod);
    t*=t;
    if(N%2==1) t*=2;
    t%=mod;
    return t;
}


int main() {
    int N;
    cin>>N;
    string s;
    cin>>s;

    long long pop = 0;

    for(int c=0;c<s.size();c++) {
        pop += s[c]=='1';
    }


    vector<long long> bonus(N,0);
    vector<long long> malus(N,0);

    vector<long long> v(3,0);

    for(int c=0;c<s.size();c++) {
        for(int c2=0;c2<3;c2++) {
            v[c2]*=2;
            v[c2]+=(s[c]-'0');
        }
        if(pop < N){
            bonus[c] = (fastPow(s.size()-c-1,(pop+1)))%(pop+1);
        }
        if(pop > 1){
            malus[c] = (-fastPow(s.size()-c-1,pop-1)+(10*(pop-1)))%(pop-1);
        }
        if(pop > 1)
            v[0] %= (pop-1);
        if(pop != N)
            v[2] %= (pop+1);
        if(pop>0)v[1] %= pop;
    }
    long long trueRes = 0;
    for(int c=0;c<s.size();c++) {

        long long res = 0;
        if(s[c] == '0') {
            res = (v[2]+bonus[c])%(pop+1);
        } else {
            if(pop <= 1) {
                cout<<0<<"\n";
                continue;
            }
            res = (v[0]+malus[c])%(pop-1);
        }
        cout<<1+bourrin(res)<<"\n";
    }
}


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

int main(){
  int x ; cin >> x ;
  if(x==2){
    cout << 2 << endl ;
    return 0 ;
  }
  if(x==3){
    cout << 3 << endl ;
    return 0 ;
  }
  vector<int> prime ;
  prime.push_back(2) ;
  prime.push_back(3) ;
  for(int i=5;i<1000000;i+=2){
    bool check = true ;
    for(int j=0;j<prime.size();j++){
      if(i%prime.at(j)==0){
        check = false ;
        break ;
      }
    }
    if(check){
      if(i>=x){
        cout << i << endl ;
        return 0 ;
      }else{
        prime.push_back(i) ;
      }
    }
  }
}

Measured memory_bytes: 384
#include "iostream"
using namespace std;

int main() {
  int n;
  cin >> n;
  int fix;
  int x[110], y[110];
  int h[110];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] != 0) fix = i;
  }

  bool ans = true;

  for (int a = 0; a < 101; a++) {
    for (int b = 0; b < 101; b++) {
      for (int hi = max(h[fix] - 210, 0); hi < h[fix] + 210; hi++) {
        ans = true;
        for (int k = 0; k < n; k++) {
          if (h[k] != max(hi - abs(x[k] - a) - abs(y[k] - b), 0)) {
            ans = false;
          }
        }
        if (ans) {
          cout << a << " " << b << " " << hi << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.String;
import java.lang.System;
import java.lang.reflect.Array;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		
		if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
			System.out.println(0);
		} else {
			long[] arr = new long[3];
			arr[0] = a;
			arr[1] = b;
			arr[2] = c;
			long max = a;
			int j = 0;
			for (int i = 1; i < 3; i++){
				if (arr[i] > max) {
					max = arr[i];
					j = i;
				}
			}
			arr[j] = 1;
			long ans = 1;
			int i = 0;
			while (i < 3) {
				ans = ans * arr[i];
				i++;
			}
			System.out.println(ans);
		}
		
		
	}
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

        ll n, k;
        cin >> n >> k;

        ll sum = k;

        FO(i, n - 1) {
            sum *= (k-1);
        }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stack>
#include <stdio.h>
#include <ios>     // std::left, std::right
#include <iomanip>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
//const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int digitlen(long long i){
    long long t = i;
    int count = 0;
    while(t){
        count += 1;
        t /= 10;
    }
    return count;
}

vector<int> cumsum(vector<int> arr){
    vector<int> ret;
    int l = arr.size();
    ret.push_back(arr[0]);
    for(int i = 1; i < l; i++){
        ret.push_back(ret[i-1] + arr[i]);
    }
    return ret;
}

vector<int> eratosthenes(int n){
    int arr[n+1];
    rep(i,0,n+1){
        arr[i] = 1;
    }
    arr[0] = 0; arr[1] = 0;
    for(int i = 2; i < n; i++){
        if(arr[i]==1){
            for(int j = 2*i; j < n+1; j+=i){
                arr[j] = 0;
            }
        }
    }
    
    vector<int> ret;
    for(int i = 2; i<n+1; i++){
        if(arr[i] == 1){
            ret.push_back(i);
        }
    }
    return ret;

}


int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            return 0;
        }

           cout << eratosthenes(n*2).size() - eratosthenes(n).size() << endl;
    }
}


Measured memory_bytes: 4156
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

struct store
{
    ll a;
    ll b;
}sl[100005];

bool cmp(store x, store y)
{
    return x.a < y.a;
}

int main()
{
    ll n, m;
    cin>>n>>m;
    for(int i = 0; i < n; ++i)
    {
        cin>>sl[i].a>>sl[i].b;
    }
    sort(sl, sl + n, cmp);
    ll ans = 0, sum = 0;
    for(int i = 0; i < n; ++i)
    {
        if(sum + sl[i].b >= m)
        {
            ans += (m - sum) * sl[i].a;
            break;
        }
        else
        {
            sum += sl[i].b;
            ans += sl[i].b * sl[i].a;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (r, g, b) = (string(), string(), string());
    let s = r + &g + &b;
    println!(
        "{}",
        if s.parse::<i32>().unwrap() % 4 == 0 {
            "YES"
        } else {
            "NO"
        }
    );
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
  int a, b;
  char op;
  int res;

  while(1){
    scanf("%d %c %d", &a, &op, &b);

    if(op == '?') break;

    if(op == '+'){
      res = a + b;
    }
    else if(op == '-'){
      res = a - b;
    }
    else if(op == '*'){
      res = a * b;
    }
    else if(op == '/'){
      res = a / b;
    }

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


Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include<vector>
#include <set>
#define rep(i,n) for(i=0;i<n;i++)
#define P pair<int,int>
using namespace std;
int n;


int main()
{	
	int b, c, d, e, f, i, j, m=0, s, t;
	cin >> n;
	vector<int>a(n);
	vector<int>z(n);
	rep(i, n)cin >> a[i];
	for (i = n ; i > 0; i--) {
		b = n / i ;
		if (b == 1) {
			z[i - 1] = a[i - 1];
			if (z[i - 1] == 1)m++;
			continue;
		}
		c = 0;
		for (j = 2; j <= b;j++) {
			c = c + z[j * i - 1];
		}
		c = c % 2;
		if (c == a[i - 1])z[i - 1] = 0;
		else {
			z[i - 1] = 1; m++;
		}
	}

	cout << m<<"\n";
	rep(i, n) {
		if (z[i] == 1)cout << i + 1 << " ";
	}
	return 0;
}

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

int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		int sum = a + b;
		int ans = 0;
		while (sum > 0)
		{
			ans++;
			sum /= 10;
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	deque<int> ans;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(!(i % 2)) {
			ans.push_front(a);
		}
		else{
			ans.push_back(a);
		}
	}
	if(n % 2) {
		for(int i = 0; i < n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	else {
		for(int i = n - 1; i >= 0; i--) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	return 0;	
}


Measured memory_bytes: 3072
#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 n,l;cin>>n>>l;
  vector<string> vec(n);
  rep(i,n)cin>>vec[i];
  sort(all(vec));
  rep(i,n)cout<<vec[i];
  cout<<endl;
}

Measured memory_bytes: 3596
import sys
k,bisc_to_yen,yen_to_bisc = map(int,input().split())
if yen_to_bisc - bisc_to_yen <= 2 or k-1 < bisc_to_yen:# 後者は、「あと二回で終了」までに地道増やしが間に合わない場合
    print(k+1)
    sys.exit()
before_change = bisc_to_yen - 1
remain = k - before_change
num_change = remain//2
ans = num_change*(yen_to_bisc-bisc_to_yen)
if remain % 2 == 1:
    ans += 1
print(ans+bisc_to_yen)


Measured memory_bytes: 9096
# ABC097C - K-th Substring (ARC097C)
def substring_getter(a: str, x: int) -> set:
    length = len(a)
    ret = set()
    for i in range(length - x + 1):
        ret.add(a[i : i + x])
    return ret


def main():
    s = input()
    k = int(input())
    ans = set()
    for i in range(1, k + 1):
        ans = ans | substring_getter(s, i)
    print(sorted(ans)[k - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 4804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ret;
    for (int i = 2; n > 0; i += 5) {
        bool flag = true;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0)flag = false;
        }
        if (flag) {
            n--;
            ret.push_back(i);
        }
    }

    for (int i = 0; i < ret.size(); i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256