akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  YES((a==3||a==5||a==7));
  return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <vector>
using std::vector;

int main(void) {
    using std::cin;
    using std::cout;

    int N;
    cin >> N;
    vector<int> A(N);
    for (int &ai : A) cin >> ai;

    if (N == 1) {
        cout << A.at(0) / 2 << '\n';
        return 0;
    }

    long long ans = 0LL;
    for (int i = 0; i < N - 1; ++i) {
        // A[i] を偶数なら使い切る
        int p = A.at(i) / 2;
        A.at(i) -= 2 * p;

        // A[i]が奇数でも，A[i]!=0で使い切る
        int p_diff = std::min(A.at(i), A.at(i + 1));
        A.at(i) -= p_diff;
        A.at(i + 1) -= p_diff;

        ans += (long long)p_diff + (long long)p;
    }

    // A[N] 以外にはカードが残っていない
    // A[N] でペアを作る
    ans += (long long)A.at(N - 1) / 2LL;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
# -*- coding:utf-8 -*-
# AIZU ONLINE JUDGE
# Introduction to Algorithms and Data Structures
# ALDS1_5_B
# Recursion / Divide and Conquer - Merge Sort

# ?????????????????????????????±??????????????\??????????????¢?????´????????????
# ????????±??????(Divide and Conquer method)?????????????????§????§£?±???§???????????§????????????????°????????????????????????????????????¨???????§£?±????????????¨??§?????????????????????????????¨???????§£?±?????????¨?????????????§£?±???????????????¨???
# ?????????????????´??????????????????????????????????????????????????°????????´???????????????????????????????????????????????¨????????£?????´?????????

# Input
# A     : ??´??????????????????
# left  : ??????????????????????????????????????????????????????
# mid   : right??¨mid???????????????????¬?????????§???????????????
# right : ??????????????????????????????????????????????????????

cnt = 0
def marge(A, left, mid, right):
    global cnt
    # ??????????????????????????????????????????
    n1 = mid-left
    n2 = right-mid

    # L[0..n1],R[0..n2]?????????
    l = []
    r = []
    for i in xrange(n1):
        l.append(A[left+i])
    for i in xrange(n2):
        r.append(A[mid+i])
    l.append(float('inf'))
    r.append(float('inf'))
    i = 0
    j = 0
    for k in xrange(left,right):
        cnt += 1
        if l[i]<=r[j]:
            A[k] = l[i]
            i+=1
        else:
            A[k] = r[j]
            j+=1

def marge_sort(A,left,right):
    if left+1<right:
        mid = (right+left)/2
        marge_sort(A, left,mid)
        marge_sort(A, mid,right)
        marge(A,left,mid,right)

def main():
    n = input()
    A = map(int,raw_input().split())
    marge_sort(A,0,len(A))
    print " ".join(map(str,A))
    print cnt

if __name__ == '__main__':
    main()

Measured memory_bytes: 54624
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int size=0;
	int number,base;
	cin>>number>>base;
	while(number){
		number/=base;
		size++;
	}
	cout<<size;
	return 0;
}

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


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

        char ch = s[0];
        if( ch == s[1] && ch == s[2] ) {
                puts("Yes");
                return 0;
        }

        ch = s[3];

        if(ch == s[1] && ch == s[2] ) {
                puts("Yes");
                return 0;
        }

        puts("No");



        return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
s = input().rstrip()

colname = {'R': 0, 'G': 1, 'B': 2}
color = [[], [], []]
for i in range(n):
    ci = colname[s[i]]
    color[ci].append(i + 1)
color = sorted(color, key=lambda x: len(x))

color[2] = set(color[2])
nc2 = len(color[2])

x = 0
for r in color[0]:
    for g in color[1]:
        x += nc2
        if r > g:
            if (r + (r - g)) in color[2]:
                x -= 1
            if (g - (r - g)) in color[2]:
                x -= 1
        else:
            if (g + (g - r)) in color[2]:
                x -= 1
            if (r - (g - r)) in color[2]:
                x -= 1
        c = r + g
        if c % 2 == 0 and (c // 2) in color[2]:
            x -= 1
print(x)

Measured memory_bytes: 9352
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()
	imos := make([]int, N+1)
	for i := 0; i < N; i++ {
		imos[i+1] += imos[i] + A[i]
	}

	mn := imos[N]
	for j := 1; j < N; j++ {
		s := imos[N] - imos[j]
		t := imos[j]
		p := abs(s - t)
		if mn > p {
			mn = p
		}
		//fmt.Println(p)
	}
	fmt.Println(mn)

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
    string S, T;
    cin >> S;
    T = "ATGC";

    int ans = 0;
    for(int i=0; i<S.size(); i++) {
        int now = 0;
        for(int j=i; j<S.size(); j++) {
            bool ok = false;
            for (int k=0; k<T.size(); k++) {
                if (S[j]==T[k]) {
                    ok = true;
                }
            }
            if(ok) {
                now++;
                ans = max(now, ans);
            } else {
                break;
            }
        } 
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main() {
	string a, b = "";
	cin >> a;

	for (int i = a.size() - 1; i >= 0; i--)b += a[i];
	cout << b << endl;

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

ll dp[41][500][500];

void solve() {
    ll N, Ma, Mb;cin >> N >> Ma >> Mb;
    vll A(N),B(N),C(N);
    for (int i = 0; i < N; i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    for (int i = 0; i < 41; i++)
    {
        for (int j = 0; j < 500; j++)
        {
            for (int k = 0; k < 500; k++)
            {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0]=0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 401; j++)
        {
            for (int k = 0; k < 401; k++)
            {
                if(dp[i][j][k] == INF) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + A[i]][k + B[i]] = min(
                    dp[i + 1][j + A[i]][k + B[i]],
                    dp[i][j][k] + C[i]
                );
            }
        }
    }
    ll ans = INF;
    for (int j = 1; j < 401; j++)
    {
        for (int k = 1; k < 401; k++)
        {
            if(Ma*k==Mb*j) {
                ans = min(ans, dp[N][j][k]);
            }
        }
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


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

using namespace std;

int main() {
	int n, l;
	string a[100];
	cin >> n >> l;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)cout << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,w[100],i,j,t,s1,s2,s,ans=100;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&w[i]);
    for(t=0;t<n;t++){
        s1=0; s2=0;
        for(i=0;i<=t;i++)
            s1+=w[i];
        for(j=i;j<n;j++)
            s2+=w[j];
        s=s1-s2;
        if(s<0) s=-s;
        if(ans>s) ans=s;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int n, a, b, max, min, add;
  scanf("%d %d %d", &n, &a, &b);
  if(a > b) max = b;
  else max = a;
  add = a + b;
  if(add <= n) min = 0;
  else min = add -n;
  printf("%d %d\n", max, min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll n, a, b, c;
vector<ll> l(10);

ll dfs(ll ex, ll sa, ll sb, ll sc){
     if(ex == n){
         if(sa == 0 or sb == 0 or sc == 0){
             return INF;
         }else{
             return abs(a -sa) + abs(b -sb) + abs(c - sc) - 30;
         }
     }
     ll x = dfs(ex+1, sa, sb, sc);
     ll y = dfs(ex+1, sa+l[ex], sb, sc) + 10;
     ll z = dfs(ex+1, sa, sb+l[ex], sc) + 10;
     ll w = dfs(ex+1, sa, sb, sc+l[ex]) + 10;

     return min(x, min(y, min(z, w)));
 }

int main(){
    cin>>n>>a>>b>>c;
    for(ll i=0;i<n;++i){
        cin>>l[i];
    }
    ll ans = dfs(0, 0, 0, 0);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
T,A = map(int,input().split())
h = list(map(int,input().split()))
#print(h)
l =[]
for i in range(n):
  a = T - h[i]*0.006
 # print(a)
  b = abs(a-A)
  l.append(b)
  #print(l)
c = h.index(h[l.index(min(l))])
print(c+1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    string s;
    cin>>s;
    int ans=0;
    for(int d=1;d<n;d++){
        int tmp=0;
        for(int i=0;i+d<n;i++){
            if(s[i]==s[i+d]){
                tmp++;
            }else{
                tmp=0;
            }
            ans = max(ans,min(tmp,d));
        }
    }
    cout<<ans<<endl;
}

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

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

    unsigned long long total = 0;
    unsigned long long digit;
    for (digit = 1; digit < 20; digit++)
    {
        if (total + pow(26, digit) >= N)
        {
            N -= total;
            break;
        }
        else
        {
            total += pow(26, digit);
        }
    }
    N--;
    vector<unsigned long long> ans(digit, 0);
    for (unsigned long long i = 0; i < digit; i++)
    {
        ans[i] = N % 26;
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    for (unsigned long long a : ans)
    {
        cout << (char)('a' + a);
    }
    cout << endl;
}


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

using namespace std;

using int64 = long long;

// Verified: AOJ-DSL1A
class UFSet {
 private:
  vector<int> ranks;
  vector<int> prevs;

 public:
  UFSet(int n) : ranks(n), prevs(n) {
    for (int i = 0; i < n; i++) prevs[i] = i;
  }

  // Returns a root of a tree which x belongs to.
  int Find(int x) {
    if (x != prevs[x]) prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
    }
  }
};

struct WeightedEdge {
  int v1, v2;
  int64 weight;
  WeightedEdge(int v1, int v2, int64 weight)
      : v1(v1), v2(v2), weight(weight) {}
};

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

  int n, h, w;
  cin >> n >> h >> w;
  vector<WeightedEdge> edges;
  for (int i = 0; i < n; i++) {
    int r, c;
    int64 weight;
    cin >> r >> c >> weight;
    r--;
    c--;
    edges.emplace_back(r, h + c, weight);
  }
  sort(edges.begin(), edges.end(), [](const auto& e1, const auto& e2) {
    return e1.weight > e2.weight;
  });

  UFSet uf_set(h + w);
  vector<int> has_cycle_vector(h + w);
  int64 answer = 0;
  for (const auto& e : edges) {
    int s1 = uf_set.Find(e.v1);
    int s2 = uf_set.Find(e.v2);
    if (s1 != s2) {
      if (has_cycle_vector[s1] && has_cycle_vector[s2]) continue;
      int new_has_cycle = has_cycle_vector[s1] || has_cycle_vector[s2];
      uf_set.Union(e.v1, e.v2);
      int s3 = uf_set.Find(e.v1);
      has_cycle_vector[s3] = new_has_cycle;
      answer += e.weight;
    } else {
      if (has_cycle_vector[s1]) continue;
      has_cycle_vector[s1] = true;
      answer += e.weight;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 4208
#include <stdio.h>
int main(void) {
    int num[31]={0},i,temp;
    for (i=0; i<28; i++) {
        scanf("%d\n",&temp);
        num[temp]++;
    }
    for (i=1; i<=30; i++) {
        if (num[i]==0) printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 600
N, M = map(int, input().split())
pena = [0]*N
score = 0
flag = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if flag[p]:
        continue
    if S == 'AC':
        flag[p] = True
        score+=1
    else:
        pena[p]+=1
res = 0
for i in range(N):
    if flag[i]:
        res+=pena[i]
print(score, res)


Measured memory_bytes: 50536
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B >> C;
  cout << A * B/2 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1002002];
int main(void){
	while(1){
		ll n,m,i,j,p[1001],hi,lo,mi,pp,x,mx;
		cin>>n>>m;
		if(n==0)break;
		p[0]=0;
		for(i=1;i<=n;i++) cin>>p[i];
		pp=pow(n+1,2);
		for(i=0;i<=pp+1;i++) a[i]=0;
		for(i=0;i<=n;i++) for(j=0;j<=n;j++) a[i*n+j]=p[i]+p[j];
		sort(a,a+(pp+1));
//		for(i=0;i<=pp+1;i++) cout<<a[i]<<endl;
		mx=0;
		for(i=0;i<=pp+1;i++){
			hi=pp+1; lo=0;
			while(hi>=lo){
				mi=(hi+lo)/2;
				x=a[i]+a[mi];
				if(x>m) hi=mi-1;
				else if(x<m) lo=mi+1;
			}
			x=a[i]+a[hi];
			if(mx<x&&m>=x) mx=x;
		}
		cout<<mx<<endl;
	}
	return 0;
}


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

int N,indeks[100010],ans,number;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    cin>>N;
    for(int i = 1;i <= N;i++){
        cin>>number;
        indeks[number]++;
    }
    for(int i = 1;i <= 100000;i++){
        ans = max(ans, indeks[i - 1] + indeks[i] + indeks[i + 1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3860
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    vector<int> p(3);
    cin>>p[0]>>p[1]>>p[2];
    sort(p.begin(),p.end());
    cout<<p[0]+p[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
w0 = wv[0][0]
wv.sort(key=lambda x: (x[0], -x[1]))
w1, w2, w3, w4 = [], [], [], []
for w, v in wv:
    if w == w0:
        w1.append(v)
    elif w == w0 + 1:
        w2.append(v)
    elif w == w0 + 2:
        w3.append(v)
    else:
        w4.append(v)
Sw1, Sw2, Sw3, Sw4 = [0], [0], [0], [0]
S = 0
for v in w1:
    S += v
    Sw1.append(S)
S = 0
for v in w2:
    S += v
    Sw2.append(S)
S = 0
for v in w3:
    S += v
    Sw3.append(S)
S = 0
for v in w4:
    S += v
    Sw4.append(S)
l1, l2, l3, l4 = len(w1), len(w2), len(w3), len(w4)
V = 0
v = 0
for i in range(l1 + 1):
    if w0 * i > W:
        break
    for j in range(l2 + 1):
        if w0 * i + (w0 + 1) * j > W:
            break
        for k in range(l3 + 1):
            if w0 * i + (w0 + 1) * j + (w0 + 2) * k > W:
                break
            for l in range(l4 + 1):
                if w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l > W:
                    break
                v = Sw1[i] + Sw2[j] + Sw3[k] + Sw4[l]
                V = max(V, v)
print(V)

Measured memory_bytes: 9240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10 - n) << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int x[2], y[2];
    for (int i = 0; i < 2; ++i) {
        cin >> x[i] >> y[i];
    }
    for (int i = 2; i > 0; --i) {
        cout << x[i-1] - (y[1]-y[0]) << " " << y[i-1] + (x[1]-x[0]) << "\n "[i-1];
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

vvi to;
vector<vector<mint>> dp;

mint dfs(int v, bool b, int p) {
    if (dp[v][b].x > 0) return dp[v][b];

    mint resb = b ? 0 : 1;
    mint resw = 1;
    for (auto n : to[v]) {
        if (n == p) continue;
        resw *= dfs(n, false, v);
        if (!b) resb *= dfs(n, true, v);
    }
    mint res = resw + resb;
    dp[v][b] = res;
    return res;
}

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

    int n;
    cin>>n;
    to = vvi(n);
    rep(i, n - 1) {
        int x, y;
        cin>>x>>y; x--; y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    dp = vector<vector<mint>>(n, vector<mint>(2));
    mint ans = dfs(0, false, -1);
    cout<<ans<<endl;
}

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

ll q=0;
vector<ll>to[100005];
vector<ll>p(100005);
vector<ll>check(100005);

void dfs(ll v, ll w=-1){
  check[v]=q;
  for(ll i=0; i<to[v].size(); i++){
    ll u=to[v][i];
    if(u==w)continue;
    if(check[u]>0)continue;
    dfs(u,v);
  }
}

int main(){
  ll n,m;
  cin >> n >> m;
  for(ll i=0; i<n; i++){
    cin >> p[i];
    p[i]--;
  }
  
  for(ll i=0; i<m; i++){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  
  for(ll i=0; i<n; i++){
    if(check[i]) continue;
    q++;
    dfs(i);
  }
  
  ll ans=0;
  for(ll i=0; i<n; i++){
    if(check[p[i]]==check[i])ans++;
  }
  
  //for(int i=0; i<n; i++) cout << check[i] << endl;
  
  cout << ans << endl;
  
}
  
  
  


Measured memory_bytes: 10368
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    m_cnt = 0
    for i in range(n):
        t_s = s[:i + 1]
        t_t = s[i + 1:]
        import collections
        t_s = collections.Counter(t_s)
        t_t = collections.Counter(t_t)
        cnt = 0
        for k, v in t_s.items():
            if k in t_t.keys():
                cnt += 1
        m_cnt = max(m_cnt, cnt)
    print(m_cnt)


if __name__ == '__main__':
    main()


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        t: f32,
        x: f32,
    }

    println!("{}", t / x);
}


Measured memory_bytes: 4352
import itertools
import sys

N = int(input())
key = "MARCH"
S = [x for x in [input() for i in range(N)] if x[0] in key]
march = {}
for x in S:
    march.setdefault(x[0], []).append(x)

if len(march) < 3:
    print(0)
    sys.exit()
    
sizes = [len(x) for x in march.values()]
print(sum([a*b*c for a, b, c in itertools.combinations(sizes, 3)]))


Measured memory_bytes: 10916
n = int(input())

lis = [111, 222, 333, 444, 555, 666, 777, 888, 999]

if n <= lis[0]:
    print(lis[0])
elif n <= lis[1]:
    print(lis[1])
elif n <= lis[2]:
    print(lis[2])
elif n <= lis[3]:
    print(lis[3])
elif n <= lis[4]:
    print(lis[4])
elif n <= lis[5]:
    print(lis[5])
elif n <= lis[6]:
    print(lis[6])
elif n <= lis[7]:
    print(lis[7])
elif n <= lis[8]:
    print(lis[8])

Measured memory_bytes: 3064
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()
    t = in_na()
    cake = list(zip(t, t, t))

    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                c = []
                for x, y, z in cake:
                    if i == 1:
                        x = -x
                    if j == 1:
                        y = -y
                    if k == 1:
                        z = -z
                    c.append(x + y + z)
                c.sort(reverse=True)
                ans = max(ans, sum(c[:M]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e6+5,M=5e3+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
struct P{int x,y;}p[N];
bool cmp(P a,P b){return a.x<b.x;}
int n,sx,sy,tx,ty,rx,ry,cnt;
#define R(a) (a=1e8-a)
int tmp[N];
int main(){
	read(sx,sy);read(tx,ty);read(n);
	if(sx>tx)rx=1,R(sx),R(tx);
	if(sy>ty)ry=1,R(sy),R(ty);
	rep(i,1,n){
		int x,y;read(x,y);if(rx)R(x);if(ry)R(y);
		if(sx<=x&&x<=tx&&sy<=y&&y<=ty)p[++cnt]=(P){x,y};
	}
	if(sx==tx||sy==ty)printf("%.12lf",100.0*(tx-sx+ty-sy)+(10*pi-20)*cnt);else{
		sort(p+1,p+1+cnt,cmp);
		int ans=0;
		rep(i,1,cnt){
			int o=lower_bound(tmp+1,tmp+1+ans,p[i].y)-tmp;
			tmp[o]=p[i].y;
			gmax(ans,o);
		}double res=100.0*(tx-sx+ty-sy)+(5*pi-20)*ans;
		if(ans>min(tx-sx,ty-sy))res+=5*pi;
		printf("%.12lf",res);
	}
}

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

int main(){
	int c1,c5,c10,c50,c100,c500;
	cin>>c1>>c5>>c10>>c50>>c100>>c500;
	if((((c1*1)+(c5*5)+(c10*10)+(c50*50)+(c100*100)+(c500*500))/1000)>=1){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		int C = int.Parse(Console.ReadLine());
		int D = int.Parse(Console.ReadLine());
		int E = int.Parse(Console.ReadLine());
		int K = int.Parse(Console.ReadLine());
		string ans = "Yay!";
		if(E-A > K){
			ans = ":(";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
// https://atcoder.jp/contests/abc172/tasks/abc172_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N), B(M), AS(N + 1), BS(M + 1);

    REP(i, N) {
        cin >> A[i];
        AS[i + 1] = A[i];
    }
    REP(i, M) {
        cin >> B[i];
        BS[i + 1] = B[i];
    }
    REP(i, N) { AS[i + 1] += AS[i]; }
    REP(i, M) { BS[i + 1] += BS[i]; }
    AS.emplace_back(INT64_MAX);
    BS.emplace_back(INT64_MAX);
    auto it1 = lower_bound(ALL(AS), K + 1);
    it1--;
    int d1 = distance(AS.begin(), it1);
    int ans = 0;
    while (true) {
        auto it2 = lower_bound(ALL(BS), K - *it1 + 1);
        it2--;
        int d2 = distance(BS.begin(), it2);
        ans = max(ans, d1 + d2);
        if (it1 == AS.begin()) {
            break;
        }
        it1--;
        d1--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11104
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<climits>
#include<cmath>
#include<iomanip>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()

using namespace std;



ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}


/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/


int main(){
   // IOS; 
    ll t;
    t=1;
    //cin>>t;
        while(t--){
            ll n,w;
            cin>>n>>w;
            ll arr[n+1][w+1]={0};
            pair<ll,ll> p[n+1];
            FOR(i,n+1){
                arr[i][0]=0;
            }
            FOR(i,w+1){
                arr[0][i]=0;
            }
            ll x,y;
            FORE(i,1,n){
                cin>>x>>y;
                p[i]={x,y};
            }
            FORE(i,1,n){
                FORE(j,1,w){
                    if(p[i].F>j)
                    arr[i][j]=arr[i-1][j];
                    else{
                        arr[i][j]=max(p[i].S+arr[i-1][j-p[i].F],arr[i-1][j]);
                    }
                }
            }
            /*FORE(i,0,n){
                FORE(j,0,w){
                    cout<<arr[i][j]<<" ";
                }
                cout<<"\n";
            }*/
            cout<<arr[n][w];


        } 
} 


Measured memory_bytes: 79104
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	b := getInts(N - 1)
	a := make([]int, N)
	a[0] = b[0]
	a[N-1] = b[len(b)-1]
	for i := 0; i < N-2; i++ {
		a[i+1] = min(b[i], b[i+1])
	}
	// hout(a)
	ans := 0
	for i := 0; i < N; i++ {
		ans += a[i]
	}
	out(ans)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    char a;
    cin >> a;
    if(a >='a') a = 'a';
    else a = 'A';
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
A = set(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N+1):
    if i not in A:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N])

Measured memory_bytes: 11884
n = int(input())

spl = {}
spl = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    # spl.setdefault(s,[])
    # spl[s].append((p,i+1))

spl.sort()
for s,p,i in spl:
    print(i)

# spl = sorted(spl.items(), key=lambda x:x[0])
# for s, pil in spl:
#     pil.sort()
#     for p,i in pil:
#         print(i)

 

Measured memory_bytes: 62448
# b = 0 のとき、aを返す
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
n = int(input())
a = [int(x) for x in input().split()]
reversed_a = list(reversed(a))

length = len(a)
left_gcd = [0] * length
right_gcd = [0] * length

for i in range(1, length):
  left_gcd[i] = gcd(a[i-1], left_gcd[i-1])
  right_gcd[i] = gcd(reversed_a[i-1], right_gcd[i-1])
  
right_gcd = right_gcd[::-1]
m = [gcd(r, l) for l, r in zip(left_gcd, right_gcd)]

# print(left_gcd)
# print(right_gcd)
# print(m)

print(max(m))

Measured memory_bytes: 14436
#include <stdio.h>

#define MAX 100

void print(int,int*);

int main(){
  int N,a[MAX],i,j,key;

  scanf("%d" ,&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d" ,a + i);
  }

  print(N,a);
  for(j = 1 ; j < N ; j++){
    key = a[j];
    i = j - 1;

    while(i >= 0 && a[i] > key){
      a[i+1] = a[i];
      i--;
    }
    a[i+1] = key;
    print(N,a);
  }
    
  return 0;
}


void print(int N,int *a){
  int i;

  for(i = 0 ; i < N ; i++){
    if(i != N-1){
      printf("%d " ,a[i]);
    }else{
      printf("%d\n" ,a[i]);
    }
  }
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
vector<ll> a;
int main(){
    ll n,m,tmp=0,cnt=0;
    ll ans=0;
    priority_queue<ll> que;
    cin>>n>>m;
    rep(i,0,n){cin>>tmp;que.push(tmp);}
    rep(i,0,m){
       ll a=que.top();
       que.pop();
       que.push(a/2);
    }
    rep(i,0,n){ans+=que.top();que.pop();}
    cout<<ans;
}


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

using namespace std;

#define LL long long

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

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

    LL ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ans += a[i] / 2;
        a[i] %= 2;
        int tmp = min(a[i], a[i + 1]);
        ans += tmp;
        a[i] -= tmp;
        a[i + 1] -= tmp;
    }

    ans += a[n - 1] / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	auto S = new char*[M];
	for (int i = 0; i < M; i++) {
		S[i] = new char[3];
	}
	auto wa = new int[N] {};
	auto ac = new bool[N] {};
	int sum = 0;
	int acs = 0;
	for (int i = 0; i < M; i++) {
		int q;
		scanf("%d %s", &q, S[i]);
		q--;
		if (S[i][0] == 'A') {
			if (!ac[q]) {
				ac[q] = true;
				sum += wa[q];
				acs++;
			}
		}
		else {
			if (!ac[q]) {
				wa[q]++;
			}
		}
	}
	printf("%d %d", acs, sum);
	return 0;
}

Measured memory_bytes: 4608
import numpy as np
MOD = 10**9 + 7


def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


N = int(input())
if N == 1:
    print(1)
    exit()
N_list = seachPrimeNum(N)
ans_list = [0 for i in range(len(N_list))]
for i in range(2, N+1):
    temp_i = i
    for j in range(len(N_list)):
        while temp_i % N_list[j] == 0:
            temp_i = temp_i // N_list[j]
            ans_list[j] += 1
ans = 1
for i in range(len(ans_list)):
    ans = ans * (ans_list[i]+1) % MOD
print(ans)


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

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int val = 0;
	for(int i = 0;i < 50000; ++i){
		if(i * 27/25 == n)	{
			val = i;
		}
	}
	if(val)cout << val << '\n';
	else cout << ":(" << '\n';
}


Measured memory_bytes: 256
n = int(input())
Dict = {}
ans = 0
tmp_list = []
for i in range(n):
    tmp = list(input())
    tmp_list.append(tmp)
tmp_list.reverse()
for i in range(n):
    tmp = tmp_list[i]
    tmp = sorted(tmp)
    tmp = ''.join(tmp)
    if tmp not in Dict.keys():
        Dict[tmp] = 1
    else:
        ans += Dict[tmp]
        Dict[tmp] += 1


print(ans)

Measured memory_bytes: 39040
# N個のスイッチ
# M個の電球 それぞれKiこのスイッチに繋がる
# スイッチSi(電球)k()
# MとNのルート

N, M = map(int, input().split())

bulb_lst = []
for m in range(M):
    # 最初は電球が繋がっているスイッチの数
    # sは繋がっているスイッチの番号
    bulb_lst.append(list(map(int, input().split())))

# onになっているスイッチを2で割ったときの求めるあまり
want_switch = list(map(int, input().split()))

# スイッチ全パターン分のON OFFの状態を取得する。
# 特定の状態に対してそれぞれの電球がどうなっているかをチェックする。
# targetのスイッチの点灯状況とそれに伴う電球の点灯状況
# 全ての電球が光っている場合resを増やす

res = 0

for switch_pattern in (list(map(int, bin(i)[2:].zfill(N))) for i in range(2 ** N)):
    flg = True
    # i番目のスイッチが点灯しているかどうか
    for bulb, ws in zip(bulb_lst, want_switch):
        if ws != sum([switch_pattern[con_idx-1] for con_idx in bulb[1:]]) % 2:
            flg = False
            break
    if flg:
        res += 1
print(res)


Measured memory_bytes: 3064
import numpy as np
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

ans=[]
for i,j in enumerate(a):
    ans+=[(i+1)]*j
    
b=np.reshape(ans,(h,w))

for i,j in enumerate(b):
    if i%2==0:
        print(*j)
    else:
        print(*j[::-1])

Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

ll a[100001] = {};

int main() {
	ll n; cin >> n;
	ll negativeCnt = 0;
	ll minAbsolute = 1e10;
	rep(i, 0, n) {
		ll A; cin >> A;
		a[i] = A;
		if (A < 0) {
			negativeCnt++;
		}
		minAbsolute = min(minAbsolute, abs(A));
	}

	ll sum = 0;
	rep(i, 0, n) {
		sum += abs(a[i]);
	}

	if (negativeCnt & 1) {
		sum -= 2 * minAbsolute;
	}

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

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector <pair<ll, ll>> lr(q);
  for (ll i = 0; i < q; ++i) {
    ll l, r;
    cin >> l >> r;
    l--;
    r--;
    lr[i] = pair<ll, ll>(l, r);
  }

  vector<ll> cnts(n, 0);
  ll cnt = 0;
  for (ll i = 1; i < s.size(); ++i) {
    if (s[i-1] == 'A' && s[i] == 'C') cnt++;
    cnts[i] = cnt;
  }

  for (ll i = 0; i < q; ++i) {
    ll l = lr[i].first;
    ll r = lr[i].second;
    cout << cnts[r] - cnts[l] << endl;
  }

  return 0;
}

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

int main() {
	long long A, B, N;
	cin >> A >> B >> N;

	if (B <= N) {
		cout << (A * (B - 1)) / B - A * ((B - 1) / B) << endl;
	}
	else {
		cout << (A * N) / B - A * (N / B) << endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
	int mod=1e9+7;
	int dp[2000+4];
	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	   	
	   	int s;
	 	cin>>s;
	

	 	vector<int> dp(s+1,0);
		dp[0]=1;

	  	for(int sum=3; sum<=s; sum++){
	  		for(int i=3;i<=sum;i++){
	  			dp[sum]+=dp[sum-i];
	  			dp[sum]%=mod;
	  		}
	  	}
	  	cout<<dp[s]<<endl;
	    return 0;
}

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

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

  while (true) {

    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }

    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }

  }
}

Measured memory_bytes: 3636