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

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

#define INF 1000000000
#define index(a, b, c) (a)*81+(b)*9+(c)

int N;
char s[100004];
int dp[2][2*9*9];

bool input(){
  cin>>s;
  if(s[0]=='#')return false;
  N = strlen(s);
  REP(i, N)s[i] -= '1';
  return true;
}

int x[9] = {0,1,2,0,1,2,0,1,2};

void solve(){
  REP(i, 2) {
  	REP(j, 9) {
  		REP(k, 9) {
  			if(x[j]>x[k]) dp[0][index(i, j, k)] = INF;
  			else dp[0][index(i, j, k)] = 0;
  		}
  	}
  }
  
  REP(l, N) {
    REP(i, 2*9*9)dp[1][i] = INF;
    
  	REP(i, 2) {
  		REP(j, 9) {
  			REP(k, 9) {
  				if(dp[0][index(i, j, k)] == INF)continue;
  				if(x[s[l]]<=x[k])
  				dp[1][index(0, s[l], k)] = min(dp[1][index(0, s[l], k)], dp[0][index(i, j, k)]+(i==0));
  				if(x[s[l]]>=x[j])
  				dp[1][index(1, j, s[l])] = min(dp[1][index(1, j, s[l])], dp[0][index(i, j, k)]+(i==1));
  				
  			}
  		}
  	}
  	
    REP(i, 2*9*9)dp[0][i] = dp[1][i];
  }
  
  int a = INF;
  /*REP(i, N+1){
    REP(j,2*9*9){
      if(dp[i][j] == INF)
        cout<<'N';
      else
        cout<<dp[i][j];
      if((j+1)%9==0)cout<<' ';
    }
    cout<<endl;
  }*/
  REP(i, 2*9*9) {
    a = min(a, dp[1][i]);
  }
  cout<<a<<endl;
}

int main(){
  //cin.tie(0);
  
  while (input()){
      solve();
  }
  
  return 0;
}

Measured memory_bytes: 3048
N = int(input())

a = list(map(int, input().split()))

F = 0

for i in range(N):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      F = 1
      
if F == 1:
  print('DENIED')
else:
  print('APPROVED')
      



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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  k = n - k;
  if (k == 0) return cout << 0 << endl, 0;
  VV<lint> dp(k + 2, V<lint>(n, 1e18));
  V<> h(n);
  REP(i, n) {
    cin >> h[i];
    for (int x = k; x >= 2; --x) REP(j, i) {
      dp[x][i] = min(dp[x][i], dp[x - 1][j] + (h[j] < h[i] ? h[i] - h[j] : 0));
    }
    dp[1][i] = h[i];
  }
  cout << *min_element(begin(dp[k]), end(dp[k])) << endl;
}


Measured memory_bytes: 1024
import math

temp = input().split(" ")
min = int(temp[0])
max = int(temp[1])
divisor1 = int(temp[2])
divisor2 = int(temp[3])
divisors = [divisor1,divisor2] if divisor1 > divisor2 else [divisor2, divisor1]

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

gcdDivisors = gcd(divisors[0], divisors[1]);
lcmDivisors = (divisor1 * divisor2) // gcdDivisors

divNum1 = max // divisor1 - (min - 1) // divisor1;
divNum2 = max // divisor2 - (min - 1) // divisor2;
divNumLcm = max // lcmDivisors - (min - 1) // lcmDivisors;

divNumTotal = divNum1 + divNum2 - divNumLcm;
ans = max - min + 1 - divNumTotal

print(int(ans))    


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

struct mint {
  ll x;
  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;
  }
  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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct cominit {
  vector<mint> fact, ifact;
  cominit(int n): fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int r) {
    if (n < r or r < 0) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
  }
};

int main() {
  int s;
  cin >> s;
  int div = 0;
  mint ans = 0;
  cominit nCr(5000);
  while (1) {
    s -= 3;
    if (s < 0) break;
    ans += nCr(s + div, div);
    div++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
int main(void){
int a,ball[10],r,l,i,j,k,m,cou,cou2,bre,kai;
scanf("%d",&a);
for(i=0;i<a;i++){
    cou=0,cou2=0,r=0,l=0,kai=0,bre=1;
    for(j=0;j<10;j++){
        scanf("%d",&ball[j]);
    }
    for(k=0;k<9;k++){
        if(ball[k]<ball[k+1]){
            cou=cou+1;
        }
        if(ball[k]>ball[k+1]){
            cou2=cou2+1;
        }
        if(cou==9||cou2==9)break;
    }
    for(m=0;m<10;m++){
        if(cou==9||cou2==9)break;
        if(r==0){
            r=ball[0];
            continue;
        }
        if(r>ball[m]&&l>ball[m]){
            printf("NO\n");
            break;
        }
        if(r<ball[m]){
            r=ball[m];
        }
        else if(r>ball[m]){
            l=ball[m];
        }
        kai=kai+1;
    }
    if(cou==9){
        printf("YES\n");
        continue;
    }
    if(cou2==9){
        printf("NO\n");
        continue;
    }
    if(kai==9){
    printf("YES\n");
    }
}
return 0;
}

Measured memory_bytes: 580
import heapq
t = 1
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	# n = map(int,input().split())
	n = int(input())
	a = list(map(int,input().strip().split()))[0:n]
	b = list(map(int,input().strip().split()))[0:n]
	c = list(map(int,input().strip().split()))[0:n-1]
	ans = 0
	for i in range(n):
		ans += b[i]
	for i in range(n-1):
		x = a[i]
		y = a[i+1]
		if(y == x+1):
			ans += c[x-1]
	print(ans)
	# print(n*n*n)
	# m = 1000
	# i = 0
	# while i < n:
	# 	j = i
	# 	while j+1 < n and v[j+1] >= v[j]:
	# 		j += 1
	# 	x = m//v[i]
	# 	m = m%v[i]
	# 	temp = x*v[j]
	# 	m += temp
	# 	i = j+1
	# print(m)


Measured memory_bytes: 62416
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto n = N;
    int[] ps;
    foreach (i; 2..10^^6) {
        while (n%i == 0) {
            n /= i;
            ps ~= i;
        }
    }
    if (n != 1) ps ~= n;
    writefln("%d: %s", N, ps.to!(string[]).join(" "));
}


Measured memory_bytes: 2536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,n;
    cin>>n>>a>>b;
    cout<<(((n*a)<b)?(n*a):b)<<"\n";
    return 0;
}

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

list_s = [1,2,3,4,5,6,7,8,9,10,11,12,13]
list_h = [1,2,3,4,5,6,7,8,9,10,11,12,13]
list_c = [1,2,3,4,5,6,7,8,9,10,11,12,13]
list_d = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(n):
    zugara, num = input().split()
    #print(zugara)
    #print(num)
    #print(list_s)
    if zugara == 'S':
        list_s.remove(int(num))
    elif zugara == 'H':
        list_h.remove(int(num))
    elif zugara == 'C':
        list_c.remove(int(num))
    else:
        list_d.remove(int(num))

for i in list_s:
    print('S', i)
for i in list_h:
    print('H', i)
for i in list_c:
    print('C', i)
for i in list_d:
    print('D', i)


Measured memory_bytes: 5612
class Bit
  def initialize(n)
    @bit = Array.new(n + 1, 0)
    @n = n
  end

  def add(i, x)
    while i <= @n
      @bit[i] += x
      i += i & -i
    end
  end

  def sum(i)
    s = 0
    while i > 0
      s += @bit[i]
      i -= i & -i
    end
    s
  end
end

N, M, Q = gets.split.map(&:to_i)
lrs = M.times.map { gets.split.map(&:to_i) }
pqs = Q.times.map { gets.split.map(&:to_i) }
list = []
lrs.each do |(l, r)|
  list.push([l, r, -1])
end
pqs.each.with_index do |(p, q), i|
  list.push([p, q, i])
end
sorted = list.sort_by { |(_, b, c)| [b, c] }
bit = Bit.new(N)
ans = Array.new(Q)
sorted.each do |(a, b, c)|
  if c == -1
    bit.add(a, 1)
  else
    sum = bit.sum(b) - bit.sum(a - 1)
    ans[c] = sum
  end
end
ans.each do |sum|
  puts sum
end


Measured memory_bytes: 53496
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	double dp[n+1][n+1],h[n];
	f(i,0,n)
		cin>>h[i];
	dp[0][0]=1;
	f(i,1,n+1)
		dp[i][0]=1,dp[0][i]=0;
	f(i,1,n+1)
		dp[i][0]=dp[i-1][0]*(1-h[i-1]);
	f(i,1,n+1)
	{
		f(j,1,i+1)
			dp[i][j]=(dp[i-1][j-1]*h[i-1]+dp[i-1][j]*(1-h[i-1]));
		f(j,i+1,n+1)
			dp[i][j]=0;	
	}
	double ans=0.0;
	f(i,(n+1)/2,n+1)
		ans+=dp[n][i];
	cout<<sp(12)<<ans;
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, ans;
	cin >> n;
	if (n <= 599) ans = 8;
	else if (n <= 799) ans = 7;
	else if (n <= 999) ans = 6;
	else if (n <= 1199) ans = 5;
	else if (n <= 1399) ans = 4;
	else if (n <= 1599) ans = 3;
	else if (n <= 1799) ans = 2;
	else if (n <= 1999) ans = 1;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
 using namespace std;
 const long long mod=1e9+7;

 int main(){
 int N,M;
 cin>>N>>M;

    vector<int>oks(N+1,true);
    for(int i=0;i<M;++i){
 int a;cin>>a;
 oks[a]=false;
 }
    vector<long long int>dp(N+1);
 dp[0]=1;
 for(int now=0;now<N;++now){
 for(int next=now+1;next<=min(N,now+2);++next){
 if(oks[next]){
 dp[next]+=dp[now];
 dp[next]%=mod;
 }
 }
 }

 cout<<dp[N]<<endl;
 return 0;
 }




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int N = 110 , mz = 1e9+7;

int main(){
    int n,k;
    long long sum = 0;
    cin>>n;
    while( n-- ){
        cin>>k;
        sum += k-1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char in;
	cin>>in;
	switch (in){
		case 'A':
			cout<<"T";
			break;
		case 'T':
			cout<<"A";
			break;
		case 'C':
			cout<<"G";
			break;
		case 'G':
			cout<<"C";
			break;
	}
	
}

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

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

  vector<int> H;
  int Hi;
  for ( int i=0; i<N; i++ ) {
	cin >> Hi;
	H.push_back(Hi);
  }

  int ans = 0;
  int Hmax = 0;
  for ( int i=0; i<N; i++ ) {
	if ( H[i] >= Hmax ) {
	  Hmax = H[i];
	  ans++;
	};
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N, K; cin >> N >> K;
	vector<bool> D(10, false);;
	rep(i, 0, K) {
		int tmp; cin >> tmp;
		D[tmp] = true;
	}
	//int ans = N;
	while (true) {
		int ans = N;
		int tmp = ans;
		while (ans > 0) {
			if (D[ans % 10])break;
			ans /= 10;
		}
		if (ans == 0)break;
		N++;
	}
	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
/* ac */
/* gcc ac.c -o ac */

#include <stdio.h>


int main()
{
int a, b, c;
int ab, bc, ca;


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

ab = a+b;
bc = b + c;
ca = c + a ;

if(ab <= bc && ab <= ca)
printf("%d",ab);

else if(bc<= ca)
printf("%d",bc);

else 
printf("%d",ca);

return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

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

    static class TimeLimitExceeded {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int N = in.nextInt();
            int limitedTime = in.nextInt();

            Map<Integer, Integer> input = new TreeMap<>();

            // 経路値の入力の取得
            for (int i = 0; i < N; i++) {
                input.put(in.nextInt(), in.nextInt());
            }

            int ans = 0;
            for (Map.Entry<Integer, Integer> e : input.entrySet()) {
                if (e.getValue() <= limitedTime) {
                    ans = e.getKey();
                    break;
                }
            }

            if (ans == 0) {
                out.println("TLE");
                return;
            }

            out.println(ans);
        }

    }
}



Measured memory_bytes: 25172
#include<stdio.h>

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

  if(a <= b)
    if(b <= c){
      printf("%d %d %d\n",a,b,c);
    }
    else if(a <= c){
      printf("%d %d %d\n",a,c,b);
      }
    else{
      printf("%d %d %d\n",c,a,b);
    }
  else if(a <= c){
    printf("%d %d %d\n",b,a,c);
    }
    else if(b <= c){
      printf("%d %d %d\n",b,c,a);
      }
        else{
	  printf("%d %d %d\n",c,b,a);
	}
  return 0;
}

Measured memory_bytes: 596
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int _(int x) {
  return x + 500;
}

struct point {
  int x;
  int y;
  int d;
  point(int x, int y, int d)
    : x(x), y(y), d(d) {
  }
};

void solve() {
  int t, n;
  while (cin >> t >> n, t) {
    vvi m(1000, vi(1000, false));
    while (n--) {
      int x, y;
      cin >> x >> y;
      m[_(x)][_(y)] = true;
    }
    int sx, sy;
    cin >> sx >> sy;
    queue<point> q;
    q.push(point(sx, sy, 0));
    int c = 0;
    while (q.size()) {
      point p = q.front();
      q.pop();
      if (p.d > t || m[_(p.x)][_(p.y)]) continue;
      c++;
      m[_(p.x)][_(p.y)] = true;
      int dx[] = {1, 1, 0, -1, -1, 0}, dy[] = {1, 0, -1, -1, 0, 1};
      rep(i, 6) q.push(point(p.x + dx[i], p.y + dy[i], p.d + 1));
    }
    cout << c << endl;
  }
}

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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

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

  vector<string> v;

  while (1) {
    string t;
    cin >> t;

    if (t == "END_OF_TEXT") {
      break;
    }

    transform(all(t), t.begin(), ::tolower);
    v.push_back(t);
  }

  int count = 0;

  for (auto &&i : v) {
    if (w == i) {
      count++;
    }
  }

  printf("%d\n", count);
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){

    map<char,int> a;
    char s;
    while(cin>>s){
        a[s]++;
    }
    for(auto i=a.begin();i!=a.end();i++){
        if(i->second%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
        
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
    bool ok = false;
    while (N != 0)
    {
        if (N % 10 == 7)
        {
            ok = true;
        }
        N /= 10;
    }
    if (ok)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

ll power(ll a,ll b){
	if(b==0) return 1;
	if(b&1) return power(a,b/2)*power(a,b/2)*a;
	else return power(a,b/2)*power(a,b/2);
}

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		int n,ma=-1;
		cin>>n;
		map<string,int> m;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			m[s]++;
			ma=max(ma,m[s]);
		}

		for(auto i:m){
			if(i.ss==ma){
				cout<<i.ff<<endl;
			}
		}
	}
}

Measured memory_bytes: 26880
module Main where
 
import Control.Applicative
import Text.Printf
import Numeric
 
main :: IO ()
main = do
  { [r] <- getDoubles
  ; let area = pi * r ^ 2
  ; let peri = 2 * pi * r
  ; putDoubles [area, peri]
  }
 
--
 
getInts :: IO [Int]
getInts = map read . words <$> getLine
 
putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show
 
getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine
 
putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble
 
showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""


Measured memory_bytes: 4108
#include <stdio.h>

int main(void){
    int A, B, max;
    scanf("%i %i", &A, &B);
    int a = A + B;
    int b = A - B;
    int c = A * B;
    max = a;
    if (max < b){
        max = b;
    }
    if (max < c){
        max = c;
    }
    printf("%i", max);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//



     signed main(){
  int d;
  clock_t st=clock();
  cin>>d;
    clock_t ed=clock();

  int c[26];
  for(int i=0;i<26;i++)cin>>c[i];
  int t[d],s[d][26],x[26]={};
    vector<int>v[26];
    for(int i=0;i<26;i++)v[i].push_back(-1);

  for(int i=0;i<d;i++)for(int j=0;j<26;j++)cin>>s[i][j];
   // cerr<<'i';
  for(int i=0;i<d;i++){
      for(int j=0;j<26;j++)x[j]+=c[j];
      int k=0;
      for(int j=1;j<26;j++)if(x[k]+s[i][k]<x[j]+s[i][j])k=j;
      t[i]=k;
      x[k]=0;
      v[k].push_back(i);
  }
  for(int i=0;i<26;i++)v[i].push_back(d);
//for(int i=0;i<d;i++)cout<<t[i]+1<<endl;
  // cerr<<double(clock()-st)/CLOCKS_PER_SEC<<endl;
//while(false){
while(double(clock()-st)/CLOCKS_PER_SEC<1.95){
  if(rand()%5){
    int p=rand()%d;
    auto q=find(v[t[p]].begin(),v[t[p]].end(),p);
    q++;
  // int m=(p+(*q))/2;
   int m=p+rand()%((*q)-p);
//cerr<<m<<' '<<p<<endl;
   if(m==p)continue;
   auto r1=find(v[t[m]].begin(),v[t[m]].end(),m);
   auto r0=r1-1,r2=r1+1;
   if((m-p)*((*q)-m)*c[t[p]]+s[m][t[p]]>(m-(*r0))*((*r2)-m)*c[t[m]]+s[m][t[m]]){
 
    v[t[p]].insert(q,m);
    v[t[m]].erase(r1);
    t[m]=t[p];
   }
  }else{
    int u=1;
    if(rand()%2)u++;
    if(u>=d)continue;
    int p=rand()%(d-u);
    if(t[p]==t[p+u]||p+u==d){continue;}
    auto q1=find(v[t[p]].begin(),v[t[p]].end(),p);
    auto q0=q1-1,q2=q1+1;
      auto r1=find(v[t[p+u]].begin(),v[t[p+u]].end(),p+u);
    auto r0=r1-1,r2=r1+1;
    if((p-(*q0))*((*q2)-p)*c[t[p]]+s[p][t[p]]+(p+u-(*r0))*((*r2)-p-u)*c[t[p+u]]+s[p+u][t[p+u]]<(p+u-(*q0))*((*q2)-p-u)*c[t[p]]+s[p+u][t[p]]+(p-(*r0))*((*r2)-p)*c[t[p+u]]+s[p][t[p+u]]){
      (*q1)=p+u;
      (*r1)=p;
      swap(t[p],t[p+u]);
    }
   
  }




}
     for(int i=0;i<d;i++)cout<<t[i]+1<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3748
#include<cstdio>
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;

int main(){
    int len_array,num_query;
    int command,b,e;
    
    scanf("%d",&len_array);
    vector<int> int_array(len_array,0);
    
    for(int i = 0; i < len_array;i++){
        cin >> int_array[i];
    }
    scanf("%d",&num_query);
    for(int i = 0; i < num_query;i++){
        scanf("%d %d %d",&command,&b,&e);
        int min_val = int_array[b];
        int max_val = int_array[b];
        for(int j = b;j < e;j++){
            min_val = min(min_val,int_array[j]);
            max_val = max(max_val,int_array[j]);
        }
        if(command == 0) printf("%d\n",min_val);
        else printf("%d\n",max_val);
    }
    
    return 0;
}


Measured memory_bytes: 3208
fn solve(ls: Vec<usize>) -> usize {
    let n = ls.len();
    let mut ls = ls;
    ls.sort();

    let mut cnt = 0;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            for k in (j + 1)..n {
                if ls[i] + ls[j] <= ls[k] {
                    break;
                }
                cnt += 1;
            }
        }
    }

    cnt
}

#[test]
fn test_solve() {
    assert_eq!(solve(vec![3, 4, 2, 1]), 1);
    assert_eq!(solve(vec![1, 1000, 1]), 0);
    assert_eq!(solve(vec![218, 786, 704, 233, 645, 728, 389]), 23);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let ls = parse_vec!(usize);
    println!("{}", solve(ls));
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<ll, ll>> v(N);
	for(int i=0; i<N; ++i){
	    ll a, b;
	    cin >> a >> b;
	    v[i]=make_pair(b, a);
	}
	sort(v.begin(), v.end());
	ll now=0;
	bool flag=true;
	for(int i=0; i<N; ++i){
	    now += v[i].second;
	    if(now>v[i].first){
	        flag=false;
	        break;
	    }
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

void printArray(int array[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (i == n - 1) {
      printf("%d\n", array[i]);
    } else {
      printf("%d ", array[i]);
    }
  }
  return;
}

int main() {
  int i, n, array[100];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", array + i);
  }
  for (i = 1; i < n; i++) {
    printArray(array, n);
    int key = array[i];
    int j = i - 1;
    while (j >= 0 && array[j] > key) {
      array[j + 1] = array[j];
      j--;
    }
    array[j + 1] = key;
  }
  printArray(array, n);
  return 0;
}


Measured memory_bytes: 2048
from collections import defaultdict as dd
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dict = dd(int)
for i in d:
    dict[i] += 1
for i in t:
    dict[i] -= 1
for k in dict:
    if dict[k] < 0:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 41700
N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j] = li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

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

int main() {
  int N,M;
  long long p;
  long long c = 0;
  int NM = 0;
  int NN = 0;
  int MM = 0;
  cin >> N >> M;

// N:M 2n + 2n + 1 = 4n + 1
// N:N 2n + 2n = 4n
// M:M 2n + 1 + 2n + 1 = 4n + 2

  NM = N * M ;
  if (N>1) NN = N * (N-1) ;
  if (M>1) MM = M * (M-1) ;

  cout << (NN + MM) / 2 << endl;
}

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

const int MAXN=200005;

int n,k;
long long a[MAXN],s[MAXN],b[MAXN];
map<long long,int> mp;

int lowbit(int x)
{
    return (x&-x);
}

void modify(int x,int num)
{
    while(x<=n+1){
        a[x]+=(long long)num;
        x+=lowbit(x);
    }
}

long long sum(int x)
{
    long long ans=0;
    while(x>0){
        ans+=a[x];
        x-=lowbit(x);
    }
    return ans;
}

int main()
{
    scanf("%d %d",&n,&k);
    s[0]=0;b[0]=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        s[i]=s[i-1]+(long long)(x-k);
        b[i]=s[i];
    }
    sort(b,b+1+n);
    int tot=0;
    for(int i=0;i<=n;i++)
        if(!mp.count(b[i]))mp[b[i]]=++tot;
    long long cnt=0;
    memset(a,0,sizeof(a));
    for(int i=0;i<=n;i++){
        cnt+=sum(mp[s[i]]);
        modify(mp[s[i]],1);
    }
    printf("%lld\n",cnt);
    return 0;
}


Measured memory_bytes: 17408
//***********************************************************************************************************//
//    TOPIC :
//***********************************************************************************************************//
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define ll long long int
#define ull unsigned long long int
#define INF 99999999
ll mod = 1e9 + 7;

// int mod = 1e9 + 7;
#define fr(a, b, c) for (int a = b; a < c; a++)
#define fre(a, b, c) for (int a = b; a <= c; a++)

void the_martian()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll powm(ll a, ull b)
{
    // m_steps = 0;
    ll res = 1;
    while (b)
    {
        // m_steps++;
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        // cout << a << " " << b << endl;
        b >>= 1;
    }
    return res;
}

int main()
{
    
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int dp[n + 1];
    dp[0] = 0;
    dp[1] = 0;

    for (int i = 2; i <= n; i++)
    {
        int t = 1;
        int ans = INT_MAX;
        while (0 < (i - t) && t <= k)
        {
            ans = min(ans, dp[i - t] + abs(arr[i - 1] - arr[i - t - 1]));
            t++;
        }

        // cout << ans << endl;
        dp[i] = ans;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1152
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

struct Ville {
    large x, y;
    large p;

    large near_x, near_y;
};

int nx;
int xs[20];
int ny;
int ys[20];

static large solve(Ville* const v, const int n, const int start, const int k) {
    if (k == 0) {
        auto sum = 0LL;
        for (int i = 0; i < n; ++i) {
            auto xmin = LLONG_MAX;
            auto ymin = LLONG_MAX;
            for (int ix = 0; ix < nx; ++ix)
                xmin = min(xmin, abs(v[i].x - xs[ix]));
            for (int iy = 0; iy < ny; ++iy)
                ymin = min(ymin, abs(v[i].y - ys[iy]));
            sum += v[i].p * min(xmin, ymin);
        }
        return sum;
    }

    auto score = LLONG_MAX;
    for (int i = start; i + k <= n; ++i) {
        // horizontal
        xs[nx++] = v[i].x;
        auto case1 = solve(v, n, i + 1, k - 1);
        nx--;
        // vertical
        ys[ny++] = v[i].y;
        auto case2 = solve(v, n, i + 1, k - 1);
        ny--;

        score = min({score, case1, case2});
    }
    return score;
}

int main()
{
    int n;
    cin >> n;
    auto ville = vector<Ville>();
    for (auto i = 0; i < n; ++i) {
        auto v = Ville{};
        cin >> v.x >> v.y >> v.p;
        ville.push_back(v);
    }


    xs[nx++] = 0;
    ys[ny++] = 0;
    for (int k = 0; k < n; ++k) {
        cout << solve(ville.data(), n, 0, k) << "\n";
    }

    for (int k = n; k <= n; ++k) {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 3604
/*
 * atcoder/abc080/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v) { cout << v << endl; }
template <typename T> void in(T &v) { cin >> v; }
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<int, bool> P;
vector<pair<int, int> > B;
vector<pair<int, int> > A[30];
vector<P> D;

int main() {
  int N, C;in(N),in(C);
  {
    loop(i,0,N) {
      int s, t, c; in(s),in(t),in(c);
      c--;
      A[c].emplace_back(s, t);
    }

    loop(i,0,C) {
      sort(A[i].begin(), A[i].end());
      int m = A[i].size();
      loop(j,0,m) {
        auto a = A[i][j];
        if (j==0) {
          B.push_back(a);
          continue;
        }

        auto &b_last = B.back();
        if (b_last.second == a.first) {
          b_last.second = a.second;
          continue;
        }

        B.push_back(a);
      }
    }
  }

  {
    for (auto b: B) {
      D.emplace_back(b.first, false);
      D.emplace_back(b.second, true);
    }
    sort(D.begin(), D.end());
  }

  int cnt = 0;
  int ans = 0;
  for (auto &&d: D) {
    if (!d.second) {
      ans = max(ans, ++cnt);
    } else {
      cnt--;
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 7344
#include <stdio.h>
  
int main(void){
    char ch;
    int alpha[26]={0},i;
    while(scanf("%c",&ch)!=EOF){
        if('A'<=ch && ch<= 'Z'){
            alpha[ch-'A']++;
        }
        else if('a'<=ch && ch<= 'z'){
            alpha[ch-'a']++;
        }
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,alpha[i]);
    }
    return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

ll gcd(ll a,ll b){
  while(b!=0){
    ll tmp=a;a=b;b=tmp%b;
  }
  return a;
}

int main()
{
  ll n;string s;cin>>n>>s;
  ll a[3]={0,0,0};
  for(ll i=0;i<n;i++){
    if(s[i]=='R')a[0]++;
    if(s[i]=='G')a[1]++;
    if(s[i]=='B')a[2]++;
  }
  ll ans=a[0]*a[1]*a[2];
  for(ll i=0;i<=n-3;i++){
    for(ll j=1;j<=(n-1-i)/2;j++){
      if(s[i]!=s[i+j] && s[i]!=s[i+j*2] && s[i+j]!=s[i+j*2])ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  string x;
  int sum;

  while(true){
    sum = 0;
    cin >> x;
    if(x == "0") break;
    for(int i=0; i<x.size(); i++){
      sum += x[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

int n, k;

void dfs(int cur, vector<int> &ans, vector<vector<int>> &g, vector<bool> &used){
    
    used[cur] = true;

    // 周りの頂点数
    int num = g[cur].size();

    // 決定済みの頂点数
    int cnt = 0;
    for(int i = 0; i < g[cur].size(); i++){
        int nxt = g[cur][i];
        if(ans[nxt] != -1) cnt++;
    }

    // 残った色の数
    int rest = k - 1 - cnt;
    
    // 残った色を順番に割り振る
    for(int i = 0; i < g[cur].size(); i++){
        int nxt = g[cur][i];
        if(ans[nxt] == -1){
            ans[nxt] = rest;
            rest--;
        }
    }

    for(int i = 0; i < g[cur].size(); i++){
        int nxt = g[cur][i];
        if(used[nxt] == false){
            dfs(nxt, ans, g, used);
        }
    }

}

signed main(){
    
    cin >> n >> k;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    vector<int> ans(n, -1);
    ans[0] = k;
    vector<bool> used(n, false);
    dfs(0, ans, g, used);
    int anss = 1;
    for(int i = 0; i < n; i++){
        anss *= ans[i];
        anss %= MOD;
    }
    cout << anss << endl;
    return 0;
}


Measured memory_bytes: 11136
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N-K+1):
    l,r = x[i],x[i+K-1]
    if l*r>=0:
        ans = min(ans,max(abs(l),abs(r)))
    else:
        ans = min(ans,min(abs(l)*2+r,abs(l)+r*2))
print(ans)

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

#define fo(i,a,b) for (register int i = a;i <= b;i ++)
#define fd(i,a,b) for (register int i = a;i >= b;i --)
#define wr(a,b) printf("%s = %d\n",a,b)
#define mem(a,b) memset(a,(b),sizeof(a))

using namespace std;

const int N = 100010;

int n;
int h[N], w[N];
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
    //freopen("in.txt","r",stdin);
    
    cin >> n;
    bool ans = 1;
    fo (i,1,n){
		cin >> h[i];
		if (i == 1) continue;
		if (!w[i])
		 if (h[i] == h[i - 1]) w[i] = w[i - 1];
		  else w[i] = h[i - 1];
		  //cout << w[i] << endl;
		  //cout << h[i] << endl;
		  //cout << (w[i - 1] <= h[i - 1])<< endl;
		if (h[i] < h[i - 1]) 
		 if (h[i - 1] - h[i] == 1)
		   ans &= (w[i - 1] <= h[i - 1]) ;
		  // w[i + 1] = h[i]; 
		  else ans = 0;
		//cout << " --" <<  ans << endl;
    }
    if (ans) cout << "Yes" << endl;
     else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    ll n; cin >> n;
    vll a(n),tmp(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    if(n % 2 == 0)rep(i,n)tmp[i] = 2*(i/2) + 1;
    else rep(i,n)tmp[i] = 2*((i+1) / 2);
    
    bool b = a == tmp;
    if(!b){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i,n/2){
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
} 

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

int main()
{
    int n, i, j, key = 0, ans = 0;
    string s;
    
    cin >> s;
    
    n = s.size();
    
    for(i = n-2; (i >= 2) && (key == 0); i = i-2) {
        
        for(j = 0; j < i / 2; j++) {
            if(s[j] != s[(i/2)+j]) {
                break;
            }
            
            if(j+1 == i/2) {
                key = 1;
                ans = i;
            }
        }
    }
    
    cout << ans << "\n";
    
    return 0;
}

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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int A = line[0];

            int B = line[1];

            if (A <= B * 2)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(A - B * 2);
            }
        }
        

    }
}   


Measured memory_bytes: 13268
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	int N;
	string S[300];
	cin >> N;
	for(int i=0; i<N; i++) cin >> S[i];
	int ans = 0;
	for(int i=0; i<N; i++){
		bool flg = true;
		for(int j=0; j<N; j++){
			for(int k=0; k<N; k++){
				if(S[j][k] != S[k][j]) flg = false;
			}
		}
		ans += flg * N;
		string s = S[0];
		for(int j=0; j<N-1; j++){
			S[j] = S[j+1];
		}
		S[N-1] = s;
	}
	cout << ans << endl;
}

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

int main()
{
  std::string input;
  std::cin >> input;
  int zero_first_cnt = 0;
  bool one_flag = false;
  for (char ch : input) {
    if (one_flag) {
      if (ch == '0') {
        zero_first_cnt++;
      }
    } else {
      if (ch == '1') {
        zero_first_cnt++;
      }
    }
    one_flag = !one_flag;
  }
  std::cout << std::min(zero_first_cnt, (int)input.size()-zero_first_cnt) << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
using namespace std;

int N, M, v[1100000], seen;
vector<int> range[100005];

void u(int n, int b, int t, int s, int e) {
    if (s >= t || e <= b) return;
    if (s <= b && e >= t) v[n] += 1;
    else u(2*n,b,(b+t)/2,s,e), u(2*n+1,(b+t)/2,t,s,e);
}

int q(int n, int b, int t, int x) {
    if (x < b || x >= t) return 0;
    return v[n] + (t-b>1 ? q(2*n,b,(b+t)/2,x) + q(2*n+1,(b+t)/2,t,x):0);
}

int main() {
    scanf("%d %d", &N, &M);
    for (int i = 0, l, r; i < N; i++) {
        scanf("%d %d", &l, &r);
        range[r-l+1].push_back(l);
    }
    for (int i = 1; i <= M; i++) {
        int o = N-seen;
        for (int j = i; o < N && j <= M; j += i) o += q(1,1,M+5,j);
        printf("%d\n", o);
        seen += range[i].size();
        for (auto it = range[i].begin(); it != range[i].end(); it++) u(1,1,M+5,*it,(*it)+i);
    }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(rall(b));
  rep(i,n){
    if(a[i]==b[0]){
      cout<<b[1]<<endl;
    }
    else{
      cout<<b[0]<<endl;
    }
  }
}

Measured memory_bytes: 3200
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let xs: Vec<i64> = get_vec();

    let rs = {
        let mut rs = vec![(0, 0); n];
        for (i, x) in xs.iter().enumerate() {
            rs[i] = (*x, i);
        }
        rs.sort_by(|(a, _), (b, _)| b.cmp(a));
        rs
    };

    let mut ans = vec![0; n];
    let &(mut current_top, mut current_top_i) = &rs[0];
    ans[current_top_i] = current_top;
    let mut pending_num = 1;
    let mut done_num = 0;
    for (x, i) in &rs[1..] {
        if i < &current_top_i {
            ans[current_top_i] += (current_top - x) * done_num;
            ans[current_top_i] -= x * pending_num;

            done_num += pending_num;

            current_top = *x;
            current_top_i = *i;
            ans[current_top_i] += x;
            pending_num = 1;
        } else {
            ans[current_top_i] += x;
            pending_num += 1;
        }
    }
    ans[current_top_i] += current_top * done_num;

    for a in &ans {
        println!("{}", a);
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


Measured memory_bytes: 5452
#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++)
const ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  ll ans=1000;
  rep(i,0,n-1){
    if(a[i]<a[i+1]){
      ans=ans+(a[i+1]-a[i])*(ans/a[i]);
    }
  }
  cout<<ans<<endl;
      
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
int main(){
    int n,d,c=0;
    double x,y;
    scanf("%i%i",&n,&d);
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&x,&y);
        if(d>=sqrt(x*x + y*y))
            c++;
    }
    printf("%i\n",c);
}

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

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

    if(op == "+"){
        cout << a + b << endl;
    }
    else if(op == "-"){
        cout << a - b << endl;
    }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAX(X,Y) ((X)<(Y) ? (Y) : (X))
#define MIN(X,Y) ((X)>(Y) ? (Y) : (X))

typedef long long int lli;

lli a[300000];
lli min[300000], max[300000];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);

    min[0] = a[0];
    max[n-1] = a[n-1];
    for(int i=1; i<n; i++) {
        min[i] = MIN(min[i-1], a[i]);
        max[n-1-i] = MAX(max[n-1-i+1], a[n-1-i]);
    }

    lli res=-0xFFFFFFFFULL;
    for(int i=1; i<n; i++)
        res = MAX(res, max[i]-min[i-1]);
    printf("%lld\n",res);

    return 0;
}

Measured memory_bytes: 7388
def slove():
    import sys
    input = sys.stdin.readline
    n, x = list(map(int, input().rstrip('\n').split()))
    l = list(map(int, input().rstrip('\n').split()))
    cnt = 1
    t = 0
    for i in range(n):
        t += l[i]
        if t <= x:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

const int N = 100005;

vi g[N];
bool vis[N];
ll dp[N][2];

pii dfs(int u,int p){
    vis[u]=1;
    dp[u][0]=dp[u][1]=1;
    for(int v:g[u]){
        if(v==p){
            continue;
        }
        pii p=dfs(v,u);
        dp[u][1]*=(p.F+p.S);
        dp[u][0]*=p.S;
        dp[u][0]%=MOD;
        dp[u][1]%=MOD;
    }
    return mp(dp[u][0],dp[u][1]);
}

int main(){
    IOS
    
    int n;
    cin>>n;
    FOR(i,0,n-1){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    pii ans=dfs(1,0);
    cout<<(ans.F+ans.S)%MOD;
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 14336