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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n,m;
ll cnt[111111];
vector<ll> mod[111111];
bool used[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n){
		ll x;
		cin>>x;
		mod[x%m].pb(x);
		cnt[x]++;
	}
	rep(i,m){
		sort(all(mod[i]));
	}
	ll res=mod[0].size()/2;
	repl(i,1,m/2+1){
		ll add;
		if(i!=m-i)add=min(mod[i].size(),mod[m-i].size());
		else{
			res+=mod[i].size()/2;
			continue;
		}
		res+=add;
		ll pnum=0,bnum=0;
		rep(j,mod[i].size()){
			if(used[mod[i][j]])continue;
			used[mod[i][j]]=true;
			pnum+=cnt[mod[i][j]]/2;
			bnum+=cnt[mod[i][j]]%2;
		}
		if(add-bnum>0){
			res+=max(0LL,(pnum*2-(add-bnum))/2);
		}else{
			res+=pnum;
		}
		if(i!=m-i){
			pnum=0,bnum=0;
			rep(j,mod[m-i].size()){
				if(used[mod[m-i][j]])continue;
				used[mod[m-i][j]]=true;
				pnum+=cnt[mod[m-i][j]]/2;
				bnum+=cnt[mod[m-i][j]]%2;
			}
			if(add-bnum>0){
				res+=max(0LL,(pnum*2-(add-bnum))/2);
			}else{
				res+=pnum;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long l;
int main(void) {
    int n; cin >> n;
    l now = 100000;
    for(int r = 0; r < n; r++) {
        now += now / 20; //5/100を掛けるので
        //もし1000円未満が0でなければ、繰り上げを行う。
        if(now % 1000 != 0) now = now - (now % 1000) + 1000;
    }
    cout << now << endl;
    return(0);
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  ll n_a=(n-1)/a;
  ll n_b=(n-1)/b;
  ll n_c=(n-1)/c;
  ll n_d=(n-1)/d;
  ll n_e=(n-1)/e;
  ll ans=max(n_a,max(n_b,max(n_c,max(n_d,n_e))))+5;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
    }
    if a > 8 || b > 8 {
        println!("{}", ":(");
    } else {
        println!("{}", "Yay!");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];
char a[100][100],b[100][100];

int main(){
  cin >> n >> m;
  rep(i,0,n){
    rep(j,0,n){
      cin >> a[i][j];
    }
  }
  rep(i,0,m){
    rep(j,0,m){
      cin >> b[i][j];
    }
  }
  s = "No";
  rep(i,0,n){
    rep(j,0,n){
      l = 0;
      rep(k,0,m){
        rep(p,0,m){
          if(a[i+k][j+p] == b[k][p])l++;
        }
      }
      if(l == m*m)s = "Yes";
    }
  }
  print(s);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<vector<int> >in(a+1);
  rep(i,a)rep(j,b){
    int tmp;cin>>tmp;
    in[i].pb(tmp);
  }
  rep(i,b){
    int sum=0;
    rep(j,a)sum+=in[j][i];
    in[a].pb(sum);
  }
  rep(i,a+1){
    int sum=0;
    rep(j,b)sum+=in[i][j];
    in[i].pb(sum);
  }

  rep(i,a+1){
    bool h=false;
    rep(j,b+1){
      if(h)cout<<" ";
      cout<<in[i][j];
      h=true;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1272
/*
 ABC-166
 */
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int N=300005;


void solve()
{
    int n,k;
    cin>>n>>k;
    int cnt[n+1]={0};int d,x;
    for(int i=0;i<k;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>x;
            cnt[x]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(!cnt[i])
            ans++;
    cout<<ans<<endl;

}

int32_t main()
{
    IOS;
    // startTime=clock();
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    // cout<<getCurrentTime()<<endl;
    return 0;
}



Measured memory_bytes: 3648
using System;
using System.Linq;

namespace Graph_II
{
    class Single_Source_Shortest_Path_I
    {
        struct Edge
        {
            public int to;
            public int cost;
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var graph = new Edge[n][];

            for (int i = 0; i < n; i++)
                graph[i] = Console.ReadLine().Trim(' ').Split(' ')
                    .Skip(2)
                    .Select((s, index) => new { val = int.Parse(s), index})
                    .GroupBy(x => x.index / 2)
                    .Select(group => group.Select(g => g.val))
                    .Select(vc => new Edge { to = vc.First(), cost = vc.Last() })
                    .ToArray();

            var used = new bool[n];
            var mincost = Enumerable.Repeat(int.MaxValue, n).ToArray();
            mincost[0] = 0;

            while (true)
            {
                var v = -1;
                for (int i = 0; i < n; i++)
                    if (!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;

                if (v == -1) break;
                used[v] = true;

                for (int i = 0; i < graph[v].Length; i++)
                    mincost[graph[v][i].to] = Math.Min(mincost[graph[v][i].to], mincost[v] + graph[v][i].cost);
            }

            for (int i = 0; i < mincost.Length; i++)
                Console.WriteLine($"{i} {mincost[i]}");
        }
    }
}



Measured memory_bytes: 46760
X = int(input())
beki=[]
for a in range(X):
    A=a+1
    for i in range(32):
        I=i+1
        j=0
        for j in range(9):
            J=j+2
            if A == I**J:
                beki.append(A)
                break
            elif A<I**J:
                break
print(max(beki))

Measured memory_bytes: 3060
/******************************************
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fin for(int i = 0; i < n; i++)
#define fiab for(int i=a;i<b;i++)
#define fi1b for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
  int n,wt;
cin>>n>>wt;
LL w[n],v[n];
LL dp[n+5][wt+5]={0};
fin{
	cin>>w[i]>>v[i];
} 	for(int j=0;j<=wt;j++){
		fin{
			if(j==0){
				dp[i][j]=0;
			}
			if(i==0){
				if(w[i]>j){
					dp[i][j]=0;
				}else{
					dp[i][j]=v[i];
				}
			}else{
				if(j>w[i]){
				dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
			}else dp[i][j]=dp[i-1][j];
		}
		}
}cout<<dp[n-1][wt]<<endl;

return 0;
}

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

typedef long long ll;

ll mod=1e9+7;

int main(){
  ll n,m;
  cin >> n >> m;
  ll a[n],b[m],c[m];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<m;i++) cin >> b[i] >> c[i];
  sort(a,a+n);
  ll sum[m];
  for(int i=0;i<m;i++){
    sum[i]=b[i]+c[i]*mod;
  }
  sort(sum,sum+m);
  reverse(sum,sum+m);
  for(int i=0;i<m;i++){
    b[i]=sum[i]%mod;
    c[i]=sum[i]/mod;
  }
  ll t=0;
  for(int i=0;i<n;i++){
    if(b[t]==0) t++;
    if(t>=m) break;
    if(b[t]>0){
      if(a[i]<c[t]){
        a[i]=c[t];
        b[t]--;
      }
    }
    //cout << t << " " << b[t] << endl;
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=a[i];
    //cout << a[i] << " ";
  }
  cout << ans << endl;
}

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

namespace ConsoleApp15
{
    class Class368
    {
        static void Main()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = NM[0], M = NM[1];
            var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            var uni = new Union_Find(N);
            for (int i = 0; i < M; i++)
            {
                var r = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                uni.Unite(--r[0], --r[1]);
            }
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (uni.IsSameGroup(--p[i], i))
                    count++;
            }
            Console.WriteLine(count);
        }
    }

    public class Union_Find
    {
        private int[] data;
        public Union_Find()
        {
            int size = 200000;
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public Union_Find(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }
        public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
        public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
        public int getMem(int x) => -data[Root(x)];
    }
}


Measured memory_bytes: 24540
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    string in;
    cin>>in;
    int ans=0;
    for(int i=0,j=in.length()-1;i<in.length()/2;i++,j--){
        if(in[i]!=in[j]){
            ans++;
        }
    }
    cout<<ans<<endl;
}



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

int top, S[1000];

void push(int x) {
  top++;
  S[top] = x;
}

int pop() {
  top--;
  return S[top + 1];
}

int main() {
  int a, b;
  top = 0;
  char s[100];
  while( scanf("%s", s) != EOF ) {
    if ( s[0] == '+' ) {
      a = pop();
      b = pop();
      push(a + b);
    } else if ( s[0] == '-' ) {
      b = pop();
      a = pop();
      push(a - b);
    } else if ( s[0] == '*' ) {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  
  printf("%d\n", pop());

  return 0;
}


Measured memory_bytes: 2704
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> set = new HashSet<>();
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 76956
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

int main(){
  char a,b;
  cin >> a >> b;
  char c;
  if(a>b)c='>';
  else if(a==b)c='=';
  else c='<';
  printf("%c\n",c);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
 
typedef long long int64;
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
const int INF = 1 << 30;

int get_dist(int x1, int y1, int x2, int y2){ //(x1, y1)の方が(x2, y2)より大きいこと
  return max(x1 - x2, y1 - y2);
}
int main()
{
  int N;
  scanf("%d", &N);
  vector< int > x(N), y(N);

  // (x1,y1) と(x2,y2)のマンハッタン距離
  // |x1 - x2| + |y1 - y2|

  // 以下の中の最大値
  // -(x1 - y1) - (x2 + y2)
  // -(x1 + y1) + (x2 + y2)
  // (x1 + y1) - (x2 + y2)
  // (x1 - y1) + (x2 + y2)

  // (x - y) と (x + y)

  for(int i = 0; i < N; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    x[i] = a - b, y[i] = a + b;
  }

  int xlow = *min_element(ALL(x)), xhigh = *max_element(ALL(x));
  int ylow = *min_element(ALL(y)), yhigh = *max_element(ALL(y));

  int ret = 0, res = 0;
  for(int i = 0; i < N; i++){
    ret = max( ret, min( get_dist( x[i], y[i], xlow, ylow), get_dist( xhigh, yhigh, x[i], y[i])));
  }
  for(int i = 0; i < N; i++){
    res = max( res, min( get_dist( x[i], yhigh, xlow, y[i]), get_dist( xhigh, y[i], x[i], ylow)));
  }


  cout << min(ret, res) << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define MAX 1000000009
#define For(i, a, b) for( ll i = (a); i < (b); i++ )
#define ll long long
using namespace std;

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

    ll x,y,a,b,r;
    cin>>x>>y>>a>>b>>r;

    vector<ll> va, vb, vr;
    
    ll t;
    
    For(i,0,a){
      cin>>t;
      va.push_back(t);
    } 

    For(i,0,b){
      cin>>t;
      vb.push_back(t);
    }
     
    For(i,0,r){
      cin>>t;
      vr.push_back(t);
    }


    sort(va.begin(), va.end()); reverse(va.begin(), va.end());
    sort(vb.begin(), vb.end()); reverse(vb.begin(), vb.end());
    sort(vr.begin(), vr.end()); reverse(vr.begin(), vr.end());

    vector<ll> vc;

    For(i,0,x)vc.push_back(va[i]);
    For(i,0,y)vc.push_back(vb[i]);
    For(i,0,min(r,(x+y)))vc.push_back(vr[i]);

    sort(vc.begin(), vc.end()); reverse(vc.begin(), vc.end());
    ll sum = 0;
    For(i,0,(x+y)) sum += vc[i];

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 8816
#include <stdio.h>

#define max(x, y) (((x) > (y)) ? (x) : (y))

int solv(int n) {
  int i, j, res = 0, abc[100000][3], p[3], t[3];

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

  // 最初の選択
  for (i = 0; i < 3; i++) {
    p[0] = p[1] = p[2] = 0;
    // n 日繰り返す
    for (j = 0; j < n; j++) {
      t[0] = max(p[1] + abc[j][0], p[2] + abc[j][0]);
      t[1] = max(p[0] + abc[j][1], p[2] + abc[j][1]);
      t[2] = max(p[0] + abc[j][2], p[1] + abc[j][2]);
      p[0] = t[0];
      p[1] = t[1];
      p[2] = t[2];
    }

    for (j = 0; j < 3; j++) {
      res = max(res, p[j]);
    }
  }

  return res;
}

int main(int argc, char **argv) {
  int n;

  while (scanf("%d", &n) != EOF) {
    printf("%d\n", solv(n));
  }

  return 0;
}


Measured memory_bytes: 1280
n,m = map(int,input().split())
AC = [0]*n
WA = [0]*n
ans = 0
for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s == "AC" and AC[p] == 0:
        AC[p] = 1
        ans += WA[p]
    WA[p] += 1
print(sum(AC),ans)

Measured memory_bytes: 10440
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
vector<ll> r(3);
FOR(3)cin>>r[i];
sort(ALL(r));
reverse(ALL(r));
cout<<r[0]*10+r[1]+r[2]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 17;
const int L = 32775;
const int INF = 2e+9;

int f[L][N],val[L];
int n,m;
struct edge{
	int x,y,l;
}e[N*N];
int d[N][N];

int main(){
	n=get();m=get();
	int sum=0;
	fo(i,1,m){
		e[i].x=get();e[i].y=get();e[i].l=get();
		sum+=e[i].l;
		d[e[i].x][e[i].y]=d[e[i].y][e[i].x]=e[i].l;
	}
	fo(t,1,(1<<n)-1){
		fo(i,1,m)
		if (((1<<(e[i].x-1))&t)>0&&((1<<(e[i].y-1))&t)>0)val[t]+=e[i].l;
	}
	fo(t,0,(1<<n)-1)fo(x,1,n)f[t][x]=-1;
	fo(t,1,(1<<(n-1))-1)
	if (t&1)f[t][1]=val[t];
	fo(t,1,(1<<n)-1)
		fo(x,1,n)
		if (f[t][x]>-1){
			int u=((1<<n)-1)^t;
			int p=u;
			for(;u;u=(u-1)&p){
				fo(y,1,n)
				if (((1<<(y-1))&u)>0&&d[x][y])f[t^u][y]=max(f[t^u][y],f[t][x]+d[x][y]+val[u]);
			}
		}
	printf("%d\n",sum-f[(1<<n)-1][n]);
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

using namespace std;

void solution()
{
    int64_t x,k,d;
    cin >> x >> k >> d;
    const auto [quot, rem] = div(abs(x), d);
    if(quot > k){
        cout << (abs(x) - d*k) << '\n';
        return;
    }
    k -= quot;
    x = x < 0 ? -rem : rem;
    if(k % 2 == 0){
        cout << abs(x) << '\n';
    }else{
        cout << min(abs(x+d), abs(x-d)) << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  ll N, M, H, A, B;
  cin >> N >> M;
  vector<ll> H_vec;
  vector<bool> ret_vec;
  H_vec.reserve(N);
  ret_vec.reserve(N);
  for (auto i = 0;i < N;i ++) {
    cin >> H;
    H_vec.push_back(H);
    ret_vec.push_back(true);
  }
  for (auto i = 0;i < M;i ++) {
    cin >> A >> B;
    A --;
    B --;
    ret_vec[A] = ret_vec[A] && (H_vec[A] > H_vec[B]);
    ret_vec[B] = ret_vec[B] && (H_vec[A] < H_vec[B]);
  }
  ll ret = 0;
  for (auto i = 0;i < N;i ++) {
    if (ret_vec[i]) {
      ret ++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 4052
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e14+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int n,i;cin>>n;
	if(n==0){return false;}
	vector<int>oya(n);
	vector<llint>len(n);
	vector<llint>sai(n);
	vector<bool>ha(n,true);
	for(i=1;i<n;i++){cin>>oya[i];}
	for(i=1;i<n;i++){cin>>len[i];oya[i]--;if(i>1){ha[oya[i]]=false;}}
	llint tyo=0,ans=0;
	if(ha[0]){ans-=len[1]*2;sai[0]=-big;}
	for(i=n-1;i>0;i--){
		if(ha[i]){ans+=len[i];continue;}
		ans+=len[i]*3;
		sai[i]+=len[i];
		maxeq(tyo,sai[i]+sai[oya[i]]);
		maxeq(sai[oya[i]],sai[i]);
	}
	cout<<ans-tyo<<endl;
	return true;
}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3212
// https://atcoder.jp/contests/abc128/tasks/abc128_c
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

  vector<vector<int>> s;
  vector<int> p(m);

  rep(i, m) {
    int k;
    cin >> k;
    vector<int> si(k);
    rep(j, k) {
      cin >> si[j];
    }
    s.push_back(si);
  }
  rep(i, m) {
    cin >> p[i];
  }

  auto is_all_on = [&](int flg) {
    rep(i, m) {
      auto si = s[i];
      int cnt = 0;
      for(auto sw : si) {
        if(flg & (1 << (sw-1))) {
          cnt++;
        }
      }
      // cout << "flg: " << flg << ", i: " << i << ", cnt: " << cnt << endl;
      if(cnt % 2 != p[i]) {
        return false;
      }
    }
    return true;
  };

  int ans = 0;
  for(int bit=0;bit<(1<<n);++bit) {
    if(is_all_on(bit)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define p pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<d;
#define OUTL(d) cout<<d; BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))
 
ll gcd(ll x, ll y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

ll lcm(ll x, ll y){
    return x * (y / gcd(x, y));
}

signed main(){ INIT;
    ll x, y;
    while(cin >> x){
        cin >> y;
        OUT(gcd(x, y)); SP; OUTL(lcm(x, y));
    }
RET;}

Measured memory_bytes: 3088
//Author : Gaara

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

#define ll long long
#define pb push_back
#define endl "\n"
#define fo(i,n) for(ll i=0;i<n;i++)
#define ro(i,n) for(ll j=n-1;i>=0;i--)
#define vll vector<long long>
#define mod 1000000007
#define MAX 200000

vector<vector<int>> adj(MAX+1);
bool visited[MAX+1];
int x=0;

void dfs(int s, int e){
	visited[s]=true;
	x++;
	for(auto u:adj[s]){
		if(visited[u]) continue;
		if(u!=e) dfs(u,s);
	}
	return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
		int n,m; cin>>n>>m;
		
		fo(i,m){
			int a,b;
			cin>>a>>b;
			adj[a].pb(b);
			adj[b].pb(a);
		}
		
		int ans=0;
		for(int i=1;i<=n;i++){
			if(visited[i]) continue;
			x=0;
			dfs(i,0);
			ans = max(ans,x);
		}

		cout<<ans<<"\n";
	}
    return 0;
}

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

int main()
{
    int a,b,c,d,e;
    cin >> a;
    b = a/1000;
    a = a%1000;
    c = a/100;
    a = a%100;
    d = a/10;
    a = a%10;
    e = a;
 
    if(b==c && c==d){
        cout << "Yes" << endl;
    }else if(c==d && d==e){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 

   
    return 0;
}


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

using namespace std;

int main() {

  int64_t K, S;
  cin >> K >> S;

  int64_t ans = 0;
  for(int64_t i=0;i<=K;i++)
    for(int64_t j=0;j<=K;j++)
      if(S - i - j <= K && S - i - j >= 0)
	ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())

m = 10**5+1
nums = [0]*m
ans = 0
for i in a:
  nums[i] += 1
  ans += i
  
for _ in range(q):
  b,c = map(int, input().split())
  ans -= b*nums[b]
  ans += c*nums[b]
  nums[c] += nums[b]
  nums[b] = 0
  print(ans)

Measured memory_bytes: 21200
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

 
int main()
{ 
	FIN;
	
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif
	
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	vector <bool> dp(k+1,false);
	forr(i,1,k+1)
	{
		forn(j,n)
		{
			if(i-v[j] < 0) continue;
			if(dp[i-v[j]] == false) dp[i]=true;
		}
	}
	if(dp[k]==true) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}


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



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

    #ifndef ONLINE_JUDGE   
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);   
    #endif   
  	
  	int n;
  	cin>>n;
  	char ch[5];

  	int a[4]={0};
  	char k;

  	for(int i=0;i<n;i++){
  		cin>>ch;
  		k = ch[0];
  		if(k=='A')
  			a[0]++;
  		else if(k == 'W')  
  			a[1]++;
  		else if(k == 'T')
  			a[2]++;
  		else if(k == 'R')
  			a[3]++;
  	}

  	cout<<"AC x "<<a[0];
  	cout<<"\nWA x "<<a[1];
  	cout<<"\nTLE x "<<a[2];
  	cout<<"\nRE x "<<a[3];
    



    
return 0;


}  

Measured memory_bytes: 3652
main = do
  s <- getLine
  putStrLn $ if heisei s <= 4 then "Heisei" else "TBD"

heisei ('2':'0':'1':'9':'/':'0':a:'/':_:_) = read [a]
heisei ('2':'0':'1':'9':'/':'1':a:'/':_:_) = 10 + read [a]


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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

int n,k;

int main(){
	scanf ("%d%d",&n,&k);
	REP(i,k){
		int a;
		scanf ("%d",&a);
		n-=a;
		if (n<0){
			puts ("-1");
			return 0;
		}
	}
	printf ("%d\n",n);
	
	return 0;
}


Measured memory_bytes: 3760
import Data.List

solver::[Int]->(Int,Int)
solver ls = let m:m':rest = sortBy (\ x -> \ y -> compare y x ) ls in
            if div m 2 == 0 then (m,find_even m m' rest)
                            else (m,find_odd  m m' rest)

--max list stored
find_even::Int -> Int -> [Int] -> Int
find_even m now [] = now
find_even m now (x:rest) = if (abs (x - (div m 2))) < (abs (now - (div m 2)))
                              then find_even m x rest
                              else find_even m now rest

find_odd ::Int -> Int -> [Int] -> Int
find_odd m now []  = now
find_odd m now (x:rest) = if (min (abs (x - (div (m+1) 2))) (abs (x - (div (m-1) 2)))) < (min (abs (now - (div (m+1) 2))) (abs (now - (div (m-1) 2))))
                              then find_odd m x rest
                              else find_odd m now rest

main::IO()
main=do
  _<-getLine
  d<-getLine
  let dat = map read (words d)
  let (a,b) = solver dat
  putStr ((show a)++" "++(show b)++"\n")


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

/* solve */

int main(){
    int n;
    cin >> n;
    ll a[200010];
    ll s[200010];
    ll tmp=0;
    map<ll,ll> mp;
    mp[0]++;
    s[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> a[i];
        s[i]=s[i-1]+a[i];
        mp[s[i]]++;
    }
    
    ll ans=0;
    set<ll> st;
    rep(i,n){
        st.insert(s[i]);
    }
    for(auto itr=st.begin();itr!=st.end();itr++){
        tmp=mp[*itr];
        if(tmp>1)
            ans+=tmp*(tmp-1)/2;
    }
    cout << ans;
}


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

	// 解くだけゲー
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();

			double a = (x1 * x1) - (x2 * x2);
			double b = 2 * (x2 - x1);
			double c = (y1 * y1) - (y2 * y2);
			double d = 2 * (y2 - y1);

			double e = (x1 * x1) - (x3 * x3);
			double f = 2 * (x3 - x1);
			double g = (y1 * y1) - (y3 * y3);
			double h = 2 * (y3 - y1);

			// 円の中心座標cx,cy
			double cx = (d * (g + e) - h * (a + c)) / (b * h - (d * f));
			double cy = (b * (g + e) - f * (a + c)) / (d * f - (b * h));

			// 円の半径r
			double r = Math.sqrt(((x1 - cx) * (x1 - cx)) + ((y1 - cy) * (y1 - cy)));

			// cx =roundOff(cx);
			// cy =roundOff(cy);
			// r =roundOff(r);

			System.out.printf("%.3f %.3f %.3f\n", cx, cy, r);

		}

		sc.close();

	}

	double roundOff(double a) {

		double b = a * 1000;

		double c = b % 10;

		//
		if (c == 0) {
			return a;
		}

		// 四捨五入
		if (c >= 5) {
			b += 10 - c;
		} else {
			b -= c;
		}

		return b / 1000;
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 20788
#include<iostream>
#include<string>
using namespace std;
int main(){
 string a,b;
 cin>>a>>b;
 string c= a+b;
 int x=stoi(c);

 int i=0;
 string ans="No";
 while(i*i<=x){
  if(i*i==x){
   ans="Yes";
  }
  i++;
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 512
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

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

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
    string N;
    cin >> N;
    ll d = N.back() - '0';
    if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) {
        cout << "hon" << endl;
    } else if (d == 0 || d == 1 || d == 6 || d == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    string s;
    cin >>s;
    s[3]='8';
    cout <<s;

    return 0;
}





Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

var mod int64 = 1000000007

func modPow2(num int64) int64 {
	if num == 0 {
		return 1
	}

	var rtn int64
	rtn = 1
	var i int64
	for i = 0; i < num; i++ {
		rtn = (rtn << 1) % mod
	}
	return rtn
}

func main() {
	N := getStdinInt64()
	hash1 := make(map[string]int64)
	hash2 := make(map[string]string)
	var zero int64 = 0
	var i int64
	for i = 0; i < N; i++ {
		list := getStdinIntArr64()
		A := list[0]
		B := list[1]
		if A == 0 && B == 0 {
			zero++
		} else if B == 0 {
			hash1["1/0"]++
			hash2["1/0"] = "0/1"
		} else if A == 0 {
			hash1["0/1"]++
			hash2["0/1"] = "1/0"
		} else {
			rat1 := big.NewRat(A, B)
			rat2 := big.NewRat(-B, A)
			hash1[fmt.Sprint(rat1)]++
			hash2[fmt.Sprint(rat1)] = fmt.Sprint(rat2)
		}
	}

	var ans int64 = 1
	for idx, val1 := range hash1 {
		if val1 == -1 {
			continue
		}
		var val2 int64 = hash1[hash2[idx]] // 仲の悪い相方
		var tmp1 int64 = (modPow2(val1) - 1) % mod
		var tmp2 int64 = (modPow2(val2) - 1) % mod
		var tmp3 int64 = 1
		hash1[idx] = -1 // 重複を避ける
		hash1[hash2[idx]] = -1
		ans = (ans * (tmp1 + tmp2 + tmp3)) % mod
	}
	if (ans + zero - 1) > 0 {
		ans = (ans + zero - 1) % mod
	} else {
		ans = (ans + zero + mod - 1) % mod
	}
	fmt.Printf("%d", ans)

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinInt64() int64 {
	sc.Scan()
	rtn, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}


Measured memory_bytes: 108332
#include <stdio.h>
#include <stdlib.h>
int VAR00 , VAR01 , VAR02 ;

struct STRUCT00 {
  int MEMBER00 ;
  struct STRUCT00 * MEMBER01 ;
} ;

struct STRUCT01 {
  int MEMBER02 ;
  int MEMBER03 ;
  struct STRUCT00 * MEMBER04 ;
} ;

struct STRUCT01 VAR03 [ 100000 ] ;

void FUNC00 ( ) {
  for ( int VAR04 = 0 ; VAR04 < VAR00 ; VAR04 ++ ) {
    VAR03 [ VAR04 ] . MEMBER02 = 0 ;
    VAR03 [ VAR04 ] . MEMBER03 = -1 ;
  }
}

void FUNC01 ( int ARG00 , int ARG01 ) {
  int VAR05 ;
  struct STRUCT00 * VAR06 , * VAR07 ;
  VAR06 = ( struct STRUCT00 * ) malloc ( sizeof ( struct STRUCT00 ) ) ;
  VAR06 -> MEMBER00 = ARG01 ;
  if ( VAR03 [ ARG00 ] . MEMBER02 == 0 ) {
    VAR03 [ ARG00 ] . MEMBER04 = VAR06 ;
    VAR03 [ ARG00 ] . MEMBER02 ++ ;
  }
  else {
    VAR07 = VAR03 [ ARG00 ] . MEMBER04 ;
    VAR05 = VAR03 [ ARG00 ] . MEMBER02 - 1 ;
    while ( VAR05 -- ) {
      VAR07 = VAR07 -> MEMBER01 ;
    }
    VAR07 -> MEMBER01 = VAR06 ;
    VAR03 [ ARG00 ] . MEMBER02 ++ ;
  }
  VAR06 = ( struct STRUCT00 * ) malloc ( sizeof ( struct STRUCT00 ) ) ;
  VAR06 -> MEMBER00 = ARG00 ;
  if ( VAR03 [ ARG01 ] . MEMBER02 == 0 ) {
    VAR03 [ ARG01 ] . MEMBER04 = VAR06 ;
    VAR03 [ ARG01 ] . MEMBER02 ++ ;
  }
  else {
    VAR07 = VAR03 [ ARG01 ] . MEMBER04 ;
    VAR05 = VAR03 [ ARG01 ] . MEMBER02 - 1 ;
    while ( VAR05 -- ) {
      VAR07 = VAR07 -> MEMBER01 ;
    }
    VAR07 -> MEMBER01 = VAR06 ;
    VAR03 [ ARG01 ] . MEMBER02 ++ ;
  }
}

void FUNC02 ( ) {
  struct STRUCT00 * VAR08 ;
  for ( int VAR09 = 0 ; VAR09 < VAR00 ; VAR09 ++ ) {
    printf ( "node:%d" , VAR09 ) ;
    for ( int VAR10 = 0 ; VAR10 < VAR03 [ VAR09 ] . MEMBER02 ; VAR10 ++ ) {
      if ( VAR10 == 0 ) {
 VAR08 = VAR03 [ VAR09 ] . MEMBER04 ;
      }
      else {
 VAR08 = VAR08 -> MEMBER01 ;
      }
      printf ( " %d" , VAR08 -> MEMBER00 ) ;
    }
    printf ( "\n" ) ;
  }
}

void FUNC03 ( int ARG02 , int ARG03 ) {
  struct STRUCT00 * VAR11 ;
  for ( int VAR12 = 0 ; VAR12 < VAR03 [ ARG02 ] . MEMBER02 ; VAR12 ++ ) {
    if ( VAR12 == 0 )
      VAR11 = VAR03 [ ARG02 ] . MEMBER04 ;
    else
      VAR11 = VAR11 -> MEMBER01 ;
    if ( VAR03 [ VAR11 -> MEMBER00 ] . MEMBER03 == -1 ) {
      VAR03 [ VAR11 -> MEMBER00 ] . MEMBER03 = ARG03 ;
      FUNC03 ( VAR11 -> MEMBER00 , ARG03 ) ;
    }
  }
}

int main ( void ) {
  int VAR13 , VAR14 ;
  int VAR15 ;
  struct STRUCT00 * VAR16 , * VAR17 ;

  scanf ( "%d%d" , & VAR00 , & VAR01 ) ;
  FUNC00 ( ) ;
  for ( int VAR18 = 0 ; VAR18 < VAR01 ; VAR18 ++ ) {
    scanf ( "%d%d" , & VAR13 , & VAR14 ) ;
    FUNC01 ( VAR13 , VAR14 ) ;
  }


  for ( int VAR19 = 0 ; VAR19 < VAR00 ; VAR19 ++ ) {
    if ( VAR03 [ VAR19 ] . MEMBER03 == -1 ) {
      VAR03 [ VAR19 ] . MEMBER03 = VAR19 ;
      FUNC03 ( VAR19 , VAR19 ) ;
    }

  }

  scanf ( "%d" , & VAR02 ) ;
  for ( int VAR20 = 0 ; VAR20 < VAR02 ; VAR20 ++ ) {
    scanf ( "%d%d" , & VAR13 , & VAR14 ) ;
    if ( VAR03 [ VAR13 ] . MEMBER03 == VAR03 [ VAR14 ] . MEMBER03 )
      printf ( "yes\n" ) ;
    else
      printf ( "no\n" ) ;
  }

  return 0 ;
}


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

int main(void){
    int n,k; cin >> n >> k;

    map<int,ll> A;
    for(int i=1; i<=n; i++){
        if(i%k==0) A[1]++;
        if(k%2==0 && i%k==k/2) A[2]++;
    }

    cout << A[1]*A[1]*A[1]+A[2]*A[2]*A[2] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int* num;
    num = new int[N];
    for (int  i = 0; i < N; i++)
    {
        cin >> num[i];
    }
    int counter =0;
    for (int i = 1; i < N-1; i++)
    {
        if(num[i-1]<num[i]&&num[i]<num[i+1])counter++;
        else if(num[i+1]<num[i]&&num[i]<num[i-1])counter++;
    }
    cout << counter << endl;
    

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    if (s.length() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S,T;
    ll A,B;
    string U;
    cin >> S >> T >> A >> B >> U;
    
    if(S==U) A--;
    if(T==U) B--;
    cout << A << " " << B << endl;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    c = [0] * 4
    for num in map(int, input().split()):
        c[num] += 1
    dp = [[[0] * (N+2) for _ in range(N+2)] for _ in range(N+2)]
    for i3 in range(c[3]+1):
        for i2 in range(c[2]+c[3]-i3+1):
            for i1 in range(c[1]+c[2]+c[3]-i2-i3+1):
                try:
                    dp[i1][i2][i3] = (i1 * dp[i1-1][i2][i3] +
                                      i2 * dp[i1+1][i2-1][i3] +
                                      i3 * dp[i1][i2+1][i3-1] +
                                      N) / (i1+i2+i3)
                except IndexError:
                    continue
                except ZeroDivisionError:
                    continue

    print(dp[c[1]][c[2]][c[3]])


if __name__ == "__main__":
    main()


Measured memory_bytes: 608520