akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[5000000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 5000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k, h[400];
int dp[400][400];
//i番目まででj個消費された時の最小コスト
signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	n++;
	for (int i = 0; i < 400; i++) {
		for (int j = 0; j < 400; j++) {
			dp[i][j] = Inf;
		}
	}
	dp[0][0] = 0;
	dp[0][1] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int z = 0; z < i; z++) {
				dp[i][j] = min(dp[i][j], dp[z][j - 1] + max(0ll, h[i] - h[z]));
			}
		}
	}
	int ans = Inf;
	for (int i = 0; i < n; i++) {
		ans = min(ans, dp[i][n - k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll X,Y;

bool solve(){
    if(X == 2 || Y == 2)
        return false;
    
    bool gX=false, gY=false;

    if(X == 4 || X == 6 || X == 9 || X == 11)
        gX = true;

    if(Y == 4 || Y == 6 || Y == 9 || Y == 11)
        gY = true;

    return gX == gY;
}

int main(){
    cin >> X >> Y;

    if(solve())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int k = in.nextInt();
        int x = in.nextInt();
        out.println((500*k>=x)?"Yes":"No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22996
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    printf("%.2lf",2*3.14159*n);

    return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string a, b;
  cin >> a >> b;
  string res = "EQUAL";
  if (a.size() > b.size()) {
    res = "GREATER";
  } else if (a.size() < b.size()) {
    res = "LESS";
  } else {
    if (a == b) {
      res = "EQUAL";
    } else {
      res = a > b ? "GREATER" : "LESS";
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N, Q;
		int day[101];
		cin >> N >> Q;
		if( N == 0 && Q == 0 ) break;

		for(int i = 0; i < 101; i++)
			day[i] = 0;

		for(int i = 0; i < N; i++) {
			int M;
			cin >> M;
			for(int j = 0; j < M; j++) {
				int tmp;
				cin >> tmp;
				day[tmp] ++;
			}
		}

		//最大値を調べる
		int max = -1;
		int ans = -1;
		for(int i = 0; i < 101; i++) {
			if(day[i] > max) {
				max = day[i];
				ans = i;
			}
		}
		if(max >= Q)
			cout << ans << endl;
		else cout << 0 << endl;

	}

	
	//while(1){}
	return 0;
}

Measured memory_bytes: 1160
from collections import deque
q = deque()

def bfs(i, j):
    q.append((i, j))
    d[i][j] = 0
    c[i][j] = 1
    m = 0
    while len(q) != 0:
        S = q.popleft()
        i, j = S[0], S[1]
        if s[i + 1][j] == "." and c[i + 1][j] == 0:
            q.append((i + 1, j))
            d[i + 1][j] = d[i][j] + 1
            c[i + 1][j] = 1
            if d[i + 1][j] > m:
                m = d[i + 1][j]
        if s[i][j + 1] == "." and c[i][j + 1] == 0:
            q.append((i, j + 1))
            d[i][j + 1] = d[i][j] + 1
            c[i][j + 1] = 1
            if d[i][j + 1] > m:
                m = d[i][j + 1]
        if s[i - 1][j] == "." and c[i - 1][j] == 0:
            q.append((i - 1, j))
            d[i - 1][j] = d[i][j] + 1
            c[i - 1][j] = 1
            if d[i - 1][j] > m:
                m = d[i - 1][j]
        if s[i][j - 1] == "." and c[i][j - 1] == 0:
            q.append((i, j - 1))
            d[i][j - 1] = d[i][j] + 1
            c[i][j - 1] = 1
            if d[i][j - 1] > m:
                m = d[i][j - 1]
        c[i][j] = 2
    return m

h, w = map(int, input().split())
s = [["#"] + list(input()) + ["#"] for _ in range(h)]
s.insert(0, ["#" for _ in range(w + 2)])
s.append(["#" for _ in range(w + 2)])
ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == ".":
            d = [[-1 for _ in range(w + 2)] for _ in range(h + 2)]
            c = [[0 for _ in range(w + 2)] for _ in range(h + 2)]
            a = bfs(i, j)
            if a > ans:
                ans = a
print(ans)

Measured memory_bytes: 3316
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  for(int i = 1; i <= 1250; i++){
    if(a==(int)(i*1.08)-i && b==(int)(i*1.1)-i){
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	rt0;
}

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

int main() {
    int n,q;cin>>n>>q;
    vector<int> g[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);
    }
    int c[n]{};
    for (int i=0;i<q;i++) {
        int a,b;cin>>a>>b;
        a--;
        c[a]+=b;
    }
    queue<int> qu;
    qu.push(0);
    int vis[n]{};
    while (!qu.empty()) {
        int a=qu.front();
        qu.pop();
        vis[a]=1;
        for (int b:g[a])
            if (!vis[b]) {
                c[b]+=c[a];
                qu.push(b);
            }
    }
    for (int i=0;i<n;i++) {
        if (i!=0)
            cout<<' ';
        cout<<c[i];
    }
    return 0;
}

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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	cin >> n >> k;
	ll a[n], b[n + 1];
	scan(a, n);

	rep(j, 0, k, 1) {
		memset(b, 0, sizeof(b));
		rep(i, 0, n, 1) {
			ll mi = max(0LL, i - a[i]), mx = min(n - 1, i + a[i]);
			b[mi]++;
			b[mx + 1]--;
		}
		bool br = true;
		rep(i, 1, n, 1) {
			b[i] += b[i - 1];
			br = br && (a[i] == b[i]);
		}

		rep(i, 0, n, 1)	{
			if (a[i] != b[i])	br = false;
			a[i] = b[i];
		}

		if (br)	break;
	}

	rep(i, 0, n, 1)	cout << a[i] << " ";
}


Measured memory_bytes: 6716
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

string str;

string func(string s){
	string ret;
	int cnt = 0;
	rep(i,s.size()){
		if(s[i] == '['){
			int checker = 0;
			string tmp;
			while(true){
				i++;
				if(s[i] == '[') checker++;
				if(s[i] == ']' && checker == 0) break;
				if(s[i] == ']') checker--;
				tmp.push_back(s[i]);
			}
			ret += func(tmp);
		} else if(s[i] == '?'){
			ret.push_back('A');
			cnt = 0;
		} else if(s[i] == '+'){
			cnt++;
		} else if(s[i] == '-'){
			cnt--;
		} else{
			int x = s[i]-'A';
			x += cnt;
			x += 26*10;
			x %= 26;
			ret.push_back('A'+x);
			cnt = 0;
		}
	}
	reverse(ret.begin(),ret.end());
	return ret;
}

void solve(){
	string ans = func(str);
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}

int main(){
	while(cin >> str){
		if(str == ".") break;
		solve();
	}
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = 100;
		for(int i=0;i<n;i++)
		{
			m = (int)Math.ceil(m*1.05);
		}
		System.out.println(m*1000);
	}
}

Measured memory_bytes: 12000
from typing import Set


class UnionFind:
    """Union-Find: O(α(N))"""

    __slots__ = ["_data_size", "_first_idx", "_parents"]

    def __init__(self, data_size: int, is_zero_origin: bool = True) -> None:
        self._data_size = data_size
        self._first_idx = 0 if is_zero_origin else 1
        self._parents = [-1] * (data_size + self._first_idx)

    def __getitem__(self, x: int) -> int:
        """Find the group (root) of vertex x."""
        while self._parents[x] >= 0:
            x = self._parents[x]

        return x

    def __len__(self) -> int:
        """Count the number of groups (roots)."""
        return len(self.groups)

    @property
    def groups(self) -> Set[int]:
        """Return the set of groups (roots)."""
        return {
            self[x] for x in range(self._first_idx, self._data_size + self._first_idx)
        }

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected or not."""
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self[x], self[y]
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

    def unite_all(self, *vertices: int) -> None:
        """Unite the groups of all of the given vertices."""
        x = vertices[0]
        for y in vertices[1:]:
            self.unite(x, y)

    def get_size(self, x: int) -> int:
        """Return the size of the group vertex x belongs."""
        return -self._parents[self[x]]


def unionfind():
    # https://judge.yosupo.jp/problem/unionfind
    # https://atcoder.jp/contests/practice2/tasks/practice2_a
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    unionfind()


Measured memory_bytes: 145196
#include <iostream>
using namespace std;
int main()
{

    int H;
    cin >> H;
    int N;
    cin >> N;
    int P;

    for (int i = 0; i < N; i++)
    {
        cin >> P;
        H -= P;
    }

    if (H > 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    };

    return 0;
}

Measured memory_bytes: 888
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] a = nextIntArray(sc, N);

		sc.close();

		Arrays.sort(a);

		int alice = 0;
		int bob = 0;
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				alice += a[N - 1 - i];
			} else {
				bob += a[N - 1 - i];
			}
		}

		out.println(alice - bob);

	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23124
fun main(args: Array<String>) {
    // Your code here!
    var (n,k) = readLine()!!.split(" ").map{it.toInt()}
    var list = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    
    ans = list.filter{it >= k}.count()
    println(ans)
}


Measured memory_bytes: 48124
from collections import defaultdict
from collections import deque
n,q = map(int,input().split())
d = defaultdict(list)
dp = [0] * n
ep = [0] * n
for i in range(n-1):
    ta,tb = map(int,input().split())
    d[ta-1].append(tb-1)
    d[tb-1].append(ta-1)
for i in range(q):
    ta,tb = map(int,input().split())
    dp[ta-1] +=tb
ep[0]+=1
l = deque()
l.append(0)
used = [False] * n
while l:
    t = l.pop()
    used[t] = True
    for i in d[t]:
        if not used[i]:
            dp[i] += dp[t]
            l.append(i)
print(*dp)

Measured memory_bytes: 119512
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> x;
	for(int i=0;i!=n*2;++i){
		int temp;
		cin>>temp;
		x.push_back(temp);
	}
	sort(x.begin(),x.end());
	int ans=0;
	for(int i=0;i!=2*n;++i){
		if(!(i%2))
			ans+=x[i];
	}
	cout<<ans;
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  int ans=0;
  while(1) {
    int min_num = min(a,min(b,c));
    int count=0;
    if (min_num==a) {
      count++;
    }
    if (min_num==b) {
      count++;
    }
    if (min_num==c) {
      count++;
    }
    if(count==2) {
      if (min_num==a) {
        a++;
      }
      if (min_num==b) {
        b++;
      }
      if (min_num==c) {
        c++;
      }
    }
    else if(count==1) {
      if (min_num==a) {
        a+=2;
      }
      if (min_num==b) {
        b+=2;
      }
      if (min_num==c) {
        c+=2;
      }
    }
    else {
      break;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a=[0,0,0,0,0]
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
k=int(input())
for i in range(5):
  for j in range(5):
    if abs(a[i]-a[j])>k:
      print(":(")
      exit()
print("Yay!")


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int a,b;
  cin >> a >> b;
  cout << (b%a==0 ? a+b : b-a) << endl;
}



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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";

void solve( int test_case )
{
    int n;
    cin >> n;

    ll minn = LLONG_MAX;
    ll maxx = LLONG_MIN;

    vll v ( n );

    for ( int i=0 ; i<n ; i++ )
    {
        cin >> v[i];
        maxx = max ( maxx , v[i] );
        minn = min ( minn , v[i] );
    }

    ull ans = INT_MAX;
    for ( int i=minn ; i<maxx+1 ; i++ )
    {
        ull temp = 0;
        for ( int j : v )
            temp += (j-i)*(j-i);
        ans = min ( ans , temp );
    }

    cout << ans ; line

}

int main()
{fast
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
function main()
  
  N = parse(Int,readline())
  ans = String[]
  
  dict = Dict{String,Int64}()
  
  for i in 1:N
    
    S = chomp(readline())
    dict[S] = get(dict,S,0)+1
    
  end
  
  num_max = maximum(values(dict))
  
  for (x,y) in dict

    if y == num_max
      push!(ans,x)
    end
    
  end
  
  sort!(ans)
  
  println.(ans)
  
end

main()

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}
vec_int divisor(int n) {
  vec_int ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    map<string,int> num_map;
    rep(i,N){
        cin>>A.at(i);
        string num_str = to_string(A.at(i));
        if(num_map.count(num_str)==0){
            num_map[num_str]=1;
        }else{
            num_map[num_str]++;
        }
    }

    sort(A.begin(),A.end());

    int tot_num=0;
    for(int i=0;i<N;i++){
        if(num_map[to_string(A.at(i))]>1)continue;

        vec_int divisors = divisor(A.at(i));

        int flag = 0;
//        for(int val : divisors){
        for(int j=0;j<divisors.size()-1;j++){
            int val = divisors.at(j);
            //if(val==1)continue;
            auto iter1 =(lower_bound(A.begin(),A.end(), val)); 
            int dist = distance(A.begin(),iter1);
            if(A.at(dist)==val){
                //約数があったのでダメ
                flag=1;
                break;
            }
        }
        if(flag==0){
            tot_num++;
        }


    }

    cout<<tot_num<<endl;



    return 0;
}

Measured memory_bytes: 20368
#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;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }
vector<int> compress(vector<int>&a, vector<int>&b) {
	vector<int>ret;
	ret.insert(ret.end(), all(a));
	ret.insert(ret.end(), all(b));
	sort(all(ret));
	ret.erase(unique(all(ret)), ret.end());
	for (auto &o : a)o = distance(ret.begin(), lower_bound(all(ret), o));
	for (auto &o : b)o = distance(ret.begin(), lower_bound(all(ret), o));
	return ret;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N);
	rep(i, 0, N) { cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; }
	auto zipx = compress(x1, x2);
	auto zipy = compress(y1, y2);
	vector<vector<int>>field(zipx.size(), vector<int>(zipy.size(), 0));
	rep(i, 0, N) {
		field[x1[i]][y1[i]]++;
		field[x2[i]][y2[i]]++;
		field[x1[i]][y2[i]]--;
		field[x2[i]][y1[i]]--;
	}
	rep(i, 0, zipx.size())rep(j, 1, zipy.size())field[i][j] += field[i][j - 1];
	rep(i, 0, zipy.size())rep(j, 1, zipx.size())field[j][i] += field[j - 1][i];
	int ans(0);
	rep(i, 0, zipx.size() - 1)rep(j, 0, zipy.size() - 1) {
		if (field[i][j])ans += (zipx[i + 1] - zipx[i])*(zipy[j + 1] - zipy[j]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 128244
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(all(b));
    reverse(all(b));
    rep(i,n){
        if(a[i]==b[0]) cout<<b[1];
        else cout<<b[0];
        cout<<endl; 
    }
}

Measured memory_bytes: 4844
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	int f=1;
	cin>>s;
	if(s[0]!='A')f=0;
	int cn=0,cn2=0;
	FOR(i,2,s.length()-1){
		if(s[i]=='C')cn++;
	}
	if(cn!=1)f=0;
	FOR(i,0,s.length()){
		if(!('a'<=s[i]&&s[i]<='z'))cn2++;
	}
	if(cn2!=2)f=0;
	if(f)cout<<"AC";
	else cout<<"WA";
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long 
#define fast cin.sync_with_stdio(false);
using namespace std;


int main()
{
 

	int n;
	cin>>n;
	int grid[n][3];

	int ans=-1;

	for(int i=0;i<n;i++)
		for (int j=0;j<3;j++)
			cin>>grid[i][j],ans=max(ans,grid[i][j]);



	for (int i=1;i<n;i++)
	{
		for (int j=0;j<3;j++)
		{
			int val=-1;
			for (int k=0;k<3;k++)
			{
				if (k!=j)
					val=max(val,grid[i-1][k]);
			}

			grid[i][j]+=val;
			ans=max(ans,grid[i][j]);
		}
	}

	cout<<ans;


}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
  int a,b,x;
  int ababa;
  scanf("%d %d %d",&x,&a,&b);
  ababa=b-a;
  if(a>=b){printf("delicious\n");}
  else if(x>=ababa){printf("safe\n");}
  else{printf("dangerous\n");}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c;
    cin >> a >> b >> c ;
    
    if(a % b == 0){
        cout << (a / b) * c << endl;
    } else {
        cout << (a / b + 1) * c << endl;
    }

    
}


Measured memory_bytes: 3572
#include<stdio.h>
#include<limits.h>
#define INF INT_MAX
#define NIL (-1)
#define FIRST 1
#define SECOND 2
#define MAX 101
int datanum;
int M[MAX][MAX];
void dijkstra(){
  int minv,i,u,v;
  int d[MAX],houmon[MAX];
  for(i=0;i<datanum;i++){
    d[i] = INF;
    houmon[i] = 0;
  }
  
  d[0] = 0;
  houmon[0] = FIRST;
  
  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<datanum;i++){
      if(minv > d[i] && houmon[i] != SECOND){
	u = i;
	minv = d[i];
      }
    }
    if(u == NIL)break;
    houmon[u] = SECOND;
    for(i=0;i<datanum;i++){
      if(houmon[i] != SECOND && M[u][i] != INF){
	if(d[i] > d[u] + M[u][i]){
	  d[i] = d[u] + M[u][i];
	  houmon[i] = FIRST;
      }
    }
  }
}
  for(i=0;i<datanum;i++){
    printf("%d ",i);
    if(d[i] == INF)printf("-1\n");
    else printf("%d\n",d[i]);
  }

  return;
}







int main(){
   int i,j,u,k,c,v;
   scanf("%d",&datanum);
   //INF で初期化
   for(i=0;i<datanum;i++){
     for(j=0;j<datanum;j++){
       M[i][j] = INF;
     }
   }
   for(i=0;i<datanum;i++){
     scanf(" %d %d",&u,&k);
     for(j=0;j<k;j++){
       scanf(" %d %d",&v,&c);
       M[u][v] = c;
     }
   }
   dijkstra();
   
   return 0;
 }



Measured memory_bytes: 2104
#include<cstdio>
#include<algorithm>

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

using namespace std;

int ans; // ツ暫ツ津ィツ嘉ー
void dfs(int i,int sum,int *a,int now=0){
	// ツ篠ゥツ鳴セツづ按枝ツ環?づィ
	int rem=sum;
	for(int j=1;j<10;j++) rem+=a[j]*j;
	if(now+rem/10<=ans) return;

	ans=max(ans,now);

	if(sum==10){
		dfs(1,0,a,now+1);
		return;
	}
	if(i>=10) return;

	dfs(i+1,sum,a,now);
	if(a[i]>0 && sum+i<=10){
		a[i]--;
		dfs(i,sum+i,a,now);
		a[i]++;
	}
}

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[10]={};
		rep(i,n){
			int b; scanf("%d",&b);
			a[b]++;
		}

		int sum=0;
		for(int i=1;i<5;i++){
			int c=min(a[i],a[10-i]);
			sum+=c;
			a[i]-=c;
			a[10-i]-=c;
		}
		{ // i==5
			sum+=a[5]/2;
			a[5]%=2;
		}

		ans=-1;
		dfs(1,0,a);
		printf("%d\n",sum+ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main()
{
	int SIZE;

	std::cin >> SIZE;

	int* array = (int*)malloc(sizeof(int) * SIZE);
	for (int i = 0; i < SIZE; i++)
	{
		std::cin >> array[i];
	}

	int t = 0;
	while (true)
	{
		//2で割れるかの判定
		bool isWaru = false;

		bool flug = false;
		for (int i = 0; i < SIZE; i++)
		{
			if (array[i] % 2 == 0)
			{
				if (!flug)
				{
					array[i] = array[i] * 0.5;
					isWaru = true;
					flug = true;
				}
				else
				{
					array[i] = array[i] * 3;
				}
			}
			else
			{
				array[i] = array[i] * 3;
			}
		}
		if (!isWaru) break;
		
		t++;
	}
	std::cout << t;

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for (int i = A; i <= B; i++) {
    if (i % 10 == i / 10000 && i % 100 / 10 == i / 1000 % 10) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

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

int main()
{
    ll n,m,c,ans=0,sum=0;
    cin >> n >> m >> c;
    vll b(m);
    ll a[n][m];
    rep(i,m)cin >> b[i];
    rep(i,n){
        sum = c;
        rep(j,m){
            cin >> a[i][j];
            sum += a[i][j]*b[j];
        }
        if(sum > 0)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const [s]: string[] = tmp.shift().split(" ");
    if (n % 2 == 1) {
      return "No";
    }
    const ss = s.substr(0, n / 2);
    return `${ss + ss == s ? "Yes" : "No"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
def main112():
    N, T = (int(x) for x in input().split())

    candi = [0] * N

    for n in range(N):
        candi[n] = (list(map(int, input().split())))

    candi = sorted(candi, key=lambda x: x[0])

    answer = 10000

    for c in candi:
        if c[1] <= T and c[0] < answer:
            answer = c[0]

    if answer != 10000:
        print(answer)
    else:
        print("TLE")

main112()

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

using namespace std;
#define lint long long

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

int main() {
    lint A, B, C, D;
    cin >> A >> B >> C >> D;
    
    lint X = abs(C - A);
    lint Y = abs(D - B);
    
    lint g = gcd(X, Y);
    
    lint x = X / g;
    lint y = Y / g;
    
    cout << g * (x + y - 1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	}
}


Measured memory_bytes: 26936
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <cstring>
#include <algorithm>
#include <random>
#include <deque>
#include <queue>
#include <ctime>

using namespace std;

using LL = long long;

void solve() {
    LL q,h,s,d;
    cin >> q >> h >> s >> d;

    LL min1 = min({4*q, 2*h, s});
    LL min2 = min({min1*2, d});

    LL n;
    cin >> n;
    cout << min2*(n/2) + min1*(n%2) << endl;
}

int main() {
    solve();
}


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

using namespace std;

const int N=1e5+10;
int a[N],b[N],c[N];

int main()
{
    int n,m,l=0,i;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i==0) b[0]=1e9;
        else b[i]=b[i-1];
        if(a[i]<b[i]) b[i]=a[i];
        c[i]=a[i]-b[i];
    }
    sort(c,c+n);
    for(i=n-1;i>=0;i--)
    {
        if(c[i]==c[n-1]) l++;
    }
    printf("%d",l);
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  REP(i, n) cin >> a[i] >> b[i] >> c[i];
  int dp[n+1][10*n+1][10*n+1];
  REP(k, n+1){
    REP(i, 10*n+1){
      REP(j, 10*n+1) dp[k][i][j] = 100000;
    }
  }
  dp[0][0][0] = 0;
  REP(k, n){
    REP(i, 10*n+1){
      REP(j, 10*n+1){
        if(i >= a[k] && j >= b[k]){
          dp[k+1][i][j] = min(dp[k][i][j], dp[k][i-a[k]][j-b[k]] + c[k]);
        }
        else dp[k+1][i][j] = dp[k][i][j];
      }
    }
  }
  int ans = 100000;
  for(int i = 1;; i++){
    if(ma*i > (10*n) || mb*i > (10*n)) break;
    ans = min(ans, dp[n][ma*i][mb*i]);
  }
  if(ans == 100000) cout << -1 << endl;
  else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 25984
from collections import Counter
import numpy as np
N, M = (int(i) for i in input().split())

A=[]
for i in range(N):
    A_tmp = np.array([int(i) for i in input().split()[1:]])
    A.extend(A_tmp)

c = Counter(A)
values, counts = zip(*c.most_common())
print(np.sum(np.array(counts)==N))

Measured memory_bytes: 20696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,K;
	string S;

	cin>>N>>S>>K;
	K--;
	char A = S[K];
	rep(i,N){
		if(S[i]!=A)cout<<'*';
		else cout<<S[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int n;cin >> n;
  vector<int>a(n,0),cnt(n+1);
  rrep(i,1,n)cin >> a[i];
  rep(i,n)cnt[a[i]]++;
  rrep(i,1,n+1)cout << cnt[i] << endl;
}



Measured memory_bytes: 4780
#include<stdio.h>

int main(){
	int h,w,i,j,count=1,k,flag[400][400]={{0}};
	long ans=0;
	char hw[400][401];
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++)scanf("%s",hw[i]);
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(flag[i][j]==0){
				flag[i][j]=count;
				int que[10000000][2];
              	long st=0,fn=1;
				que[0][0]=i;
				que[0][1]=j;
				long ck=0,cw=0;
				if(hw[i][j]=='.')cw++;
				if(hw[i][j]=='#')ck++;
				while(st<fn){
				if(hw[que[st][0]][que[st][1]]=='#'){
					if(que[st][1]<w-1&&flag[que[st][0]][que[st][1]+1]==0
					&&hw[que[st][0]][que[st][1]+1]=='.'){
						flag[que[st][0]][que[st][1]+1]=count;
						que[fn][0]=que[st][0];
						que[fn++][1]=que[st][1]+1;
						cw++;
					}
					if(que[st][0]<h-1&&flag[que[st][0]+1][que[st][1]]==0
					&&hw[que[st][0]+1][que[st][1]]=='.'){
						flag[que[st][0]+1][que[st][1]]=count;
						que[fn][0]=que[st][0]+1;
						que[fn++][1]=que[st][1];
						cw++;
					}
					if(que[st][1]>0&&flag[que[st][0]][que[st][1]-1]==0
					&&hw[que[st][0]][que[st][1]-1]=='.'){
						flag[que[st][0]][que[st][1]-1]=count;
						que[fn][0]=que[st][0];
						que[fn++][1]=que[st][1]-1;
						cw++;
					}
					if(que[st][0]>0&&flag[que[st][0]-1][que[st][1]]==0
					&&hw[que[st][0]-1][que[st][1]]=='.'){
						flag[que[st][0]-1][que[st][1]]=count;
						que[fn][0]=que[st][0]-1;
						que[fn++][1]=que[st][1];
						cw++;
					}
				}
				if(hw[que[st][0]][que[st][1]]=='.'){
					if(que[st][1]<w-1&&flag[que[st][0]][que[st][1]+1]==0
					&&hw[que[st][0]][que[st][1]+1]=='#'){
						flag[que[st][0]][que[st][1]+1]=count;
						que[fn][0]=que[st][0];
						que[fn++][1]=que[st][1]+1;
						ck++;
					}
					if(que[st][0]<h-1&&flag[que[st][0]+1][que[st][1]]==0
					&&hw[que[st][0]+1][que[st][1]]=='#'){
						flag[que[st][0]+1][que[st][1]]=count;
						que[fn][0]=que[st][0]+1;
						que[fn++][1]=que[st][1];
						ck++;
					}
					if(que[st][1]>0&&flag[que[st][0]][que[st][1]-1]==0
					&&hw[que[st][0]][que[st][1]-1]=='#'){
						flag[que[st][0]][que[st][1]-1]=count;
						que[fn][0]=que[st][0];
						que[fn++][1]=que[st][1]-1;
						ck++;
					}
					if(que[st][0]>0&&flag[que[st][0]-1][que[st][1]]==0
					&&hw[que[st][0]-1][que[st][1]]=='#'){
						flag[que[st][0]-1][que[st][1]]=count;
						que[fn][0]=que[st][0]-1;
						que[fn++][1]=que[st][1];
						ck++;
					}
				}
					st++;
				}
				ans+=cw*ck;
				count++;
			}
		}
	}
	printf("%ld\n",ans);
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  int cnt = 0;
  for (int i = 1; i < S.size(); i++) {
    if (2 <= i && i <= S.size() - 2 && S[i] == 'C') {
      cnt++;
    } else if (!('a' <= S[i] && S[i] <= 'z')) {
      cout << "WA" << endl;
      return 0;
    }
  }
  if (cnt != 1) {
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex = [1/2*(i+1) for i in p]
total = [0]

for i in range(N):
    total.append (total[i] + ex[i])

ans = 0
for i in range(N+1-K):
    tmp = total[i+K] - total[i]
    if ans < tmp:
        ans = tmp

print (ans)


Measured memory_bytes: 25060
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	n = int(input())
	a = list(map(int, [int(input()) - 1 for i in range(n)]))
	cur = 0
	for i in range(10**5):
		cur = a[cur]
		if cur == 1:
			print(i + 1)
			exit()
	print("-1")

if __name__ == '__main__':
	main()


Measured memory_bytes: 17124
from collections import Counter

H, W, N, *AB = map(int, open(0).read().split())

move = [
    (-1, -1), (-1, 0), (-1, 1),
    (0, -1),  (0, 0),  (0, 1),
    (1, -1),  (1, 0),  (1, 1),
]

C = Counter()
for a, b in zip(*[iter(AB)] * 2):
    C.update(
        (a - i, b - j)
        for i, j in move
        if 2 <= a - i <= H - 1 and 2 <= b - j <= W - 1
    )

D = Counter(v for _, v in C.items())

print((H - 2) * (W - 2) - len(C))
for i in range(1, 10):
    print(D[i])


Measured memory_bytes: 178260
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=25;
int a[N],b[N],c[N],n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n)scanf("%d",&b[i]);
	fp(i,1,n-1)scanf("%d",&c[i]);
	fp(i,1,n){
		res+=b[a[i]];
		if(a[i]-1==a[i-1])res+=c[a[i-1]];
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char a[11],b[11],c[11];
    scanf("%s %s %s",a,b,c);

    int len_a = strlen(a);
    int len_b = strlen(b);

    if (a[len_a - 1] == b[0] && b[len_b - 1] == c[0]){
        printf("%s\n","YES");
    }
    else {
        printf("%s\n","NO");
    }

    return 0;
}


Measured memory_bytes: 128
X, N = map(int, input().split())
pi = list(map(int, input().split()))
newpi = [0 for i in range(N)]
for i in range(N):
    newpi[i] = pi[i] - X
for x in range(101):
    if not(((-1) * x) in newpi):
        print((-1) * x + X)
        break
    if not(x in newpi):
        print(x + X)
        break

Measured memory_bytes: 61884
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;

ll d[302][302][302];
int lmin[302][4], lmax[302][4];

int main()
{
	memset(lmin, 0x3f, sizeof(lmin));

	int N, M; scanf("%d %d", &N, &M);
	for(int i = 0, l, r, x; i < M; i++){
		scanf("%d %d %d", &l, &r, &x);
		if(x == 1) lmin[r][1] = min(lmin[r][1], l), lmax[r][1] = max(lmax[r][1], l);
		else if(x == 2) lmin[r][2] = min(lmin[r][2], l), lmax[r][2] = max(lmax[r][2], l);
		else lmin[r][3] = min(lmin[r][3], l), lmax[r][3] = max(lmax[r][3], l);
	}

	d[0][0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int x1 = 1; x1 < 3; x1++)
			for(int x2 = x1 + 1; x2 <= 3; x2++)
				if(lmax[i][x1] && lmax[i][x2] && lmin[i][x1] <= lmax[i][x2])
					return !printf("0\n");

		for(int ai = 0; ai < i; ai++)
			for(int bi = 0; bi < i; bi++){
				bool psb1 = true, psb2 = true;
				for(int x = 1; x <= 3; x++){
					if(!lmax[i][x]) continue;
					int vmin = lmin[i][x], vmax = lmax[i][x];
					if((vmin <= i) + (vmin <= ai) + (vmin <= bi) != x) psb1 = false;
					if((vmax <= i) + (vmax <= ai) + (vmax <= bi) != x) psb1 = false;
					if((vmin <= i) + (vmin <= i - 1) + (vmin <= ai) != x) psb2 = false;
					if((vmax <= i) + (vmax <= i - 1) + (vmax <= ai) != x) psb2 = false;
				}

				if(psb1){
					d[i][ai][bi] += d[i - 1][ai][bi];
					d[ai][i][bi] += d[ai][i - 1][bi];
					d[ai][bi][i] += d[ai][bi][i - 1];					
				}
				if(psb2){
					if(ai != i - 1 || ai != bi || bi != i - 1){
						d[i][i - 1][ai] += d[bi][i - 1][ai];
						d[i - 1][i][ai] += d[i - 1][bi][ai];
						d[i - 1][ai][i] += d[i - 1][ai][bi];
					}
					if(bi != i - 1){
						d[i][ai][i - 1] += d[bi][ai][i - 1];
						d[ai][i][i - 1] += d[ai][bi][i - 1];
						d[ai][i - 1][i] += d[ai][i - 1][bi];
					}
				}
			}

		for(int ai = 0; ai < i; ai++)
			for(int bi = 0; bi < i; bi++){
				d[i][ai][bi] %= mod;
				d[ai][i][bi] %= mod;
				d[ai][bi][i] %= mod;
			}
	}

	ll ans = 0;
	for(int ai = 0; ai < N; ai++)
		for(int bi = 0; bi < N; bi++)
			ans = (ans + d[N][ai][bi] + d[ai][N][bi] + d[ai][bi][N]) % mod;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 215168
def make_heights_list(height):
    return [int(height), True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

#print(heights)

# 塔を基準にして、その塔ごとに繋がる道をリストアップする
roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    #print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        # ng_len += 1
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        # ng_len += 1

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

#print(heights)

print(good_towers_len)


Measured memory_bytes: 27940
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    string s,t;
    int n,a = 0,b = 0;
    cin >> n;
    
    rep(i,0,n){
        cin >> s >> t;
        
        if(s == t){
            a++;
            b++;
        }
        else if(s > t){
            a += 3;
        }
        else{
            b += 3;
        }
    }
    
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3168