akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
 
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}
 
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
using namespace std;
 
typedef pair<int,int> pii;
 
int main(){
  int n;
  cin >> n;

  vector<int> v(n);
  REP(i,n){
    cin >> v[i];
  }

  int ans = 0;
  bool is_water = true;
  while(is_water){
    is_water = false;
    for(int i = 0; i < n; ++i){
      if(v[i] > 0){
        is_water = true;
        ans++;
        v[i]--;
        while(v[i+1] != 0 && i+1 < n){
          v[i+1]--;
          i++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
 



Measured memory_bytes: 256
n = int(input())
ans = 0
divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)

for i in divisors:
    if i == 1:
        continue
    if n//(i-1) == n%(i-1):
        ans += i-1
print(ans)

Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007;
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define tz(x) __builtin_ctz(x)
#define csb(x) __builtin_popcount(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;


int32_t main(){
int a,b;
cin>>a>>b;
for(int i=1;i<10000;i++){
	int x=i*8/100;int y=i*(0.1);
	if(x==a&&y==b){cout<<i<<endl;return 0;}
}
cout<<-1<<endl;

}

Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    ll hap[n][3];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> hap[i][j];

    ll dp[n][3];
    dp[0][0] = dp[0][1] = dp[0][2] = max(hap[0][0], max(hap[0][1], hap[0][2]));

    for (int i = 1; i < n; i++)
        for (int j = 0; j < 3; j++)
            dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + hap[i][j];

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
}


Measured memory_bytes: 4992
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];

    for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }

    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	vi a(n);
	int tot = 0;
	for(int i = 0; i < n; i++) cin >> a[i], tot ^= a[i];
	for(int i = 0; i < n; i++) cout << (a[i] ^ tot) << " ";
	
}





Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	cin >> s;
	cout << s.substr(0,3) << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int a, b;
	string s;
	cin >> a >> b >> s;

	for (int i = 0; i <= a + b; i++) {
		if (i == a) {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if (s[i] == '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int ans;
	int N;
	int max = 0,min = 1000;

	cin >> N ;
	
	for (int i = 0; i < N; i++) {
		cin >> ans;
		if (max < ans) {
			max = ans;
		}
		if (min > ans) {
			min = ans;
		}
	}
	
	cout << max - min << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13)
    cout << b << endl;
  else if (a >= 6)
    cout << b / 2 << endl;
  else
    cout << 0 << endl;
}


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

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

    if (N % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    
    // vector<ll> fives(N);
    // for (ll i=0; i<N; i++){
    //     fives[i] = 0;
    // }
    ll ans = 0;
    ll m = 5;
    while(m <= N){
        for (ll i=2; i < (N / m + 1); i+=2){
            if (i * m % 2 == 0){
                ans += 1;
            }
        }
        m *= 5;
    }

    // for (ll i=0; i<N/2; i++){
    //     while(arr[i] % 5 == 0){
    //         ans += 1;
    //         arr[i] /= 5;
    //     }
    // }
    // ll ans = 0;
    // for (ll i=0; i<N/2; i++){
    //     ans += fives[i*2];
    // }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
const main = (input) => {
  const k = parseInt(input.trim(), 10)

  const his = {}
  let last = 0
  let count = 0

  while (true) {
    const m = (last*10 + 7) % k
    if (m === 0) return console.log(count+1)
    if (his[m]) return console.log(-1)

    last = m
    his[m] = true
    count++
  }
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  ll K;
  cin >> N >> K;
  vector<pll> AB(N);
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    AB[i] = make_pair(a, b);
  }
  sort(AB.begin(), AB.end());
  for (int i = 0; i < N; i++) {
    if (K - AB[i].second > 0) {
      K -= AB[i].second;
    } else {
      cout << AB[i].first << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main(){
	ios_base::sync_with_stdio(false);
    ll k,x;
    cin >> k >> x;
    for(ll i=x-k+1;i<=x+k-1;i++){
        cout << i << " ";
    }
    cout << endl;
	return 0;
}

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

typedef long long ll;

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

    if (A >= K) {
        cout << K << endl;
    } else if (A+B >= K) {
        cout << A << endl;
    } else {
        cout << A  - (K-A-B) << endl;
    }
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (A >= 13) {
			System.out.println(B);
		}else if(A >= 6 && A <= 12){
			System.out.println(B/2);
		}else{
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 35672
#include <cstdio>
#include <vector>

using namespace std;

long long dp(
    int r, int c, int cnt, vector<vector<vector<long long>>> &rcd,
    const int n, const int m, const vector<vector<int>> &matrix
) {
    if (r == n)
    {
        return 0;
    } 
    else if (rcd[r][c][cnt] != -1)
    {
        return rcd[r][c][cnt];
    }
    else
    {
        long long maxv = 0;

        // take
        if (matrix[r][c] && cnt != 0)
        {
            if (c + 1 < m)
            {
                maxv = max(maxv, dp(r, c + 1, cnt - 1, rcd, n, m, matrix) + matrix[r][c]);
            }
            maxv = max(maxv, dp(r + 1, c, 3, rcd, n, m, matrix) + matrix[r][c]);
        }

        // don't take
        if (c + 1 < m)
        {
            maxv = max(maxv, dp(r, c + 1, cnt, rcd, n, m, matrix));
        }
        maxv = max(maxv, dp(r + 1, c, 3, rcd, n, m, matrix));

        rcd[r][c][cnt] = maxv;
        return maxv;
    }
}

int main() {
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    vector<vector<int>> matrix(n, vector<int>(m, 0));
    for (int idx = 0; idx < k; idx += 1)
    {
        int r, c, v;
        scanf("%d%d%d", &r, &c, &v);
        matrix[r - 1][c - 1] = v;
    }

    vector<vector<vector<long long>>> rcd(n, vector<vector<long long>>(m, vector<long long>(4, -1)));

    long long res = dp(0, 0, 3, rcd, n, m, matrix);
    printf("%lld\n", res);
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int X, Y; cin >> X >> Y;
  cout << X + Y / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=100005;

struct EDGE{
	int from,to,next;
} e[N*2];

int n,cnt;
int head[N],f[N];

void addedge(int u,int v){
	e[++cnt].from=u;e[cnt].to=v;e[cnt].next=head[u];
	head[u]=cnt;
}

void dfs(int x,int fa){
	f[x]=0;
	for (int i=head[x];i;i=e[i].next){
		if (e[i].to==fa) continue;
		dfs(e[i].to,x);
		f[x]^=f[e[i].to]+1;
	}
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v);addedge(v,u);
	}
	dfs(1,0);
	if (f[1]==0) puts("Bob");else puts("Alice");
}

Measured memory_bytes: 7936
n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
t = [[0] * n for i in range(n)]
for i in range(n-1):
    cc, cs, cf = csf[i][0], csf[i][1], csf[i][2]
    t[i][i] = cs
    for j in range(1+i):
        cs = csf[i][1]
        while t[j][i] > cs:
            cs += cf
        t[j][i+1] = cs + cc 
for i in range(n):
    print(t[i][n-1])

Measured memory_bytes: 76304
n = int(input())
 
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
 
 
a.sort()
b.sort()
c.sort()
 
 
from bisect import bisect_left,bisect_right
ans = 0
for i in b:
    count_a = bisect_left(a,i)
    count_c = n - bisect_right(c,i)
    ans += count_a * count_c
print(ans)

Measured memory_bytes: 23644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  double R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans=0;
  for(int r=0; r*R<=N; r++){
    for(int g=0; g*G+r*R<=N; g++){
      int tmp=(N-r*R-g*G)/B;
      if(r*R+g*G+B*tmp==N) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n,k;
ll a[51][51];
ll mod = 1000000007;
ll res[51][51];

void multiply() 
{ 
    ll res2[n+1][n+1];
    fr(i,1,n)
    { 
        fr(j,1,n) 
        { 
            res2[i][j] = 0; 
            fr(k,1,n) 
                res2[i][j] = ((res2[i][j]%mod) + ((a[i][k]%mod) * (a[k][j]%mod))%mod)%mod; 
        } 
    } 

    fr(i,1,n)
    {
        fr(j,1,n)
        {
            a[i][j] = res2[i][j]%mod;
        }
    }
}

void multiply2() 
{ 
    ll res2[n+1][n+1];
    fr(i,1,n)
    { 
        fr(j,1,n) 
        { 
            res2[i][j] = 0; 
            fr(k,1,n) 
                res2[i][j] = ((res2[i][j]%mod) + ((res[i][k]%mod) * (a[k][j]%mod))%mod)%mod; 
        } 
    } 

    fr(i,1,n)
    {
        fr(j,1,n)
        {
            res[i][j] = res2[i][j]%mod;
        }
    }
} 

void modexp()
{  
    fr(i,1,n)
    {
        res[i][i] = 1;
    }
    while (k > 0)
    {
        if (k & 1) 
        {
            multiply2();
        }   

        k = k>>1;     
        multiply();
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;

    fr(i,1,n)
    {
        fr(j,1,n)
        {
            cin >> a[i][j];
        }
    }

    ll ans = 0;
    modexp();

    fr(i,1,n)
    {
        fr(j,1,n)
        {
            ans = (ans + (res[i][j]%mod))%mod;
            // cout << res[i][j] << " ";
        }
        // cout << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int[][] array = new int[r+1][c+1];
		int intTemp = 0;
		int intSumC = 0;
		int intSumR = 0;
		for(int i = 0; i <= r; i++){
			intSumC = 0;
			for(int j = 0; j <= c; j++){
				if(i == r && j == c){
					for(int k = 0; k < c; k++){
						array[r][c] += array[r][k];
						intSumC = array[r][c];
					}
				}else if(i == r){
					for(int k = 0; k < r; k++){
						array[r][j] += array[k][j];
					}
				}else if(j == c){
					for(int k = 0; k < c; k++){
						array[i][c] += array[i][k];
					}
				}else{
					intTemp = scan.nextInt();
					array[i][j] = intTemp;
					intSumC += intTemp;
				}
				array[i][c] = intSumC;

			}

		}
		for(int i = 0; i < r + 1; i++){
			for(int j = 0; j < c + 1; j++){
				if(j == c){
					System.out.println(array[i][j]);
				}else{
					System.out.print(array[i][j] + " ");
				}
			}
		}
		scan.close();
	}
}

Measured memory_bytes: 39372
# 初期入力
import bisect
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted =sorted(V)

#取る個数take_num、返す個数reverse(t +r <=K)個全て決める

ans =[]
take_V =[] #最後に持っている宝石の価値
#Vが全てマイナスなら取らない
if V_sorted[-1] <=0:
    ans =0
else:
    take_num =min(K,N)
    for tak in range(1,take_num +1):
        reverse =min(K -tak,tak) #返す数はtake_numではなく、Kから引く
        for lef in range(tak+1):
            for rev in range(reverse +1):
            
                take =[]                    #取った宝石
                rig =N-(tak -lef )          #lef:左側の取る数 rig:右側の取る数
                take.extend(V[    :lef])
                take.extend(V[rig:   ])
                take.sort()
                take_V.append(sum(take[rev:]))
        
    ans =max(take_V)
print(ans)

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int N,K;

int main(){
	fast;
	
	cin>>N>>K;
	
	cout<<int(log(N)/log(K)) + 1;
	
}




Measured memory_bytes: 640
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
bool ck(string &s){
	rep(k,s.size()-1)if(s[k]!=s[k+1])return 0;
	return 1;
}
int main(){
	string s;
	while(cin>>s,s!="0"){
		int step=0; bool sc=ck(s);
		vector<string> frontier,next;
		frontier.push_back(s);
		set<string> visited; visited.insert(s);
		for(bool cg=1;cg&&!sc;step++){
			cg=0; next.clear();
			rep(i,frontier.size()){
				rep(j,frontier[i].size()-1){
					char c,cc=frontier[i][j],cn=frontier[i][j+1];
					if(cc==cn)continue;
					if(cc>cn)swap(cc,cn);
					if(cc=='b')c=cn=='g'?'r':'g';
					else c='b';
					
					string nx=frontier[i];
					nx[j]=nx[j+1]=c;
					if(visited.find(nx)==visited.end()){
						cg=1;
						sc=sc||ck(nx);
						next.push_back(nx),visited.insert(nx);
					}
				}
			}
			frontier=next;
		}
		if(sc)cout<<step<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1828
object Main extends App {
  import scala.math.max
  
  val Array(a,b,c,x,y) = readLine.split(" ").map{_.toInt}
  val z = max(x,y)
  
  println((for (i <- 0 to 2*z by 2; j = max(0,x-i/2); k = max(0,y-i/2)) yield i*c + j*a + k*b).min)
}

Measured memory_bytes: 41752
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int main(){
  int a,b;
  int max;
 
  scanf("%d %d", &a, &b);
 
  max = a + b;
  if(max < a - b) max = a - b;
  if(max < a*b) max = a*b;
 
  printf("%d\n", max);
  return 0;
}

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

#define rep(i,st,en) for(int i=st;i<=en;i++)
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

const int N=100000;
typedef long long LL;
const LL MOD=1000000007;
int ans[N];
bool vis[N];
map < int, pair<int,int> > M;

int main(){
    pair <int,int> p,now;
    FAST_IO;
    int n,m,d,q;
    cin>>n>>m>>d;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int tmp;
            cin>>tmp;
            p.first=i;p.second=j;
            M[tmp]=p;
        }
    }

    for(int k=1;k<=n*m;k++){
        if(!vis[k]){
            vis[k]=true;
            int sum=ans[k];
            now=M[k];
            for(int i=k+d;i<=n*m;i+=d){
                vis[i]=true;
                p=M[i];
                sum+=(abs(p.first-now.first)+abs(p.second-now.second));
                ans[i]=sum;
                now=p;
            }
        }
    }
    int l,r;
    cin>>q;
    while(q--){
        cin>>l>>r;
        cout<<ans[r]-ans[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    if(N%2) cout << N/2 << endl;
    else cout << N/2-1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    int n; cin >> n;
    vector<long long> as(n);
    long long sum=0;
    for(int i=0; i<n; ++i){
        cin >> as[i];
        sum+=as[i];
    }
    int i;
    long long acc=0;
    for(i=0; i<n && acc<sum/2; ++i){
        acc+=as[i];
    }
    long long ans=abs(acc-(sum-acc));
    acc=0;
    for(i=0; i<n-1 && acc+as[i]<sum/2; ++i){
        acc+=as[i];
    }
    ans=min(ans, abs(acc-(sum-acc)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	d := nextInt()
	var ans string
	switch d {
	case 25:
		ans = "Christmas"
	case 24:
		ans = "Christmas Eve"
	case 23:
		ans = "Christmas Eve Eve"
	case 22:
		ans = "Christmas Eve Eve Eve"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	set<int>a;

	int b[100000];
	int c, d;
	int k;
	int n, m;

	int x, y, z;


	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		y = a.erase(x);
		if (y == 0)a.insert(x);
	}

 printf("%d\n",a.size());

	return 0;
}

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

int main(){
    int n,m;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++){
        cin >> blue[i];
    }
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++){
        cin >> red[i];
    }

    int ans = 0;
    auto calc = [&](string s){
        int buff = 0;
        for (string t: blue){
            if (t == s){
                buff++;
            }
        }
        for (string t: red){
            if (t == s){
                buff--;
            }
        }

        return buff;
    };

    for (int i = 0; i < n; i++){
        ans = max(ans,calc(blue[i]));
    }

    cout << ans << endl;

}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string s;
    cin >> s;
    if(s=="SSS")COUT(0);
    else if(s=="RRS"||s=="SRR")COUT(2);
    else if(s=="RRR")COUT(3);
    else COUT(1);
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int n, cnt = 0;
    cin >> n;
    for(int a=1; a<n; a++){
        int b = 1;
        while(a*b<n){
            b++;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <unordered_set>
using namespace std;

int main(void) {
    long A = 0;
    cin >>A;
    cout << A + A*A + A*A*A << endl;
    return 0;
}



Measured memory_bytes: 3616
#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 ans = 0;
    int now = 1;
    int one = 0;
    for(int i=0; i<n; i++){
        if(a.at(i) == now){
            now++;
            one = 1;
        }
        else{
            ans++;
        }
    }
    if(one == 0) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
// AtCoder Beginner Contest 110 - Problem B: 1 Dimensional World's Tale (https://abc110.contest.atcoder.jp/tasks/abc110_b)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 200 };

int xs[MAX], ys[MAX];

void solve(int N, int M, int X, int Y)
{
    sort(xs, xs + N);
    sort(ys, ys + M);

    auto z = xs[N - 1] + 1;
    auto ans = z <= ys[0] and X < z and z <= Y;

    cout << (ans ? "No War" : "War") << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    REPN(i, N)
        cin >> xs[i];

    REPN(i, M)
        cin >> ys[i];

    solve(N, M, X, Y);

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 

int power(int x,int k)
{
	int ans=1;
	for(int i=1;i<=k;i++)
		ans*=x;
	return ans;
}
int32_t main()
{
	fastio();
	int n;
	cin>>n;

	int len=1;
	while(true){
		if(pow(26,len)>=n)
		{
			break;
		}
		n-=pow(26,len);
		len++;
	}
	n--;
	vector<int> ar(len,0);
	for(int i=len-1;i>=0;i--)
	{	
		ar[i]=n%26;
		n/=26;
	}
	for(int i=0;i<len;i++)
	{
		cout<<char('a'+ar[i]);
	}
}


Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
const double pi = 3.141592653589793;
using ll = long long;

class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};
double get_distance(Point a, Point b){
    return (a-b).abs();
}
int main() {
    double a, b, h, m; cin >> a >> b >> h >> m;
    Point p0 = Point(b * sin(pi * (m/double(30))), b * cos(pi * (m/double(30))));
    m += h * 60;
    Point p1 = Point(a * sin(pi * (m/double(360))), a * cos(pi * (m/double(360))));
    cout << fixed << setprecision(12) << get_distance(p0, p1) << endl;
}

Measured memory_bytes: 4100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextStr()

	if n[0] >= 'a' {
		fmt.Println("a")
		return
	}
	fmt.Println("A")
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
n,m = gets.split.map(&:to_i)
g = Array.new(n+1){[]}
 
m.times do
  f,t = gets.split.map(&:to_i)
  g[f].push t
  g[t].push f
end
 
ans = Array.new(n+1)
ans[0] = ans[1] = 0
 
queue = []
queue.push [1, g[1]]
 
while !queue.empty? do
  from, nexts = queue.shift
  nexts.each do |nex|
    next if ans[nex]
    ans[nex] = from
    queue.push [nex, g[nex]]
  end
end
 
if ans.include?(nil)
  puts 'No'
else
  puts 'Yes'
  2.upto(n).each do |i|
    puts ans[i]
  end
end

Measured memory_bytes: 35468
S = input()

s = list(S)

s.reverse()

#print (s)

lis = [0] * 13
lis[0] = 1
keta = 1

for i in range(len(S)):

    nlis = [0] * 13



    for j in range(10):

        for k in range(13):

            if s[i]== "?" or j == int(s[i]):
                nlis[ (k + (j * keta)) % 13] += lis[k]

    keta *= 10
    keta = keta % 13
    for j in range(13):
        lis[j] = nlis[j] % (10**9 + 7)

#print (lis)
print (lis[5] % (10**9 + 7))


Measured memory_bytes: 49648
/* ----------------------------
 * ABC 81 B
 * ---------------------------- */
#include <iostream>

using namespace std;

int main(){
	int n;
	int a[210];
	int count = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	while(true){
		for(int i = 0; i < n; i++){
			if(a[i]%2 != 0)
				goto OUT_OF_LOOP;
			a[i] /= 2;
		}
		++count;
	}
	OUT_OF_LOOP:
	cout << count << endl;
	return 0;
}



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

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

    int N, K; cin >> N >> K;
    vector<int> A(N, 0);
    rep(i, 0, N) {
        int in;
        cin >> in;
        ++A[in-1];
    }

    sort(A.begin(), A.end(), greater<int>());
    int rewritten = 0;
    rep(i, 0, N) {
        if (i >= K)
            rewritten += A[i];
    }

    cout << rewritten << "\n";
}

Measured memory_bytes: 1024
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	string s;
	cin >> s;
	bool flag = false;
	rep(i,s.size()-1){
		if(s[i] == 'A' && s[i+1] == 'C'){
			flag = true;
			cout << "Yes" << endl;
			break;
		}
	}
	if (!flag) cout << "No" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

char map[30][30];
int cnt=0;
int w,h;

void DFS(int x,int y);
int main(){

  int i,j;

  while(1){
    scanf("%d %d",&w,&h);
    if(w==0 && h==0) break;
    
    for(i=0;i<h;i++){
      scanf("%s",map[i]);
    }
    
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(map[i][j]=='@'){
	  DFS(j,i);
	  break;
	}
      }
    }
    
    printf("%d\n",cnt);
    cnt=0;
  }
  
  return 0;
}


void DFS(int x,int y){

  if(x<0 || y<0 || x>=w || y>=h) return;
  if(map[y][x]=='&' || map[y][x]=='#') return;

  map[y][x]='&';
  cnt++;

  DFS(x+1,y); DFS(x,y+1);
  DFS(x-1,y); DFS(x,y-1);


  return ;
}

Measured memory_bytes: 616
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 200000;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	
	cout << v[0] << " " << v[1] << " " << v[2] << endl;


	return 0;
}


Measured memory_bytes: 3136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, t;
vector<p> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>t;
    for (int i = 0; i < n; i++)
    {
        int tempa, tempb;
        cin >> tempa>>tempb;
        a.push_back(make_pair(tempa,tempb));
    }
    sort(ALL(a));
    ll dp[n+1][t+1+3000];
    for(int i=0;i<=t+3000;i++){
        for(int j=0;j<=n;j++){
            dp[j][i]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=t+3000;j++){
            if(j>=t){
                dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            }
            else{
                dp[i+1][j+a[i].first]=max(dp[i][j+a[i].first],dp[i][j]+a[i].second);
                if(j<a[i].first)
                dp[i+1][j]=dp[i][j];
                //cout<<dp[i+1][j+a[i].first]<<"\n";
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=t+3000;i++){
        //cout<<dp[n][i]<<"\n";
        ans=max(ans,dp[n][i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 141056
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    vector<int> a(n + 1);
    vector<int> b(n);
    for (int i = 0; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    long long res;
    if (a[0] < b[0]) {
        res = a[0];
        b[0] -= a[0];
    } else {
        res = b[0];
        b[0] = 0;
    }

    for (int i = 1; i < n; i++) {
        if (b[i - 1] > 0) {
            res = res + min(a[i], b[i - 1]);
            a[i] = max(a[i] - b[i - 1], 0);
        }

        res = res + min(a[i], b[i]);
        b[i] = max(b[i] - a[i], 0);
    }

    if (b[n - 1] > 0) res += min(a[n], b[n - 1]);

    cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int p[20202];
int a[20202], b[20202];

signed main()
{
    cin >> N;
    REP(i,N) cin >> p[i];

    REP(i,N) a[i] = N * (i + 1);
    REP(i,N) b[i] = N * (N - i);

    REP(i,N) {
        a[p[i]-1] += i;
    }

    REP(i,N) {
        if (i == 0) cout << a[i];
        else cout << " " << a[i];
    }
    cout << endl;
    REP(i,N) {
        if (i == 0) cout << b[i];
        else cout << " " << b[i];
    }
    cout << endl;
}


Measured memory_bytes: 1152
from functools import reduce


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


N = int(input())
a_list = list(map(int, input().split()))
gcd_list = [a_list[-1]]
for idx in range(N - 2, 0, -1):
    gcd_list.append(gcd(gcd_list[N - 2 - idx], a_list[idx]))
max_gcd_a = gcd_list[-1]
gcd_list.append(1)
gcd_list.reverse()

for idx in range(1, N):
    if idx != 1:
        left_gcd = gcd(left_gcd, a_list[idx - 1])
    else:
        left_gcd = a_list[0]
    if idx < N - 1:
        right_gcd = gcd_list[idx + 1]
    else:
        right_gcd = left_gcd

    gcd_a = gcd(left_gcd, right_gcd)
    if max_gcd_a < gcd_a:
        max_gcd_a = gcd_a

print(max_gcd_a)

# どれか１つを除いた時の最大公約数で最大のもの


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

int main(){
    int N;
    cin>>N;
    long long ans=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0){
            if(i%5!=0){
                ans+=i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int n,m,i,j,k,l,num,renew = 0;

  scanf("%d",&n);

  int A[n+1],M[n+1][n+1];
  for(i = 0;i <= n;i++){
    A[i] = 0;
    for(j = 0;j <= n;j++){
      M[i][j] = 0;
    }
  }

  for(i = 1;i <= n;i++){
    scanf("%d",&num);
    scanf("%d",&m);
    for(j = 1;j <= m;j++){
      scanf("%d",&k);

      M[num][k] = 1;

      if(k == 1) continue;

      if(num != 1 && A[num] == 0) A[num] = -1;
      else if(A[k] == 0) A[k] = A[num] + 1;
      else if(A[k] > A[i] + 1){
        A[k] = A[num] + 1;
        renew = 1;
      }

      if(renew == 1){
        for(l = 1;l <= n;l++){
          if(M[k][l] == 1){
            if(A[l] > A[k] + 1) A[l] = A[k] + 1;
          }
        }
      }
      renew = 0;
    }
  }

  printf("1 %d\n",A[1]);

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



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll r,g,b,n;

int main(){
    cin >> r >> g >> b >> n;
    ll ans = 0;
    rep(i,n/r+1){
        rep(j,n/g+1){
            ll cnt = i*r+j*g;
                // cout << i << " " << j << " " << cnt << endl;
            if(n - cnt < 0)continue;
            if((n - cnt) % b == 0){
                // cout << i << " " << j << " " << cnt << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = input()

dict = {}
max_n = 0
for i in range(n):
    if dict.get(s[i]) == None:
        dict[s[i]] = 1
        max_n = max(max_n, dict[s[i]])
    else:
        dict[s[i]] += 1
        max_n = max(max_n, dict[s[i]])
#print(dict)

ans = []
for k, v in dict.items():
    if v == max_n:
        ans.append(k)

ans = sorted(ans)

for output in ans:
    print(output)

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

int main(){
    int k, a, b;
    cin >>k >> a >> b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout <<"OK" << endl;
            return 0; 
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
mod = 10**9+7


def mat_mul(A, B):
    # A,Bは正方行列とする
    C = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            C[i][j] = sum(A[i][k] * B[k][j] for k in range(N)) % mod
    return C


def matpow(A, n):
    B = [[0]*N for _ in range(N)]
    for i in range(N):
        B[i][i] = 1
    while n > 0:
        if n & 1:
            B = mat_mul(A, B)
        A = mat_mul(A, A)
        n //= 2
    return B


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]
    A = matpow(A, K)
    ans = 0
    for a in A:
        ans = (ans + sum(a)) % mod
    print(ans)


Measured memory_bytes: 71004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, c; cin >> n >> c;
  vector<vector<ll>> D(c, vector<ll>(c));
  rep(i, c) rep(j, c) cin >> D[i][j];
  vector<vector<ll>> C(n, vector<ll>(n));
  rep(i, n) rep(j, n) cin >> C[i][j];
  vector<map<ll, ll>> cnt(3);
  rep(i, n) rep(j, n) {
    cnt[(i+j)%3][C[i][j]-1]++;
  }
  ll ans = longinf;
  vector<bool> used(c);
  auto dfs = [&](auto dfs, int k, ll cost) {
    if(k == 3) {
      ans = min(cost, ans);
      return;
    }
    rep(i, c) {
      if(!used[i]) {
        ll tmp = 0;
        for(auto ele: cnt[k]) tmp += D[ele.first][i] * ele.second;
        used[i] = true;
        dfs(dfs, k+1, cost+tmp);
        used[i] = false;
      }
    }
  };
  dfs(dfs, 0, 0);
  cout << ans << "\n";
  return 0;
}


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

int main(void){
	int a,b,A,B;
	cin>>a>>b;
	if(b==1){
	    A=a;
	}
	if(b==2){
	    A=a*11;
	}
	if(b==3){
	    A=a*111;
	}
	if(b==4){
	    A=a*1111;
	}
	if(b==5){
	    A=a*11111;
	}
	if(b==6){
	    A=a*111111;
	}
	if(b==7){
	    A=a*1111111;
	}
	if(b==8){
	    A=a*11111111;
	}
	if(b==9){
	    A=a*111111111;
	}

	if(a==1){
	    B=b*1;
	}
	if(a==2){
	    B=b*11;
	}
	if(a==3){
	    B=b*111;
	}
	if(a==4){
	    B=b*1111;
	}
	if(a==5){
	    B=b*11111;
	}
	if(a==6){
	    B=b*111111;
	}
	if(a==7){
	    B=b*1111111;
	}
	if(a==8){
	    B=b*11111111;
	}
	if(a==9){
	    B=b*111111111;
	}
    
    if(a>b){
        cout<<B<<endl;
    }
    else{
        cout<<A<<endl;
    }

}
	
	
	
	

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

int main() {
  int N, M;
  cin >> N >> M;
  int A[200010], B[200010];
  for (int i = 0; i < M; i++)
    cin >> A[i] >> B[i];
  
  map<int, int> mp_AC;
  map<int, int> mp_CB;
  
  for (int i = 0; i < M; i++) {
    if (A[i] == 1)
      mp_AC[B[i]]++;
    else if (B[i] == N)
      mp_CB[A[i]]++;
  }
  
  for (auto x: mp_AC) {
    int k = x.first;
    if (mp_CB[k] > 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 15872