akhauriyash/Code-Regression huggingface dataset:
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{
        int ans = 0;
        while (N)
        {
                ans++;
                N /= 10;
        }
        return ans;
}

int main()
{
        int A, B, K;
        cin >> A >> B >> K;
        for (int i = min(A, B); i > 0; i--)
        {
                if (A % i == 0 && B % i == 0)
                {

                        K--;
                }
                if (K == 0)
                {
                        cout << i << endl;
                        return 0;
                }
        }

        return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
if n%2!=0:
  al.append(a[-1])
print(sum(al)-sum(bo))

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
namespace boost {template <class T>struct integer_iterator {T a;bool operator != (integer_iterator const & it) const { return a != it.a; }T operator * () const { return a; }integer_iterator & operator ++ () { ++ a; return *this; }integer_iterator operator ++ (int) { return { a ++ }; }};template <class T>struct integer_range {T l, r;typedef integer_iterator<T> iterator;iterator begin() const { return { l }; }iterator end  () const { return { r }; }};template <class T>integer_range<T> irange(T l, T r) { assert (l <= r); return { l, r }; }template <class T>struct integer_iterator_with_step {T a, d, i;bool operator != (integer_iterator_with_step const & it) const { return a != it.a or d != it.d or i != it.i; }T operator * () const { return a+d*i; }integer_iterator_with_step & operator ++ () { ++ i; return *this; }integer_iterator_with_step operator ++ (int) { return { a, d, i ++ }; }};template <class T>struct strided_integer_range {T l, r, s;typedef integer_iterator_with_step<T> iterator;iterator begin() const { return { l, s, 0 }; }iterator end  () const { return { l, s, (r - l) / s }; }};template <class T>strided_integer_range<T> irange(T l, T r, T s) { assert (s > 0 ? l <= r : s < 0 ? l >= r : false); return { l, r, s }; }}
typedef long long ll;
using namespace std;
using namespace boost;
#define MAX_H 250
int main() {
    int h; cin >> h;
    vector<ll> heap;
    for (int query : irange(0,h)) {
        ll k; cin >> k;
#if 0
        int i = heap.size();
#endif
        heap.push_back(k);
#if 0
        while (i != 0) {
            int j = i / 2;
            if (heap[i] > heap[j]) {
                swap(heap[i], heap[j]);
                i = j;
            } else {
                break;
            }
        }
#endif
    }
    for (int i : irange(0,h)) {
        printf("node %d: ", i+1);
        printf("key = %lld, ", heap[i]);
        if (i != 0) printf("parent key = %lld, ", heap[(i-1)/2]);
        if (i*2+1 < heap.size()) printf( "left key = %lld, ", heap[i*2+1]);
        if (i*2+2 < heap.size()) printf("right key = %lld, ", heap[i*2+2]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1204
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll b_p(ll b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p ^ 1));
    ll v = b_p(b, p >> 1);
    return ml(v, v);
}

const int MAXN = 2000 + 25;

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

ll dp[MAXN];

void solve() {

    int s;
    cin >> s;

    dp[0] = 1;

    for (int sum = 0; sum< MAXN; ++ sum) {

        for (int j = 0; j <= sum - 3 ;++ j) {
            dp[sum ] =add(dp[sum], dp[j]);
        }

    }



    cout << dp[s];
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;



int main() {
    ll N; cin >> N;
    vll P(N + 1, 0);
    vll id(N + 1, 0); // id[x] = y : 数xがPでy番目にある(1-indexed)
    rep(i, N) {
        cin >> P[i + 1];
        id[P[i + 1]] = i + 1;
    }

    multiset<ll> S;
    S.insert(0); S.insert(0);
    S.insert(N + 1); S.insert(N + 1);
    ll ans = 0;

//数Nから降順に寄与を計算
    for (int i = N; i >= 1; i--) { 
        S.insert(id[i]);
        auto itr = S.find(id[i]); //multiset<int>::iterator
        auto itr2 = itr;
        ll x, y, u, v;
        y = *(--itr); x = *(--itr);  //setやmultisetのイテレータはランダムアクセス不可能なので+-1できない！
        u = *(++itr2); v = *(++itr2); //が、インクリメントはできるのでそれで地道に・・・
        ll a = (y - x) * (u - id[i]) + (id[i] - y) * (v - u);
        ans += a * i;
    }

    cout  << ans << endl;


}


Measured memory_bytes: 6528
def make_divisors(n):
    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)

    divisors.sort(reverse = True)
    return divisors
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = sum(A)
divisors = make_divisors(m)
for d in divisors:
    A1 = list(map(lambda x:x%d, A))
    A1.sort()
    res = 0
    index = N
    for i in range(N):
        res+=A1[i]
        if res>K:
            res-=A1[i]
            index = i
            break
    
    res1 = 0
    for i in range(index, N):
        res1+=d-A1[i]
    if res>=res1:
        ans = d
        break
print(ans)        
    

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int N=read();
		if(N==0) break;
		int a[N];
		int minimum=100000000;
		REP(i,N){
			a[i]=read();
		}
		sort(a,a+N);
		REP(i,N-1){
			minimum = min(a[i+1]-a[i],minimum);
		}
		cout << minimum<<endl;
	}
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int N,K;
  cin>>N>>K;
  if(N%K ==0){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>dc;
  int a=1;
  while(a<=n){dc.push_back(a);a*=6;}
  a=9;
  while(a<=n){dc.push_back(a);a*=9;}
  sort(all(dc));
  vector<int>dp(n+1,1e9+7);
  dp[1]=1;
  dp[0]=0;
  //for(auto t:dc)cout<<t<<endl;
  while(dp[n]==1e9+7)
  {
    auto tdp=dp;
    for(auto c:dc)
    {
      rep(i,n-c+1)
      {
        chmin(tdp[i+c],dp[i]+1);
      }
    }
    dp=tdp;
  }
  cout<<dp[n]<<endl;

  return 0;

}


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0;i<n;i++)
	{
		cin >> a[i];
	}
	for(int i = 0;i<n;i++)
		cin >> b[i];

	int Ans = 0;

	for(int i = 0;i<n;i++)
	{
		int ans = 0;
		for(int j = 0;j<=i;j++)ans+=a[j];
		for(int j = i;j<n;j++)ans+=b[j];
		Ans = max(ans,Ans);
	}
	cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

bool cmp1(pair<long, long> a, pair<long, long> b){
    return a.first < b.first;
}
bool cmp2(pair<long, long> a, pair<long, long> b){
    return a.second < b.second;
}

int main(int argc, char const *argv[])
{
    long n;
    scanf("%ld\n", &n);
    vector<pair<long, long>> r;
    for(int i=0; i<n; i++){
        long x, l;
        scanf("%ld %ld\n", &x, &l);
        r.push_back(make_pair(x-l, x+l));
    }

    sort(r.begin(), r.end(), cmp2);
    long e = r[0].second;
    long cnt = 1;
    for(int i=1; i<n; i++){
        if(r[i].first >= e){
            e = r[i].second;
            cnt++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 2420
N = int(input())
a = list(map(int,input().split()))

cnt = 0
for i in range(N):
	if ((i+1) % 2 != 0) and (a[i] % 2 != 0):
		#print("i,a[i]",i,a[i])
		cnt += 1

print(cnt)

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <bitset>
#include <ctime>
 
using namespace std;
 
typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

struct Math
{
	typedef long long Long;
	static int egcd(int a, int b){
		int x,y;
		return egcd(a,b,x,y);
	}
	// ax + by = c
	static int egcd(int a,int b, int &x, int &y) {
		x = 1, y = 0;
		int nx = 0, ny = 1;
		int nr = b, r = a;
		while(nr != 0) {
			int q = r / nr;
			tie(r, nr) = make_tuple(nr, r - q*nr);
			tie(x, nx) = make_tuple(nx, x - q*nx);
			tie(y, ny) = make_tuple(ny, y - q*ny);
		}
		// bezout = x , y 
		// gcd    = o_r
		return r;
	}
	static int MOD;
	static Long modInv(Long a, Long b)
	{
		int x,y; egcd(a,b,x,y);
		return x < 0 ? x + b : x;
	}
	static Long divide(Long a, Long b)
	{
		return a * modInv(b, MOD) % MOD;
	}
	static int fact(int n)
	{
		static vector<int> F;
		if(F.size() <= n)
		{
			int oSZ = F.size();
			F.resize(n+1);
			if(oSZ == 0)F[0] = 1 , oSZ++;
			for(int i = oSZ; i <= n; ++i)
				F[i] = (1LL * F[i-1] * i) % MOD;
		}
		return F[n];
	}
	static int catalan(int n)
	{
		return divide(ncr(2*n,n), n+1);
	}
	static int ncr(int n,int k)
	{
		if(k < 0 || n < 0 || n < k)return 0;
		return divide(fact(n) , (1LL * fact(k) * fact(n-k)) % MOD);
	}
	static int mul(int a,int b){
		return (1LL*(a%MOD)*(b%MOD))%MOD;
	}
	static int  mul(int a,int b,int c){
		return (1LL*mul(a,b)*(c%MOD))%MOD;
	}
	static int  mul(int a,int b,int c,int d){
		return (1LL*mul(a,b)*mul(c,d))%MOD;
	}
	static bool solveDiophantine(int a, int b, int c, int &x, int &y) {
		int gc = egcd(a,b,x,y);
		if(c % gc != 0)return false;
		int d = c / gc;
		x *= d;
		y *= d;
		return true;
	}
	static void moveBezout(int a,int b, int c, int &x, int &y, int pos = 1){
		int gc = egcd(a,b);
		b /= gc;
		a /= gc;
		x += b * pos;
		y -= a * pos;
	}
};
int Math::MOD = 998244353;

int main(int argc, char *argv[]) {
	
	Long N, A, B, K;
	cin >> N >> A >> B >> K;
	
	Long ways = 0;
	for (int i = 0; i <= N && i * A <= K; ++i) {
		Long RK = K - i * A;
		if (RK % B != 0) continue;
		Long j = RK / B;
		if (j > N) continue;
		ways = (ways + Math::mul(Math::ncr(N, i), Math::ncr(N, j))) % Math::MOD;
	}
	cout << ways << endl;
	
}


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

void output(int A[], int N) {
    int i;

    for (i=0; i<N; i++){
        if (i>0) {
            cout << " ";
        }
        cout << A[i];
    }
    
    cout << endl;
}

void insertionSort(int A[], int N) {
    int i, j, v;
    
    for (i=0; i<N; i++) {
        v = A[i];
        j = i - 1;
        
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        output(A, N);
    }
}

int main() {
    int N, i;
    cin >> N;
    
    int A[N];
    for (i=0; i<N; i++) {
        cin >> A[i];
    }
    
    insertionSort(A, N);
    
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
#define N 25

typedef struct{
  int p;
  int sib;
  int left;
  int right;
  int deg;
  int dep;
  int hei;
  
}Node;

Node T[N];

void preParse(int);
void inParse(int);
void postParse(int);

int n;
int main(){
  int i,k,l,r,key,d;

  scanf("%d",&n);

   for(i=0;i<n;i++){
   T[i].p=-1;
   T[i].sib=-1;
   }
  for(i=0;i<n;i++){
    scanf("%d",&key);
    scanf("%d",&l);
    scanf("%d",&r);
    T[key].left=l;
    T[key].right=r;

      T[l].p=key;
      T[r].p=key;
  }

 
  for(i=0;i<n;i++){
    if(T[i].p==-1){printf("Preorder\n");
                    preParse(i);
		    printf("Inorder\n");
                   inParse(i);
		   printf("Postorder\n");
                  postParse(i); 
    }
  }             
  return 0;
}

void preParse(int u){
  static int count=0;
  if(u==-1) return;
  if(count==n-1) printf(" %d\n",u);
  else printf(" %d",u);
  count++;
        preParse(T[u].left);
        preParse(T[u].right);
 
}

void inParse(int u){
  static int count=0;
   if(u==-1) return;
       inParse(T[u].left);
       if(count==n-1) printf(" %d\n",u);
 
       else printf(" %d",u);
	 count++;
       inParse(T[u].right);
}

void postParse(int u){
  
  if(u==-1) return;
       postParse(T[u].left);
       postParse(T[u].right);
  if(T[u].p==-1) printf(" %d\n",u);
  else  printf(" %d",u);
         
}
   

Measured memory_bytes: 612
//https://atcoder.jp/contests/abc140/tasks/abc140_d
//D - Face Produces Unhappiness
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
//    cin.tie(0);
//    ios::sync_with_stdio(false);
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,K; cin>>N>>K;
    string S; cin>>S;

    ll count=0;
    auto sha=[&](ll no){
        if (no<0||no>=S.size()) return 'x';
        return S[no];
    };
    REP(i,S.size()){
        if(sha(i)=='R'){
            if(sha(i+1)=='R') ++count;
        } else { //L
            if(sha(i-1)=='L') ++count;
        }
    }
    //lr,rl    
    ll lr=0,rl=0;
    REP(i,S.size()){
        if(sha(i)=='L'&&sha(i+1)=='R') ++lr;
        if(sha(i)=='R'&&sha(i+1)=='L') ++rl;
    }
//    cout<<"LR:"<<lr<<endl;;
//    cout<<"RL:"<<rl<<endl;;
    auto tmp = min(lr,rl);
    tmp=min(K,tmp);
    count+=tmp*2;
    K-=tmp;
    if(K>0){
        lr-=tmp;
        rl-=tmp; 
        tmp=max(lr,rl);       
        count += min(K,tmp);
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 512
using System;
class Aoj
{
    public static void Main()
    {
        while (true)
        {
            String[] st = Console.ReadLine().Split(' ');
            int a = int.Parse(st[0]);
            int b = int.Parse(st[2]);
            int sum=0;
            if (st[1] == "+")
                sum = a + b;
            else if (st[1] == "-")
                sum = a - b;

            else if (st[1] == "/")
                sum = a / b;

            else if (st[1] == "*")
                sum = a * b;

            else if (st[1] == "?")
                break;

                Console.WriteLine("{0}", sum);
        }
    }

}

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
using namespace std;
#define MAX 100001

bool prime[MAX];
void calcPrime(){
	for(int i = 0; i < MAX; i++) prime[i] = true;
	for(int i = 2; i < MAX; i++){
		if( prime[i] ){
			for(int j = i+i; j < MAX; j += i){
				prime[j] = false;
			}
		}
	}
}

int main(){
	int n;
	calcPrime();
	while( cin >> n ){
		int under = -1, over = -1;
		for(int d = n, u = n; 2 < d || u < MAX; ){
			if( under != -1 && over != -1 ) break;
			if( under == -1 && 2 < d ){
				d--;
				if( prime[d] ) under = d;
			}
			if( over == -1 && u < MAX ){
				u++;
				if( prime[u] ) over = u;
			}
		}
		cout << under << " " << over << endl;
	}
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    vector<pair<ll,ll>> jobs;

    REP(i,N){
        ll A, B;
        cin >> A >> B;
        jobs.push_back(make_pair(B,A));
    }
    sort(jobs.begin(), jobs.end());


    ll cur = 0;
    REP(i,N){
       cur += jobs[i].second;
       if( jobs[i].first < cur ){
         cout << "No" << endl;
         return 0;
       }

    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6512
x=int(input())
if x==2:
    print(2)
else:
    while True:
        cnt=0
        if x%2==0:
            x+=1
            continue
        for i in range(2,x):
            if x%i==0:
                cnt=1
                continue
        if cnt==1:
            x+=1
        else:
            print(x)
            break

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
void dfs(int node,vector<int>&visited,vector<vector<int> >&adj)
{
	for(auto var:adj[node])
	{
		if(visited[var])
		 continue;
		visited[var]=1;
		dfs(var,visited,adj);
	}
	
}
int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int> >adj(n+1);
	for(int i=1; i<=m; i++){
		int x,y,z;
		cin>>x>>y>>z;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	vector<int>visited(n+1);
	int ans=0;
	for(int i=1; i<=n; i++){
		if(!visited[i]){
			ans++;
			visited[i]=1;
			dfs(i,visited,adj);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    for(ll i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
    ll ans = 0;
    for(ll i = k; i < n; i++)
    {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in =new Scanner(new BufferedInputStream(System.in));
		while(in.hasNext())
		{
			BigInteger a = in.nextBigInteger(),b = in.nextBigInteger();
			System.out.println(a.multiply(b));
		}
		in.close();
	}

}


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

float prob(int i,int k){
  int cnt = 0;
  while (i < k)
  {
    i *= 2;
    cnt++;
  }
  return cnt;
}

int main(){
  double n, k;
  cin >> n >> k;
  if(n<k){
    double p = 0;
    for (int i = 1; i <= n;i++)
    {
      double a = 1.0 / n;
      double b = pow(0.50, prob(i, k));
      p += a * b;
    }
    cout << fixed << setprecision(12) << p << endl;
  }else{
    double p = 0;
    for (int i = 1; i <= k; i++)
    {
      double a = 1.0 / n;
      double b = pow(0.50, prob(i, k));
      p += a * b;
    }
    p += (1.0 - k / n);
    cout << fixed<<setprecision(12)<<p << endl;
  }
}

Measured memory_bytes: 4168
using System.Linq;
using static System.Console;

namespace AtCoder.Probrems.Solvers.ABC118
{
    public class _C
    {
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        static long N;
        static long[] A;

        public static long Solve()
        {
            N = long.Parse(ReadLine());
            A = ReadLine().Split().Select(long.Parse).ToArray();
            var ans = 0L;
            for (int i = 0; i < A.Length; i++)
            {
                ans = Battle(A[i], ans);
            }
            return ans;
        }

        static long Battle(long l, long r)
        {
            if (l < r)
                return Battle(r, l);

            if (r == 0)
                return l;

            return Battle(r, l % r);
        }

        private const int MOD = 1000000007;
    }
}


Measured memory_bytes: 20832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{

    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int ans = 0;
            for (int i = 0; i <=A ; i++)
            {
                for (int j = 0; j <=B ; j++)
                {
                    for (int k  = 0; k<=C ; k++)
                    {
                      if(X - (500 * i + 100 * j + 50 * k)==0){
                        ans++;
                      }
                    }
                }
            }
          Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int search(int A[], int n, int key){
 int i=0;
 A[n]=key;
 while (A[i]!=key)i++;
 return i!=n;
 }

int main(){
 int i,n, A[10000+1],q,key,sum=0;
 scanf("%d", &n);
 for(i=0; i< n; i++) scanf("%d" ,&A[i]);

 scanf("%d",&q);
 for(i=0; i<q; i++){
  scanf("%d", &key);
  if(search(A, n, key)) sum++;
 }
 printf("%d\n", sum);
 return 0;
}
 

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int n,d[300][300];
long long ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>d[i][j];
    bool ok=1,x[300][300]={};
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if(d[i][k]+d[k][j]<d[i][j])ok=0;
        if(k!=i&&k!=j&&d[i][k]+d[k][j]==d[i][j])x[i][j]=1;
    }
    if(!ok){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(!x[i][j])ans+=d[i][j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int n; scanf("%d", &n);
  int a[100001];
  for (int i=0;i<100001;i++){
    a[i] = 0;
  }
  int t;
  int m = 0;
  for (int i=0;i<n;i++){
    scanf("%d", &t);
    a[t] += 1;
    if (t > m){
      m = t;
    }
  }
  int x = a[0] + a[1];
  for (int i=1;i<=m;i++){
    if (a[i-1] + a[i] + a[i+1] > x){
      x = a[i-1] + a[i] + a[i+1];
    }
  }
  printf("%d", x);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int i, j;
  int a;
  int c1 = 0, c_min = 1000000001;
  
  for(i = 0; i < N ; i++){
    cin >> a;
    c1 = 0;
    
    int x = 1;
    for(j = 0; ; j++){
      	x *= 2;
  		if(a % x == 0){
          c1++;
        }
      	else{
          break;
        }
    }
    if(c_min > c1){
       c_min = c1;
    }
  }
  cout << c_min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

ll n,k;
vi v,c;
set<ll> s;

void rec(int l,int p){
	if(l==k){
		do{
			string str;
			rep(i,k){
				str+=to_string(c[v[i]]);
			}
			s.insert(stoll(str));
		}while(next_permutation(all(v)));
		sort(all(v));
	}
	else{
		range(i,p+1,n){
			v[l]=i;
			rec(l+1,i);
		}
	}
}

void solve(){
	c.resize(n);
	v.resize(k);
	rep(i,n){
		cin>>c[i];
	}
	rec(0,-1);
	cout<<s.size()<<endl;
	s.clear();
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin>>n>>k,n){
		solve();
	}
}



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

int main()
{
    int n, x;
    while(1)
    {
        int count = 0;
        cin >> n >> x;
        if (n == 0 && x == 0)
            break;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                for (int k = 1; k <= n; k++)
                {
                    if(i != j && j != k && i != k && i + j + k == x)
                        count++;
                }
            }
        }
        count /=  6;
        cout << count << endl;
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<complex>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
bool check(ll I,ll I2){
  if(abs(I)==I&&abs(I2)!=I2)
    return false;
  if(abs(I)!=I&&abs(I2)==I2)
    return false;
  return true;
}
int main(){
  int n;cin>>n;
  ll I=0;
  int a;cin>>a;
  I=a;
  ll I2;
  ll ans=0;
  ll ans2=0;
  if(I<0){
    I2=1;
    ans2=1+abs(I);
  }else if(I>0){
    I2=-1;
    ans2=1+abs(I);
  }else{
    I=1;
    I2=-1;
    ans=1;ans2=1;
  }
  for(int i=1;i<n;i++){
    cin>>a;
    if(check(I,I+a)||I+a==0){
      if(0<I){
	ans+=abs(I+a)+1;
	I=-1;
      }else if(I<0){
	ans+=abs(I+a)+1;
	  I=1;
      }else{
	if(I<0){
	  I=1;ans++;
	}else{
	  I=-1;ans++;
	}
      }
    }else{
      I+=a;
    }
    if(check(I2,I2+a)||I2+a==0){
      if(0<I2){
	ans2+=abs(I2+a)+1;
	I2=-1;
      }else if(I2<0){
	ans2+=abs(I2+a)+1;
	  I2=1;
      }else{
	if(I2<0){
	  I2=1;ans2++;
	}else{
	  I2=-1;ans2++;
	}
      }
    }else{
      I2+=a;
    }
  }

  cout<<min(ans,ans2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    vector<vector<ll> > dp(sz(s)+1,vector<ll>(13,0));
    if(s[0]=='?'){
        rep(i,10) dp[1][i]=1;
    }
    else{
        ll n=s[0]-'0';
        dp[1][n]=1;
    }
    
    //rep(i,13) cout<<dp[1][i]<<endl;
    
    FOR(i,2,sz(s)+1){
        if(s[i-1]=='?'){
            rep(j,10){
                rep(k,13){
                    dp[i][(k*10+j)%13] += dp[i-1][k];
                    dp[i][(k*10+j)%13] %= MOD;
                }
            }
        }
        else{
            ll n=s[i-1]-'0';
            rep(j,13){
                dp[i][(j*10+n)%13] += dp[i-1][j];
                dp[i][(j*10+n)%13] %= MOD;
            }
        }
    }
    
    cout<<dp[sz(s)][5];
}


Measured memory_bytes: 16708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#define ll long long
using namespace std;
const int N=110;
int arr[N],brr[N];
int main() 
{
	int n;
	while(cin>>n)
	{
		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];	
			ans+=arr[i];
		}
		int m,p,x;
		cin>>m;
		for(int i=0;i<m;i++)
		{
			cin>>p>>x;
			cout<<ans-arr[p]+x<<"\n";
		}
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
count=0
counts=[]
z=[]
for i in range(n):
	x,y=list(map(int,input().split()))
	z.append([x,y])
z.append([-14,-20])
for i in z:
	if i[0]==i[1]:
		count+=1
	else:
		counts.append(count)
		count=0
if max(counts)>=3:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 62376
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

int main()
{
    int t=0,n,m,a[100010],x;
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    //memset(b,0,sizeof(b));
    map<int ,int >p;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&m);
        if(!p.count(m))
        {
            a[t++]=m;
            p[m]=1;
        }
        else p[m]+=1;
    }
    int maxn=0;
    //for(int i=0;i<t;i++) printf("p[%d]=%d\n",a[i],p[a[i]]);
    for(int i=0;i<t;i++)
    {
        x=p[a[i]];
        if(p.count(a[i]+1)&&p.count(a[i]-1))
        {
            x=p[a[i]]+p[a[i]+1]+p[a[i]-1];
        }
        else if(p.count(a[i]+1))  x+=p[a[i]+1];
        else if(p.count(a[i]-1))  x+=p[a[i]-1];
        if(x>maxn) maxn=x;
        //printf("max=%d\n",maxn);
    }

    printf("%d\n",maxn);


    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};
  
/* ----------------------------------------------------------------------------------- */


void solve() {
	int n, m;
	cin >> n >> m;
	int res = (((n * (n - 1)) / 2.0) + ((m * (m - 1)) / 2.0));
	cout << res << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3600
module WeightedDirectedGraph
  (* 辺の重み *)
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  (* ハッシュテーブルを使うようにしたダイクストラ法の実装 *)
  val raw_dijkstra :
    (* 頂点数（Hashtblを用いるので目安程度） *)
    int ->
    (* 隣接リスト *)
    ('v -> ('v * Weight.t) list) ->
    (* 始点 *)
    'v ->
    (* 始点から辿り着けなければNoneを返す関数 *)
    ('v -> Weight.t option)
end =
struct
  module WMap = Map.Make (Weight)

  let raw_dijkstra n es s =
    let d = Hashtbl.create n in
    Hashtbl.add d s Weight.zero;
    let rec dijkstra_aux q =
      match WMap.min_binding_opt q with
      | None -> ()
      | Some (w, us) ->
          dijkstra_aux @@
          Fun.flip (Fun.flip List.fold_left (WMap.remove w q)) us @@ fun q u ->
            if 0 < Weight.compare w (Hashtbl.find d u)
            then q
            else Fun.flip (Fun.flip List.fold_left q) (es u) @@ fun q (v, c) ->
              let open Weight in
              match Hashtbl.find_opt d v with
              | Some d when Weight.compare d (w + c) <= 0 -> q
              | _ ->
                  Hashtbl.replace d v (w + c);
                  WMap.add (w + c) (v :: try WMap.find (w + c) q with Not_found -> []) q in
    dijkstra_aux (WMap.singleton Weight.zero [s]);
    Hashtbl.find_opt d
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m s ->
  let es = Array.make n [] in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun u v a b ->
      es.(u - 1) <- (v - 1, a, b) :: es.(u - 1);
      es.(v - 1) <- (u - 1, a, b) :: es.(v - 1);
  done;
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun c d -> (c, d) in
  let d = Fun.flip (G.raw_dijkstra (n * 2501)) (0, min 2500 s) @@ fun (v, w) ->
    (let (c, d) = vs.(v) in ((v, min 2500 (w + c)), d)) ::
      Fun.flip List.filter_map es.(v) (fun (u, a, b) ->
        if w < a
        then None
        else Some ((u, w - a), b)) in
  for v = 1 to n - 1 do
    Printf.printf "%d\n" @@
    List.fold_left min max_int @@
    List.init 2501 @@ fun w -> Option.value ~default:max_int @@ d (v, w)
  done


Measured memory_bytes: 30484
#include <iostream>
#include <utility>

auto input() -> std::pair<int,int> {
	int H, A;
	std::cin >> H >> A;
	return std::make_pair(H,A);
}

void process() {
	auto data = input();
	std::cout << (data.first / data.second
					+ static_cast<int>(data.first%data.second!=0))
		<< std::endl;
}

int main() {
	process();
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

bool check_dup_insert(set<ll> &st, ll n) {
    if(st.find(n) != st.end()) return false;
    st.insert(n);
    return true;
}

int main() {
    ll N;
    cin >> N;
    V<ll> S(N);
    for(ll &e : S) cin >> e;
    
    ll ans = 0;
    for(ll range = 1; range <= N - 1; range++) {
        ll left = 0, right = N - 1;
        ll score = 0;
        ll max_score = 0;
        set<ll> st;
        while(right - range > 0) {
            right -= range;
            left += range;
            bool ok = (check_dup_insert(st, left) &
                       check_dup_insert(st, right));
            if(!ok) break;
            score += S[left] + S[right];
            ll A = right;
            ll B = A - range;
            if(!(0 < A && 0 < B && B < A)) continue;
            DEBUG(make_tuple(A, B, range, score));
            chmax(max_score, score);
        }
        chmax(ans, max_score);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
c = list(map(int,input().split())) + list(map(int,input().split())) + list(map(int,input().split()))
n = int(input())
d = [0]*9
for i in range(n):
    m = int(input())
    for j in range(9):
        if c[j] == m:
            d[j] = 1
if (d[0],d[1],d[2]) == (1,1,1) or (d[3],d[4],d[5]) == (1,1,1) or (d[6],d[7],d[8]) == (1,1,1)\
    or (d[0],d[3],d[6]) == (1,1,1) or (d[1],d[4],d[7]) == (1,1,1) or (d[2],d[5],d[8]) == (1,1,1)\
        or (d[0],d[4],d[8]) == (1,1,1) or (d[2],d[4],d[6]) == (1,1,1):
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 220000
#define NUM 50

int n;
pair<int,int> dat[2 * MAX - 1];

int init(int n_){
	n = 1;
	
	while(n < n_) n *= 2;
	
	for(int i = 0; i < 2 * n - 1; i++) dat[i] = make_pair(0,1);
	
	return n;
}

void update(int k, pair<int,int> a){
	k += n - 1;
	dat[k] = a;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k].second = ((dat[k * 2 + 1].second)/__gcd(dat[k * 2 + 1].second,dat[k * 2 + 2].second))*dat[k * 2 + 2].second;
		dat[k].first = (dat[k].second/dat[k * 2 + 1].second)%MOD*dat[k * 2 + 1].first%MOD + (dat[k].second/dat[k * 2 + 2].second)%MOD*dat[k * 2 + 2].first%MOD;
		dat[k].first %= MOD;
	}
}

pair<int,int> query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l){
		return make_pair(0,1);
	}
	
	if(a <= l && r <= b){
		return dat[k];
	}else {
		pair<int,int> vl = query(a, b, k * 2 + 1, l, (l + r) / 2 );
		pair<int,int> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		pair<int,int> res;
		
		res.second = (vl.second/__gcd(vl.second,vr.second))*vr.second;
		res.first = (res.second/vl.second)%MOD*vl.first%MOD + (res.second/vr.second)%MOD*vr.first%MOD;
		res.first %= MOD;
		
		return res;
	}
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int l, r;
	int N, Q;
	int period, sum;
	pair<int,int> ans;
	vector<int> permutation;
	
	cin>>N>>Q;

	permutation.resize(N+1);
	for(int i = 1; i <= N; i++){
		cin>>permutation[i];
	}
	
	init(N+5);
	
	for(int i = 1, num; i <= N; i++){
		num = i;
		sum = 0;
		for(int j = 1; j < NUM; j++){
			sum += num;
			sum %= MOD;
			
			num = permutation[num];
			
			period = j;
			if(num == i) break;
		}
		update(i,make_pair(sum,period));
	}
	
	for(int i = 0; i < Q; i++){
		cin>>l>>r;
		ans = query(l,r+1,0,0,n);
		cout<<ans.first<<endl;;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

int main() {
    double r0, w0, c, r;
    while(cin>>r0>>w0>>c>>r, r0+w0+c+r) {
        cout << max((int)ceil((c*w0 - r0) / r), 0) << endl;
    }
}


Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

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

	bool is_ok = (a == b) && (b == c);
	if (is_ok) {
		cout <<  "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int main() {

  int n, a = 0, b = 0;
  char popo;
  cin >> n;
  string buff1, buff2, buffest;
  for(int i = 1;i <= n;i++){
    buffest.push_back('0' + i);
  }
  for(int i = 1;i <= n;i++){
    cin >> popo;
    buff1.push_back(popo);
  }
  for(int i = 1;i <= n;i++){
    cin >> popo;
    buff2.push_back(popo);
  }
  int i = 0;
  while(next_permutation(buffest.begin(), buffest.end()) && (a == 0 || b == 0)){
    i++;
    if(buff1 == buffest){
      a = i;
    }
    if(buff2 == buffest){
      b = i;
    }
  }
  cout << abs(a - b);
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){

  string in;
  while(cin>>in){
    int c1=0,c2=0;
    rep(i,in.size()-2){
      if(in[i]=='J'&&in[i+1]=='O'&&in[i+2]=='I')c1++;
      if(in[i]=='I'&&in[i+1]=='O'&&in[i+2]=='I')c2++;
    }
    cout<<c1<<endl<<c2<<endl;
  }
}

Measured memory_bytes: 1196
package main

import (
	"fmt"
)

const INF = 1 << 30

func main(){
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	var dp[100001][3] int
	// j: ABC のどれを直前にやったか
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i], &c[i])
	}
	for i := 1; i < len(dp); i++ {
		for j := 0; j < 3; j++ {
			dp[i][j] = INF
		}
	}
	dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0]
	for i := 0; i < n-1; i++ {
		dp[i+1][0] = maxInt(dp[i][1], dp[i][2]) + a[i+1]
		dp[i+1][1] = maxInt(dp[i][0], dp[i][2]) + b[i+1]
		dp[i+1][2] = maxInt(dp[i][0], dp[i][1]) + c[i+1]
	}
	fmt.Println(maxInt3(dp[n-1][0], dp[n-1][1], dp[n-1][2]))
}

func maxInt3(a, b, c int) int {
	if a < b {
		a, b = b, a
	}
	if a < c {
		a, c = c, a
	}
	return a
}

func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

Measured memory_bytes: 9728
#include <iostream>

using namespace std;

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

uint64_t lcd(uint64_t a, uint64_t b){
	return a/gcd(a, b)*b;
}

int main(){
	int n;
	cin >> n;
	uint64_t result=1;
	for(int i=0; i<n; ++i){
		uint64_t t;
		cin >> t;
		result=lcd(result, t);
	}
	cout << result << "\n";
	return 0;
}


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

int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << "T" << endl;
  }
  else if(b=='T'){
    cout << "A" << endl;
  }
  else if(b=='G'){
    cout << "C" << endl;
  }
  else{
    cout << "G" << endl;
  }
}

Measured memory_bytes: 3384