akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	b := next()
	var ans string
	switch b {
	case "A":
		ans = "T"
	case "C":
		ans = "G"
	case "G":
		ans = "C"
	case "T":
		ans = "A"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

maxv = -999999999
minv = r[0]
for i in range(1,n):
    if (r[i] - minv) > maxv:
        maxv = r[i] - minv
    if r[i] < minv:
        minv = r[i]
print(maxv)

Measured memory_bytes: 13588
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean b = s.startsWith("YAKI");

        if(b){
            System.out.print("Yes");
        }else {
            System.out.print("No");
        }
    }
}

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

#define INF 1e9
#define pb push_back
#define mp make_pair
#define nl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int arr[200005];

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

	int n;
	cin >> n;
	for(int i=0,tmp;i<n-1;i++){
		cin >> tmp;
		arr[tmp-1]++;
	}
	for(int i=0;i<n;i++){
		cout << arr[i] << nl;
	}

	return 0;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    map<string,int> mp;
    string s;
    int n;
    cin>>n;
    while(n--){
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';

    return 0;
}

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

using namespace std;
const int MAXN = 2e5+5;
bool visited[MAXN];
vector<pair<int,int>> v1[7];
int curr = 1;
stack<int> s1;
int n,r,c;
bool check(int x,int y){
    if(x==r||x==0||y==0||y==c){
        return true;
    }
    return false;
}
int main(){

    cin>>r>>c;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(!check(x1,y1)||!check(x2,y2)){
            continue;
        }

        if(x1==0){
            v1[0].push_back(make_pair(y1,curr));

        }else if(y1==0){
            v1[1].push_back(make_pair(x1,curr));

        }else if(x1==r){
            v1[2].push_back(make_pair(y1,curr));

        }else if(y1==c){
            v1[3].push_back(make_pair(x1,curr));

        }
        if(x2==0){
            v1[0].push_back(make_pair(y2,curr));
        }else if(y2==0){
            v1[1].push_back(make_pair(x2,curr));
        }else if(x2==r){
            v1[2].push_back(make_pair(y2,curr));
        }else if(y2==c){
            v1[3].push_back(make_pair(x2,curr));
        }
        curr++;

    }
    sort(v1[0].rbegin(),v1[0].rend());
    sort(v1[1].begin(),v1[1].end());
    sort(v1[2].begin(),v1[2].end());
    sort(v1[3].rbegin(),v1[3].rend());

    for(auto x:v1[0]){
        int curr = x.second;
       // cout<<curr<<" "<<x.first<<endl;
        if(visited[curr]==true){
            if(s1.top() == curr){
                s1.pop();
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
        }else{
            s1.push(curr);
            visited[curr] = true;
        }

    }
    for(auto x:v1[1]){
        int curr = x.second;
        if(visited[curr]==true){
            if(s1.top() == curr){
                s1.pop();
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
        }else{
            s1.push(curr);
            visited[curr] = true;
        }
    }
    for(auto x:v1[2]){
        int curr = x.second;
        if(visited[curr]==true){
            if(s1.top() == curr){
                s1.pop();
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
        }else{
            s1.push(curr);
            visited[curr] = true;
        }
    }
    for(auto x:v1[3]){
        int curr = x.second;
        if(visited[curr]==true){
            if(s1.top() == curr){
                s1.pop();
            }else{
                cout<<"NO"<<endl;
                return 0;
            }
        }else{
            s1.push(curr);
            visited[curr] = true;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 2520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		System.out.println((a%3==0 || b%3==0 || (a+b)%3==0) ? "Possible" : "Impossible");
	}
}

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

const int A = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    int n;
    string s, t;
    cin >> n >> s >> t;
    string res = "";
    for(int i = 0; i < n; ++i){
        res += s[i];
        res += t[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;cin>>n>>m;
  if(n==m) print("Yes"); else print("No");
  return 0;
}

Measured memory_bytes: 256
while True :
    n, k = map(int, input().split())
    
    if n == 0 :
        break
    else :
        A = []
        S = []
        s = 0
        cnt = 0
        
        for i in range(n) :
            A.append(int(input()))
            
        for i in range(k) :
            s += A[i]
        S.append(s)
            
        for j in range(k, n) :
            s = S[cnt] - A[j - k] + A[j]
            S.append(s)
            cnt += 1
        
        print(max(S))


Measured memory_bytes: 11520
main :: IO ()
main = do
  s <- map (=='1') <$> getLine
  print $ min (solveOdd True s 0 0) (solveOdd False s 0 0)

solveOdd :: Bool -> [Bool] -> Int -> Int -> Int
solveOdd _ [] acco acce = acco + acce
solveOdd b (x:xs) acco acce
  | x == b = solveEven (not b) xs (acco + 1) acce
  | otherwise = solveEven (not b) xs acco acce

solveEven :: Bool -> [Bool] -> Int -> Int -> Int
solveEven _ [] acco acce = acco + acce
solveEven b (x:xs) acco acce
  | x == b = solveOdd (not b) xs acco (acce + 1)
  | otherwise = solveOdd (not b) xs acco acce


Measured memory_bytes: 7164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int L=-1e9;
  int S=1e9;
  int LP=0;
  int SP=0;
  rep(i,N){
    if(A[i]>L){
      L=A[i];
      LP=i;
    }
    if(A[i]<S){
      S=A[i];
      SP=i;
    }
  }
  vector<PII> ans;
  if(S>=0){
    cout<<N-1<<endl;
    rep(i,N-1) cout<<i+1<<" "<<i+2<<endl;
    return 0;
  }else if(L<=0){
    cout<<N-1<<endl;
    rep(i,N-1) cout<<N-i<<" "<<N-1-i<<endl;
    return 0;
  }else if(L>abs(S)){
    cout<<2*N-2<<endl;
    rep(i,N-1-LP) cout<<LP+1<<" "<<LP+i+2<<endl;
    rep(i,LP) cout<<LP+1<<" "<<LP-i<<endl;
    rep(i,N-1) cout<<i+1<<" "<<i+2<<endl;
    return 0;
  }else{
    cout<<2*N-2<<endl;
    rep(i,N-1-SP) cout<<SP+1<<" "<<SP+i+2<<endl;
    rep(i,SP) cout<<SP+1<<" "<<SP-i<<endl;
    rep(i,N-1) cout<<N-i<<" "<<N-1-i<<endl;
    return 0;
  }
}

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

using namespace std;

bool equals(const string& s, const string& t, size_t p)
{
    for(size_t i = 0; i != s.size(); ++i)
    {
        size_t j = (i + p) % s.size();
        if(s[j] != t[i])
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s,t;
    cin >> s >> t;
    
    for(size_t p = 0; p != s.size(); ++p)
    {
        if(equals(s, t, p))
        {
            cout << "Yes\n";
            return 0;
        }
    }
    
    cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n,m;
  cin>>n>>m;
  cout<<min((2*n+m)/4,m/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

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

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

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

string s;
set<int> si[2][100];

int main() {
	si[0][1].insert(0);
	si[0][2].insert(0);
	si[0][2].insert(1);
	si[1][0].insert(1);
	si[1][0].insert(2);
	si[1][1].insert(2);
	while (cin >> s&&s != "#") {
		ll ans = INF;
		int num = 0;
		int now = 0;
		int pos = (s[0] - '0' - 1) % 3;
		rep(i, s.size() - 1) {
			if (si[now][pos].find((s[i + 1] - '0' - 1) % 3)
				!= si[now][pos].end()) {
				num++;
			}
			else {
				now = (now + 1) % 2;
			}
			pos = (s[i + 1] - '0' - 1) % 3;
		}
		ans = min(ans, (ll)num);
		num = 0;
		now = 1;
		pos = (s[0] - '0' - 1) % 3;
		rep(i, s.size() - 1) {
			if (si[now][pos].find((s[i + 1] - '0' - 1) % 3)
				!= si[now][pos].end()) {
				num++;
			}
			else {
				now = (now + 1) % 2;
			}
			pos = (s[i + 1] - '0' - 1) % 3;
		}
		ans = min(ans, (ll)num);
		cout << ans << endl;
	}
}

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

using namespace std;

int main() {
  string N;
  cin >> N;
  
  int tmp = 0;
  for (int i = 0; i < (int)N.size(); i++) {
    tmp += (int)(N[i] - '0');
  }
  
  if (tmp % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

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


Measured memory_bytes: 3560
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (auto &a : v)
    cin >> a;
  for (auto &a : c)
    cin >> a;
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (0 < v[i] - c[i])
      ans += v[i] - c[i];
  cout << ans << endl;
}

Measured memory_bytes: 3592
a,b = map(int,input().split())

li = []
for _ in range(50):
    li.append(['.'] * 100)
for _ in range(50):
    li.append(['#'] * 100)

for i in range(b-1):
    j = i // 50
    k = i % 50
    li[j*2][k*2] = '#'

for i in range(a-1):
    j = i // 50
    k = i % 50
    li[j*2 + 51][k*2] = '.'

print(100, 100)
for i in range(100):
    for j in range(100):
        print(li[i][j], end = '')
    print()


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

int h[105];
int sum = 0;

void calcAns(int begin, int end) {
    if(begin == end) return;
    if(begin + 1 == end) {
        sum += h[begin];
        return;
    }

    int minNum = 101;
    int minIndex;
    for(int i = begin; i < end; i++) {
        if(h[i] < minNum) {
            minNum = h[i];
            minIndex = i;
        }
    }

    for(int i = begin; i < end; i++) {
        h[i] -= minNum;
    }

    sum += minNum;
    calcAns(begin, minIndex);
    calcAns(minIndex+1, end);
}


int main(void)
{
    int n;
    cin >> n;
    rep(i, n) cin >> h[i];
    calcAns(0, n);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  string a,b,c;
  cin >>A>>B>>C;
  if(B-A==C-B)Out("YES");
  else Out("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
struct custom {
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=(y>>1);
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   string s;
   cin>>s;
  ll i;
  for(i=0;i<s.size();i++)
  {
     s[i]=(s[i]=='?')?'D':s[i];
  }
  cout<<s<<endl;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int can = 0;
		for (int j = 1; j <= i; j += 2) {
			if (i % j == 0)
				can++;
			if (can == 9)
				break;
		}
		if (can == 8) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

long A[MAX];

long partition(long A[], long p, long r) {
  long x = A[--r];
  long i = p - 1, j;
  for (j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      int tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  int tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;

  return i + 1;
}

int main(void) {
  long i, n, x;

  scanf("%ld", &n);

  for (i = 0; i < n; i++)
    scanf("%ld", &A[i]);

  x = partition(A, 0, n);

  //printf("%ld\n", x);

  printf("%ld", A[0]);
  for (i = 1; i < x; i++)
    printf(" %ld", A[i]);
  printf(" [%ld]", A[x]);
  for(i = x + 1; i < n; i++)
    printf(" %ld", A[i]);
  puts("");

  return 0;
}

Measured memory_bytes: 1820
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):

    res = 0
    for i in range(1,N+1):
        t = 0
        for c in str(i):
            t += int(c)
        if A <= t <= B:
            res += i
    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
short max(short a, short b){return a<b?b:a;}
short n, m, ans, now, i, j;
char S[100][11], T[100][11], c;
char s[100], t[100];
char done[100];
int main(){
  scanf("%hd\n", &n);
  for(i=0; i<n; i++){
    while((c=getchar())!=10){S[i][s[i]++]=c;}
  }
  scanf("%hd\n", &m);
  for(i=0; i<m; i++){
    while((c=getchar())!=10){T[i][t[i]++]=c;}
  }
  register char f, r, k;
  for(i=0; i<n; i++){
    if(done[i]){continue;}
    now = 0;
    r=s[i];
    for(j=0; j<n; j++){
      if(s[j]!=r){continue;}
      f=1;
      for(k=0; k<r; k++){
        if(S[i][k]!=S[j][k]){f=0; break;}
      }
      if(f){done[j]=1; now++;}
    }
    for(j=0; j<m; j++){
      if(t[j]!=r){continue;}
      f=1;
      for(k=0; k<r; k++){
        if(S[i][k]!=T[j][k]){f=0; break;}
      }
      if(f){now--;}
    }
    ans=max(ans, now);
  }
  printf("%d\n", max(ans, 0));
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];

    }
    int k;
    k=round(double(sum)/(double)n);
    int j=0;
    for(int i=0;i<n;i++)
    {
        j+=(a[i]-k)*(a[i]-k);
    }
    cout<<j;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]

ok = 0
ng = 0
ng_l = {}
end = set()

for _ in range(M):
    p, S = [x for x in input().split()]
    p = int(p)

    if not p in end:
        if S == 'AC':
            ok += 1
            end.add(p)

            if p in ng_l:
                ng += ng_l[p]
        else:
            if p in ng_l:
                ng_l[p] += 1
            else:
                ng_l[p] = 1

print('{} {}'.format(ok, ng))


Measured memory_bytes: 17332
use List::Util qw/sum/;

my ($n, $k) = glob<>;
my @p = glob<>;

my $s = sum @p[$0..$k-1];
my $m = $s;

for ($i = $k; $i < @p; $i++) {
    $in = @p[$i];
    $out = @p[$i-$k];
    $s = $s - $out + $in;
    if ($m < $s) {
        $m = $s;
    }
}

print (($m + $k) / 2);

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

int int_len(long long int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(long long int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a=0,b=0,c=0,d=0,n=0,count=0,ans=1000000;
  string s;
  cin>>n;
  for(long long int i=1;i<=sqrt(2*n)+1;i++){
    if(n%i==0){
      ans=min(ans,(long long int)max(int_len(i),int_len(n/i)));
    }
  }
  
  cout<<ans<<endl;
  return 0;
}
///////////////////////////



Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

ll a[100010];

int main()
{
	int n, sum = 0;
	
	scanf("%d", &n);
	ll s = 0, x;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[i] <= 2 * s) {
			sum++;
		} else {
			sum = 1;
		}
		s += a[i];
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vi a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    vi c(k), d(k);
    rep(i, k) {
        cin >> c[i] >> d[i];
        --c[i];
        --d[i];
    }
    UF uf(n);
    rep(i, m) uf.unite(a[i], b[i]);
    vector<set<int>> st(n);
    rep(i, m) {
        st[a[i]].insert(b[i]);
        st[b[i]].insert(a[i]);
    }
    rep(i, k) {
        if(uf.same(c[i], d[i])) {
            st[c[i]].insert(d[i]);
            st[d[i]].insert(c[i]);
        }
    }
    rep(i, n) {
        cout << uf.size(i) - st[i].size() - 1;
        cout << (i+1 == n ? '\n' : ' ');
    }
    // rep(i, n) cout << uf.size(i) << " " << st[i].size() << endl;
    return 0;
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}
int main()
{
    ll X;
    cin>>X;
    vector<pair<ll,ll>> ae;
    for(ll x=-3981;x<=3981;x++)
    {
        ae.pb({binpow(x,5),x});
    }
    for(auto it : ae)
    {
        for(auto i : ae)
        {
            if(it.first-i.first==X)
            {
                cout<<it.second<<" "<<i.second;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main(){
	int n , m , cnt = 0;
	cin>>n>>m;
	bool s = 1;
	vector<int> a(n);
	for(int i = 0 ; i < n ; i++){cin>>a[i];cnt+=a[i];}
	sort(a.begin() , a.end() , greater<int>());
	if(4*m*a[m-1] < cnt) s = 0;
	cout<<(s ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
    print('Yes')
    print(2)
    print("1 1")
    print("1 1")
    exit()
t = [3]
cnt = 3
while t[-1]+cnt <= n:
    t.append(t[-1]+cnt)
    cnt += 1
if t[-1] != n:
    print('No')
    exit()
print('Yes')
try:
    n_cols = t[-1]-t[-2]
except:
    print(3)
    print("2 1 2")
    print("2 3 1")
    print("2 2 3")
    exit()
print(n_cols+1)
t_len = len(t)
t2 = [i+1 for i in t]
t3 = [0 for i in t]
for col in range(n_cols+1):
    out = str(n_cols)
    if col <=2:
        if col == 0:
            out += " 1 2"
        elif col == 1:
            out += " 1 3"
        elif col == 2:
            out += " 2 3"
    else:
        idx = t[col-3]+1
        while idx <= t[col-2]:
            out += " " + str(idx)
            idx += 1
    for i in range(t_len-1):
        if t2[i] != t[i+1]+1:
            out += " " + str(t2[i])
            t2[i] += 1
    print(out)

Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}

int main() {
    int N, S; cin >> N >> S;
    vector<int> A(N); rep(i, N) cin >> A[i];
    vector<mint> dp(S + 1);
    dp[0] = modpow(2, N);
    rep(i, N) {
        repr(j, S + 1) if (j + A[i] <= S) {
            dp[j + A[i]] += dp[j] * modinv(2);
        }
    }
    cout << dp[S] << endl;
}

struct boot {
    boot() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} boot_;


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

using namespace std;

using lint = long long;

const int N_ = int(3.1e5);

class SegmentTree{
  const int MAXN = int(3e5);
	lint tree[530000*2], lazy[530000*2];
	void lazydown(int p){
		tree[2*p] += lazy[p];
		tree[2*p+1] += lazy[p];
		lazy[2*p] += lazy[p];
		lazy[2*p+1] += lazy[p];
		lazy[p] = 0;
	}
	void add(int s, int e, int ps, int pe, int p, lint v){
		if(e < ps || pe < s) return;
		if(s <= ps && pe <= e){
			tree[p] += v;
			lazy[p] += v;
			return;
		}
		lazydown(p);
		int pm = (ps + pe) / 2;
		add(s, e, ps, pm, 2*p, v);
		add(s, e, pm+1, pe, 2*p+1, v);
		tree[p] = max(tree[2*p], tree[2*p+1]);
	}
	lint query(int s, int e, int ps, int pe, int p){
		if(e < ps || pe < s) return -1e18;
		if(s <= ps && pe <= e) return tree[p];
		lazydown(p);
		int pm = (ps + pe) / 2;
		return max(query(s, e, ps, pm, 2*p), query(s, e, pm+1, pe, 2*p+1));
	}
public:
  void add(int s, int e, lint v) {
    add(s, e, 0, MAXN, 1, v);
  }
  lint query(int s, int e) {
    return query(s, e, 0, MAXN, 1);
  }
  void init() {
    memset(lazy, 0, sizeof lazy);
    memset(tree, 0, sizeof tree);
  }
}seg;

int W, H, N;
using pii = pair<int, int>;
vector<pii> points;

lint solve() {
  lint ret = 0;
  
  seg.init();

  sort(points.begin(), points.end());

  stack<pii> up, down;
  for(int i = 0; i < int(points.size()); i++) {
    int x, y; tie(x, y) = points[i];
    if(y > H/2) {
      int j = i;
      while(!up.empty() && up.top().first > y) {
        seg.add(up.top().second, j-1, (y - up.top().first));
        j = up.top().second;
        up.pop();
      }
      if(j < i) {
        up.emplace(y, j);
      }
    }else {
      int j = i;
      while(!down.empty() && down.top().first < y) {
        seg.add(down.top().second, j-1, -(y - down.top().first));
        j = down.top().second;
        down.pop();
      }
      if(j < i) {
        down.emplace(y, j);
      }
    }
    up.emplace(H, i);
    down.emplace(0, i);

    seg.add(i, i, H - x);
    ret = max(ret, seg.query(0, i) + (i+1 < points.size() ? points[i+1].first : 0));
  }
  
  ret *= 2;
  return ret;
}

int main() {
#ifdef IN_MY_COMPUTER
  freopen("f.in", "r", stdin);
#endif
  scanf("%d%d%d", &W, &H, &N);
  for(int i = 0; i < N+2; i++) {
    int x, y; 
    if(i < N) scanf("%d%d", &x, &y);
    else if(i == N) x = 0, y = 0;
    else x = W, y = H;
    points.emplace_back(x, y);
  }

  lint ans1 = solve();

  swap(H, W);
  for(pii &p : points) {
    swap(p.first, p.second);
  }

  lint ans2 = solve();
  
  printf("%lld\n", max(ans1, ans2));
  return 0;
}

Measured memory_bytes: 21868
a = input()
b = input()

c = [0]*26
cc = [0]*26

for i in a:
    c[int(ord(i)-ord('a'))] += 1
    
for i in b:
    cc[int(ord(i)-ord('a'))] += 1
    
    
for i, j in zip(sorted(c), sorted(cc)):
    if i != j:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a,b;
  cin >> a >> b;
  vector<long> h(1000);
  h[0]=0;
  for(long i=1;i<1000;i++) h[i]=h[i-1]+i;
  cout << h[b-a]-b << endl;
}

Measured memory_bytes: 3632
# https://atcoder.jp/contests/abc121/tasks/abc121_d

import itertools
import collections
import bisect

# bin(10*12) = '0b1110100011010100101001010001000000000000' -> 40桁あればよい
# def calc(x, b):
#     if b == 0:
#         return x // 2 + x % 2
#     base = 2 ** b
#     if x < base:
#         return 0
#
#     if (x // base) % 2:
#         if x // base == 1:
#             return x % base + 1
#         else:
#             return x // 2 + x % base + 1
#     else:
#         return x // 2
#
#
# def main():
#     A, B = map(int, input().split())
#
#     bits = []
#     for i in range(41):
#         a = calc(max(0, A-1), i)
#         b = calc(max(0, B), i)
#         bits.append(abs(b - a) % 2)
#
#     print(bits)
#     ans = 0
#     for i in range(len(bits)):
#         ans += bits[i] * (2 ** i)
#     print(ans)

def calc(x):
    if x % 2:  # 奇数なら 1 or 0
        if x % 4 == 1:
            return 1
        else:
            return 0
    else:
        if x % 4 == 0:
            return x
        else:
            return x ^ 1

def main():
    A, B = map(int, input().split())
    ans = calc(B) ^ calc(max(0, A-1))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

// 3 3 4 2 4
// 1 0 0 0 0
// 0 0 1 0 0
// 0 0 1 0 0
void solve(long long N, vector<long long> a) {
    ll ans = 0, current = 0;
    while (1) {
        if (current == 1) {
            break;
        }
        if (ans >= N) {
            ans = -1;
            break;
        }
        ans++;
        current = a[current] - 1;
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  solve(N, move(a));
  return 0;
}


Measured memory_bytes: 4024
#include <stdio.h>
int a,b,c,z,y,j,aaa;

main(){
 scanf("%d%d%d",&a,&b,&c);


  int x[3] ={a,b,c};

  if(x[0]>x[1]){
  	z=x[0];
  	x[0]=x[1];
  	x[1]=z;
  }
    if(x[0]>x[2]){
  	z=x[0];
  	x[0]=x[2];
  	x[2]=z;
  }
  
    if(x[1]>x[2]){
  	z=x[1];
  	x[1]=x[2];
  	x[2]=z;
  }

  for(aaa=0;aaa<3;aaa++){
  if(aaa==2){printf("%d\n",x[aaa]);break;}
  printf("%d ",x[aaa]);
 
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll ans,n,a[200];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    ans = abs(a[1]-a[n]);
    cout<<ans<<newl;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
R = [W[0]]
for i in range(1,N):
    R.append(R[i-1] + W[i])
s = sum(W)

ans = 1000

for i in range(N):
    ans = min(ans,abs(R[i]-(s-R[i])))
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000003;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    if(a != c) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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


int main(){
	int n,x,ans=0;
	cin>>n>>x;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	rep(i,n){
		x-=a[i];
		if(x>=0)ans++;
		else break;
	}
	if(x>0)ans--;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#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>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<ll> A(1000000);

    A[0] = s;

    for (ll i = 1; i <= 1000000; ++i) {
        if (A[i-1]%2 == 0) { A[i] = A[i-1]/2; }
        else { A[i] = 3 * A[i-1] + 1; }
        for (ll j = 0; j < i; ++j) {
            if (A[i] == A[j]) { cout << i + 1 << endl; goto xyz; }
        }

    }

xyz:;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int g[200][200];
int INF = 1e9;

int main()
{
    rep(i, 200) rep(j, 200) g[i][j] = INF;
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> a(r);
    rep(i, r)
    {
        cin >> a[i];
        a[i]--;
    }
    sort(ALL(a));
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        g[a][b] = g[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

    int minv = INF;

    do
    {
        int sum = 0;
        rep(i, r - 1) sum += g[a[i]][a[i + 1]];
        minv = min(minv, sum);

    } while (next_permutation(ALL(a)));

    OP(minv);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int x,y,z;
cin>>x>>y>>z;
cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

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

typedef long long ll;

const int maxn = 100010;
int a[maxn];
ll dp[maxn][2];

int main() {
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  dp[1][0] = a[0] + a[1];
  dp[1][1] = -dp[1][0];
  for (int i = 2; i < n; ++i) { 
    dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
    dp[i][1] = max(dp[i - 1][0] - 2 * a[i - 1] - a[i], dp[i - 1][1] + 2 * a[i - 1] - a[i]);
//    cout << i << ' ' << dp[i][0] << ' ' << dp[i][1] << endl;
  }
  cout << max(dp[n - 1][0], dp[n - 1][1]);
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int cnt;
	string str;
	cin >> cnt >> str;
	
	int min = 300001;

	std::vector<int> west(cnt,0), east(cnt,0);
	if(str[0] == 'W')
		west[0] = 1;
	else
		east[0] = 1;
	
	for(int i = 1; i < cnt; ++i){
		if(str[i] == 'W'){
			west[i] = west[i-1] + 1;
			east[i] = east[i-1];
		}else{
			west[i] = west[i-1];
			east[i] = east[i-1] + 1;
		}
	}
	
	int ans;
	for(int i = 0; i < cnt; ++i){
		if(i == 0)
			ans = east[cnt-1] - east[i];
		else if(i == cnt-1)
			ans = west[i-1];
		else
			ans = west[i-1] + (east[cnt-1] - east[i]);
		
		if(min > ans)
			min = ans;
	}

	cout << min << endl;
	
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    int dp[3][n]={ 0 };
    for(int i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        if(i>0){
        dp[0][i]=a+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c+max(dp[1][i-1],dp[0][i-1]);
        }else
        {
             dp[0][0]=a;dp[1][0]=b;dp[2][0]=c;
        }
        
    }
    cout<<max({dp[0][n-1],dp[1][n-1],dp[2][n-1]});
     
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

void test(int L, int R) {
    int a = 0, b = 0, c = 0;
    for(int x = L; x <= R; ++x) {
        for(int y = x; y <= R; ++y) {
            bool f = false, g = false;
            if ((x ^ y) == y % x) {
                ++a;
                f = true;
            }
            if (2 * x > y && (x & ~y) == 0) {
                ++b;
                g = true;
                cerr << x << "," << y << endl;
            }
            if (f != g) {
                ++c;
            }
        }
    }
    cerr << a << "," << b << "," << c << endl;
}

int dp[100][2][2][2];

void solve(long long L, long long R){
    int res = 0;

    int t = 62;
    dp[t][1][1][1] = 1;

    for(int i = t; i > 0; --i) {
        int ls = (L >> (i - 1)) & 1, rs = (R >> (i - 1)) & 1;

        // 0, 0, 0
        dp[i - 1][0][0][0] += dp[i][0][0][0] * 3 % MOD;
        dp[i - 1][0][0][0] %= MOD;

        // 0, 0, 1
        // This case doesn't exist

        // 1, 0, 0
        dp[i - 1][1][0][0] += (1 + rs) * dp[i][1][0][0] % MOD + rs * (1 - ls) * (dp[i][1][1][1] + dp[i][1][1][0]) % MOD;
        dp[i - 1][1][0][0] %= MOD;

        // 1, 0, 1
        // This case doesn't exist
        if (rs) {
            // 1, 0, 0

            dp[i - 1][0][0][0] += dp[i][1][0][0] * 1 % MOD;
            dp[i - 1][0][0][0] %= MOD;
        }

        // 0, 1, 0
        dp[i - 1][0][1][0] = ((2 - ls) * dp[i][0][1][0] % MOD + ls * dp[i][0][1][1]) % MOD + rs * (1 - ls) * dp[i][1][1][0];
        dp[i - 1][0][1][0] %= MOD;
        if (!ls) {
            // 0, 1, 0
            dp[i - 1][0][0][0] += dp[i][0][1][0] * 1 % MOD;
            dp[i - 1][0][0][0] %= MOD;

            // 0, 1, 1
            dp[i - 1][0][0][0] += dp[i][0][1][1] * 1 % MOD;
            dp[i - 1][0][0][0] %= MOD;
        }


        dp[i - 1][0][1][1] = (1 - ls) * (dp[i][0][1][1] + dp[i][1][1][1] * rs) % MOD;

        if (rs || !ls) {
            // 1, 1, 0
            dp[i - 1][1][1][0] = (dp[i][1][1][0] + dp[i][1][1][1] * rs * ls) % MOD;
        }

        if (rs && !ls) {
        } else if (!rs && !ls) {
            // 1, 1, 1
            dp[i - 1][1][1][1] += dp[i][1][1][1] * 1 % MOD;
            dp[i - 1][1][1][1] %= MOD;

            // 1, 1, 0
        }
    }

    for(int i = 0; i < 2; ++i) for(int j = 0; j < 2; ++j)  {
                res = (res + dp[0][i][j][0]) % MOD;
            }

    cout << res << endl;
}

signed main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
$array = explode(" ", $input);
$s = $array[0];
$c = $array[1];

if ( $s >= floor($c / 2)) {
  echo floor($c / 2)."\n";
} else {
  echo $s + floor( ($c - 2 * $s ) / 4) . "\n";
}

Measured memory_bytes: 4604
#計数ソート
maxx = 2000001;
maxnum = 10010;

n=int(input())
A=[int(x) for x in input().split()]  
A.insert(0,0) 
B=[-1 for x in range(n)]
C=[0 for x in range(maxnum)]



for a in A[1:]:
    C[a]+=1
for i in range(1,maxnum): # 累加和
    C[i]+=C[i - 1]
    
for j in range(1,n+1):
    B[C[A[j]]-1]=A[j]
    C[A[j]]-=1

lens=len(B)    
for i in range(0,lens-1):
    print(B[i],end=' ')
print(B[lens-1])


Measured memory_bytes: 224204
n, m = map(int, input().split())
a =0
for i in range(n+1):
    for s in range(0, n+1-i)[::-1]:
        if 4*(i) + 2*(n-i) == m:
            a = a + 1
        else:
            a = a
if a > 0:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <math.h>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;

int main(void){
    int A,B,ans=0;

    cin >> A >> B;

    if(A >= 13) ans = B;
    else if(A >= 6) ans = B / 2;
    else if(A <= 5) ans =0;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//Try until you reach your goal
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    ll k=0;
    ll flg=0;
    while(x--){
        ll a,b;
        cin>>a>>b;
        if(a==b){
            k++;
        }
        else{
            k=0;
        }
        if(k>=3){
            flg=1;
        }
    }
    if(flg==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const char NONE = '0';

int main(void) {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string str;
		cin >> str;

		string train(500, NONE);
		int pos = 250;
		train[pos] = str[0];

		for (int j = 1; j < (int)str.size(); j += 3) {
			char c = str[j + 2];
			int dir = str[j] == '<' ? -1 : 1;
			pos += dir;
			train[pos] = c;
		}

		remove_if(train.begin(), train.end(), [](char c){ return c == NONE; });
		train = train.substr(0, train.find(NONE));

		cout << train << endl;
	}

	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int P[N];
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  sort(P,P+N);
  int sum;
  for(int i=0;i<N-1;i++){
    sum=sum+P[i];
  }
  sum=sum+P[N-1]/2;
  cout<<sum<<endl;
  return 0;
}

  
  
    

Measured memory_bytes: 256