akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n, l;

int main(){
  cin >> n >> l;
  int s = n*l + n * (n - 1)/2;
  int taste_diff = INF;
  int num = 0;
  for(int i = 0; i < n; i++){
    if(taste_diff > abs(0 - i - l)){
      taste_diff = abs(i + l);
      num = i;
    }
  }
  cout << s - num - l <<endl;
}

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

int main(){
  int N;
  cin >> N;
  map<string,int> A;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(A.count(S)){
      A[S]++;
    }
    else{
      A[S]=1;
    }
  }
  cout << "AC x " << A["AC"] << endl;
  cout << "WA x " << A["WA"] << endl;
  cout << "TLE x " << A["TLE"] << endl;
  cout << "RE x " << A["RE"] << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  sort(A.begin(),A.end());
  int ai = A.back();
  A.pop_back();
  sort(A.begin(),A.end(),[&](int a,int b){
      return max(a ,(ai-a)) < max(b , (ai-b));
    });
    
  cout<<ai<<" "<<A[0]<<endl;
  return 0;
}


Measured memory_bytes: 1024
import Data.Array

main = do
  n <- readLn
  cs <- getLine
  let ar = listArray (1, n) cs
  print $ f 1 n ar 0

f l r ar i
  | r <= l = i
  | ar ! l == 'R' = f (l + 1) r ar i
  | ar ! r == 'W' = f l (r -1) ar i
  | otherwise = f (l + 1) (r -1) ar (i + 1)


Measured memory_bytes: 15244
#include <iostream>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3])cout << "No" << endl;
  else if((s[0] == s[1] && s[2] == s[3])||(s[0] == s[2] && s[1] == s[3])||(s[0] == s[3] && s[1] == s[2]))cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

int main(){
  while(true)
  {
    double x, h;
    cin >> x >> h;
    if(!x && ! h)
      break;
    double hh =	sqrt(h * h + (x / 2) * (x / 2));
    printf("%lf\n", x * x +  x * hh / 2.0 * 4.0);
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define setbits(x)  __builtin_popcountll(x)
#define mod 1000000007
#define v(n) vector<int> v(n)
#define w(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define f(i,j,n) for(int i=j;i<=n;i++)
#define  FAST ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
void c_p_c(){
    ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
}
int main(){
    c_p_c();int t=0;
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[1]=='S')
     cout<<"0";
    else
    {f(i,0,1)
      if(s[i]==s[i+1]&&s[i]=='R')
        t++;
    cout<<t+1;}
}   
    
    
     

     
   









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

// Prerequisite:
// $ sudo apt-get install libboost-all-dev
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using bigint = boost::multiprecision::cpp_int;
using decfloat = boost::multiprecision::cpp_dec_float_50;

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(ll, n);
  if (n % 2) {
    wt(0);
  } else {
    ll ans = 0;
    ll fives = 1;
    while (bigint(fives) * 5 <= n) {
      fives *= 5;
      ans += n / fives / 2;
    }
    wt(ans);
  }
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int Q = in.nextInt();

            int[] L = new int[M];
            int[] R = new int[M];
            int[][] count = new int[N][N];
            for (int i = 0; i < M; i++) {
                L[i] = in.nextInt() - 1;
                R[i] = in.nextInt() - 1;
                count[L[i]][R[i]]++;
            }

            TwoDimensionalCumulativeSum cumsum = new TwoDimensionalCumulativeSum(count);

            int[] p = new int[Q];
            int[] q = new int[Q];
            for (int i = 0; i < Q; i++) {
                p[i] = in.nextInt() - 1;
                q[i] = in.nextInt() - 1;
                System.out.println(cumsum.cumulativeSum(p[i], p[i], q[i] + 1, q[i] + 1));
            }

        }
    }

}

class TwoDimensionalCumulativeSum {
    private int[][] sum;

    public TwoDimensionalCumulativeSum(int[][] values) {
        int R = values.length;
        int C = values[0].length;
        sum = new int[R + 1][C + 1];
        for (int r = 0; r < R; r++) {
            for (int c = 0; c < C; c++) {
                sum[r + 1][c + 1] = sum[r + 1][c] + sum[r][c + 1] - sum[r][c] + values[r][c];
            }
        }
    }

    public int cumulativeSum(int startRInclusive, int startCInclusive, int endRExclusive, int endCExclusive) {
        return sum[startRInclusive][startCInclusive] - sum[endRExclusive][startCInclusive] - sum[startRInclusive][endCExclusive] + sum[endRExclusive][endCExclusive];
    }
}


Measured memory_bytes: 156668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <functional>
#include <stack>
#include <fstream>
#include <bitset>

using namespace std;

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

const int N = 3e3 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

const vector<int> dx = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
const vector<int> dy = { -1, -1, 0, 1, 1, 1, 0, -1, -1 };

int gcd(int a, int b) {
	return (b ? gcd(b, a % b) : a);
}

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

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	forn(i, n)
		cin >> a[i];

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

	if (a.back() < k) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int g = a[0];
	for (int i = 1; i < n; ++i)
		g = gcd(g, a[i]);

	if (k % g == 0)
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
	cout << endl;
}

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

using namespace std;
#define ll  long long
#define ld long double

int main()
{
 // freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
ll n;
ll a[100005]={0};
    cin>>n;
    for(ll i =1;i<=n;i++) {
        cin>>a[i];
    }
ll dp[100005]={0};
dp[1] = 0;
dp[2] = abs(a[2]-a[1]);
for(ll i =3;i<=n;i++) {
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
}
cout<<dp[n];

}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    const i64 mod = 998244353;
    i64 n, s;
    cin >> n >> s;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    vector<i64> f(s + 1);
    f[0] = 1;
    i64 ans = 0;
    for (i64 k : a) {
        vector<i64> g = f;
        for (i64 i = 0; i <= s - k; ++i) {
            (g[i + k] += f[i]) %= mod;
        }
        (g[0] += 1) %= mod;
        f = g;
        ans += f[s];
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int ans=0;
	
	int p,q,r;
	cin >> p >> q >> r;
	ans = p+q+r-max({p,q,r});
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
i = gets.to_i

cards = {}

[:S, :H, :C, :D].each do |s|
  cards[s] = {}
  1.upto(13).each{ |i| cards[s][i] = 0 }
end

i.times do
  s, n = gets.chomp.split
  cards[s.to_sym][n.to_i] = 1
end

[:S, :H, :C, :D].each do |s|
  cards[s].select! { |_s, _n| _n.zero? }
  cards[s].each_key { |k| puts "#{s} #{k}"}
end

Measured memory_bytes: 6872
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b = map(int, input().split())
    if a <= 5:
        print(0)
    elif 6 <= a and a <= 12:
        print(b//2)
    else:
        print(b)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, K; cin >> A >> B >> C >> K;
  int ans = 0;
  if(K <= A) ans = K;
  else if(K <= A + B) ans = A;
  else ans = A - (K - A - B);
  cout << ans;
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

bool can_cons[2001];

int main() {
  ios_base::sync_with_stdio(false);
  int N, Q;
  cin >> N;
  fill (can_cons, can_cons + 2001, false);
  can_cons[0] = true;
  REP(i, N) {
    int a;
    cin >> a;
    for (int j = 2000; j >= 0; j--) {
      if (can_cons[j] && j + a <= 2000) {
	can_cons[j+a] = true;
      }
    }
  }

  cin >> Q;
  REP(i, Q) {
    int m;
    cin >> m;
    cout << (can_cons[m] ? "yes" : "no") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, D, X; cin >> N >> D >> X;
	ll A[100];
	rep(i, 0, N)cin >> A[i];
	ll C = 0;
	rep(i, 0, N) {
		ll d = 1;
		while (d <= D) {
			C++;
			d = d + A[i];
		}
	}

	cout << C + X << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
int main(void){
    int n;
    cin>>n;
    map<int,int>mp[2];
    rep(i,n){
        int v;
        cin>>v;
        mp[i%2][v]++;
    }
    int a0=-1,a1=-1,b0=-1,b1=-1;
    for(auto c:mp[0]){
        if(c.second>mp[0][a0]){
            a1=a0;
            a0=c.first;
        }else if(c.second>mp[0][a1]){
            a1=c.first;
        }
    }
    for(auto c:mp[1]){
        if(c.second>mp[1][b0]){
            b1=b0;
            b0=c.first;
        }else if(c.second>mp[1][b1]){
            b1=c.first;
        }
    }
    int ans = a0!=b0? (n-mp[0][a0]-mp[1][b0]) : min(n-mp[0][a0]-mp[1][b1], n-mp[0][a1]-mp[1][b0]);
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin >> str;
	int s = 0, e = 0;
	for(int i = 0; i < str.length(); i++) {
		if(str[i] == 'A') {
			s = i;
			break;
		}
	}
	for(int i = str.length(); 0 < i; i--) {
		if(str[i] == 'Z') {
			e = i;
			break;
		}
	}


	cout << e - s + 1 << endl;
	return 0;
}

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

int main() {
    double n,a,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=1/a;
    }
    ans=1/ans;
    cout<<fixed<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        //「そのターンのときにそこにいた人は確実に死ぬ」を伝播させていきたい

        //最終ターンからいくらか経った後に
        var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        char[] s = Console.ReadLine().ToArray();
        string[] q = Enumerable.Repeat(0, nq[1]).Select(_ => Console.ReadLine()).ToArray();
        int deadLower = -1;
        int deadUpper = nq[0];
        //死ぬ場所の上限下限をもつ
        for (int i = q.Length - 1; i >= 0; i--)
        {
            var query = q[i];
            if (query[2] == 'L')
            {
                if (deadLower + 1 < s.Length && s[deadLower + 1] == query[0]) deadLower++;
                //今そこいても死なないよ!っていうところを作る
                if (0 <= deadUpper && deadUpper < s.Length && s[deadUpper] == query[0]) deadUpper++;
            }
            else
            {
                if (0 <= deadUpper - 1 && s[deadUpper - 1] == query[0]) deadUpper--;
                //そこは安全になったよーってね
                if (0 <= deadLower && deadLower < s.Length && s[deadLower] == query[0]) deadLower--;
            }
        }
        Console.WriteLine(Max(0, deadUpper - deadLower - 1));
    }
}


Measured memory_bytes: 30684
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))

s = sorted(s)
sum_point = sum(s)

s = list(filter(lambda x: x % 10 != 0, s))


if sum_point % 10 != 0:
    ans = sum_point
else:
    if len(s) == 0:
        ans = 0
    else:
        ans = sum_point - s[0]
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  if(S.size() < 4)cout << "No" << endl;
  else{
    if(S.substr(0, 4) == "YAKI")cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
Stat=input().split()
B=input().split()
ans=0
for i in range(int(Stat[0])):
    A = []
    A=input().split()
    S=0
    for j in range(int(Stat[1])):
        S=S+int(A[j])*int(B[j])
    if S+int(Stat[2]) > 0:
        ans=ans+1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int dp[21][101][101];
int b[100000];
int main() {
    int n, m, c, s, g;
    while(cin >> n >> m >> c >> s >> g, n){
        s--; g--;
        for (int i = 0; i < c; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    dp[i][j][k] = INF<int>;
                }
                dp[i][j][j] = 0;
            }
        }
        for (int i = 0; i < m; ++i) {
            int x, y, d, k;
            cin >> x >> y >> d >> k;
            x--; y--; k--;
            dp[k][x][y] = min(dp[k][x][y], d);
            dp[k][y][x] = min(dp[k][y][x], d) ;
        }
        for (int x = 0; x < c; ++x) {
            for (int k = 0; k < n; ++k) {
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        dp[x][i][j] = min(dp[x][i][j], dp[x][i][k]+dp[x][k][j]);
                    }
                }
            }
        }
        vector<int> p(c);
        for (auto &&l : p) scanf("%d", &l);

        for (int i = 0; i < c; ++i) {
            vector<int> q(p[i], MOD), r(p[i], 0);
            for (int j = 0; j < p[i]-1; ++j) cin >> q[j];
            for (int j = 0; j < p[i]; ++j) cin >> r[j];
            int cur = 0;
            b[0] = 0;
            for (int j = 1; j < 100000; ++j) {
                if(q[cur] < j) cur++;
                b[j] = b[j-1] + r[cur];
            }
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    if(dp[i][j][k] != INF<int>) dp[i][j][k] = b[dp[i][j][k]];
                }
            }
        }
        for (int i = 1; i < c; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    dp[0][j][k] = min(dp[0][j][k], dp[i][j][k]);
                }
            }
        }
        for (int k = 0; k < n; ++k) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    dp[0][i][j] = min(dp[0][i][j], dp[0][i][k]+dp[0][k][j]);
                }
            }
        }
        if(dp[0][s][g] == INF<int>){
            puts("-1");
        }else {
            cout << dp[0][s][g] << "\n";
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string S;
    int Q;
    cin >> S >> Q;

    bool isRev = false;
    string l = "", r = "";

    REP(i, Q) {
        int t;
        cin >> t;
        if(t == 1) {
            isRev = !isRev;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if(isRev) {
                if(f == 1) { r += c; }
                else { l += c; }
            }
            else {
                if(f == 1) { l += c; }
                else { r += c; }
            }
        }
    }

    string ans;
    if(isRev) {
        reverse(r.begin(), r.end());
        reverse(S.begin(), S.end());
        ans = r + S + l;
    }
    else {
        reverse(l.begin(), l.end());
        ans = l + S + r;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1300
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n;
    
    cin >> n;
    
    int a[n];
    rep(i,0,n) cin >> a[i];
    
    int q,b,e,k;
    cin >> q;
    
    rep(i,0,q){
        cin >> b >> e >> k;
        cout << count(a+b,a+e,k) << endl;
    }
    
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    int a[2][100];
    int i, j;
    for(i = 0; i < 2; i++){
        for(j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    
    for(j = 1; j < n; j++){
        a[0][j] += a[0][j - 1];
    }
    for(j = n - 2; j >= 0; j--){
        a[1][j] += a[1][j + 1];
    }
    
    int max = 0;
    for(j = 0; j < n; j++){
        if(a[0][j] + a[1][j] > max){
            max = a[0][j] + a[1][j];
        }
    }
    
    cout << max << endl;
    
    return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const ll MOD = 1e9 + 7;
const int MAX = 5000010;
int lastInc[MAX] = {};

int cnt[100010] = {}, cnt1[100010] = {};

main()
{
    double a, b, t;
    cin >> a >> b >> t;
    t += .5;

    cout << int(t / a) * b << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()

	ans := 0
	if n == 1 {
		ans = 0
	} else {
		ans = (n-1)*n/2
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

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


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


int main() {
int n;
cin >> n;
vector<int> b(n-1);
rep(i,n-1) cin >> b[i];
ll ans = 0;
rep(i,n) {
  if (i == 0) ans += b[i];
  else if (i == n-1) ans += b[i-1];
  else ans += min(b[i],b[i-1]);
}
cout << ans << endl;
return 0;
}



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


def solve(K: int, X: int):
    left = X-K+1
    right = X+K-1
    print(" ".join(map(str, range(left, right+1))))
    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()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#define pri(a) cout << a << endl;
using namespace std;
typedef int64_t Int;
typedef uint64_t uInt;
const double pi = M_PI;

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

    if (a + b > 2 * c) {
        if (x < y) {
            if (b < 2 * c) {
                pri(b * (y - x) + 2 * c * x);
            } else {
                pri(2 * c * y);
            }
        } else if (x > y) {
            if (a < 2 * c) {
                pri(a * (x - y) + 2 * c * y);
            } else {
                pri(2 * c * x);
            }
        } else {
            pri(2 * c * x);
        }

    } else {
        pri(a * x + b * y);
    }
}


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

int main() {
  int n, m, q;
  cin >> n >> m >> q;

  vector<vector<int>> v(n + 1, vector<int>(n + 1));
  for (int i = 0; i < m; ++i) {
    int li, ri;
    cin >> li >> ri;
    v[li][ri] += 1;
  }

  for (int i = 0; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      v[i][j] += v[i][j - 1];
    }
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      v[i][j] += v[i - 1][j];
    }
  }

  for (int i = 0; i < q; ++i) {
    int pi, qi;
    cin >> pi >> qi;

    int ans = v[qi][qi] - v[qi][pi - 1] - v[pi - 1][qi] + v[pi - 1][pi - 1];
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

int main(){

  int h,w,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(15);
  cout << (double)w*h/2 << " ";
  if(x == (double)w/2 && y == (double)h/2)cout << 1 << endl;
  else cout << 0 << endl;
  


  return 0;
}


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

#define vi vector<int>
#define ll long long int

int main() {

  ll N;
  cin >> N;

  ll sum = 0;
  for (ll i = 1; i<sqrt(N); i++) {
    if (N%i == 0 && N/i != i+1) sum += (N/i - 1);
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> v(N, 0);
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
    }
    for(int i=0;i<N;i++){
        if(v[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	string s;
	cin >> s;
	bool f = false;
	rep(i,2) if(s[i] == s[i + 1] && s[i + 1] == s[i + 2]) f = true;
	cout << (f ? "Yes" : "No") << endl;
}


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

int main(void) {
	int n;
	cin >> n;
	int a[2][n];
	for(int i=0;i<n;i++) cin >> a[0][i];
	for(int i=0;i<n;i++) cin >> a[1][i];

	int ans = -1, sum;
	for(int i=0;i<n;i++) {
		sum = 0;
		for(int j=0;j<=i;j++) {
			sum += a[0][j];
		}
		for(int j=i;j<n;j++) {
			sum += a[1][j];
		}

		ans = max(ans, sum);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>

int main(void){
	
	char num[1001];
	
	while(1) {
		scanf("%s", num);
		int sum = 0; 
		
		if(num[0] != '0'){
			int i = 0;
			while(num[i]){
				sum += num[i] - '0';
				i++;
			}
			printf("%d\n", sum);
		}
		else break;
	}
	
	return 0;
}

Measured memory_bytes: 964
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n , x , y;
int c[N] , w[N];
int m[N];
int parent[N];
int sizes[N];
int mn1 , mn2;
int ans;
map < int , int > mp[N];
int fact[N];
int ifact[N];
int find(int node){
	if(parent[node] == node){
		return node;
	}
	return parent[node] = find(parent[node]);
}
void join(int x , int y){
	int a = find(x);
	int b = find(y);
	if(a != b){
		if(sizes[a] < sizes[b]){
			swap(a , b);
		}
		sizes[a] += sizes[b];
		parent[b] = a;
	}
}
int main(){
	scanf("%d %d %d" , &n , &x , &y);
	for(int i = 1 ; i <= n ; ++i){
		parent[i] = i;
		sizes[i] = 1;
	}
	fact[0] = 1;
	for(int i = 1 ; i < N ; ++i){
		fact[i] = (1LL * fact[i - 1] * i) % mod;
	}
	ifact[N - 1] = 787600812;
	for(int i = N - 2 ; i >= 0 ; --i){
		ifact[i] = (1LL * ifact[i + 1] * (i + 1LL)) % mod;
	}
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d %d" , c + i , w + i);
		m[c[i]] = i;
	}
	for(int i = 1 ; i <= n ; ++i){
		if(w[i] < w[m[c[i]]]){
			m[c[i]] = i;
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		if(w[i] + w[m[c[i]]] <= x){
			join(i , m[c[i]]);
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		if(m[i]){
			if(!mn1){
				mn1 = m[i];
			}
			else if(w[m[i]] < w[mn1]){
				mn2 = mn1;
				mn1 = m[i];
			}
			else if(!mn2){
				mn2 = m[i];
			}
			else if(w[m[i]] < w[mn2]){
				mn2 = m[i];
			}
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		if(w[i] + w[mn1] <= y && c[i] != c[mn1]){
			join(i , mn1);
		}
		if(mn2 && w[i] + w[mn2] <= y && c[i] != c[mn2]){
			join(i , mn2);
		}
	}
	ans = 1;
	for(int i = 1 ; i <= n ; ++i){
		++mp[find(i)][c[i]];
	}
	for(int i = 1 ; i <= n ; ++i){
		if(find(i) == i){
			ans = (1LL * ans * fact[sizes[i]]) % mod;
			for(auto it : mp[i]){
				ans = (1LL * ans * ifact[it.second]) % mod;
			}
		}
	}
	printf("%d\n" , ans);
}

Measured memory_bytes: 24448
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int a, b;
	char op;
	while(scanf("%d %c %d", &a, &op, &b) > 0) {
		switch(op){
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", (int)(a / b));
				break;
			case '?':
				return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define int long long
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=1e5+5;
int n,a[N],sum=0;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	fw (i,0,n) cin>>a[i],sum+=a[i];
	int tmp=n*(n+1)/2;
	if (sum%tmp!=0) {cout<<"NO"; return 0;}
	int temp=sum/tmp;
	bool good=true;
	fw (i,0,n) {
		int j=i+1; if (j>=n) j-=n;
		int val=a[j]-a[i]-temp;
		if (val>0||val%n!=0) good=false;
	}
	if (good) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    char[] s = scanner.next()
        .toCharArray();

    for (int i = 0; i < s.length; i++) {
      s[i] += n;
      if(s[i] > 'Z') {
        s[i] = (char) ('A' + s[i] - 'Z' - 1);
      }
    }
    System.out.println(String.valueOf(s));
  }

}


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

int main(){
    long long n,k;
    cin >> n >> k;
    if(k == 0) {
        cout << n*n << endl;
        return 0;
    }
    long long ans = 0;
    for(int i=k+1; i<=n; i++){
        ans += n/i * (i-k);
        if(n%i >= k) ans += n%i - k + 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
    for(;;){
        int x,y;

        cin >> x >> y;
        if(x > y){
            swap(x,y);
        }
        else if(x <= y){
            if((x == 0) && (y == 0)){
                break;
            }
        }
        cout << x << " " << y << endl;
    }
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
ll MOD=1e9+7;
ll MAX=1e17;

int counter[200000];

int main(){
	fast_io;
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if(a[i]){
			counter[a[i]]++;
			counter[a[i]-1]++;
			counter[a[i]+1]++;
		}
		else {
			counter[0]++;
			counter[1]++;
		}
	}
	int ans=-1;
	for (int i = 0; i < 150000; ++i)
	{
		ans=max(ans,counter[i]);
	}
	show(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
inline char ask(lint x){
	printf("? %lld\n",x);
	fflush(stdout);
	char c;
	while(!isalpha(c=getchar()));
	return c;
}
inline bool ispow10(int x){
	for(lint i=1;i<=x;i*=10){
		if(x==i)return true;
	}
	return false;
}
int main(){
	int num=1;
	for(;;num*=10){
		if(num==1000000000)break;
		int l=num,r=num+9;
		while(l<r){
			int m=(l+r)>>1;
			if(ask(m*1000000000ll+999999999)=='Y'){
				r=m;
			}else{
				l=m+1;
			}
		}
		num=l;
		//for(;ask(num*1000000000ll+999999999)=='N';num++,assert(num%10));
		if(ispow10(num+1)){
			if(ask(num*10ll-1)=='N')break;
		}else if(ask(num+1)=='Y')break;
	}
	printf("! %d\n",num);
	fflush(stdout);
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<" "<<"\n";
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int base = 1150; 
const int money = 4280; 

int main() {
	
	int n;
	
	while(cin >> n && n != -1) {
		
		int sum = 0;
		
		if(n <= 10)
			sum = base;
		
		else if(n > 10 && n <= 20)
			sum = sum + (n-10) * 125 + base;
			
		else if( n <= 30)
			sum = sum + 10 * 125 + (n-20) * 140 + base;
		
		else if( n > 30)
			sum = sum + 10 * 125 + 10 * 140 + (n-30) * 160 + base;
			
		cout << money - sum << "\n";
	}


	return 0;
}




Measured memory_bytes: 2980
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> vec(N);//a_i
  rep(i,N) cin >> vec.at(i);

  int count = 0;
  int a = 0;
  while (true){
    count++;
    a = vec.at(a) - 1;
    if (a == 1) break;
    if (count > N){
      count = -1;
      break;
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 3760
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e5+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
vvi adj(maxn);
vb vis(maxn);
vi indegree(maxn);
vi ans(maxn);
void dfs(ll v){
    vis[v]=true;
    for(auto u:adj[v]){
        ans[u]=max(ans[u],ans[v]+1);
        --indegree[u];
        if(indegree[u]==0)dfs(u);
    }
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    fio;
    ll n,m;
    cin>>n>>m;
    fr(i,1,m){
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        ++indegree[y];
    }
    fr(i,1,n){
        if(!vis[i] and indegree[i]==0)dfs(i);
    }
    ll x=*max_element(ans.begin(),ans.end());
    cout<<x;
    return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int a[3],n,i,sum=0;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&n);
  qsort(a,3,sizeof(int),cmp);
  sum += a[0];
  sum += a[1];
  for(i=0;i<n;i++){
    a[2] = a[2]*2;
  }
  sum += a[2];
  
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 10000000007
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    ll I = 1000000007;
    ll a=-1,b=INF,ai=-1,bi=INF;
    for(int i = 0; i < n; i++) {
        ll x,y;cin >> x >> y;
        ll p=x+y;
        a=max(a,p);
        b=min(b,p);
        
        ll q=I-x +y;
        ai=max(ai,q);
        bi=min(bi,q);
    }

    cout << max(a-b,ai-bi) << endl;

    return 0;
}

Measured memory_bytes: 3628
puts case gets.to_i
when 400..599
  8
when 600..799 
  7
when 800..999 
  6
when 1000..1199 
  5
when 1200..1399 
  4
when 1400..1599 
  3
when 1600..1799 
  2
when 1800..1999 
  1
end


Measured memory_bytes: 14380
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = a + b;
		
		if( ans >= 24) {
			ans -= 24;
		}
		
		System.out.println(ans);
}
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>


void print_winner(int i)
{
	if (i == 1)
		printf("First\n");
	else
		printf("Second\n");
	return;
}
int main(void)
{
	int n, k;
	scanf("%d %d",&n, &k);

	int *a;
	a = (int *)malloc(sizeof(int)*(n+1));

	int *dp;
	dp = (int *)malloc(sizeof(int*)*(k+1));
	int i = 0;
	int j = 0;
	while (i < n)
	{
		//dp[i] = (int *)malloc(sizeof(int)*(k+1));
		scanf("%d",&(a[i]));
		i++;
	}
	i = 0;
	j = 0;

	//dp[0][0]=0;
	i = 0;
	j = 0;
	while (i <= k)
	{
		dp[i] = 0;
		j = 0;
		while (j < n)
		{
			if (i-a[j] == 0)
			{
				dp[i] = 1;
				break;
			}
			else if(i-a[j] > 0 && dp[i-a[j]] == 0)
			{
				dp[i] = 1;
				break;
			}
			j++;
		}
		i++;
	}
	print_winner(dp[k]);
	return (0);
}


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

int main(){
  int n;
  int p=0;
  int w=0;
  int g=0;
  int y=0;
  cin >> n;
  char pack[n];
  for(int i=0;i<n;i++){
    cin >> pack[i];
    if(pack[i]=='P') p++;
    else if(pack[i]=='W') w++;
    else if(pack[i]=='G') g++;
    else if(pack[i]=='Y') y++;
  }
  if(p>0&&w>0&&g>0&&y>0) cout << "Four" << endl;
  else cout << "Three" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

const int INF = 10000000;

using namespace std;

class NODE{
	public:
		int cost, dst;
		NODE(){}
		NODE(int dst, int cost):dst(dst),cost(cost){}
		bool operator< (const NODE& node)const{ return cost > node.cost;}
};

typedef vector<NODE> Nodes;
typedef vector<Nodes> Graph;

int dks(const Graph& g, int start, int fin)
{
	vector<int> dist(g.size(), INF);
	
	priority_queue<NODE> Q;
	Q.push(NODE(start,0));
	
	while(!Q.empty()){
		NODE e = Q.top();
		Q.pop();
 		if(dist[e.dst] != INF){
			continue;
		}
		dist[e.dst] = e.cost;
		
		if(e.dst == fin){
			return dist[e.dst];
		}
		
		for(int i = 0; i < g[e.dst].size(); i++){
			int pw = e.cost + g[e.dst][i].cost;
			Q.push(NODE(g[e.dst][i].dst,pw));
		}
	}
	
	return INF;
}

int main()
{
	for(;;){
		int n, k;
		int a, b, c, d;
		int temp;
		
		cin >> n;
		cin >> k;
		if(n == 0 && k == 0){
			break;
		}
		
		priority_queue<NODE> Q;
		
		Graph graph(n+1);
		for(int i = 0; i < k; i++){
			cin >> a;
			if(a == 0){
				//q©çÌ¶\
				//bÍn_AcÍI_ð\·
				cin >> b;
				cin >> c;
				temp = dks(graph, b,c);
				if(temp == INF){
					cout << -1 << endl;
				}
				else{
					cout << temp << endl;
				}
			}
			else{
				//D^sîñ
				//bÆcªRXgdÅÂÈªÁÄ¢é±Æð\·
				cin >> b;
				cin >> c;
				cin >> d;
				
				//^sîñÌvectorÉîñðÇÁ
				
				graph[b].push_back(NODE(c, d));
				graph[c].push_back(NODE(b, d));
			}
		}
		
	}
	return 0;
}

/*

0:(1,5)(2,4)(3,2)
1:(0,5)(2,2)(5,6)
2:(0,4)(1,2)(3,3)(4,2)
3:(0,2)(2,3)(4,6)
4:(3,6)(2,2)(5,4)
5:(1,6)(4,4)

*/

Measured memory_bytes: 964
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math


def f(a, b):
    return max(len(str(a)), len(str(b)))


n = int(input())
r, cur = math.floor(math.sqrt(n)), 999999

for i in range(1, r + 1):
    if n % i != 0: continue

    ret = f(i, int(n / i))
    if ret < cur:
        cur = ret

print(cur)


Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>(N);
        for (int i=0; i < N; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list,Comparator.reverseOrder());
        int size = INF;
        int ans = 0;
        for(int i = 0;i<N;i++){
            int num = list.get(i);
            if(size>num)ans++;
            size = num;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
	int x=0,max=0;
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
	if(s[i]=='I'){
	x++;
}
	else{

	x--;
}
	if(max<x){
		max=x;
	}
	}

	cout<<max;
	
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::string str;
	std::cin >> N;
	std::cin >> str;
	int count = 0;
	for (auto i : boost::irange(0, N - 2))
	{
		if (str.substr(i, 3) == "ABC")
		{
			++count;
		}
	}
	std::cout << count << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = 10, m = 3;
    int alt[] = new int[n];
    for (int i = 0; i < n; i++) {
      alt[i] = sc.nextInt();
    }
    Arrays.sort(alt);
    for (int i = 0; i < m; i++) {
      System.out.println(alt[n-i-1]);
    }
  }
}

Measured memory_bytes: 12000
using System;

namespace ABC105_A_AtCoder_Crackers
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] instr = Console.ReadLine().Split(' ');
			int n = int.Parse(instr[0]);
			int k = int.Parse(instr[1]);

			int amari = n % k;

			if (amari != 0)
			{
				Console.WriteLine(1);
			}
			else
			{
				Console.WriteLine(0);
			}
		}
	}
}

Measured memory_bytes: 13140
import itertools
from math import sqrt,factorial
n=int(input())
x=[]
y=[]
for i in range(n):
    xi,yi=map(int,input().split())
    x.append(xi)
    y.append(yi)
lis = [x for x in range(n)] # 0からn-1までのリスト
ans=0
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成
# 以下出力
for one_case in permutations_lis: 
  for i in range(n-1):
      xi=x[one_case[i]]
      yi=y[one_case[i]]
      xj=x[one_case[i+1]]
      yj=y[one_case[i+1]]
      ans+=sqrt((xi-xj)**2+(yi-yj)**2)
ans=ans/factorial(n)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  char c;
  cin >> c;
  if(isupper(c)){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int l1=s1.length();
    int l2=s2.length();
    int dp[l1+1][l2+1];
    for(int i=0;i<=l1;i++)
    {
        for(int j=0;j<=l2;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(s1[i-1]==s2[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[l1][l2]<<"\n";
    string ans="";
    int i=l1,j=l2;
    while(i>0 && j>0)
    {
        if(s1[i-1]==s2[j-1])
        {
            ans=s1[i-1]+ans;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 35456