akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M;
  cin >> N >> M;

  VVL xs(N, VL(3));
  cin >> xs;

  LL ans = 0;
  REP(b,8){
	REP(k,N) REP(i,3) if(b>>i&1) xs[k][i] *= -1;

	VL tmp(N);
	REP(i,N) tmp[i] = xs[i][0] + xs[i][1] + xs[i][2];
	SORT(tmp);

	LL sum = 0;
	REP(i,M) sum += tmp[N-1-i];
	maxi(ans, sum);

  	REP(k,N) REP(i,3) if(b>>i&1) xs[k][i] *= -1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    ll d = 0;
    ll ans = 0;
    rep(i, 0, N)
    {
        rep(j, 0, D)
        {
            cin >> X.at(i).at(j);
        }
    }
    rep(i, 0, N)
    {
        rep(j, i + 1, N)
        {
            rep(k, 0, D)
            {
                d += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
            }
            rep(l, 1, 1000)
            {
                if (l * l == d)
                {
                    ans++;
                    break;
                }
            }
            d = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace A___Garden
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            Console.WriteLine((a * b) - (a + b - 1));
        }
    }
}

Measured memory_bytes: 13140
/*
  A - キャンディーと2人の子供 / Fighting over Candies
  <http://abc047.contest.atcoder.jp/tasks/abc047_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  if( (a<1 || a>100) || (b<1 || b>100) || (c<1 || c>100) ){
    fprintf(stderr, "INPUT ERROR!\n");
    return -1;
  }

  if( (a+b==c) || (a+c==b) || (b+c==a) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


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

ll N, M, AI, BI, CI;
priority_queue<pair<ll, ll> > pq;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> M;
    for (ll i = 0; i < N; i++) {
        cin >> AI;
        pq.push(make_pair(AI, 1));
    }
    for (ll i = 0; i < M; i++) {
        cin >> BI >> CI;
        pq.push(make_pair(CI, BI));
    }
    ll ans = 0, cur = 0;
    while (!pq.empty() && cur < N) {
        ans += pq.top().first * min(N-cur, pq.top().second);
        cur += pq.top().second;
        pq.pop();
    }
    
    cout << ans << "\n";
    
}

Measured memory_bytes: 6384
from functools import reduce
import math

N, M = [int(a) for a in input().split()]
s = []
bulb_list = []

for i in range(M):
  line = [int(a) for a in input().split()]
  k = line[0]
  s.append([int(x) for x in line[1:k+1]])
  bulb_list += s[i]

#print(list(set(bulb_list)))
p = [int(a) for a in input().split()]
#print(s)
count = 0

for i in range(int(math.pow(2, N))):
  onoff = format(i, '010b')
  ok = True
  #print('---')
  #print(onoff)
  for j in range(M):
    l = list(map(lambda x: int(onoff[-x]), s[j]))
    mod = reduce(lambda a, b: a+b, l) % 2
    #print(j, s[j], l, p[j], mod)
    if mod != p[j]:
      ok = False
      break
  if ok:
    #print('ok')
    count += 1

print(count)


Measured memory_bytes: 3680
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    ans = 0
    A_count = 0
    i = 0
    N = len(S)
    while i < N - 1:
        if S[i] == "A":
            A_count += 1
            i += 1
        elif S[i:i + 2] == "BC":
            ans += A_count
            i += 2
        else:
            A_count = 0
            i += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  int n, m; cin >> n >> m;
  int ans = n*(n-1)/2 + m*(m-1)/2;
  cout << ans << endl;
  return 0;
}

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

int bubble_sort(int A[], int N){
    int flag = 1,cnt = 0;
    while(flag){
        flag = 0;
        for(int j = N-1; j >= 1; j--){
            if(A[j] < A[j-1]){
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                cnt++;
                flag = 1;
            }
        }
    }
    return cnt;
}

void print(int A[], int n){
    for(int i = 0; i < n; i++){
        cout << A[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
}

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int cnt = bubble_sort(A,n);
    print(A,n);
    cout << cnt << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    string s; cin >> s;

    int ans = 0;
    for(int i=0; i<N; i++) if(s[i] == 'E') ans++;

    int tmp = ans;
    for(int i=0; i<N; i++){
        if(s[i] == 'E') tmp--;
        else tmp++;

        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 900
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    int num;
    int64_t a, b;
    cin >> num >> a >> b;
    vector<int> arr(num);
    cins(arr);

    int64_t sum = 0;
    int prev = arr[0];
    for(int i = 1; i < num; i++) {
        int cur = arr[i];
        int64_t walk = a * (cur-prev);
        debug("%ld vs %ld\n", walk, b);
        sum += min(walk, b);
        prev = cur;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
n, k = map(int, input().split())
l = [0 for i in range(10 ** 5 + 5)]
for i in range(n):
    a,b=map(int, input().split())
    l[a]+=b

n = 0
for i,x in enumerate(l):
    n+=x
    if n>=k:
        print(i)
        break

Measured memory_bytes: 5928
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF ((int)1<<62)
signed main(){
    int n;
    cin>>n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        a.push_back(t);
    }
    vector<int> sum;
    sum.push_back(0);
    for(int i=0;i<n;i++){
        sum.push_back(sum[i]+a[i]);
    }
    int mi=INF;
    for(int i=1;i<n;i++){
        int x=sum[i],y=sum[sum.size()-1]-x;
        mi=min(mi,abs(x-y));
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

int main()
{
    int n;
    cin >> n;
    vl a(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n - 1)
    {
        a[i + 1] = gcd(a[i], a[i + 1]);
    }
    cout << a[n - 1] << endl;
}


Measured memory_bytes: 1024
num = list(map(int,input().split()))
string = input()
s_key=[]
count=[]
for i in range(num[1]):
    s_key.append(list(map(int,input().split())))
for i in range(num[0]):
    if i==0:
        count.append(0)
    else:
        if (string[i-1]=='A' and string [i]=='C'):
            count.append(count[i-1]+1)
        else:
            count.append(count[i-1])
for k in range(num[1]):
    result=count[s_key[k][1]-1]-count[s_key[k][0]-1]
    print(result)

Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    REP(i,s.size() - 1){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    REP(i,s.size() - 2){
        if(s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
A, B, K = [int(akb) for akb in input().split()]
a, b = min(A, B), max(A, B)
r = b % a
while r > 0:
  b = a
  a = r
  r = b % a
gcd = a
ans = a
if K > 1:
  for i in range(1, 100):
    if gcd % (i+1) == 0:
      ans = gcd / (i+1)
      K -= 1
    if K == 1:
      break
print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 1;

int a[maxn][3], dp[maxn][3];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    printf("%d\n", max({ dp[n][0], dp[n][1], dp[n][2] }));
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+500;
int fa[N],K,n,ans;
int fst[N],nxt[N],to[N],mm,f[N];
void ade(int u,int v){to[++mm]=v,nxt[mm]=fst[u],fst[u]=mm;}
void dfs(int u)
{
    f[u]=-1;
    for(int i=fst[u];i;i=nxt[i])
    {
        int v=to[i];dfs(v);f[u]=max(f[u],f[v]);
    }
    ++f[u];if(f[u]==K-1&&fa[u]!=1)++ans,f[u]=-1;
}
int main()
{
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",fa+i);
        if(i!=1)ade(fa[i],i);
    }
    if(fa[1]!=1)++ans;
    for(int i=fst[1];i;i=nxt[i])dfs(to[i]);cout<<ans<<endl;
}

Measured memory_bytes: 11896
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
int n;
int dp[100005],h[100005];
int solve(int i)
{
	if(i==n-1)
		return 0;
	if(dp[i]!=-1)
		return dp[i];
	int ans=inf;
	ans=abs(h[i]-h[i+1])+solve(i+1);
	if(i+2<n)
		ans=min(ans,abs(h[i]-h[i+2])+solve(i+2));
	dp[i]=ans;
	return ans;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   memset(dp,-1,sizeof(dp));
   cin>>n;
   for(int i=0;i<n;i++)
   {
   	cin>>h[i];
   }
   cout<<solve(0)<<endl;
}                       

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    vector<int> gyo,retu;
    for(int i=0; i<H; i++){
        cin >> a[i];
    }
    string s;
    for(int i=0; i<H; i++){
        s.push_back('.');
    }
    
    for(int i=0; i<H; i++){
        int cnt=0;
        for(int j=0; j<W; j++){
            if(a[i][j]=='.'){
                cnt++;
            }
        }
        if(cnt==W) gyo.push_back(i);
    }
    for(int i=0; i<W; i++){
        int cnt=0;
        for(int j=0; j<H; j++){
            if(a[j][i]=='.'){
                cnt++;
            }
        }
        if(cnt==H) retu.push_back(i);
    }
    
    for(int i=0; i<H; i++){
        bool flag1;
        for(int j=0; j<W; j++){
            bool flag2=true;
            flag1=true;
            for(int k=0; k<gyo.size(); k++){
                if(i==gyo[k]){
                    flag1=false;
                }
            }
            for(int k=0; k<retu.size(); k++){
                if(j==retu[k]){
                    flag2=false;
                }
            }
            if(!flag1) break;
            if(flag2) cout << a[i][j];
        }
        if(flag1)cout << endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			String[] S = new String[N];
			for (int i = 0;i < N;++ i) S[i] = sc.next();
			for (String judge : new String[]{"AC", "WA", "TLE", "RE"}) {
				System.out.printf("%s x %d\n", judge, Arrays.stream(S).filter(s -> s.equals(judge)).count());
			}
		}
	}
}

Measured memory_bytes: 63876
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let mut a = vec![];
        let mut b = vec![];
        (0..n).for_each(|_| {
            let x: usize = scn.read();
            let y: usize = scn.read();
            a.push(x);
            b.push(y);
        });
        a.sort();
        b.sort();
        if n % 2 != 0 {
            let x1 = a[n / 2];
            let x2 = b[n / 2];
            println!("{}", x2 - x1 + 1);
        } else {
            let x1 = a[n/2 - 1] + a[n/2];
            let x2 = b[n/2 - 1] + b[n/2];
            println!("{}", x2 - x1 + 1);
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4908
#include <stdio.h>
#include <stdlib.h>
int maxi(int a,int b,int c);
int mini(int a,int b,int c);

int main(void){
int a,b,c;
  int max,min;
  scanf("%d %d %d",&a,&b,&c);
  max=maxi(a,b,c);
  min=mini(a,b,c);
  printf("%d\n",abs(max-min));
  
return 0;
}

int maxi(int a,int b,int c){
int max;
  max=a;
  if(b>=max){max=b;}
  if(c>=max){max=c;}
  
return max;
}

int mini(int a,int b,int c){
int min;
  min=a;
  if(b<=min){min=b;}
  if(c<=min){min=c;}
  
return min;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int s[30];
char str[30];
int main(){
	cin>>str;
	int c;
	for(int i=0;i<strlen(str);i++){
		c=str[i]-'a';
		s[c]++;
		if(s[c]>1){
			cout<<"no";	
			return 0;
		}
	}
	cout<<"yes";
	return 0;
}

Measured memory_bytes: 256
#include<stack>
#include<cstdio>

using namespace std;

bool isope(char c){return c=='+'||c=='-'||c=='*'||c=='/';}

double calc(double a,char c,double b)
{
	switch(c){
		case '+':	return a+b;
		case '-':	return a-b;
		case '*':	return a*b;
		case '/':	return a/b;
	}
}

int main()
{
	while(1){
		stack<double> st;

		while(1){
			char s[16];
			int f=scanf("%s",s);
			if(!~f)	return 0;

			if(s[1]=='\0' && isope(s[0])){
				double b=st.top();	st.pop();
				double a=st.top();	st.pop();
				st.push(calc(a,s[0],b));
			}
			else{
				double a;
				sscanf(s,"%lf",&a);
				st.push(a);
			}

			if(getchar()=='\n')	break;
		}

		printf("%f\n",st.top());
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
  int A[100], n, j, key;

  scanf("%d\n", &n);

  for ( int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  for ( int k = 0; k < n; k++) {
      if (k != n-1) {
        printf("%d ", A[k]);
      } else {
        printf("%d\n", A[k]);
      }
    }

  for ( int i = 1; i < n; i++) {
    key = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    for ( int k = 0; k < n; k++) {
      if (k != n-1) {
        printf("%d ", A[k]);
      } else {
        printf("%d\n", A[k]);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2032
s=list(map(int,input().split()))
a=s[1]+s[2]
b=int(s[0]//a)
c=s[0]%a
if c==0:
  print(b*s[1])
else:
  if c<=s[1]:
    print(b*s[1]+c)
  else:
    print(b*s[1]+s[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N, A, B;
  cin >> N >> A >> B;

  if(A>B){
    cout << 0 << endl;
    return 0;
  }
  if(N==1){
    if(A!=B){
      cout << 0 << endl;
      return 0;
    }else{
      cout << 1 << endl;
      return 0;
    }
  }
  
  ll x = A + (N-1)*B;
  ll y = (N-1)*A + B;

  cout << x-y+1 << endl;
  
  return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
a = 0
for i in A:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            a += 1
if a == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
 int A,B,C,D,P;
 scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
 int X,Y;
 X=A*P;
 if(P<=C){
  Y=B;
 }
 else{
  Y=B+D*(P-C);
 }
 if(X>Y){
  printf("%d\n",Y);
 }
 else{
  printf("%d\n",X);
}
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

int main(){
    string S;
    cin >> S;
    //cout << S[2] << endl;
    bool ans = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == '7'){
            ans = 1;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define ri register int
#define forn(i, n) for(int i = 1; i <= (n); i++)
typedef long long ll;
using namespace std;
/* Template_In_Programming_Contest */

void rd(int& u) {scanf("%d", &u);}
void rd2(int& u, int& v) {scanf("%d%d", &u, &v);}
void rd3(int& u, int& v, int& w) {scanf("%d%d%d", &u, &v, &w);}
void ptn(int u) {printf("%d\n", u);}
void pte(int u) {printf("%d ", u);}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
typedef vector <int> vi;
const int N = 300 + 5; 
int dis[N][N], dis1[N][N], put[N], n, m, q, L;
vi v;
signed main(){
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	cin >> n >> m >> L;
	memset(dis, 0x3f, sizeof(dis));
	memset(dis1, 0x3f, sizeof(dis1));
	forn(i, n) dis[i][i] = 0;
	forn(e, m) {
		int u, v, w;
		cin >> u >> v >> w;
		if(w <= L) dis[u][v] = dis[v][u] = min(dis[u][v], w);
	}
	forn(k, n) forn(i, n) forn(j, n)
			if(dis[i][j] > dis[i][k] + dis[k][j])
				dis[i][j] = dis[i][k] + dis[k][j];
	forn(i, n) forn(j, n)
		if(dis[i][j] <= L) dis1[i][j] = 1; 
	forn(k, n) forn(i, n) forn(j, n)
			if(dis1[i][j] > dis1[i][k] + dis1[k][j])
				dis1[i][j] = dis1[i][k] + dis1[k][j];
	cin >> q; 
	while(q--) {
		memset(put, 0, sizeof(put));
		int s, t;
		cin >> s >> t;
		if(dis1[s][t] == 0x3f3f3f3f3f3f3f3fll) {
			puts("-1");
			continue;
		}
		cout << dis1[s][t] - 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
	int i, j, n;
	int G[100][100];
	int u, k, v;

	scanf("%d", &n);

	//?????????
	for (i = 0; i < n; i++){
		for (j = 0; j < n; j++){
			G[i][j] = 0;
		}
	}

	//??£??\?????????1?????£??\
	for (i = 0; i < n; i++){
		scanf("%d %d ", &u, &k);
		for (j = 0; j < k; j++){
			scanf("%d ", &v);
			G[u-1][v-1] = 1;
		}
	}

	//??£??\???????????????
	for (i = 0; i < n; i++){
		for (j = 0; j < n-1; j++){
			printf("%d ", G[i][j]);
		}
		printf("%d\n", G[i][j]);
	}

	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[17][1<<16];
ll N, M;
ll A[16];

ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> N >> M;
    for(int i = M - 1; i >= 0; i--) cin >> A[i];
    dp[0][0] = 1;
    for(int i = 0; i < M; i++) {
        for(int bits = 0; bits < (1 << N); bits++) {
            if(dp[i][bits] == 0) continue;
            //cerr << i << " " << bits << " " << dp[i][bits] << endl;
            for(int j = 0; j < N; j++) {
                if(bits & (1 << j)) continue;
                ll Rest = ((1<<N) - A[i]) - bits;
                if(Rest < 0) continue;
                ll choise = beki(2, j) - 1;
                ll factor = combination(Rest, choise);
                factor *= Factorial[choise+1];
                factor %= mod;
                dp[i+1][bits|(1<<j)] += dp[i][bits] * factor;
                dp[i+1][bits|(1<<j)] %= mod;
            }
            dp[i+1][bits] += dp[i][bits];
            dp[i+1][bits] %= mod;
        }
    }
    ll ans = 0;
    for(int bits = 0; bits < (1 << N); bits++) {
        dp[M][bits] *= Factorial[(1<<N) - 1 - bits];
        dp[M][bits] %= mod;
        //cerr << M << " " << bits << " " << dp[M][bits] << endl;
        if(__builtin_parity(bits)) ans -= dp[M][bits];
        else ans += dp[M][bits];
    }
    ans %= mod;
    ans += mod;
    ans %= mod;
    ans *= (1 << N);
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 243328
def solve(brd, list)
  if list.all?{|v| v}
    brd.map{ |bs| puts bs.map{ |b| b ? '.' : 'Q' }.join }
    return
  end
  y = list.index{|v| !v}
  (0..7).each do |x|
    if brd[y][x] && check(y, x, brd)
      brd[y][x] = false
      list[y] = true
      solve(brd, list)
      list[y] = false
      brd[y][x] = true
    end
  end
end

def check(y, x, brd)
  (1..7).each do |i|
    (-1..1).each do |dy|
      (-1..1).each do |dx|
        next if dy == 0 && dx == 0
        ny = y + dy * i
        nx = x + dx * i
        if 0 <= ny && ny < 8 && 0 <= nx && nx < 8
          return false unless brd[ny][nx]
        end
      end
    end
  end
  true
end

brd = 8.times.map{ [true] * 8 }
list = [false] * 8
gets.to_i.times do
  r, c = gets.split.map(&:to_i)
  list[r] = true
  brd[r][c] = false
end

solve(brd, list)

Measured memory_bytes: 8768
exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

def ser(i,c)
  @table[i] = c
  @ctable[c] += 1
  @link[i].each do |ni|
    ser(ni,c) if @table[ni] == nil
  end
end

n,m,k =inp
link = na2(n+1,0)
m.times do |i|
  a,b = inp
  link[a].push(b)
  link[b].push(a)
end
@link = link
table = na(n+1,nil)
@table = table
c = 0
@ctable = na(n)
(1..n).each do |i|
  if table[i] == nil
    ser(i, c)
    c += 1
  end
end
ans = na(n,0)
n.times do |i|
  ans[i] = @ctable[@table[i+1]] - @link[i+1].size - 1
end
k.times do
  c,d = inp
  if @table[c] == @table[d]
    ans[c-1] -= 1
    ans[d-1] -= 1
  end
end
puts ans.join(" ")

Measured memory_bytes: 74284
/*
  第4回ユニリタプログラミングコンテスト～練習サイト～
  C言語用
  ファイル名 qA.c
  作成者 228 金子幸裕 2017/06/14 12:30
  ※long long 型 は 旧式のコンパイラでは対応していない
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    long long int nn, na, nb;
    long long int nmax, nmin;
    long long int nanswer;

    scanf( "%lld %lld %lld" , &nn, &na, &nb );

    nmax = na *          1 + nb * ( nn - 1 );
    nmin = na * ( nn - 1 ) + nb * 1;
    
    nanswer = nmax - nmin + 1;
    
    if ( nn == 1 && nb - na > 0   )
    {
        nanswer = 0;
    }

    if ( nb - na < 0 )
    {
        nanswer = 0;
    }

    printf("%lld", nanswer);

    printf("\n");

    return ( 0 );

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}

int main () {
  int n, m;
  cin >> n >> m;
  vi x(m);
  rep(i,m) cin >> x[i];
  
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(x.begin(), x.end());
  vi d(m-1);
  rep(i,m-1) d[i] = x[i+1] - x[i];
  sort(d.begin(), d.end());
  rep(i,n-1) d.pop_back();
  int ans = SUM(d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int num = 0;
		int ans = 0;
		for(int i = 1; i < 6; i++) {
			num = scan.nextInt();
			if(num == 0) {
				ans = i;
			}
		}
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a[3][3], c[3][3];
   for (int j = 0; j < 3; j++)
   {
      for (int k = 0; k < 3; k++)
      {
         cin >> a[j][k];
      }
   }
   int n;
   cin >> n;
   int b[n];
   for (int j = 0; j < 3; j++)
   {
      for (int k = 0; k < 3; k++)
      {
         c[j][k] = 0;
      }
   }

   for (int i = 0; i < n; i++)
   {
      cin >> b[i];
      for (int j = 0; j < 3; j++)
      {
         for (int k = 0; k < 3; k++)
         {
            if (a[j][k] == b[i])
            {
               c[j][k] = 1;
            }
         }
      }
   }
   int flag = 0;
   for (int i = 0; i < 3; i++)
   {
      for (int j = 0; j < 3; j++)
      {
         if (c[i][j] == 0)
         {
            flag = 1;
         }
      }
      if (!flag)
      {
         cout << "Yes" << endl;
         return 0;
      }
      flag = 0;
   }
   flag = 0;
   for (int i = 0; i < 3; i++)
   {
      for (int j = 0; j < 3; j++)
      {
         if (c[j][i] == 0)
         {
            flag = 1;
         }
      }
      if (!flag)
      {
         cout << "Yes" << endl;
         return 0;
      }
      flag = 0;
   }
   flag = 0;
   if (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1)
   {
      cout << "Yes" << endl;
      return 0;
   }
   if (c[2][0] == 1 && c[1][1] == 1 && c[0][2] == 1)
   {
      cout << "Yes" << endl;
      return 0;
   }
   cout << "No" << endl;
}

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

int n, c = 1;
int main()
{
	int i, t;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &t);
		if (c == t) c++;
	}
	if (c == 1) puts("-1");
    else cout << n - c + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	ll A[100000];
	ll B[100000];
	
	ll ASum = 0;
	ll BSum = 0;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		ASum += A[i];
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
		BSum += B[i];
	}
	
	if(BSum > ASum){
		cout << -1 << endl;
		return 0;
	}
	else if(BSum == ASum){
		cout << 0 << endl;
		return 0;
	}
	
	ll Diff[100000];
	for(int i = 0; i < N; i++){
		Diff[i] = A[i] - B[i];
	}
	
	ll remain = ASum - BSum;
	sort(Diff, Diff+N);
	
	int ans = 0;
	for(int i = 0; i < N; i++){
		if(Diff[i] >= 0 && Diff[i] <= remain){
			remain -= Diff[i];
		}else{
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
w a b
 */
int w,a,b;

int main(){
  cin>>w>>a>>b;
  cout<< max(max(b-(a+w),0), max(a-(b+w),0))<<endl;

  return 0;
}


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 rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
    vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c=0;
  rep(i,a){
  if(c<b[i])
    c=b[i];
    if(c-b[i]>=2){
      cout<<"No";
      return 0;
      }
  }
  cout<<"Yes";
}

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



int main() {
    using vi = vector<int>;
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    long x = 0;
    while(true){
        if(x%2==0){
            c-=b;
        }else{
            a-=d;
        }
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        if(a<=0){
            cout << "No" << endl;
            break;
        }
        x++;
    }
}

Measured memory_bytes: 3596
def check_yy(a, b):
    if a == "0":
        if b == "0":
            return True
    elif a == "1":
        if b in ["3", "4", "5", "6", "7", "8", "9"]:
            return True
    elif a in ["2", "3", "4", "5", "6", "7", "8", "9"]:
        return True
    return False


S = input()

if check_yy(S[0], S[1]):
    if check_yy(S[2], S[3]):
        print("NA")
    else:
        print("YYMM")
elif check_yy(S[2], S[3]):
    print("MMYY")
else:
    print("AMBIGUOUS")


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> edge;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

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

  int N = 1;
  int L_ = L;
  while(L_ >>= 1) N++;
  vector<edge> edges;
  repi(i, 1, N){
    edges.emplace_back(i, i+1, 0);
    edges.emplace_back(i, i+1, 1 << (i-1));
  }

  L_ = L;
  repi(i, 1, N){
    if(L_ % 2) edges.emplace_back(i, N, (L_-1) << (i-1));
    L_ >>= 1;
  }
  printf("%d %d\n", N, (int)edges.size());
  for(auto it = edges.begin(); it != edges.end(); ++it){
    printf("%d %d %d\n", get<0>(*it), get<1>(*it), get<2>(*it));
  }
  return 0;
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}
// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  int n;
  cin >> n;
  n = n%10;
  switch (n) {
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN
	
	int n, i, b;
	cin >> n;
	vi ns(n + 1);
	for (i = 1; i < n; i++) {
		cin >> b;
		ns[b]++;
	}
	for (i = 1; i <= n; i++)
		cout << ns[i] << "\n";
		
	return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 200000 + 5;
int a[100];

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		string s;
		stringstream ss;
		ss << i;
		ss >> s;
		int l = s.length();
		a[(s[0] - '0')*10 + (s[l-1] - '0')]++;
	}
	int sum = 0;
	for(int i = 1; i <= 9; ++i){
		for(int j = i; j <= 9; ++j){
			if(i == j)
				sum += a[i*10+j]*a[i*10+j];
			else
				sum += a[i*10+j]*a[j*10+i]*2;
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
fun main() = ABC168B.main()

object ABC168B {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val K= readInt()
        val S= readString()

        val ans = if(S.length <= K) S
        else S.take(K) + "..."

        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

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

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

Measured memory_bytes: 256
# coding: utf-8
N= int(input())
A=list(map(int,input().split()))

cA = [A[-1]]

MOD = 10**9+7

for i in range(N-1):
    cA.append(cA[-1]+A[-2-i])

ans=0
cA.reverse()


for i in range(N-1):
    ans+=A[i]*cA[i+1]
    ans=ans%MOD
    
print(ans)

Measured memory_bytes: 31436
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
template <typename T> mint modpow(T x, ll n) {
    mint res = 1;
    mint a = x;
    while(n > 0) {
        if(n & 1)
            res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    vector<mint> kosuu(k + 1);
    for(ll i = k; i > 0; i--) {
        mint a = k / i;
        a = modpow(a, n);
        for(ll j = 2; j * i <= k; j++) {
            a -= kosuu[i * j];
        }

        kosuu[i] = a;
    }

    mint ans = 0;
    rep(i, k) { ans += kosuu[i + 1] * (i + 1); }

    cout << ans.a << endl;
}

Measured memory_bytes: 3992
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int a[] = new int[n];
    for(int i = 0; i < n; i++) {
      a[Integer.parseInt(sc.next())-1] = i+1;
    }
    for(int i = 0; i < n; i++) {
      System.out.print(a[i] + " ");
    }
  }
}

Measured memory_bytes: 49192
#include<stdio.h>

int main(void)
{
  char S[20];
  scanf("%s",&S);
  
  if(S[0] == 'S')
  {
    printf("Cloudy\n");
  }
  else if(S[0] == 'C')
  {
    printf("Rainy\n");
  }
  else if(S[0] == 'R')
  {
    printf("Sunny\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
K = int(input())
import math
g = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i == j and j == k:
                g += math.gcd(math.gcd(i,j),k)
            elif i == j and j != k:
                g += math.gcd(math.gcd(i,j),k) * 3
            elif i != j and j == k:
                g += math.gcd(math.gcd(i,j),k) * 3
            else:
                g += math.gcd(math.gcd(i,j),k) * 6


print(g)


Measured memory_bytes: 9144