akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.NoSuchElementException;

public class Main {
	
	static final int[] dx = { -1, 0, 0, 1 };
	static final int[] dy = { 0, -1, 1, 0 };
	
	static int h, w, n;
	static char[][] block;
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		h = sc.nextInt();
		w = sc.nextInt();
		n = sc.nextInt();
		
		block = new char[h][];
		int[][] point = new int[n + 1][2];
		
		for (int y = 0; y < h; y++) {
			block[y] = sc.next().toCharArray();
			for (int x = 0; x < w; x++) {
				char c = block[y][x];
				if (c == 'S') {
					point[0] = new int[] { x, y };
				} else if ('1' <= c && c <= '9') {
					point[c - '0'] = new int[] { x, y };
				}
			}
		}
		
		int total = 0;
		for (int i = 0; i < n; i++) {
			total += bfs(point[i][0], point[i][1], point[i + 1][0], point[i + 1][1]);
		}
		
		System.out.println(total);
	}
	
	static int bfs(int sx, int sy, int gx, int gy) {
		Deque<int[]> q = new ArrayDeque<>();
		boolean[][] visited = new boolean[h][w];
		q.offer(new int[] { sx, sy, 0 });
		while (!q.isEmpty()) {
			int[] now = q.poll();
			if (now[0] == gx && now[1] == gy) return now[2];
			visited[now[1]][now[0]] = true;
			for (int i = 0; i < 4; i++) {
				int nx = now[0] + dx[i];
				int ny = now[1] + dy[i];
				if ((0 <= ny && ny < h) && (0 <= nx && nx < w) && !visited[ny][nx] && block[ny][nx] != 'X') {
					visited[ny][nx] = true;
					q.offer(new int[] { nx, ny, now[2] + 1 });
				}
			}
		}
		return -1;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			System.out.println("poyo");
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
}

Measured memory_bytes: 65724
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N, vector<int> (N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin >> G[i][j];
    }
  }
  vector<vector<int>> G2;
  G2 = G;
  for(int k=0; k<N; k++){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        chmin(G2[i][j],G2[i][k]+G2[k][j]);
      }
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(G[i][j] > G2[i][j]){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  ll ans=0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      bool ok = true;
      for(int k=0; k<N; k++){
        if(i==k || j==k) continue;
        if(G[i][j] == G[i][k]+G[k][j]) ok = false;
      }
      if(ok) ans += G[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define MOD 998244353

vi freq;

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

int main() {
    ios_base::sync_with_stdio(false);
    int n,a,last1,last2;
    cin >> n;
    freq.assign(n+3,0);
    cin >> a;
    if (a != 0) {
        rep(i,n-1) {
            cin >> a;
        }
        cout << 0 << '\n';
        return 0;
    }
    freq[0] = 1;
    rep(i,n-1) {
        cin >> a;
        freq[a]++;
    }
    if (freq[0] != 1) {
        cout << 0 << '\n';
        return 0;
    }
    rrep(i,n+3) {
        if (freq[i]>0) {
            last2=i;
            break;
        }
    }
    rep(i,n+3) {
        if (freq[i]==0) {
            last1=i;
            break;
        }
    }
    if (last1 - 1 != last2) {
        cout << 0 << '\n';
        return 0;
    }
    if (n==1) {
        cout << 1 << '\n';
        return 0;
    }
    if (last1 == 1) {
        cout << 1 << '\n';
        return 0;
    }
    ll re=binpow(freq[1],freq[2],MOD),cnt=re;
    rap(i,3,last1) {
        re = (binpow(freq[i-1],freq[i],MOD));
        cnt = ((cnt%MOD)*(re%MOD))%MOD;
    }
    cout << cnt << '\n';
    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

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

#define INF 1e+15
#define MAX_V 1000000

struct edge {
    long long to;
    long long cost;
};

// <最短距離, 頂点の番号>
using P = pair<long long, long long>;

long long V;
vector<edge> G[MAX_V];
long long d[MAX_V];

void dijkstra(long long s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first) continue;
        //if prim,
        //d[v] = -d[v];
        //for keep tree
        for (long long i=0; i<(long long)G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    long long N;
    cin >> N;
    V = 1000000;
    long long E;
    cin >> E;
    long long S;
    cin >> S;
    long long U,V,A,B;
    for (long long i=0; i<E; ++i) {
        cin >> U >> V >> A >> B;
        for(long long j=5000; j>=A; j--){
            edge e = {10000*V+j-A, B};
            G[10000*U+j].push_back(e);
            edge e2 = {10000*U+j-A, B};
            G[10000*V+j].push_back(e2);
        }
    }
    long long C, D;
    for(long long i=1; i<=N; i++){
        cin >> C >> D;
        for(long long j=0; j<=5000; j++){
            if(j+C<=5000){
                edge e3 = {10000*i+j+C, D};
                G[10000*i+j].push_back(e3);
            }else{
                edge e4 = {10000*i+5000, D};
                G[10000*i+j].push_back(e4);
            }
            
        }
    }
    if(S>5000){
        S=5000;
    }
    dijkstra(10000+S);
    long long ans[51];
    fill(ans,ans+51,INF);
    for(long long i=2; i<=N; i++){
        for(long long j=0; j<=5000; j++){
            ans[i] = min(ans[i],d[10000*i+j]);
        }
    }
    for(long long i=2; i<=N; i++){
        cout << ans[i] << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 67880
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

	int main() {
		int n;
		cin >> n;
		hei(ll) a(n);
		ll sum = 0;
		rep(i, 0, n) {
			cin >> a[i];
			sum += a[i];
		}
		ll ans = 1000000000000;
		ll x = a[0];
		sum -= a[0];
		rep(i, 1, n) {
			ans = min(ans, abs(sum - x));
			x += a[i];
			sum -= a[i];
		}
		cout << ans << endl;
		return 0;
	}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k)cout<<x*n<<endl;
	else cout<<x*k+y*(n-k)<<endl;
}
		
		


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	coin := 0

	if A >= B {
		coin += A
		A--
	} else {
		coin += B
		B--
	}

	if A >= B {
		coin += A
		A--
	} else {
		coin += B
		B--
	}

	fmt.Println(coin)
}


Measured memory_bytes: 512
import scala.io.StdIn._
object Main extends App {
  val n = readInt()
  val points = Array.tabulate(n){_ ⇒
    val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
    Point(x, y)
  }
  val memo = Array.tabulate(n){i ⇒ Array.fill(n - i){-1}}
  for (i ← 1 until n / 100) minTree(points, 0, i * 100)(memo)
  println(minTree(points, 0, n)(memo))
  def minTree(points: Array[Point], from: Int, until: Int)(implicit memo: Array[Array[Int]]): Int = {
    if (from + 1 == until) {
      0
    }else if (until - from == 2) {
      minTree(points(from), points(from + 1))
    }else {
      if (memo(from)(until - from - 1) < 0) {
        memo(from)(until - from - 1) = (from + 1 until until).map{mid ⇒ minTree(points, from, mid) + minTree(root(points, from, mid), root(points, mid, until)) + minTree(points, mid, until)}.min
      }
      memo(from)(until - from - 1)
    }
  }
  def minTree(a: Point, b: Point, c: Point): Int = {
    Math.min(minTree(root(a, b), c) + minTree(a, b), minTree(a, root(b, c)) + minTree(b, c))
  }
  def minTree(a: Point, b: Point): Int = {
    b.x - a.x + a.y - b.y
  }
  def root(points: Array[Point], from: Int, until: Int): Point = root(points(from), points(until - 1))
  def root(a: Point, b: Point): Point = {
    Point(a.x, b.y)
  }
}

case class Point(x: Int, y: Int)


Measured memory_bytes: 593304
s = gets.chomp.split("")
t = gets.chomp.split("")
ans = t.size
(s.size - t.size + 1).times do |i|
  cnt = 0
  t.each_index do |j|
    cnt += 1 if s[i+j] != t[j]
  end
  ans = cnt if ans > cnt
end
puts ans

Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
  
  cin >> s1 >> s2;
  
  int sw=0;
  for(int i=0;i<3;++i)
  {if(s1.at(i)==s2.at(2-i)) sw++;
  }
  
  if(sw==3) cout <<"YES";
  else cout <<"NO";

return 0;}

Measured memory_bytes: 3588
import heapq
N,M=map(int,input().split())
A=[-1*int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    a=-1*heapq.heappop(A)
    a=a//2
    heapq.heappush(A,-1*a)
print(-1*sum(A))

Measured memory_bytes: 14184
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[100005];
llint cnt[1<<20];
llint pop[1<<20];

void zeta_transform(llint a[], int n)
{
	int S = 1<<n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < S; j++){
			if(!(j&(1<<i))) a[j] += a[j^(1<<i)], a[j] %= mod;
		}
	}
}

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
	zeta_transform(cnt, 20);
	for(int i = 0; i < (1<<20); i++) cnt[i] = modpow(2, cnt[i]) + mod - 1, cnt[i] %= mod;
	for(int i = 1; i < (1<<20); i++) pop[i] = pop[i&(i-1)] + 1;
	
	llint ans = 0;
	for(int i = 0; i < (1<<20); i++){
		if(pop[i]%2) ans += mod - cnt[i], ans %= mod;
		else ans += cnt[i], ans %= mod;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 20320
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());

	cout << A[N-1]-A[0];
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,a,b,c = map(int,input().split())
s = [input().rstrip() for i in range(n)]
def mthd(a,b,c,s):
  print("Yes")
  for i in range(n):
    if s[i] == "AB":
      if a >= b:
        print("B")
        a -= 1
        b += 1
      else:
        print("A")
        a += 1
        b -= 1
    if s[i] == "AC":
      if a >= c:
        print("C")
        a -= 1
        c += 1
      else:
        print("A")
        a += 1
        c -= 1
    if s[i] == "BC":
      if c >= b:
        print("B")
        c -= 1
        b += 1
      else:
        print("C")
        c += 1
        b -= 1
if a+b+c >= 3 and [a,b,c].count(0) <= 1:
  mthd(a,b,c,s)
else:
  if s[0] == "AB" and a+b == 0:
    print("No")
  elif s[0] == "BC" and b+c == 0:
    print("No")
  elif s[0] == "AC" and a+c == 0:
    print("No")
  elif a+b+c >= 3:
    mthd(a,b,c,s)
  elif a+b+c == 1:
    ans = []
    for i in range(n):
      if s[i] == "AB":
        if a == 1:
          ans.append("B")
        elif b == 1:
          ans.append("A")
        else:
          print("No")
          exit()
        a,b = b,a
      if s[i] == "BC":
        if c == 1:
          ans.append("B")
        elif b == 1:
          ans.append("C")
        else:
          print("No")
          exit()
        c,b = b,c
      if s[i] == "AC":
        if c == 1:
          ans.append("A")
        elif a == 1:
          ans.append("C")
        else:
          print("No")
          exit()
        c,a = a,c
    print("Yes",*ans,sep="\n")
  elif a+b+c == 2:
    print("Yes")
    for i in range(n-1):
      if s[i] == "AB":
        if a>b or (a == b and s[i+1] != "AC"):
          print("B")
          a -= 1
          b += 1
        elif a<b or s[i+1] == "AC":
          print("A")
          a += 1
          b -= 1
      elif s[i] == "AC":
        if a>c or (a == c and s[i+1] != "AB"):
          print("C")
          a -= 1
          c += 1
        elif a<c or s[i+1] == "AB":
          print("A")
          a += 1
          c -= 1
      elif s[i] == "BC":
        if c>b or (b == c and s[i+1] != "AC"):
          print("B")
          c -= 1
          b += 1
        elif c<b or s[i+1] == "AC":
          print("C")
          c += 1
          b -= 1
    if s[-1] == "AB":
      if b > 0:
        print("A")
      else:
        print("B")
    if s[-1] == "BC":
      if b > 0:
        print("C")
      else:
        print("B")
    if s[-1] == "AC":
      if c > 0:
        print("A")
      else:
        print("C")

Measured memory_bytes: 86092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	ll n;
	while(cin>>n){
		cout<<180*(n-2)<<endl;
	}
}


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

const int MOD = 1000000007;
const int A = 0, C = 1, G = 2, T = 3;

int main() {
    int N; cin >> N;
    boost::multi_array<int, 4> dp(boost::extents[101][4][4][4]);
    dp[0][T][T][T] = 1;
    rep(i, N) rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4) {
        auto ng = [&](int a, int b, int c, int d) -> bool {
            return j == a && k == b && l == c && m == d;
        };
        if(ng(j, A, G, C) || ng(j, A, C, G) || ng(j, G, A, C) || ng(A, G, l, C) || ng(A, k, G, C)) continue;
        (dp[i + 1][k][l][m] += dp[i][j][k][l]) %= MOD;
    }
    int ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) {
        (ans += dp[N][i][j][k]) %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
S = input()

if len(S) % 2 != 0:
    print("No")
    exit()
    
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "h":
            pass
        else:
            print("No")
            exit()
    else:
        if S[i] == "i":
            pass
        else:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>

using namespace std;

#define ll long long

int main()
{
	long q;
	cin >> q;

	//	1,3,5,7,9,11,...
	constexpr long size = 100000;
	vector<bool> prime(size, true);

	for (long i = 4; i < size; i += 2)
		prime[i] = false;

	for (long i = 3; i < size; i += 2)
		if (prime[i])
			for (long j = i * 2; j < size; j += i)
				prime[j] = false;
	vector<long> pre(size, 0);
	pre[1] = 0;
	for (long i = 3; i < size; i += 2)
		if (prime[i] && prime[(i + 1) / 2])
			pre[i] = pre[i - 2] + 1;
		else
			pre[i] = pre[i - 2];
	
	for (long p = 0; p < q; p++)
	{
		long l, r;
		cin >> l >> r;
		if (l == 1)
			l = 3;
		printf("%ld\n", pre[r] - pre[l - 2]);
	}

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
  double eps = 10e-7;
  double x1,y1,x2,y2,x3,y3;
  int T;
  scanf("%d",&T);
  for(int i=0;i<T;i++){
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  double a = pow(x2-x3,2.0)+pow(y2-y3,2.0);
  double b = pow(x3-x1,2.0)+pow(y3-y1,2.0);
  double c = pow(x1-x2,2.0)+pow(y1-y2,2.0);
  double a2 = sqrt(pow(x2-x3,2.0)+pow(y2-y3,2.0));
  double b2 = sqrt(pow(x3-x1,2.0)+pow(y3-y1,2.0));
  double c2 = sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
  double s = (a2+b2+c2)/2.0;
  double S = sqrt(s*(s-a2)*(s-b2)*(s-c2));
  double px = (a*(b+c-a) * x1 + b*(c+a-b) * x2 + c*(a+b-c) * x3) / (16.0*pow(S,2.0));
  double py = (a*(b+c-a) * y1 + b*(c+a-b) * y2 + c*(a+b-c) * y3) / (16.0*pow(S,2.0));
  double r = a2*b2*c2/(4.0*S);
  px += 0.00005 + eps;
  py += 0.00005 + eps;
  r += 0.00005 + eps;
  printf("%.3f %.3f %.3f\n",px,py,r);
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int k2 = k * 2;
        int[][] b = new int[k2][k2];
        int[][] w = new int[k2][k2];
        int[][] bs = new int[k2][k2];
        int[][] ws = new int[k2][k2];

        for(int i=0; i<n; i++) {
            int x = sc.nextInt() % k2;
            int y = sc.nextInt() % k2;
            if (sc.next().equals("W")) {
                w[x][y] ++;
            } else {
                b[x][y] ++;
            }
        }

        bs[0][0] = b[0][0];
        ws[0][0] = w[0][0];
        for(int i=1; i<k2; i++) {
            bs[i][0] = bs[i-1][0] + b[i][0];
            bs[0][i] = bs[0][i-1] + b[0][i];
            ws[i][0] = ws[i-1][0] + w[i][0];
            ws[0][i] = ws[0][i-1] + w[0][i];
        }
        for(int x=1; x<k2; x++) {
            for(int y=1; y<k2; y++) {
                bs[x][y] = bs[x-1][y] + bs[x][y-1] - bs[x-1][y-1] + b[x][y];
                ws[x][y] = ws[x-1][y] + ws[x][y-1] - ws[x-1][y-1] + w[x][y];
            }
        }
        int max = 0;
        for(int x=0; x<k; x++) {
            for(int y=0; y<k; y++) {
                max = Math.max(max, sum1(bs, x, y, k) + sum2(ws, x, y, k));
                max = Math.max(max, sum1(ws, x, y, k) + sum2(bs, x, y, k));
            }
        }
        System.out.println(max);
    }


    static int sum2(int[][] a, int x, int y, int k) {
        return a[k*2-1][k*2-1] - sum1(a, x, y, k);
    }

    static int sum1(int[][] a, int x, int y, int k) {
        int res = 0;
        res += sum(a, 0,0,x, y);
        res += sum(a, x+k,0, k*2, y);
        res += sum(a, x,y,x+k, y+k);
        res += sum(a, 0, y+k, x, k*2);
        res += sum(a, x+k,y+k, k*2, k*2);
        return res;
    }

    static int sum(int[][] a, int x0, int y0, int x1, int y1) {
        if(x0 == x1 || y0 == y1) return 0;
        if(x0 == 0 && y0 == 0) {
            return a[x1-1][y1-1];
        }
        if(x0 == 0) {
            return a[x1-1][y1-1] - a[x1-1][y0-1];
        }
        if(y0 == 0) {
            return a[x1-1][y1-1] - a[x0-1][y1-1];
        }
        return a[x1-1][y1-1] - a[x0-1][y1-1] - a[x1-1][y0-1] + a[x0-1][y0-1];
    }
}


Measured memory_bytes: 161912
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	int a,b,c;
	string s;
	cin >> a >> b >> c;
	cout << (a-b+1) * (a-c+1) << endl;
	return 0;

}

Measured memory_bytes: 256
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
ret = 0
for i in range(n-1):
    for j in range(i+1, n):
        meu = 0
        for y, z in zip(x[i], x[j]):
            meu += (y-z)**2
        if (meu**0.5).is_integer():
            ret += 1
print(ret)

Measured memory_bytes: 62644
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Process terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let n: usize = sc.read();
        let mut d: Vec<i32> = (0..n).map(|_| sc.read()).collect();
        d.sort();
        d.dedup();
        println!("{}", d.len());
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;



int main(){
    lint N;
    cin>>N;
    double g[N][2];
    double ans=0;
    rep(i,N){
      double j,k;
      cin>>j>>k;
      g[i][0]=j;
      g[i][1]=k;
    }

    vector <double> x;
rep(i,N){

  rep(j,N){
    if(i==j)continue;
      x.push_back(sqrt((g[i][0]-g[j][0])*(g[i][0]-g[j][0])+(g[i][1]-g[j][1])*(g[i][1]-g[j][1])));
  }
}
rep(i,x.size()){
  ans+=x[i];
}
ans/=N;
printf("%.6f",ans);


}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

vector<int> G[100100];

const ll mod = 1e9+7;
int main()
{
	int n, k;
	cin >> n >> k;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		--a, --b; 
		G[a].push_back(b);
		G[b].push_back(a);
	}
	queue<P> que;
	que.push({0,-1});
	ll ans = 1;
	vector<bool> seen(n+1,false);
	ans *= k;
	seen[0] = true;
	while(que.size()){
		auto p = que.front();
		que.pop();
		int now = k-1;
		for(int i = 0; i < G[p.first].size(); i++){
			int x = G[p.first][i]; // 頂点 x を塗る
			if(seen[x]){
				now--;
			}
		}
		for(int i = 0; i < G[p.first].size(); i++){
			int x = G[p.first][i]; // 頂点 x を塗る
			if(x == p.second) continue;
			seen[x] = true;
			ans *= now;
			ans %= mod;
			now--;
			que.push({x,p.first});
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9888
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e15
typedef long long llong;
using namespace std;

int main(){
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<llong> a(x),b(y),c(z);
	REP(i,x) cin>>a[i];
	REP(i,y) cin>>b[i];
	REP(i,z) cin>>c[i];
	
	vector<llong> dp(x*y);
	int num=0;
	REP(i,x){
		REP(j,y){
			dp[num]=a[i]+b[j];
			num++;
		}
	}
	sort(ALL(dp),greater<llong>());
	
	int n=min(x*y,k);
	vector<llong> dp2(n*z);
	int num2=0;
	REP(i,n){
		REP(j,z){
			dp2[num2]=dp[i]+c[j];
			num2++;
		}
	}
	sort(ALL(dp2),greater<llong>());
	
	REP(i,k) cout<<dp2[i]<<endl;
	return 0;
}//解説参考.

Measured memory_bytes: 31616
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long ret = 1;
  for (int i = 1; i <= N; ++i) {
    ret *= i;
    ret = ret % (1000000000 + 7);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  ll la=0,ra=x;
  while(ra-la!=1)
  {
    ll mid=(ra+la)/2;
    ll sum=mid*(mid+1)/2;
    if(sum>=x) ra=mid;
    else la=mid;
  }
  cout<<ra<<endl;
}

Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ;
using namespace std;
#define MAX 200003
vector<ll> v[MAX];
bitset<MAX> color;
void dfs(int node,int par)
{
    for(auto i: v[node]) {
        if(i^par) {
            color[i]=color[node] ^ 1 ;
            dfs(i,node);
        }
    }
}
int main()
{
    ll n; cin>>n;
    for(int i=1;i<=n-1;i++){
        ll a, b; cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    color[1]=0;
    dfs(1,1);
    int flag=1;
    ll red= color.count();
    ll blue=n-red;
    if(red>blue)  flag=0,swap(red,blue);
    ll val= n/3;
    ll zero=val; ll one= val; ll  two= val;
    ll left=n%3;
    if(left==1){
        one++;
    }
    if(left==2) one++, two++;
    // if(zero+one<red)  { cout<<"-1"<<endl; return 0;  }
    ll arr[n+2]={0};
    vector<ll> temp;
    if(red<=val) {
        for(int i=3;i<=n;i+=3) temp.push_back(i);
        for(int i=1;i<=n;i+=3) temp.push_back(i);
    }
    else{
        for(int i=1;i<=n;i+=3) temp.push_back(i);
        for(int i=3;i<=n;i+=3) temp.push_back(i);
    }
    for(int j=2;j<=n;j+=3) temp.push_back(j);
    int j=0;
    for(int i=1;i<=n;i++){
        if(color[i]==flag)  arr[i]=temp[j++];
    }
    for(int i=1;i<=n;i++){
        if(arr[i]==0){
            arr[i]=temp[j++];
        }
    }
    for(int i=1;i<=n;i++) cout<<arr[i]<<" ";
    cout<<endl;
    
    
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e3 + 5;

bitset<N * N> DP;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, sum = 0; cin >> n;
	DP[0] = 1;
	for (int i = 0; i < n; i++) {
		int x; cin >> x; sum += x;
		DP |= DP << x;
	}
	for (int i = (sum + 1) / 2; i <= sum; i++) if (DP[i]) die(i);

	return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc130/tasks/abc130_b

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t, ans = 0;
    ll sum = 0;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> t;
        sum += t;
        if (sum <= x) {
            ans = i + 1;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

int count = 0;
 for (int i=0; i<N; i++) {
   int a;
   cin >> a;
   if ((i+1) % 2 != 0 && a % 2 != 0) {
     count++;
   }
 }
 cout << count << endl;
}



Measured memory_bytes: 3592
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
int b[10];
long long mod = 1e9+7;
typedef long long ll;
int main()
{
	ll n,m;ll sum = 0;
	cin>>n>>m;
	if(n<m)swap(n,m);
	if(n==m){
		
		ll d = 1;
		for(ll i= 1;i<=n;i++)
		{
			d*=i;
			d=d%mod;
		}
		sum = d*d*2%mod;
		cout<<sum<<endl;
	}
	else if(n-2>=m) {
		cout<<0<<endl;
	}
	else
	{
		ll d= 1,c = 1;
		for(ll i=1;i<=n;i++)
		{
			 d*=i;
			 d=d%mod;
		}
		for(ll i=1;i<=m;i++)
		{
			c*=i;
			c=c%mod;
		}
		sum = c*d%mod;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  long n,i,j,cnt=0,tmp;
  int a[10000];
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    cnt+=a[i];
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j]>a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  cout<<a[n-1]<<" "<<a[0]<<" "<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	i64 A = 0, B = 0;
	std::vector<i64> a(n), b(n);
	std::vector<std::pair<i64, int>> vec;
	for(int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
		
		vec.push_back({a[i], i});
		vec.push_back({b[i], i});
		
		A += a[i];
		B += b[i];
	}
	sort(begin(vec), end(vec));
	
	/*
	for(auto v: vec) cout << v.first << " "; cout << endl;
	for(auto v: vec) cout << v.second << " "; cout << endl;
	*/
	
	i64 tmp = 0, ans = std::min(A, B);
	bool flag = false;
	std::vector<bool> used(n, false);
	for(int i = 0; i < n; i++) {
		tmp += vec[i].first;
		if(used[vec[i].second]) flag = true;
		else used[vec[i].second] = true;
	}
	if(!flag) {
		if(vec[n - 1].second == vec[n].second) {
			i64 latte = vec[n + 1].first - vec[n - 1].first;
			i64 malta = vec[n].first - vec[n - 2].first;
			tmp += std::min(latte, malta);
		} else {
			tmp -= vec[n - 1].first;
			tmp += vec[n].first;
		}
	}
	ans = std::min(ans, tmp);
	
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main()

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

    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a+3);

    cout << a[0]+a[1];

    return 0;
}


Measured memory_bytes: 256
a = int(input())

b = list(map(int, input().split()))
c = []
count = 0

if a == 1:
    print(0)
    exit()

for i in range(a-1):
    if b[i] >= b[i+1]:
        count += 1
    else:
        count = 0
    c.append(count)

print(max(c))

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

struct hako {
	int tate;
	int yoko;
};
bool biggerthan(hako a, hako b) {
	int a2 = (a.tate)*(a.tate) + (a.yoko)*(a.yoko);
	int b2 = (b.tate)*(b.tate) + (b.yoko)*(b.yoko);
	if (a2 != b2) return a2 > b2;
	return a.tate > b.tate;
}
bool smallerthan(hako b, hako a) {
	int a2 = (a.tate) * (a.tate) + (a.yoko) * (a.yoko);
	int b2 = (b.tate) * (b.tate) + (b.yoko) * (b.yoko);
	if (a2 != b2) return a2 > b2;
	return a.tate > b.tate;
}
int main() {
	hako inp;
	hako hyouka;
	int a, b;
	int n, count;
	int resulttate[200] = {};
	int resultyoko[200] = {};
	hako tmp[30000];
	int nanko;
	for (count = 0; true; count++) {
		
		cin >> a >> b;
		inp.tate = a;
		inp.yoko = b;
		nanko = 0;
		if (a == 0 && b == 0) break;
		for (int i = 2; i < 150; i++) {
			for (int j = i-1; j > 0; j--) {
				hyouka.tate = j;
				hyouka.yoko = i;
				if (biggerthan(hyouka, inp)) {
					tmp[nanko].tate = j;
					tmp[nanko].yoko = i;
					nanko++;
				}
			}
		}
		sort(tmp, tmp + nanko, smallerthan);
			resulttate[count] = tmp[0].tate;
			resultyoko[count] = tmp[0].yoko;
	}
	for (int i = 0; i < count; i++) {
		cout << resulttate[i] << " " << resultyoko[i] << endl;
	}
	return 0;
}
	/*
	int n;
	long long int sumer = 0;
	int temp;
	int ave;
	int data[60000];
	int result[60000] = {};
	int count;
	for (count = 0; true; count++) {
		cin >> n;
		sumer = 0;
		temp = 0;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> temp;
			data[i] = temp;
			sumer += temp;
		}
		ave = sumer / n;
		for (int i = 0; i < n; i++) {
			if (data[i] <= ave) {
				result[count]++;
			}
		}
		
	}
	for (int i = 0; i < count; i++) {
		cout << result[i] << endl;
	}
	return 0;
}
/*
//単一連結リストの実装
struct ListNode {
	int data;
	struct ListNode* next;
};*//*
int ListLength(struct ListNode* head) {
	struct ListNode* current = head;
	int count = 0;
	while (current != NULL) {
		count++;
		current = current -> next;
	}
	return count;
}


int main()
{
	int n = 0;
	int owari = 11451414;
	int result[50010] = {};
	int sa = owari;
	int count = 0;
	while (true) {
		int dataset[50010];
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> dataset[i];
		}
		sort(dataset, dataset + n);
		sa = owari;
		for (int i = 1; i < n; i++) {
			if (abs(dataset[i] - dataset[i - 1]) < sa) {
				sa = abs(dataset[i] - dataset[i - 1]);
			}
		}
		result[count] = sa;
		count++;
	}
	for (int i = 0; i < count; i++) {
		cout << result[i] << endl;
	}
	return 0;
}
*/


Measured memory_bytes: 3240
using System;
using System.Collections.Generic;
class Program
{
  public static void Main()
  {
    var line = Console.ReadLine().Split();
    int a = int.Parse(line[0]);
    int b = int.Parse(line[1]);
    line = Console.ReadLine().Split();
    int c = int.Parse(line[0]);
    int d = int.Parse(line[1]);
    Console.WriteLine((a-c)*(b-d));
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;

  string border(W + 2, '#');
  
  vector<string> a(H + 2);

  a[H + 1] = a[0] = border;
  for (int i = 1; i < (H + 1); i++) {
	cin >> a[i];
    a[i] = "#" + a[i] + "#";
  }

  // 出力
   for (auto itr = a.begin(); itr != a.end(); ++itr) {
        cout << *itr << endl;
   }
}


Measured memory_bytes: 3636
import numpy as np
def solve(n, a):
    b = np.abs(a)
    num = 0
    for i in range(n):
        if a[i] < 0:
            num += 1
    if num % 2 == 0:
        return np.sum(b)
    else:
        return np.sum(b) - 2*np.min(b)

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Measured memory_bytes: 23316
import sys
input = sys.stdin.readline
# 昇順ソートされた配列の挿入位置indexを返す O(logN)
from bisect import bisect_left

def isOver(a,n,x):
	cnt = 0
	for i in range(n):
		cnt += n-bisect_left(a,x-a[i])
	return cnt

def calX(a,n,m,l,r):
	while r-l>1:
		# x: 握手で得たい最低パワー値
		x = (l+r)//2
		if isOver(a,n,x) >= m:
			l = x
		else: #握手する限界回数すら満たせないほど大きいxなら
			r = x 
	return l

n,m = map(int, input().split())
a = list(map(int, input().split()))

#累積和の下準備
a.sort()
s = [0]*(n+1)
for i in range(n):
	s[i+1] = s[i]+a[i]

x = calX(a,n,m,a[0]*2,a[n-1]*2)

out = 0
for i in range(n):
	idx = bisect_left(a,x-a[i])
	out += s[n]-s[idx]+a[i]*(n-idx)

out -= (isOver(a,n,x)-m)*x

print(out)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) cout << s[i] << t[i];
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int g[110][110];
pair<pair<int,int>,int> edge[1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=i+1;j<a;j++)g[i][j]=g[j][i]=mod;
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);p--;q--;
		g[p][q]=g[q][p]=r;
		edge[i]=make_pair(make_pair(p,q),r);
	}
	for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	int ret=0;
	for(int i=0;i<b;i++){
		bool ok=false;
		for(int j=0;j<a;j++)for(int k=0;k<a;k++){
			if(g[j][k]==g[j][edge[i].first.first]+g[k][edge[i].first.second]+edge[i].second)ok=true;
			if(g[j][k]==g[k][edge[i].first.first]+g[j][edge[i].first.second]+edge[i].second)ok=true;
			
		}
		if(!ok)ret++;
	}
	printf("%d",ret);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,M;
  cin >> N >> M;

  int x = 1900*M+100*(N-M);

  cout << x*pow(2,M) << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> F(N,vector<int>(10)),P(N,vector<int>(11));
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin>>F.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin>>P.at(i).at(j);
    }
  }

  int ans=-1000000000;
  for(int i=1;i<(1<<10);i++){
    vector<int> a(10);
    int res=i;
    for(int j=0;j<10;j++){
      a.at(j)=res%2;
      res/=2;
    }
    int sub=0;
    for(int j=0;j<N;j++){
      int count=0;
      for(int k=0;k<10;k++){
        count+=F.at(j).at(k)*a.at(k);
      }
      sub+=P.at(j).at(count);
    }
    ans=max(ans,sub);
  }
  cout<<ans<<endl;
}


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

int main() {
  int N=0, a=0, b=0, c=10;
  cin >> N;
  
  a = N % c;
  for(int i=0; i<8; i++){
    if(c > N){
      break;
    }
    b = N / c;
    a += b % 10 ;
    c = c * 10;
  }
  
  if(N % a == 0){
    cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  } 
}

Measured memory_bytes: 3540
######################################################
############Created by Devesh Kumar###################
#############devesh1102@gmail.com####################
##########For CodeForces(Devesh1102)#################
#####################2020#############################
######################################################
import sys
input = sys.stdin.readline

# import sys
import heapq 
import copy
import math
import decimal
# import sys.stdout.flush as flush
# from decimal import *
#heapq.heapify(li) 
#
#heapq.heappush(li,4) 
#
#heapq.heappop(li)
#
# &	Bitwise AND Operator	10 & 7 = 2
# |	Bitwise OR Operator	10 | 7 = 15
# ^	Bitwise XOR Operator	10 ^ 7 = 13
 
# <<	Bitwise Left Shift operator	10<<2 = 40
# >>	Bitwise Right Shift Operator
# '''############ ---- Input Functions ---- #######Start#####'''
 

def inp():
	return(int(input()))
def inlt(): 
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(list(s[:len(s) - 1]))
def insr2():
	s = input()
	return((s[:len(s) - 1]))
def invr():
	return(map(int,input().split()))
 ############ ---- Input Functions ---- #######End
 # #####   

def pr_list(a):
	print(*a, sep=" ")
def main():
	# tests =  inp()
	tests = 1
	mod = 1000000007
	limit = 10**18
	ans = 0
	start = {}
	for test in range(tests):
		n = inp()
		a = inlt()
		pre =[a[0]]
		for i in range(1,n):
			pre.append(pre[-1] + a[i])
		dp = [[-1*sys.maxsize for j in range(n)] for i in range(n)]
		for i in range(n-1,-1,-1):
			dp[i][i] = a[i]
			for j in range(i+1,n,1):
				dp[i][j] = max( a[i] + (pre[j] - pre[i]) - dp[i+1][j] , a[j] + pre[j-1] - pre[i] + a[i]  - dp[i][j-1])
		# print(dp)
		print( 2*dp[0][n-1] - sum(a))
				





		
		


if __name__== "__main__":
	main()

Measured memory_bytes: 158244
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int k = Integer.parseInt(scan.next());
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());

		for (int i = a;i <= b; ++i){
			if (i%k==0){
				System.out.print("OK");
				System.exit(0);
			}
		}
		System.out.print("NG");

	}
}

//end


Measured memory_bytes: 35704
package main

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

func main() {
    scanner :=  bufio.NewScanner(os.Stdin)
    var s string
           if scanner.Scan() {
                s= scanner.Text()
           } 
     ns := strings.Split(s, " ")
     a, _ := strconv.Atoi(ns[0])
    b, _:= strconv.Atoi(ns[1])
     c, _:= strconv.Atoi(ns[2])
     if a <= b *  c {
         fmt.Println("Yes")
     } else {
          fmt.Println("No")
    }
}

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

using namespace std;

int main(){
	string s,t;
	int total=0;
	cin>>s>>t;
	for(int i=0;i<=s.size();i++){
		if(s[i]!=t[i]){
			total++;
		}
	}
	cout<<total;
}

Measured memory_bytes: 3836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;



int main()
{
	int a, b, c;
	while (scanf("%d%d%d", &a, &b, &c) == 3)
	{
		printf("%d\n", a + b + c - max(a, max(b, c)));
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
# Initializing variables
n, r = map(int, input().split())

# Calculating
if n >= 10:
    print(r)
else:
    print(r + (100 * (10 - n)))

# Check out my Youtube channel! https://www.youtube.com/channel/UCMOKVyAbTZOpKikTrX5dy_A

Measured memory_bytes: 2940