akhauriyash/Code-Regression huggingface dataset:
program main
	implicit none
	integer    :: N, M
	integer(8) :: monkey, dog, i
	read(*, *) N, M
	if(abs(N-M) > 1) then
		write(*, *) 0
	else if(M /= N) then
		dog = 1
		do i = N, 1, -1
			dog = mod(dog*i,1000000007)
		end do
		
		monkey = 1
		do i = M, 1, -1
			monkey = mod(monkey*i,1000000007)
		end do
		
		write(*, *) mod(dog*monkey,1000000007)
	else
		dog = 1
		do i = N, 1, -1
			dog = mod(dog*i,1000000007)
		end do
		
		write(*, *) mod(2*dog*dog,1000000007)
	end if
end program main

Measured memory_bytes: 384
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
const int N = 105;
int n, k, ans;
bool vis[N];
int main() 
{
	rd(n), rd(k);
	for (int i = 1, x, y; i <= k; i++)
	{
		rd(x);
		while (x--)
			rd(y), vis[y] = 1;
	}
	for (int i = 1; i <= n; i++)
		if (!vis[i])
			ans++;
	pt(ans);
    return 0;
}

Measured memory_bytes: 1532
class BIT:
    def __init__(self, size: int):
        self.__size = size
        self.__data = [0] * (size + 1)

    def update(self, idx: int, v: int):
        while idx <= self.__size:
            self.__data[idx] += v
            idx += idx & -idx

    def sum(self, l: int, r: int):
        """(l, r] の累積和
        """
        return self.__sum(r) - self.__sum(l)

    def __sum(self, idx: int):
        s = 0
        while idx > 0:
            s += self.__data[idx]
            idx -= idx & -idx
        return s


def practical_skill_test(
        H: int, W: int, D: int, A: list, Q: int, queries: list) -> list:
    # sorted_A = sorted([(A[h][w], h, w) for h in range(H) for w in range(W)])
    per_rem = [[] for _ in range(D)]
    for h in range(H):
        for w in range(W):
            a = A[h][w]
            per_rem[a % D].append((a, h, w))

    # あまりごとの累積和
    ss = []
    for d in range(D):
        per_rem[d].sort()

        n = len(per_rem[d])
        ss.append([0] * (n + 1))

        for idx in range(n-1):
            _, i, j = per_rem[d][idx]
            _, x, y = per_rem[d][idx + 1]
            # print('{}({},{}) -> {}({},{})'.format(a, i, j, b, x, y))

            ss[d][idx + 1] = ss[d][idx] + abs(x - i) + abs(y - j)

    res = []
    for l, r in queries:
        d = l % D
        if d > 0:
            li, ri = l // D, r // D
        else:
            li, ri = l // D - 1, r // D - 1
        res.append(ss[d][ri] - ss[d][li])

    return res


if __name__ == "__main__":
    H = 0
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    queries = [tuple(int(s) for s in input().split()) for _ in range(Q)]

    ans = practical_skill_test(H, W, D, A, Q, queries)
    for a in ans:
        print(a)


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

/*
迷路探索, 最短距離にはBFSが使える. 開始地点の隣接箇所を調べ, その箇所の隣接箇所を調べ, という動き.
マスを頂点, 移動にかかるコストを辺とするグラフを考えたとき,
辺の重みが全て1ならBFS, 0か1なら01-BFS, 1以上もあるならダイクストラ法, 
負数もあるならベルマン-フォード法.
今回はワープを使うかどうかとして01-BFSが使える.
コスト0の辺を使って行けるところは先に全て埋めて, 手詰まりになったら初めてコスト1の辺を使う.
これを実現するためにdequeを使う. 0を使う辺は前, 1を使う辺は後ろから入れる.
*/

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  int ch, cw;
  cin >> ch >> cw;
  int dh, dw;
  cin >> dh >> dw;
  ch--; cw--; dh--; dw--;
  vector<string> s(h);  // フィールド
  rep(i, h) cin >> s[i];
  const int INF = 1e9;
  
  vector<vector<int>> dist(h, vector<int>(w, INF));  // 各マス到達時点でのコストを入れる
  deque<P> q;  // deque
  dist[ch][cw] = 0;  // スタート地点のコスト
  q.emplace_back(ch, cw);  // スタート地点の座標を入れる
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop_front();
    int d = dist[i][j];
    
    // 現在地の上下左右をチェック
    rep(v, 4) {  
      int ni = i+di[v], nj = j+dj[v];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;  // 範囲外
      if (s[ni][nj] == '#') continue;  // 壁
      if (dist[ni][nj] <= d) continue;  // INFじゃない, つまりチェック済み.
      dist[ni][nj] = d;
      q.emplace_front(ni, nj);  // コスト+0で行けるので前からpush
    }
    
    // 現在地から5×5の範囲をチェック
    for (int ei = -2; ei <= 2; ++ei) {
      for (int ej = -2; ej <= 2; ++ej) {
        int ni = i+ei, nj = j+ej;
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;  // 範囲外
        if (s[ni][nj] == '#') continue;  // 壁
        // 今と同じかより小さいコストが入っている. つまりそこに行くのにワープが必要ない.
        if (dist[ni][nj] <= d+1) continue;
        dist[ni][nj] = d+1;
        q.emplace_back(ni, nj);  // コスト+1で行くので後ろからpush
      }
    }
  }
  
  int ans = dist[dh][dw];
  if (ans == INF) ans = -1;  // 目的地にたどり着けなかった
  cout << ans << endl;
}

Measured memory_bytes: 9580
using System;

namespace B___Touitsu
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var input = new string[3];
            for (var i = 0; i < 3; i++)
            {
                input[i] = Console.ReadLine ();
            }
            var ans = 0;
            for (var i = 0; i < n; i++)
            {
                if (input[0][i] != input[1][i] && input[0][i] != input[2][i] && input[1][i] != input[2][i])
                    ans += 2;
                
                else if ((input[0][i] == input[1][i] && input[1][i] != input[2][i]) || (input[1][i] == input[2][i] && input[0][i] != input[1][i]) || input[0][i] == input[2][i] && input[0][i] != input[1][i])
                    ans++;
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 200001
ll N;

long long par[MAX_N]; // 親
long long rankuf[MAX_N]; // 木の深さ
ll L[MAX_N], R[MAX_N];
ll treenum = 0;
// n要素で初期化
void init(long long n) {
	for (long long i = 0; i < n; i++) {
		par[i] = i;
    	rankuf[i] = 0;
		L[i] = i;
		R[i] = i;
	}
	treenum = n;
}
// 木の根を求める
long long find(long long x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}
// xとyの属する集合を併合
void unite(long long x, long long y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rankuf[x] < rankuf[y]) {
		par[x] = y;
		L[y] = min(L[x], L[y]);
		R[y] = max(R[x], R[y]);
	} else {
		par[y] = x;
		L[x] = min(L[x], L[y]);
		R[x] = max(R[x], R[y]);
		if (rankuf[x] == rankuf[y]) rankuf[x]++;
	}
	treenum--;
}
// xとyが同じ集合に属するか否か
bool same(long long x, long long y) {
	return find(x) == find(y);
}

int main(){	
	scanf("%lld",&N);
	vector<long long> a(N-1+1), b(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
		a[i]--;
		b[a[i]] = i;
		// cout << a[i] << " " << b[a[i]] << endl;
 	}
	init(N);
	long long sum = 0;
	for(int i = N-1 ; i >= 0 ; i--){
		if (b[i]-1>=0 && a[b[i]-1]>i) unite(b[i]-1, b[i]);
		if (b[i]+1<=N-1 && a[b[i]+1]>i) unite(b[i]+1, b[i]);
		ll f = find(b[i]);
		// cout << R[f] << " " << L[f] << " " << b[i] << endl;
		// cout << (R[f]-L[f]+2)*(R[f]-L[f]+1)/2 - (b[i]-L[f]+1)*(b[i]-L[f])/2 - (R[f]-b[i]+1)*(R[f]-b[i])/2 << endl;
		// cout << endl;
		sum += ( (R[f]-L[f]+2)*(R[f]-L[f]+1)/2 - (b[i]-L[f]+1)*(b[i]-L[f])/2 - (R[f]-b[i]+1)*(R[f]-b[i])/2 )*(i+1);
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

int dp[201][201];

void dpInit(){
	for(int i = 0; i <= 200; i++){
		for(int j = 0; j <= 200;j++){
			dp[i][j] = -1;
		}
	}
	return ;
}

int gcd(int a,int b){
	if(dp[a][b] != -1) return dp[a][b];
	if( b > a) return gcd(b,a);
	if( b == 0) return a;
	if( b == 1) return 1;
	int ans = gcd(b,a%b);
	dp[a][b] = ans;
	return ans;
}

void makeTableDp(){
	for(int i = 0; i <= 201; i++){
		for(int j = 0; j <= 201; j++){
			dp[i][j] = gcd(i,j);
		}
	}
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int K;
	unsigned long long int sum = 0;
	cin>>K;
	dpInit();
	//makeTableDp();
	for(int a = 1; a <= K; a++){
		for(int b = 1; b <= K; b++){
			for(int c = 1; c <= K; c++){
				int num = gcd(a,b);
				num = gcd(c,num);
				sum += num;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int siz,time;
    string name;
    while(true){
        cin>>name;
        if(name[0]=='-')break;
        cin>>time;
        for(int abc=0;abc<time;abc++){
            cin>>siz;
            name=name.substr(siz)+name.substr(0,siz);
        }
        cout<<name<<endl;
    }
      
}


Measured memory_bytes: 3144
//
// Created by Myabu on 2020/01/16.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int N,K;

    cin>>N>>K;

    int ans = 1;
    for (int i = 0; i < N; ++i) {
        ans = min(ans+K, ans * 2);
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
N = int(input())
Len = len(str(N))

# head tail
C = [] 

for i in range(0,10):
    C.append([0,0,0,0,0,0,0,0,0,0])

for A in range(0,N):
    ac = str(A+1)
    ha = int(ac[0])
    ta = int(ac[-1])
    C[ha][ta] += 1

ans = 0
for head in range(0,10):
    for tail in range(0,10):
        ans += C[head][tail] * C[tail][head]

print(ans)




Measured memory_bytes: 3064
use proconio::*;

const MOD: i64 = 1_000_000_007;

fn main() {
    input! {
        s: usize,
    }

    let mut array = vec![0i64; 2001];
    array[0] = 1;
    for i in 3..=2000 {
        for j in 3..=i {
            array[i] = (array[i] + array[i - j]) % MOD;
        }
    }
    println!("{}", array[s]);
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<string.h>
int main(){
	char str[1205];
	fgets(str,1205,stdin);
	for(int i=0;i<strlen(str);i++){
		if(str[i]>=65&&str[i]<=90)printf("%c",str[i]+32);
		else if(str[i]>=97&&str[i]<=122)printf("%c",str[i]-32);
		else {
			printf("%c",str[i]);
		}
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll n,k;
vll a;

ll check(ll b){
  ll sum=0;
  REP(i,n){
    if(a[i]!=0){
      ll p = b/a[i];

      if(b>0 && b%a[i]!=0){
        if(a[i]>0)
          p++;
        else
          p--;
      }

      if(a[i]>0){
        ll index = max(ll(lower_bound(a.begin(), a.end(), p)-a.begin()),ll(i+1));
        ll num = max(n-index,0LL);
        sum += num;
 //       cout<<"index:"<<upper_bound(a.begin(), a.end(), p)-a.begin()-(i+1)<<" num:"<<num<<endl;
      }
      else{
        ll num = max(ll(upper_bound(a.begin(), a.end(), p)-a.begin()-(i+1)),0LL);
        sum += num;
  //      cout<<p<<endl;
  //      cout<<"index:"<<upper_bound(a.begin(), a.end(), p)-a.begin()-(i+1)<<" num:"<<num<<endl;
      }



    }
    else{
      if(b<=0)
        sum+=n-(i+1);
    }

   // cout<<a[i]<<":"<<sum<<endl;
  }

  return sum;
}


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

  cin>>n;
  cin>>k;
  a.assign(n,0);
  REP(i,n)cin>>a[i];

  sort(a.begin(), a.end());
//  check(-12);

//ok:border
  ll ok=1e18;
  ll ng=-1e18;
  while(ok-ng>1){
    ll mid = (ok+ng)/2;
    if(check(mid)<=n*(n-1)/2-k)
      ok = mid;
    else
      ng = mid;
    //cout<<ng<<endl;
  }

  if(check(ok)==k)
  cout<<ok<<endl;
  else
  cout<<ng<<endl;
}


Measured memory_bytes: 1792
N = int(input())
J = []
for i in range(N):
  J.append(list(map(int, input().split())))
J.sort(key=lambda x:x[1])
time = 0
for i in range(N):
  time += J[i][0]
  if time > J[i][1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 53720
// Code by ajcxsu
// Geometry template

#include<bits/stdc++.h>
#define EPS (1e-9)
using namespace std;

struct Point {
    double x,y;
    Point(double x=0,double y=0):x(x), y(y) {}

    Point operator +(Point p) { return Point(x+p.x,y+p.y); }
    Point operator -(Point p) { return Point(x-p.x,y-p.y); } // 加减
    Point operator *(double a) { return Point(x*a,y*a); }
    Point operator /(double a) { return Point(x/a,y/a); } // 数乘

    double norm() { return x*x+y*y; } // 范数
    double abs() { return sqrt(norm()); } // 大小

    bool operator < (const Point &p) { return x!=p.x?x<p.x:y<p.y; }
    bool operator == (const Point &p) { return fabs(p.x-x) < EPS && fabs(p.y-y) < EPS; }
} ;
typedef Point Vector;

double dot(const Point &a, const Point &b) {
    return a.x*b.x+a.y*b.y;
} // 内积
double cross(const Point &a, const Point &b) {
    return a.x*b.y-a.y*b.x;
} // 外积
bool equals(double a, double b) { return fabs(a-b)<EPS; } // 误差相等

struct Line {
    Point p1,p2;
} ;
typedef Line Seg;

/* 1 正交 2 平行 0 其他 */
int PO(Vector a, Vector b) {
    if(equals(dot(a,b), 0)) return 1;
    else if(equals(cross(a,b), 0)) return 2;
    else return 0;
}
int PO(Line a, Line b) { // 正交、平行判定
    return PO(a.p2-a.p1, b.p2-b.p1);
}

istream& operator >>(istream &in, Vector &a) {
    in>>a.x>>a.y;
    return in;
}
istream& operator >>(istream &in, Line &a) {
    in>>a.p1>>a.p2;
    return in;
} // 输入重载

Point project(Point a, Seg b) {
    Vector base=b.p2-b.p1;
    Vector hypo=a-b.p1;
    return b.p1+base*(dot(base, hypo)/ base.norm());
} // 投影

Point ref(Point a, Seg b) {
    Vector base=project(a,b)-a;
    return a+base*2;
} // 映像

int ccw(Vector a, Vector b) {
    if(cross(a,b)>EPS) return 1; // Counter clockwise
    else if(cross(a,b)<-EPS) return -1; // Clockwise
    else if(dot(a,b)<-EPS) return 2; // Online back
    else if(a.norm()<b.norm()) return -2; // Online front
    else return 0; // On segement
} // 判断顺时针逆时针
int ccw(Point p0, Point p1, Point p2) {
    return ccw(p1-p0, p2-p0);
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
    if( ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0 &&
        ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0) return 1;
    return 0;
}
bool intersect(Seg a, Seg b) {
    return intersect(a.p1, a.p2, b.p1, b.p2);
} // 判断线段是否相交

Point crossp(Seg a, Seg b) {
    Vector base=b.p2-b.p1, hypo=a.p1-b.p1, hypo2=a.p2-b.p1;
    double h1=fabs(cross(base,hypo))/base.abs();
    double h2=fabs(cross(base,hypo2))/base.abs();
    double t=h1/(h1+h2);
    return a.p1+(a.p2-a.p1)*t;
} // 线段交点

double disp(Point a, Seg b) {
    if(dot(b.p2-b.p1,a-b.p1) < 0.0) return (a-b.p1).abs();
    else if(dot(b.p1-b.p2, a-b.p2) < 0.0) return (a-b.p2).abs();
    return (project(a,b)-a).abs();
}
double diss(Seg a, Seg b) {
    if(intersect(a,b)) return 0.0;
    return min(min(disp(a.p1,b), disp(a.p2,b)), min(disp(b.p1,a), disp(b.p2,a)));
}

ostream& operator <<(ostream &out, Vector a) {
    out<<a.x<<' '<<a.y;
    return out;
} // 输出重载

int main() {
    cout.setf(ios::fixed);
    cout<<setprecision(10); // 设置输出精度

    int q;
    cin>>q;
    while(q--) {
        Seg a,b;
        cin>>a>>b;
        cout<<diss(a,b)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<string>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define REP(i,a,n) for(int i = a ; i < n  ;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 1010
typedef long long ll;

int V;
vector<int> G[MAX];
int match[MAX];
bool used[MAX];

void add_edge(int u, int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    int u = G[v][i], w = match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bm(){
  int res = 0;
  memset(match, -1, sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v] < 0){
      memset(used, 0, sizeof(used));
      if(dfs(v)) res ++;
    }
  }
  return res;
}

void solve(){
}
int main(){
  int n,m;
  while(cin>>n>>m && (n||m)){
    rep(i,MAX)G[i].clear();
    vector<int> r;
    vector<int> b;
    rep(i,n){
      int t;
      cin>>t;
      r.push_back(t);
    }

    rep(i,m){
      int t;
      cin>>t;
      b.push_back(t);
    }

    V = n+m;

    rep(i,n){
      rep(j,m){
        if(__gcd(r[i] , b[j]) !=1){
          add_edge(i,j+n);
        }
      }
    }
    /*
    rep(i,V){
      cout<<i<<":";
      rep(j,G[i].size()){
        cout<<G[i][j]<<" ";
      }
      cout<<endl;
    }
    */

    cout<<bm()<<endl;
  }
}

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

int main() {
  int k,a,b,x;
  string ans = "NG";
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    x = i%k;
    if(x==0){
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[4];
cin >> s;
string ans = "No";
if(s[0]==s[1]&&s[2]==s[3]) {
  ans = "Yes";
} else if(s[0]==s[2]&&s[1]==s[3]) {
  ans = "Yes";
} else if(s[0]==s[3]&&s[1]==s[2]) {
  ans = "Yes";
}
if(s[0]==s[1]&&s[0]==s[2]) ans="No";
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

if y >0:
    if x>y:
        print(x-y+2)
    elif 0<=x<=y:
        print(y-x)
    elif -y<=x<0:
        print(y+x+1)
    elif x<-y:
        print(-x-y+1)
        
elif y==0:
    if x>0:
        print(x+1)
    elif x==0:
        print(0)
    else:
        print(-x)
        
elif y<0:
    if 0<=x<=-y:
        print(-y-x+1)
    elif x>-y:
        print(y+x+1)
    elif y<x<0:
        print(x-y+2)
    else:
        print(y-x)

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  int M = in();
  vec<int> score(N);
  auto A = in(M);
  REP(i, M) {
    int X = 0;
    REP(j, N) {
      int b = in();
      if (b == A[i]) {
        score[j]++;
      } else {
        X++;
      }
    }
    score[A[i] - 1] += X;
  }
  for (int s : score) {
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3220
import math
a,b,c,d = map(int,input().split())

def death_time(hp,atack):
    if hp%atack == 0:
        return hp/atack
    else:
        return hp//atack + 1

takahashi_death = death_time(a,d)
aoki_death = death_time(c,b)

if aoki_death<=takahashi_death:
    print("Yes")
else:
    print("No")

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

int main() {
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  for (int i = 0; i < N; i++)
    cin >> t[i];

  ll sum = 0;
  for (int i = 1; i < N; i++) {
    ll diff = t[i] - t[i - 1];
    if (diff >= T) {
      sum += T;
    } else {
      sum += diff;
    }
  }
  cout << sum + T << endl;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    S = list(input())
    K = int(input())

    k_str = S[K-1]
    for i in range(len(S)):
        if S[i] != k_str:
            S[i] = '*'

    print(''.join(S))


if __name__ == '__main__':
    main()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<ll,20> bt;

int N,M;
int X[101010],Y[101010];
vector<pair<int,int>> V;
vector<int> Ys;
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>X[i];
	FOR(i,M) cin>>Y[i];
	Ys.push_back(0);
	FOR(i,N) {
		if(X[i]<Y[0]) continue;
		if(X[i]>Y[M-1]) continue;
		x=lower_bound(Y,Y+M,X[i])-Y;
		V.push_back({X[i]-Y[x-1],-(Y[x]-X[i])});
		Ys.push_back(Y[x]-X[i]);
	}
	sort(ALL(V));
	V.erase(unique(ALL(V)),V.end());
	sort(ALL(Ys));
	Ys.erase(unique(ALL(Ys)),Ys.end());
	bt.add(0,1);
	FORR(v,V) {
		y=lower_bound(ALL(Ys),-v.second)-Ys.begin();
		bt.add(y,bt(y-1)%mo);
	}
	
	cout<<bt(Ys.size()+2)%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6896
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split(' ')))
counts = {i: 0 for i in range(10**5)}
for ai in a:
    if (ai != 0): counts[ai-1] += 1
    counts[ai] += 1
    if (ai != 99999): counts[ai+1] += 1
ans = 0
for i in range(10**5):
    if counts[i] > ans:
        ans = counts[i]
print(ans)

Measured memory_bytes: 20640
#include<stdio.h>

int main()
{
  int n1, n2;
  int temp;

  scanf("%d %d", &n1, &n2);

  if(n1 < n2)
    {
      temp = n1;
      n1 = n2;
      n2 = temp;
    }
  temp = 0;
  while(n1%n2)
    {
      temp = n2;
      n2 = n1%n2;
      n1 = temp;
    }
  printf("%d\n", n2);
}



Measured memory_bytes: 2148
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    int A,B;
    cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
using namespace std;
int main()
{
    fast_io;
li n,i;
cin>>n;
cout<<(n-1)*(n)/2;
return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};



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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  REP(i, tx-sx) cout << 'R';
  REP(i, ty-sy) cout << 'U';
  REP(i, tx-sx) cout << 'L';
  REP(i, ty-sy) cout << 'D';
  cout << 'D';
  REP(i, tx-sx+1) cout << 'R';
  REP(i, ty-sy+1) cout << 'U';
  cout << 'L';
  cout << 'U';
  REP(i, tx-sx+1) cout << 'L';
  REP(i, ty-sy+1) cout << 'D';
  cout << 'R'<< endl;

  return 0;
}


Measured memory_bytes: 256
s=input()
l=len(s)

mod=10**9+7

dp=[[0 for j in range(13)] for i in range(l)]

if s[0] =="?":
    dp[0] = [1]*10+[0]*3
else:
    dp[0][int(s[0])] =1

for i in range(1, l):
 if s[i]=='?':
   for j in range(10):
     for k in range(13):
       dp[i][(k*10+j)%13]+=dp[i-1][k]%mod
 else:
   for k in range(13):
     dp[i][(k*10+int(s[i]))%13]+=dp[i-1][k]%mod
print(dp[-1][5]%mod)

Measured memory_bytes: 66268
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a,b,c;
int temp =0;
a =sc.nextInt();
b =sc.nextInt();
c =sc.nextInt();
if(a>b){ temp = a; a = b; b = temp;}
if(b>c){ temp = b; b = c; c = temp;}
if(a>b){ temp = a; a = b; b = temp;}
System.out.println(a+" "+b+" "+c);
}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    string s;cin>>s;
    int n=s.size();
    int cnt=0;
    rep(i,0,n){
        if(s[i]=='o')cnt++;
    }
    if(cnt>=8){
        cout<<"YES"<<endl;
        return 0;
    }
    if(8-cnt<=15-n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}


Measured memory_bytes: 256
n,k=map(int, input().split())
pn = list(map(int, input().split()))
ex_list = [(pn[i]+1)/2 for i in range(len(pn))]
ex_wa_list = []
wa = 0
for i in range(len(ex_list)):
    wa += ex_list[i]
    ex_wa_list.append(wa)
Ans_list = []
wa2 = 0
for i in range(n-k+1):
    if i == 0:
        wa2 = ex_wa_list[k-1]
    else:
        wa2 = ex_wa_list[k-1+i] - ex_wa_list[i-1]
    Ans_list.append(wa2)
print(max(Ans_list))

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

using namespace std;


typedef pair<int, int> pii;

char m[10][10];
int pass[10][10];

int main() {
	int h, w;
	scanf("%d%d", &h, &w);

	for (int i = 0; i < h; i++) {
		scanf(" %s", m[i]);
	}

	queue <pii> q;
	if(m[0][0] == '#') {
		q.push(pii(0,0));
		pass[0][0] = 1;
	}
	int ok = 1;
	while(!q.empty()) {
		pii a = q.front();
		q.pop();
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				if (i+j != 1) continue;
				if (a.first+i >= h || a.second+j >= w) continue;
				if (m[a.first+i][a.second+j] == '#') {
					q.push(pii(a.first+i, a.second+j));
					pass[a.first+i][a.second+j] = 1;
				}
			}
		}
		if(q.size() > 1) ok = 0;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if(m[i][j] == '#') {
				if(pass[i][j] == 0) ok = 0;
			}
		}
	}
	if (ok) puts("Possible");
	else puts("Impossible");
}

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

int main(){
    int n;
    cin >> n;
    int l[n];
    int r[n];
    int ans=0;
    for(int i=0; i<n; i++){
        cin >> l[i] >> r[i];
    }

    for(int i=0; i<n; i++){
        if(l[i] >= r[i]){
            ans += l[i] - r[i] + 1;
        }
        else {
            ans += r[i] - l[i] + 1;
        }
    }

    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin>>s>>t;
    vi Set[26];
    rep(i,s.size()){
        Set[s[i]-'a'].pb(i);
    }
    int idx=-1;
    ll ans=0;
    rep(i,t.size()){
        int c = t[i]-'a';
        if (Set[c].empty()){
            cout<<"-1\n";
            return 0;
        }
        if (idx+1 > Set[c].back()){
            ans+=s.size()-idx-1;
            idx = -1;
        }
        int dest = *lower_bound(all(Set[c]), idx+1);
        ans += dest-idx;
        idx = dest;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int a,b,h,m;
const double pi=2*acos(0);
double c,d;
int main()
{
	scanf("%d %d %d %d",&a,&b,&h,&m);
	c=(h+m/60.0)/12.0*2*pi;
	d=(m/60.0)*2*pi;
	printf("%.10lf",sqrt(a*a+b*b-2*a*b*cos(c-d)));
}

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

  int n;
  int l[15];
  int ans = 0;
  int count;
  int sum = 0;

  cin >> n;

  for ( int i = 0; i < n; i++ ) {
    cin >> l[i];
    if ( ans < l[i] ) {
      ans = l[i];
      count = i;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    if ( i != count ) sum += l[i];
  }

  if ( ans < sum ) cout << "Yes\n";
  else cout << "No\n";

  return 0;

}



// B - Polygon
// source127.cpp


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a,b,c,d,e;
    int dmax;
    cin >> a >> b >> c >> d >> e;
    cin >> dmax;
    if(e - a > dmax)
    {
        cout << ":(\n";
    }
    else
    {
        cout << "Yay!" << endl;
    }
    return 0;
}

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();
        sc.nextLine();

        int count = 1;
        long min = sc.nextLong();
        for (int i = 1; i < n; i++) {
            long num = sc.nextLong();
            if(min >= num) {
                min = num;
                count++;
            }
        }
        System.out.println(count);
    }
}


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

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

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

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

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

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

fn gcd(a: u64, b: u64) -> u64 {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}

fn main() {
  input!{
    N: usize,
    S: chars,
  }
  let total = S.iter().filter(|&c| c==&'R').count()
    * S.iter().filter(|&c| c==&'G').count()
    * S.iter().filter(|&c| c==&'B').count()
    ;

  let mut rem = 0;
  for i in 0..N {
    for j in i..N {
      let k = 2 * j - i;
      if k >= N || S[i] == S[j] || S[j] == S[k] || S[k] == S[i] {continue}
      rem += 1;
    }
  }
  println!("{}", total - rem);

}



Measured memory_bytes: 2184
def actual(N, A):
    count = 0
    while True:
        is_all_even = all([a % 2 == 0 for a in A])

        if is_all_even:
            A = [a // 2 for a in A]
            count += 1
        else:
            return count

N = int(input())
A = list(map(int, input().split()))

print(actual(N, A))


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    long long h, w;
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0) cout << 0 << endl;
    else {
        long long ans = h*w;
        vector<long long> a(3);

        for(int i = 1; i < h; i++) {
            a[0] = w*i;
            a[1] = (h-i)*(w/2);
            a[2] = h*w - a[0] - a[1];
            //cout << a[0] << ":" << a[1] << ":" << a[2] << endl;
            sort(a.begin(), a.end());
            ans = min(ans, a[2] - a[0]);
        }
        
        for(int i = 1; i < w; i++) {
            a[0] = i * h;
            a[1] = (w-i)*(h/2);
            a[2] = h*w - a[0] - a[1];
            sort(a.begin(), a.end());
            ans = min(ans, a[2] - a[0]);
        }
        
        ans = min(h, ans);
        ans = min(w, ans);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <climits>
#include <math.h>

#define sint(x) scanf("%d", &x)
#define sints(x,y) scanf("%d%d", &x, &y)

using namespace std;

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

    cout << s.substr(0,3) << endl;

    return 0;
}


Measured memory_bytes: 3624
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    A, B, H, M = map(int, input().split())

    h = 30 * H + M * 0.5
    m = 6 * M
    theta = max(h, m) - min(h, m)
    theta = min(theta, 360 - theta)

    res2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta / 180 * math.pi)
    print(res2 ** 0.5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69284
#include <stdio.h>
int main(void){
  int n,a[100],i,j,min=150,max=-150,t,ans=1000000000;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
    if (a[i]<min) min=a[i];
    if (a[i]>max) max=a[i];
  }
  for (i=min;i<=max;i++){
    t=0;
    for (j=0;j<n;j++) t+=(a[j]-i)*(a[j]-i);
    if (t<ans) ans=t;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main() 
{ 
int n,m; 
while(scanf("%d%d",&n,&m)!=EOF) 
{ 
int u,v;
 bool flag=false,vis[2000005];
  for(int i=1;i<=n;i++) 
  vis[i]=false; 
  for(int i=1;i<=m;i++)
   { 
   scanf("%d%d",&u,&v);
    if(flag)
	 continue; 
	 if(u==1) 
	 { if(vis[v])
	  { flag=true;
	   }
	    vis[v]=true; 
		}
		else if(v==n)
		 { 
		 if(vis[u])
  { flag=true;
	  }
	 vis[u]=true;
	 }
  }
	  if(flag) 
	  printf("POSSIBLE\n");
	  else
		 printf("IMPOSSIBLE\n");
		 }
	  return 0; 
	  }


Measured memory_bytes: 384
<?php
list($N,$A,$B) = explode(" ",trim(fgets(STDIN)));
$s = str_split(trim(fgets(STDIN)));

$i = 0;
while($i < $N){
if($A + $B == 0){
while($i < $N){
echo "No" . PHP_EOL;
++$i;
}
}else{
if($s[$i] == "c"){
echo "No" . PHP_EOL;
}elseif($s[$i] == "a"){
echo "Yes" . PHP_EOL;
--$A;
}else{
if($B == 0){
echo "No" . PHP_EOL;
}else{
echo "Yes" . PHP_EOL;
--$B;
}
}
}
++$i;
}
?>

Measured memory_bytes: 21392
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}
int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int h, w;
	vector<string> s(100);
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
		s.at(i) = '#' + s.at(i);
		s.at(i) += '#';
	}
	string p(w + 2, '#');
	cout << p << endl;
	for (int i = 0; i < h; i++) {
		cout << s.at(i) << endl;
	}
	cout << p << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	class DSU {
		int n;
		int[] upper;
		
		public DSU(int n) {
			this.n=n;
			Arrays.fill(upper=new int[n], -1);
		}
		
		int root(int x) {
			return upper[x]<0?x:(upper[x]=root(upper[x]));
		}
		
		void unite(int x,int y) {
			x=root(x);y=root(y);
			if (x!=y) {
				upper[x]+=upper[y];
				upper[y]=x;
			}
		}
		
		int sz(int x) {
			return -upper[root(x)];
		}
		
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] id=new int[N];
		int[] y=new int[N];
		for (int i=0;i<N;++i) {
			int x=sc.nextInt()-1;
			y[x]=sc.nextInt()-1;
			id[x]=i;
		}
		DSU ds=new DSU(N);
		Stack<Integer> st=new Stack<Integer>();
		for (int x=0;x<N;++x) {
			int q=x;
			while (!st.isEmpty() && y[st.peek()]<y[x]) {
				int p=st.pop();
				if (q==x) q=p;
				ds.unite(id[x], id[p]);
			}
			st.add(q);
		}
		PrintWriter pw=new PrintWriter(System.out);
		for (int i=0;i<N;++i) {
			pw.println(ds.sz(i));
		}
		pw.flush();
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 65772
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535
#define GYOU_MAX 80



int main(void)
{
	char S[17];
	scanf("%s", S);

	char s[] = "CODEFESTIVAL2016";
	int count = 0;

	for (int i = 0; i < strlen(S); i++) {
		if (s[i] != S[i]) {
			count++;
		}
	}
	printf("%d\n", count);

	return 0;


}

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 110;
const long long Q = 10001;
const long long mod = 1e9 + 7;;
const long long block = sqrt(N);

using namespace std;

int n;
int a[N];
int b[N];
int c[N];

void solve()
{
        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i] >> b[i] >> c[i];
        }
        for(int i = 0; i <= 100; i++){
                for(int j = 0; j <= 100; j++){
                        set < int > s;
                        int big = 2e9;
                        for(int h = 1; h <= n; h++){
                                int dif = abs(a[h] - i) + abs(b[h] - j);
                                if(c[h]){
                                        s.insert(c[h] + dif);
                                }
                                else{
                                        big = min(big, dif);
                                }
                        }
                        if(s.size() == 1 && *s.begin() <= big){
                                cout << i << " " << j << " " << *s.begin() << "\n";
                                return;
                        }

                }
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("substr3.in");
        //fout("substr3.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


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


int main(){
  string S;
  cin >> S;
  if (S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if (S == "Cloudy"){
    cout << "Rainy" << endl;
  }else if(S == "Rainy"){
    cout << "Sunny" << endl;
  }
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  if(a == b && b == c){
    cout << 0 << endl;
    return 0;
  }
    
  
  int na, nb, nc;
  int maxv = max(max(a,b),c);
  int cnt = 0;

  na = a;
  nb = b;
  nc = c;

  int i;
  for(i=a; i<maxv-1; i+=2){
    cnt++;
  }
  na = i;

  for(i=b; i<maxv-1; i+=2){
    cnt++;
  }
  nb = i;

  for(i=c; i<maxv-1; i+=2){
    cnt++;
  }
  nc = i;

  if(na == nb && nb == nc){
    cout << cnt << endl;
    return 0;
  }

  // 665 patten
  if(na == maxv && nb == maxv && nc == maxv-1){
    cout << cnt+2 << endl;
    return 0;
  }

  if(na == maxv && nb == maxv-1 && nc == maxv){
    cout << cnt+2 << endl;
    return 0;
  }

  if(na == maxv-1 && nb == maxv && nc == maxv){
    cout << cnt+2 << endl;
    return 0;
  }

  // 665 patten
  cout << cnt+1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
// find_by_order(), order_of_key()
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/
bool isq(i64 x) {
  i64 rt = sqrt(x);
  for (i64 b = rt - 2; b <= rt + 2; ++b) {
    if (b * b == x) return 1;
  }
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, d;
  cin >> n >> d;
  vector<vector<i64>> a(n, vector<i64>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) {
    i64 dis = 0;
    for (int k = 0; k < d; ++k) {
      dis += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
    }
    if (isq(dis)) ans++;
  }
  kek(ans);
  
  return 0;
} 


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	sort.Slice(A, func(i, j int) bool { return A[i] < A[j] })
	for i := 1; i < N; i++ {
		if A[i] == A[i-1] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 6512
N=int(input())
d=dict()
for _ in range(N):
    S=input()
    if S not in d:
        d[S]=0
    d[S]+=1
M=max(d.values())
ans=[]
for S in d.keys():
    if d[S]==M:
        ans.append(S)
ans.sort()
for S in ans:
    print(S)


Measured memory_bytes: 35224