akhauriyash/Code-Regression huggingface dataset:
//2018年  3月 21日 水曜日 18:04:13 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, R;
ll G[210][210];

void solve() {
	cin >> N >> M >> R;
	vector<int> ord(R);
	rep(i, 0, R) {
		cin >> ord[i];
		ord[i]--;
	}
	sort(all(ord));

	rep(i, 0, N) {
		rep(j, 0, N) {
			if(i != j) G[i][j] = inf;
		}
	}
	rep(i, 0, M) {
		ll a, b, c;
		cin >> a >> b >> c; a--; b--;
		G[a][b] = c;
		G[b][a] = c;
	}
	rep(k, 0, N) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				MIN(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	ll res = inf;
	do {
		ll tmp = 0;
		rep(i, 0, R - 1) {
			int from = ord[i], to = ord[i + 1];
			tmp += G[from][to];
		}
		MIN(res, tmp);
	} while(next_permutation(all(ord)));
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
	char s[4];
	int i,a,c=0,x=0;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a-1;i++){
		for(int j=i+1;j<a;j++){
			if(s[i]==s[j]) c++;
		}
	}
	if(c==2) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

int selectionSort(int A[], int N){
  int i, j, sw = 0, t, minj;
  for(i = 0; i < N - 1; i ++){
    minj = i;
    for(j = i; j < N; j++){
      if( A[j] < A[minj])
        minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if(i != minj) sw++;
  }
  return sw;
}


int main(){
  int A[100], N, i, sw;
  cin >> N;
  for(i = 0; i < N; i++)
    cin >> A[i];

  sw = selectionSort(A,N);

  for(i = 0; i < N; i++){
    if( i > 0) cout << " " ;
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Measured memory_bytes: 3088
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  
  if(e-a>k) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
  
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll h, w;
ll solve(vector<string> &b, PII s, PII g){
   int cnt[b.size()][b[0].size()];
   memset(cnt, -1, sizeof(cnt));
   deque<PII> que;
   cnt[s.first][s.second] = 0;
   que.push_back(s);

   while(que.empty() == false){
     PII f = que.front();
     que.pop_front();
     rep(dir, 4) { 
       int ni = f.first + dy[dir];
       int nj = f.second + dx[dir];
       if (ni >= 0 && ni < h && nj >= 0 && nj < w && b[ni][nj] != '#' && cnt[ni][nj] == -1){
         cnt[ni][nj] = cnt[f.first][f.second] + 1;
         if (ni == g.first && nj == g.second) return cnt[ni][nj];
         que.push_back(PII(ni, nj));
       }
     }
   }
   return cnt[g.first][g.second];
}

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

  cin >> h >> w;
  vector<string> b(h);
  rep(i, h) cin >> b[i];
  ll ans = 0;
  rep(si, h) rep(sj, w) rep(gi, h) rep(gj, w) {
    if (b[si][sj] != '#' && b[gi][gj] != '#')
      ans = max(ans, solve(b, PII(si, sj), PII(gi, gj)));
  }
  cout << ans << endl;
  return 0;
}


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

int to[510][510];

void dfs(int left, int right, int v){
  
  if( right-left == 1 ){ return;}
 
  // [l,r)の区間をv以上の値でぬり分ける
  
  int mid = (left+right)/2;
  
  for(int i = left; i < mid; i++){
    for(int j = mid; j < right; j++){ 
      
      to[i][j] = v;
      
    }
  }
  
  dfs(left,mid,v+1);
  dfs(mid,right,v+1);
  
  return;
}
  
  
 

signed main(void){
  
  int N; cin >> N;
  
  dfs(0,N,1);//[0,N)の範囲を、1以上でぬり分ける
  
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      
      if( i == j ){ continue;}
      
      cout << to[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
} 

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define int long long
vector<vector<int> > adj((int)1e5);
vector<bool> visited((int)1e5, false);
void dfs(int v){
    if(visited[v]) return;
    visited[v] = true;
    for(int i=0; i<adj[v].size(); i++){
        if(!visited[adj[v][i]]){
            dfs(adj[v][i]);
        }
    }
}
signed main() {
    int n, m, i, j, u, v, z;
    int ans = 0;
    scanf("%lld %lld", &n, &m);
    for(i=1; i<=m; ++i){
        scanf("%lld %lld %lld", &u, &v, &z);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(i=1; i<=n; i++){
        if(!visited[i]){
            ans++;
            dfs(i);
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int n,m; cin >> n >> m;
    vl a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    auto c = convolution(a, b);
    rep(i,n+m-1){
        cout << c[i] << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 27232
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 30 ; i >= 0 ; i--){
        n = a.size();
        int cur = (1 << i);
        int l = 0, r = n - 1;
        vector <int> taken(n);
        while(l < r){
            if(a[l] + a[r] < cur) l++;
            else if(a[l] + a[r] > cur) r--;
            else{
                ans++;
                taken[l] = taken[r] = 1;
                l++; r--;
            }
        }
        vector <int> b;
        for(int i = 0 ; i < n ; i++){
            if(taken[i]) continue;
            b.push_back(a[i]);
        }
        a = b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            List<Integer> bestCosts = new ArrayList<>(Collections.nCopies(n, Integer.MAX_VALUE));
            List<Integer> heights = Stream.generate(new Supplier<Integer>() {

                public Integer get() {
                    return in.nextInt();
                }
            }).limit(n).collect(Collectors.toList());

            bestCosts.set(0, 0);
            for (int i = 0; i < n; i++) {
                for (int j : new int[]{i + 1, i + 2}) {
                    if (j < n) {
                        int cost = Math.abs(heights.get(i) - heights.get(j));
                        bestCosts.set(j, Math.min(bestCosts.get(j), bestCosts.get(i) + cost));
                    }
                }
            }

            out.println(bestCosts.get(n - 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 43432
// input macro
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)*}
    };
}

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

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

// body
fn main() {
    input! {
        l: usize,
        r: usize,
    };
    let mut ans = 2019;
    if r - l > 2019 {
        ans = 0;
    } else {
        for i in l..(r + 1) {
            for j in (i + 1)..(r + 1) {
                ans = std::cmp::min(ans, (i * j) % 2019);
            }
        }
    }
    println!("{}", ans);
}


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

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

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max() - 1;
constexpr auto llinf = numeric_limits<ll>().max() - 1LL;

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << endl;
}
template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

constexpr ll mod = ll(1e9 + 7);

ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }

ll power(ll a, ll b) {
	ll result = 1LL;
	while (b) {
		if (b % 2LL) result = mult(result, a);
		a = mult(a, a);
		b /= 2LL;
	}
	return result;
}

ll divide(ll a, ll b) { return mult(a, power(b, mod - 2)); }

ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }

ll subtract(ll a, ll b) { return ((a - b) % mod + mod) % mod; }

void solve() {
  int n, m;
  cin >> n >> m;
  vi h(n + 1);
  repa(i, 1, n) cin >> h[i];
  unordered_map<int, set<int>> adj;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  int cnt = 0;
  repa(i, 1, n) {
    auto ngh = adj[i];
    bool good = true;
    for (auto e : ngh) {
      if (h[i] <= h[e]) {
        good = false;
        break;
      }
    }
    cnt += good;
  }
  cout << cnt;
	cout << "\n";
}

#define REPEAT 0
#define CASE 0

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#if REPEAT
		int t;
		cin >> t;
		repa(i, 1, t) {
			#if CASE
				cout << "Case #" << i << ": ";
			#endif
			solve();
		}
	#else
		solve();
	#endif
	return 0;
}


Measured memory_bytes: 21824
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, j;
	char str[1000];
	
	while (scanf("%s", str) != EOF){
		for (i = 0; i < strlen(str); i++){
			if (str[i] - '@'){
				printf("%c", str[i]);
			}
			else {
				for (j = 0; j < str[i + 1] - '0'; j++){
					printf("%c", str[i + 2]);
				}
				i += 2;
			}
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

#define N_MAX 10000005

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    ll x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    sort(x,x+n);
    ll ans = INF;
    for(ll j = x[0]; j <= x[n-1]; j++){
        ll tmp = 0;
        for(ll i = 0; i < n; i++){
            tmp += ((j - x[i]) * (j - x[i]));
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef vector<int> vi;
typedef long double D;

int main(){
  int n;
  while(cin >> n, n){
    vector<vi> dis(n, vi(n,1e9));
    vi deg(n,0);
    rep(i,n)dis[i][i] = 0;

    rep(i,n-1){
      int a,b,t;
      cin >> a >> b >> t;
      a--; b--;
      dis[a][b] = dis[b][a] = t;
      deg[a]++; deg[b]++;
    }

    for(int i=1;i<n;i++){
      if(deg[i] == 1){
	rep(j,n){
	  if(dis[i][j] != 1e9)dis[i][j] = dis[j][i] = 0;
	}
      }
    }

    int ans = 0;
    rep(i,n){
      rep(j,n){
	if(dis[i][j] != 1e9)ans += dis[i][j];
      }
    }

    rep(k,n)rep(i,n)rep(j,n)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

    int maxd = 0;
    rep(i,n){
      if(dis[0][i] != 1e9)maxd = max(maxd, dis[0][i]);
    }

    cout << ans - maxd << endl;
  }
}

Measured memory_bytes: 3012
// reference: https://ei1333.hateblo.jp/entry/2017/04/10/224413

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
#include <map>
#include <complex>
#include <set>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

struct edge {
    int to, cost;
};

vector<edge> g[100000];
ll dist[100000];

void dfs1(int idx, int par) {
    for (edge &e: g[idx]) {
        if (e.to == par) continue;
        dfs1(e.to, idx);
        dist[idx] = max(dist[idx], dist[e.to] + e.cost);
    }
}

int dfs2(int idx, int d_par, int par) {
    vector<pair<int, int> > d_child;
    // 番兵（ノードの次元が1の時にも d_child[1]にアクセスできるようにする & 影響を与えない）
    d_child.emplace_back(0, -1);
    for (edge &e: g[idx]) {
        if (e.to == par) d_child.emplace_back(d_par + e.cost, e.to);
        else d_child.emplace_back(dist[e.to] + e.cost, e.to);
    }
    sort(d_child.rbegin(), d_child.rend());
    int ret = d_child[0].first + d_child[1].first; //最大から2つ
    for (edge &e: g[idx]) {
        if (e.to == par) continue;
        // 基本は d_child[0].first が d_par になるが、e.toの部分木が最大値の時はそれを取り除く必要がある
        ret = max(ret, dfs2(e.to, d_child[d_child[0].second == e.to].first, idx));
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b, w;
        cin >> a >> b >> w;
        g[a].push_back((edge) {b, w});
        g[b].push_back((edge) {a, w});
    }

    dfs1(n / 2, -1);
    cout << dfs2(n / 2, 0, -1) << endl;

    return 0;
}


Measured memory_bytes: 20296
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	string s, t;
	cin >> s >> t;
	ll ans = 0;
	rep(i, s.size())
	{
		if (s[i] != t[i])
			ans++;
	}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3796
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<deque>
#define rep(i,rept)	for(int i = 1; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {
	int d = 0;
	cin >> d;
	if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
		return 0;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
		return 0;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 25) {
		cout << "Christmas" << endl;
	}

		return 0;
}

Measured memory_bytes: 764
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ps = readln.split.to!(int[]);
    int r, min_p = ps[0];
    foreach (p; ps) {
        min_p = min(min_p, p);
        if (p == min_p) ++r;
    }
    writeln(r);
}

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

long n, k;
const long MAX = 100000;
long T[MAX];

long check(long p){
	long i = 0;
	for (long j = 0; j < k; j++){
		long s = 0;
		while (s + T[i] <= p){
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

long solve(){
	long left = 0;
	long right = 100000 * 10000;
	while (left < right){
		long mid = (left + right) / 2;
		long v = check(mid);
		if (v >= n) right = mid;
		else left = mid + 1;
	}
	return right;
}

int main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> T[i];
	long ans = solve();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,k,a[100005];
ll sum[100005],f[105][100005];
void add(ll &x,ll v)
{
	x+=v;
	if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=k;i++) sum[i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(k>a[i]) add(f[i][j],sum[j]-sum[j-a[i]-1]);
			else add(f[i][j],sum[j]);
			//printf("f(%d,%d)=%lld\n",i,j,f[i][j]);
		}
		sum[0]=f[i][0];
		for(int j=1;j<=k;j++) sum[j]=(sum[j-1]+f[i][j])%mod;
	}
	printf("%lld\n",f[n][k]);
	return 0;
}

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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if (a >= c || b >= c){
    cout << "No";
  }
  else if ((c - a - b) * (c - a - b) - 4 * a * b > 0){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace my_header {
#define pb push_back
#define mp make_pair
#define pir pair<int, int>
#define vec vector<int>
#define pc putchar
#define clr(t) memset(t, 0, sizeof t)
#define pse(t, v) memset(t, v, sizeof t)
#define bl puts("")
#define wn(x) wr(x), bl
#define ws(x) wr(x), pc(' ')
    const int INF = 0x3f3f3f3f;
    typedef long long LL;
    typedef double DB;
    inline char gchar() {
        char ret = getchar();
        for(; (ret == '\n' || ret == '\r' || ret == ' ') && ret != EOF; ret = getchar());
        return ret; }
    template<class T> inline void fr(T &ret, char c = ' ', int flg = 1) {
        for(c = getchar(); (c < '0' || '9' < c) && c != '-'; c = getchar());
        if (c == '-') { flg = -1; c = getchar(); }
        for(ret = 0; '0' <= c && c <= '9'; c = getchar())
            ret = ret * 10 + c - '0';
        ret = ret * flg; }
    inline int fr() { int t; fr(t); return t; }
    template<class T> inline void fr(T&a, T&b) { fr(a), fr(b); }
    template<class T> inline void fr(T&a, T&b, T&c) { fr(a), fr(b), fr(c); }
    template<class T> inline char wr(T a, int b = 10, bool p = 1) {
        return a < 0 ? pc('-'), wr(-a, b, 0) : (a == 0 ? (p ? pc('0') : p) : 
            (wr(a/b, b, 0), pc('0' + a % b)));
    }
    template<class T> inline void wt(T a) { wn(a); }
    template<class T> inline void wt(T a, T b) { ws(a), wn(b); }
    template<class T> inline void wt(T a, T b, T c) { ws(a), ws(b), wn(c); }
    template<class T> inline void wt(T a, T b, T c, T d) { ws(a), ws(b), ws(c), wn(d); }
    template<class T> inline T gcd(T a, T b) {
        return b == 0 ? a : gcd(b, a % b); }
    template<class T> inline T fpw(T b, T i, T _m, T r = 1) {
        for(; i; i >>= 1, b = b * b % _m)
            if(i & 1) r = r * b % _m;
        return r; }
};
using namespace my_header;

LL dp[51][2], p, n, a[51];

int main() {
#ifdef lol
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif

	fr(n, p);
	for (int i = 1; i <= n; ++i)
		fr(a[i]);
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 2; ++j) {
			dp[i][j ^ (a[i] & 1)] += dp[i - 1][j];
			dp[i][j] += dp[i - 1][j];
		}
	}
	wt(dp[n][p]);

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		String[][] map = new String[8][8];
		for(int i = 0; i < 8; i++){
			String line = sc.nextLine();
			for(int j = 0; j < 8; j++){
				map[i][j] = line.substring(j, j+1);		
			}
		}
		
		String tomoe = "o";
		String charlotte = "x";
		
		String now = tomoe;
		boolean tomoeC = true;
		String wait = charlotte;
		boolean charlotteC = true;
		while(true){
			int max = 0;
			int maxI = 0;
			int maxJ = 0;
			for(int i = 0; i < 8; i++){
				for(int j = 0; j < 8; j++){
					if(map[i][j].equals(".")){ 
						int c = check(i, j, now, wait, map);
						if(c == max && now.equals(tomoe)){
							if(i < maxI || (i == maxI && j < maxJ)){ 
								maxJ = j; maxI = i;
							}
						}
						else if(c == max && now.equals(charlotte)){
							if(i > maxI || (i == maxI && j > maxJ)){
								maxJ = j; maxI = i;
							}
						}
						else if(c > max){
							max = c;
							maxI = i;
							maxJ = j;
						}
					}
				}
			}
			
			if(!tomoeC && !charlotteC) break;
			if(max == 0) {
				if(now.equals(tomoe)) tomoeC = false;
				else charlotteC = false;
			}
			else{
				map[maxI][maxJ] = now;
				turn(maxI, maxJ, now, wait, map);
			}
			String t = now;
			now = wait;
			wait = t;
		}
		
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				System.out.printf(map[i][j]);
			}
			System.out.println();
		}
	}
	public int check(int i, int j, String now, String wait, String[][] map){
		int sum = 0;
		int[] x = { 0, 1, 1, 1, 0,-1,-1,-1};
		int[] y = {-1,-1, 0, 1, 1, 1, 0,-1};
		
		for(int k = 0; k < 8; k++){
			int nx = i + x[k];
			int ny = j + y[k];
			int s = 0;
			while(nx < 8 && ny < 8 && nx >= 0 && ny >= 0){
				if(map[nx][ny].equals(wait)) 
					s++;
				else if(map[nx][ny].equals(now))
					break;
				else {
					s = 0;
					break;
				}
				nx = nx + x[k];
				ny = ny + y[k];
				if(nx >= 8 || ny >= 8 || nx < 0 || ny < 0) s = 0;
			}
			sum += s;
		}
		return sum;
	}
	public void turn(int i, int j, String now, String wait, String[][] map){
		int[] x = { 0, 1, 1, 1, 0,-1,-1,-1};
		int[] y = {-1,-1, 0, 1, 1, 1, 0,-1};
		
		for(int k = 0; k < 8; k++){
			int nx = i + x[k];
			int ny = j + y[k];
			int s = 0;
			while(nx < 8 && ny < 8 && nx >= 0 && ny >= 0){
				if(map[nx][ny].equals(wait)) 
					s++;
				else if(map[nx][ny].equals(now))
					break;
				else {
					s = 0;
					break;
				}
				nx = nx + x[k];
				ny = ny + y[k];
				if(nx >= 8 || ny >= 8 || nx < 0 || ny < 0) s = 0;
			}
			if(s > 0){
				nx = i + x[k];
				ny = j + y[k];
				for(int t = 0; t < s; t++){
					map[nx][ny] = now;
					nx = nx + x[k];
					ny = ny + y[k];
				}
			}
		}
	}

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

Measured memory_bytes: 20312
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <queue>

#define INF (1<<28)

using namespace std;

int H, W, K;
int x1, y1, x2, y2;
vector<vector<char>> c;
typedef pair<int, int> P;

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

void solve() {
  queue<P> q;
  q.push(P(x1, y1));
  int d[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      d[i][j] = INF;
    }
  }
  d[x1][y1] = 0;

  while (!q.empty()) {
    P cc = q.front(); q.pop();
    int cx = cc.first, cy = cc.second;
    // printf("c = (%d, %d)\n", cx, cy);
    if (cx == x2 && cy == y2) {
      break;
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= K; j++) {
        int nx = cx + dx[i] * j, ny = cy + dy[i] * j;
        // printf("n = (%d, %d) = %c\n", nx, ny, (0 <= nx && nx < H && 0 <= ny && ny < W ? c[nx][ny] : '-'));
        if (0 <= nx && nx < H && 0 <= ny && ny < W && c[nx][ny] == '.' && d[nx][ny] > d[cx][cy]) {
          if (d[nx][ny] > d[cx][cy]+1) {
            d[nx][ny] = d[cx][cy]+1;
            q.push(P(nx, ny));
          }
        } else {
          break;
        }
      }
    }
  }

  printf("%d\n", d[x2][y2] == INF ? -1 : d[x2][y2]);
}

int main() {
  scanf("%d %d %d", &H, &W, &K);
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  x1--; y1--; x2--; y2--;

  getchar();
  for (int i = 0; i < H; i++) {
    c.push_back(vector<char>());
    for (int j = 0; j < W; j++) {
      c[i].push_back(getchar());
    }
    getchar();
  }

  solve();
}


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

int main(){
    string num_str;
    cin >> num_str;

    int sum = 0;

    for(int i=0;i<num_str.size();i++) sum += num_str[i] - '0';

    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3708
K = int(input())
A , B = map(int,input().split())

if A == B:
    if A % K == 0:
        print('OK')

    elif B % K == 0:
        print('OK')

    else:
        print('NG')

else:
    for i in range(B-A+1):
        i += A
        if i % K == 0:
            print('OK')
            break

    else:
        print('NG')


Measured memory_bytes: 9156
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int N, M;
int ans;

int main() {
	string s;
	cin >> s;
	ans = 0;
	rep(i, 0, 4) {
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> cnt(26, 60);
  while (n--) {
    string s;
    cin >> s;
    vector<int> cur(26);
    for (char c : s)
      ++cur[c - 'a'];
    for (int i = 0; i < 26; ++i)
      cnt[i] = min(cnt[i], cur[i]);
  }
  for (int i = 0; i < 26; ++i)
    for (int j = 0; j < cnt[i]; ++j)
      cout << char('a' + i);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=110;
int n,a[maxn],cnt;
int main()
{
    n=read();
    for(int i=1;i<=n;i++)a[i]=read();
    sort(a+1,a+n+1);
    for(int i=1;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            for(int k=j+1;k<=n;k++)
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
                {
                    if(a[i]+a[j]>a[k])cnt++;
                }
    printf("%d\n",cnt);
    return 0;
}
/*

*/

Measured memory_bytes: 3224
N=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(N):
  sum+=A[i]
sum
ans=0
for i in range(N):
  A[i]=abs(A[i]*N-sum)
  if(A[i]<A[ans]):
    ans=i
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);

	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];

	}
	for (int i = 0; i < a; i++)
	{
		cin >> y[i];
	}
	for (int i = 0; i < a; i++)
	{
		if (x[i]-y[i]>0)
		{
			ans += x[i] - y[i];
		}
	}



	cout << ans<< endl;


	//sort(x, x + a);
	//cout << z << endl;


	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

ll solve(ll ans) {
	ll ret = 0;
	while (ans > 0) {
		ret += ans % 10;
		ans /= 10;
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string N;
	cin >> N;
	ll n = 0;
	vi VN(SZ(N));//各位
	REP(i, SZ(N)) {
		VN[i] = N[i] - '0';
		n *= 10;
		n += VN[i];
	}
	ll ans = solve(n);
	ll maxv = n;
	REP(i, SZ(VN)) {//1減らす位
		bool b = false;
		ll now = 0;
		REP(j, SZ(VN)) {
			now *= 10;
			if (b) {
				now += 9;
				continue;
			}
			if (i == j) {
				if (VN[j] == 0)break;
				now += VN[j] - 1;
				b = true;
				continue;
			}
			now += VN[j];
		}
		if (!b)continue;
		if (ans < solve(now)) {
			ans = solve(now);
			maxv = now;
		}
	}
	cerr << maxv << endl;
	cout << ans << endl;
	PAU;
	return 0;
}


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

int main() {
  int x[5],xi;
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  for(int i=0;i<5;i++) {
    for(int j=i;j<5;j++) {
      if(x[i] < x[j]) {
        xi = x[i];
        x[i] = x[j];
        x[j] = xi;
      }
    }
  }
  for(int i=0;i<4;i++) {
    cout << x[i] << " ";
  }
  cout << x[4] <<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w, k;
  cin >> h >> w >> k;
  vector<bool> exists(h, true);
  vector<string> v(h);
  rep(i, 0, h) {
    cin >> v[i];
    if (v[i].find('#') == string::npos)
      exists[i] = false;
  }

  vector<vector<int>> ans(h, vector<int>(w, 0));
  int cur = 1;

  rep(i, 0, h) {
    int x = -1;
    if (!exists[i]) {
      if (i > 0)
        rep(j, 0, w) ans[i][j] = ans[i - 1][j];
      continue;
    } else {
      rep(j, 0, w) {
        if (v[i][j] == '#') {
          x++;
          if (x == 1) {
            cur++;
            x = 0;
          }
        }
        ans[i][j] = cur;
      }
    }
    cur++;
  }

  repr(i, 0, h) {
    if (ans[i][0] == 0) {
      rep(j, 0, w) { ans[i][j] = ans[i + 1][j]; }
    }
  }

  rep(i, 0, h) {
    rep(j, 0, w) {
      if (j > 0)
        cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}


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

int main() {
    int n, k; cin >>n >>k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >>a[i];

    if (k>=n-1) { // TLE対策1
        for (int i = 1; i <= n; i++) cout <<n << " ";
        cout << endl;
        return 0;
    }

  	// 回答を観た（imos法：累積和による実装により、メインの計算量をO(n)にできる！）
    for (int j = 0; j < k; j++) {
        vector<int> b(n+1);

        for (int i = 0; i < n; i++) {
            int l = max(i-a[i], 0);
            int r = min(i+a[i]+1, n);
            b[l]++; b[r]--;
        }
        for (int i = 0; i < n; i++) b[i+1] += b[i];
        b.pop_back();
        if (a==b) break;

        a = b;
    }

    for (int i = 0; i < n; i++) cout <<a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4836
n = int(input())
# 隣接リスト
graph = {i+1000*j:[] for i in range(n) for j in range(i+1,n)}
# 入次数を管理
st = {i+1000*j:0 for i in range(n) for j in range(i+1,n)}


# 入次数が0の頂点の集まり
szero = []

#ソートされたやつたち
ans = []

for i in range(n):
    ls = list(map(int,input().split()))
    f = -1
    for p in ls:
        v = min(i,p-1) + 1000*(max(i,p-1))
        if f != -1:
            graph[f].append(v)
            st[v] += 1
        f = v

for v in st.keys():
    if st[v] == 0:szero.append(v)
count = 0
next_szero = []
while True:
    count += 1
    for i in szero:
        ans.append(i)
        for v in graph[i]:
            st[v] -= 1
            if st[v] == 0:
                next_szero.append(v)
    if len(next_szero) == 0:break
    szero = next_szero
    next_szero = []

if len(ans) != n*(n-1)//2:
    print(-1)
else:
    print(count)

Measured memory_bytes: 173188
#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;

int bit[200010],n;

    int sum(int i){
        int s= 0;
        while(i>0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        while(i<=n){
            bit[i] += x;
            i += i & -i;
        }
    }

int main(){
    int i,k;
    cin >> n >> k;
    long long x=0,a[200010],ans=0;
    pair<long long ,long long> p[200010];
    for(i=0;i<n;i++){
        cin >> a[i];
        a[i] -= k;
    }

    for(i=0;i<n;i++){
        x += a[i];
        if(x>=0){
            ans += 1;
        }
        p[i] = make_pair(x,i);
    }

    sort(p,p+n);
    a[p[0].second] = 1;
    for(i=1;i<n;i++){
        if(p[i].first==p[i-1].first){
            a[p[i].second] = a[p[i-1].second]+1;
        }else{
            a[p[i].second] = i+1;
        }
    }

    for(i=0;i<n;i++){
        bit[i] = 0;
    }
    for(i=0;i<n;i++){
        ans += sum(a[i]);
        add(a[i],1);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 5760
using System;
class Program
{
	static void Main(string[] args)
	{
      // スペース区切りの整数の入力
      var input = Console.ReadLine().Split(' ');
      var a = int.Parse(input[0]);
      var b = int.Parse(input[1]);
      var max=Math.Max(a,b);
      var min=Math.Min(a,b);
      if(max>min){
        Console.WriteLine(max*2-1);
      }
      else{
        Console.WriteLine(max*2);
      }
	}
}


Measured memory_bytes: 13140
#include <stdio.h>

int main(void) {
    int A,B;
    if (scanf("%d %d",&A,&B) != EOF) {
        if (B % A == 0) {
            printf("%d", A+B);
        } else {
            printf("%d", B-A);
        }
    } else {
        return 1;
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define inf 0x3f3f3f3f
int main()
{
    int k,n,i,sum;
    int a[400400]={};
    while(~scanf("%d%d",&k,&n))
    {
        int minx=inf;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            a[n+i]=a[i];
        }
        for(i=n-1;i<2*n-1;i++)
        {
            if(a[i]>a[i-n+1])
                sum=a[i]-a[i-n+1];
            else
                sum=a[i]+(k-a[i-n+1]);
//            printf("%d %d %d\n",sum,a[i],a[i-n+1]);
            minx=sum>minx?minx:sum;//minx=inf;
        }
        printf("%d\n",minx);
    }
}


Measured memory_bytes: 1792
def func(N, A_i):
    array = [0]*N
    for i in range(N):
        array[A_i[i]-1] = i+1
    ans = str(array[0])
    for i in range(N-1):
        ans += " " + str(array[i+1])
    return ans

N = int(input())
A_i = list(map(int, input().split(" ")))
print(func(N, A_i))

Measured memory_bytes: 13880
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)

using namespace std;

int in[32];
int out[32];

int main(void){
	int n;
	char s[128];
	
	while(scanf("%d", &n),n){
		vector<int> x[32];
		rep(i,32) in[i] = out[i] = 0;
		
		rep(i,n){
			scanf("%s", s);
			in[s[0]-'a']++;
			out[s[strlen(s)-1]-'a']++;
			x[s[0]-'a'].push_back(s[strlen(s)-1]-'a');
		}
		
		int d = 0;
		
		rep(i,26){
			if(in[i] != out[i]){
				d++;
			}
		}
		
		if(d == 0){
			int use[32];
			rep(i,32)use[i] = -1;
			queue<char>q;
			
			rep(i,26){
				if(x[i].size() > 0){
					use[i] = 0;
					rep(j, x[i].size()){
						q.push(x[i][j]);
					}
					break;
				}
			}
			
			while(!q.empty()){
				int f = q.front();q.pop();
				if(use[f] != -1)continue;
				use[f] = 0;
				rep(i, x[f].size()){
					q.push(x[f][i]);
				}
			}
			bool flg = true;
			rep(i,26){
				if(use[i] == -1 && x[i].size())
					flg = false;
			}
			if(flg){
				puts("OK");
			}else{
				puts("NG");
			}
		}
		else{
			puts("NG");
		}
		rep(i,32)x[i].clear();
	}
	
	return 0;
}

Measured memory_bytes: 1252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int ans = Math.abs(a[1] - a[0]) + Math.abs(a[2] - a[1]);
        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <algorithm>
int n, k, s, x;
int p[200000];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", p + i);
		p[i]++;
	}
	for (int i = 0; i < k; i++) {
		s += p[i];
	}
	x = s;
	for (int i = 0; i < n - k; i++) {
		s -= p[i];
		s += p[i + k];
		if (s > x)x = s;
	}
	printf("%d", x / 2);
	if (x % 2)printf(".5");
	printf("\n");
}

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

/*   ++   *
 *   北   *
 --西・東++
 *   南   *
 *   --   */

void calcCart ( double length, double angle, double* result )
{
    result[0] = length * cos( M_PI * 2 * angle / 360.0 );
    result[1] = length * sin( M_PI * 2 * angle / 360.0 );
}

int main ( void )
{
    int input[2];
    double angle = 90.0, tmp[2], result[2] = { 0.0 };

    while ( scanf( "%d,%d", &input[0], &input[1] ) != EOF )
    {
        calcCart( (double)input[0], angle, tmp );
        result[0] += tmp[0];
        result[1] += tmp[1];
        angle -= input[1];
    }

    printf( "%d\n", (int)result[0] );
    printf( "%d\n", (int)result[1] );

    return 0;
}

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

int main(){
  int n='A'-'a';
  string s,t,u;
  cin >> s >> t >> u;
  char a,b,c;
  a=s.at(0)+n;
  b=t.at(0)+n;
  c=u.at(0)+n;
  cout << a << b << c << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int gcd(int a, int b){
	if(b==0){
		return a;
	}
	return gcd(b, a%b);
}

int lcm(int a, int b){
	return a/gcd(a, b)*b;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	string s, t;
	cin>>n>>m>>s>>t;
	if(s[0]!=t[0]){
		cout<<-1<<'\n';
		return 0;
	}
	if(n==m){
		cout<<(s==t ? n : -1)<<'\n';
		return 0;
	}
	int a=gcd(n, m);
	int b=n/a, c=m/a;
	bool ok=true;
	int j=c;
	for(int i=b; i<n; i+=b){
		if(j>=m){
			break;
		}
		if(s[i]!=t[j]){
			ok=false;
		}
		j+=c;
	}
	ll nn=n, mm=m, aa=a;
	cout<<(ok ? nn/aa*mm : -1)<<'\n';
	return 0;
}


Measured memory_bytes: 640