akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <vector>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  ll res = 0;
  map<char, int> mp;
  mp['s'] = r;
  mp['p'] = s;
  mp['r'] = p;

  vector<bool> free(n, true);
  rep(i, n){
    if(i < k) {
      res += mp[t[i]];
      free[i] = false;
    } else{
      if(t[i] != t[i-k]){
        res += mp[t[i]];
        free[i] = false;
      }else{
        if (free[i-k]){
          res += mp[t[i]];
          free[i] = false;
        }else{
          free[i] = true;
        }
      }
    }
    // cout << res << endl;
  }

  cout << res << endl;

}


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

int main()
{
    int n;
    cin >> n;
    map<char, vector<bool>> m{
        {'S', vector<bool>(14, false)},
        {'H', vector<bool>(14, false)},
        {'C', vector<bool>(14, false)},
        {'D', vector<bool>(14, false)},
    };
    rep(i, n)
    {
        char type;
        int num;
        cin >> type >> num;
        m[type][num] = true;
    }
    for (char ch : {'S', 'H', 'C', 'D'})
    {
        rep(i, 14)
        {
            if (i == 0)
                continue;
            if (m[ch][i] == true)
                continue;
            cout << ch << " " << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3100
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as B

query :: [(Int,Int,Int)] -> [(Int,Int,Int)]
query cs =
  foldl' (flip $ \(x,y,h) ->
             filter $ \(cx,cy,ch) -> ch <= abs (x-cx) + abs (y-cy))
  (foldl' (flip $ \(x,y,h) ->
              filter $ \(cx,cy,ch) -> ch == h + abs (x-cx) + abs (y-cy))
   [(cx,cy,h0 + abs (x0-cx) + abs (y0-cy)) | cx <- [0..100], cy <- [0..100]]
   cs0)
  cs1
  where
    ((x0,y0,h0):cs0,cs1) = partition (\(_,_,h) -> h > 0) cs
    
main :: IO ()
main = do
  n <- getLine
  cs <- map ((\(a:b:c:_)->(a,b,c))
              . unfoldr (B.readInt . B.dropWhile (== ' '))) 
         . B.lines <$> B.getContents
  let (cx,cy,ch):_ = query cs
  putStrLn $ show cx ++ ' ' : show cy ++ ' ' : show ch

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
string s; cin >> s;
string t= "CODEFESTIVAL2016";
int  ans = 0;
for(int i = 0; i < 16; ++i){
if(s[i]!=t[i])++ans;
}
cout << ans << endl;
}


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

int main() {
	int a[N][N];
	int n, u, k, v;
	cin >> n;

	rep(i, n) rep(j, n) a[i][j] = 0;

	rep(i, n) {
		cin >> u >> k;
		u--;
		rep(j, k) {
			cin >> v;
			v--;
			a[u][v]++;
		}
	}


	rep(i, n){
		rep(j, n) {
			if (j) cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
ar = [0] * (N + 1)
br = [0] * (M + 1)

for i, v in enumerate(A):
    ar[i+1] = ar[i] + v

for i, v in enumerate(B):
    br[i+1] = br[i] + v

max_read = 0
j = M
for i in range(N+1):
    if ar[i] > K:
        break
    while br[j] > K - ar[i]:
        j -= 1
    max_read = max(max_read, i+j)

print(max_read)


Measured memory_bytes: 47408
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] d = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                d[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, d);
    }
}

class Solver {
    public void solve(long N, long[] d) {
        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                ans += d[i] * d[j];
            }
        }
        System.out.println(ans);
    }
}



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

int main(){
	string S;
	cin >> S;
	int n = S.size();
	cout << S[0] << n - 2 << S[n - 1] << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_diff = [x[i]-x[i-1] for i in range(1,m)]
x_diff.sort(reverse = True)
if n >= m:
  print(0)
else:
  del x_diff[:n-1]
  print(sum(x_diff))

Measured memory_bytes: 56744
# ビスケット生産装置を起動すると、起動してから A 秒後、2A 秒後、3A 秒後、
# ... (A の倍数秒後) に
# B枚ずつビスケットを生産します。
 
# ビスケット生産装置を起動してから T+0.5秒後までに生産されるビスケットの
# 合計枚数を求めてください。

A,B,T=map(int,input().split())
# print(A,B,T)

cnt=1
sum=0
for i in range(T):

  if (i+1) % A*cnt == 0:
    sum=sum+B
    cnt=cnt+1
#    print(i+1,sum)
    
print(sum)

Measured memory_bytes: 2940
! 2019.12.8
!
      program answer
      implicit none
      integer :: N
      integer,allocatable,dimension(:) :: A
      integer,allocatable,dimension(:,:) :: X,Y
      integer :: ans
      integer :: cn
      integer :: sm
      integer,allocatable,dimension(:) :: J
      integer :: M
      integer :: i,k
!
      read(*,*) N
      allocate(A(N),X(N,N),Y(N,N),J(N))
! initialization
      ans = 0
! read data
      do i=1,N
        read(*,*) A(i)
        do k=1,A(i)
          read(*,*) X(i,k),Y(i,k)
        end do
      end do
! generate array
      do M=1,2**N-1
        cn = 0
        call mk_array(J,N,M)
      lp:do i=1,N
          do k=1,A(i)
            if(J(i) == 1) then
              if(J(X(i,k)) /= Y(i,k)) then
                cn = 1
                exit lp
              end if
            end if
          end do
        end do lp
        if(cn == 0) then
          sm = 0
          do i=1,N
            sm = J(i) + sm
          end do
          if(ans < sm) ans = sm
        end if
!        write(*,*) sm,M,(J(i),i=1,N)
      end do
      write(*,*) ans
      end program answer
!------------------------------------------------
      subroutine mk_array(J,N,M)
!------------------------------------------------
      implicit none
      integer,intent(in) :: N,M
      integer,dimension(N),intent(inout) :: J
      integer :: i
      integer :: cyc
      integer :: aaa
      intrinsic mod
! initialization
      do i=1,N
        J(i) = 0
      end do
! 
      aaa = M
      cyc = 1
      do
        if(mod(aaa,2) == 1) then
          J(cyc) = 1
        else
          J(cyc) = 0
        end if
        cyc = cyc + 1
        aaa = aaa / 2
        if( aaa == 0) exit
      end do
      end subroutine mk_array

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"

	"github.com/emirpasic/gods/trees/binaryheap"
	"github.com/emirpasic/gods/utils"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)

	aList := make([]int64, n*3)
	for i := 0; i < n*3; i++ {
		var a int64
		fmt.Fscan(r, &a)
		aList[i] = a
	}

	topHeap := binaryheap.NewWith(utils.Int64Comparator)          // 小さいものから先に
	bottomHeap := binaryheap.NewWith(func(a, b interface{}) int { //大きいものから先に
		return -utils.Int64Comparator(a, b)
	})

	sumList := make([][]int64, n+1)
	var topSum, bottomSum int64
	for i := 0; i < n; i++ {
		topHeap.Push(aList[i])
		topSum += aList[i]
		bottomHeap.Push(aList[n*3-1-i])
		bottomSum += aList[n*3-1-i]
		sumList[i] = make([]int64, 2)
	}
	sumList[n] = make([]int64, 2)

	sumList[0][0] = topSum
	topMinInter, _ := topHeap.Pop()
	topMin := topMinInter.(int64)

	for i := 1; i < n+1; i++ {
		// k := n + i
		tmp := aList[n-1+i]
		if tmp > topMin {
			topSum += tmp - topMin
			topHeap.Push(tmp)
			topMinInter, _ = topHeap.Pop()
			topMin = topMinInter.(int64)
		}
		sumList[i][0] = topSum
	}

	sumList[n][1] = bottomSum
	bottomMaxInter, _ := bottomHeap.Pop()
	bottomMax := bottomMaxInter.(int64)

	for i := n - 1; i >= 0; i-- {
		tmp := aList[n+i]
		if tmp < bottomMax {
			bottomSum -= bottomMax - tmp
			bottomHeap.Push(tmp)
			bottomMaxInter, _ = bottomHeap.Pop()
			bottomMax = bottomMaxInter.(int64)
		}

		sumList[i][1] = bottomSum
	}

	bestScore := int64(-math.MaxInt64)
	for i := 0; i < n+1; i++ {
		tmpScore := sumList[i][0] - sumList[i][1]
		if tmpScore > bestScore {
			bestScore = tmpScore
		}
	}

	fmt.Fprintln(w, bestScore)

}


Measured memory_bytes: 19288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m; cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<vector<int>> g(n);
    rep(i,m){
        int a,b; cin >> a >> b; a--; b--;
        if(h[a] <= h[b]) g[a].pb(b);
        if(h[a] >= h[b]) g[b].pb(a);
    }
    int ans = 0;
    rep(i,n){
        if(g[i].size() == 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7728
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if((i+1)%2 == 1 && a[i] % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
int main(){
  int n,z=0;
  scanf("%d",&n);
  short a[n],b[n],c[n-1];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
    z += b[i];
  }
  for(int i=0;i<n-1;i++){
    scanf("%d",&c[i]);
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1]){
      z += c[a[i]-1];
    }
  }
  printf("%d\n",z);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)
    exit()

mod = 10**9 + 7
if n % 2 == 1:
    if a[0] == 0 and a[1] == 0:
        print(0)
        exit()
    ans = 1
    for i in range(1, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)
else:
    ans = 1
    for i in range(0, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)


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

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

Measured memory_bytes: 256
n,d=map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
squares=[i*i for i in range(200)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    distance=0
    for k in range(d):
      distance+=(a[i][k]-a[j][k])**2
    if distance in squares:
      cnt+=1
print(cnt)

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

using namespace std;

const int mod = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.length();
  auto add = [&] (int& x, int y) {
    x += y;
    if (x >= mod) {
      x -= mod;
    }
  };
  auto mul = [&] (int x, int y) {
    return (int) ((long long) x * y % mod);
  };
  vector<vector<int>> dp(n + 1, vector<int>(2, -1));
  function<int (int, bool)> f = [&] (int p, bool limit) {
    if (!p) {
      return 1;
    }
    if (~dp[p][limit]) {
      return dp[p][limit];
    }
    if (limit) {
      int result = f(p - 1, s[p - 1] == '0');
      if (s[p - 1] == '1') {
        add(result, mul(2, f(p - 1, true)));
      }
      return dp[p][limit] = result;
    } else {
      return dp[p][limit] = mul(3, f(p - 1, false));
    }
  };
  cout << f(n, true) << '\n';
  return 0;
}


Measured memory_bytes: 15184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  ll ans = 1;
  for (int i = 1; i <= n; i++) {
    ans = (ans * i) % MOD;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < 4; i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[4]);
}

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

int main(){
    int n;
    while(cin >> n , n){
        map<string,int> id;
        vector<int> p(n);
        for(int i=0;i<n;i++){
            string s;
            cin >> s >> p[i];
            id[s] = i;
        }
        int m;
        cin >> m;
        vector<pair<int,vector<int> > > recipe(m);
        for(int i=0;i<m;i++){
            string o;
            int k;
            vector<int> ls;
            cin >> o >> k;
            for(int j=0;j<k;j++){
                string q;
                cin >> q;
                ls.push_back(id[q]);
            }
            recipe[i] = make_pair(id[o],ls);
        }
        bool update = true;
        while(update){
            update = false;
            for(int i=0;i<m;i++){
                int sum = 0;
                for(auto j : recipe[i].second){
                    sum += p[j];
                }
                if(p[recipe[i].first] > sum){
                    p[recipe[i].first] = sum;
                    update = true;
                }
            }
        }
        string t;
        cin >> t;
        cout << p[id[t]] << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
using namespace std;
 
int W, H, N;
int x[110];
int y[110];
int a[110];
int XL, XR, YB, YU;
int ans;
 
int main(){
  cin >> W >> H >> N;
  for(int i=0; i<N; ++i){
    cin >> x[i] >> y[i] >> a[i];
  }
  int XL =0;
  int XR =W;
  int YB =0;
  int YU =H;
  for(int i=0; i<N; ++i){
    if( a[i] == 1){
      if( x[i] > XL) XL = x[i];
    }
    if (a[i] ==2){
      if( x[i] < XR) XR = x[i];
    }
    if (a[i] ==3){
      if (y[i] > YB) YB =y[i];
    }
    if (a[i] ==4){
      if (y[i] < YU) YU =y[i];
    }
  }
  int area = (XR - XL) * (YU - YB);
  if (XR-XL <0 || YU -YB <0) ans =0;
  else ans = area;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/04/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vi a(n);
    repl(i, 1, n){
        cin >> a[i];
        a[i]--;
    }
    vi ans(n, 0);
    perl(i, 1, n){
        ans[a[i]] += 1;
    }
    rep(i, n){
        cout << ans[i] << endl;
    }
    return 0;
}

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

typedef complex<double> P;

string l(string s){
	//if( s[0] <= 'Z' ) s[0] = s[0] - 'Z' + 'z';
	return s;
}

int main(){
	map<string,int> d;
	string s;
	int mx = 0;
	string v = "";
	while( cin >> s ){
		mx = max(mx,++d[l(s)]);
		if( v.size() < s.size() ) 
			v = l(s);
	}
	for( auto i : d)
		if( mx == i.second) cout << i.first << " ";
	cout << v << endl;
		
	
			
			
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>//包除原理を用いる問題
using namespace std;
long long dp[100010];
const long long MOD = 1000000007;

long long modpow(long long a, long long b, long long mod = 1000000007) {
   long long res = 1;
   for (a %= mod; b; a = a * a % mod, b >>= 1)
     if (b & 1) res = res * a % mod;
   return res;
 }

int main(){
    int n,k; cin >> n >> k;
    for(int g=k;g>0;--g){
        long long reg = 0;
        if(floor(k/g) >=2){
            for(int i=2;i<=floor(k/g);++i){
                reg += dp[i*g] %MOD;
            }
        }
        dp[g] = modpow(floor(k/g),n,MOD) - reg%MOD;   //(long long)pow(floor(k/g),n)%MOD - reg%MOD;
    }
    long long sum = 0;
    for(int i=1;i<=k;++i){
        sum += i * dp[i]%MOD;
    }
    cout << sum%MOD << endl;
    return 0;
}

Measured memory_bytes: 4420
// Contest: AtCoder Beginner Contest 165 (https://atcoder.jp/contests/abc165)
// Problem: E: Rotation Matching (https://atcoder.jp/contests/abc165/tasks/abc165_e)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, m; cin >> n >> m;
    if (n % 2) {
        rep(i, m)
            cout << (i + 1) << ' ' << (n - i) << '\n';
    } else {
        vpi a;
        int b = 1;
        for (int i = n - 1; i > n / 2; i -= 2)
            a.emplace_back(b, b + i), ++b;
        int i = n / 2 - ((n / 2) % 2 ? 1 : 2);
        for (; i; i -= 2)
            a.emplace_back(b, b + i), ++b;
        rep(j, m)
            cout << a[j].first << ' ' << a[j].second << '\n';
    }

    return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef unsigned long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 2, M = 2e3 + 2;

int X[N], Y[N], DP[M << 1][M << 1];
int F[M << 2], I[M << 2];

int Power(int a, int b) {
	int res = 1;
	for(; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}
int C(int n, int r) { return r > n ? 0 : 1LL * I[r] * I[n - r] % MOD * F[n] % MOD; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	F[0] = 1;
	for (int i = 1; i < 4 * M; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	I[(M << 2) - 1] = Power(F[(M << 2) - 1], MOD - 2);
	for (int i = (M << 2) - 1; i; i--) I[i - 1] = 1LL * i * I[i] % MOD;

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> X[i] >> Y[i];
	for (int i = 0; i < n; i++) DP[-X[i] + M][- Y[i] + M]++;
	for (int i = 1; i < 2 * M; i++) DP[0][i] = (DP[0][i] + DP[0][i - 1]) % MOD, DP[i][0] = (DP[i][0] + DP[i - 1][0]) % MOD;
	for (int i = 1; i < 2 * M; i++) for (int j = 1; j < M + M; j++) DP[i][j] = (DP[i][j] + DP[i - 1][j] + DP[i][j - 1]) % MOD;
	int ans = 0;
	for (int i = 0; i < n; i++) ans = (ans + DP[X[i] + M][Y[i] + M]) % MOD;
	for (int i = 0; i < n; i++) ans = (ans - C(X[i] + X[i] + Y[i] + Y[i], X[i] + X[i]) + MOD) % MOD;
	cout << 1LL * ans * I[2] % MOD << endl;


	return 0;
}


Measured memory_bytes: 64512
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> a, a2;
	map<int, int> m;
	
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		a.push_back(x);
		a2.push_back(x);
	}
	
	sort(a2.begin(), a2.end());
	
	for(int i = 0;i < n;i++){
		m[a2[i]] = i;
	}
	
	int d = 0;
	for(int i = 0;i < n;i++){
		if(abs(i - m[a[i]]) % 2) d++;
	}
	
	cout << (d/2) << endl;
	
	return 0;
}

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

int main(){
	int n,count = 0;
	stack<int> get;
	while(cin >> n){
		if(n==0){
			cout <<  get.top() << endl;
			get.pop();
			count -= 1;
		}
		else{
			get.push(n);
			count += 1;
		}
	}
	return 0;
}

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

int n, dist[100005];

int main() {
	scanf("%d", &n);
	memset(dist, -1, sizeof(dist));
	deque<int> que; que.push_back(1);
	dist[1] = 1;
	while (!que.empty()) {
		int now = que.front(); que.pop_front();
		if (now == 0) {
			cout << dist[0] << endl; return 0;
		}
		int nxt = (now * 10) % n;
		if (dist[nxt] ==-1 || dist[nxt] > dist[now]) {
			dist[nxt] = dist[now];
			que.push_front(nxt);
		}
		
		nxt = (now + 1) % n;
		if (dist[nxt] == -1 || dist[nxt] > dist[now]) {
			dist[nxt] = dist[now] + 1;
			que.push_back(nxt);
		}
		
	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll     = int64_t;
using ull    = uint64_t;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = LONG_MAX;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)
#define fout           cout<<fixed<<setprecision(10)
#define fasten         cin.tie(0),ios::sync_with_stdio(0)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {fasten,fout;}

struct UFT{
    vector<ll>parent;
    UFT(ll N):parent(N){rep(i,N)parent[i]=i;}
    def root(ll x){
        if(parent[x]==x)return x;
        else return parent[x]=root(parent[x]);
    }
    def unite(ll x,ll y){
        ll root_x=root(x),root_y=root(y);
        if(root_x!=root_y){
            if(root_x>root_y)swap(root_x,root_y);
            parent[root_x]=root_y;
        }
    }
    def same(ll x,ll y){return root(x)==root(y);}
};

signed main(){
    ll N,M,X,Y,S=0;
    cin>>N>>M;
    ll P[N];
    rep(i,N)cin>>P[i];
    UFT nums(N);
    rep(i,M){
        cin>>X>>Y;
        nums.unite(X-1,Y-1);
    }
    rep(i,N){
        if(nums.same(i,P[i]-1)){
            S++;
        }
    }
    cout<<S<<endl;
}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846

    int n,m;
    int sz[100005];
    int parent[100005];
    vector<pair<int,int>>a(100005);

    int find_comp(int x){
        if(x!=parent[x]){
            parent[x]=find_comp(parent[x]);
        }
        return parent[x];
    }

    bool same_comp(int x, int y){
        return find_comp(x)==find_comp(y);
    }

    void join_comp(int X,int Y){
        int x=find_comp(X);
        int y=find_comp(Y);
        if(sz[x]>sz[y]){
            parent[y]=x;
            sz[x]+=sz[y];
        }
        else{
            parent[x]=y;
            sz[y]+=sz[x];
        }
    }



    void solve(){
        cin>>n>>m;
        vector<long long>ans(m+1);
        for(int i=0;i<n;i++){
            parent[i]=i;
            sz[i]=1;
        }
        for(int i=0;i<m;i++){
            cin>>a[i].first>>a[i].second;
            a[i].first--;
            a[i].second--;
        }
        ans[m]=(ll)n*(n-1)/2;
        for(int i=m-1;i>=0;i--){
            int x=a[i].first;
            int y=a[i].second;
            if(same_comp(x,y)){
                ans[i]=ans[i+1];
                continue;
            }
            ll size_x=sz[find_comp(x)];
            ll size_y=sz[find_comp(y)];
            join_comp(x,y);
            ans[i]=max(ans[i+1]-size_x*size_y,0LL);
        }
        for(int i=1;i<=m;i++)
            cout<<ans[i]<<"\n";
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 5536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll cnt = 0;
ll inf = 1000001;
ll E;
ll solve(ll E) {
    ll ans = inf;
    for (ll z = 0; z * z * z <= E; ++z) {
        for (ll y = 0; y * y <= E; ++y) {
            // ll z = (ll) round(pow(E - x - y * y, 1.0 / 3));
            ++cnt;
            ll x = E - z * z * z - y * y;
            if (x >= 0) {
                ans = min(ans, x + y + z);
            }
        }
    }
    return ans;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    #define ll int;

    while (cin >> E) {
        if (E) {
            cout << solve(E) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w; cin >> h >> w;
  vector<int> d(h*w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int t;
      if (i % 2 == 0) t = i * w + j;
      else t = (i+1) * w - j-1;
      cin >> d[t];
    }
  }
  vector<pair<int, int>> x, y;
  for (int i = 0; i < h*w-1; i++) {
    if (d[i] % 2) {
      d[i]--; d[i+1]++;
      int a = i % w; int b = i / w;
      if (b % 2) a = w-a-1;
      x.push_back({b+1, a+1});
      a = (i+1) % w; b = (i+1) / w;
      if (b % 2) a = w-a-1;
      y.push_back({b+1, a+1});
    }
  }
  cout << x.size() << endl;
  for (int i = 0; i < (int) x.size(); i++) {
    cout << x[i].first << " " << x[i].second << " " << y[i].first << " " << y[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int n;
int calc(const string &s)
{
    int res = 0;
    // res += 100 * atoi(s.substr(0, 2).c_str());
    // res += 10 * atoi(s.substr(3, 2).c_str());
    // res += atoi(s.substr(6).c_str());
    res += 3600 * stoi(s.substr(0, 2));
    res += 60 * stoi(s.substr(3, 2));
    res += stoi(s.substr(6));
    return res;
}
signed main(void)
{
    while(cin >> n, n)
    {
        vector<int> cnt(100000, 0);
        for(int i = 0; i < n; i++)
        {
            string s, t; cin >> s >> t;
            cnt[calc(s)]++;
            cnt[calc(t)]--;
        }
        int ans = 1;
        for(int i = 1; i < cnt.size(); i++)
        {
            cnt[i] += cnt[i - 1];
            ans = max(ans, cnt[i]);
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3516
package main


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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    sc.Scan()
    s, _ := strconv.Atoi(sc.Text())
    mem := make(map[int]int)
    for i := 1; i< 1000001; i++ {
        _, ok := mem[s]
        if ok {
            fmt.Println(i)
            break
        } else {
            mem[s] = i
            if s % 2 == 0 {
                s = s / 2
            } else {
                s = s * 3 + 1
            }
        }
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 100000
#define pb push_back
#define mp make_pair
#define INF (1LL<<62)
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
Int N;
pii P[1002];
int main()
{
    cin>>N;
    cin>>P[1].fs>>P[1].sc;
    for (Int i=2;i<=N;++i)
    {
        cin>>P[i].fs>>P[i].sc;
        Int coff=max(P[i-1].sc/P[i].sc,P[i-1].fs/P[i].fs);
        while (P[i-1].sc>coff*P[i].sc||P[i-1].fs>coff*P[i].fs)
            coff++;
        P[i].sc*=coff;
        P[i].fs*=coff;
    }
    cout<<P[N].sc+P[N].fs;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

class UnionFind{
public:
	vector<int> par,rank;
	//0-indexed
	UnionFind(int n){init(n);}
	void init(int n = 1) {
		par.resize(n);
		rank.resize(n,0);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x]==rank[y]){
				rank[x]++;
			}
		}
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};


// なもりグラフ
// https://www.hamayanhamayan.com/entry/2019/08/25/090415

int main(){
	int N,H,W;
	ll ans = 0;
	cin >> N >> H >> W;
	UnionFind uf(H+W+6);
	priority_queue< pair<ll,P> > pq;
	FOR(i,0,N){
		int r,c,a;
		cin >> r >> c >> a;
		pq.push({a,{r,c}});
	}
	FOR(i,0,N){
		auto X = pq.top();
		int h = X.second.first;
		int w = X.second.second;
		int a = X.first;
		pq.pop();
		if(not uf.same(h,w+H)){
			ans += a;
			uf.unite(h,w+H);
		}else if(not uf.same(h,H+W+2)){
			ans += a;
			uf.unite(h,H+W+2);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

struct DATA{
  string s;
  int n;
};

bool Search(const char&);
int Compare(string, string);

int main(){
  int i, j, n, m, x, sum;
  string s;
  string::iterator iter;
  vector<string> Lottery;
  DATA hit;
  vector<DATA> Hit;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(i=0; i<n; ++i){
      cin >> s >> x;
      iter = find_if(s.begin(), s.end(), Search);
      s.erase(s.begin(), iter);
      hit.s = s;
      hit.n = x;
      Hit.push_back(hit);
    }
    for(i=0; i<m; ++i){
      cin >> s;
      Lottery.push_back(s);
    }

    for(i=0, sum=0; i<Lottery.size(); ++i){
      for(j=0; j<Hit.size(); ++j){
	if(Compare(Lottery[i], Hit[j].s) == 1)
	  sum += Hit[j].n;
      }
    }
    cout << sum << endl;
    Lottery.clear();
    Hit.clear();
  }

  return 0;
}

bool Search(const char& c){
  if(c == '*') return false;
  else return true;
}

int Compare(string a, string b){
  int i, j;
  for(i=a.size()-b.size(), j=0; j<b.size(); ++i, ++j){
    if(a[i] != b[j]) return 0;
  }
  return 1;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N, M,H[101010];
vector<ll> abv[101010];
ll mk[101010];

ll i, j, k,ans;
int main(){
    scanf("%lld%lld", &N, &M);
    fornum(i,0,N){
        scanf("%lld", &H[i + 1]);
    }
    fornum(i,0,M){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        abv[a].push_back(b);
        abv[b].push_back(a);
    }
    fornum(i,1,N+1){
        fornum(j,0,abv[i].size()){
            ll b = abv[i][j];
            if(H[i]<=H[b])
                break;
        }
        if(j==abv[i].size())
            ++ans;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 10488
x, y, a, b, c = map(int, input().split())

a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list = list(map(int, input().split()))
b_list.sort(reverse=True)
c_list = list(map(int, input().split()))
c_list.sort(reverse=True)

a_index =0
b_index =0
c_index = 0
count = 0
for i in range(x+y):
    if (a_index < x) and \
        (b_index >= y or a_list[a_index] >= b_list[b_index]) and \
        (c_index >= c or a_list[a_index] >= c_list[c_index]):
        count += a_list[a_index]
        a_index += 1
    elif (b_index < y) and \
        (a_index >= x or b_list[b_index] >= a_list[a_index]) and \
        (c_index >= c or b_list[b_index] >= c_list[c_index]):
        count += b_list[b_index]
        b_index += 1
    elif (c_index < c) and \
        (a_index >= x or c_list[c_index] >= a_list[a_index]) and \
        (b_index >= y or c_list[c_index] >= b_list[b_index]):
        count += c_list[c_index]
        c_index += 1
    
print(count)


Measured memory_bytes: 105444
#include<stdio.h>
#include<stdlib.h>
main()
{
        int i, n, q, com, x, y, count = 0;
        long int *a, *min;
        scanf("%d %d", &n, &q);
        min = (long int*)malloc(sizeof(long int) * q);
        a = (long int*)malloc(sizeof(long int) * n);
        for(i = 0; i < n; i++){
                a[i] = 2147483647;
        }
        for(i = 0; i < q; i++){
                scanf("%d %d %d", &com, &x, &y);
                switch(com){
                case 0:
                        a[x] = y;
                        break;
                case 1:
                        min[count] = a[x];
                        for(n = x + 1; n <= y; n++){
                                if(min[count] > a[n]){
                                        min[count] = a[n];
                                }
                        }
                        count++;
                        break;
                }
        }
        for(i = 0; i < count; i++){
                printf("%ld\n", min[i]);
        }
        free(a);
        free(min);
}

Measured memory_bytes: 2528
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    set<int> set;
    int q;
    cin>>q;
    rep(i,q){
        int y,x;
        cin>>y>>x;
        if(y==0){
            set.insert(x);
            cout<<set.size()<<endl;
        }
        else{
            cout<<(set.find(x)!=set.end())<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<pair<ll, ll>> w(n);
    forn(i, n) cin >> w[i].se >> w[i].fi;
    sort(allele(w));

    ll cur = 0;
    forn(i, n)
    {
        cur += w[i].se;
        if(cur > w[i].fi) return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b&&b<c) printf("%d %d %d\n",a,b,c);
    if(a<c&&c<b) printf("%d %d %d\n",a,c,b);
    if(b<a&&a<c) printf("%d %d %d\n",b,a,c);
    if(c<b&&b<a) printf("%d %d %d\n",c,b,a);
    if(c<a&&a<b) printf("%d %d %d\n",c,a,b);
    if(b<c&&c<a) printf("%d %d %d\n",b,c,a);
    if(a==b&&a<c) printf("%d %d %d\n",c,b,a);
    if(a==b&&c>a) printf("%d %d %d\n",a,b,c);
    if(a==c&&a>b) printf("%d %d %d\n",b,c,a);
    if(a==c&&b>a) printf("%d %d %d\n",c,a,b);
    if(b==c&&a>b) printf("%d %d %d\n",b,c,a);
    if(b==c&&b>a) printf("%d %d %d\n",a,b,c);
    if(a==b&&b==c) printf("%d %d %d\n",a,b,c);

    return 0;
}



Measured memory_bytes: 2044
MOD = 998244353
module ModInt
  refine Integer do
    def +(b); (super b) % MOD; end
    def -(b); (super b) % MOD; end
    def *(b); (super b) % MOD; end
    def pow(b); super(b, MOD); end
    def inv; pow(MOD - 2); end
    def /(b); self * b.inv; end
  end
end
using ModInt

class FactTable
  attr_reader :fa, :fi
  def initialize(n)
    @fa = [1] * (n + 1)
    @fi = [1] * (n + 1)
    2.upto(n) { |i| fa[i] = fa[i - 1] * i }
    fi[n] = 1 / fa[n]
    n.downto(3) { |i| fi[i - 1] = fi[i] * i }
  end
 
  def nCk(n, m)
    fa[n] * fi[m] * fi[n - m]
  end
end
 
n,m,k = gets.split.map(&:to_i)
ft = FactTable.new(n)
 
ans = 0
0.upto(k) do |k|
  ans += (m-1).pow(n-1-k) * m * ft.nCk(n-1,k)
end
puts ans

Measured memory_bytes: 17360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char b = scan.next().charAt(0);
		scan.close();
		if(b=='A'||b=='T')System.out.println((b=='A')? "T":"A");
		else System.out.println((b=='C')? "G":"C");
	}
}

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

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

Measured memory_bytes: 3636
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll n,x,t;
    cin>>n>>x>>t;
    n=ceil(n*1.00/x);
    cout<<n*t<<endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	const int a = 200000;
	int num;
	cin >> num;
	int p[a];
	for (int i = 0; i < num; i++) {
		cin >> p[i];
	}
	int minc = p[0];
	int maxc = p[1] - p[0];
	for (int i = 1; i < num; i++) {
		maxc = max(maxc, p[i] - minc); 
		minc = min(minc, p[i]);
	}
	cout << maxc << endl;
	return 0;
}

Measured memory_bytes: 3872
#include<iostream>
#include<vector>
using namespace std;
#define max 101000
vector<int> p[max];
bool flag[max];
int ds[max][2];


void dfs(int n,int m,int d){
  if(flag[n]) return;
  flag[n] = true;
  ds[n][m] = d;
  for(int i=0;i<p[n].size();i++) 
    dfs(p[n][i],m,d+1);

}

int main(){
  int n;

  cin>>n;

  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  dfs(0,0,0);
  fill(flag,flag+n,false);
  dfs(n-1,1,0);

  int c = 0;
  for(int i=0;i<n;i++)
    if(ds[i][0]<=ds[i][1]) c++;
    if(2*c>n)
      cout<<"Fennec"<<endl;
    else
      cout<<"Snuke"<<endl;

    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

struct Point {
	ll x;
	ll y;
	Point(ll x = 0, ll y = 0) : x(x), y(y) {}

	Point& operator+=(const Point& a) { x += a.x; y += a.y; return *this; }
	Point& operator-=(const Point& a) { x -= a.x; y -= a.y; return *this; }
	Point operator+(const Point& a) const { Point ret(*this); return ret += a; }
	Point operator-(const Point& a) const { Point ret(*this); return ret -= a; }
	bool operator==(const Point& a) const { return x == a.x && y == a.y; }
	bool operator!=(const Point& a) const { return x != a.x || y == a.y; }
	bool operator<(const Point& a) const { return x < a.x || (x == a.x && y < a.y); }
	bool operator>(const Point& a) const { return x > a.x || (x == a.x && y > a.y); }
};

void solve() {
    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Point v1 = p2 - p1;
    Point p3 = p2 + Point(-v1.y, v1.x);
    Point v2 = p3 - p2;
    Point p4 = p3 + Point(-v2.y, v2.x);
    cout << p3.x << ' ' << p3.y << ' ' << p4.x << ' ' << p4.y << endl;
    return;
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int n,m;
  char IOI[1000002];

  while( cin >> n , n ){
    cin >> m;
    cin >> IOI;

    int cnt = 0;
    for( int i = 0 ; i < m ; i++ ){
      if( IOI[i] != 'I') continue;

      int j = 0;
      for( ++i ; i < m & j < n ; i+= 2 , j++ ){
	if( IOI[i] != 'O' || IOI[i + 1] != 'I' ) break;
      }
      // O が m 個あるか調べる
      if( j < n ){
	i--;
	continue;
	// O が m 個ないかbreak
      }
      for( ++cnt ; i < m ; i += 2 , cnt++ ){
	if( IOI[i] != 'O' || IOI[i + 1] != 'I' ) break;
	// 指定された数のIOI文があり、後半にOIがあるなら続く限りcntを増やす
      }
      i--;
    }
    cout << cnt << endl; 
  }
  return 0;
}

Measured memory_bytes: 2136