akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,w,n;
int ab[3]={0,1,-1};
ll ans[12];
vector < pair<ll,ll> > x;
map < pair<ll,ll>,int > y;
map < pair<ll,ll>,bool > z;
int main()
{
	cin>>h>>w>>n;
	ans[0]=1ll*(h-2)*(w-2);
	while(n--)
    {
        int a,b;
        cin>>a>>b;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                if(a+ab[i]>1&&a+ab[i]<h&&b+ab[j]>1&&b+ab[j]<w)
                {
                    x.push_back(pair<ll,ll>(a+ab[i],b+ab[j]));
                    y[pair<ll,ll>(a+ab[i],b+ab[j])]++;
                }
    }
    for(int i=0;i<x.size();i++)
        if(!z[pair<ll,ll>(x[i].first,x[i].second)])
        {
            ll a=x[i].first,b=x[i].second;
            ans[y[pair<ll,ll>(a,b)]]++;
            z[pair<ll,ll>(a,b)]=1;
            ans[0]--;
        }
    for(int i=0;i<10;i++)
        printf("%lld\n",ans[i]);
}


Measured memory_bytes: 127972
i,o,t,j,l,s,z=map(int,input().split())
ans=0
ans+=o
if j==1 and l==1 and i==1:
    ans+=3
elif j<2 and l<2 and i<2:
    ans+=0
elif j%2==1 and l%2==1 and i%2==1:
    ans+=j+i+l
elif j%2==1 and l%2==1 and i%2==0:
    ans+=j+i+l-1
elif j%2==1 and l%2==0 and i%2==1:
    ans+=j+i+l-1
elif j%2==1 and l%2==0 and i%2==0:
    ans+=j+i+l-1
elif j%2==0 and l%2==1 and i%2==1:
    ans+=j+i+l-1
elif j%2==0 and l%2==1 and i%2==0:
    ans+=j+i+l-1
elif j%2==0 and l%2==0 and i%2==1:
    ans+=j+i+l-1
elif j%2==0 and l%2==0 and i%2==0:
    ans+=j+i+l
print(ans)


Measured memory_bytes: 3064
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_HOUSE_MAX		200000									// 最大家数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Pos[D_HOUSE_MAX * 2];								// 位置
static int siHCnt;												// 家数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最小値 - 取得
int
fGetMin(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 < piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// １周・家数 - 取得
	int liSum;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liSum, &siHCnt);

	// 位置 - 取得
	for (i = 0; i < siHCnt; i++) {
		fscanf(szpFpI, "%d", &si1Pos[i]);
		si1Pos[i + siHCnt] = si1Pos[i] + liSum;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 最短距離 - 取得
	int liMin = liSum;
	for (i = 0; i < siHCnt; i++) {
		liMin = fGetMin(liMin, si1Pos[i + siHCnt - 1] - si1Pos[i]);
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

//Thanks for zaki_
class UnionFind
{
    std::vector<int> data;

  public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

struct edge{
  ll from, to, cost;
};

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

    ll n;
    cin >> n;
    ll a, b, c;
    vector<edge> es(n - 1);
    REP(i, n - 1){
        cin >> a >> b >> c;
        a--;
        b--;
        es[i] = ((edge){a, b, c});
    }
    UnionFind uf(2 * n);
    REP(i, n - 1){
        a = es[i].from, b = es[i].to, c = es[i].cost;
        if(c % 2){
            uf.unite(a, b + n);
            uf.unite(b, a + n);
        }
        else{
            uf.unite(a, b);
            uf.unite(a + n, b + n);
        }
    }
    ll s = 0;
    REP(i, n){
        if(uf.find(s, i + n)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

#define pb push_back
#define mp make_pair


int main()
{

    int sum = 0;
    int n;
    scanf("%d", &n);
    const int A = 4000001;
    bitset<A> can;
    can[0] = 1;
    forn(i,0,n) {
        int x;
        scanf("%d", &x);
        can = can | (can<<x);
        sum += x;
    }
    for(int i = (sum+1)/2; i <= sum; i++) {
        if(can[i]) {
            cout<<i;
            return 0;
        }
    }
    
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int k = 1;
    while(true) {
        if(k*(k-1)/2 == n) break;
        if(k*(k-1)/2 > n) {
            Yes(0);
            return 0;
        }
        k++;
    }
    Yes(1);
    cout << k << endl;
    vvi ans(k);
    int now = 1;
    rep2(j,1,k) rep(i,j) {
        ans[i].pb(now);
        ans[j].pb(now++);
    }
    rep(i,k) {
        cout << ans[i].size() << " ";
        cout << ans[i];
    }
}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b == 1) {
            System.out.println(0);
            return;
        }
        if (a >= b) {
            System.out.println(1);
            return;
        }
        int c = 0;
        int d = 0;
        while (c < b) {
            if (c == 0) {
                c += a;
                d++;
            } else {
                c += a - 1;
                d++;
            }

            }
        System.out.println(d);
    }

}


Measured memory_bytes: 23124
import java.util.*;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26328
N = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13928
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <iostream>
#include <type_traits>


template<
  typename R = std::uint64_t,
  typename T,
  typename U
>
static inline typename std::common_type<R, T, U>::type
modfact(T n, U mod) noexcept
{
  static_assert(std::is_integral<R>::value, "[modfact] Type of the return value must be an integer");
  static_assert(std::is_integral<T>::value, "[modfact] Type of the first argument must be an integer");
  static_assert(std::is_integral<U>::value, "[modfact] Type of the second argument must be an integer");

  R p = 1;
  for (; n > 1; n--) {
    p = (p * n) % mod;
  }
  return p;
}


int
main()
{
  constexpr int kMod = 1000000007;

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

  int n, m;
  std::cin >> n >> m;
  if (std::abs(n - m) > 1) {
    std::cout << 0 << std::endl;
  } else {
    auto fnm = modfact(n, kMod) * modfact(m, kMod) % kMod;
    std::cout << ((std::abs(n - m) == 1) ? fnm : (2 * fnm % kMod)) << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 ALL(v) v.begin(), v.end()

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t>P(N);
  REP(i,N) cin >> P[i];
  
  int64_t c = 0;
  int64_t m = P[0];
  REP(i,N){
    m = min(m,P[i]);
    if(m >= P[i]) c++;
  }
  cout << c << endl;


}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    long long int n, m;

    cin >> n >> m;

    long long int ans = 0;

    if (m >= 2 * n) {
        ans += n;
        m -= 2 * ans;
        ans += m / 4;
    } else {
        ans += m / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
//const int MAX_INT = (1 << 31) - 1;


int main() {

	int n;
	set<int> s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.insert(a);
	}

	cout << s.size();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; i++)
using LL = long long; using VL = vector<LL>;
template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>;


void solve() {
	int N;
	while (cin>>N,N){
		V<string> vs(N);
		FOR(i, 0, N) {
			cin >> vs[i];
		}
		int ans = 0;
		int L = 0, R = 0;
		int state = 0;
		FOR(i, 1, N) {
			if (vs[i] == "lu") {
				if (vs[i - 1] == "ru")ans++;
			}
			else if (vs[i] == "ru") {
				if (vs[i - 1] == "lu")ans++;
			}
			else if (vs[i] == "ld") {
				if (vs[i - 1] == "rd")ans++;
			}
			else if (vs[i] == "rd") {
				if (vs[i - 1] == "ld")ans++;
			}
		}

		cout << ans << endl;
	}

}

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

	solve();

	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for (int i = 1; i <= min(a, b); ++i) {
        if (a%i == 0 && b%i == 0) {
            v.emplace_back(i);
        }
    }
    sort(v.rbegin(), v.rend());
    cout << v[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 5000000

int hashfunc(int);
int h1(int);
int h2(int);
int chartoint(char);
void findhashfunc(int,char *);
int getkey(char *);

char strstack[M][12];

int main(){
  int n,i,k,key;
  char str[12],scanstr[12];
  scanf("%d",&n);
   for(i=0;i<M;i++){
      strstack[i][0]='\0';
      } 
  
  
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp("insert",str)==0){
      scanf("%s",scanstr);
      key=getkey(scanstr);
      
      k=hashfunc(key);
      strcpy(strstack[k],scanstr);
     
      
     
      
    }
    else if(strcmp("find",str)==0){
      scanf("%s",scanstr);
       k=getkey(scanstr);
     
      findhashfunc(k,scanstr);
      
    }
    else exit(1);
  }
  return 0;
}
int chartoint(char c){
  if(c=='A')return 1;
  else if(c=='C')return 2;
  else if(c=='G')return 3;
  else if(c=='T')return 4;
  return 0;
}
int hashfunc(int k){
  int i=0,l,H1,H2;
  H1=h1(k);
  H2=h2(k);
  while(1){
    l=(H1+i*H2)%M;
    i++;
    if(strstack[l][0]=='\0') return l;
}
  return 0;
}
int h1(int k){
  return k%M;
}
int h2(int k){
  return 1+k%(M-1);
}
void findhashfunc(int k,char scanstr[]){
  int i=0,H1,H2,l;
  H1=h1(k);
  H2=h2(k);
  while(1){
    l=(H1+i*H2)%M;
    if(strcmp(strstack[l],scanstr)==0) {printf("yes\n");return;}
    else if(strstack[l][0]=='\0'){ printf("no\n"); return;}
    i++;
   
  }
      printf("no\n");
}
int getkey(char scanstr[])
{
  int i,p,k;
    k=0;
      p=1;
      for(i=0;i<strlen(scanstr);i++){

	k+=p*chartoint(scanstr[i]);
	p*=5;
        
      }
      return k;
}

  
    
  
  
   
  
  



Measured memory_bytes: 60384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
  N = parseInt(input[0]);
  A = parseInt(input[1]);
  B = parseInt(input[2]);
  answer2 = (N-A-B > 0) ? 0 : Math.abs(N-A-B); 
	console.log('%d %d',Math.min(A,B),answer2);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

	const long long mod = 1000000007LL;

	if (m < n) swap(n, m);

	if (2 <= m - n) {
		cout << 0 << endl;
		return 0;
	}

	long long tmp;

	if (n == m) {
		tmp = 2;
	}
	else { // n + 1 = m
		tmp = 1;
	}

	while (true) {
		tmp *= m;
		tmp = tmp % mod;
		tmp *= n;
		tmp = tmp % mod;

		if (m == 1LL && n == 1LL) break;
		
		m = max(m - 1, 1LL);
		n = max(n - 1, 1LL);
	}
	
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A == B && B == C && A > 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 int main()
{
   long long int a,b,n;
   cin>>a>>b>>n;
   long long int mn=min(n,b-1);
   long long int ans=floor((a*mn)/b)-a*floor(mn/b);
   cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n;
    sci(n);
    vi a(n+1);
    rep(i,1,n){
        sci(a[i]);
    }
    vvll dp(n+1,vll(n+1));//dp[i][j] = maxTotal X-Y in the (i,j) sequence.
    for(int start=n;start>=1;--start){
        for(int end=start;end<=n;++end){
            if(start == end)
                dp[start][end] = a[start];
            else dp[start][end] = max(a[start] - dp[start+1][end],a[end] - dp[start][end-1]);
        }
    }
    cout << dp[1][n] << endl;
}

Measured memory_bytes: 73764
(defun main ()
  (let* ((n (read))
         (a (make-array 0 :element-type 'integer
                          :adjustable t
                          :fill-pointer 0))
         (g (make-array (+ n 2) :element-type 'integer
                                :initial-element 0
                                :adjustable t))
         (gr (make-array (+ n 2) :element-type 'integer
                                 :initial-element 0
                                 :adjustable t))
         (ans 0))
    (dotimes (i n)
      (vector-push-extend (read) a))
    (setf (aref g 0) (aref a 0))
    (setf (aref gr (1+ n)) (aref a (1- n)))
    (loop for i from 1 upto n
          do (setf (aref g i) (gcd (aref g (1- i)) (aref a (1- i))))
             (setf (aref gr (1+ (- n i))) (gcd (aref gr (- n i -2)) (aref a (- n i)))))
;;    (format t "~A~%~A~%~A~%" a g gr)
    (loop for i from 2 below n
          do (setf ans (max ans (gcd (aref g (1- i)) (aref gr (1+ i))))))
    (format t "~A~%" (max ans (aref g (1- n)) (aref gr 2)))))

(main)


Measured memory_bytes: 59752
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

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

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

vll DP;
ll N, M;
vvll AdjList;
vector<bool> visited;

ll dfs(int n){
    if(visited[n]) return DP[n];
    visited[n] = true;

    ll maxy = 0;
    for(int i = 0; i < (int)AdjList[n].size(); ++i){
        int v = AdjList[n][i];
        maxy = max(dfs(v)+1, maxy);
    }
    return DP[n] = maxy;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N >> M;
    AdjList.resize(N);
    visited.assign(N, false);
    DP.assign(N, 0);

    for(int i = 0; i < M; ++i){
        int u, v; cin >> u >> v; u--; v--;
        AdjList[u].pb(v);
    }
    for(int i = 0; i < N; ++i) dfs(i);
    
    ll longest = 0;
    for(int i = 0; i < N; ++i) longest = max(longest, DP[i]);
    cout << longest << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 8576
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  int a[n][n-1];
  rep(i,n){
    rep(j,n-1) cin>>a[i][j];
  }

  int next[n][2]; // 対戦相手, 何試合目か
  rep(i,n){
    next[i][0] = a[i][0];
    next[i][1] = 1;
  }
  int day = 0;
  bool visited[n];
  rep(i,n) visited[i] = false;
  bool check = true;
  int cnt = 0;

  while(check){
    // cerr<<"day"<<day+1<<endl;
    // cerr << "next[0][1]" SP next[0][1] << endl;

    rep(i,n){ // 次の対戦相手の更新
      if(!visited[i]) continue;
      if(next[i][1]==n-1){
        next[i][0] = INF; visited[i]=true;
      }else{
        next[i][0] = a[i][next[i][1]]; visited[i]=false; next[i][1]++;
      }

      // if(i==0){
      //   cerr<< "index0 check" SP next[i][0] SP next[i][1] SP visited[i] << endl;
      // }
      // if(next[i][1]==n) cnt++;
    }

    // rep(i,n) cerr<<next[i][0] << ' ';
    // cerr<<endl;
    check = false;

    rep(i,n){
      if(visited[i]||next[i][0]==INF) continue; // 対戦済みならスルー
      int aite = next[i][0]-1;
      if(visited[aite]||next[aite][0]==INF||next[aite][0]!=i+1) continue;
      // 対戦可能な時の処理
      // if(next[aite][0]!=i+1) continue;
      // cerr << "shori:" SP i SP "aite:" SP aite << endl;
      // cerr << visited[i] SP visited[aite] << endl;
      check = true;
      visited[i] = true; visited[aite] = true;
      if(next[i][1]==n-1) cnt++;
      if(next[aite][1]==n-1) cnt++;
    }
    day++;
    if(!check) return cout<<-1<<endl, 0;
    if(cnt==n) check=false;
    // cerr << "day:" SP day SP "cnt:" SP cnt << endl;
    // cerr << "visited[0]" SP visited[0] << endl;
    // cerr << endl;
  }
  cout << day << endl;

  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    long long int k;
    int sgn=0;
    long long int a[n];
    for(int i=0;i<n;i++){
        cin>>k;
        if(k<0){
            k=-k;
            sgn=1-sgn;
        }
        a[i]=k;
    }
    sort(a,a+n);
    long long int ans=0;
    if(sgn==0){
        ans=a[0];
    }
    else{
        ans=-a[0];
    }
    for(int i=1;i<n;i++){
        ans=ans+a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
lst = []

for i in range(n):
    a = int(input())
    p = []
    for _ in range(a):
        x,y = [int(i) for i in input().split()]
        p.append([x-1,y])
    lst.append(p)

def check(mask,lst):
    cnt = 0
    for i in range(n):
        if mask & (1<<i):
            cnt += 1
            for (p,TF) in lst[i]:
                if mask&(1<<p) != TF<<p:
                    return 0
    return cnt
    
ans = 0
for mask in range(1<<n):
    c = check(mask,lst)
    ans = max(ans,c)    
print(ans)    

Measured memory_bytes: 43996
from math import ceil
N,H = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
max_a = max(ab, key=lambda x:x[0])[0]
ab = sorted(ab, key=lambda x:x[1], reverse=True)
ans = 0
damage = 0
for ai,bi in ab:
    if damage>=H: 
        print(ans);exit()
    if bi<=max_a: 
        break
    else:
        ans += 1
        damage += bi

ans += ceil((H-damage)/max_a)
print(ans)

Measured memory_bytes: 18824
fun main(args: Array<String>) {
    val S = readLine()!!
    val S1 = S.slice(0..1)
    val S2 = S.slice(2..3)

    val MMYY = 1 <= S1.toInt() && S1.toInt() <= 12
    val YYMM = 1 <= S2.toInt() && S2.toInt() <= 12

    when {
        MMYY && YYMM -> "AMBIGUOUS"
        MMYY -> "MMYY"
        YYMM -> "YYMM"
        else -> "NA"
    }.let(::println)
}

Measured memory_bytes: 33808
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 80000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n,a,b;
int main(){
    read(n),read(a),read(b);
    ll p=a+b;
    ll ans=n/p*a;
    n%=p;
    ans+=min(n,a);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_V = 205;

int V, E, R;
int r[11];
int d[MAX_V][MAX_V];///d储存边的权值，不存在是INF，d[i][i] = 0
int p[11];

void floyd()
{
  for (int k = 0; k < V; ++k)
    for (int i = 0; i < V; ++i)
      for (int j = 0; j < V; ++j)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int calc()
{
  int ret = 0;
  for (int i = 0; i + 1 < R; ++i) {
    ret += d[r[p[i]]][r[p[i + 1]]];
    //printf("ret+=d[%d][%d]=%d\n", r[p[i]], r[p[i + 1]], d[r[p[i]]][r[p[i + 1]]]);
  }
  //puts("");
  return ret;
}

void solve()
{
  floyd();
  for (int i = 0; i < R; ++i) p[i] = i;
  int ans = INT_MAX;
  do {
    ans = min(ans, calc());
    //printf("tmpans = %d\n", calc());
  } while (next_permutation(p, p + R));
  cout << ans << endl;
}

int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> V >> E >> R;
  for (int i = 0; i < R; ++i) cin >> r[i], --r[i];
  memset(d, 0x3f, sizeof d);
  for (int i = 0; i < V; ++i) d[i][i] = 0;
  for (int i = 0; i < E; ++i) {
    int a, b, c; cin >> a >> b >> c;
    --a; --b;
    d[a][b] = d[b][a] = c;
  }
  /*floyd();
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      printf("%d ", d[i][j]);
    }
    puts("");
  }*/
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <cctype>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define watch(x) cout << (#x) << " is " << (x) << endl

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


bool is_month(int x) {
    return (1 <= x and x <= 12);
}

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

    string s;
    cin >> s;
    int first = stoi(s.substr(0, 2));
    int second = stoi(s.substr(2));

    if (is_month(first) and is_month(second)) cout << "AMBIGUOUS" << endl;
    else if (is_month(first) ) cout << "MMYY" << endl;
    else if (is_month(second)) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
if A + B <= 2 * C:
    print(X*A+Y*B)
else:
    if X >= Y:
        if A >= 2*C:
            print(2*X*C)
        else:
            print((X-Y)*A + 2*Y*C)
    else:
        if B >= 2*C:
            print(2*Y*C)
        else:
            print((Y-X)*B + 2*X*C)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main{
    public static void main(String[] args) throws IOException
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	int n = Integer.parseInt(str);
	System.out.println(""+(n*n*n)+"");
    }
}

Measured memory_bytes: 24196
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

struct Dsu {
  int dsu[200005];
  Dsu() { rep(i, 0, 200005) dsu[i] = -1; }
  int size(int u) { return -dsu[find(u)]; }
  int find(int u) { if (dsu[u] < 0) return u; return dsu[u] = find(dsu[u]); }
  void merge(int u, int v) {
    u = find(u), v = find(v);
    if (u == v) return;
    dsu[u] += dsu[v];
    dsu[v] = u;
  }
} dsu;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, m; read(n, m);
  int ans = 0;
  rep(i, 0, m) {
    int a, b; read(a, b);
    dsu.merge(a, b);
  }
  rep(i, 1, n + 1) chmax(ans, dsu.size(i));
  write(ans);
}



Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    vector<int> ar(3);
    rep(i,3) cin >> ar[i];
    vector<int> oe(3);
    int e = 0;
    int o = 0;
    rep(i,3){
        if (ar[i] % 2 == 0){
            e++;
            oe[i] = 0;
        }
        else {
            o++;
            oe[i] = 1;
        }
    }
    int ans = 0;
    if (e > 0 && o > 0){
        if (e == 2){
            rep(i,3){
                if (oe[i] == 0) ar[i]++;
            }
        }
        else {
            rep(i,3){
                if (oe[i] == 1) ar[i]++;
            }
        }
        ans++;
    }   
    int mx = max({ar[0], ar[1], ar[2]});
    rep(i,3){
        ans += (mx - ar[i]) / 2;
    }
    cout << ans << endl;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e9;
const ld PI = asin(1) * 2;

int n;
map<string, int> cnt;

int main()
{
    FAST_IO;

    cin >> n;
    int most = 0;
    FOR(i, 1, n) {
        string in; cin >> in;
        cnt[in]++;
        most = max(most, cnt[in]);
    }

    for (auto p : cnt) if (p.s == most) cout << p.f << "\n";

    return 0;
}


Measured memory_bytes: 23808
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], res[12345678], ok[12345678];
signed main() {
	vector<char> v; map<int, int> cost;
	int n, m, a, b, c, x = 2, cnt = 1, ans = INF; string s, t;
	cin >> n >> m;
	for (int h = 1; h <= n; h++) {
		cin >> res[h];
	}
	test[1] = 1; ok[1] = 1;
	while (true) {
		cnt = res[cnt]; test[x] = cnt;
		if (ok[cnt] != 0) { ans = ok[cnt]; break; }
		ok[cnt] = x; x++;
	}
	x -= ans;//周期の数
	ans--;//周期前の最後
	if (m <= ans) {
		cout << test[m + 1] << endl; return 0;
	}
	m -= ans; cout << test[m % x + ans + 1] << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int LINF=1e18;

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;  //セグ木の幅
  F f;  //モノイドの作用
  T ti;  //初期値
  vector<T> dat;  //セグ木で使う配列 一番上に使われるのがdat[1] 一番下の段の左端がdat[n]
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}  //fがモノイドとしての作用、tiが単位元

  void init(int n_){  //ただの初期化
    n=1;
    while(n<n_) n<<=1;  //nが実際にとる２べきの幅
    dat.assign(n<<1,ti);  //dat配列は幅の２倍あってその全てにtiを代入
  }

  void build(const vector<T> &v){  //vector vに合わせた初期化
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];  //v[i]を一番子の所に代入
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);  //iの子供は2*i、2*i+1
  }

  void set_val(int k,T x){  //（0-indexedで）kにxを代入
    dat[k+=n]=x;
    while(k>>=1)  //kがどんどん自分の親になっていく、0になったらおしまい
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){  //[a,b)の範囲のモノイドの作用を返す
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);  //左端を使いたくなるのはブロックが奇数の時
      if(r&1) vr=f(dat[--r],vr);  //右端〃偶数の時（開区間なのでr:奇数で反応）
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){  //dat[k]:[l,r)の間にいるenを返す
    //下のfind用なので先にそっち読むべき
    //accはst~lとかで確定している値
    if(l+1==r){  //答えがちゃんと存在するならこのlが答え
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1; //入るならk-n(==l)を、入らないなら-1を返す
    }
    int m=(l+r)>>1;  //にぶたんのそれ
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);  //mがstより後ろなら明らかにl=m;
    if(st<=l&&!check(f(acc,dat[k]))){  //今見てるk全部でもダメ(mだと足りないのでl=mにする）
      acc=f(acc,dat[k]);  //kは全部accに加えた上で-1を返す
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);  //まず[l,m)の中にenがいるか探す
    if(~vl) return vl;  //いたならそれを返す(if(~vl)は-1以外にのみ反応する)
    return find(st,check,acc,(k<<1)|1,m,r);  //いなかったら[m,r)の中にenがいるのでそれを返す
    //acc=f(acc,dat[k]);がここで効いてる
  }

  template<typename C>
  int find(int st,C &check){
    //check(f(dat[st]~dat[en-1]))=false,check(f(dat[st]~dat[en]))＝trueとなるenを返す
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

signed main(){
  int n,m;cin>>n>>m;
  vector<int> l(m),r(m),c(m);
  for(int i=0;i<m;i++)cin>>l[i]>>r[i]>>c[i];
  typedef pair<int,int> P;
  typedef pair<int,P> PI;
  vector<PI> a(m);
  for(int i=0;i<m;i++)a[i]=PI(l[i]-1,P(r[i]-1,c[i]));
  sort(a.begin(),a.end());
  auto f=[](int a,int b){return min(a,b);};
  SegmentTree<int> seg(f,LINF);
  seg.init(n);
  int s=seg.n;
  seg.set_val(0,0);
  for(int i=0;i<m;i++){
    int ll=a[i].first,rr=a[i].second.first,cc=a[i].second.second;
    int t=seg.query(ll,rr);
    //cout<<ll<<" "<<rr<<" "<<cc<<" "<<t<<endl;
    if(seg.dat[rr+s]>t+cc)seg.set_val(rr,t+cc);
  }
  //for(int i=0;i<=10;i++)cout<<seg.dat[i+s]<<" ";cout<<endl;
  if(seg.dat[n-1+s]<LINF)cout<<seg.dat[n-1+s]<<endl;
  else cout<<-1<<endl;
}


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

const int maxn=1000002;
int n, ans=0, cnt[maxn+3], divs[maxn+3];

int main(){
	memset(cnt,0,sizeof cnt);
	memset(divs,0,sizeof divs);
	cin >> n;
	for (int i=0;i<n;i++){
		int a;
		cin >> a;
		cnt[a]++;
	}
	for (int i=1;i<=maxn;i++){
		if (cnt[i]>0){
			if (cnt[i]==1 && divs[i]==0) ans++;
			for (int j=i+i;j<=maxn;j+=i) divs[j]++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 11456
<?php
class help {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}


$n = trim(fgets(STDIN));
$input = trim(fgets(STDIN));
$input = str_replace(array("\r\n","\r","\n"), '', $input);
$cards = explode(" ", $input);
$alice = 0;
$bob = 0;
rsort($cards,SORT_NUMERIC);
for ($i=0; $i < count($cards); $i++) {
  if ($i == 0 || $i % 2 == 0) {
    $alice += $cards[$i];
  } else {
    $bob += $cards[$i];
  }
}

help::println($alice - $bob);

?>


Measured memory_bytes: 4728
#include <stdio.h>

int main(void){
    char b;
    scanf("%c",&b);
    char ans;

    if(b == 'A'){
        ans = 'T';
    }
    if(b == 'T'){
        ans = 'A';
    }

    if(b == 'C'){
        ans = 'G';
    }

    if(b == 'G'){
        ans = 'C';
    }

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

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll digit_sum(ll n) {
	ll s = 0;
	while (n != 0) s += n % 10, n /= 10;
	return s;
}

vector<ll> eratos(int N) {

	vector<ll> result;
	result.reserve(sqrt(N) + 1);
	vector<bool> f(N + 1);

	for (int i = 2; i <= N; i++) {
		if (!f[i]) {
			result.push_back(i);
			for (int k = 1; i * k <= N; k++) f[k*i] = true;
		}
	}

	return result;
}

int a[200000] = {};

int main(void) {

	ll result = 0;
	int n,middle;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}

	sort(a,a+n);

	if (n % 2) {
		middle = a[n / 2];
	}
	else {
		middle = (a[n / 2] + a[n / 2 - 1]) / 2;
	}

	for (int i = 0; i < n; i++) {
		result += abs(a[i] - middle);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
	char a[10]={};
	int c,i,cnt=0,leap=0;
	while(gets(a)){
		c=strlen(a);
		for(i=0;i<c;i++){
			if(a[i]==' '){
				continue; 
			}else if(a[i]=='5'){
				cnt++;
			}else if(a[i]=='7'){
				leap++;
			}
		}if(cnt==2&&leap==1){
			printf("YES\n");
		}else{
			printf("NO\n");
		}cnt=0;leap=0;
	}
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0 ; i < n ; i++){
            a[i] = sc.nextInt();
        }
        long yono = 0;
        for(int i = 0 ; i < n ; i++){
            yono += a[i] / 2;
        if(i != n - 1 && a[i + 1] != 0){
                a[i + 1] += a[i] % 2;
            }
        }
        sc.close();
        System.out.println(yono);
    }
}

Measured memory_bytes: 59456
#include <iostream>
#include<math.h>
using namespace std;

long int divide(long int a,long int b){
	if(b!=0)return (a+b-1)/b;
	return -1;
}

int main() {
	long int k,n,i,v1=0,v2=0,ratio;
	cin>>n;
	long int v[n][2];
	for(i=0;i<n;i++){
		cin>>v[i][0]>>v[i][1];
	}
	
	v1=v[0][0];
	v2=v[0][1];
	for(i=1;i<n;i++){
		k=fmaxl(divide(v1,v[i][0]),divide(v2,v[i][1]));
		v1=k*v[i][0];
		v2=k*v[i][1];
	}
	
	cout<<v1+v2<<endl;
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	N := readInt()

	var ans int
	for i := 1; i < N-1; i++ {
		if i >= N-i {
			break
		}
		if i != N-i {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<queue>
#define LL long long
#define Set(s,v) memset(s,v,sizeof(s))
using namespace std;
inline LL read(){
    LL ans=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-'){f=-1;}ch=getchar();}
    while(ch>='0'&&ch<='9'){ans=(ans<<3)+(ans<<1)+(ch^48);ch=getchar();}
    return ans*f;
}
void write(LL x){
    if(x<0){putchar('-');x=-x;}
    if(x>9){write(x/10);}
    putchar(x%10|48);
}
struct node{
    int x,y;
    LL step;
};
int n,m,a;
int cnt;
int xd[]={0,0,1,-1},
    yd[]={1,-1,0,0};
char mp[1005][1005];
bool book[1005][1005];
queue<node> q;
int ans;
int main(){
    n=read();
    m=read();
    a=n*m;
    for (int i=1;i<=n;i++){
        scanf("%s",mp[i]+1);
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if(mp[i][j]=='#'){
                cnt++;
                q.push((node){i,j,0});
                book[i][j]=1;
            }
        }
    }
    while(!q.empty()){
        node t=q.front();
        q.pop();
        for (int i=0;i<4;i++){
            int xx=t.x+xd[i],yy=t.y+yd[i];
            if(xx<1||yy<1||xx>n||yy>m||book[xx][yy]){
                continue;
            }
            book[xx][yy]=1;
            cnt++;
            if(cnt==a){
                printf("%lld\n",t.step+1);
                return 0;
            }
            q.push((node){xx,yy,t.step+1});
        }
    }
    puts("0");
    return 0;
}

Measured memory_bytes: 18612
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
	int n;
	cin >> n;
	ll res = 0;
	vector<ll> dp(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			dp[j]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		res += i * dp[i];
	}
	cout << res << endl;
}

int main() {
    FAST_INPUT;

   	solve();
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll L;
ll A[200050];
ll sum[200050];
ll even[200050];
ll odd[200050];
ll even_after[200050];
ll even_before[200050];
ll odd_after[200050];
ll odd_before[200050];

int main() {
    //cout.precision(10);
    cin >> L;
    for(int i = 1; i <= L; i++) {
        cin >> A[i];
        sum[i] = sum[i - 1] + A[i];
        even[i] = even[i - 1];
        if(A[i] % 2 == 1) even[i]++;
        if(A[i] == 0) even[i] += 2;
        odd[i] = odd[i - 1];
        if(A[i] % 2 == 0) odd[i]++;
    }
    for(int i = 1; i <= L; i++) {

        int here_left_here_cost = 0;
        int left_here_cost = 0;
        if (A[i] == 0) {
            left_here_cost = 1;
            here_left_here_cost = 2;
        } else if (A[i] % 2 == 0) {
            left_here_cost = 1;
        } else {
            here_left_here_cost = 1;
        }

        even_before[i] = min(even_before[i - 1] + here_left_here_cost, sum[i]);
        odd_before[i] = min(odd_before[i - 1] + left_here_cost, even_before[i]);
    }
    for (int i = L - 1; i >= 0; i--) {
        
        int here_right_cost = 0;
        int here_right_here_cost = 0;
        if (A[i + 1] == 0) {
            here_right_cost = 1;
            here_right_here_cost = 2;
        } else if (A[i + 1] % 2 == 0) {
            here_right_cost = 1;
        } else {
            here_right_here_cost = 1;
        }
        
        even_after[i] = min(even_after[i + 1] + here_right_here_cost, sum[L] - sum[i]);
        odd_after[i] = min(odd_after[i + 1] + here_right_cost, even_after[i]);
    }
    ll ans = 1e16;
    for(int i = 0; i <= L; i++) {
        ans = min(ans, odd_before[i] + odd_after[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,m1,m2;cin>>n;
  vector<int> x(n,0),y(n,0);
  REP(i,n){
    cin>>x.at(i);
    y.at(i)=x.at(i);
  }
  sort(y.begin(),y.end());
  m1=y.at(n/2-1);
  m2=y.at(n/2);
  REP(i,n){
    if(x.at(i)<=m1) cout<<m2<<endl;
    else cout<<m1<<endl;
  }
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (N* A < B) {
			System.out.println(N*A);
		} else {
			System.out.println(B);
		}

	}


}

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

using namespace std;

const int MAXN = 15;

int n, k;
int d[MAXN];

bool ok (int x) {
    while (x) {
        int z = x % 10;
        for (int i=0; i<k; i++) {
            if (z == d[i]) return 0;
        }
        x /= 10;
    }
    return 1;
}

int main () {
    cin >> n >> k;
    for (int i=0; i<k; i++) {
        cin >> d[i];
    }
    while (!ok(n)) n++;
    cout << n;
    return 0;
}


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

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define pb push_back
#define ar array

typedef long long ll;
typedef long double ld;
//using ll = long long;

typedef vector<int> vi;

const ld EPS = 1e-9, PI = acos(-1.);
const int INF = 0x3f3f3f3f, MOD = 1e9+7;

// global to problem

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin >> r;
	cout << 2*PI*r << endl;

}


Measured memory_bytes: 3816
import statistics
n = int(input())-1
a = list(map(int, input().split()))
N = sorted([[x,y] for y, x in enumerate(a)])

ans = [0] * (n+1)
for i in range(n+1):
    if i < n//2+1: 
        ans[N[i][1]] = N[n//2+1][0]
    else: ans[N[i][1]] = N[n//2][0]
for x in ans: print(x)

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

typedef long long int ll;

int main()
{
    ll k;
    string s;
    cin >> k >> s;
    
    if(k >= (ll)s.size()){
        cout << s;
    }
    else{
        for(ll i = 0;i < k;i++){
            cout << s[i];
        }
        cout << "...";
    }

    return 0;
}

Measured memory_bytes: 3628