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

#define all(v) v.begin(),v.end()
#define rep(i,a,n) for(auto i=a;i<=n;i++)
#define f(i,n) for(auto i=0;i<n;i++)
#define fr first
#define sc second
#define pb emplace_back
#define pf push_front
#define mp make_pair
#define ll long long
#define endl "\n"
#define digit(n) floor(log10(n))+1
#define mod 1000000007
#define maxn 1000001
#define mem(a,val) memset(a,val,sizeof(a))
#define pow(a,b) (ll)(pow(a,b)+0.5)
#define inf 1000000000000000001
#define FASTIO std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//------------------- * Chaliye Shuru Karte Hain (code) * -------------------//

int main()
{
    FASTIO
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll x=0,f=0,j,q=1,i,n,m,k;
    //cin>>q;
    while(q--)
    {
        cin>>n>>k;
        vector<ll> a(n+1,0),dp(n+1,0);
        rep(i,1,n)cin>>a[i];
        dp[2]=abs(a[2]-a[1]);
        rep(i,3,n){
            dp[i]=inf;
            rep(j,1,k)
            if(i-j>0)dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
        }
        cout<<dp[n];



        cout<<endl;    
    }        
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main()
{
  vector<int> in(3);
  map<int,int> mp;

  for(auto &x: in)
  {
    cin >> x;
    // cout << x << endl;
  }

  for(auto x: in)
  {
    if(x==5)
      mp[5]++;
    else if(x==7)
      mp[7]++;
  }

  if((mp[5]==2) && (mp[7]==1))
    cout << "YES" <<endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
const ll mod = 998244353;

struct zhtools {
    ll fac[N] = {1ll};

    ll binpow(ll a, ll b) {
        ll res = 1ll;
        while (b > 0) {
            if (b & 1) res = res * a % mod;
            a = a * a % mod;
            b >>= 1;
        }
        return res % mod;
    }

    void init() { for (ll i = 1; i < N; i++)fac[i] = fac[i - 1] * i % mod; }

    ll inv(ll a) { return binpow(a, mod - 2); }

    ll A(ll n, ll m) { return fac[n] * inv(fac[n - m]) % mod; }

    ll C(ll n, ll m) { return fac[n] * inv(fac[m]) % mod * inv(fac[n - m]) % mod; }
} zh;

ll n, m, k;

int main() {
    zh.init();
    scanf("%lld%lld%lld", &n, &m, &k);
    ll ans = 0;
    for (int i = 0; i <= k; i++) {
        ans = (ans + (m * zh.C(n - 1, i)) % mod * zh.binpow(m - 1, n - 1 - i) + mod) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 11624
n, ma, mb = map(int, input().split())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

M = 401
INF = 10 ** 15
min_cost = [[INF] * M for k in range(M)]
s = set()
min_cost[0][0] = 0
s.add((0, 0))

for k in range(n):
    ss = set(s)
    for i, j in reversed(sorted(s)):
        if i + a[k] < M and j + b[k] < M:
            cc = min_cost[i][j] + c[k]
            if cc < min_cost[i + a[k]][j + b[k]]:
                ss.add((i + a[k], j + b[k]))
                min_cost[i + a[k]][j + b[k]] = cc
    s = ss

res = INF
for i in range(1, M):
    for j in range(1, M):
        if i * mb == j * ma:
            if min_cost[i][j] < res:
                res = min_cost[i][j]

if res == INF:
    res = -1
print(res)


Measured memory_bytes: 8504
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<bool> stair(n+1);
  rep(i, m) {
    int at;
    cin >> at;
    stair[at] = true;
  }
  
  ll mod = 1e9+7;
  vector<ll> dp(n+1);
  dp[0] = 1;
  rep(i, n) {
    for(int j = i+1; j <= min(n, i+2); ++j) {
      if(!stair[j]) {
        dp[j] += dp[i];
        dp[j] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}
    

Measured memory_bytes: 3964
x1, y1, x2, y2 = tuple(map(int, input().split(' ')))
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
program main
  implicit none

  integer :: ak, bk, mk
  integer, allocatable :: a(:), b(:), m(:,:), total(:)
  integer :: i, j

  read (*,*) ak, bk, mk

  allocate(a(ak))
  allocate(b(bk))
  allocate(m(3,mk))

  read(*,*) a
  read(*,*) b
  read(*,*) m

     allocate(total(mk+1))
     do i = 1, mk
        total(i) = a(m(1,i)) + b(m(2,i)) - m(3,i)
     end do

     total(mk + 1)=minval(a) + minval(b)

     write(*,*) minval(total)

     deallocate(total)
     
 deallocate(a,b,m)
 stop
 
end program main



Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <string.h>

#define int long long int


using namespace std;

class Graph
{
    private:
        typedef struct Node_Structure
        {
            int                             data;
            vector<struct Node_Structure *> adjacentNodes;
            int                             adjacentNodesCount;
            Node_Structure(int dataValue)
            {
                data               = dataValue;
                adjacentNodesCount = 0;
            }
        }Node;

        unordered_map<int, Node_Structure *> graphNodesMap;
        int                                  numberOfNodes;
        vector<int>                          longestPathVector;

        int getLongestPathFomNode(Node *node)
        {
            if(longestPathVector[node->data] > -1)
            {
                return longestPathVector[node->data];
            }
            for(int i = 0 ; i < node->adjacentNodesCount ; i++)
            {
                longestPathVector[node->data] = max(longestPathVector[node->data], 1 + getLongestPathFomNode(node->adjacentNodes[i]));
            }
            return longestPathVector[node->data] == -1 ? 0 : longestPathVector[node->data];
        }

    public:
        Graph(int nodes)
        {
            numberOfNodes     = nodes;
            longestPathVector = vector<int>(nodes+1, -1);
            for(int i = 1 ; i <= nodes ; i++)
            {
                graphNodesMap[i] = new Node(i);
            }
        }

        void addDirectedAdjacency(int fromNode, int toNode)
        {
            if(graphNodesMap.find(fromNode) == graphNodesMap.end())
            {
                graphNodesMap[fromNode] = new Node(fromNode);
            }
            if(graphNodesMap.find(toNode) == graphNodesMap.end())
            {
                graphNodesMap[toNode] = new Node(toNode);
            }
            graphNodesMap[fromNode]->adjacentNodes.push_back(graphNodesMap[toNode]);
            graphNodesMap[fromNode]->adjacentNodesCount++;
        }

        int getLongestRouteSize()
        {
            int longestPath = 1;
            for(int i = 1 ; i <= numberOfNodes ; i++)
            {
                longestPath = max(longestPath, getLongestPathFomNode(graphNodesMap[i]));
            }
            return longestPath;
        }
};

int32_t main()
{
    int nodes, relations;
    cin>>nodes>>relations;
    Graph graph = Graph(nodes);
    for(int i = 0 ; i < relations ; i++)
    {
        int fromNode, toNode;
        cin>>fromNode>>toNode;
        graph.addDirectedAdjacency(fromNode, toNode);
    }
    cout<<graph.getLongestRouteSize()<<endl;
    return 0;
}

Measured memory_bytes: 14372
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int w = sc.nextInt();
			int h = sc.nextInt();

			if ((w | h) == 0) {
				break;
			}

			int value[][] = new int[h][w];

			for (int i = 0; i < h; i++) {
				String buffer = sc.next();
				for (int j = 0; j < w; j++) {
					switch (buffer.charAt(j)) {
					case '.':
						value[i][j] = 1;
						break;
					case '@':
						value[i][j] = 2;
						break;
					}
				}
			}

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

			int z=0;
			int sum = 0;
			for (int c = 0; c < 403; c++) {
				z=0;
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (value[i][j] == 2) {
							for (int k = 0; k < 4; k++) {
								int ni = i + dy[k];
								int nj = j + dx[k];

								if(ni < 0){
									continue;
								}
								if(ni >= h){
									continue;
								}
								if(nj < 0){
									continue;
								}
								if(nj >= w){
									continue;
								}
								if(value[ni][nj] == 1){
									value[ni][nj] = 2;
								}
							}
							value[i][j] = 3;
							z++;
						}
					}
				}
				sum += z;
				if(z == 0){
					break;
				}
			}
			System.out.println(sum);
		}

	}

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

Measured memory_bytes: 13000
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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")
    };
}

use std::collections::{VecDeque, HashSet};

fn main() {
    input! {
        H: usize,
        W: usize,
        s: [chars; H],
    }

    let mut visited = HashSet::new();
    let mut q = VecDeque::new();

    for h in 0..H {
        for w in 0..W {
            if visited.contains(&(h, w)) {
                continue;
            }

            if s[h][w] == '.' {
                continue;
            }

            q.clear();
            q.push_back((h, w));

            let mut neighbor_painted = false;

            while let Some((h, w)) = q.pop_front() {
                if visited.contains(&(h, w)) {
                    continue;
                }
                visited.insert((h, w));

                // up
                if h > 0 && s[h - 1][w] == '#' {
                    q.push_back((h - 1, w));
                    neighbor_painted = true;
                }
                // down
                if h + 1 < H && s[h + 1][w] == '#' {
                    q.push_back((h + 1, w));
                    neighbor_painted = true;
                }
                // left
                if w > 0 && s[h][w - 1] == '#' {
                    q.push_back((h, w - 1));
                    neighbor_painted = true;
                }
                // right
                if w + 1 < W && s[h][w + 1] == '#' {
                    q.push_back((h, w + 1));
                    neighbor_painted = true;
                }
            }

            if !neighbor_painted {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll cnt = 0;
    for (ll i = 0; i < n - 2; i++)
    {
        for (ll j = i + 1; j < n - 1; j++)
        {
            for (ll k = j + 1; k < n; k++)
            {
                if (a[i] == a[j])
                {
                    continue;
                }
                if (a[j] == a[k])
                {
                    continue;
                }
                if (a[k] == a[i])
                {
                    continue;
                }
                if (a[i] >= a[j] + a[k])
                {
                    continue;
                }
                if (a[j] >= a[i] + a[k])
                {
                    continue;
                }
                if (a[k] >= a[j] + a[i])
                {
                    continue;
                }
                //cout << a[i] << a[j] << a[k] << endl;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n, k; scanf("%d%d", &n, &k);
    ll cnt1 = 0, cnt2 = 0;
    for (int i = 1; i <= n; i++) {
        if (i % k == 0) cnt1++;
        if (k % 2 == 0 && i % k == k / 2) cnt2++;
    }
    ll res = cnt1 * cnt1 * cnt1 + cnt2 * cnt2 * cnt2;
    printf("%lld\n", res);
}


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

int main() {
    int X;
    int Y;
    cin >> X >> Y;
    for (int i = 1; i <= 2 * Y; i++) {
        if ((i * X) % Y !=0 && i * X != X) {
            cout << i * X << "\n";
            break;
        } else if (X % Y == 0) {
            cout << "-1 \n";
            break;
        }
        if (i == 2 * Y) {
            cout << "-1 \n";
            break;
        }
    }
}


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

int linearSearch(vector<int> a, int n, int x) {
	for (int i = 0; i < n; i++) {
		if (a[i] == x) {
			return i;
		}
	}
	return -1;
}

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

	int q;
	cin >> q;
	vector<int> t(q);
	for (int i = 0; i < q; i++) {
		cin >> t[i];
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		if (linearSearch(s, n, t[i]) != -1) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    char a, b;
    cin >> a >> b;
    if ((a=='H' && b == 'H') || (a=='D' && b=='D')) cout << 'H' << endl;
    else cout << "D" << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;
    cin>>n;
    vl x(n),y(n);
    vll a(n),b(n),c(n),d(n);
    ll ans=0;
    rep(i,n){
        cin>>x[i]>>y[i];
        a[i].F=x[i]+y[i];
        a[i].S=i;
        b[i].F=-x[i]-y[i];
        b[i].S=i;
        c[i].F=x[i]-y[i];
        c[i].S=i;
        d[i].F=-x[i]+y[i];
        d[i].S=i;
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    sort(all(d));
    for(int i=n-1;i>=0;--i){
        if(a[i].S!=b[n-1].S){
            ans=max(ans,a[i].F+b[n-1].F);
            break;
        }
    }
    for(int i=n-1;i>=0;--i){
        if(b[i].S!=a[n-1].S){
            ans=max(ans,b[i].F+a[n-1].F);
            break;
        }
    }
    for(int i=n-1;i>=0;--i){
        if(c[i].S!=d[n-1].S){
            ans=max(ans,c[i].F+d[n-1].F);
            break;
        }
    }
    for(int i=n-1;i>=0;--i){
        if(d[i].S!=c[n-1].S){
            ans=max(ans,d[i].F+c[n-1].F);
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int N; cin >> N; vector<int> s[N]; int M[N], ls=0, c, a[10001]; long long ans=0;
  for(int i=0; i<10001; i++) a[i]=0;
  for(int i=0; i<N; i++) {
    cin >> M[i];
    for(int j=0; j<M[i]; j++) {
      cin >> c; s[i].push_back(c);
    }
  }
  //for(int i=0; i<N; i++) cout << s[i].size() << " ";
  
  for(int i=N-1; i>=0; i--){
    for(int j=0; j<M[i]; j++){
      a[s[i][j]]++; ls = max(ls, s[i][j]);
    }
    //cout << "2" << endl;
    while (a[ls]==0){
      ls--; if (ls<0) return 1;
      //cout << "5" << endl;
    }
    //cout << "4" << endl;
    ans += ls; a[ls]--;
  }
  //cout << "3" << endl;
  cout << ans << endl;
}


Measured memory_bytes: 20640
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=507;

int n;
int odl[nax][nax];

int out[nax][nax];

ll wyn;

void dfs(int a, int b, int o)
{
	if (a<1 || b<1 || a>n || b>n)
		return;
	o-=out[a][b];
	if (odl[a][b]<=o)
		return;
	odl[a][b]=o;
	dfs(a+1, b, o+1);
	dfs(a-1, b, o+1);
	dfs(a, b+1, o+1);
	dfs(a, b-1, o+1);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			odl[i][j]=min(min(i-1, n-i), min(j-1, n-j));
	for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=n; j++)
		{
			int x;
			scanf("%d", &x);
			x--;
			int a=x/n;
			int b=x%n;
			a++;
			b++;
			wyn+=odl[a][b];
			out[a][b]=1;
			dfs(a, b, odl[a][b]);
		}
	}
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 20776
#include<iostream>

using namespace std;

const string YES = "Yes";
const string NO  = "No";

int main() {
  int N,A,B;
  string S;
  cin >> N >> A >> B >> S;
  int a = 0,b = 0;
  for(int i=0;i<N;++i) {
    if( S[i] == 'a' ) {
      if( a+b < A+B ) cout << YES << endl,++a;
      else            cout << NO << endl;
    } else if( S[i] == 'b' ) {
      if( a+b < A+B && b < B ) cout << YES << endl, ++b;
      else                     cout << NO << endl;
    } else {
      cout << NO << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
from math import gcd
def resolve():
    print(["No","Yes"]["7" in input()])
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """117"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """123"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """777"""
        output = """Yes"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 16336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

int N, L[10], S;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		S += L[i];
	}
	for (int i = 0; i < N; i++) {
		if (L[i] >= S - L[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
//~ #define int long long
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int h,a;cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, k := nextInt(), nextInt(), nextInt()
	for i := 0; i < k; i++ {
		if i%2 == 0 {
			a /= 2
			b += a
		} else {
			b /= 2
			a += b
		}
	}
	fmt.Println(a, b)
}


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

int main() {
	// your code goes here
	long long int n,a,b;
  cin>>n>>a>>b;
  if(a==0)
    cout<<"0";
  else
 { long long int s=((n/(a+b))*(a+b));
      long long int diff=n-s;
       long long int ans=((n/(a+b))*a)+min(a,diff);
         cout<<ans;
 }

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int A[MAXN];
int main()
{
	int n;
	scanf("%d", &n);
	long long int tot = 0, val = 1ll*n*(n+1)/2;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &A[i]);
		tot+=A[i];
	}
	if(tot%val)
	{
		printf("NO\n");
		return 0;
	}
	long long int num = tot/val, temp = 0;
	for (int i = 0; i < n; ++i)
	{
		long long int x = A[(i+1)%n] - A[i];
		x-=num;
		if(x > 0)
		{
			printf("NO\n");
			return 0;
		}
		if(x < 0)
		{
			x*=-1;
			if(x%n)
			{
				printf("NO\n");
				return 0;
			}
			temp+=(x/n);
		}
	}
	if(temp == num)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

int a[10010];
int mat[110][110];

int main () {

int h,w;
cin>>h>>w;
int n;
cin>>n;
int p=1;
int s=0;
int d=w;
for (int k=0; k<n; k++) {
	cin>>a[k];
	int da=0;
		for (int i=0; i<h; i++) {
			for (int j=s; j!=d; j+=p) {
				if (mat[i][j]==0) {mat[i][j]=k+1; a[k]--;}
				if (a[k]==0) {da=1; break;}
			}
			if (da==1) {s=0; d=w; p=1; break;}
			if (s==0) {s=w-1; d=-1; p=-1;} else {s=0; d=w; p=1;}
		}
}
for (int i=0; i<h; i++) {
	for (int j=0; j<w; j++) {
		cout<<mat[i][j]<<" ";
	}
	cout<<endl;
}


return 0;
}

Measured memory_bytes: 384
from itertools import groupby
from collections import defaultdict

N, M = map(int, input().split())
cards = sorted(list(map(int, input().split())))
# print(cards)
cards_dict = defaultdict(int)  # デフォルト値に0を指定
for key, group in groupby(cards):
    # print(key)
    count = len(list(group))
    # print(count)
    cards_dict[key] += count
# print(cards_dict)
# print("--------------")
for i in range(M):
    bi, ci = map(int, input().split())
    cards_dict[ci] += bi
# print(cards_dict)
d2 = sorted(cards_dict.items(), key=lambda x: x[0])
# print(d2)

index = len(d2) - 1
rest = N
ans = 0
while (rest > 0):
    num = d2[index][1]
    # print(num)
    if rest >= num:
        ans += num * d2[index][0]
        rest -= num
    else:
        ans += rest * d2[index][0]
        rest = 0
    index -= 1
print(ans)


Measured memory_bytes: 44192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    int k = s.length();
    int win = 0;
    rep(i, k){
        if(s[i] == 'o') win++;
    }

    if(k - win < 8) ans2(true);
    else ans2(false);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	while (n--) {
		string s, message; cin >> s >> message;
		int msz = message.size();
		for (int i = s.size() - 1; i >= 0; --i) {
			if (s[i] == 'J') {
				message = message[msz - 1] + message.substr(0, msz - 1);
			} else if (s[i] == 'C') {
				message = message.substr(1, msz - 1) + message[0];
			} else if (s[i] == 'E') {
				for (int j = 0; j < msz / 2; ++j) swap(message[j], message[j + (msz + 1) / 2]);
			} else if (s[i] == 'A') {
				reverse(message.begin(), message.end());
			} else if (s[i] == 'P') {
				for (int j = 0; j < msz; ++j)
					if (isdigit(message[j])) message[j] = ((message[j] - '0' + 9) % 10) + '0';
			} else if (s[i] == 'M') {
				for (int j = 0; j < msz; ++j)
					if (isdigit(message[j])) message[j] = ((message[j] - '0' + 1) % 10) + '0';
			}
		}
		cout << message << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
#include <vector>
using namespace std;
typedef long long int ll;
#define ALL(v) v.begin(), v.end()

int N;
vector<pair<int, int> > tasks;

int main(void){
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        //tasks[i]=make_pair(b, a);
        tasks.emplace_back(b, a);
    }

    sort(ALL(tasks));
    int sum = 0;
    bool isyes = true;
    for (auto v : tasks) {
        sum += v.second;

        if (sum > v.first) {
            isyes = false;
            break;
        }
    }
    cout << (isyes ? "Yes" : "No") << endl;

    return 0;
 }


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int n; cin >> n;
	int a[n];


	int sum = 0;
	REP(i, n){
		cin >> a[i];
		sum += a[i] - 1;
	}
	cout << sum << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  map<long long, long long> list;
  list[0] = 1;
  long long ans = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    ans += list[sum];
    list[sum]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
from collections import defaultdict
import sys

sys.setrecursionlimit(1000000)

d = defaultdict(list)
cost = defaultdict(int)
N = int(input())

for _ in range(N-1):
    u, v, w = map(int, input().split())
    d[u].append(v)
    d[v].append(u)
    cost[(u, v)] = w

visited = [False]*(N+1)
color = [-1]*(N+1)

def dfs(x):
    visited[x]=True
    if color[x]==-1:
        color[x] = 0

    for y in d[x]:
        if visited[y]:
            continue
        
        c = cost[(x, y) if x<y else (y, x)]
        if c%2==0:
            color[y] = 0 if color[x]==0 else 1
        else:
            color[y] = 1 if color[x]==0 else 0
        dfs(y)

dfs(1)
for i in color[1:]:
    print(i)

Measured memory_bytes: 86108
#include "bits/stdc++.h"
using namespace std;

template<typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main(){
    long long a, b;
    cin >> a >> b;
    long long g = gcd(a, b);
    map<int, int> mp;
    for (int i = 2; (long long)i * i <= g; i++) {
        while (g % i == 0) {
            mp[i]++;
            g /= i;
        }
    }
    if (g > 1) mp[g]++;
    cout << mp.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int M1,M2,D1,D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;

  if(M1==2){
    if(D1 == 28){
      if(D2 == 1){
	cout << "1" << endl;
      }else{
	cout << "0" << endl;
      }
      
    }
    else{
	cout << "0" << endl;
    }
    return 0;
  }
 
  if(M1==4 || M1==6 || M1==9 || M1==11){
    if(D1 == 30){
      cout << "1" << endl;
    }else{
      cout << "0" << endl;
    }
  }
  else{
    if(D1 == 31){
      cout << "1" << endl;
    }else{
      cout << "0" << endl;
    }
  }
}


Measured memory_bytes: 256
=begin
5
1 2
3 9
3 5
5 9
6 8
=end

class Curriculum
    attr_reader :data, :start_time, :end_time, :diff

    def initialize(a)
        @data = a
        @start_time = a[0]
        @end_time = a[1]
        @diff = a[1] - a[0]
    end

    def <=>(t)
        c = 0

        self.data.size.times do |i|
            c = self.data[i] <=> t.data[i]

            if c != 0 then
                break
            end
        end

        return c
    end
end

n = gets.to_i

a = []
n.times do |i|
    a[i] = Curriculum.new(gets.split(" ").map(&:to_i))
end

a = a.sort

#p a.map{ |x| [x.start_time, x.end_time] }

i = 0
while i < a.size - 1
    if a[i].end_time >= a[i + 1].end_time then
        a.delete_at(i)
    else
        if a[i].end_time >= a[i + 1].start_time then
            a.delete_at(i + 1)
        else
            i += 1
        end
    end
end

#p a.map{ |x| [x.start_time, x.end_time] }

print a.size, "\n"
exit

def dive(now, a, c)
    if !a then
        return c
    end

    count = c

    a.size.times do |i|
        if a[i].start_time > now.end_time then
            k = dive(a[i], a[i + 1, a.size], c + 1)

            if k > count then
                count = k
            end
        end
    end

    return count
end


count = 1
max = 10
if a.size > 1000 then
  max = 1
end
max.times do |i|
    k = dive(a[i], a[i + 1, a.size], 1)
    if k > count then
        count = k
    end
end

print count, "\n"



Measured memory_bytes: 23908
#include <stdio.h>
int main(void)
{
	int a, b, k, i, c, d=0;
	
	scanf("%d%d%d",&a,&b,&k);
	
	if(a>b) c=b;
	else    c=a;
	for(i=c;i>0;i--){
	    if((a%i==0)&&(b%i==0)) d++;
	    if(k==d) break;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 128
<?php
  
fscanf(STDIN, "%s", $N);

$N = $N -1;

for($i = 0; $i < 26; $i++){
  $a[] = chr(ord('a') + $i);
}

$one = $N % 26;
$result = $a[$one];
$carry = ($N - $one) / 26;
while($carry != 0) {
  $one = ($carry - 1) % 26;
  $result = $a[$one].$result;
  $carry = ($carry - 1 - $one) / 26;
}
echo $result;


Measured memory_bytes: 16228
#include<iostream>
using namespace std;
int main()
{
	int c=1,n,a[1<<17];cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int l=1;c<n*2;c++)
	{
		l=a[l];
		if(l==2)
		{
			cout<<c<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;
ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}


int main(){
 ll n;
 cin>>n;
 vector<ll>s(n);
 rep(i,n){
     cin>>s[i];
 }
 map<ll,ll>mp;
 rep(i,n){
     mp[s[i]-1]=i+1;
 }
 rep(i,n){
     cout<<mp[i]<<" ";
     if(i==n-1)cout<<endl;
 }
}



Measured memory_bytes: 10320
/*  ex6_2
    L40S38  */
#include<stdio.h>
#include<string.h>
#define LIMIT 100
int main(void){
    char word[LIMIT];
    //word:英小文字からなる文字列s
    scanf("%s",word);
    printf("%c%d%c",word[0],strlen(word)-2,word[strlen(word)-1]);
    //最初の文字、文字列の長さ-2(最初と最後の文字を抜いた分)、最後の文字を連続して出力
    return 0;
}

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

using namespace std;

vector<string> answer;

void dfs(int remain, int used_max, const string& current_str) {
  if (remain == 0) {
    answer.push_back(current_str);
    return;
  }

  for (int next = 0; next <= used_max + 1; next++) {
    string next_str = current_str + (char)('a' + next);
    dfs(remain - 1, max(used_max, next), next_str);
  }
}

int main() {
  int N;
  cin >> N;
  dfs(N - 1, 0, "a");

  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 7796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static long count;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        char[] sArr = s.ToArray();
        int[] arrAns = new int[1];
        checkAns(0,sArr,n,'R',arrAns);
        long allCount = 1;
        var ele = sArr.GroupBy(x => x);
        if(ele.Count() != 3)
        {
            Console.WriteLine(0);
            return;
        }
        foreach (var g in ele)
        {
            allCount *= g.Count();
        }
        Console.WriteLine(allCount - count);
    }

    static void checkAns(int ind ,char[] sArr , int n , char target , int[] arrAns)
    {
        for(int i = 0; i < n; i++)
        {
            if (sArr[i] == target)
            {
                if(ind == 0)
                {
                    arrAns[0] = i;
                    checkAns(1, sArr, n, 'G', arrAns);
                } else if(ind == 1)
                {
                    int max = Math.Max(arrAns[0], i);
                    int min = Math.Min(arrAns[0], i);
                    if(max+ max- min < n)
                    {
                        if (sArr[max + max - min] == 'B') count++;
                    }
                    if(min - (max - min) >= 0)
                    {
                        if (sArr[min - (max - min)] == 'B') count++;
                    }
                    if((max - min) % 2 == 0)
                    {
                        if (sArr[min + (max - min) / 2] == 'B') count++;
                    }
                }
            }
        }

    }



}




Measured memory_bytes: 18884
N, K = map(int, input().rstrip().split())
sunuke = [int(i) for i in range(1,N + 1)]
d = []
A = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

for k in range(K):
  for i in range(d[k]):
    if A[k][i] in sunuke:
      sunuke.remove(A[k][i])
  
    
print(len(sunuke))

Measured memory_bytes: 80332
#include <iostream>
#include <string>

using namespace std;

int main(void){

 string s;
cin >> s;
bool a=false,b=false;
for( int i = 0; i<s.size();++i){
  if(s[i]=='C')a = true;

if(s[i]=='F' && a ) b = true;
} 

cout << (b ? "Yes" : "No") << endl;



}


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

public class Page
{
    public int p { get; set; }
    public char status { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var r = Array.ConvertAll(line, int.Parse);
            var pages = new List<Page>();
            pages.Add(new Page { p = r[0], status = 's' });
            var prev = r[0];
            for (int i = 1; i < n; i++)
            {
                if (r[i] == prev + 1) prev++;
                else
                {
                    pages.Add(new Page { p = prev, status = 'e' });
                    pages.Add(new Page { p = r[i], status = 's' });
                    prev = r[i];
                }
            }
            pages.Add(new Page { p = prev, status = 'e' });
            Disp(pages);
        }
    }
    public static void Disp (List<Page> p)
    {
        for (int i = 0; i < p.Count(); i++)
        {
            switch(p[i].status)
            {
                case 's':
                    Console.Write(p[i].p);
                    break;
                case 'e':
                    if (i != p.Count() -1)
                    {
                        if (p[i].p == p[i - 1].p) Console.Write(" ");
                        else Console.Write("-{0} ", p[i].p);
                    }
                    else
                    {
                        if (p[i].p == p[i - 1].p) Console.WriteLine();
                        else Console.WriteLine("-{0}", p[i].p);
                    }
                        break;
            }
        }
    }
}

Measured memory_bytes: 9712
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int n;
    cin >> n;
    string s, u;
    cin >> s >> u;
    for(int i = 0 ; i < n; i++) cout << s[i] << u[i];
    cout << endl;
}
  
int32_t main() {
 
    FAST;

   
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26164
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

set<ll> calc_divs_for(const ll N) {
    set<ll> ans;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.insert(i);
            ans.insert(N / i);
        }
    }
    return ans;
}

ll pow(const ll base, ll n) {
    ll ans = 1;
    while (n > 0) {
        ans *= base;
        n--;
    }
    return ans;
}

int main(void) {
    ll N;
    cin >> N;

    set<ll> ans;

    // for a = 0;
    {
        // printf("a = 0\n");
        set<ll> divs = calc_divs_for(N - 1);
        for (auto &div : divs) {
            // printf("%lld\n", div);
            ans.insert(div);
        }
    }

    // for a = 1;
    {
        // printf("a = 1\n");
        set<ll> divs = calc_divs_for(N);
        for (auto &div : divs) {
            ll x = N / div - 1;
            if (x == 0) {
                // printf("%lld\n", div);
                ans.insert(div);
            } else {
                if (x % div == 0) {
                    // printf("%lld\n", div);
                    ans.insert(div);
                }
                // set<ll> ds = calc_divs_for(x);
                // for (auto &d : ds) {
                //     printf("%lld\n", d);
                //     ans.insert(d);
                // }
            }
        }
    }

    // for a = n;
    for (ll i = 2; i <= 40; i++) {
        // printf("a = %lld\n", i);
        for (ll j = 1; pow(j, i) <= N; j++) {
            ll v = pow(j, i);
            if (N % v == 0) {
                ll x = N / v - 1;
                if (x == 0) {
                    // printf("%lld\n", j);
                    ans.insert(j);
                } else {
                    if (x % j == 0) {
                        // printf("%lld\n", j);
                        ans.insert(j);
                    }
                    // set<ll> ds = calc_divs_for(x);
                    // for (auto &d : ds) {
                    //     printf("%lld\n", d);
                    //     ans.insert(d);
                    // }
                }
            }
        }
    }

    ans.erase(1);
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<ll>>
#define map map<ll ,ll>
#define umap unordered_map<ll , ll>
#define endl "\n"
#define set set<ll> 
#define setC set<char>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,n,a) for(int i = n ; i >= a ; --i)

typedef long long int ll;

void solv(){
    ll n , k;
    cin >> n  >> k;
    vi arr(n+1 );
    FOR(i , 1 , n){
        cin >> arr[i];
    }

    vll dp(n+1 , INT_MAX);
    dp[1] = 0;
    FOR(i , 2 , k+1){
        dp[i] = abs(arr[i] - arr[1]);
    }

    FOR(i , k+2 , n){
        FORback(j , i-1 , i-k){
            dp[i] = min(abs(arr[i] - arr[j])+dp[j] , dp[i]);
        }
    }
    cout << dp[n] << endl;
    // FOR(i , 1 , n){
    //     cout << dp[i] << " ";
    // }
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




Measured memory_bytes: 4504