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

main :: IO ()
main = do
  (h : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . f $ h

f :: Int -> Int
f 1 = 1
f h = 1 + 2 * f (h `div` 2)

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


Measured memory_bytes: 508
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N, M;
    cin >> N >> M;

    vector<vector<long long>> xyz(N, vector<long long>(3));
    for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> xyz[i][j];

    long long ans = LONG_LONG_MIN;
    for (int bit = 0; bit < (1 << 3); bit++) {
        long long sum = 0;
        vector<long long> a(N, 0);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                if (bit & (1 << j)) a[i] += xyz[i][j];
                else a[i] += -xyz[i][j];
            }
        }
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
        for (int i = 0; i < M; i++) sum += a[i];
        ans = max(ans, sum);
    }

    cout << ans <<endl;

    return 0;
}














































Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int x=Math.abs(m-n);
    int y=0;

    if(x%2==0){
       y=x/2;
         if (n<m) {
         System.out.println(n+y);
       }else{
         System.out.println(m+y);
       }
     }

    if(x%2!=0){
      System.out.println("IMPOSSIBLE");
    }
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <list>

using namespace std;
int main()
{
    int n, t, tmp_c, tmp_t;
    vector<int> c;
    cin >> n >> t;
    for (int i=0; i<n; ++i){
        cin >> tmp_c >> tmp_t;
        if(tmp_t <= t){
            c.push_back(tmp_c);
        }
    }
    if(c.size() == 0){
        cout << "TLE" << endl;
    }
    else {
        sort(c.begin(), c.end());
        cout << c[0] << endl;
    }
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, K;
    cin >> n >> K;
    vi a(n + 1);
    rep(i, n) cin >> a[i + 1];

    vvvi dp(n + 1, vvi(n + 1, vi(1 << 8)));
    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, n) {
            rep(k, 1 << 8) {
                (dp[i + 1][j][k] += dp[i][j][k]) %= mod;
                (dp[i + 1][j + 1][k ^ a[i + 1]] += dp[i][j][k]) %= mod;
            }
        }
    }

    int ans = 0;
    int t = 1;
    rep2(j, 1, n + 1) {
        (t *= j) %= mod;
        (ans += t * dp[n][j][K]) %= mod;
    }
    cout << ans << endl;
}


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

using namespace std;

enum class direction_t { u, d, l, r };

// 常に x >= y
std::vector<direction_t> solve(int x, int y) {
  std::vector<direction_t> ret;
  ret.reserve((x + y) * 6);
  for (int i = 0; i < x; ++i) {
    ret.emplace_back(direction_t::r);
  }
  for (int i = 0; i < y; ++i) {
    ret.emplace_back(direction_t::u);
  }

  for (int i = 0; i < x; ++i) {
    ret.emplace_back(direction_t::l);
  }
  for (int i = 0; i < y; ++i) {
    ret.emplace_back(direction_t::d);
  }

  ret.emplace_back(direction_t::d);
  for (int i = 0; i < x + 1; ++i) {
    ret.emplace_back(direction_t::r);
  }
  for (int i = 0; i < y + 1; ++i) {
    ret.emplace_back(direction_t::u);
  }
  ret.emplace_back(direction_t::l);

  ret.emplace_back(direction_t::u);
  for (int i = 0; i < x + 1; ++i) {
    ret.emplace_back(direction_t::l);
  }
  for (int i = 0; i < y + 1; ++i) {
    ret.emplace_back(direction_t::d);
  }
  ret.emplace_back(direction_t::r);

  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;
  int const x = tx - sx;
  int const y = ty - sy;
  bool const swap = x < y;
  if (swap) {
    auto ret = solve(y, x);
    for (auto const d : ret) {
      switch (d) {
        case direction_t::u:
          std::cout << "R";
          break;
        case direction_t::d:
          std::cout << "L";
          break;
        case direction_t::l:
          std::cout << "D";
          break;
        case direction_t::r:
          std::cout << "U";
          break;
      }
    }
  } else {
    auto ret = solve(x, y);
    for (auto const d : ret) {
      switch (d) {
        case direction_t::u:
          std::cout << "U";
          break;
        case direction_t::d:
          std::cout << "D";
          break;
        case direction_t::l:
          std::cout << "L";
          break;
        case direction_t::r:
          std::cout << "R";
          break;
      }
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 384
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [a, b, angle] = content
    .trim()
    .split(' ')
    .map(n => parseInt(n, 10));
  const rad = toRad(angle);
  const area = (a * b * Math.sin(rad)) / 2;
  const height = b * Math.sin(rad);
  const len =
    a +
    b +
    Math.sqrt(
      Math.pow(a - b * Math.cos(rad), 2) + Math.pow(b * Math.sin(rad), 2)
    );
  console.log([area, len, height].map(n => n.toFixed(6)).join('\n'));
});

const toRad = angle => (angle / 180) * Math.PI;


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

int main (void) {
    long long n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);

    long long set_len   = a+b;
    long long n_set     = n / set_len;
    long long mod_set   = n % set_len;

    printf("%lld\n", n_set*a+((mod_set<a)?mod_set:a));
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 2018/8/12
 
 14:00-14:39 analysis
 
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N,M;
SETI E[MAX_N];
SETI P[2];

void dfs(int u, int par) {
  if(P[par].count(u)) return;
  P[par].emplace(u);
  FORR(v,E[u]) dfs(v,par^1);
}

void solve() {
  dfs(0,0);
  LL both=0;
  REP(i,N) both+=P[0].count(i)&&P[1].count(i);
  
  LL res=0;
  REP(u,N) {
    bool g0=P[0].count(u),g1=P[1].count(u);
    if(g0&&!g1) res+=SZ(P[1])-SZ(E[u]);
    if(g1&&!g0) res+=SZ(P[0])-SZ(E[u]);
    if(g0&&g1) {
      res+=both-1-SZ(E[u]);
    }
/*
    REP(p,2) if(P[p].count(u)) {
      cnt[p]=SZ(P[p^1])-SZ(E[u]);
    }
    if(P[0].count(u)&&P[1].count(u)) cnt[2]+=both-1-SZ(E[u]);
    dump4(u,cnt[0],cnt[1],cnt[2]);*/
  }
//  LL res=cnt[0]+cnt[1]-cnt[2];
  res/=2;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,M) {
    int u,v; cin>>u>>v;
    --u,--v;
    E[u].emplace(v);
    E[v].emplace(u);
  }
  solve();
  return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    int x;
    cin >> x;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (v[i] + v[i - 1] > x) {
            int need = (v[i] + v[i - 1]) - x;
            ans += need;
            if (need <= v[i])
                v[i] -= need, need = 0;
            else v[i - 1] -= (need - v[i]), v[i] = 0;
        }
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

pairs = [list(map(int, input().split())) for _ in range(N)]

x0 = 0
y0 = 0
t0 = 0
res = "Yes"
for t, x, y in pairs:
    dx = x - x0
    dy = y - y0
    dt = t - t0

    if abs(dx) + abs(dy) != dt:
        tmp = dt - (abs(dx) + abs(dy))
        if tmp <= 0 or tmp % 2 != 0:
            res = "No"
            break
    x0 = x
    y0 = y
    t0 = t

print(res)

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
		a--;
	else
		b--;
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    int a, b, n;
    cin >> n >> a >> b;

    cout << min(n * a, b);

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
count=0
for i in range(n):
    if a[i]>b[i]:
        count=count+b[i]
    else:
        count=count+a[i]
        if b[i]-a[i]>a[i+1]:
            count=count+a[i+1]
            a[i+1]=0
        else:
            count=count+(b[i]-a[i])
            a[i+1]=a[i+1]-(b[i]-a[i])

print(count)
            









Measured memory_bytes: 82148
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	cin>>n;
	while(n--){
		int h,w;
		cin>>h>>w;
		int x1[26],x2[26],y1[26],y2[26];

		REP(i,26){
			x1[i]=w;
			x2[i]=-1;
			y1[i]=h;
			y2[i]=-1;
		}

		char fld[h][w];

		REP(i,h){
			REP(j,w){
				cin>>fld[i][j];
				if(fld[i][j]=='.')continue;
				int a=fld[i][j]-'A';
				x1[a]=min(x1[a],j);
				x2[a]=max(x2[a],j);
				y1[a]=min(y1[a],i);
				y2[a]=max(y2[a],i);
			}
		}

		vector<int>v;
		REP(i,26)if(x1[i]!=w)v.PB(i);
		string ans="SUSPICIOUS";

		do{
			bool f=true;
			char tmp[h][w];
			REP(i,h)REP(j,w)tmp[i][j]='.';
			REP(i,v.size()){
				for(int x=x1[v[i]];x<=x2[v[i]];x++){
					for(int y=y1[v[i]];y<=y2[v[i]];y++){
						tmp[y][x]=(char)('A'+v[i]);
					}
				}
			}
			REP(i,h)REP(j,w)if(tmp[i][j]!=fld[i][j])f=false;
			if(f)ans="SAFE";
		}while(next_permutation(v.begin(),v.end()));

		cout<<ans<<endl;

	}
}


Measured memory_bytes: 3144
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<stack>
#include<list>
#include<set>

using namespace std;

#define DEBUG_FLAG

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#ifdef DEBUG_FLAG
    #define dbgout(fmt, ...) fprintf(stderr, "\033[1;33mDEBUG(%s:%d):\t\033[0m" fmt, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define dbgout(fmt, ...) 
#endif

int modRess[10001];

int main(void)
{
    int N, P;
    scanf("%d%d", &N, &P);
    char str[N+10];
    long long ans = 0, base = 1, modr = 0;
    scanf("%s", str);
    modRess[0] = 1;
    if (P == 2 || P == 5) {
        for(int i=0; i < N; i++) {
		    if((str[i]-'0') % P == 0) ans+=(i+1);
        }
    } else {
        for (int i = N-1; i >= 0; i--) {
            modr += (str[i] - '0') * base;
            modr %= P;
            ans += modRess[modr];
            modRess[modr]++;
            base *= 10;
            base %= P;
        }
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
// package app;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // String line = sc.next();
        int X = sc.nextInt();

        int _happiness1000 = X / 500;
        int _happiness5 = X % 500 / 5;

        System.out.println(_happiness1000 * 1000 + _happiness5 * 5); 
    }

}

Measured memory_bytes: 23892
#include<stdio.h>
 
int main(){
    double x1, x2, x3, y1, y2, y3, r, xp, yp;
    double a, b, c;
 
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
 
        a = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        b = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
        c = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);

        if((a>0 && b>0 && c>0) || (a<0 && b<0 && c<0)){
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
        return 0;
}

Measured memory_bytes: 612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();

            int N = vals[0];
            int ans = 0;

            List<int> P = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();

            //List<int> cost = new List<int>(new int[N * N]);
            int[] cost = new int[N * N];
            //List<bool> left = new List<bool>(new bool[N * N]);
            var left = new bool[N * N];

            for (int i = 0; i < N * N; i++)
            {
                cost[i] = i / N;
                cost[i] = Math.Min(cost[i], N - 1 - i / N);
                cost[i] = Math.Min(cost[i], i % N);
                cost[i] = Math.Min(cost[i], N - 1 - i % N);
            }

            foreach (var ctm in P)
            {
                ans += cost[ctm - 1];
                Queue<int> bfsQueue = new Queue<int>();
                int point = ctm - 1;
                left[ctm - 1] = true;
                bfsQueue.Enqueue(point);
                do
                {
                    point = bfsQueue.Dequeue();
                    var val = cost[point] + (left[point] ? 0 : 1);

                    if (point + N < N * N && cost[point + N] > val)
                    {
                        cost[point + N] = val;
                        bfsQueue.Enqueue(point + N);
                    }
                    if (point - N >= 0 && cost[point - N] > val)
                    {
                        cost[point - N] = val;
                        bfsQueue.Enqueue(point - N);
                    }
                    if (point % N != N - 1 && cost[point + 1] > val)
                    {
                        cost[point + 1] = val;
                        bfsQueue.Enqueue(point + 1);
                    }
                    if (point % N != 0 && cost[point - 1] > val)
                    {
                        cost[point - 1] = val;
                        bfsQueue.Enqueue(point - 1);
                    }
                } while (bfsQueue.Count() != 0);



            }

            Console.WriteLine(ans);
            Console.Out.Flush();

        }



    }

}


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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long n = nx[0];
            long x = nx[1];

            x = Math.Max(x, n - x);
            long ans = 0;
            long large = x;
            long small = n - x;
            while(small>0)
            {
                ans += large / small * small;
                long tmp = small;
                small = large % small;
                large = tmp;
            }
            Console.WriteLine(ans * 3);
        }


    }
}


Measured memory_bytes: 2904
N=int(input())
S,T=map(str,input().split())
l_S=list(S)
l_T=list(T)
ans_l=[]
for i in range (N):
    ans_l.append(l_S[i])
    ans_l.append(l_T[i])
ans="".join(ans_l)
print(ans)

Measured memory_bytes: 3060
//author Eterna King
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
ll res, n;
int main()
{
	n = read_ll();
	for (int i = 1; 1ll * i * i <= n; ++i) {
		if (n % i == 0) {
			if (n / i == i)continue;
			else {
				ll p1 = i, p2 = n / i;
				if (p1 > p2)swap(p1, p2);
				if (p2 - 1 > p1) res += p2 - 1;
			}
		}
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	for n in range(1, 3502):
		for h in range(1,3502):
			t = n*h*N
			p = 4*n*h-(n*N+h*N)
			if p>0 and t%p==0:
				w = t//p
				print(n , h, w)
				exit()


if __name__=="__main__":
	main()

Measured memory_bytes: 64200
let rec transpose = function
    | (_::_)::_ as M -> List.map List.head M :: transpose (List.map List.tail M)
    | _ -> []

let eightFn = 
    [ for i in [1L;-1L] do 
      for j in [1L;-1L] do 
      for k in [1L;-1L] do 
            yield (fun (ar: int64[]) -> i*ar.[0] + j*ar.[1] + k*ar.[2]) ]

// read N and M
let [|n;m|] = stdin.ReadLine().Split() |> Array.map int
// generate processed input, using int64.
let processedInput =
    [ for i in 1..n do
        let ar = stdin.ReadLine().Split() |> Array.map int64
        yield List.map (fun fn -> fn ar) eightFn ]
// do the work
processedInput
|> transpose
|> List.map (List.toArray >> Array.sort >> Array.rev >> (fun a -> a.[0..m-1]) >> Array.sum)
|> Seq.max
|> printfn "%d"

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

from collections import deque
import heapq
import math
import bisect


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N = int(input())
    A = list(map(int, input().split()))

    pre = [0] * (N+1)
    suf = [0] * (N+1)
    for i in range(N):
        pre[i+1] = gcd(pre[i], A[i])
        suf[N-i-1] = gcd(suf[N-i], A[N-i-1])

    ans = 0
    for i in range(N):
        ans = max(ans, gcd(pre[i], suf[i+1]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63856
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		String[] array = sc.nextLine().split(" ");
	    System.out.println(array[2] + " " + array[0] + " " + array[1]);
	}
}


Measured memory_bytes: 39856
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int n;
const int MAX_N = 100000;


int main() {
	int dp[MAX_N + 10] = {};	// dp[n] = n円になる最小の回数
	cin >> n;
	dp[0] = 0;	// 初期化
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + 1;
		for (int j = 6; j <= i; j *= 6) {
			chmin(dp[i], dp[i - j] + 1);
		}
		for (int j = 9; j <= i; j *= 9) {
			chmin(dp[i], dp[i - j] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int cnt = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      int x = vec.at(i) + vec.at(j);
      for(int k=j+1; k<N; k++){
        if(x <= vec.at(k)){
          continue;
        }
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<ll> sum = A;
  ll mod = pow(10, 9) + 7;
  for (ll i = N - 1; i > 0; --i) {
    sum.at(i - 1) += sum.at(i);
    sum.at(i - 1) %= mod;
  }
  ll ans = 0;
  for (ll i = 0; i < N - 1; ++i) {
    ans = (ans + A.at(i) * sum.at(i + 1) % mod) % mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define mp make_pair
#define For(i,x,y) for(int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pa;
map<ll,ll>ma;
const int maxn=2e5+10;
ll a[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    For(i,1,n)cin>>a[i];
    sort(a+1,a+1+n);
    ll ans=0;
    priority_queue<ll>q;
    q.push(a[n]);
    ma[a[n]]=1;
    for(int i=n-1; i>=1; i--){
        int u=q.top();//q.pop();
        ans+=u;ma[u]--;//cout<<u<<endl;
        if(!ma.count(a[i]))q.push(a[i]);
        ma[a[i]]+=2;
        if(ma[u]==0)q.pop();
    }
    cout<<ans<<endl;
   // for(int i=n; i>1; i--)ans+=a[i];
   // cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 18104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_Challenge
{
    class _022_B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] res = new int[n];
            res[0] = 2;
            res[1] = 3;
            res[2] = 25;
            int i = 3;
            if (n % 2 == 0)
            {
                res[i] = 30;
                i++;
            }
            int now = 32;
            for (; i < n; i += 2)
            {
                while ((now % 2 > 0) && (now % 3 > 0) && (now % 5 > 0)) now++;
                res[i] = now;
                res[i + 1] = 30000 - now;
                now++;
            }
            for(int j = 0; j < n; j++)
            {
                WriteLine(res[j]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
h,w=LI()
s=[S() for _ in range(h)]
blackcount=0
for i,j in itertools.product(range(h),range(w)):
    if s[i][j]=="#":
        blackcount+=1
dhdw=[[-1,0],[1,0],[0,-1],[0,1]]
mindist=[[-1]*w for _ in range(h)]
seen=[[0]*w for _ in range(h)]
queue=collections.deque()
def bfs():
    seen[0][0]=1
    queue.append([0,0])
    mindist[0][0]=1
    while queue:
        qh,qw=queue.popleft()
        for dh,dw in dhdw:
            nh,nw=qh+dh,qw+dw
            if not(0<=nh<=h-1) or not(0<=nw<=w-1) or seen[nh][nw] or s[nh][nw]=="#":
                continue
            if [nh,nw]==[h-1,w-1]:
                return mindist[qh][qw]+1
            seen[nh][nw]=1
            queue.append([nh,nw])
            mindist[nh][nw]=mindist[qh][qw]+1
    else:
        return -1
mindist=bfs()
print(h*w-blackcount-mindist if mindist!=-1 else -1)

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

int main(){
    int n,x,t;
    set<int> s;
    cin >> x >> n;
    for(int i = 0; i < n; ++i){
        cin >> t;
        s.insert(t);
    }

    vector<pair<int,int>> diff;
    for(int i = -200; i <= 200; ++i){
        if(s.count(i)) continue;
        diff.emplace_back(abs(x-i),i);
    }
    sort(diff.begin(),diff.end());
    int mn = 2e9;
    for(int i = 0; i < diff.size(); ++i){
        if(diff[i].first!=diff[0].first) break;
        mn = min(diff[i].second,mn);
    }
    cout << mn;
    return 0;
}

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

int main() {
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end());
  cout << a.at(2)*10+a.at(0)+a.at(1) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int gyou , retsu,i,j;
  for( ; ; )
    {
      scanf("%d  %d",&gyou , &retsu );
      if(gyou ==0 && retsu == 0)break;
      for(i=1 ; i<=gyou ; i++)
	{
	  if(i%2==1)
	    {
	  for(j=1 ; j<=retsu ; j++)
	    {
	      if(j%2==1)printf("#");
	      else printf(".");
	    }
	  printf("\n");
	    }

	   if(i%2==0)
	    {
	  for(j=1 ; j<=retsu ; j++)
	    {
	      if(j%2==1)printf(".");
	      else printf("#");
	    }
	  printf("\n");
	    }
	  
	  
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n, p / 2);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, K;
	std::cin >> N >> K;
	vll p(N);
	rep(i, 0, N) {
		std::cin >> p[i];
	}
	sort(p.begin(), p.end());

	ll ans = 0;
	rep(i, 0, K) {
		ans += p[i];
	}

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Replace Digits
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_E2 = 1 << 19; // = 524288
const int MOD = 998244353;

/* typedef */

typedef long long ll;

struct Elm {
  int v, b, t;
  Elm(): v(0), b(1), t(10) {}
  Elm(int _v, int _b, int _t): v(_v), b(_b), t(_t) {}

  void set(int d) { v = (ll)d * b % MOD; }

  Elm operator+(const Elm &e) const {
    return
      Elm((v + (ll)e.v * t % MOD) % MOD,
	  (b + (ll)e.b * t % MOD) % MOD,
	  (ll)t * e.t % MOD);
  }
};

template <typename T, const int MAX_E2>
struct SegTreeDelay {
  int e2;
  T nodes[MAX_E2], defv;
  int dls[MAX_E2];
  SegTreeDelay() {}

  void init(int n, T _defv) {
    defv = _defv;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, defv);
    //fill(dls, dls + MAX_E2, 0);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }
  void set(int i, T v) { get(i) = v; }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
  }

  void __update(int k) {
    if (dls[k] > 0) {
      int k0 = k * 2 + 1, k1 = k0 + 1;
      nodes[k0].set(dls[k]);
      nodes[k1].set(dls[k]);
      dls[k0] = dls[k1] = dls[k];
      dls[k] = 0;
    }
  }

  void set_range(int r0, int r1, int v, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      nodes[k].set(v);
      dls[k] = v;
      return;
    }

    __update(k);

    int im = (i0 + i1) / 2;
    int k0 = k * 2 + 1, k1 = k0 + 1;
    set_range(r0, r1, v, k0, i0, im);
    set_range(r0, r1, v, k1, im, i1);
    nodes[k] = nodes[k0] + nodes[k1];
  }
  void set_range(int r0, int r1, int v) { set_range(r0, r1, v, 0, 0, e2); }

  T sum_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return defv;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    __update(k);

    int im = (i0 + i1) / 2;
    T v0 = sum_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = sum_range(r0, r1, k * 2 + 2, im, i1);
    return v0 + v1;
  }
  T sum_range(int r0, int r1) { return sum_range(r0, r1, 0, 0, e2); }
};

/* global variables */

SegTreeDelay<Elm,MAX_E2> st;

/* subroutines */

/* main */

int main() {
  int n, q;
  scanf("%d%d", &n, &q);

  st.init(n, Elm(0, 1, 10));

  for (int i = 0; i < n; i++) st.set(i, Elm(1, 1, 10));
  st.setall();

  while (q--) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    l--;

    st.set_range(n - r, n - l, d);
    Elm e = st.sum_range(0, n);
    printf("%d\n", e.v);
  }
  return 0;
}


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

int main() {
  
  int64_t MOD = 1000000007;
  
  int N; cin >> N; int64_t sum = 0, ans = 0;
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) {
    
    int64_t A; cin >> A;
    
    vec[i] = A; sum += A;
    
  }
  
  for (int i = 0; i < N; i++) {
    
    sum -= vec[i];
    
    ans += sum % MOD * vec[i] % MOD;
    
    ans %= MOD;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;

const int MAXN = 200055;

int C[MAXN], Cn;

int O[MAXN*2];
int A[MAXN], B[MAXN];

ll Ans;
int N, L = INF, mxA, mxB, mnA, mnB;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		if(A[i] > B[i]) swap(A[i], B[i]);
	}
	Ans = ll((mxA = *max_element(A, A+N)) - (mnA = *min_element(A, A+N)));
	Ans *= ll((mxB = *max_element(B, B+N)) - (mnB = *min_element(B, B+N)));

	iota(O, O+(N<<1), 0); sort(O, O+(N<<1), [&](int a, int b) {
		return ((a&1) ? A : B)[a>>1] < ((b&1) ? A : B)[b>>1];
	});

	for(int s = 0, e = -1, x, l; s <= N; s++) {
		for(; e+1 < (N<<1) && Cn < N;) {
			e++;
			x = O[e] >> 1;
			if(!C[x]) Cn++;
			C[x]++;
		}
		if(Cn < N) break;
		x = O[s];
		l = -((x&1) ? A : B)[x>>1];
		x = O[e];
		l += ((x&1) ? A : B)[x>>1];
		if(l < L) L = l;
		x = O[s] >> 1;
		C[x]--;
		if(!C[x]) Cn--;
	}

	cout << min(Ans, ll(L) * (max(mxA, mxB) - min(mnA, mnB))) << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M;
	cin>>N>>M;
	vector<ip> ship(M);
	set<int> from1;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		if(a==1)from1.insert(b);
		ship[i].first = a;
		ship[i].second = b;
	}
	bool ok = false;
	rep(i,M){
		if(ship[i].second == N){
			if(from1.count(ship[i].first)==1){
				ok = true;
			}
		}
	}
	cout<<((ok)?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <sstream>
// #include <cmath>
// #include <map>
// #include <set>
// #include <deque>
// #include <stack>
// #include <vector>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define PI acos(-1)
typedef long long ll;
const ll mod=1e9+7;

int main()
{
	//debug;
	ios;
	int N,num=0;
	string S;
	cin>>N>>S;
	for(int i=0;i<S.size()-2;i++)
	{
		if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
			num+=1;
	}
	cout<<num;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
// Big two primes
#define MAX 100002
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
//int min(int a,int b){if(a<b) return a; else return b;}
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
//int cbrt(int x){ int lo=1,hi=min(2000000ll,x)while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;}

int main()
{

    fio;

    int n;
    cin>>n;

    int d = n%10;

    if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9)
        cout<<"hon"<<endl;

    else if(d == 0 || d == 1 || d == 6 || d == 8)
     cout<<"pon"<<endl;

    else
        cout<<"bon"<<endl;

    rr;
}


Measured memory_bytes: 3660
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

int main()
{
    for (int i = 1; i <= 9; i ++) {
        for (int j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n",i , j, i * j);
        }
    }
    return 0;
}




Measured memory_bytes: 3104
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

#[allow(dead_code)]
fn solve(a: u32, b: u32, c: u32) -> usize {
    let mut set = HashSet::new();
    set.insert(a);
    set.insert(b);
    set.insert(c);
    set.len()
}

fn main() {
    input! {
    a: u32,
    b: u32,
    c: u32,
    };

    println!("{}", solve(a, b, c));
}


Measured memory_bytes: 4352
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin >> n >> m;
    vi food(m,0);
    rep(i,n)
    {
        int k;
        cin >> k;
        rep(j,k)
        {
            int a;
            cin >> a;
            ++food[a-1];
        }
    }
    int ans=0;
    rep(i,m)
    {
        if(food[i]==n)++ans;
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> v(N,0);

  for(int i=0;i<N;i++){
    int temp;
    cin>>temp;
    v[i]=temp;
  }
  
  int num=v[0];
  for(int i=1;i<=N;i++){
    if(num==2){
      cout<<i<<endl;
      return 0;
    }
    num=v[num-1];
  }

  cout<<(-1)<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0;bool b=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')b=0;c=getchar();}
	while(c>='0'&&c<='9')n=(n<<3)+(n<<1)+(c^48),c=getchar();
	return b?n:-n;
}
int h,w,n,ans; 
main()
{
	h=read();w=read();n=read();
	ans=(n-1)/max(w,h)+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int x[N], y[N], i, j, k, n, add[N], best, tmm, maxx, minn, col;
char c[N];

int main() {
scanf("%d %d", &n, &k);
for (i=0;i<n;i++) {
	scanf("%d %d %c", &x[i], &y[i], &c[i]);
	y[i] %= (2 * k);
}
best = 0;
for (j=0;j<k;j++) {
	for (i=0;i<k;i++) add[i] = 0;
	for (i=0;i<n;i++) {
		if (x[i] < j) col = 1; else col = ((x[i] - j) / k) % 2;
		if (c[i] == 'W') col = 1 - col;
		tmm = y[i];
		//printf("%d %d\n", col, tmm);
		if (col == 1) {
			if (y[i] < k) tmm += k; else tmm -= k;
		}
		//printf("%d %d\n", col, tmm);
		if (tmm < k) add[0]++; else add[tmm - (k - 1)]++;
		if (tmm >= k - 1) add[k]--; else add[tmm + 1]--;
	}
	tmm = 0;
	maxx = 0;
	minn = INF;
	//for (i=0;i<k;i++) printf("%d ", add[i]);
	//printf("\n");
	for (i=0;i<k;i++) {
		tmm += add[i];
		maxx = max(maxx, tmm);
		minn = min(minn, tmm);
	}
	best = max(best, maxx);
	best = max(best, n - minn);
}
printf("%d\n", best);
return 0;
}



Measured memory_bytes: 1152
// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

map<ll,int>mp;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,ans=0;cin>>n;
    for(int i=0;i<n;i++){
	ll x;cin>>x;
	mp[x]++;
    }
    while(sz(mp)>1 || (mp.begin()->S)>1){
	ll A=mp.rbegin()->F;
	if(--mp[A]==0) mp.erase(A);
	for(int j=1;j<32;j++){
	    ll x=(1ll<<j);
	    if(A<x && mp.count(x-A)){
		ans++;
		if(--mp[x-A]==0) mp.erase(x-A);
	    }
	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const long long INF = LLONG_MAX / 2;

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

    while(--t >= 0){
        long long n;
        int e;
        cin >> n >> e;

        vector<vector<long long> > dp(51, vector<long long>(e+1, 0));
        for(int i=1; i<=50; ++i){
            for(int j=1; j<=e; ++j){
                dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + 1;
                dp[i][j] = min(dp[i][j], INF);
            }
        }

        int ans = 0;
        while(dp[ans][e] < n)
            ++ ans;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1248
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        var t = Console.ReadLine().Split(' ');
        int N = int.Parse(t[0]);
        int K = int.Parse(t[1]);
        if (K == 1)
            Console.WriteLine(0);
        else
            Console.WriteLine(N - K);
    }
}

Measured memory_bytes: 11092
import itertools
k = int(input())
a =[]
for i in range(k):
    a.append(i+1)
c = list(itertools.combinations(a,2))
cnt=0
for i in c:
    if i[0]%2==1 and i[1]%2==0:
        cnt+=1
    elif i[0]%2==0 and i[1]%2==1:
        cnt+=1
print(cnt)

Measured memory_bytes: 3316
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
ans = 0

for i in range(1, n+1):
    b[i-1] = a[i-1] - i

sort_b = sorted(b)
num = sort_b[n // 2]

for i in range(n):
    ans += abs(b[i] - num)

print(ans)

Measured memory_bytes: 26360
#include <iostream>
#include <stdio.h>
#define MAX 20001

int n;
int A[50];

int solve(int i, int m) {
    if ( m == 0 ) {
        return true;
    }
    if ( i >= n ) {
        return false;
    }
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}


int main() {
    int q, m;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &m);
        if (solve(0, m)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3152