akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 200000
#define ll long long
using namespace std;

int main(){
    ll ans=1;
    ll n;
    cin>>n;
    ll data[n];
    for (int i=0; i<n; i++){
        cin>>data[i];
        if (data[i]==0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    
    for (ll i=0; i<n; i++){
        if(1000000000000000000/data[i]<ans){
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=data[i];
        
    }
    

    
    cout<<ans<<endl;
}

Measured memory_bytes: 4404
#include <iostream>
#include <unordered_map>

using namespace std;

const int W = 4, H = 5;
unordered_map<string, int> memo;

inline int next(int pos, int dy, int dx)
{
    if (dy == 0 && dx == 0)
        return -1;
    int x = (pos % W) + dx, y = (pos / W) + dy;
    if (x < 0 || y < 0 || x >= W || y >= H)
        return -1;
    return y * W + x;
}

int Rec(string s)
{
    if (memo.end() != memo.find(s))
        return memo[s];

    const int n = s.size();
    int res = n;

    for (int i = 0; i < n; ++i) {
        string tmp("", n - 2);

        for (int dy = -1; dy <= 1; ++dy) {
            for (int dx = -1; dx <= 1; ++dx) {
                int nx = next(i, dy, dx);
                if (nx == -1 || nx >= n)
                    continue;
                if (s[i] != s[nx])
                    continue;

                int index = 0;
                for (int l = 0; l < n; ++l)
                    if (l != i && l != nx)
                        tmp[index++] = s[l];

                res = min(res, Rec(tmp));
            }
        }
    }

    memo.insert(unordered_map<string, int>::value_type(s, res));
    return res;
}

int main()
{
    int N;

    cin >> N;
    while (N--) {
        // Input
        char ch;
        string card;

        for (int i = 0; i < H * W; ++i) {
            cin >> ch;
            card += ch;
        }
        // Solve
        cout << Rec(card) << endl;
    }

    return 0;
}

Measured memory_bytes: 1516
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

string S, T;
vector<string> ans;
string ns;

bool check(int p, int L){
	bool ok = 1;
	rep(i,L){
		if(!(S[p]==T[i] || S[p]=='?')){
			ok = 0; break;
		}
		p++;
	}
	if(ok) return 1;
	else return 0;
}

string DO(int p, int L){
	string s = ns;
	rep(i,L){
		s[p++] =  T[i];
	}
	return s;
}

int main(){
	cin >> S >> T;

	int l1 = S.size();
	ns = S;
	rep(i,l1){
		if(ns[i]=='?') ns[i] = 'a';
	}

	int l2 = T.size();
	bool ok = 0;
	rep(i,l1){
		if((S[i]==T[0] || S[i]=='?')&&(i+l2-1)<l1){
			if(check(i,l2)){
				ok = 1;
				string tmp = DO(i,l2);
				ans.pb(tmp);
			}
		}
	}

	if(ok){
		sort(ans.begin(),ans.end());
		cout << ans[0] << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    loop(i, n) cin >> a[i] >> b[i];
    vector<pair<ll, ll>> pairs(n);
    loop(i, n) pairs[i] = make_pair(a[i], b[i]);
    sort(all(pairs));
    loop(i, n)
    {
        a[i] = pairs[i].first;
        b[i] = pairs[i].second;
    }
    priority_queue<ll> select;
    ll now = 0;
    ll ans = 0;
    loop(i, m)
    {
        ll can = i + 1;
        while (a[now] <= can && now < n)
        {
            select.push(b[now]);
            now++;
        }
        if (!select.empty())
        {
            ll choose = select.top();
            select.pop();
            ans += choose;
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 7364
#include<stdio.h>

int main() {
	int D, N, out = 1;
	scanf("%d %d", &D, &N);
	for (int i = 0; i < D; i++) {
		out *= 100;
	}
	if (N == 100)N++;
	printf("%d\n", out*N);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
  int a[3],i,j,k,n,ans;
  for(i=0;i<3;i++){cin>>a[i];}
  sort(a,a+3);
  ans=0;
 while(a[1]!=a[2]){ans++;a[0]++;a[1]++;}
  
  n=a[2]-a[0];
  ans+=n/2;
  if(n%2==1)ans+=2;
  cout<<ans;
  
  
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9)
		cout<<"hon";
	else if(a%10==0||a%10==1||a%10==6||a%10==8)
		cout<<"pon";
	else if(a%10==3)
		cout<<"bon";
	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 105;
const int MAXVAL = 1e5 + 50;
const int INF = 0x3f3f3f3f;

int n, w;
int weight[N];
int val[N];
ll dp[MAXVAL];
int bound;

void load() {
    scanf("%d%d", &n, &w);

    for(int i = 0; i < n; ++i) {
        scanf("%d%d", weight + i, val + i);
        bound += val[i];
    }
}

void solve() {
    dp[0] = 0;

    for(int j = 0; j < n; ++j) {
        for(int i = bound; i >= val[j]; --i)
                dp[i] = min(dp[i], dp[i - val[j]] + weight[j]);
    }

    ll sol;
    for(int i = bound; i >= 0; --i){
        if(dp[i] <= w) {
            sol = i;
            break;
        }
    }
    printf("%lld\n", sol);
}

int main() {
    memset(dp, INF, sizeof dp);

    load();
    solve();

    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;sc.hasNext();) {
			P ps[] = new P[4];
			for(int i=0;i<4;i++) ps[i] = new P(sc.nextDouble(), sc.nextDouble());
			boolean flg = true;
			for(int i=0;i<3;i++) if( ps[i].sub(ps[(i+1)%3]).det(ps[i].sub(ps[3])) * ps[i].sub(ps[(i+2)%3]).det(ps[i].sub(ps[3])) >= 0.0 )
				flg = false;
			
			System.out.println( (flg? "YES": "NO") );
		}
	}
	
	class P {
		double x, y;
		P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		
		P sub(P p) {
			return new P( x-p.x, y-p.y );
		}
		
		double det(P p) {
			return x * p.y - y * p.x;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

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

  vector<uint64_t> C(N, 0);
  N_TIMES(m, M) {
    uint64_t a, b;
    cin >> a >> b;

    ++C[a - 1];
    ++C[b - 1];
  }

  bool flag = true;
  N_TIMES(n, N) {
    if ((C[n] & 1) == 1) { flag = false; break; }
  }
  cout << (flag ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 1024
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	arr =  inp.readIntArray()
	s = set()
	s.update(arr)
	if len(s) == 2:
		print("Yes")
	else:
		print("No")

if __name__ == "__main__":
   main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <time.h>

int main(){
	
	int N,M,C;
	
	scanf("%d %d %d",&N,&M,&C);
	
	int B[M];
	
	for(int i=0;i<M;i++){
		scanf("%d",&B[i]);
	}
	
	int A[N][M];
	int count=0;
	
	for(int i=0;i<N;i++){
		int AA=C;
		for(int j=0;j<M;j++){
			scanf("%d",&A[i][j]);
			AA += A[i][j]*B[j];
		}
		if(AA>0){
			count++;
		}
		
	}
	
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 60);
int64_t N, K;
vector<int64_t> scores[5005];
vector<int64_t> P(5005), C(5005);
int64_t tot[5005];
vector<int64_t> maxs(5005, -INF);

bool visited[5005];
void dfs(int64_t v, int64_t score, int64_t start)
{
  if (visited[v])
  {
    scores[start].push_back(score);
    tot[start] = score;
    return;
  }
  visited[v] = true;
  scores[start].push_back(score);
  dfs(P.at(v), score + C.at(P.at(v)), start);
}

int main()
{
  cin >> N >> K;
  for (int64_t i = 0; i < N; i++)
  {
    cin >> P.at(i);
    P.at(i)--;
  }
  for (int64_t i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 5005; j++)
    {
      visited[j] = false;
    }
    dfs(i, 0, i);
  }
  for (int i = 0; i < N; i++)
  {
    int64_t cyc = scores[i].size() - 1;
    int64_t cycles = K / cyc, r = K % cyc;
    if (tot[i] < 0 || cycles == 0)
    {
      int64_t ma = -INF;
      for (int j = 1; j <= min(K, cyc); j++)
      {
        ma = max(ma, scores[i].at(j));
      }
      maxs[i] = ma;
    }
    else
    {
      if (r == 0)
      {
        int64_t ma = -INF;
        for (int j = 1; j <= cyc; j++)
        {
          ma = max(ma, scores[i].at(j));
        }
        ma += (cycles - 1) * tot[i];
        maxs[i] = ma;
      }
      else
      {
        int64_t ma = 0;
        for (int j = 1; j <= r; j++)
        {
          ma = max(ma, scores[i].at(j));
        }
        ma += cycles * tot[i];
        maxs[i] = ma;
      }
    }
  }
  int64_t ans = -INF;
  for (int64_t i = 0; i < N; i++)
  {
    ans = max(ans, maxs[i]);
  }
  cout << ans << endl;
}

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

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

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i], a[i]--;

  int logk = floor(log2(k));
  vector<vector<ll>> d(logk + 1, vector<ll>(n));
  rep(i, n) d[0][i] = a[i];

  rep(i, logk) rep(j, n) d[i + 1][j] = d[i][d[i][j]];

  int now = 0;
  for (int i = 0; i <= logk; ++i) {
    if (k & 1) now = d[i][now];
    k >>= 1;
  }
  cout << now + 1 << endl;
  return 0;
}


Measured memory_bytes: 100356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,b,t;
    cin>>x>>b>>t;
    int a=0;
    if(t<x)
    {
        cout<<"0"<<endl;
        return 0;
    }
    else
    {
        a=t/x;
        b=b*a;
    }
    cout<<b<<endl;
    return 0;

}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int MAXM = 2e5 + 5;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
struct edge {int dest, home; };
int n, m;
int pre[MAXN], suf[MAXN];
bool vis[MAXN][MAXN], ans[MAXM];
vector <edge> a[MAXN];
void dfs(int from, int pos) {
	vis[from][pos] = true;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (!vis[from][a[pos][i].dest]) dfs(from, a[pos][i].dest);
}
void dfspre(int pos, int val) {
	pre[pos] = val;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (pre[a[pos][i].dest] == -1) dfspre(a[pos][i].dest, val);
}
void dfssuf(int pos, int val) {
	suf[pos] = val;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (suf[a[pos][i].dest] == -1) dfssuf(a[pos][i].dest, val);
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		a[x].push_back((edge) {y, i});
	}
	for (int i = 1; i <= n; i++)
		dfs(i, i);
	for (int i = 1; i <= n; i++)
	for (unsigned j = 0; j < a[i].size(); j++)
		if (vis[a[i][j].dest][i]) ans[a[i][j].home] ^= true;
	for (int i = 1; i <= n; i++) {
		memset(pre, -1, sizeof(pre));
		memset(suf, -1, sizeof(suf));
		pre[i] = suf[i] = 0;
		for (unsigned j = 0; j < a[i].size(); j++)
			if (pre[a[i][j].dest] == -1) dfspre(a[i][j].dest, j);
		for (unsigned j = a[i].size(); j > 0; j--)
			if (suf[a[i][j - 1].dest] == -1) dfssuf(a[i][j - 1].dest, j - 1);
		for (unsigned j = 0; j < a[i].size(); j++)
			if (pre[a[i][j].dest] != suf[a[i][j].dest]) ans[a[i][j].home] ^= true;
	}
	for (int i = 1; i <= m; i++)
		if (ans[i]) printf("diff\n");
		else printf("same\n");
	return 0;
}

Measured memory_bytes: 5504
#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>;

const int INF = 1001001001;
int main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h + 1, INF);
  dp[0] = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    rep(j, h) {
      int nj = min(j + a, h);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
s = str(input())

aaa = collections.Counter(s)
s_r = aaa["R"]
s_g = aaa["G"]
s_b = aaa["B"]

def noteq(a, b, c):
  if a != b and b != c and c != a:
    return True
  else:
    return False

ans = s_r * s_g * s_b

for i in range(n):
  for d in range(n):
    j = i + d
    k = j + d
    if k >= n:
      break;
    else:
      a = s[i]
      b = s[j]
      c = s[k]
      if noteq(a, b, c):
        ans -= 1
    
print(ans)

Measured memory_bytes: 9376
n=int(input())
a=[-1 for i in range(n)]
d=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    d[u].append([v,w])
    d[v].append([u,w])
e=0
a[0]=0
l=[]
for i,j in d[0]:
    a[i]=(a[0]+j)%2
    l.append(i)
while len(l)>0:
    b=l.pop()
    for i,j in d[b]:
        if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i)
print(*a,sep='\n')

Measured memory_bytes: 46960
fun main(args: Array<String>) {
    val (A, B, C, D) = readLine()!!.split(' ').map { it.toLong() }
    val cd = lcm(C, D)
    val aDIVc = A.div(C)
    val aDIVd = A.div(D)
    val bDIVc = B.div(C)
    val bDIVd = B.div(D)
    val aDIVcd = A.div(cd)
    val bDIVcd = B.div(cd)
    var res = (B - bDIVc - bDIVd + bDIVcd) - (A - aDIVc - aDIVd + aDIVcd)
    if (A % C != 0L && A % D != 0L) {
        res = res.inc()
    }
    println(res)
}

private fun gcd(m: Long, n: Long): Long {
    if (m < n) return gcd(n, m)
    return if (n == 0L) m else gcd(n, m % n)
}

private fun lcm(m: Long, n: Long): Long {
    return m * n / gcd(m, n)
}


Measured memory_bytes: 38044
fun solve(S: String) {
    val alp = "abcdefghijklmnopqrstuvwxyz"
    repeat(26) {
//        println(it)
        if (alp[it].toString() == S) {
            println(alp[(it + 1) % 26])
        }
    }
}

fun main() {
    val S = readLine()!!
//    val N = readLine()!!.toInt()
//    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(S)
}

Measured memory_bytes: 34396
n=gets.to_i
a=gets.chomp.split(" ").map(&:to_i)
x=1
sum = 0
a.each do |v|
  x=x.lcm(v)
end
a.each do |v|
  sum+=x/v
  # sum=(sum+x/v)%1000000007
end
puts sum%(1000000007)

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

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int> > V(N + 1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        V[a].push_back(b);
    }
    int S, T;
    cin >> S >> T;
    vector<vector<bool> > passed(N + 1, vector<bool>(3, false));
    int start = S;
    passed[start][0] = true;
    queue<int> Q;
    Q.push(start);
    int dist = 0;
    while (!Q.empty()) {
        int size = Q.size();
        dist++;
        while (size--) {
            int c = Q.front();
            Q.pop();
            for (const auto v : V[c]) {
                if (passed[v][dist % 3]) continue;
                if (v == T && dist % 3 == 0) {
                    printf("%d\n", dist/3);
                    return 0;
                }
                Q.push(v);
                passed[v][dist % 3] = true;
            }
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 12800
N = int(input())
c = list(map(int, input().split()))

a = list()


for i in range(N):
    if (c[i] % 2 == 0):
        if(c[i] % 3 == 0 or c[i] % 5 == 0):
            a.append(1)
        else:
            a.append(0)



b = 0
for i in range(len(a)):
    b = b + int(a[i])


if(b == len(a)):
    print("APPROVED")
else:
    print("DENIED")

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1; 
	//cin>>t;
	while(t--){
		float n, x, t;
		cin>>n>>x>>t;
		if(n<=x){
			cout<<t<<"\n";
		}
		else {
			cout<<(int)(ceil(n/x)*t)<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,x[3000],y[3000];
    while(cin>>n,n){
    set<pair<int,int>>st;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        st.emplace(x[i],y[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int x1=x[i],y1=y[i],x2=x[j],y2=y[j],x3=x2-y2+y1,y3=y2+x2-x1,x4=x1-y2+y1,y4=y1+x2-x1;
            if(st.count(make_pair(x3,y3))&&st.count(make_pair(x4,y4)))
                ans=max(ans,(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }
    }
    cout<<ans<<endl;
    }
}



Measured memory_bytes: 3328
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3942190
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MOD = 1e9 + 7;
LL fact[999999];
LL ifact[999999];
pair<LL, LL> vec[1111111];
LL dp[1000101];

LL modpow(LL a, LL b){
    LL r = 1;
    while(b){
        if(b & 1) r = (r * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return r;
}

LL inv(LL x){
    return modpow(x, MOD - 2);
}

LL mul(LL a, LL b){
    return (a * b) % MOD;
}

LL add(LL a, LL b){
    return (a + b) % MOD;
}

LL sub(LL a, LL b){
    return (add(a, -b) + MOD) % MOD;
}

LL calc(LL x1, LL y1, LL x2, LL y2){
    if(x2 < x1 || y2 < y1) return 0;
    LL x = x2 - x1;
    LL y = y2 - y1;
    return mul(fact[x + y], mul(ifact[x], ifact[y]));
}

int main(){
    
    // 1. 入力情報取得.
    fact[0] = 1;
    ifact[0] = 1;
    for(LL i = 1; i <= 999999; i++){
        fact[i] = mul(fact[i - 1], i);
        ifact[i] = mul(ifact[i - 1], inv(i));
    }
    
    // 2. dp更新.
    LL n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    
    for(int i = 0; i < k; i++){
        LL x, y;
        scanf("%d %d", &x, &y);
        vec[i] = pair<LL, LL>(x, y);
    }
    vec[k] = pair<LL, LL>(n, m);
    sort(vec, vec + k + 1);
    for(int i = 0; i < k + 1; i++){
        LL x = calc(1, 1, vec[i].first, vec[i].second);
        dp[i] = x;
    }
    for(int j = 0; j < k + 1; j++){
        for(int i = 0; i < j; i++){
            if(vec[i].first <= vec[j].first && vec[i].second <= vec[j].second){
                dp[j] = sub(dp[j], mul(dp[i], calc(vec[i].first, vec[i].second, vec[j].first, vec[j].second)));
            }
        }
    }
    // 3. 出力.
    printf("%lld\n", dp[k]);
    return 0;
    
}

Measured memory_bytes: 18560
import java.awt.*;
import java.io.*;
import java.net.StandardSocketOptions;
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main();
    }
    public Main(){
        new TestA().doIt();
    }
    class TestA{
        void doIt() {
            String str = sc.next();
            String zero[] = {"SSS"};
            String one[] = {"RSS","SRS","SSR","RSR"};
            String two[] = {"RRS","SRR"};
            String three[] = {"RRR"};
            for(int i = 0;i < zero.length;i++){
                if(str.equals(zero[i]))System.out.println(0);
            }
            for(int i = 0;i < one.length;i++) {
                if (str.equals(one[i])) System.out.println(1);
            }
            for(int i = 0;i < two.length;i++){
                if(str.equals(two[i]))System.out.println(2);
            }
            for(int i = 0;i < three.length;i++){
                if(str.equals(three[i]))System.out.println(3);
            }
        }
    }
}

Measured memory_bytes: 35604
s = int(input())
lst = [s]
while True:
    x = lst[-1]
    if x%2 == 0:
        lst.append(x // 2)
    else:
        lst.append(3 * x + 1)
    if lst.count(lst[-1]) >= 2:
        print(len(lst))
        break
        

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

typedef long long int ll; 

int main(void)
{
	ll n,d;
	cin >> n >> d;

	ll cnt = 0;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin >> x >> y;
		ll val = (x*x) + (y*y);
		if(val <= (d*d))
			cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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

int main(void){
	double a,b,c,d,e,f;
	double x,y;
	cout << fixed;
	cout.precision(3);
	while(cin >> a >>b >> c >> d >> e >>f){
		x=(c*e-b*f)/(a*e-b*d);
		y=(c*d-a*f)/(b*d-a*e);
		if(x==0) x=0.0;
		if(y==0) y=0;
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll n, s;
ll a[maxn];
int main(){
    cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        s ^= a[i];
    }
    for(int i = 1;i <= n;i++){
        cout << (s ^ a[i]) << " ";
    }
    puts("");
    return 0;
}

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

int main(){
    vector<int> vec(5);
    for (int i = 0; i < 5; i++){
        cin >> vec.at(i);
    }
    int k;
    cin >> k;
    if (vec.at(4)-vec.at(0)>k){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 5010
int f[N][N], n;
string s;

int main() {
    cin >> n >> s;
    int ans = 0;
    for(int i = n - 1; i >= 0; i--)
        for(int j = n - 1; j >= 0; j--) {
            if (s[i] == s[j]) f[i][j] = max(f[i][j], f[i + 1][j + 1] + 1);
            ans = max(ans, min(f[i][j], j - i));
        }
    cout << ans << endl;
}

Measured memory_bytes: 98048
#include <iostream>

using namespace std;

int main() {
  string N;
  cin >> N;
  int ans = 0;
  if (N[0] == '+') {
    ans++;
  } else {
    ans--;
  }
  if (N[1] == '+') {
    ans++;
  } else {
    ans--;
  }
  if (N[2] == '+') {
    ans++;
  } else {
    ans--;
  }
  if (N[3] == '+') {
    ans++;
  } else {
    ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    vector<int>ans(n+1);
    rep(i,n)cin>>a[i+1];
    
    for(int i=n;i>0;i--){
        int sum=0;
        for(int j=i+i;j<=n;j+=i){
            sum+=ans[j];
        }
       
        ans[i]=(sum+a[i])%2;
    }
    
    int res=0;
    rep(i,n){
        res+=ans[i+1];
        //cout<<i+1<<" "<<a[i+1]<<endl;
    }
    cout<<res<<endl;
    rep(i,n){
        if(ans[i+1]==1){
            cout<<i+1<<endl;
        }
    }
   
    return 0;
}

Measured memory_bytes: 2432
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define d(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
    LL r,g,b;
    cin>>r>>g>>b;
    if((g*10+b)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[]d = new int[6];
		for(int i = 0; i < 6; i++) {
			d[i] = scan.nextInt();
		}
		int[]e = new int[6];
		for(int i = 0; i < 6; i++) {
			e[i] = scan.nextInt();
		}
		int[]d0 = {d[0], d[1], d[2], d[3], d[4], d[5]};
		int[]d1 = {d[1], d[5], d[2], d[3], d[0], d[4]};
		int[]d2 = {d[2], d[0], d[1], d[4], d[5], d[3]};
		int[]d3 = {d[3], d[0], d[4], d[1], d[5], d[2]};
		int[]d4 = {d[4], d[0], d[2], d[3], d[5], d[1]};
		int[]d5 = {d[5], d[1], d[3], d[2], d[4], d[0]};
		scan.close();
		int[][]D = new int[24][6];
		for(int i = 0; i < 6; i++) {
			D[0][i] = d0[i];
			D[4][i] = d1[i];
			D[8][i] = d2[i];
			D[12][i] = d3[i];
			D[16][i] = d4[i];
			D[20][i] = d5[i];
		}

		for(int i = 0; i < 3; i++) {
			int[]k0 = rot(D[i]);
			int[]k1 = rot(D[i + 4]);
			int[]k2 = rot(D[i + 8]);
			int[]k3 = rot(D[i + 12]);
			int[]k4 = rot(D[i + 16]);
			int[]k5 = rot(D[i + 20]);

			for(int j = 0; j < 6; j++) {
				D[i + 1][j] = k0[j];
				D[i + 5][j] = k1[j];
				D[i + 9][j] = k2[j];
				D[i + 13][j] = k3[j];
				D[i + 17][j] = k4[j];
				D[i + 21][j] = k5[j];
			}
		}
//		for(int i = 0; i < 24; i++) {
//			for(int j = 0; j < 6; j++) {
//				System.out.print(D[i][j] + " ");
//			}
//			System.out.println();
//		}

		for(int i = 0; i < 24; i++) {
			boolean flag = true;
			for(int j = 0; j < 6; j++) {
				if(D[i][j] != e[j]) {
					flag = false;
					break;
				}
			}
			if(flag) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}
	static int[] rot(int[] d) {
		int []t = new int[6];
		int []d1 = new int[6];
		for(int j = 0; j < 6; j++) {
			t[j] = d[j];
			d1[j] = d[j];
		}
		d1[1] = t[3];
		d1[2] = t[1];
		d1[3] = t[4];
		d1[4] = t[2];
		return d1;
	}
	static void disp(int[] d) {
		for(int i : d) {
			System.out.print(i + " ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 26404
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>

char t[3][4];

int main() {
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> t[i][j];
		}
	}
	for (int i = 0; i < 3; i++) {
		if (t[0][i] != t[1][2 - i]) {
			std::cout << "NO" << std::endl;
			return 0;
		}
	}
	std::cout << "YES" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define for_list(a) for(auto i:a)
#define f(s,a) for(int i=0;i<s;i++) cin>>a[i];

int count = 0;
void show(int a[201][201]){
    for (int i = 0; i < 201; ++i)
    {
        for (int j = 0; j < 201; ++j)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }

}
 
template<typename T>
vector<int> maxmin_list(T a){
    int l = INT_MIN,p = INT_MAX;
    for_list(a){
        l = max(l,i);
        p = min(i,p);
    }
    vector<int> v = {l,p};
    return v;
}
ll power(ll a,ll b){
    ll s;
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    if(b%2 == 0){
        s = power(a,b/2);
        return s*s;
    }
    else{
        s = power(a,(b-1)/2);
        return a*s*s;
    }
}
int randomize(){
    return (rand()%10000);
}
int b[100000];
int main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    // cout <<fixed;
    // cout << setprecision(2);
    int k;cin >> k;
    ll l[k];
    ll a[k];
    for (int i = 0; i < k; ++i)
    {
        cin >> a[i];
    }
    l[0] = 0;
    l[1] = abs(a[0] - a[1]);
    for (int i = 2; i < k; ++i)
    {
        l[i] = min(abs(a[i]-a[i-1])+l[i-1],abs(a[i]-a[i-2])+l[i-2]);
    }
    // for (int i = 0; i < k; ++i)
    // {
    //     cout << l[i] << " ";
    // }
    // cout << endl;
    cout << l[k-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll x[100010], l[100010];
pair<ll, ll> xl[100010];

int main() {
    cin >> n;
    rep(i, n) cin >> x[i] >> l[i];

    rep(i, n) {
        xl[i].first= x[i] + l[i];
        xl[i].second= x[i] - l[i];
    }
    sort(xl, xl+n);

    int ans = 0;
    ll t = -LLINF;
    rep(i, n) {
        if (t <= xl[i].second) {
            ans++;
            t = xl[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
//package com.zhangyong.algorithm;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        private FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        private FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }


    private void solve() {
        int n, m;
        n = in.nextInt();
        m = in.nextInt();
        int[] arr = new int[n+1];
        int l, r;
        for (int i = 0; i < m; i++) {
            l = in.nextInt();
            r = in.nextInt();
            arr[l] += 1;
            arr[r] += 1;
        }
        for (int i = 1; i <= n; i++) {
            out.println(arr[i]);
        }
    }

    private void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl '\n'
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 50;

vi a;
int b[N], sum[N];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	string s;
	int i, n, ans, cnt;
	cin >> s;
	n = s.length();
	cnt = 1;
	fo(i,1,n)
	{
		if(s[i] != s[i-1])
		{
			a.pb(cnt);
			cnt = 1;
		}
		else
			cnt++;
	}
	a.pb(cnt);
	if(sz(a) == 1)
	{
		ans = a[0];
	}
	else if(sz(a) == 2)
	{
		ans = max(a[0],a[1]);
	}
	else
	{
		fo(i,0,sz(a))
			b[i+1] = a[i];
		fo(i,1,sz(a)+1)
			sum[i] = sum[i-1] + b[i];
		ans = 0;
		fo(i,1,sz(a)+1)
			ans = max(ans, min(sum[i], sum[sz(a)]-sum[i-1]));
	}
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 1100
#include<iostream>

int main() {
    int h,w;
    std::string pic[105];
    std::cin >> h >> w;
    for (int i = 0; i < h; i++)
        std::cin >> pic[i];
    for (int i = 0; i < h; i++) {
        std::cout << pic[i] << "\n" << pic[i] << std::endl;
    }
    return 0;
}

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

typedef long long ll;

using namespace std;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int x;
    cin >> x;

    int  a = x / 500;
    int b = (x % 500) / 5;
    int ans = (a * 1000) + (b * 5);
    cout << ans << endl;


}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	priority_queue<int>q;    
	int m,n,t;
	cin >>n>>m;
	for(int i=0;i<n;i++){
		cin>>t;
		q.push(t); 
	} 
	long long sum=0;	
	while(m){
		t=q.top()/2;		
		q.pop();		
		q.push(t);		
		m--;
	}	
	while(!q.empty()){		
	    sum+=q.top();
		q.pop();
	}	
	cout<<sum;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

bool passed[50][50];
char field[50][50];


const int dy[]={-1,0,0,1,1,-1,1,-1};
const int dx[]={0,-1,1,0,1,-1,-1,1};
int w,h;

void dfs(int y,int x){
	if(passed[y][x])
		return;
	passed[y][x] = true;
	for(int i = 0; i < 8; i++){
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(ny >= 0 && nx >= 0 && ny < h && nx < w && !passed[ny][nx] && field[ny][nx] != '0'){
			dfs(ny,nx);
		}
	}
}

int main(){

	while(cin >> w >> h && !(w == 0 && h == 0)){
		for(int i = 0; i < h; i++){
			fill(passed[i],passed[i]+w,false);
			for(int j = 0; j < w; j++){
				cin >> field[i][j];
			}
		}
		int cnt = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(field[i][j] == '0' || passed[i][j]){
					continue;
				}
				else{
					cnt++;
					dfs(i,j);
				}
			}
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	R[] rs;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			rs=new R[n];
			for(int i=0; i<n; i++){
				int id=sc.nextInt();
				int h=sc.nextInt();
				int w=sc.nextInt();
				rs[i]=new R(id, h, w);
			}
			solve();
		}
	}

	void solve(){
		Arrays.sort(rs);
		println(""+rs[0].id);
	}

	class R implements Comparable<R>{
		int id;
		double error;

		R(int id, int h, int w){
			this.id=id;
			error=Math.abs(22-10000.*w/h/h);
		}

		@Override
		public int compareTo(R r){
			if(error+EPS<r.error){
				return -1;
			}else if(error>r.error+EPS){
				return 1;
			}else{
				return id-r.id;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <iostream>
#define ll long long
using namespace std;
ll lin() {ll x;scanf("%lld",&x);return x;}
int main(){
    ll n=lin(),m=lin();
  if(m>n*2)cout<<(m-2*n)/4+n<<endl;
  else cout<<m/2<<endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)
dp1 =[0 for _ in range(13)]
dp1[0]=1


move = [[] for _ in range(13)]

for i in range(10):
    for j in range(13):
        move[(10*j+i)%13].append(j)



for i in range(n):
    dp2 =[0 for _ in range(13)]
    if s[i]=="?":
        si = range(10)
        for mod,ex in enumerate(move):
            dp2[mod] += sum([dp1[x] for x in ex])
    else:
        si = int(s[i])
        for j in range(13):
            dp2[(10*j+si)%13]+=dp1[j]
    dp1 = [x%(10**9+7) for x in dp2] 


print(dp1[5])


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


int main(){
  int K;
  cin >> K;
  
  string S;
  cin >> S;

  if(S.length() <= K){
    cout << S;
  } else{ 
    cout << S.substr(0, K) << "...";
  }

  return 0;
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, con = 0;
	int H[MAX] = {};
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>H[i];
		bool flag = true;
		for(int j = 0; j < i; j++){
			if(H[i] < H[j]){
				// cout<<H[i]<<" "<<H[j]<<endl;
				flag = false;
			}
		}
		if(flag) con++;
		// cout<<i<<" "<<flag<<endl;
	}
	cout<<con<<endl;
	return 0;
}
 

Measured memory_bytes: 256
data class Item(val to: Int, val cost: Int)
fun main(args: Array<String>) {
    val N = nextInt()
    var G = Array(N) { mutableListOf<Item>() }
    for (n in 0 until N - 1) {
        var (u, v, w) = listOfInt(-1, -1, 0)
        w %= 2
        G[u].add(Item(v, w))
        G[v].add(Item(u, w))
    }
    val ans = Array(N) { -1 }
    ans[0] = 0
    val Q = Queue<Int>()
    Q.enqueue(0)
    while (!Q.isEmpty()) {
        val v = Q.dequeue()!!
        G[v].forEach {
            val u = it.to
            if (ans[u] == -1) {
                ans[u] = ans[v] xor it.cost
                Q.enqueue(u)
            }
        }
    }
    println(ans.joinToString("\n"))
}

class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(t: T) = elements.add(t)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
}

fun gcd(a: Long, b: Long): Long = if (b > 0) gcd(b, a % b) else a
fun lcm(a: Long, b: Long): Long = a * b / gcd(a, b)
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }



Measured memory_bytes: 81940
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, i;
	cin >> N >> i;
	cout << (N - i + 1);
}

Measured memory_bytes: 256