akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main()
{
	dhoom;
	int a , b , c;
	cin >> a >> b >> c;
	if(a == b)
		cout << c << endl;
	else if(b == c)
		cout << a << endl;
	else 
		cout << b << endl;
	
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;

    var a = input.split(' ')[0];
    var b = input.split(' ')[1];
    var diff = b - a;

    var height = 0
    for(var i = 0; i <= diff; i++){
        height += i;
    }
    
    var snow_height = height - b;
    console.log(snow_height);
});


Measured memory_bytes: 7500
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  
  rep(i, n) {
    cin >> a[i];
  }
  ll ans = INF;
  for(int i = 0; i + k - 1 < n; ++i) {
    ll s;
    if (a[i] < 0 && a[i + k - 1] > 0) {
      s = max(abs(a[i]), abs(a[i + k - 1])) + min(abs(a[i]), abs(a[i + k - 1])) * 2;
    } else {
      s = max(abs(a[i]), abs(a[i + k - 1]));
    }
    ans = min(ans, s);
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if (k <= a){
		cout << k;
	}else if(k <= a + b){
		cout << a;
	}else{
		cout << a - (k - a - b);
	}
}


Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int ans;

void dfs(int N, int K, int a) {
	if (N == 0) {
		ans = min(ans, a);
		return;
	}
	dfs (N - 1, K, a + K);
	dfs (N - 1, K, a * 2);
}

int main() {

	int N,K; cin >> N >> K;
	ans = 1e9;
	dfs(N, K, 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

map<ll, ll> prime_factorization(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while(n >= a*a){
    if(n % a == 0){
      ans[a]++;
      n /= a;
    }else{
      a++;
    }
  }
  ans[n]++;

  return ans;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  map<ll, ll> mp;
  rep2(i, 2, n+1){
    auto add = prime_factorization(i);
    for(auto p : add){
      mp[p.first] += p.second;
    }
  }
  
  mint ans = 1;
  for(auto p : mp){
    ans *= (p.second+1);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  int N, K, S;
  cin >> N >> K >> S;
  //入力終了

  //K個Sを並べた後，適当な数をN-K個並べればよい
  int ans[N];
  rep(i, K)
    ans[i] = S;
  
  //S=10^9のとき，S+1をans[]に入れると問題の条件を満たさないことに注意
  int insert;
  if(S == 1000000000)
    insert = 1;
  else
    insert = S+1;
  for(int i=K; i<N; i++)
    ans[i] = insert;

  //解答
  rep(i, N)
    cout << ans[i] << " ";
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define V vector<int>
#define VLL vector<ll>
#define VV vector<vector<ll>>
#define vec vector
#define scan(a) scanf("%d",&a)
#define print(a) printf("%d",a)
#define be(x) begin(x),end(x)
#define For(a) for(int i=0;i<a;i++)
#define Forin(j,a,b) for(int j=a;j<b;j++)
#define len(a) a.size()
#define pb push_back 
#define mp make_pair
#define Um unordered_map
#define Us unordered_set
#define F first
#define S second
#define mod 1000000007

void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    
    /*int t;
    cin>>t;
    while(t--)
    {
        //solve();
        solve();cout<<"\n";
        //cout<<"Case #"<<tc<<": "<<solve()<<"\n";
        //cout<<solve()<<"\n";
    }*/
    solve();
    cout<<"\n";
return 0;
}
void solve()
{
   ll n;
   cin>>n;
   cout<<!n;
}

Measured memory_bytes: 3608
A,B,K = gets.split.map(&:to_i)
a = Array.new
if A+K-1 < B-K+1

    for i in 0..K-1 
        a[i] = A+i
    end

    for i in K..(2 * K)-1
        a[i] = B-i+K
    end

else
    for i in 0..B-A
        a[i] = A+i
    end
end
puts a.sort

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
using namespace std;
int p[10];
int n,k;

int main()
{
   cin>>n>>k;
   for(int i=0;i<k;i++)
   {
   	int a;
   	cin>>a;
   	p[a]=1;
   }
   for(int i=n;i<=10*n;i++)
   {
   //	cout<<i<<endl;
   	int x=i;
   	 while(p[x%10]==0&&x!=0)
   	 {
   	   x/=10;	
	 }
	 if(x==0)
	 {
	 	cout<<i<<endl;
	 	return 0;
	 }
   }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#ダイクストラ法通常版
#O(ElogV)
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist): #キューから値が無くなるまで
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]: #既に最小距離が確定しているなら
            continue
        v = minedge[1] #vに頂点を代入
        d[v] = minedge[0] #その頂点のコストに重みを代入
        used[v] = False #vには最小距離が入っていることが証明できる(ヒープキューを使用しているため)
        for e in edge[v]: #頂点vから伸びている辺の先をヒープキューに入れてく
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d #回しきったらreturn(たどり着けなかった頂点はinf.)

################################
############input###############
################################
n = int(readline()) #n:頂点数　w:辺の数

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    x,y,z = map(int,readline().split()) #始点,終点,重み(重みがないなら全部1に固定すること)
    x,y = x-1,y-1 #zero indexedされていないならこれやること
    edge[x].append([z,y])
    edge[y].append([z,x]) #こっちもつけると無向グラフ

q,k = map(int,readline().split())

fromk = dijkstra_heap(k-1)



for i in range(q):
    x,y = map(int,readline().split())
    x,y = x-1,y-1
    print(fromk[x]+fromk[y])


Measured memory_bytes: 96032
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int sr, sc;
    cin >> sr >> sc;

    string s, t;
    cin >> s >> t;

    int flag = 0;  // flag = 0 のとき駒は盤上にある

    // 左に動かして外に出す場合
    int now = sc;  // いま駒のある列
    rep(i, n) {

        if(s[i] == 'L') {
            now--;
        }

        if(now < 1) {
            flag = 1;
            break;
        }

        if(now < w && t[i] == 'R') {
            now++;
        }

    }

    // 右に動かして外に出す場合
    now = sc;
    rep(i, n) {

        if(s[i] == 'R') {
            now++;
        }

        if(w < now) {
            flag = 1;
            break;
        }

        if(1 < now && t[i] == 'L') {
            now--;
        }
        
    }

    // 上に動かして外に出す場合
    now = sr;  // いま駒のある行
    rep(i, n) {

        if(s[i] == 'U') {
            now--;
        }

        if(now < 1) {
            flag = 1;
            break;
        }

        if(now < h && t[i] == 'D') {
            now++;
        }
        
    }

    // 下に動かして外に出す場合
    now = sr;
    rep(i, n) {
        
        if(s[i] == 'D') {
            now++;
        }

        if(h < now) {
            flag = 1;
            break;
        }

        if(1 < now && t[i] == 'U') {
            now--;
        }
        
    }

    if(flag) {
        cout << "NO";
    }
    else {
        cout << "YES";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 776
h, w = [int(v) for v in input().split()]
s = [list('.' * (w + 2))]
s.extend([list('.' + input() + '.') for i in range(h)])
s.append(list('.' * (w + 2)))

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == '.':
            cnt = 0
            cnt += s[i-1][j-1:j+2].count('#')
            cnt += s[i][j-1:j+2].count('#')
            cnt += s[i+1][j-1:j+2].count('#')
            s[i][j] = str(cnt)

for v in s[1:-1]:
    print(''.join(v[1:-1]))

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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> D(n);
	rep(i,n) scanf("%d",&D[i]);

	if(count(D.begin(),D.end(),12)>=2) return puts("0"),0;
	if(count(D.begin(),D.end(), 0)>=1) return puts("0"),0;

	for(int d=1;d<12;d++) if(count(D.begin(),D.end(),d)>=3) return puts("0"),0;

	if(n+1>12) return puts("1"),0;

	int ans=0;
	rep(S,1<<n){
		vector<int> a(n+1);
		rep(i,n) a[i]=(S>>i&1?D[i]:24-D[i]);

		int tmp=24;
		rep(i,n+1) rep(j,i) tmp=min({tmp,abs(a[i]-a[j]),24-abs(a[i]-a[j])});
		ans=max(ans,tmp);
	}
	printf("%d\n",ans);

	return 0;
}


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

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int n = IO.INT();
        int[] m = IO.INT(n);
        int p = 0;
        for (int i = 0; i < n; i++) { if (PRIME.ISPRIME(m[i])) { p++; } }
        IO.WRITE(p);
        IO.FLUSH();
    }
}
#region PRIME
namespace LIB
{
    public class PRIME
    {
        public static bool ISPRIME(int p)
        {
            bool f = false;
            if (p == 2) { f = true; }
            else if (p > 2 && (p % 2 != 0))
            {
                f = true;
                int q = (int)Math.Sqrt(p);
                for (int j = 3; j <= q; j += 2) { if (p % j == 0) { f = false; break; } }
            }
            return f;
        }
    }
}
#endregion
namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}

vector<ll> vec(100,0);

void emb(){
  vec[1] = 2;
  REP(i,2,100){
    vec[i] = vec[i-1] * vec[i-1];
    vec[i] %= mod;
    //cout << vec[i] << endl;
  }
}

int main(){
  ll n;
  ll a,b;

  cin >> n >> a >> b;
  ll ans = 1;
  emb();
//  rep(i,n){
//    ans *= 2;
//    ans %= mod;
//  }
  t1 = n;
  ll piv = 1;
  while(t1 != 0){
    if(t1 % 2 == 1){
      ans *= vec[piv];
      ans %= mod;
      //cout << piv << endl;
    }
    piv++;
    t1 /= 2;
  }
  //cout << ans << endl;


  ans--;//
  t1 = 1;
  rep(i,a){
    t1 *= (n - i);
    t1 %= mod;
    t1 *= modinv(i+1,mod);
    t1 %= mod;
  }
  ans -= t1;

  t1 = 1;
  rep(i,b){
    t1 *= (n - i);
    t1 %= mod;
    t1 *= modinv(i+1,mod);
    t1 %= mod;
  }
  ans -= t1;



  ans += mod * 3;
  ans %= mod;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  vector<char> a(4);
  for(int i =0;i<4;i++)
    cin >> a.at(i);
  
  if(a.at(0) == a.at(1)) cout << "Bad";
  else if(a.at(1) == a.at(2)) cout << "Bad";
  else if(a.at(2) == a.at(3)) cout << "Bad";
  else cout << "Good";
}

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>;

ll dfs(vector<int> &s, int i, ll sum, ll sa){
    int n = s.size();
    if (i == n - 1){
        return sa;
    }
    ll sa0 = sa + s[i + 1];
    ll sa1 = sa + sum * 9 + s[i + 1];
    return dfs(s, i + 1, s[i + 1], sa0) + dfs(s, i + 1, sum * 10 + s[i + 1], sa1);
}

int main(){
    string s0;
    cin >> s0;
    int k = s0.size();
    vector<int> s;
    for (char i : s0){
        s.push_back(i - '0');
    }
    ll ans;
    ans = dfs(s, 0, s[0], s[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int count = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) != t.charAt(i)) count++;
    }
    System.out.println(count);
  }
}

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

#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct{
  int id;
  int k;
  int *v;
  int color;
  int dscv;
  int fin;

}Graph;

Graph *G;
int n;
int **Adj;
int t;


void getDef(){
  int i,j;

  Adj = malloc(sizeof(int*) * (n+1));
  for(i=1;i<=n;i++){
    Adj[i] = malloc(sizeof(int) * (n+1));
    for(j=1;j<=n;j++){
      Adj[i][j] = 0;
    }
  }
}
/*
void getAdj(int id){
int i,j;

//printf("in getAdj\n");
for(j=1; j<=G[id].k; j++){
for(i = 1; i <= n; i++){
//printf("Adj[%d][%d]->G[id].v[j]:%d\n",id,i,G[id].v[j]);
if(G[id].v[j]==i){
Adj[id][i]=1;
}
//printf("Adj[%d][%d]->%d\n",id,i,Adj[id][i]);
}
//printf("%d\n",Adj[id-1][i]);
}
}
*/

void printer(){
  int i, j;

  for(i=1; i<=n; i++){
    printf("%d %d %d\n",G[i].id, G[i].dscv, G[i].fin);
  }
}

void visit(int id){
  int i;

  G[id].color = GRAY;
  G[id].dscv = ++t;
  for(i=1; i<=G[id].k; i++){
    if(G[G[id].v[i]].color == WHITE){
      visit(G[id].v[i]);
    }
  }
  G[id].color = BLACK;
  G[id].fin = ++t;
}

void dfs(){
  int i,j;

  for(i=1; i<=n; i++){
    G[i].color = WHITE;
  }
  t = 0;
  for(i=1; i<=n; i++){
    if(G[i].color == WHITE){
      visit(G[i].id);
    }
  }
}

int main() {
  int i, j;
  int id;

  //-----各種入力処理------
  scanf("%d",&n);
  G = malloc(sizeof(Graph) * (n+1));
  getDef();
  for (i = 1; i <= n; i++) {
    scanf("%d",&id);
    G[id].id = id;
    scanf("%d",&G[id].k);
    if(G[id].k != 0){
      G[id].v = (int*)malloc(sizeof(int) * (G[id].k+1));
      //G[id].color = (int*)malloc(sizeof(int) * (G[id].k+1));
      for(j = 1; j <= G[id].k; j++){
        scanf("%d",&G[id].v[j]);
      }
    }
    //getAdj(id);
  }
  dfs();
  //printf("fin enter\n");
  //---------------------
  printer();

  free(G);
  free(Adj);
  return 0;
}



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

string S; int dp[300009][4][3], mod = 1000000007;

int main() {
	cin >> S;
	dp[0][0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0' || S[i] == '?') {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 3; k++) {
					if (dp[i][j][k] == 0) continue;
					int s = k + 1; if (s == 3) s = 1;
					dp[i + 1][j][s] += dp[i][j][k];
					dp[i + 1][j][s] %= mod;
				}
			}
		}
		if (S[i] == '1' || S[i] == '?') {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 3; k++) {
					if (dp[i][j][k] == 0) continue;
					int s = k - 1, t = j; if (s == -1) { s = 0; t++; if (t >= 4) t = 3; }
					dp[i + 1][t][s] += dp[i][j][k];
					dp[i + 1][t][s] %= mod;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			if (i - j >= 1) { ans += dp[S.size()][i][j]; ans %= mod; }
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    ll n;
    cin>>n;
    
    vector<ld> p(n+1);
    for(ll i=1;i<=n;i++)
        cin>>p[i];
    
    ld dp[n+1][n+1] = {0};
    
    dp[1][0] = (1-p[1]);
    dp[1][1] = p[1];
    
    for(ll i=2;i<=n;i++){
        for(ll j=0;j<=n;j++){
            if(j>i)
                break;
            
            if(j!=0)
                dp[i][j] = dp[i-1][j-1] * p[i];
            dp[i][j] += dp[i-1][j] * ( 1-p[i] );
        }
    }
    
    
    
    ld ans = 0;
    for(ll i=0;i<=n;i++)
        if( i>(n-i) )
            ans += dp[n][i];
    
    cout<<fixed<<setprecision(10)<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 144436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int max_i = 0;
  int max = -1;
  for (int i = 0; i < N; i++) {
    if (A.at(i) > max) {
      max_i = i;
      max = A.at(i);
    }
  }
  int max_others = 0;
  for (int i = 0; i < N; i++) {
  	if (i != max_i) {
    	max_others += A.at(i);
    }
  }
  
  if (max < max_others) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


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

using namespace std;

int main() {
	long long a, b, n;
	scanf("%lld%lld%lld", &a, &b, &n);
	
	if (n >= b - 1) printf("%lld\n", a * (b - 1) / b);
	else printf("%lld\n", a * n / b);
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
    int d;
    cin >> d;
    
    if(d == 25){
        cout << "Christmas" << endl;
    } else if(d ==24){
        cout << "Christmas Eve" << endl;
    } else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

List = []
indexList = ['M', 'A', 'R', 'C', 'H']
for index in indexList:
    temp = []
    for i in range(N):
        if S[i][0] == index:
            temp.append(S[i])
    List.append(temp)
ans = 0
ans += len(List[0])*len(List[1])*len(List[2])
ans += len(List[0])*len(List[1])*len(List[3])
ans += len(List[0])*len(List[1])*len(List[4])
ans += len(List[0])*len(List[2])*len(List[3])
ans += len(List[0])*len(List[2])*len(List[4])
ans += len(List[0])*len(List[3])*len(List[4])
ans += len(List[1])*len(List[2])*len(List[3])
ans += len(List[1])*len(List[2])*len(List[4])
ans += len(List[1])*len(List[3])*len(List[4])
ans += len(List[2])*len(List[3])*len(List[4])
print(ans)


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

int main(void) {
	int i,c,n,hen[3];
	double h,a;
	scanf("%d",&n);
	
	for(i = 0; n > i; i++){
		scanf("%d%d%d",&hen[0], &hen[1], &hen[2]);
		for(c = 0; 3 > c; c++){
		if(hen[c]*hen[c] + hen[(c+1)%3] * hen[(c+1)%3] == hen[(c+2)%3]*hen[(c+2)%3]) {printf("YES\n");break;}
		}
		if(3 == c)printf("NO\n");
	}
	return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]にA_i-iの値を格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        A[i]-=(i+1);
    }
    qsort(A,N,sizeof(int),asc);

    long ans=0;
    int b;
    if(N%2==0){
        b=(A[N/2]+A[N/2-1])/2;
        for(int i=0;i<N;i++) ans+=abs(A[i]-b);

        b++;
        long tmp=0;
        for(int i=0;i<N;i++) tmp+=abs(A[i]-b);

        ans=MIN(ans,tmp);
    }
    else{
        b=A[N/2];
        for(int i=0;i<N;i++) ans+=abs(A[i]-b);
    }

    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 1788
import sys


def main():
    input = sys.stdin.readline
    N = int(input())

    robots = list()

    for i in range(N):
        x, arm = map(int, input().split())
        right = x+arm
        robots.append([x, right])

    robots.sort(key=lambda x: x[1])
    count = 0
    last_r = -10**10
    for x, r in robots:
        l = x - (r - x)
        if l < last_r:
            count += 1
        else:
            last_r = r

    print(N - count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21348
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 400005;

ll a[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int k, n;
    cin >> k >> n;
    FOR(i,1,n){
        cin >> a[i];
    }
    FOR(i,n+1,2*n){
        a[i] = k + a[i-n];
    }
    ll ans = 1e18;
    FOR(i,n,2*n){
        ans = min(ans, a[i] - a[i-n+1]);
    }
    cout << ans;

    
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

using ll = long long;
using ldb = long double;

#define forn(i, x, n) for (int i = x; i < (int)(n); ++i)
#define forcin(a, n) for (int i = 0; i < n; cin >> a[i], ++i)
#define forb(i, x, n) for (int i = (int)(x); i >= n; --i)
#define mmax(a, b, c) max(a, max(b, c))
#define mmin(a, b, c) min(a, min(b, c))
#define pb push_back
#define mp make_pair

const int N = 100500 * 3;
const long double eps = 1e-11;

int a[N];

int main() {
    int a, b;
    cin >> a >> b;
    if ( a * b % 2 ) {
        cout << "Odd\n";
    } else {
        cout << "Even";
    }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
xy = map(int, read().split())
graph = [[] for _ in range(N + 1)]

# その頂点に向かう辺の数
V = [0] * (N + 1)

for x, y in zip(xy, xy):
    graph[x].append(y)
    V[y] += 1

# その頂点に向かう辺がない頂点
start = [i for i, name in enumerate(V) if name == 0]

# 頂点iを終点とする最長パスの長さ
dp = [0] * (N + 1)
queue = []

while start:
    v = start.pop()
    for go in graph[v]:
        V[go] -= 1
        if V[go] == 0:
            start.append(go)
        dp[go] = max(dp[go], dp[v] + 1)

print(max(dp))

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

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

if(A == B){
    if(B!=C)cout <<"Yes";
    else cout << "No";
}
else {
    if(B==C)cout <<"Yes";
    else if(A == C)cout << "Yes";
    else cout << "No";
}
}

Measured memory_bytes: 256
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)1e5+10;
const ll DIV = (ll)1e9+7;
// ll dp[MAXN][MAXN];


int main(void) {
   ll N;
   cin>>N;
   vector<ll> A(N),B(N),C(N);
   rep(i,N) cin>>A[i];
   rep(i,N) cin>>B[i];
   rep(i,N) cin>>C[i];
   sort(A.begin(),A.end());
   sort(B.begin(),B.end());
   sort(C.begin(),C.end());
   ll ans = 0;
   rep (i,N) {
      ll a = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
      ll c = C.end() - upper_bound(C.begin(),C.end(),B[i]);
      // cout<<a<<" "<<c<<endl;
      ans += a*c;
   }
   cout<<ans<<endl;



   return 0;
}

Measured memory_bytes: 2560
N,*H=`dd`.split.map &:to_i
B=[0]*-~M=2**18
N.times{|i|j=k=H[i]
r=0
1while(r=[r,B[j]+H[N+i]].max;j&=j-1)>0
(B[k]=r;k+=k&-k)while B[k]&.<r}
p B[M]

Measured memory_bytes: 55828
def DFS(start,e):
    global edge
    global g
    global visited
    visited[start]=1

    cant=None
    if(e[0]==start):
        cant=e[1]
    elif(e[1]==start):
        cant=e[0]
    for ed in g[start]:
        if(ed==cant):
            continue
        if(visited[ed]==None):
            DFS(ed,e)
            

n,m=map(int,input().split())
g=[[] for _ in range(n)]
edge=[]

for _ in range(m):
    v,w=map(int,input().split())
    g[v-1].append(w-1)
    g[w-1].append(v-1)
    edge.append((v-1,w-1))


ans=0
for e in edge:
    visited=[None]*n
    DFS(0,e)
    flag=True
    for i in range(n):
        if(visited[i]==None):
            flag=False
    if(not flag):
        ans+=1

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

vector<ll> ans;
int make_divisors(ll n){
    for(ll i=1; i < ll(pow(n,0.5))+1; ++i){
        if(n % i == 0){
            ans.push_back(i + n/i);
        }
    }
    sort(ans.begin(), ans.end());
    return 0;
}

void Main() {
  ll N;
  cin >> N;
  make_divisors(N);
  OUT(ans[0]-2);
}

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

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  int N,i,k;
  scanf("%d\n",&N);
  char S[N];
  i,k = 0;
  scanf("%s",&S);
  while (i + 2 < N)
  {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
      k++;
    i++;
  }
  printf("%d",k);
}

Measured memory_bytes: 128
#include <stdio.h>
int ft_strcmp(char* S, char* T)
{
  int i;
  i = 0;
  while (S[i])
  {
    if (S[i] - T[i] != 0)
      return (S[i] - T[i]);
    i++;
  }
  return (S[i] - T[i]);
}

int main()
{
  char S[11],T[11],U[11];
  int A,B,i;
  scanf("%s %s\n",&S, &T);
  scanf("%d %d\n",&A,&B);
  scanf("%s",&U);
  i = 0;
  if (!(ft_strcmp(S,U)))
  {
    printf("%d %d",A - 1,B);
    return (0);
  }
  if (!(ft_strcmp(T,U)))
  {
    printf("%d %d",A,B - 1);
    return (0);
  }
  printf("%d %d",A,B);
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int, input().split()))

even, odd = [], []

for i in range(n):
  if i % 2 == 0:
    even.append(l[i])
  else:
    odd.append(l[i])

if n % 2 == 0:
  ans = odd[::-1] + even
else:
  ans = even[::-1] + odd
ans = map(str, ans)
print(' '.join(ans))

Measured memory_bytes: 31476
#include<stdio.h>
int f(int x){
    if(x%2==0)
        return x/2;
    else
        return 3*x+1;
}
int main(void){
    int s,i,j,c,A[1000];
    scanf("%d",&s);
    A[0]=s;
    c=0;
    for(i=1;i<1000;i++){
        A[i]=f(A[i-1]);
    }
    for(i=1;i<1000;i++){
        for(j=0;j<i;j++){
            if(A[i]==A[j]){
                printf("%d",i+1);
                c=1;
                break;
            }
        }
        if(c==1)
            break;
    }
    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void asc_sort(char str[]);
void des_sort(char str[]);

int main(void){
  int a[64];
  char num[16],format[16];
  int i,j,L,flg;

  while( scanf("%d %d",&a[0],&L) && L){
    flg=0;
    sprintf(format,"%%0%dd",L);
    for(i=1;i<64;i++){
      sprintf(num,format,a[i-1]);
      des_sort(num);
      a[i]=atoi(num);
      asc_sort(num);
      a[i]-=atoi(num);
      for(j=0;j<i;j++){
	if(a[j]==a[i]){
	  printf("%d %d %d\n",j,a[i],i-j);
	  flg=1;
	  break;
	}
      }
      if(flg) break;
    }
  }
  return 0;
}

void asc_sort(char str[]){
  int i,j,k,l;
  char min;
  l=strlen(str);
  for(i=0;i<l;i++){
    for(j=i+1,min=str[i],k=i;j<l;j++){
      if(min>str[j]){
	k=j;
	min=str[j];
      }
    }
    str[k]=str[i];
    str[i]=min;
  }
}

void des_sort(char str[]){
  int i=0,l;
  char strs[16];
  asc_sort(str);
  strcpy(strs,str);
  l=strlen(str);
  for(i=0;i<l;i++) str[i]=strs[l-1-i];
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
class Main{
	static final int MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		long k = saori.saorihayami();
		if(k%2 == 1){
			System.out.println((a-b)*-1);
		} else {
			System.out.println(a-b);
		}	
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const ll MOD = 1e9 + 7;
const int MAX = 5000010;
int lastInc[MAX] = {};

int cnt[100010] = {}, cnt1[100010] = {};

main()
{
    int n;
    cin >> n;
    int a[n];
    for (auto &x : a)
        cin >> x;
    int pref[n], suff[n];
    pref[0] = a[0], suff[n - 1] = a[n - 1];

    for (size_t i = 1; i < n; i++)
    {
        pref[i] = __gcd(pref[i - 1], a[i]);
    }
    for (int i = n - 2; i >= 0; i--)
    {
        suff[i] = __gcd(suff[i + 1], a[i]);
    }
    int ans = pref[n - 1];
    if (n == 1)
        return cout << a[0] << endl, 0;
    for (size_t i = 0; i < n; i++)
    {
        if (i == 0)
        {
            ans = max(ans, suff[1]);
        }
        else if (i == n - 1)
        {
            ans = max(ans, pref[n - 2]);
        }
        else
        {
            ans = max(ans, __gcd(pref[i - 1], suff[i + 1]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int n;
    cin >> n;
    deque<ll> b;
    ll inp;
    REP(i,n){
        cin >> inp;
        if(i%2)
            b.push_back(inp);
        else
            b.push_front(inp);
    }


    if(n % 2){
        for(int i=0; i < n; i++)
            printf("%lld ", b[i]);
    }
    else{
        for(int i=n-1; i >= 0; i--)
            printf("%lld ", b[i]);

    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        static long MOD = 1000000007L;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = in.nextIntArray(N);

            int[] cnt = new int[N];
            Arrays.fill(cnt, 3);
            long ans = 1;
            for (int i = 0; i < N; i++) {
                if (A[i] == 0) {
                    ans *= cnt[A[i]]--;
                } else {
                    ans *= (cnt[A[i]] - cnt[A[i] - 1]);
                    cnt[A[i]]--;
                }
                ans %= MOD;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 34608
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define mod 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
#define int long long

struct item {
    int wt;
    int val;
};

int solve(vector<item> ar, int n, int W) {
    int maxVal = n * 1000;
    int dp[n+1][maxVal + 1];

    for(int val = 0; val <= maxVal; val++)
    {
        dp[0][val] = imax;
    }

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

    for(int i = 1; i <= n; i++) {
        for(int v = 0; v <= maxVal; v++) {
            dp[i][v] = dp[i-1][v];
            if(ar[i].val > v) {
                continue;
            }
            dp[i][v] = min(dp[i][v], ar[i].wt + dp[i-1][v - ar[i].val]);
           // cout<<dp[i-1][v-ar[i].val]+ar[i].wt<<" ";
        }
       // cout<<"\n";
    }

  /*  for(int i=1;i<=n;i++)
    {
        for(int j=0;j<18;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<"\n";

    }*/
    int ans = 0;
    for(int val = 0; val <= maxVal; val++) {
        if(dp[n][val] <= W) {
            ans = val;
        }
    }
    return ans;

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, w; cin >> n >> w;
    vector<item> v(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> v[i].wt >> v[i].val;
    }
    cout << solve(v, n, w);

    return 0;
}


Measured memory_bytes: 82516
#include<stdio.h>
#include<string.h>
int main(){
	int n,t1=0,t2=0,i,tmp;
	char s1[128],s2[128];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",s1,s2);
		tmp=strcmp(s1,s2);
		if(tmp>=1)t1+=3;
		else if(tmp<=-1)t2+=3;
		else{
			t1++;
			t2++;
		}
	}
	printf("%d %d\n",t1,t2);
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62);

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m;
i64 x[101010], y[101010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < m; i++){
		cin >> y[i];
	}
	
	i64 X = 0, Y = 0;
	for(int i = 1; i < n; i++){
		X += (x[i] - x[i-1]) * i * (n-i);
		X %= INF;
	}
	for(int i = 1; i < m; i++){
		Y += (y[i] - y[i-1]) * i * (m-i);
		Y %= INF;
	}
	
	cout << X * Y % INF << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int cnt=0;
    for(auto c:s){
        if(c=='2') cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main(){
  ll n,k,sum=0,sum2=0;
  tuple<ll,ll,ll> c;
  cin>>n>>k;
  ll a[n];
  priority_queue<tuple<ll,ll,ll>> b;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(int i=0;i<n;i++){
    b.push({ceil(a[i]/(floor(k*a[i]/sum)+1)),floor(k*a[i]/sum)+1,a[i]});
    sum2+=floor(k*a[i]/sum);
  }
  for(int i=sum2;i<k;i++){
    c=b.top();
    b.pop();
    get<1>(c)++;
    get<0>(c)=get<2>(c)/get<1>(c)+(get<2>(c)%get<1>(c)==0 ? 0 : 1);
    b.push(c);
  }
  cout<<get<0>(b.top())<<endl;
}


Measured memory_bytes: 11112
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   int k; cin>>k;
   ll res=0;
   for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
        for(int kk=1;kk<=k;kk++){
            res+=__gcd(i,__gcd(j,kk));
        }
    }
   }
   cout<<res<<endl;
   End;
}


Measured memory_bytes: 3648