akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cassert>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <string>
#include <cstring>
#include <cmath>

#define forn(x, a)             for (int x = 0; x < a; x++)
#define fore(x, a, b, c)       for (int x = a; x <= b; x += c)
#define forr(x, a)             for (int x = a; x >= 0; x--)
#define all(container)         (container).begin(), (container).end()
#define rall(container)        (container).rbegin(), (container).rend()
#define sz(container)          (int) container.size()
#define mp                     make_pair
#define fi                     first
#define se                     second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector< vector< int > > vvi;
typedef vector<bool> vb;
typedef vector<long long> vll;

#ifdef LOCAL_DEFINE
    #include "../../library/debug.hpp"
#else
    #define debug(...) 0
#endif

void read(int &a) {scanf("%d", &a);}
void read(ll &a) {scanf("%lld", &a);}
void read(char* a, string& s) {scanf("%s", a); s = string(a);}
void read(float &a) {scanf("%f", &a);}
void read(double &a) {scanf("%lf", &a);}
void print(vi &a) {for (auto& x: a) printf("%d ", x); puts("");}
void print(int &a) {printf("%d ", a);}
void println(int &a) {printf("%d\n", a);}
void print(ll &a) {printf("%lld ", a);}
void println(ll &a) {printf("%lld\n", a);}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void solve() {
    ll x;
    read(x);
    ll p = 100, ans = 0;
    while (p < x) {
        p += p / 100;
        ans++;
    }
    print(ans);
}

int main(void) {
    int T = 1;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, m;
    cin >> n >> m;
    int l = 0, r = INF;
    repi(i, m, 0)
    {
        int L, R;
        cin >> L >> R;
        l = max(l, L);
        r = min(r, R);
    }
    cout << max(r - l + 1,0) << endl;
    return 0;
}

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

void solve(){
    ll n, cnt = 0;
    cin >> n;
    ll a[n];
    map<ll, ll> mp, m;
    set<ll> s;
    for(ll i = 0; i < n; i++) cin >> a[i], mp[a[i]]++, s.insert(a[i]);
    for(auto &i: s) if(!m[i]){
        if(mp[i] <= 1) ++cnt;
        for(ll j = 2*i; j < 1000200; j+=i) m[j]++;
    }
    cout << cnt << endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 89392
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int k = stdin.nextInt();
        long[] x = new long[n];
        long[] y = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = stdin.nextLong();
            y[i] = stdin.nextLong();
        }

        long ans = Long.MAX_VALUE;
        for (int a = 0; a < n; a++) {
            for (int b = a + 1; b < n; b++) {
                for (int c = 0; c < n; c++) {
                    for (int d = c + 1; d < n; d++) {
                        long x1 = Math.min(x[a], x[b]);
                        long x2 = Math.max(x[a], x[b]);
                        long y1 = Math.min(y[c], y[d]);
                        long y2 = Math.max(y[c], y[d]);
                        
                        int count = 0;
                        for (int i = 0; i < n; i++) {
                            if (x1 <= x[i] && x[i] <= x2 && y1 <= y[i] && y[i] <= y2) {
                                count++;
                            }
                        }

                        if (k <= count) {
                            ans = Math.min(ans, (x2 - x1) * (y2 - y1));
                        }
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  int n;cin>>n;
  vector<int> a(n,0);
  for(int i=1;i<n;i++){
    int k;cin>>k;
    a[k-1]++;
  }
  rep(i,n)cout<<a[i]<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static constexpr int64_t MOD = 2;

std::vector<int64_t> solve(int64_t n, std::vector<int64_t> as) {
  bool allZero = true;
  for (auto&& a : as) {
    if (a != 0) {
      allZero = false;
      break;
    }
  }
  if (allZero) {
    return std::vector<int64_t>();
  }

  std::bitset<200001> bits;
  int i;
  for (i = n - 1; i >= n / 2; --i) {
    if (as[i] != 0) {
      bits.set(i + 1);
    }
  }
  for (; i >= 0; --i) {
    int aSum = as[i];
    for (int j = 2; (i + 1) * j <= n; ++j) {
      if (bits.test((i + 1) * j)) {
        aSum = (aSum + 1) % 2;
      }
    }
    if (aSum != 0) {
      bits.set(i + 1);
    }
  }

  std::vector<int64_t> ret;
  for (i = 1; i < n + 1; ++i) {
    if (bits.test(i)) {
      ret.push_back(i);
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  auto const res = solve(n, std::move(as));
  if (res.empty()) {
    std::cout << 0 << std::endl;
  } else if (res.front() == -1) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << res.size() << std::endl;
    for (int i = 0; i < res.size(); i++) {
      std::cout << res[i];
      if (i < res.size() - 1) {
        std::cout << " ";
      }
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3064
n,c = map(int,input().split())
ab = []
for _ in range(n):
    s, t, cha = (int(x) for x in input().split())
    ab.append([s, t, cha])

ab = sorted(ab, key=lambda x: x[0])
ab = sorted(ab, key=lambda x: x[2])

for i in range(1,n):
    if ab[i][0] == ab[i-1][1] and ab[i][2] == ab[i-1][2]:
        ab[i][0] = ab[i-1][0]
        ab[i-1][0] = -1

time = [0]*(10**5+1)

for i in range(n):
    if ab[i][0] == -1:
        continue
    time[ab[i][0]-1] += 1
    time[ab[i][1]] -= 1

ans = 0
memo = 0

for i in time:
    memo += i
    ans = max(ans,memo)

print(ans)

Measured memory_bytes: 98532
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        HashSet<Integer> numbers = new HashSet<Integer>() {
            {
                add(1);
                add(2);
                add(3);
            }
        };
        Scanner scanner = new Scanner(System.in);
        numbers.remove(scanner.nextInt());
        numbers.remove(scanner.nextInt());
        
        for(int i: numbers) {
            System.out.println(i);
        }
        
        //
        
        
        
    }
}


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

int A,B;
int main (){
    cin >> A >> B;
    if(A>=13) cout << B << endl;
    else if(A >= 6 && A <= 12) cout << B /2 << endl;
    else cout << 0 << endl;
    return 0;
}


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

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    int Min=INT_MAX;
    for(int i=0;i<n;i++){
        cin >> h[i];
        Min=min(h[i],Min);
    }
    int ans=Min;
    for(int i=0;i<n;i++){
        h[i]-=Min;
    }
    int m=0;
    for(int i=0;i<n-1;i++){
        if(h[i]<=h[i+1]){
            if(i==n-2){
                ans+=h[i+1]-m;
            }
            continue;
        }else{
            ans+=h[i]-m;
            m=h[i+1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i,j,k,c=0,d=0,ans=0;
  cin>>n>>m;
  int s=0,t=2*n+1;

  for(i=0;i<n;i++){
    cout << "lst " << i << endl;
    cin >> k;
    ans+=k*(k-1);
    for(j=0;j<k;j++) cin >> c;
  }

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

Measured memory_bytes: 1280
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

/*void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

int COM(int n,int k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}*/

//}

int n,ans,cnt;
unordered_map<int,int> a;

main(){
    cin>>n;
    rep(i,n){
        int tmp;
        cin>>tmp;
        a.count(tmp)?a[tmp]++:a[tmp]=1;
    }
    ans=a.size();
    for(auto x:a){
        cnt+=(!((x.se)&1));
    }
    cout<<ans-(cnt&1)<<endl;
}


Measured memory_bytes: 4388
/*
 * @Filename: 
 * @Author: shifaqiang
 * @Email: 14061115@buaa.edu.cn
 * @Github: https://github.com/luoboganer
 * @Date: 2020-07-12 00:38:24
 * @LastEditors: shifaqiang
 * @LastEditTime: 2020-07-13 16:21:13
 * @Software: Visual Studio Code
 * @Description: 
 */

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    int n;
    cin >> n;
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    double p;
    dp[0][0] = 1; // initializations
    for (int i = 1; i <= n; i++)
    {
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1 - p);
        for (auto j = 1; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j] * (1 - p) + dp[i - 1][j - 1] * p;
        }
    }
    double ret = 0.0;
    for (auto j = (n + 1) / 2; j <= n; j++)
    {
        ret += dp[n][j];
    }
    printf("%.10f\n", ret);
    return 0;
}

Measured memory_bytes: 73740
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

isLun :: Int -> Bool
isLun n 
    | n < 1 = True
    | otherwise = let
        nums = digitToInt <$> show n
        diffPair = zip nums $ tail nums 
        checker (a, b) = abs (a - b) < 2
        in
        all checker diffPair

availableNums :: Integer -> [Integer]
availableNums 0 = [0, 1]
availableNums 9 = [8, 9]
availableNums n = [n - 1, n, n + 1]

search :: [Integer] -> Integer -> [Integer]
search availNums 1 = availNums
search availNums nokoriKeta = 
    let 
        nextNokori = nokoriKeta - 1
    in
    do
        useNum <- availNums
        let nextAvail = availableNums useNum
        nextAns <- search nextAvail nextNokori
        pure $ useNum * (10^nextNokori) + nextAns

ketaRekkyo :: Integer -> [Integer]
ketaRekkyo n = search [1..9] n

allSearch :: [Integer]
allSearch = do
    keta <- [1..]
    ketaRekkyo keta

solve :: Integer -> Integer
solve k = genericIndex allSearch (k - 1)

main = do
    k <- readInt
    print $ solve $ fromIntegral k 





Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    cout << n*n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int r,c,i,j;
 int A[101][101]={};
 scanf("%d %d", &r, &c);
 for(i=0; i<r; i++){
  for(j=0; j<c; j++){
   scanf("%d", &A[i][j]);
  }
 }
 for(i=0;i<r;i++){
  for(j=0;j<c;j++){
   A[i][c] += A[i][j];
   A[r][j] += A[i][j];
   A[r][c] += A[i][j];
  }
 }
 for(i=0;i<r+1;i++){
  for(j=0;j<c+1;j++){
   if(j==c){printf("%d\n", A[i][j]);}
   else{printf("%d ", A[i][j]);}
  }
 }
 return 0;
}

Measured memory_bytes: 648
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long ll;

int main() {
  ll n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  ll p = 0;
  ll pa = 1;
  REP(i,0,n) {
    if(s[i] == 'a') {
      if(p < a + b) {
        cout << "Yes\n";
        p++;
      } else {
        cout << "No\n";
      }
    } else if(s[i] == 'b') {
      if(p < a + b && pa <= b) {
        cout << "Yes\n";
        p++;
        pa++;
      } else {
        cout << "No\n";
      }
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
	string p[1001],s;
	int c;
	int st[1001] = { 0 }, l = 0, i,maxl=0,maxn=0;
	while ((c = getchar()) != '\n'){
		if (c == ' '){
			for (i = 0; i < l; i++){
				if (p[i] == s){
					st[i]++;
					s.clear();
					break;
				}
			}
			if (i == l){
				int size = s.size();
				p[l] = s;
				maxl = max(maxl,size);
				if (maxl == s.size())maxn = l;
				s.clear();
				l++;
			}
		}
		else{
			s += c;
		}
	}
	for (i = 0; i < l; i++){
		if (p[i] == s){
			st[i]++;
			break;
		}
	}
	if (i == l){
		int size = s.size();
		p[l] = s;
		maxl = max(maxl, size);
		if (maxl == s.size())maxn = l;
		s.clear();
		l++;
	}
	int maxb=0,maxnum;
	for (int i = 0; i < l; i++){
		maxb = max(maxb, st[i]);
		if (maxb == st[i]){
			maxnum = i;
		}
	}
	cout << p[maxnum] << " ";
	cout << p[maxn] << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#define ll long long
using namespace std;


long long int isosceles(ll int a,ll int b,ll int sum);
long long int parallel(ll int a,ll int b,ll int sum);

ll int isosceles(ll int a,ll int b,ll int sum){

	if(a!=b){
		return parallel(a,b,sum+b);
	}
	else{
		return sum+2*a;
	}

}

ll int parallel(ll int a,ll int b,ll int sum){

	if(a>b){
		if(a%b!=0){
			return parallel(b,a-b*(a/b),sum+2*b*(a/b));
		}
		else{
			return sum+b*(2*a/b-1);
		}
	}
	else if(a<b){
		if(b%a!=0){
			return parallel(a,b-a*(b/a),sum+2*a*(b/a));
		}
		else{
			return sum+a*(2*b/a-1);
		}
	}
	else{
		return sum+2*a;
	}

}

int main(){

	ll int n,x;
	cin>>n>>x;

	cout<<isosceles(x,n-x,x)<<endl;

	return 0;
}

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
const ll mod=1e9+7;
ll fact[100010];
ll powers(ll a,ll b,ll mod)
{
	ll ans=1;
	b%=mod-1;
	a%=mod;
	while(b)
	{
		if(b%2)ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
ll nCr(ll n,ll r)
{
	return (fact[n]*powers((fact[r]*fact[n-r])%mod,mod-2,mod))%mod;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	fact[0]=1;
	for(ll i=1;i<=100000;i++)fact[i]=(i*fact[i-1])%mod;
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	ll mins=0,maxs=0;
	for(ll i=0;i<n-k+1;i++)
		mins=(mins+(arr[i]*nCr(n-i-1,k-1))%mod)%mod;
	for(ll i=k-1;i<n;i++)
		maxs=(maxs+(arr[i]*nCr(i,k-1))%mod)%mod;
	cout<<(maxs-mins+(mod-7)*mod)%mod<<"\n";
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	bool cm1=false, rm2=false;
	int lm2=-1, fm1=-1, count=0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]==2 || a[i]==-2) count++;
		if(a[i] == -2){
			cm1 = !cm1;
			lm2 = i;
		}
		if(a[i]==-1 && fm1==-1) fm1 = i;
	}
	if(cm1 && fm1==-1){
		count--;
		rm2 = true;
		cm1 = false;
	}else if(cm1){
		count++;
	}
	cout << count << endl;
	for(int i=0; i<n; i++){
		if(a[i]==2 || (a[i]==-2 && !(rm2 && i==lm2)) || (a[i]==-1 && cm1 && i==fm1)){
			cout << i+1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int m, n;
		cin>>m>>n;
		if(m==0&&n==0) break;
		vector<bool> t(7368792, false);
		FOR(i, m, 7368792) {
			if(!t[i]) {
				--n;
				if(n == -1) {
					cout<<i<<endl;
					break;
				}
				FOR(j, 1, 7368792 / i + 1) {
					if(j * i < 7368792) t[j * i] = true;
				}
			}
		}
	}
}

Measured memory_bytes: 4004
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	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;
	}
};
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	vector<ll> c(n); for (int i = 0; i < n; i++) cin >> c[i];
	sort(c.begin(), c.end());
	mint res = 0;
	for (int i = 0; i < n; i++) {
		ll N = n - i;
		if (N >= 2) res += mint(2).pow(N - 2) * c[i] * (N + 1) * mint(2).pow(i);
		else res += mint(2).pow(i) * c[i];
	}
	res *= mint(2).pow(n);
	cout << res.x << "\n";
	return 0;
}

Measured memory_bytes: 4792
def resolve():
    N = int(input())
    MOD = 10**9+7
    if N < 2:
        print(0)
    elif N == 2:
        print(2)
    else:
        noone = 9**N
        noone %= MOD
        notwo = 8**N
        notwo %= MOD
        ALL = 10**N
        ALL %= MOD
        zeroplsnine = ALL - noone
        zeroplsnine %= MOD
        zeroplsnine *= 2
        zeroplsnine %= MOD
        zeroandnine = ALL - notwo
        zeroandnine %= MOD
        ans = zeroplsnine - zeroandnine
        ans %= MOD
        print(ans)
    


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 81876
#include<bits/stdc++.h>
using namespace std;
string a[6000];
bool mycmp(string a,string b)
{
	return a<b;
}
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [0]*5
ans = 0

for i in range(n):
    s = input()
    if s[0] == "M":
        l[0] += 1
    elif s[0] == "A":
        l[1] += 1
    elif s[0] == "R":
        l[2] += 1
    elif s[0] == "C":
        l[3] += 1
    elif s[0] == "H":
        l[4] += 1

for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            if i != j != k:
                ans += l[i]*l[j]*l[k]
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Unionfind uf1 = new Unionfind(n);
        Unionfind uf2 = new Unionfind(n);
        int k = sc.nextInt();
        int l = sc.nextInt();
        int[] p = new int[k];
        int[] q = new int[k];
        for (int i = 0 ; i < k ; i++) {
            p[i] = sc.nextInt() - 1;
            q[i] = sc.nextInt() - 1;
            uf1.union(p[i], q[i]);
        }
        int[] r = new int[l];
        int[] s = new int[l];
        for (int i = 0 ; i < l ; i++) {
            r[i] = sc.nextInt() - 1;
            s[i] = sc.nextInt() - 1;
            uf2.union(r[i], s[i]);
        }
        Map<Long, Integer> map = new HashMap<>();
        List<Long> list = new ArrayList<>();
        for (int i = 0 ; i < n ; i++) {
            long key = (long) 1000000 * uf1.findRoot(i) + uf2.findRoot(i);
            list.add(key);
            if (map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            } else {
                map.put(key, 1);
            }
        }
        for (int i = 0 ; i < n ; i++) {
            System.out.print(map.get(list.get(i)));
            if (i < n - 1) {
                System.out.print(" ");
            } else {
                System.out.print("\n");
            }
        }



    }

}

class Unionfind {
    ArrayList<Integer> parent;

    public Unionfind(int n) {
        parent = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            parent.add(-1);
        }
    }

    public boolean union(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) {
            return false;
        }

        if (size(x) < size(y)) {
            int temp = x;
            x = y;
            y = temp;
        }

        parent.set(x, parent.get(x) + parent.get(y));
        parent.set(y, x);
        return true;
    }

    public int findRoot(int i) {
        if (parent.get(i) < 0) {
            return i;
        } else {
            int root = findRoot(parent.get(i));
            parent.set(i, root);
            return root;
        }
    }

    public int size(int x) {
        return -parent.get(findRoot(x));
    }

    public boolean same(int x, int y) {
        return findRoot(x) == findRoot(y);
    }
}

Measured memory_bytes: 169324
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

static const int NMAX = 1e5;

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

    int n;
    cin >> n;
    vector<int> v(n);
    int ct =0;
    for(int i =0 ; i <n; ++i)
    {
        cin >> v[i];
    }
    for(int i =0; i< n; ++i)
    {
        if(v[i] != i+1)
        {
            if(v[v[i]-1] != i+1)
            {
                cout << "NO";
                return 0;
            } 
            ct++;
        }
    }
    if(ct > 2)
    {
        cout << "NO";
    }
    else
    {
        cout << "YES";
    }
    

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
long long A,B;
void GO(ll &N){
	string s;
	cin>>s;
	for(int i=0;i<4;i++)s[i]-='0';
	N=s[0]*100+s[2]*10+s[3]; 
}
int main(){
	cin>>A;
	GO(B);
	cout<<A*B/100;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,t,s=0,x,y=-1,num=0;
	cin>>n>>t>>t;
	x=t;
	for(int i=0;i<n-1;i++){
		scanf("%lld",&t);
		if(t>y&&y!=-1){
			y=t;
			if(s==y-x){
				num++;
			}else if(s<y-x){
				s=y-x;
				num=1;
			}
		}else if(t<x){
			y=-1;
			x=t;
		}else if(y==-1){
			y=t;
			if(s==y-x){
				num++;
			}else if(s<y-x){
				s=y-x;
				num=1;
			}
		}
	}
	cout<<num;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int count = 0;
    while(m)
    {
        int t;
        cin>>t;
        count += t;
        m--;
    }
    if(count > n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<(n-count)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();

		int[] dice1 = Dice.Diceget(line1);

		String line2 = sc.nextLine();

		for (int i = 0; i < line2.length(); i++) {
			char c = line2.charAt(i);
			if (String.valueOf(c).equals("E")) {
				dice1 = Dice.DiceE(dice1);
			} else if (String.valueOf(c).equals("N")) {
				dice1 = Dice.DiceN(dice1);
			} else if (String.valueOf(c).equals("S")) {
				dice1 = Dice.DiceS(dice1);
			} else if (String.valueOf(c).equals("W")) {
				dice1 = Dice.DiceW(dice1);
			}

		}
		System.out.println(dice1[1]);

	}
}

class Dice {
	public static int[] Diceget(String line) {
		int[] set = new int[7];
		String[] s = line.split(" ");
		for (int i = 1; i <= 6; i++) {
			set[i] = Integer.parseInt(s[i-1]);
		}
		return set;
	}

	public static int[] DiceE(int[] d){
		int[] dd = new int[7];
		dd[1] = d[4];
		dd[2] = d[2];
		dd[3] = d[1];
		dd[4] = d[6];
		dd[5] = d[5];
		dd[6] = d[3];
		return dd;
	}

	public static int[] DiceN(int[] d){
		int[] dd = new int[7];
		dd[1] = d[2];
		dd[2] = d[6];
		dd[3] = d[3];
		dd[4] = d[4];
		dd[5] = d[1];
		dd[6] = d[5];
		return dd;
	}

	public static int[] DiceS(int[] d){
		int[] dd = new int[7];
		dd[1] = d[5];
		dd[2] = d[1];
		dd[3] = d[3];
		dd[4] = d[4];
		dd[5] = d[6];
		dd[6] = d[2];
		return dd;
	}

	public static int[] DiceW(int[] d){
		int[] dd = new int[7];
		dd[1] = d[3];
		dd[2] = d[2];
		dd[3] = d[6];
		dd[4] = d[1];
		dd[5] = d[5];
		dd[6] = d[4];
		return dd;
	}
}

Measured memory_bytes: 26232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


//////////////////////////////////////////////////////////////////////////////////////

int main(){
    int h, w, k;
    int ans = 0;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i = 0;i < h;i++){
        for (int j = 0;j < w;j++){
            cin >> c[i][j];
        }
    }

    for (int bith = 0;bith < (1 << h);bith++){
        for (int bitw = 0;bitw < (1 << w);bitw++){
            int count = 0;
            for (int i = 0;i < h;i++){
                for (int j = 0;j < w;j++){
                    if (bith & (1 << i)){
                        continue;
                    }

                    if (bitw & (1 << j)){
                        continue;
                    }

                    if (c[i][j] == '#'){
                        count++;
                    }
                }
            }
                    if (count == k){
                        ans++;
                    }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
# coding: utf-8
"""Fighting over Candies

@author: hijiri.n
@modified: 11-19-2016

"""

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

def solve(candies):

    ach = sum(candies) / 2

    for c in candies:
        if c == ach:
            return "Yes"

    return "No"

print(solve(c_in))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  float a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  float ans=a[0];
  for(int i=1;i<n;i++)
  {
  	ans=(ans+a[i])*1.0/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <class T>struct STm{
    vector<vector<T>> st;
    STm(vector<T>& v){
        st.clear();
        st.emplace_back(v);
        int n=1,k=1;
        while((n<<1)<=v.size()) n<<=1,++k;
        st.resize(k);
        n=1;
        for(size_t i=1;i<k;++i){
            st[i].resize(v.size()-n);
            for(size_t j=0;j<v.size()-n;++j) st[i][j]=min(st[i-1][j],st[i-1][j+n]);
            n<<=1;
        }
    }
    T gt(uint_fast32_t s,uint_fast32_t t){
        size_t l=31-__builtin_clz(t-s);
        return min(st[l][s],st[l][t-(1<<l)]);
    }
};

class EYoungMaids {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        in>>n;
        vector<int> O(n/2),E(n/2),f(n+1);
        fr(i,n/2) in>>O[i]>>E[i],f[O[i]]=f[E[i]]=i;
        STm<int> o(O),e(E);
        using P=tuple<int,int,int,int,bool>;
        priority_queue<P,vector<P>,greater<P>> pq;
        int a=o.gt(0,n/2),b=e.gt(f[a],n/2);
        pq.emplace(a,b,0,n/2,false);
        bool g;
        int s,t,l,r;
        vector<int> ans;
        while(!pq.empty()){
            tie(a,b,s,t,g)=pq.top();pq.pop();
            ans.emplace_back(a);ans.emplace_back(b);
            l=f[a],r=f[b];
            if(g){
                if(s!=l) a=e.gt(s,l),pq.emplace(a,o.gt(f[a]+1,l+1),s,l,true);
                if(l+1!=r) a=o.gt(l+1,r),pq.emplace(a,e.gt(f[a],r),l+1,r,false);
                if(r!=t) a=e.gt(r,t),pq.emplace(a,o.gt(f[a]+1,t+1),r,t,true);
            }
            else{
                if(s!=l) a=o.gt(s,l),pq.emplace(a,e.gt(f[a],l),s,l,false);
                if(l!=r) a=e.gt(l,r),pq.emplace(a,o.gt(f[a]+1,r+1),l,r,true);
                if(r+1!=t) a=o.gt(r+1,t),pq.emplace(a,e.gt(f[a],t),r+1,t,false);
            }
        }
        for(auto i:ans) out<<i<<" ";
        out<<endl;
    }
};

int main() {
    EYoungMaids solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 18580
#include <cstdio>
#include<iostream>
#include <cmath>
#include<stack>
using namespace std;
struct Point { double x, y;};

int main() {

	int n;
	scanf("%d", &n);
	double gaiseki, sum = 0;

	Point points [n];

	for (int i = 0; i < n; i++) { scanf("%lf %lf", &points[i].x, &points[i].y); }

	sum = points[n - 1].x * points[0].y - points[n - 1].y * points[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		gaiseki = points[i].x * points[i + 1].y - points[i].y * points[i + 1].x;
		sum += gaiseki;
	}

	printf("%.1lf\n", fabs(sum) / 2);
	return 0;
}


Measured memory_bytes: 3248
#include <stdio.h>
     
int main(void)
{
int H,W,A,B;
(void)scanf("%d %d %d %d",&H,&W,&A,&B);
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			putchar('0'+((i<B)^(j<A)));
		}
		putchar('\n');
	}
return 0;
}

Measured memory_bytes: 1152
// Vivek Rai
// Blazer_007

#include<bits/stdc++.h>
using namespace std;

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

signed main() {

    fastio

    int n;
    cin >> n;

    vector<ll> arr(n);
    bool zero = false;

    for( int i = 0 ; i < n ; i++ ) {
        cin >> arr[i];
        if( arr[i] == 0 )
            zero = true;
    }

    if( zero ) {
        cout << 0 << endl;
            return 0;

    }

    ll prod = 1LL;
    ll tmp;
    // cout << prod << endl;
    ll maxx = (ll)1e18;
    for( int i = 0 ; i < n ; i++ ) {
        if(__builtin_mul_overflow(prod, arr[i], &tmp)){
            cout<<-1<<endl;
            exit(0);
        }
        prod *= arr[i];
    }

    if( prod > maxx ) {
        cout << -1 << endl;
        return 0;
    }
    cout << prod << endl;

    return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
 
using namespace std;
 
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
const char d[4] = {'L','U','R','D'};
 
int main(){
  char ch;
  bool G[6][6][4];
  memset(G,false,sizeof(G));
  for(int i = 0 ; i < 9 ; i++){
    int d = i%2;
    for(int j = 0 ; j < 4+d ; j++){
      cin >> ch;
      if(ch == '1'){
        if(d%2){
          G[i/2+1][j][2] = G[i/2+1][j+1][0] = true;
        }else{
          G[i/2][j+1][3] = G[i/2+1][j+1][1] = true;
        }
      }
    }
  }
  int x = 1,y = 0,dir = 2;
  string ans;
  while(true){
    if(!x && !y) break;
    ans += d[dir];
    int rh = (dir+1)%4;
    if(G[y][x][dir]){
      dir--;
      dir = (dir == -1 ? 3 : dir);
    }else if(!G[y+dy[dir]][x+dx[dir]][rh]){
      x += dx[dir], y += dy[dir];
      if(!x && !y) break;
      x += dx[rh], y += dy[rh];
      dir = rh;
      int nrh = (rh+1)%4;
      if(!G[y][x][nrh] && !(!x && !y)){
        x += dx[nrh], y += dy[nrh];
        dir = nrh;
      }
    }else{
      x += dx[dir]; y += dy[dir];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int n,m,q;
    cin >>n >>m >>q;
    vector<vector<int> > ms(n+1, vector<int>(n+1, 0));
    for(int i = 0; i < m; i++){
        int l,r;
        cin >>l >>r;
        ms[l-1][r-1]++;
    }
    vector<vector<int> > sum(n+2, vector<int>(n+2, 0));
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            sum[i][j+1] = sum[i][j] + ms[i][j];
        }
    }
    for(int i = 0; i < q; i++){
        int pp,qq;
        cin >>pp >>qq;
        int ans = 0;
        for(int j = pp-1; j < qq; j++){
            ans += sum[j][qq];
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void){
    int a[101][101];
    int r,c,sumr,sumc;
    int i,j;
    scanf("%d %d",&r,&c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<r;i++){
        sumr=0;
        for(j=0;j<c;j++){
            sumr+=a[i][j];
        }
        a[i][c]=sumr;
    }
    for(i=0;i<=c;i++){
        sumc=0;
        for(j=0;j<r;j++){
            sumc+=a[j][i];
        }
        a[r][i]=sumc;
    }
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            printf("%d",a[i][j]); 
            if(j!=c) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    FORE(x, s) {
        if (x == 'A') x = 'T';
        else if (x == 'C') x = 'G';
        else if (x == 'T') x = 'A';
        else if (x == 'G') x = 'C';
    }
    cout << s << endl;
    return (0^_^0);
}



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

using namespace std;
typedef long long ll;

ll calc(vector<pair<int, int>> &a) {
    int n = a.size();
    set<int> free;
    for (int i = 1; i <= n; i++) free.insert(i);
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for (auto[v, p] : a) {
        auto it = free.upper_bound(p);
        if (it != free.begin()) {
            it--;
            free.erase(it);
            ans += v;
        }
    }
    return ans;
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<pair<int, int>> pos, neg;
    ll tot = 0;
    for (int i = 0; i < n; i++) {
        int k, l, r;
        scanf("%d%d%d", &k, &l, &r);
        if (l > r) {
            tot += r;
            pos.push_back({l - r, k});
        } else {
            tot += l;
            neg.push_back({r - l, n - k});
        }
    }
    printf("%lld\n", tot + calc(pos) + calc(neg));
}

int main() {
    int t;
    scanf("%d", &t);
    while (t--) solve();
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi ans(n+1);
    rep1(i, 100) rep1(j, 100) rep1(k, 100) {
        int val = i*i + j*j + k*k + i*j + j*k + k*i;
        if (val > n) continue;
        ans[val]++;
    }
    rep1(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3472
n,m=map(int,input().split())
A=[[int(i) for i in input().split()] for j in range(m)]
B={}
for i in range(m):
    A[i].append(i)
A=sorted(A,key=lambda year:year[1])
for i in A:
    if i[0] not in B:
        B[i[0]]=1
        i+=[B[i[0]]]
    else:
        B[i[0]]+=1
        i+=[B[i[0]]]
A=sorted(A,key=lambda index:index[2])
for i in A:
    print(str(i[0]).zfill(6)+str(i[3]).zfill(6))

Measured memory_bytes: 35436
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const n = input[0].split(' ')[0];
  const m = input[0].split(' ')[1];
  const result = [];
  input.splice(1)
        .map((i) => (i.split(' ')))
        .forEach((arg) => {
          const p = arg[0];
          const s = arg[1];
          if(!result[p]) result[p] = {};
          if(result[p].finished) return;
          if(s === 'AC'){
            result[p].finished = true;
          }else{
            result[p].wa = !result[p].wa ? 1 : result[p].wa + 1;
          }
        });
  const acCount = result.filter((r) => r.finished).length;
  const waCount = result.filter((r) => r.finished)
                        .map((r) => r.wa ? r.wa : 0)
                        .reduce((p, c) => p + c, 0);
  console.log(acCount, waCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 57316
#include <stdio.h>
 
int main()
{
    int i,k;
    int a,b;
    while(1){
        scanf("%d %d", &a, &b);
        if(a==0&&b==0){
            break;
        }
        else if(a<=300&&b<=300){
            for(i=0; i<a; i++){
                for(k=0; k<b; k++){
                    if(i%2==0){
                        if(k%2==0){
                            printf("#");
                        }
                        else{
                            printf(".");
                        }
                    }
                    else{
                        if(k%2==0){
                            printf(".");
                        }
                        else{
                            printf("#");
                        }
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
  #include <algorithm>
  #include <cstring>
  #include <cstdio>
  #include <vector>
  #include <cstdlib>
  #include <iomanip>
  #include <cmath>
  #include <ctime>
 #include <map>
 #include <set>
 #include <queue>
 #include <stack>
 using namespace std;
 #define lowbit(x) (x&(-x))
 #define max(x,y) (x>y?x:y)
 #define min(x,y) (x<y?x:y)
 #define MAX 100000000000000000
 #define MOD 1000000007
 #define pi acos(-1.0)
 #define ei exp(1)
 #define PI 3.141592653589793238462
 #define INF 0x3f3f3f3f3f
 #define mem(a) (memset(a,0,sizeof(a)))
 typedef long long ll;
 ll gcd(ll a,ll b){
     return b?gcd(b,a%b):a;
 }
 bool cmp(int x,int y)
 {
     return x>y;
 }
 const int N=10005;
 const int mod=1e9+7;
 int a[101];
 int main()
 {
     std::ios::sync_with_stdio(false);
     int n;
     while(cin>>n){
         int s=0;
        for(int i=0;i<n;i++)
             cin>>a[i];
         sort(a,a+n);
         if(a[0]==a[n-1]) cout<<s<<endl;
         else{
             s=1234567;
             int t=0,j;
             for(int i=a[0];i<a[n-1];i++){
                 t=0;
                 for(j=0;j<n;j++){
                     t+=(i-a[j])*(i-a[j]);
                }
                 if(t<s) s=t;
             }
            cout<<s<<endl;
         }
     }
     return 0;
 }

Measured memory_bytes: 256