akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n,k,q;
  cin>>n>>k>>q;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  
  int ans=1e9;
  int x;
  int l;
  vector<int> temp;
  vector<int> temp2;
  REP(i,n){
    x = a[i];
    temp.clear();
    temp2.clear();
    REP(i,n){
      if(a[i]<x){
        sort(temp.begin(),temp.end());
        l = temp.size();
        if(l<k){
          temp.clear();
          continue;
        }else{
          REP(j,l-k+1){
            temp2.push_back(temp[j]);
          }
          temp.clear();
        }
      }else{
        temp.push_back(a[i]);
        if(i==n-1){
          sort(temp.begin(),temp.end());
          l = temp.size();
          if(l<k){
            temp.clear();
            continue;
          }else{
            REP(j,l-k+1){
              temp2.push_back(temp[j]);
            }
            temp.clear();
          }
        }
      }
    }
    sort(temp2.begin(),temp2.end());
    l = temp2.size();
    if(l<q){
      continue;
    }else{
      ans = min(ans,temp2[q-1]-temp2[0]);
    }
  }
  
  cout<<ans<<endl;  
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n;
int main()
{
  cin >> n;
  int a[n];
  int cnt = 0;
  rep(i, n){
    cin >> a[i];
    while(a[i] % 2 == 0){
      a[i] = a[i] / 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		n, q, l, r int
		s          string
	)
	fmt.Scan(&n, &q, &s)
	nums := make([]int, n+1)
	for j := 0; j < (n - 1); j++ {
		if string(s[j:(j + 2)]) == "AC" {
			nums[j+1] = nums[j] + 1
		} else {
			nums[j+1] = nums[j]
		}
	}
	for i := 0; i < q; i++ {
		fmt.Scan(&l, &r)
		fmt.Println(nums[r-1] - nums[l-1])
	}
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int A[201010];

signed main(void){ 
  int N; cin >> N;
  map<int,int> mp;
  for(int i = 0; i < N; i++){ 
    cin >> A[i];
    mp[A[i]]++;
  }
  
  int ans = 0;
  
  for(auto ne : mp ){ 
    ans += (ne.second*(ne.second-1))/2;
  }
  
  if(true){
  
  for(int i = 0; i < N; i++){ 
    // aを除いた場合の数はどうなるか　↪︎ mp[a]だけ減る
    cout << ans - (mp[A[i]]-1) << endl;
  }
  } 
  
  return 0;
}

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

int main() {
  char C;
  cin >> C;
  if ( C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u' ){
    cout << "vowel" << endl;
  }
  else {
  cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	string s;
	int cnt,n;
	cin>>s;
	n=s.length();
	for(int i=0;i<n;i++){
		if(s[i]=='p') cnt++;
	}
	cout<<n/2-cnt<<endl;
	return 0;
}

Measured memory_bytes: 4608
nu = gets.chomp.split(" ")
number = nu.map!{|x| x.to_i}
ci = gets.chomp.split(" ")
city = ci.map!{|x| x.to_i}
distance = Array.new(number[0], 0)
count1 = 0
count2 = 0

#D == city[i]と初期位置の差の最大公約数
for i in 0..number[0] - 1
  distance[i] = (city[i] - number[1]).abs
end
result = distance[-1]

if number[0] > 1

count1 = distance[1]
count2 = distance[0]
while count2 != count1 && count2 != 0 && count1 != 0
  if count2 > count1
    count2 %= count1
  else
    count1 %= count2
  end
end
if count1 == 0
  result = count2
else
  result = count1
end

if number[0] > 2
  count = 0
while count < number[0]
  count2 = distance[count]
  if distance[count] % result != 0
    while count2 != result && count2 != 0 && result != 0
      if count2 > result
        count2 %= result
      else
        result %= count2
      end
    end
  end
  if result == 0
    result = count2
  end
  count += 1
end
end

end

print result


Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    string S;
    cin >> S;
    ll ans=0;
    ll count=0;
    rep(i,S.size()){
        if (S[i]=='A'){
            count++;
        }
        else if (S[i]=='B'){
            if (count>0&&S[i+1]=='C'){
                ans+=count;
                i++;
            }
            else {
                count=0;
            }
        }
        else {
            count=0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static final int N = 300000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int answer;
		int[] table = new int[N + 1];
		for (int i = 0; i < N; i++)
			table[i] = 0;
		for (int i = 6; i <= N; i += 7) {
			table[i] = 1;
			table[i + 2] = 1;
		}
		for (int i = 6; i <= N; i++)
			if (table[i] == 1)
				for (int j = i * 2; j <= N; j += i)
					table[j] = 0;
		while (true) {
			int n = sc.nextInt();
			if (n == 1)
				break;
			System.out.print(n + ":");
			for (int i = 6; i < N; i++)
				if (table[i] == 1 && n % i == 0)
					System.out.print(" " + i);
			System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 26076
#include <stdio.h>

int main(void) {
  int x[4], y[4];
  scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
  int dx, dy, i;
  // 90度の回転と同じ (dx, dy)ベクトルに90度回転行列[[0,-1],[1,0]]をかけて前の位置に足す
  for(i = 2; i < 4; ++i) {
    dx = x[i-1] - x[i-2]; dy = y[i-1] - y[i-2];
	x[i] = x[i-1] - dy;
    y[i] = y[i-1] + dx;
  }
  printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	int N,M; cin>>N>>M;
	int a[M],b[M];

	int jud[N];
	rep(t , N){
		jud[t] = 0;
	}

	rep(i , M){
		cin>>a[i];
		cin>>b[i];
	}

	rep(j , N){
		for(auto x: a){
			if(x == j + 1)jud[j]++;
		}
		for(auto y: b){
			if(y == j + 1)jud[j]++;
		}
	}

	rep(l , N){
		cout<<jud[l]<<endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 10000006;
const ll MOD = 1000000007;

string s, t;

int z[MAXN], bst, dp[MAXN];
int cnts;

inline char sat (int pos) {
    if (pos < SZ(t)) {
        return t[pos];
    } else if (pos == SZ(t)) {
        return '@';
    } else {
        return s[(pos-SZ(t)-1)%SZ(s)];
    }
}
int calc (int ss) {
    memset(z, 0, sizeof(z));
    memset(dp, 0, sizeof(dp));
    bst = 0;

    int sz = SZ(t) + 1 + ss * SZ(s);
    assert(sz < MAXN);
    debug(sz);

    REP1 (i, sz-1) {
        if (bst+z[bst] > i) {
            z[i] = min(bst+z[bst]-i, z[i-bst]);
        }

        while (i+z[i] < sz && sat(z[i]) == sat(i+z[i])) {
            z[i]++;
        }
        if (i+z[i] >= bst+z[bst]) {
            bst = i;
        }
    }

    int ret = 0;
    for (int i=SZ(t)+1; i<sz; i++) {
        if (z[i] == SZ(t)) {
            dp[i] = dp[i-SZ(t)] + 1;
            ret = max(ret, dp[i]);
        }
    }

    return ret;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> s >> t;

    cnts = (SZ(t)+SZ(s)-1)/SZ(s);

    int ans1 = calc(5*cnts);

    int ans2 = calc(7*cnts);

    if (ans2 > ans1) {
        cout << -1 << endl;
    } else {
        cout << ans1 << endl;
    }
    return 0;
}


Measured memory_bytes: 79900
/*
author : nit1n
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;


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

	int n ; 
	cin >> n ; 
	int num = n %10 ; 
	if(num == 2 || num ==4 || num == 5 || num == 7 ||num == 9 )
		cout << "hon"; 
	else if(num ==0 || num ==1 || num ==6 || num ==8)
		cout << "pon" ; 
	else 
		cout <<"bon" ; 

}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec	second
#define pb push_back

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

const int mod = 1e9 + 7;


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

	ll n;
	cin >> n;

	ll sum;
	if(n % 2 == 1){
		sum = (n * (n+1)/2) - n;
	}else{
		sum = (n / 2) * (n + 1) - n;
	}


	cout << sum << endl;
    return 0;
}



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

int main(){
  int a,b;
  int x,y;
  int xm=-100,ym=100;
  int n,m;
  cin>>n>>m>>a>>b;
  for(int i=0;i<n;i++){
    cin>>x;
    xm=max(xm,x);
  }
  for(int i=0;i<m;i++){
    cin>>y;
    ym=min(ym,y);
  }
  int result=0;
  if(xm<ym){
    for(int i=xm+1;i<=ym;i++){
      if(i>a&&i<=b)
	result=1;
    }
  }
  if(result==1)
    cout<<"No War\n";
  else
    cout<<"War\n";
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans,a=1,b=1,c=1,mod=1000000007;
  cin >> n;
  for(long i=0;i<n;i++) a=a*10%mod;
  for(long i=0;i<n;i++) b=b*9%mod;
  for(long i=0;i<n;i++) c=c*8%mod;
  a=(a+c)%mod;
  a=(a+mod-b)%mod;
  a=(a+mod-b)%mod;
  cout << a << endl;
}

Measured memory_bytes: 3616
# ABC073D - joisino's travel
from heapq import heappop, heappush
from itertools import permutations


def dijkstra(source: int) -> "Array[int]":
    # compute the distance of the shortest path from V_source to each vertex
    size = len(G)
    dist = [float("inf")] * size
    dist[source] = 0
    undetermined = size - 2  # V_0 and V_source are determined in 1-idx graph
    queue = [(0, source)]
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                dist[u] = cost + next_cost
                heappush(queue, (dist[u], u))
        undetermined -= 1
        if not undetermined:
            return dist
    return dist


def main():
    global G
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    dist = {v: dijkstra(v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8252
s = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

max = 0

current_max = 0

i = 0


while(i < (h.size - 1))
  if h[i] >= h[i+1]
    current_max += 1
  else
    max = [max, current_max].max
    current_max = 0
  end
  i+=1
end
if current_max > 0
  max = [max, current_max].max
end

puts max


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

int a[21];
int b[21];

int main() { // a * b / gcd(a,b) = lcd(a,b)
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			sum += (a[i] - b[i]);
		}
	}
	cout << sum << '\n';




}

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

int main() {
  int N, A, x;
  string op;
  cin >> N >> A;

  x = N % 500; 
  
  if (A >= x) {
    cout << "Yes" << endl;
  }
  else {
    cout  << "No" << endl;
  }
}

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

int main() {
    int d, n;
    cin>>d>>n;
    if (n != 100) {
        cout<<(int)(pow(100, d) * n)<<endl;
        return 0;
    } else {
        cout<<(int)(pow(100, d) * n) + (int)pow(100, d)<<endl;
    }
}


Measured memory_bytes: 3784
"use strict"

const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const N = input[0];
const S = input[1];
let max = 0;
let used = [];
for (let i = 1; i < N; i++) {
  const k = S.slice(i - 1, i);
  if (used.indexOf(k) >= 0) {
    used.splice(used.indexOf(k), 1);
  }
  for (let ii = i; ii < N; ii++) {
    if (k == S.slice(ii, ii + 1) && 0 > used.indexOf(k)) {
      used.push(k);
    }
  }
  if (used.length > max) max = used.length;
}
console.log(max);


Measured memory_bytes: 19528
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var u = xArray(1,n);
  var e = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var t = o.l().map(a=>a-1);
    e[t[0]].push(t[1]);
    e[t[1]].push(t[0]);
  }
  return treeDia(e)%3 === 1 ? "Second":"First";
}

function treeDia(e){
  var r = [0,-1];
  for(var i = 0; i < 2; i++){
    r[1] = -1;
    var q = [[...r,-1]];
    while(q.length){
      var t = q.pop(), v = t[0], l = t[1]+1, p = t[2];
      if(r[1] < l)r[0] = v, r[1] = l;
      for(var j = 0; j < e[v].length; j++){
        if(p === e[v][j])continue;
        q.push([e[v][j],l,v]);
      }
    }
  }
  return r[1];
}

Measured memory_bytes: 115300
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const 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 true; } return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (size_of(x) < size_of(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int size_of(int x) { return -parent[root(x)]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (string s; cin >> s&&s != "#";) {
		vector<int> a;
		vector<char> b;
		for (auto it = s.begin(); it != s.end();) {
			if (!isdigit(*it)) {
				if (*it != '(' && *it != ')') {
					b.emplace_back(*it);
				}
				it++;
			}
			else {
				int num = 0;
				while (it != s.end() && isdigit(*it)) {
					num *= 10;
					num += *it - '0';
					it++;
				}
				a.emplace_back(num);
			}
		}
		dump(a, b);
		int n = a.size(), m = b.size();
		assert(n - 1 == m);
		vector<int> d(m);
		int idx = 0;
		int depth = 0;
		rep(i, 0, s.size()) {
			if (s[i] == '(')depth++;
			else if (s[i] == ')')depth--;
			else if (!isdigit(s[i])) {
				d[idx] = depth;
				idx++;
			}
		}
		dump(d);
		int maxd = *max_element(all(d));
		dump(maxd);
		vector<int> p(m);
		iota(all(p), 0);
		unordered_set<int> st;
		do {
			bool invalid = false;
			int mind = INF;
			rep(i, 0, m) {
				if (mind < d[p[i]])
					invalid = true;
				chmin(mind, d[p[i]]);
			}
			if (invalid)
				continue;
			dump(p);
			vector<int> ta = a;
			UnionFind c(n);
			rep(i, 0, m) {
				int idx = p[i];
				int xi = c.root(idx), yi = c.root(idx + 1);
				int x = ta[xi], y = ta[yi];
				dump(x, b[idx], y);
				if (b[idx] == '+')
					x += y;
				else if (b[idx] == '-')
					x -= y;
				else if (b[idx] == '*')
					x *= y;
				else {
					if (y == 0) {
						invalid = true;
						break;
					}
					x /= y;
				}
				ta[xi] = ta[yi] = x;
				c.unite(xi, yi);
				dump(ta);
			}
			if (invalid)
				continue;
			st.emplace(ta[c.root(0)]);
		} while (next_permutation(all(p)));
		cout << st.size() << endl;
		dump(st);
	}
	return 0;
}

Measured memory_bytes: 3180
G = [list(map(int,input().split())) for i in range(3)]
deg = [0]*4
for x in G:
    deg[x[0]-1] += 1
    deg[x[1]-1] += 1
odd = 0
for x in deg:
    if x%2 == 1:
        odd += 1
if odd == 0 or odd ==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
n,d=map(int,input().split())
X=[]
kotae=0
for i in range(n):
    x=list(map(int,input().split()))
    X.append(x)
    for j in range(i):
        ans=0
        for p in range(d):
            ans+=abs(x[p]-X[j][p])**2
        if (ans**0.5).is_integer()==1:
            kotae+=1
print(kotae)

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String[] s = {"Alice","Bob","Draw"};
        int a = in.nextInt();
        int b = in.nextInt();
        if(a==1)
            a+=100;
        if(b==1)
            b+=100;
        if(a>b)
            System.out.println(s[0]);
        else if(b>a)
            System.out.println(s[1]);
        else
            System.out.println(s[2]);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)


int main() {
  int n,k;  cin>>n>>k;
    vector<int> h(n);
    int dp[100100];
   
    rep(i,n) cin>>h[i];

    for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      for(int j=2;j<=k;j++){
		if(i>j)dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
	   //iがjより大きいなら、２段降りる場合も考える
       }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main (String[] args)  {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((a==b && a!=c) || (b==c && b!=a) || (c==a && c!=b)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
 
	}

	
	

}


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

string n;

int main(){
    cin>>n;
    
    if(n.length()==2){
        cout<<n<<endl;
    }
    else{
        for(int i=0;i<3;i++){
            cout<<n[2-i];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    int N;
    cin >> N;
	string s;
    cin >> s;
    ll i;
    for(i=0;i<s.size();i++){
        cout<< (char)((int)(s[i]+N<='Z'?s[i]+ N:s[i]+N-26));
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x,a[101],num,sum=0;
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		num=(d-1)/a[i]+1;
		sum+=num;
	}
	printf("%d\n",sum+x);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int N;
vector<int> A;
vector<vector<int>> G;
vector<int> ans;
vector<int> L;
int length = 1;


void dfs(int v,int p=-1){
    for(int nv: G[v]){
        if(nv == p) continue;
        if(L[length-1] < A[nv]){
            L[length] = A[nv];
            length++;
            ans[nv] = length;
            dfs(nv,v);
            length--;
            L[length] = 0;
        }else{
            int temp = *lower_bound(L.begin(),L.begin()+length,A[nv]);
            *lower_bound(L.begin(),L.begin()+length,A[nv]) = A[nv];
            ans[nv] = length;
            dfs(nv,v);
            int itr = lower_bound(L.begin(),L.begin()+length,A[nv]) - L.begin();
            L[itr] = temp;
        }         
    }
}

int main(){
    cin >> N;
    A.resize(N);
    for(int i=0; i<N; i++) cin >> A[i];
    G.resize(N);
    for(int i=0; i<N-1; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    L = vector<int>(N+1,0);
    ans.resize(N);
    ans[0] = 1;
    L[0] = A[0];
    dfs(0);
    for(int i=0; i<N; i++){
        cout << ans[i] << enld;
    }
    return 0;
}


Measured memory_bytes: 27960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ll>x(n),y(n);
	
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	int res = 0, smallest, cur;
    for (int p : {1, -1}) {
        for (int q : {1, -1}) {
            smallest = p * x[0] + q * y[0] + 0;
            for (int i = 1; i < n; ++i) {
                cur = p * x[i] + q * y[i] ;
                res = max(res, cur - smallest);
                smallest = min(smallest, cur);
            }
        }
    }
	cout<<res<<'\n';	
	return 0;
}

Measured memory_bytes: 6348
#include<stdio.h>
int main(void)
{
	int i,n,k,h[100000],cnt;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	cnt=0;
	for(i=0;i<n;i++){
		if(k<=h[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define TASK "C-large"
#pragma comment(linker, "/STACK:171088640")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

double workTime() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code) {
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif

	int n, m, cnt[200010];
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		cnt[i] = 0;
	}
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		if (x == 1 || x == n) {
			++cnt[y];
		}
		else if (y == 1 || y == n) {
			++cnt[x];
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (cnt[i] == 2) {
			printf("POSSIBLE\n");
			my_return(0);
		}
	}
	printf("IMPOSSIBLE\n");

	my_return(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    int ans=0;
    cin>>a>>b>>c>>k;
    if(a+b+c<k)
    {
        cout<<a-c<<endl;
        return 0;
    }
    else{
        if(k-a<=0)
        {
            cout<<k<<endl;
            return 0;
        }
        ans=a;
        k=k-a;
        if(k-b<=0)
        {
            cout<<ans<<endl;
            return 0;
        }
        k=k-b;
        if(k>c)
        ans=ans-c;
        else
        ans=ans-k;
        cout<<ans<<endl;
        return 0;
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

ll divisors(ll n,bool a)
{
	ll ans = 0,h;
	for(ll i = 2; i<=sqrt(n);i++)
	{
		ll g = n%i;
		if(g==0)
		{
			ans++;
			h = n/i;
			if(h!=i)
				ans++;
			if(a)
			{
				if(h!=i)
					ans--;
				while(h%i==0)
					h/=i;
				if(h!=1 && h%i!=1)
					ans--;
			}
		}
	}
	return (ans+1);
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	if(n==2)
	{
		cout<<1<<endl;
		return 0;
	}
	ll h = divisors(n-1,0);
	h += divisors(n,1);
	cout<<h<<endl;
	return 0;
}

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

using namespace std;

int main() {
    int K, N;
    cin >> N >> K;
    vector<int> nums(N);
    for (int i = 0; i < nums.size(); i++) {
        cin >> nums[i] ;
    }
    sort(nums.begin(), nums.end());
    int res = 0 ;
    for (int i = 0; i < K; i++) {
        res += nums[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

int main(){
	string s;cin >> s;
	if(s[s.size()-1]=='s') s+="es";
	else s+="s";
	cout << s << endl;
	
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;

int N;
int A[MAX],ANS[MAX];

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
		ANS[A[i]-1] = i+1; 
	}
	for(int i=0;i<N;i++) printf("%d ",ANS[i]);
	printf("\n"); 
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int n, m, p, r, S; char t;
int main() {
	while (true) {
		cin >> n; if (!n) { break; } cin >> m;
		S = 0; p = 0; r = 0;
		for (int i = 0; i < m; i++) {
			cin >> t;
			if (t == 'I') {
				if (i == p + 2 && r > 0) {
					r++;
				}
				else {
					r = 1;
				}
				if (r > n) {
					S++;
				}
				p = i;
			}
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define TO_STRING(x) #x
# define debug(x) {cerr<<#x<<": "<<(x)<<"\n";}
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

int main()
{
    lint A, B;
    cin >> A >> B;
    if (A < B)
    {
        swap(A, B);
    }

    if ((A - B) % 2 == 0)
    {
        lint tmp = (A - B) / 2;
        cout << A - tmp << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
char str[110];
int i,j,k,l,m,n;
int n,e,s,w;
int a[105][7],b[105][7];
int t;
 
void input() {
 
  scanf("%d",&n);
 
  for(j=0;j<n;j++){
  for(i=0;i<6;i++){
    scanf("%d",&a[j][i+1]);
    b[j][i+1] = a[j][i+1];
    // printf("a[%d] = %d\n",i+1,a[i+1]);
  }
  }
}
 
void N() {
  t = a[m][1];
  a[m][1] = a[m][2];
  a[m][2] = a[m][6];
  a[m][6] = a[m][5];
  a[m][5] = t;
}
 
void S() {
  t = a[m][1];
  a[m][1] = a[m][5];
  a[m][5] = a[m][6];
  a[m][6] = a[m][2];
  a[m][2] = t;
}
 
void E() {
  t = a[m][1];
  a[m][1] = a[m][4];
  a[m][4] = a[m][6];
  a[m][6] = a[m][3];
  a[m][3] = t;
}
 
void W() {
  t = a[m][1];
  a[m][1] = a[m][3];
  a[m][3] = a[m][6];
  a[m][6] = a[m][4];
  a[m][4] = t;
}
 
void UF() {
 
  if(a[k][1] == a[m][1]) { // if qu == 1;
    // printf("qu == 1\n");
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][5]) strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
 
 
  }  else if(a[k][1] == a[m][2]) {  // if qu == 2;
    // printf("qu == 2\n");
    if(a[k][2] == a[m][3])  strcpy( str, "NWS");
    else if(a[k][2] == a[m][1] ) strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    N();
 
 
  } else if(a[k][1] == a[m][3]){ // if qu == 3;
    //   printf("qu(%d) == %d\n",qu[k],a[3]);    
    if(a[k][2] == a[m][6])  strcpy( str, "NWS");
    else if(a[k][2] == a[m][5])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][1]) strcpy(str,"NES");
    W();
 
 
  } else if(a[k][1] == a[m][4]) {
    if(a[k][2] == a[m][1]) strcpy( str, "NWS");
    if(a[k][2] == a[m][5])  strcpy(str ,"NEES");
    if(a[k][2] == a[m][6]) strcpy(str,"NES");
    E();
 
 
  } else if(a[k][1] == a[m][5]) {
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][6])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    S();
 
 
  } else if(a[k][1] == a[m][6]) {
    if(a[k][2] == a[m][3]) strcpy( str, "NWS");
    else if(a[k][2] == a[m][2])  strcpy(str ,"NEES");
    else if(a[k][2] == a[m][4]) strcpy(str,"NES");
    N();
    N();
  }
 
 
}
 
 
void output() {
 
  if(l == 6) printf("No\n");
  else printf("Yes\n");
}
 
void IF() {
 
  for(i=0;i<strlen(str);i++) {
 
    if(str[i] == 'N') N();
    else if(str[i] == 'S') S();
    else if(str[i] == 'W') W();
    else if(str[i] == 'E') E();
  }
}
 
int main() {
 
 
  input();
 
  for(k=0;k<n;k++) {
    for(m=0; m<n;m++) {
 
    UF();
     
    IF();
 
    l=0;
 
    if(k != m) {
    for(i=1; i<=6;i++) {
      if(a[k][i] == a[m][i]) l++;
      // printf("{a[%d][%d]=%d}  == {a[%d][%d]=%d} ?\n",k,i,a[k][i],m,i,a[m][i]);
    }
    }
 
    if(l == 6) break;
 
    }
    if(l ==6) break;
  }
 
   
    output();
 
 
 
  //  strlen(?) ???????????????(??°)
 
 
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
    #include <queue>
    using namespace std;
    int ans = 0x7ffffff;
    int movee[5][3];
    bool visited[848][848];
    int r,c,k;
    int sx,sy;
    int a[848][848];
    char s[1000];
    queue<int> q;
    void bfs(int x,int y,int step)
    {
    q.push(x);q.push(y);q.push(0);
    int cur_ans,cx,cy,cd,xx,yy,dd;
    visited[x][y] = true;
    while (!q.empty())
    {
    cx = q.front();
    q.pop();
    cy = q.front();
    q.pop();
    cd = q.front();
    q.pop();
    cur_ans = cx - 1;
    cur_ans = min(cur_ans,cy - 1);
    cur_ans = min(cur_ans,r - cx);
    cur_ans = min(cur_ans,c - cy);
    ans = min(ans,cur_ans);
    if(cd == k)
    {
    continue;
    }
    for(int i = 1;i <= 4; ++i)
    {
    xx = cx + movee[i][1];yy = cy + movee[i][2];
    if(xx < 1 || xx > r || yy < 1 || yy > c)
    {
    continue;
    }
    if(a[xx][yy] == 1 || visited[xx][yy])
    {
    continue;
    }
    visited[xx][yy] = 1;
    q.push(xx);
    q.push(yy);
    q.push(cd + 1);
    }
    }
    }
    int main ()
    {
    movee[1][1] = 1;movee[1][2] = 0;
    movee[2][1] = 0;movee[2][2] = 1;
    movee[3][1] = -1;movee[3][2] = 0;
    movee[4][1] = 0;movee[4][2] = -1;
    cin>>r>>c>>k;
    for(int i = 1;i <= r; ++i)
    {
    for(int j = 1;j <= c;j++)
    {
    char c;
    cin>>c;
    if(c == '#')
    {
    a[i][j] = 1;
    }
    else if(c == '.')
    {
    a[i][j] = 2;
    }
    else if(c == 'S')
    {
    sx = i;
    sy = j;
    a[i][j] = 2;
    }
    }
    }
    bfs(sx,sy,0);
    printf("%d\n",1 + (ans + k - 1) / k);
    return 0;
    } 

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	int n, m, a;
	while (cin >> n >> m >> a, n || m || a) {
		int amida[1000][101];
		rep(i, 1000) rep(j, 101) amida[i][j] = 0;
		rep(i, m) {
			int h, p, q;
			cin >> h >> p >> q;
			amida[1000 - h - 1][p] = q;
			amida[1000 - h - 1][q] = p;
		}
		rep(i, 1000) if (amida[i][a]) a = amida[i][a];
		cout << a << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int p[1005];
char a[1005][1005];

void f3(int x) {
	a[x][x] = a[x][x+1] = 'a';
	a[x][x+2] = a[x+1][x+2] = 'b';
	a[x+2][x+2] = a[x+2][x+1] = 'c';
	a[x+2][x] = a[x+1][x] = 'd';
}

void f4(int x) {
	a[x][x] = a[x][x+1] = 'a';
	a[x+1][x] = a[x+1][x+1] = 'b';
	a[x+2][x] = a[x+3][x] = 'c';
	a[x+2][x+1] = a[x+3][x+1] = 'd';
	a[x+2][x+2] = a[x+2][x+3] = 'e';
	a[x+3][x+2] = a[x+3][x+3] = 'f';
	a[x][x+2] = a[x+1][x+2] = 'g';
	a[x][x+3] = a[x+1][x+3] = 'h';
}

void f5(int x) {
	a[x][x] = a[x][x+1] = 'a';
	a[x][x+2] = a[x][x+3] = 'b';
	a[x][x+4] = a[x+1][x+4] = 'c';
	a[x+2][x+4] = a[x+3][x+4] = 'd';
	a[x+4][x+4] = a[x+4][x+3] = 'e';
	a[x+4][x+2] = a[x+4][x+1] = 'f';
	a[x+4][x] = a[x+3][x] = 'g';
	a[x+2][x] = a[x+1][x] = 'h';
	a[x+1][x+1] = a[x+1][x+2] = 'i';
	a[x+3][x+3] = a[x+2][x+3] = 'j';
}

void f7(int x) {
	a[x][x] = a[x][x+1] = 'a';
	a[x][x+3] = a[x][x+4] = 'b';
	a[x][x+6] = a[x+1][x+6] = 'c';
	a[x+3][x+6] = a[x+4][x+6] = 'd';
	a[x+6][x+6] = a[x+6][x+5] = 'e';
	a[x+6][x+3] = a[x+6][x+2] = 'f';
	a[x+6][x] = a[x+5][x] = 'g';
	a[x+3][x] = a[x+2][x] = 'h';
	a[x+1][x+1] = a[x+1][x+2] = 'i';
	a[x+1][x+5] = a[x+2][x+5] = 'j';
	a[x+5][x+5] = a[x+5][x+4] = 'k';
	a[x+5][x+1] = a[x+4][x+1] = 'l';
	a[x+2][x+2] = a[x+2][x+3] = 'm';
	a[x+4][x+4] = a[x+3][x+4] = 'n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	p[4] = 4, p[5] = 5;
	for (int i=6; i<=1000; i++) {
		if (p[i-4])
			p[i] = 4;
		else if (p[i-5])
			p[i] = 5;
	}

	int n;
	cin >> n;

	if (n % 3 == 0) {
		for (int i=0; i<n; i+=3)
			f3(i);
	} else if (p[n]) {
		for (int k=n; k>0; k-=p[k])
			(p[k] == 4 ? f4 : f5)(k - p[k]);
	} else if (n == 7) {
		f7(0);
	} else if (n == 11) {
		f7(0);
		f4(7);
	} else {
		cout << "-1\n";
		return 0;
	}

	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			cout << (a[i][j] ? a[i][j] : '.');
		}
		cout << '\n';
	}
}

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

int main() {
        char S[11], T[12];

        scanf("%s", S);
        scanf("%s", T);

        printf("%s\n", strncmp(S, T, strlen(S)) == 0 ? "Yes" : "No");

        return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e9;

vector<long long int> a, b;
vector<vector<int>> graph;
bool flag = true;

int DFS(int v, int parent_v){
    if(b[v] != -INF) return b[v];

    long long int sum = 0;
    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        DFS(child_v, v);
        sum += b[child_v];
    }
    // a[v] = b[v] + (sum - b[v]) / 2
    b[v] = 2 * a[v] - sum;

    if(b[v] < 0) flag = false;
    if((sum - b[v]) % 2 != 0) flag = false;

    long long int leakage = 0;
    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        leakage += max(0LL, b[child_v] - (sum - b[v])/2);
    }
    if(leakage > b[v]) flag = false;

    //cout << "b[" << v+1 << "] = " << b[v] << endl;
    return b[v];
}

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

    a.resize(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    graph.resize(n);
    vector<int> degree(n);
    for(int i=0; i<n-1; i++){
        int u, v;
        cin >> u >> v;
        u -= 1;
        v -= 1;

        graph[u].push_back(v);
        graph[v].push_back(u);
        degree[u] += 1;
        degree[v] += 1;
    }

    int root = -1;
    b.assign(n, -INF);
    for(int i=0; i<n; i++){
        if(degree[i] == 1) b[i] = a[i];
        else root = i;
    }
    if(root == -1){// tree with leaves only = o--o
        if(n == 2 && a[0] == a[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }

    DFS(root, -1);
    if(flag == false || b[root] != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 19140
import sys
from collections import Counter, defaultdict


def main():
  _, *a = map(int, sys.stdin.read().split())
  c = defaultdict(int, Counter(a))
  res = max(c[i - 1] + c[i] + c[i + 1] for i in range(max(a) + 1))
  print(res)


if __name__ == '__main__':
  main()

Measured memory_bytes: 19992
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll x, a;

void func() {
    cin >> x >> a;
    cout << ((x < a)? 0 : 10) << endl;
}

int main() {
    fast_io; cout_precision;
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


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

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % 2 == 0){
			System.out.print(n);
		}else{
			System.out.println(2 * n);
		}
	}
}


Measured memory_bytes: 22740
#include <stdio.h>

// x*yの四角形の面積の周の長さを出力
int main()
{
	int iInputX, iInputY;
	scanf("%d %d", &iInputX, &iInputY);

	printf("%d %d\n", iInputX * iInputY, 2 * iInputX + 2 * iInputY);

	return 0;
}


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

map<long long,__int128> dp;
long long a,b,c;
__int128 d;
long long dist[1001];
typedef pair<long long,long long> P;
__int128 INF=1e15;
bool visited[1001];

__int128 ans(long long x) {
    if (x<=1000) {
        return dist[x];
    }
    if (dp.find(x)!=dp.end()) {
        return dp[x];
    }
    __int128 ret=INF;
    if (x%2==0) {
        ret=min({ret,ans(x/2)+a,ans(x/2)+d*(x/2)});
    }
    else {
        ret=min({ret,ans(x/2)+a+d,ans(x/2+1)+a+d,ans(x/2)+d*(x-x/2),ans(x/2+1)+d*(x-x/2-1)});
    }
    if (x%3==0) {
        ret=min({ret,ans(x/3)+b,ans(x/3)+d*(x-x/3)});
    }
    else {
        ret=min({ret,ans(x/3)+b+(x%3)*d,ans(x/3+1)+b+(3-x%3)*d,ans(x/3)+d*(x-x/3),ans(x/3+1)+d*(x-x/3-1)});
    }
    if (x%5==0) {
        ret=min({ret,ans(x/5)+c,ans(x/5)+d*(x-x/5)});
    }
    else {
        ret=min({ret,ans(x/5)+c+(x%5)*d,ans(x/5+1)+c+(5-x%5)*d,ans(x/5)+d*(x-x/5),ans(x/5+1)+d*(x-x/5-1)});
    }
    dp[x]=ret;
    return ret;
}

int main(void) {
    int tc;
    scanf("%d\n",&tc);
    INF*=INF;
    for(int t=0;t<tc;t++) {
        dp.clear();
        long long n;
        long long dd;
        scanf("%lld %lld %lld %lld %lld\n",&n,&a,&b,&c,&dd);
        d=dd;
        vector<P> adj[1001];
        for(int i=0;i<=1000;i++) {
            if (i+1<=1000) {
                adj[i].push_back(P(i+1,d));
            }
            if (i-1>=0) {
                adj[i].push_back(P(i-1,d));
            }
            if (i*2<=1000) {
                adj[i].push_back(P(i*2,a));
            }
            if (i*3<=1000) {
                adj[i].push_back(P(i*3,b));
            }
            if (i*5<=1000) {
                adj[i].push_back(P(i*5,c));
            }
            dist[i]=INF;
            visited[i]=false;
        }
        dist[0]=0;
        priority_queue<P,vector<P>,greater<P>> pq;
        pq.push(P(0,0));
        dist[0]=0;
        while (!pq.empty()) {
            int now;
            do {
                now=pq.top().second;
                pq.pop();
            } while (!pq.empty()&&visited[now]);
            if (visited[now]) {
                break;
            }
            visited[now]=true;
            for(int i=0;i<adj[now].size();i++) {
                int nt=adj[now][i].first;
                if (dist[nt]>dist[now]+adj[now][i].second) {
                    dist[nt]=dist[now]+adj[now][i].second;
                    pq.push(P(dist[nt],nt));
                }
            }
        }
        printf("%lld\n",(long long)ans(n));
    }
}

Measured memory_bytes: 4900
a, b, c, x, y = map(int, input().split())

if x>=y:
    print(min(a*x+b*y, c*x*2, c*y*2+a*(x-y)))
elif x<y:
    print(min(a*x+b*y, c*y*2, c*x*2+b*(y-x)))

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        mat: [[i64; 3]; n],
    }
    let xs: Vec<i64> = mat.iter().map(|i| i[0]).collect();
    let ys: Vec<i64> = mat.iter().map(|i| i[1]).collect();
    let hs: Vec<i64> = mat.iter().map(|i| i[2]).collect();

    for x in 0..101 {
        for y in 0..101 {
            let mut pseudo_h = None;
            for i in 0..n {
                if hs[i] > 0 {
                    let tmp = (xs[i] - x).abs() + (ys[i] - y).abs() + hs[i];
                    match pseudo_h {
                        Some(h) => {
                            if h != tmp {
                                pseudo_h = None;
                                break;
                            }
                        }
                        None => {
                            pseudo_h = Some(tmp);
                        }
                    }
                } else {
                    // do nothing
                }
            }
            if let Some(h) = pseudo_h {
                // if hs[i] == 0, check h is correct.
                let mut correct = true;
                for i in 0..n {
                    if hs[i] == 0 {
                        let distance = (xs[i] - x).abs() + (ys[i] - y).abs();
                        if 0 < h - distance {
                            correct = false;
                            break;
                        }
                    }
                }
                if correct {
                    println!("{} {} {}", x, y, h);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n];
  REP(i, n) cin >> a[i];
  ll ans = 0;
  REP(i, n) REP(j, n) {
    if (a[i] > a[j]) {
      if (i < j) {
        ans += k * (k + 1) / 2;
        ans %= MOD;
      } else if (i > j) {
        ans += k * (k - 1) / 2;
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384