akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void quick_sort (int array[], int left, int right);
void swap_int (int *x,  int *y);
int partition (int array[], int left, int right);



void swap_int (int *x,  int *y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
 
int partition (int array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;   // 先頭要素をpivotとする
 
    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        // pivotより小さいものを左へ、大きいものを右へ
        if (i < j) {
            swap_int(&array[i], &array[j]);
        }
    } while (i < j);
 
    swap_int(&array[pivot], &array[j]);   //pivotを更新
    return j;
}
 

void quick_sort (int array[], int left, int right) {
    int pivot;
    if (left < right) {
        pivot = partition(array, left, right);
        // pivotを境に再帰的にクイックソート
        quick_sort(array, left, pivot-1);
        quick_sort(array, pivot+1, right);
    }
}



SINT32 main() {
    SINT32 ans = 0;
    SINT32 max = 10;

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

    SINT32 *sabun = malloc(sizeof(SINT32)*a);
    
    SINT32 *data = malloc(sizeof(SINT32)*a);
    for (SINT32 i = 0; i < a; i++) {
        scanf("%d", &data[i]);
    }

    quick_sort(data, 0, a-1);

    for (SINT32 i = 1; i < a; i++) {
        sabun[i] = data[i] - data[i-1];
    }

/*    for (SINT32 i = 0; i < a; i++) {
        printf("%d ",sabun[i]);
    }
    printf("\n");
    */

    for (SINT32 i = 1; i < b; i++) {
        ans = ans+sabun[i];
    }




    SINT32 buf = ans;
    for (SINT32 i = b; i < a; i++) {
        buf = buf - sabun[i-b+1] + sabun[i];
 //       printf("%d ",buf);
        if (buf < ans) {
            ans = buf;
        }
    }
//    printf("\n");



    printf("%d\n",ans);
    free(data);
	return 0;
}

Measured memory_bytes: 896
def main():
    import sys
    sys.setrecursionlimit(10**7)
    input = sys.stdin.readline

    s = input().strip()

    if s[0] == s[1]:
        print('Bad')
        exit()

    if s[1] == s[2]:
        print('Bad')
        exit()

    if s[2] == s[3]:
        print('Bad')
        exit()

    print('Good')


main()




Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define MAX 5005
#define reg register

using namespace std;

int N, M;
int stk[MAX];
int p[MAX][205], lp[MAX], rp[MAX];
long long f[MAX][MAX], dis[MAX];

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void ChkMax(long long &aa, long long bb) {
	if(aa < bb) aa = bb;
	return;
}

int main() {
	N = Rd(), M = Rd();
	for(reg int i = 2; i <= N; ++i) dis[i] = Rd() + dis[i - 1];
	for(reg int i = 1; i <= N; ++i)
		for(reg int j = 1; j <= M; ++j)
			p[i][j] = Rd();
	for(reg int i = 1; i <= M; ++i) p[0][i] = INT_MAX;
	reg int top = 0;
	for(reg int i = 1; i <= M; ++i) {
		for(reg int j = 1; j <= N; ++j) {
			while(p[j][i] > p[stk[top]][i]) {
				rp[stk[top--]] = j - 1;
			} lp[j] = stk[top] + 1;
			if(p[j][i] == p[stk[top]][i]) {
				rp[stk[top]] = j - 1;
				stk[top] = j;
			} else {
				stk[++top] = j;
			}
		}
		while(top) rp[stk[top--]] = N;
		for(reg int j = 1; j <= N; ++j) {
//			cout << lp[j] << ' ' << rp[j] << endl;
			f[lp[j]][j] += p[j][i], f[j + 1][rp[j] + 1] += p[j][i];
			f[j + 1][j] -= p[j][i], f[lp[j]][rp[j] + 1] -= p[j][i];
		}
	}
	long long ans = 0;
	for(reg int i = 1; i <= N; ++i) {
		for(reg int j = 1; j <= N; ++j) {
			f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
//			cout << i << ' ' << j << ' ' << f[i][j] << endl;
			if(i <= j) {
				ChkMax(ans, f[i][j] - (dis[j] - dis[i]));
			}
		} // cout << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 200064
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main(void){
  int n, m;
  cin >> n >> m;
  vector<P> v(n);
  REP(i, n){
    int a, b;
    cin >> a >> b;
    v[i] = P(a, b);
  }
  sort(ALL(v));
  ll ans = 0;
  int count = 0;
  REP(i, n){
    ll a = v[i].first;
    ll b = v[i].second;
    if(count + b <= m){
      ans += a*b;
      count += b;
    }else{
      ans += a * (m-count);
      count = m;
    }

    if(count == m) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	int A[1<<18];
	rep(j,1<<N)cin>>A[j];
	
	
	int p[1<<18], q[1<<18];
	rep(j,1<<N){
		p[j]=A[j];
		q[j]=0;
	}
	
	rep(i,N)rep(j,1<<N)if((j & 1<<i)){
		int x[4];
		x[0]=p[j];x[1]=q[j];x[2]=p[j ^ (1<<i)];x[3]=q[j ^ (1<<i)];
		sort(x,x+4);
		p[j]=x[3];q[j]=x[2];
	}
	int s[1<<18];
	rep(j,1<<N){
		s[j]=p[j]+q[j];
	}
	int ans=0;
	rep1(j,(1<<N)-1){
		ans=max(ans,s[j]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7168
#include <stdio.h>

int main()
{
    int N;
    int L;
    int max;
    int i;
    int sum;

    scanf("%d", &N);
    sum = 0;
    max = -1;
    for(i = 0; i < N; i++) {
        scanf("%d", &L);
        sum += L;
        if(max < L) {
            max = L;
        }
    }

    if(max < (sum-max)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<int> ki[220000],ans;
int main()
{
    int n,q;
    cin >> n >> q;
    ans.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    queue<int> que;
    que.push(0);
    vector<bool> vis(n,false);
    while(!que.empty()){
        int now = que.front();que.pop();
        vis[now] = true;
        for(int next :ki[now]){
            if(vis[next])continue;
            ans[next] += ans[now];
            que.push(next);
        }
    }
    rep(i,n)cout << ans[i] << endl;

    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 1;
    for (int i = 0; i<n; i++){
        if((i<=n-2)&&(s.at(i)!=s.at(i+1)))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
    }

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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(dp(n,h)[n-1]);
    }
    static int[] dp(int n, int[] h) {
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.Abs(h[1]-h[0]);
        for(int i = 2; i < n; i ++) {
            dp[i] = Math.Min(Math.Abs(h[i]-h[i-1])+dp[i-1], Math.Abs(h[i]-h[i-2])+dp[i-2]);
        }
        return dp;
    }
}

Measured memory_bytes: 20064
X=int(input())

if 400<=X<=599:
    print(8)
    exit()
if 600<=X<=799:
    print(7)
    exit()
if 800<=X<=999:
    print(6)
    exit()
if 1000<=X<=1199:
    print(5)
    exit()
if 1200<=X<=1399:
    print(4)
    exit()
if 1400<=X<=1599:
    print(3)
    exit()
if 1600<=X<=1799:
    print(2)
    exit()
if 1800<=X<=1999:
    print(1)
    exit()


Measured memory_bytes: 9196
#include<iostream>
#include<unordered_map>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int n;
string s[1000005];
vector<string>V;

void input(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> s[i];
    V.push_back(s[i]);
  }
  for(int i = 0; i < n; ++i){
    sort(V[i].begin(), V[i].end());
  }
  sort(V.begin(), V.end());
}

ll solve(){
  ll cnt = 0;
  ll tmp = 0;
  for(int i = 0; i < n - 1; ++i){
    if(V[i] == V[i + 1]){
      tmp++;
      cnt += tmp;
    }else{
      tmp = 0;
    }
  }
  return cnt;
}

int main(){
  input();
  cout << solve() << endl;
}

Measured memory_bytes: 19828
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    ll n;
    cin>>n;
    ll A[n];
    loop(i,0,n){
        cin>>A[i];
    }
    sort(A, A+n);
    ll pro = 1;
    const ll bound = 1e18;
    loop(i,0,n){
        if(pro==0){
            break;
        }
        ll rem = bound/pro;
        if(A[i] > rem){
            pro = -1;
            break;
        }
        pro = pro * A[i];
    }
    cout<<pro<<endl;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int ans = 0;

int main(void) {
  // Here your code !
  cin >> s;

  for (auto e: s) {
    if (e == '+') ans += 1;
    else ans -= 1;
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 10

int main() {
	static int aa[N];
	int n, i, sum, max;

	scanf("%d", &n);
	max = sum = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (max < aa[i])
			max = aa[i];
		sum += aa[i];
	}
	printf(max < sum - max ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  
  int m, n, r, sum = 0;
  int i, j;
  int a[100][100], b[100];
 


  scanf("%d %d", &n, &m);
  for(i = 0; i < n; i++) {
    for(j = 0; j < m; j++) {
      scanf("%d", &r);
      a[i][j] = r;
    }
  }

  for(i = 0; i < m; i++) {
      scanf("%d", &r);
      b[i] = r;
  }

  for(i = 0; i < n; i++) {
    for(j = 0; j < m; j++) {
      sum += a[i][j] * b[j];
    }
    printf("%d\n", sum);
    sum = 0;
  }

  return 0;
}

Measured memory_bytes: 640
package main

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

func linearSearch05_2(s []int, n int, key int) bool {
	i := 0
	s = append(s, key)
	for s[i] != key {
		i++
	}
	return i != n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sarr := make([]int, n)
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		sarr[i], _ = strconv.Atoi(s)
	}

	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	tarr := make([]int, q)

	sum := 0
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		tarr[i], _ = strconv.Atoi(s)
		if linearSearch05_2(sarr, n, tarr[i]) {
			sum++
		}
	}
	fmt.Println(sum)
}



Measured memory_bytes: 6700
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)
	fmt.Fprintln(write, 6-a-b)
}


Measured memory_bytes: 640
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

long[] A;
long[] B;
Tuple!(long, long)[] X;
Tuple!(long, long)[] Y;


void main() {
    auto D = readln.chomp.to!long;

    A = new long[](10);
    B = new long[](10);
    X = new Tuple!(long, long)[](10);
    Y = new Tuple!(long, long)[](10);

    foreach (i; 0..10) {
        foreach (j; 0..10) {
            if (i >= j) {
                A[i-j] += 1;
                X[i-j] = tuple(i.to!long, j.to!long);
            } else {
                B[i-j+10] += 1;
                Y[i-j+10] = tuple(i.to!long, j.to!long);
            }
        }
    }

    long ans = 0;

    foreach (i; D.to!string.length.to!int..19) {
        ans += solve(D, i);
    }

    ans.writeln;
}

long solve(long D, int N) {
    int M = N/2 + N%2;

    long ans = 0;

    int[] DD;
    long d = D;
    for (int i = 0; i < N; ++i, d/=10) {
        DD ~= (d % 10).to!int;
    }

    foreach (mask; 0..(1 << M)) {
        long tmp = 1;
        long[] tmp1;
        long[] tmp2;
        bool carry = false;
        foreach (i; 0..M) {
            if (mask & (1 << i)) {
                if (carry) {
                    tmp *= A[(DD[i]+1)%10];
                    tmp1 ~= X[(DD[i]+1)%10][0];
                    tmp2 ~= X[(DD[i]+1)%10][1];
                    carry = DD[i] == 9;
                } else if (i == 0) {
                    tmp *= A[DD[i]] - 1;
                    tmp1 ~= X[DD[i]][0];
                    tmp2 ~= X[DD[i]][1];
                } else {
                    tmp *= A[DD[i]];
                    tmp1 ~= X[DD[i]][0];
                    tmp2 ~= X[DD[i]][1];
                    carry = false;
                }
            } else {
                if (carry && DD[i] == 9) {
                    tmp = 0;
                    break;
                } else if (carry) {
                    tmp *= B[DD[i]+1];
                    tmp1 ~= Y[DD[i]+1][0];
                    tmp2 ~= Y[DD[i]+1][1];
                } else if (i == 0) {
                    tmp *= B[DD[i]] - 1;
                    tmp1 ~= Y[DD[i]][0];
                    tmp2 ~= Y[DD[i]][1];
                    carry = true;
                } else {
                    tmp *= B[DD[i]];
                    tmp1 ~= Y[DD[i]][0];
                    tmp2 ~= Y[DD[i]][1];
                    carry = true;
                }
            }
        }

        if (tmp == 0) continue;
        if (N % 2 == 1) tmp1.popBack;
        long e = 0;
        long f = 0;
        foreach (i; tmp1) e *= 10, e += i;
        foreach_reverse (i; tmp2) e *= 10, e += i;
        foreach (i; tmp2) f *= 10, f += i;
        foreach_reverse (i; tmp1) f *= 10, f += i;
        if (f - e != D) tmp = 0;
        ans += tmp;
    }

    return ans;
}


Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    int h, w;
    cin>>h>>w;
    char a[h][w];
    bool flagh[h]={false};
    bool flagw[w]={false};
    rep(i, h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<h;i++){
        bool flag=true;
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') flag=false;
        }
        if(flag) flagh[i]=true;
    }

    for(int j=0;j<w;j++){
        bool flag=true;
        for(int i=0;i<h;i++){
            if(a[i][j]=='#') flag=false;
        }
        if(flag) flagw[j]=true;
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(flagw[j] || flagh[i]){}
            else{
                cout<<a[i][j];
            }
        }
        
        if(flagh[i]==false)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define MOD (ll)(1e9+7)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int c[2001][2001];
void init()
{
	For(i,0,2000)
	{
		c[i][0]=1;
		For(j,1,i) c[i][j]=(c[i-1][j]+c[i-1][j-1])%MOD;
	}
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	init();
	/*
	For(i,0,3)
		For(j,0,i)
			cout<<i<<" "<<j<<" "<<c[i][j]<<"\n";
	*/
	int n,b; cin>>n>>b;
	int r=n-b;
	For(i,1,b)
	{
		cout<<c[b-1][i-1]*c[r+1][i]%MOD<<"\n";
	}
	return 0;
}















Measured memory_bytes: 30080
import sys
input = sys.stdin.readline
Q = int(input())

LR = []
for _ in range(Q):
    l,r = map(int, input().split())
    LR.append((l,r))
    
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return {i: True for i in range(n + 1) if is_prime[i]}

prime_dict = primes(10**5)
like_2017 = []
for n in prime_dict:
    if (n+1)//2 in prime_dict:
        like_2017.append(n)
#print(like_2017)
like_2017 = list(sorted(like_2017))


from bisect import bisect_left, bisect_right

def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    return i

for l, r in LR:
    if l == r:
        if l in like_2017:
            print(1)
        else:
            print(0)
    else:
        l_idx = index(like_2017, l)
        r_idx = index(like_2017, r)
        if r in like_2017:
            r_idx += 1
        print(r_idx-l_idx)

Measured memory_bytes: 67932
#include <bits/stdc++.h>
using namespace std;
 
#define     all(x) x.begin(),x.end()
#define     ff first
#define     ss second
#define     ll long long
#define     ld long double
#define     pb push_back
#define     MOD 1000000007
#define     REP(i,n) for(ll i=0;i<(n);i++)
#define     FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define     FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define     BLOCK 555

typedef     vector <ll> vll;
typedef     vector <pair<ll,ll>> vp;
typedef     vector<vector<ll> >vvll;

// log(y) power calculation
ll power_mod(ll x, ll y, ll m){
    ll ans = 1;
    x%=m;
    while(y){
        if(y&1){
            ans=(ans*x)%m;
        }
        y>>=1;
        x=(x*x)%m;
    }
    return ans;
}

ll power(ll x, ll y){
    ll ans = 1;
    while(y){
        if(y&1){
            ans*=x;
        }
        y>>=1;
        x = x*x;
    }
    return ans;
}


ll mod_inv(ll x,ll m){
    return power_mod(x,m-2,m);
}


// customized hash function for lowering the collision in UNORDERED_MAP
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
 

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    if(a.ff == b.ff){
        return (a.second < b.second); 
    }
    return (a.ff < b.ff); 
} 

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

bool isPalindrome(string s){
    bool flag = true;
    for(int i=0;i<s.length()/2;i++){
        if(s[i]!=s[s.length()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}


void solve(){
   string s;
   cin>>s;
   int n = s.length();

   if(isPalindrome(s) and isPalindrome(s.substr(0,n/2)) and isPalindrome(s.substr(((n+3)/2)-1,n/2))){
        cout<<"Yes"<<endl;
   }
   else{
    cout<<"No"<<endl;
   }

}


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


    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}


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

namespace Project2
{
    class Buffet
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            int N = int.Parse(s);
            int sum = 0;

            s = Console.ReadLine();
            int[] a = s.Split(' ').Select(y =>int.Parse(y)).ToArray();

            s = Console.ReadLine();
            int[] b = s.Split(' ').Select(y => int.Parse(y)).ToArray();

            s = Console.ReadLine();
            int[] c = s.Split(' ').Select(y => int.Parse(y)).ToArray();

            for (int i = 0; i < N; i++)
            {
                sum += b[a[i]-1];
                if(i != N - 1)
                {
                    if (a[i + 1] == a[i] + 1)
                    {
                        sum += c[a[i]-1];
                    }
                }
                
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const ll inf = 1LL<<60;

int main()
{
  int n; cin >> n;
  set<int> st;
  bool flg = true;
  rep(i, n) {
    int a; cin >> a;
    if (st.count(a) > 0) flg = false;
    st.insert(a);
  }
  if (flg) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;

const int MAXN = 1000001;

const int MOD = 998244353;

class Num {
    ll value;

    static Num& convert(ll& v) {
        return reinterpret_cast<Num&>(v).mod();
    }

    static Num convert(ll&& v) {
        return v;
    }

public:

    Num(ll v = 0)
        : value(v) {
        mod();
    }

    Num& mod() {
        value %= MOD;
        return *this;
    }

#define Op(op) decltype(auto) operator op(const Num& other) {return convert(value op other.value);}

    explicit operator ll() {
        return value;
    }

    Op(+) Op(*) Op(-) Op(+=) Op(*=)
};

ll pw(ll a, int b = MOD - 2) {
    if (b == 0) return 1;
    ll v = pw(a, b / 2);
    v = (v * v) % MOD;
    if (b & 1) v = (v * a) % MOD;
    return v;
}

Num rever(Num other) {
    return pw(ll(other));
} 

Num fact[MAXN];
Num rev[MAXN];
const Num rev2 = (MOD + 1) / 2;

Num cnk(ll n, ll m) {
    return fact[n + m] * rev[m] * rev[n];
}

    
int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int n, m;
    cin >> n >> m;
    int s = n + m;
    fact[0] = 1;
    for (int i = 1; i <= s; i++) {
        fact[i] = fact[i - 1] * i;
    }

    rev[s] = rever(fact[s]);

    for (int i = s - 1; i >= 0; i--)
        rev[i] = rev[i + 1] * (i + 1);

    Num ans = cnk(n, m) * (2ll * max(n, m) - 1);

    for (int i = 0; i <= min(n, m); i++) {
        ans += cnk(i, i) * cnk(n - i, m - i);
    }

    ans *= rever(cnk(n, m));
    ans *= rever(2);

    cout << ll(ans) << "\n";
}

Measured memory_bytes: 15872
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.List (sort, group)
import qualified Data.Map as M

combination::Int->Int
combination count | count < 2 = 0
                  | otherwise = div (count*(count-1)) 2

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  getLine
  an <- getInts
  let valueFreq = M.fromList $ map (\x -> (head x,length x)) $ group $ sort an
  let overall = M.foldl (\acc cnt -> acc + combination cnt) 0 valueFreq
  mapM_ print $ map (\x -> overall - ((fromJust $ M.lookup x valueFreq)-1)) an


Measured memory_bytes: 67324
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int dis[N];
int vis[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	MEM(dis, 0x3f);
	cin >> n;
	typedef pair<int, int> Node;
	priority_queue<Node, vector<Node>, greater<Node>> pq;
	for (int i = 1; i < 10; i++)
	{
		dis[i%n] = i;
		pq.emplace(dis[i%n], i);
	}
	while (!pq.empty())
	{
		int x, d;
		tie(d, x) = pq.top();
		pq.pop();
		if (vis[x]) continue;
		vis[x] = 1;
		for (int i = 0; i < 10; i++)
		{
			int o = (x * 10 + i) % n;
			if (dis[o] > d + i)
			{
				dis[o] = d + i;
				pq.emplace(dis[o], o);
			}
		}
	}
	cout << dis[0] << endl;
	return 0;
}


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

long long gcd(long long x, long long y){
    if(y == 0) return x;
    else return gcd(y, x % y);
}

int main() {
    long long N, M; cin >> N >> M;
    long long A[N];
    long long even = 0;
    bool dif = false;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(i > 0){
            long long a = max(A[i], A[i-1]), b = min(A[i], A[i-1]);
            if(a % b == 0 && (a / b) % 2 == 0) dif = true;
        }
    }

    if(dif){
        cout << "0" << endl;
        return 0;
    }

    for (int i = 0; i < N; i++)
    {
        A[i] /= 2;
    }


    long long lcm = 1;
    for (int i = 0; i < N; i++)
    {
        lcm = A[i] / gcd(A[i], lcm) * lcm;
    }

    long long ans = M / lcm;
    ans = (ans + 1) / 2;
    cout << ans << endl;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

vi x(50,0);

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

template <typename T>
inline std::string to_bin_str(T n, std::size_t digit_num) {
   std::string str;
   while (n > 0) {
       str.push_back('0' + (n & 1));
       n >>= 1;
   }
   str.resize(digit_num, '0');
   std::reverse(str.begin(), str.end());
   return str;
}

int main(){
  int n,m,a,b;
  std::cin >> n >> m;
  vi x;
  map<int,int> y;
  rep(i,m){
    std::cin >> a >>b;
    if((a==1&&b==n)||(a==n&&b==1)){
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }else if(a==1){
      // x[b]++;
      x.emplace_back(b);
    }else if(b==1){
      x.emplace_back(a);
      // x[a]++;
    }else if(a==n){
      y[b]++;
      // y.emplace_back(b);
    }else if(b==n){
      y[a]++;
      // y.emplace_back(a);
    }
  }
  rep(i,x.size()){
    if(y[x[i]]>0) {
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }
  }
  std::cout << "IMPOSSIBLE" << std::endl;
  // std::set_difference(x.begin(), x.end(),
  //                       y.begin(), y.end(),
  //                       std::inserter(diff, diff.end()));
  //
  // rep(i,x.size()){
  //   std::cout << x[i] << std::endl;
  // }
  // std::cout  << std::endl;
  // rep(i,y.size()){
  //   std::cout << y[i] << std::endl;
  // }
  // std::cout  << std::endl;
  // rep(i,diff.size()){
  //   std::cout << diff[i] << std::endl;
  // }
  // sort(all(x));
  // sort(all(y));
  // rep(i,x.size())rep(j,y.size()){
  //   if(x[i]==y[j]){
  //     std::cout << "POSSIBLE" << std::endl;
  //     return 0;
  //   }
  //   else if(x[i]<y[j]) break;
  // }
  // std::cout << "IMPOSSIBLE" << std::endl;

}


Measured memory_bytes: 9976
#include <iostream>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int N;
    cin >> N;
    int V[N];
    int C[N];
    for(int i=0;i<N;i++){
		cin>>V[i];
	}
    for(int i=0;i<N;i++){
		cin>>C[i];
	}

    int seq1 = pow(2,N);

    int maximum = 0;
    REP(i,seq1){
        int cnt = 0;
        int X = 0;
        int Y = 0;
      	int tmp = i;
        while(tmp>0){
            if (tmp % 2 == 1){
                X += V[cnt];
                Y += C[cnt];
            }
            tmp /= 2;
          	if(tmp<=0) break;
            cnt ++;
        }
        if(maximum < X-Y) maximum = X-Y;
    }
	cout << maximum<< endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ID_min = 1
ID_max = N
for i in range(M):
    L_tmp,R_tmp = map(int,input().split())
    if ID_max < L_tmp or ID_min > R_tmp:
        ID_max = 0
        ID_min = 1
        break
    if L_tmp > ID_min:
        ID_min = L_tmp
    if R_tmp < ID_max:
        ID_max = R_tmp
print(ID_max - ID_min + 1)

Measured memory_bytes: 3060
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    input_raw = read_func().strip().split()
    [H] = [long(input_raw[0])]
    input_raw = read_func().strip().split()
    [W] = [long(input_raw[0])]

    print (N - H + 1) * (N - W + 1)

if __name__ == '__main__':
    main()

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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ans += i + 1;
	}
	cout << ans;
}

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

using namespace std;

int main()
{
	int n;	cin>>n;cin.ignore();
	while(n--){
		string s;
		getline(cin,s);
		if(s.length()>=7){
			for(int i=0;i<s.length()-6;i++){
				if(s.substr(i,7)=="Hoshino")
					s.replace(i,7,"Hoshina");
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

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

int main(){
  int tmax,tmi,n;
  int r[200000];

  cin >> n;
  for (int i=0;i<n;i++) cin >> r[i];
  tmax=-1000000001;
  tmi =0;
  for (int i=1;i<n;i++){
    if (r[i]-r[tmi]>tmax)tmax=r[i]-r[tmi];
    if (r[tmi] >r[i])tmi=i;
  }
  cout << tmax << endl;
  
  return 0;
}

Measured memory_bytes: 3848
N,X=map(int,input().split())
def f(a,b):
    if a>b:
        return f(b,a)
    if b%a==0:
        return a*(2*(b//a) - 1)
    return 2*(b//a)*a + f(b%a,a)
print(N+f(X,N-X))




Measured memory_bytes: 38256
#include<iostream>
using namespace std;
struct t{
	int h,m,s;
};

int main(){
	struct t in[3];
	struct t out[3];
	struct t stay[3];
	for(int i=0;i<3;i++){
		cin>>in[i].h>>in[i].m>>in[i].s>>out[i].h>>out[i].m>>out[i].s;
		stay[i].h = out[i].h - in[i].h;
		stay[i].m = out[i].m - in[i].m;
		stay[i].s = out[i].s - in[i].s;
		if(stay[i].s < 0){
			stay[i].m--;
			stay[i].s += 60;
		}
		if(stay[i].m < 0){
			stay[i].h--;
			stay[i].m += 60;
		}
		
	}
	for(int i=0;i<3;i++){
		cout<<stay[i].h<<" "<<stay[i].m<<" "<<stay[i].s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scan = new Scanner(System.in);
        double r = scan.nextDouble();
        System.out.printf("%.10f %.10f\n", r*r*Math.PI,2*r*Math.PI);

    }

}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    string s; std::cin >> s;
    int ans = 0;
    rrep(i, n-1) {
        string s1 = s.substr(0, i);
        string s2 = s.substr(i, n-i);
        vi vec(27);
        int tmp = 0;
        for (auto &c : s1) {
            vec[c-'a'] = 1;
        }
        for (auto &c : s2) {
            if (vec[c-'a']) tmp++, vec[c-'a']--;
        }
        chmax(ans, tmp);
    }
    std::cout << ans << "\n";
}


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

using namespace std;

int main(){

    string a;

    cin >> a;

    if(a=="SUN") cout << 7 << endl;
    if(a=="SAT") cout << 1 << endl;
    if(a=="FRI") cout << 2 << endl;
    if(a=="THU") cout << 3 << endl;
    if(a=="WED") cout << 4 << endl;
    if(a=="TUE") cout << 5 << endl;
    if(a=="MON") cout << 6 << endl;

    return 0;
}

Measured memory_bytes: 256
def f():
  s = input()
  k = int(input())
  ss = [s[i:] for i in range(len(s))]
  ss.sort()
  cnt = 0
  done = []
  for sb in ss:
    for i in range(len(sb)):
      res = (sb[0:i+1])
      if res not in done:
        done.append(res)
        cnt += 1
        if cnt == k:
          print(res)
          return
f()

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

int main() {
    long long X, Y;
    scanf("%lld %lld", &X, &Y);
    int ans = 0;
    while (X <= Y) {
        X *= 2;
        ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
inputs =  input()
inputs =  list(map(int, input().split()))
T = inputs[0]
A = inputs[1]
H =  list(map(int, input().split()))

minAveTemp = 999999999
num = 1
ansNum = 1
for height in H:
    aveTemp = T - height * 0.006
    if abs(A-minAveTemp) > abs(A-aveTemp):
        minAveTemp = aveTemp
        ansNum = num
    num+=1

print(ansNum)

Measured memory_bytes: 3064
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    int a,b,n;
    cin>>a>>b>>n;
    int x=min(b-1,n);
    cout<<(a*x)/b<<ln;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int n,m;
string s;

void solve() {
	string a;
	int x, y;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a;
			if (a == "snuke") { y = i+1; x = j; }
		}
	}
	cout << ALP[x] << y << endl;
}

int main() {
	cin >> n>>m;
	solve();
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    while (s != "0")
    {
        int sum = 0;
        for (int i = 0; i < s.length(); i++)
        {
            sum += s[i] - '0';
        }
        cout << sum << endl;
        cin >> s;
    }
    return 0;
}



Measured memory_bytes: 3228
using System;

class Program {
    static void Main( string[] args )
    {
        while ( true ) {
            string[] s = Console.ReadLine().Split();

            if ( "?" == s[ 1 ] ) {
                break;
            }

            int a = int.Parse( s[ 0 ] );
            int b = int.Parse( s[ 2 ] );
            int r = 0;

            switch ( s[ 1 ] ) {
                default:
                case "+": { r = a + b; break; }
                case "-": { r = a - b; break; }
                case "*": { r = a * b; break; }
                case "/": { r = a / b; break; }
            }

            Console.WriteLine( r );
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  int k0, k1, k2, k3; //1, 10, 100, 1000の位
  k0=N%10;
  N=N/10;
  k1=N%10;
  N=N/10;
  k2=N%10;
  N=N/10;
  k3=N%10;
  if(k0==k1 && k1==k2){
    cout << "Yes" << endl;
  }
  else if(k1==k2 && k2==k3){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int f[4][4];
int main()
{   ios::sync_with_stdio(false);
    int i,j,a;
    cin>>f[1][1]>>f[1][2]>>f[2][2];
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][2]=a-f[1][2]-f[2][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[3][1]-f[3][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    for(i=1;i<=3;i++)
    {   for(j=1;j<=3;j++)
            cout<<f[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split(' ')))+[0]
D=[abs(A[i+1]-A[i]) for i in range(N+1)]
S=sum(D)
for i in range(N):
  print(S-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]))

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

int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  int ans1=0;
  int ans2=0;
  int num=0;
  for(int i=0; i<n; i++){
    cin>>x.at(i);
    num+=x.at(i);
  }
  num/=n;
  for(int i=0; i<n; i++){
    ans1+=pow(x.at(i)-num,2);
  }
  for(int i=0; i<n; i++){
    ans2+=pow(x.at(i)-num-1,2);
  }
  cout<<min(ans1,ans2)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
using namespace std;
#define WHITE 0
#define BLACK 1

int H, W, K;

int calc_K(vector<vector<int>> vec, vector<int> HL){
    int K = 0;
    for ( int i = 0; i < H; i++){
        if (HL[i] == 1) continue;
        for ( int j = 0; j < W; j++){
          if (HL[j+H] == 1) continue;     
          if (vec[i][j] == BLACK) K += 1;
        }
    }   
    return K;
}

int rec(vector<vector<int>> vec, vector<int> HL, int decision_H){
    int number_of_choice;
    number_of_choice = 0;
    int next_decision_H = decision_H;
    if (decision_H == H + W){
        if (calc_K(vec, HL) == K) return 1;
        else return 0;
    }
    next_decision_H += 1;
    vector<int> HL1 = HL; 
    vector<int> HL2 = HL;
    HL1[decision_H] = 0;
    HL2[decision_H] = 1;
    number_of_choice += rec(vec, HL1, next_decision_H);
    number_of_choice += rec(vec, HL2, next_decision_H);
    return number_of_choice;
}

int main(){

    string v;
    cin >> H >> W >> K;
    vector<vector<int>> vec(H, vector<int>(W,0));
    vector<int> HL(H+W, 0);

    for ( int i = 0; i < H; i++){
        cin >> v;
        for ( int j = 0; j < W; j++){
            char vj = v[j];
            if (vj == '.') vec[i][j] = WHITE;
            else if (vj == '#') vec[i][j] = BLACK;                
        }
    }
    int count = rec(vec, HL, 0);
    cout << count <<endl;
}

Measured memory_bytes: 3664
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var x int
  var n int

  if sc.Scan() { n, _ = strconv.Atoi(sc.Text()) }

  for i := 1; i <= n; i++{
    x = i
    if x % 3 == 0 {
      fmt.Printf(" %d", i)
      continue
    }
    for ;x != 0; x /= 10{
      if x % 10 == 3 {
        fmt.Printf(" %d", i)
        break
      }
    }
  }
  fmt.Println()
}



Measured memory_bytes: 1140
A,B,C,D=map(int,input().split())
#Aは高橋体力、Cは青木体力
#Bは高橋攻撃,Dは青木攻撃
while(1):
    C=C-B
    if C <= 0:
        print("Yes")
        break
    A=A-D
    if A <= 0:
        print("No")
        break

Measured memory_bytes: 9152
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

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

def min(a,b)
  return a>b ? b : a
end
s=get_nsp
t=get_nsp
s_size=s.size
t_size=t.size
dp=array(t_size+1,s_size+1,0)
for i in 1..s_size
  dp[i][0]=i
  for j in 1..t_size
    dp[0][j]=j
    c=(s[i-1]==t[j-1] ? 0 : 1)
    dp[i][j]=min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+c)
  end
end
puts dp[s_size][t_size]


Measured memory_bytes: 14736
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)


int main() {
	bool box[100001] = {};
	int how[100001] = {};
	for(int i = 0;i < 100001;i++){
		how[i] = 1;
	}
	box[0] = true;

	int n, m, x, y;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> x >> y;
		x--;
		y--;
		if(box[x]) box[y] = true;
		how[x]--;
		if(how[x] == 0) box[x] = false;
		how[y]++;
	}

	int ans = 0;
	for(int i = 0;i < 100001;i++){
		if(box[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
Imports System

Class B
	Shared Sub Main
		Dim n As Integer
		Dim inputs() As String
		Dim ans As Boolean = True

		inputs = Console.ReadLine().Split()
		n = Integer.Parse(inputs(0))

		inputs = Console.ReadLine().Split()
		For i As Integer = 0 To n-1
			Dim data As Integer
			data = Integer.Parse(inputs(i))
			If data Mod 2 = 0
				If data Mod 3 = 0 OrElse data Mod 5 = 0
					'OK
				Else
					ans = False
				End If
			End If
		Next
		
		If ans
			Console.WriteLine("APPROVED")
		Else
			Console.WriteLine("DENIED")
		End If

	End Sub
End Class


Measured memory_bytes: 13140
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
using namespace std;

ll dp[3005][3005];

void getlcs(string s,string t,ll l)
{
    vector <char> lcs;
    ll i=s.size(),j=t.size();
    while(l>0)
    {
        if(s[i-1]==t[j-1])
        {
            lcs.pb(s[i-1]);
            i--; j--;
            l--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }
    for(ll i=lcs.size()-1;i>=0;i--) cout<<lcs[i];
    cout<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    ll a=-1,b=-1,ans=0;
    map <ll,ll> m;
    for(ll i=1;i<=s.size();i++)
    {
        for(ll j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
                if(m[dp[i][j]]==0)
                {
                    ans = max(ans,dp[i][j]);
                    a=i,b=j;
                    m[dp[i][j]]++;
                }
            }
            else
                {
                    dp[i][j]=max(dp[i-1][j-1],max(dp[i-1][j],dp[i][j-1]));
                }
        }
    }
    vector <char> v;
    if(ans==0) cout<<" "<<endl;
    else{
    getlcs(s,t,ans);
    }

}


Measured memory_bytes: 74288
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

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

int main()
{
  ll h,w,k;
  cin>>h>>w>>k;
  pair<ll,ll> start,goal;
  cin>>start.first>>start.second;
  cin>>goal.first>>goal.second;
  start.first--;start.second--;
  goal.first--;goal.second--;
  vector<string> field(h);
  for (ll i = 0; i < h; ++i)
  {
    cin>>field[i];
  }
  vector<vector<ll>> dist(h,vector<ll>(w,-1));
  vector<vector<bool>> seen(h,vector<bool>(w,false));
  queue<pair<ll,ll>> next;
  dist[start.first][start.second]=0;
  seen[start.first][start.second]=true;
  next.push(start);
  while(!next.empty())
  {
    ll x=next.front().first,y=next.front().second;
    next.pop();
    for (ll i = 0; i < 4; ++i)
    {
      bool flag=true;
      for (ll j = 1; j <= k; ++j)
      {
        if(!flag) break;
        ll nx=x+dx[i]*j,ny=y+dy[i]*j;
        if(nx<0||nx>=h||ny<0||ny>=w) 
        {
          flag=false;
          continue;
        }
        if(field[nx][ny]=='@') 
        {
          flag=false;
          continue;
        }
        if(dist[nx][ny]==dist[x][y]+1) continue;
        if(seen[nx][ny]) 
        {
          flag=false;
          continue;
        }
        dist[nx][ny]=dist[x][y]+1;
        seen[nx][ny]=true;
        next.push(make_pair(nx,ny));
      }
    }
  }
  cout<<dist[goal.first][goal.second]<<endl;

}

Measured memory_bytes: 20000