akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.IntMap as M

main :: IO ()
main = do
  (_ : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    bs = scanl step 0 $ as :: [Int]
      where
        step y x = (y + x - 1) `mod` k
  print . fst . foldl step (0, M.empty) . (zip <$> (replicate (pred k) Nothing ++) . map Just <*> id) $ bs
  where
    step (c, ts) (b', b) = (maybe id (+) (M.lookup b ts) c, maybe id (M.adjust pred) b' . M.alter (Just . maybe 1 succ) b $ ts)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n

{-#

import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    step :: (Int, [(Int, Int)]) -> Int -> (Int, [(Int, Int)])
    step (c, lrs) a = let c' = c + d in c' `seq` (c', lrs')
      where
        lrs' = (1, a `mod` k) : map f lrs :: [(Int, Int)]
        f :: (Int, Int) -> (Int, Int)
        f (l, r) = let l' = succ l; r' = (r + a) `mod` k in l' `seq` r' `seq` (l', r')
        d = length . filter (uncurry (==)) $ lrs' :: Int
  print . fst . foldl step (0, []) $ as

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n

#-}


Measured memory_bytes: 284028
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string n;
  cin >> n;
  int u=0,ans=0;
  char e=n[0];
  for(int i=0;i<n.size();i++)
  {
    if(n[i]==e)
      u++;
    else
    {
      e=n[i];
      ans=max(ans,u);
      u=1;
    }
  }
  ans=max(ans,u);
  if(ans>=3)
    printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int no_w_before = 0;
    int no_e_after = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'E') {
            no_e_after++;
        }
    }
    int min_no_change = no_e_after;
    for (int i = 1; i < n; i++) {
        //i is leader
        if (s[i] == 'E') {
            no_e_after--;
        } 
        if (s[i - 1] == 'W') {
            no_w_before++;
        }
        min_no_change = min(min_no_change, no_e_after + no_w_before);
    }
    cout << min_no_change;
}

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

using namespace std;

int32_t main() {
    int t = 1;
    // cin >> t;
    while(t--) {
        char c;
        cin >> c;
        cout << ++c << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

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

            var a = list[0];
            var b = list[1];
            var c = list[2];
            var k = list[3];

            var result = 0;

            for (var i = 0; i < k; i++)
            {
                if (a > 0)
                {
                    result++;
                    a--;
                }
                else if (b > 0)
                {
                    b--;
                }
                else if (c > 0)
                {
                    result--;
                    c--;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 28416
import java.util.Scanner;

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

		while (true)
		{
			int n = sc.nextInt();
			if (n == 0)
			{
				break;
			}

			int max = 0, min = 0;
			int sum = 0;
			for (int i = 0; i < n; i++)
			{
				int input = sc.nextInt();
				if (i == 0)
				{
					max = min = input;
				}
				else
				{
					if (input < min)
					{
						min = input;
					}
					if (input > max)
					{
						max = input;
					}
				}

				sum += input;
			}

			int ave = (int) ((sum - max - min) / (n - 2));
			System.out.println(ave);
		}
	}
}



Measured memory_bytes: 29416
require 'mathn'

class Solver
  def initialize

    loop do
      numbers = gets.chomp.split(' ').map(&:to_i)

      $answer = nil
      $list = nil

      break if numbers.all?(&:zero?)

      solver(numbers)

      unless $answer.nil?

        $answer.each do |index|
          $list[index*2..index*2+2] = "(#{$list[index*2]} #{$list[index*2+1]} #{$list[index*2+2]})"
        end

        puts $list
      else
        puts 0
      end
    end
  end

  def solver(numbers)
    operations = [:+, :-, :*]

    numbers.permutation(4) do |num_list|
      operations.repeated_permutation(3) do |opes|
        list = [ num_list[0], opes[0], num_list[1], opes[1], num_list[2], opes[2], num_list[3] ]
        index_list = []

        dfs( list, index_list )

        $list = list.dup
        return unless $answer.nil?
      end
    end
  end

  def dfs(list, index_list)

    if list.size == 3 && index_list.size == 2
      num = list[0].send(list[1], list[2])

      if num == 10
        index_list << 0

        $answer = index_list.dup
      end
    else
      0.upto(list.size/2-1) do |index|
        index_list << index
        tmp_list = list.dup
        r = tmp_list[index*2]
        o = tmp_list[index*2+1]
        t = tmp_list[index*2+2]

        tmp_list[index*2..index*2+2] = r.send(o, t)

        dfs( tmp_list, index_list )

        return index_list if index_list.size == 3
        #index_list.pop
      end
    end

    index_list.pop
  end
end

Solver.new

Measured memory_bytes: 7640
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;

    MOD = K;

    vll A(N);
    REP(i, N) {
        cin >> A[i];
    }

    vector<mint> S(N + 1);
    S[0] = 0;
    REP(i, N) S[i + 1] = S[i] + A[i];

    map<ll, int> m;
    ll ans = 0;
    REP(i, N + 1) {
        if (i - K >= 0) m[(S[i - K] - i + K).x]--;
        ans += m[(S[i] - i).x];
        m[(S[i] - i).x]++;
    }

    print(ans);

}


Measured memory_bytes: 18716
#include<iostream>
using namespace std;
int main(){
  char c[4];
  for(int i=0; i<3; i++) {
    cin>>c[i];
  }
  c[3] = '\0';
  if(!strcmp(c,"AAA")||!strcmp(c,"BBB")) {
    cout<<"No";}
  else {
    cout<<"Yes";
  }
}


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

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<functional>
#include <bitset>
#include<algorithm>
#include<fstream>
#include<string>
#include <cstring>
#include<stdio.h>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<vector>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
// never lose hope ..
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-8
using namespace std;
double const  PI = 3.141592653;
const int OO = 1000000000 + 9;

void fast() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}


int main()
{
	fast();

	int n, k;
	cin >> n >> k;
	vector<int>v(n + 1, 0), dp(n + 1, OO);
	for (int i = 1;i <= n;i++) {
		cin >> v[i];
	}
	dp[1] = 0;
	for (int i = 2;i <= n;i++) {
		for (int j = 1;j <= min(i, k);j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
		}
	}
	cout << dp[n];


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s,kib="";
    int i,j;
    cin>>s;
    rep(i,s.length())if(s[i]!='A')kib+=s[i];
    if(kib!="KIHBR"){
        fin("NO");
        return 0;
    }
    else{
        rep(i,s.length()-1)if(s[i]==s[i+1]&&s[i]=='A'){
            fin("NO");
            return 0;
        }
        rep(i,s.length()){
            if(s[i]=='K'&&s[i+1]!='I'){
                fin("NO");
                return 0;
            }
            if(s[i]=='I'&&s[i+1]!='H'){
                fin("NO");
                return 0;
            }
        }
        fin("YES");
    }
//////////////////////////////////////////////////////
return 0;}





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

using namespace std;

int main(){
  int n, k, a[200009], imos[200009], b[200009];
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    imos[max(1, i-a[i])]++;
    imos[min(n+1, i+a[i]+1)]--;
  }
  for(int j=0;j<k;j++){
    int sm = 0;
    for(int i=1;i<=n;i++){
      sm+=imos[i];
      b[i] = sm;
    }
    bool is_end=true;
    for(int i=1;i<=n;i++){
      imos[max(1, i-a[i])]--;
      imos[min(n+1, i+a[i]+1)]++;
      a[i]=b[i];
      if(a[i]!=n)is_end=false;
      imos[max(1, i-a[i])]++;
      imos[min(n+1, i+a[i]+1)]--;
    }
    if(is_end){
      for(int i=1;i<=n;i++){
        cout << n << (i==n?'\n': ' ');
      }
      return 0;
    }
  }
  for(int i=1;i<=n;i++){
    cout << a[i] << (i==n?'\n': ' ');
  }
}



Measured memory_bytes: 5964
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
  int n,a[100000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sum+=abs(a[0])+abs(a[n-1]);
  for(int i=1;i<n;i++) sum+=abs(a[i]-a[i-1]);
  cout<<sum-abs(a[0])-abs(a[1]-a[0])+abs(a[1])<<endl;
  for(int i=1;i<n-1;i++){
    cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
  }
  cout<<sum-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl;
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,i;
    char f[105],g[105],sum[300];
    cin>>a;
    getchar();
    cin>>f>>g;
    for(i=0;i<a;i++)
    {
        cout<<f[i]<<g[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    boost;
    int l,r,d;
    cin>>l>>r>>d;
    int res = r/d - l/d ;
    if(l%d == 0)res++;
    cout<<res<<endl;
    
    
}

Measured memory_bytes: 3612
#include<stdio.h>

long long int abs_1(long long int i){
	if(i<0) return -i;
	else return i;
}
int main()
{
	 int N,i,j;
	 long long int sum1=0,sum=0;
	scanf("%d",&N);
	long long int a[200000]={0},x,min=2e+9;
	for(i=0;i<N;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	for(i=0;i<N-1;i++)
	{
		sum1+=a[i];
		x=abs_1(2*sum1-sum);
		if(x<=min)
		{
			min=x;
		}
	}
	printf("%lld",min);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int flag=1,n,i,c=0,s;
	int a[100];
	scanf("%d",&n);//n?????\???
	for(i=0;i<n;i=i+1){
		scanf("%d",&a[i]);//a?????\???
	}//?????????????§?,a??????????°????????????¨???????????????????????????????????\????????????????????????????????¢???????????????????????£????????¨?????????
	//??\??????????????????????¬????2??????????°????????????¨????????????????????????????????¨?¶??????????????????????????????£???????????????
	while(flag==1){
		flag=0;
		for(i=n-1;i>=1;i=i-1){
			if(a[i]<a[i-1]){s=a[i];
				a[i]=a[i-1];
				a[i-1]=s;
				flag=1;
				c=c+1;
			}
		}
	}
	
	
	
	
	
	for(i=0;i<n;i=i+1){
		if(i!=0) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",c);
	
	return 0;
}//???????????¨???

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int x[20][20];
int main(){
	int n,d;cin>>n>>d;
	rep(i,n){
		rep(j,d)scanf("%d",&x[i][j]);
	}
	int cnt=0;
	rep(i,n){
		for(int j=i+1;j<n;j++){
			ll s=0;
			rep(k,d){
				s+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
			}
			ll d=sqrt(s);
			if(d*d==s){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>x(N);
	vector<int>y(N);
	vector<long long int>p(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> p[i];
	}
	vector<vector<long long int>>ysum(N, vector<long long int>(1 << N));
	vector<vector<long long int>>xsum(N, vector<long long int>(1 << N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 1 << N; j++) {
			ysum[i][j] = p[i] * abs(y[i]);
			xsum[i][j] = p[i] * abs(x[i]);
			for (int k = 0; k < N; k++) {
				if ((j >> k) & 1) {
					ysum[i][j] = min(ysum[i][j], p[i] * abs(y[i] - y[k]));
					xsum[i][j] = min(xsum[i][j], p[i] * abs(x[i] - x[k]));
				}
			}
		}
	}
	vector<long long int>ans(N + 1, MOD*MOD);
	for (int i = 0; i < 1 << N; i++) {
		int bit = (1 << N) -1- i;
		int cnt = bit;
		while (bit) {
			bit--;
			bit &= cnt;
			long long int sum = 0;
			for (int j = 0; j < N; j++) {
			//	cout << i << " " << j << " " << bit <<" "<< ysum[j][1] << " " << xsum[j][bit] << endl;
				sum += min(ysum[j][i], xsum[j][bit]);
			}
			int c = 0;
			int box = bit|i;
			while (box) {
				c += box & 1;
				box >>= 1;
			}
		//	cout << i << " bit " << bit << endl;
		//	cout << c << " " << sum << endl;
			ans[c] = min(ans[c], sum);
		}
	}
	ans.back() = 0;
	for (auto i : ans)cout << i << endl;
}

Measured memory_bytes: 11212
num_shops, target_drinks = map(int, input().split())
sell = {}

for _ in range(num_shops):
    a,b = map(int, input().split())

    try:
        sell[a] += b
    except:
        sell[a] = b

ans, bought = 0, 0

for price in sorted(sell):

    selling = sell[price]

    if bought + selling < target_drinks:
        ans += price * selling    
        bought += selling
    else:
        ans += price * (target_drinks - bought)
        break

print(ans)


Measured memory_bytes: 17880
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = attrs.shift[0]
A = attrs[0]

nega_count = 0
A.each {|v| nega_count += 1 if v < 0 }
nega_e = nega_count.even?
incl_0 = A.include?(0)

ary_abs = []
A.each{|v| ary_abs << v.abs}
result = 0
ary_abs.each{|v| result += v}
if incl_0 || nega_e then
  puts result
else
  puts result - ary_abs.min * 2
end

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

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

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int N;
ll arr[MX];

ll solve() {
    ll res = 0, sum = 0;
    F0R(i,N) {
        if (i&1) {
            if (sum+arr[i] >= 0) {
                res += abs(sum+arr[i]-(-1));
                sum = -1;
            } else sum += arr[i];
        } else {
            if (sum+arr[i] <= 0) {
                res += abs(sum+arr[i]-1);
                sum = 1;
            } else sum += arr[i];
        }
    }
    return res;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> N;

    F0R(i,N) cin >> arr[i];
    ll res = solve();
    F0R(i,N) arr[i] = -arr[i];
    res = min(res,solve());

    cout << res << "\n";

}


Measured memory_bytes: 1024
#include<stdio.h>

main(){
  double a, b, c;
  double d, e, f;
  int res;
  double s_x, s_y, tmp;

  while(1){
    res = scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f);

    if(res == EOF) break;

    s_x = (c * e - b * f) / (a * e - b * d);
    s_y = (a * f - d * c) / (a * e - b * d);

    if (s_x == -0.0){
      s_x = 0;
    }else if(s_y == -0.0){
      s_y = 0;
    }

    printf("%0.3f %0.3f\n", s_x, s_y);
  }

  return 0;
}

Measured memory_bytes: 652
def main():
    N, M = map(int, input().split())
    a = set(int(input()) for _ in range(M))
    dp = [0] * (N + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1

    for i in range(2, N + 1):
        for k in [-2, -1]:
            if i + k not in a:
                dp[i] += dp[i+k]
        dp[i] %= 1000000007

    print(dp[N])

main()


Measured memory_bytes: 58200
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec x(N), y(N), X(N), Y(N);
    REP(i, N){
        cin >> x[i] >> y[i];
        X[i] = x[i] + y[i];
        Y[i] = x[i] - y[i];
    }

    int mx = INF, Mx = -INF, my = INF, My = -INF;
    REP(i, N){
        chmin(mx, X[i]);
        chmax(Mx, X[i]);
        chmin(my, Y[i]);
        chmax(My, Y[i]);
    }
    int ans = max(Mx - mx, My - my);
    Out(ans);

    return 0;
}


Measured memory_bytes: 9516
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
goukei = []
for a in A:
    for b in B:
        goukei.append(a + b)
goukei.sort()
goukei2 = goukei[-k:]
goukei3 = []
for c in C:
    for ab in goukei2:
        goukei3.append(ab + c)
goukei3.sort(reverse=True)
print(*goukei3[:k], sep="\n")


Measured memory_bytes: 141764
let (p1, p2, p3) = (257, 251, 1000000007)

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let pow x n =
  let rec doit x n acc =
    if n = 0 then acc
    else if n mod 2 = 0 then doit (x * x mod p3) (n / 2) acc
    else doit (x * x mod p3) (n / 2) (acc * x mod p3) in
  doit x n 1

let make_hash v (x, y) (r, c) =
  let h1 = Array.make_matrix x y 0 in
  let c1 = pow p1 c in
  for i = 0 to x - 1 do
    let rec aux j acc =
      if j = c then acc
      else aux (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in
    let rec doit j z =
      if j = y - c then h1.(i).(j) <- z
      else begin
        h1.(i).(j) <- z;
        let z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in
        doit (j + 1) (if z < 0 then z + p3 else z)
      end in
    aux 0 0 |> doit 0;
  done;
  let h2 = Array.make_matrix x y 0 in
  let c2 = pow p2 r in
  for j = 0 to y - 1 do
    let rec aux i acc =
      if i = r then acc
      else aux (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in
    let rec doit i z =
      if i = x - r then h2.(i).(j) <- z
      else begin
        h2.(i).(j) <- z;
        let z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in
        doit (i + 1) (if z < 0 then z + p3 else z)
      end in
    aux 0 0 |> doit 0;
  done;
  h2

let solve (h, w) (r, c) a b =
  let s = make_hash a (h, w) (r, c) in
  let t = make_hash b (r, c) (r, c) in
  for i = 0 to h - r do
    for j = 0 to w -c do
      if s.(i).(j) = t.(0).(0) then Printf.printf "%d %d\n" i j;
    done
  done

let read_array x y =
  let a = Array.make_matrix x y '\000' in
  for i = 0 to x - 1 do
    let l = read_line () in
    for j = 0 to y - 1 do
      a.(i).(j) <- l.[j];
    done
  done;
  a

let () =
  match read_line () |> split_on_char ' ' |> List.map int_of_string with
  | [h; w] ->
    begin
      let a = read_array h w in
      match read_line () |> split_on_char ' ' |> List.map int_of_string with
      | [r; c] ->
        if h < r || w < c then ()
        else read_array r c |> solve (h, w) (r, c) a
      | _ -> assert false
    end
  | _ -> assert false

Measured memory_bytes: 43080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

void dfs(vvi &G,vb &seen,int v){
  if(seen.at(v)) return;
  seen.at(v) = true;
  for(int nv : G.at(v)){
    dfs(G,seen,nv);
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  rep(i,m){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  int count = 0;
  rep(i,m){
    vector<vector<int>> Graph(n);
    vector<bool> seen(n,false);
    rep(j,m){
      if(i == j) continue;
      Graph.at(a.at(j)).push_back(b.at(j));
      Graph.at(b.at(j)).push_back(a.at(j));
    }
    dfs(Graph,seen,0);
    rep(j,n){
      if(!seen.at(j)){
        //cout << j << endl;
        count++;
        break;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
n = gets.to_i
h = {}
n.times do
  s = gets
  h[s.chomp]=0
end

for m in ["S", "H", "C", "D"] do
  for i in 1..13 do
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end
end


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    
    transform(a.begin(), a.begin()+1, a.begin(), ::toupper);
    transform(b.begin(), b.begin()+1, b.begin(), ::toupper);
    transform(c.begin(), c.begin()+1, c.begin(), ::toupper);
    
    cout<<a[0]<<b[0]<<c[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, X;
int A[100];

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A+N);

    ll sum = 0;
    for (int i = 0; i < N; ++i) sum += A[i];

    if (sum == X) {
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    sum = 0;
    for (int i = 0; i < N-1; ++i) {
        if (sum + A[i] <= X) {
            ++ans;
            sum += A[i];
        } else {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string s;
int ans = -1;
 
int main(){
	
	cin >> s;
   int ln = s.size();
	for (int i = 1; i < ln; i++) 
		if(s[i] != s[i - 1]) 
			if(ans== -1)
				ans= max(ln - i, i);
			else
				ans = min(ans, max(ln - i, i));
	if(ans == -1)
		cout << ln;
	else
		cout << ans; 
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int X, Y;
    cin >> X >> Y;

    if (Y % 2 == 1) {
        cout << "No" << endl;
        return;
    }

    string ans = ((Y / 2 - X >= 0) && (Y / 2 - X <= X)) ? "Yes" : "No";
    cout << ans << endl;
}

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


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <vector>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

typedef long long ll;




int main(){

    int N,K;
    cin>>N>>K;
    double tmp;
    double s[N+1];
    double ans=0;
    s[0]=0;
    for(int i=1;i<=N;++i){
        cin>>tmp;
        s[i]=s[i-1]+(1+tmp)/2.0;
    }

    for(int i=K;i!=N+1;++i){
        ans=ans>=s[i]-s[i-K]?ans:s[i]-s[i-K];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            long b = long.Parse(a[0]);
            long c = long.Parse(a[1]);
            long d;
            if (c - b * 2 > 0)
            {
                 d = b + (long)((c - b * 2) / 4);
            }
            else
            {
                 d = c/2;
            }

            Console.Write(d);
        }
    }
}


Measured memory_bytes: 11092
S = input()
K = int(input())
S2 = S + S
ans = 0
s = S[0]
if len(set(S)) == 1:
    print(len(S) * K // 2)
else:
    for i in range(1, len(S2)):
        if s == S2[i]:
            ans += 1
            s = '1'
        else:
            s = S2[i]

    if ans % 2 == 0:
        ans = ans // 2 * K
    else:
        ans = (ans + 1) // 2 * K - 1

    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  double A,B,H,M;cin>>A>>B>>H>>M;
  double pi=3.14159265358979323846;
  double c2 =A*A+B*B-2*A*B*cos(  min(360- abs( ((60*H-11*M )*pi)/360  ),abs( ((60*H-11*M )*pi)/360  )  )  );
  double ans =sqrt(c2);
  pri(ans);
}






Measured memory_bytes: 4264
#include<iostream>
using namespace std;
const int MAX = 100;
int n, G[MAX + 1][MAX + 1] = { 0 };
int tt, d[MAX + 1], f[MAX + 1];
bool book[MAX + 1] = { false };
void dfs_visit(int u)
{
	for (int v = 1; v <= n; v++)
		if (G[u][v] && !book[v])
		{
			d[v] = ++tt;
			book[v] = true;
			dfs_visit(v);
		}
	f[u] = ++tt;
}
void dfs()
{
	for(int i=1;i<=n;i++)
		if (!book[i])
		{
			d[i] = ++tt;
			book[i] = true;
			dfs_visit(i);
		}
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int u, d;
		cin >> u >> d;
		for (int j = 1; j <= d; j++)
		{
			int v;
			cin >> v;
			G[u][v] = 1;
		}
	}
	dfs();
	for (int i = 1; i <= n; i++)
		cout << i << " " << d[i] <<" "<<f[i] << endl;
}


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

// 10進数xをn進数に変換
string conv(ll x, int n) {
    string ret = "";
    while (x > 0) {
        ret += (x%n) + '0';
        x /= n;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}


int main() {
    ll N, K;
    cin >> N >> K;

    cout << conv(N, K).size() << endl;

}


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

using namespace std;

void process_command(istream &istr, string &str);
void my_print(const string &str, int a, int b);
void my_reverse(string &str, int a, int b);
void my_replace(string &str, int a, int b, string &p);


int main(){
    string str;
    cin >> str;
    int q;
    cin >> q;
    for(int i = 0; i != q; ++i){
        process_command(cin, str);
    }
}

void process_command(istream &istr, string &str){
    string command;
    istr >> command;
    if (command == "print"){
        int a, b;
        istr >> a >> b;
        my_print(str, a, b);
    }else if (command == "reverse"){
        int a, b;
        istr >> a >> b;
        my_reverse(str, a, b);
    }else if (command == "replace"){
        int a, b;
        string p;
        istr >> a >> b >> p;
        my_replace(str, a, b, p);
    }else {
        cout << "Unexpected command encountered! " << command << endl;
    }

}
void my_print(const string &str, int a, int b){
    cout << str.substr(a, b - a + 1) << endl;
}

void my_reverse(string &str, int a, int b){
    while(a < b){
        auto tmp = str[a];
        str[a] = str[b];
        str[b] = tmp;
        ++a;
        --b;
    }
}

void my_replace(string &str, int a, int b, string &p){
    str.replace(a, b - a + 1, p);
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v[n];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    rep(i,n) cout<<v[i].size()<<endl;
    return 0;
}

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

int main() {
	ll x, y;
	cin >> x >> y;
	if (y % 2) {
		cout << "No" << endl;
		return 0;
	}
	if (2 * x <= y && y <= 4 * x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3624
n,m=gets.chomp.split(' ').map(&:to_i)
arry=[]
sum=0
n.times{arry<<gets.chomp.split(' ').map(&:to_i)}
arry.sort.each do |a|
  m,now=(m>=a[1] ? [m-a[1],a[1]] : [0,m])
  sum+=a[0]*now
end
puts sum

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	map<char, char> mp;
	mp['A'] = 'T';
	mp['T'] = 'A';
	mp['C'] = 'G';
	mp['G'] = 'C';

	char b;
	cin >> b;
	cout << mp[b] << endl;
}

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

	solve();
}


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

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

Measured memory_bytes: 3640
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll N, H;
    cin >> N >> H;
    vector<pair<ll, ll>> A;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A.push_back({a, (ll)0});
        A.push_back({b, (ll)1});
    }

    sort(all(A),
         [](pair<ll, ll> a, pair<ll, ll> b) { return a.first > b.first; });

    ll cnt = 0;
    rep(i, A.size()) {
        if (A[i].second == 1)
            H -= A[i].first, cnt++;
        else {
            if (H % A[i].first == 0) {
                cnt += (H / A[i].first);
            } else {
                cnt += (H / A[i].first) + 1;
            }
            break;
        }
        if (H <= 0)
            break;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 6512
from collections import Counter
N = int( input())
A = list( map( int, input().split()))
CA = Counter(A)
V = []
for x in CA:
    if CA[x] >= 2:
        V.append(CA[x]-1)
V.sort(key = None, reverse = True)
now = 0
ans = 0
for v in V:
    ans += v
    if now <= 0:
        now += v
    else:
        now -= v
b = abs(now)
if b%2 == 1:
    ans += 1
print( N-ans)

Measured memory_bytes: 18656
#include <iostream>

int main(void)
{
    int N=0;
    int th=0;
    std::cin >> N >> th;    
    int nn=0;
    for(int i = 0; i<N; i++)
    {
      int h=0;
       std::cin>>h;
       if (h>=th)
       {
         nn++;
       }
    }
    std::cout << nn;
}

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

inline long long gcd(long long a, long long b) {
	if (a < b) {
		swap(a, b);
	}
	if (a % b == 0) {
		return b;
	}
	return gcd(b, a % b);
}

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

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

	long long res = 1;
	for (int i = 0; i < n; ++i) {
		long long t;
		cin >> t;
		res = lcm(res, t);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;

int p[maxn];
bool isnotprime[maxn];
int cnt;

int count(int x, int p)
{
	return x == 0 ? 0 : count(x / p, p) + x / p;
}

int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 2; i <= N; ++i)
	{
		if (!isnotprime[i])
			p[cnt++] = i;
		for (int j = 0; j < cnt && i * p[j] <= N; ++j)
		{
			isnotprime[i * p[j]] = true;
			if (i % p[j] == 0)
				break;
		}
	}
	int ans = 1;
	for (int i = 0; i < cnt; ++i)
		ans = 1ll * ans * (count(N, p[i]) + 1) % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int a;
	int maxs = 0;
	for (int i = 0; i < n; i++){
		a = 0;
		for (int k = 0; k < m; k++) {
			int b;
			cin >> b;
			a += b;
		}
		maxs = max(maxs, a);
	}
	cout << maxs << endl;
	char c;
	cin >> c;
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int64_t k;
	std::cin >> k;
	k--;
	k *= 2;
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);
	int64_t l = -1000000000000000001, r = 1000000000000000001;
	while (r - l > 1) {
		int64_t m = l + (r - l) / 2;
		int64_t cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) cnt += std::lower_bound(a, a + n, a[i], [&] (int i, int j) { return (int64_t) i * j <= m; }) - a;
			else if (a[i] < 0) cnt += a + n - std::lower_bound(a, a + n, a[i], [&] (int i, int j) { return (int64_t) i * j > m; });
			else cnt += m >= 0 ? n : 0;
			if ((int64_t) a[i] * a[i] <= m) cnt--;
		}
		std::cerr << m << ":" << cnt << std::endl;
		if (cnt <= k) l = m;
		else r = m;
	}
	printf("%lld\n", (long long) r);
	return 0;
}


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

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(((0<=x-r)&&(x+r<=W))&&((0<=y-r)&&(y+r<=H)))
    printf("Yes\n");
  else
    printf("No\n");
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define buff ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define xy pair<int, int>
#define x first
#define y second 

#define inf std::numeric_limits<int>().max()

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


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

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

const int mod = 1000000007;
struct mint {
  ll x;  // typeINF long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(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 k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
  mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} c(1000005);

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i, a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {
  ll n, ans = 0;
  cin >> n;

  if (n < 3) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 3) {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 1; n - 2 * i - 1 > 0; ++i) {
    (ans += c(n - 2 * i - 1, i - 1).x) %= mod;
  }

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

Measured memory_bytes: 18604
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  q,h,s,d=pM(split(readline()))
  n=pI(readline())
  one=min(4q,2h,s)
  println(fld(n,2)*min(2one,d)+n%2*one)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 165144