akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    int slen = s.length();
    bool flg = true;
    for(int i = 0; i < slen; ++i) {
        if(i % 2 == 0) {
            if(s.at(i) == 'L') {
                flg = false;
                break;
            }
        }else {
            if(s.at(i) == 'R') {
                flg = false;
                break;
            }
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef long long i64;

struct BIT {

	vector<int> data;
	int size;

	void init(int n)
	{
		size = n;
		data.resize(size + 1);
		fill(data.begin(), data.end(), 0);
	}

	void add(int pos, int x)
	{
		pos += 1;
		while(pos < size + 1) {
			data[pos] += x;
			pos += pos & -pos;
		}
	}

	int sum(int pos)
	{
		pos += 1;
		int s = 0;
		while(pos > 0) {
			s += data[pos];
			pos -= pos & -pos;
		}
		return s;
	}
};

const i64 mod = 998244353;

int main()
{
	int n;
	vector<pair<int, int>> ps;
	vector<int> xs, ys;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ps.push_back({x, y});
		xs.push_back(x);
		ys.push_back(y);
	}

	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	for(int i = 0; i < n; i++) {
		int ox = ps[i].first, oy = ps[i].second;
		int x = lower_bound(xs.begin(), xs.end(), ox) - xs.begin();
		int y = lower_bound(ys.begin(), ys.end(), oy) - ys.begin();
		ps[i] = {x, y};
	}

	i64 ans = 0;
	BIT bit;

	sort(ps.begin(), ps.end());
	bit.init(n);

	vector<i64> modpow2(n + 1, 0);

	modpow2[0] = 1;
	for(int i = 1; i < n + 1; i++) {
		modpow2[i] = modpow2[i - 1] * 2;
		if(modpow2[i] >= mod) {
			modpow2[i] -= mod;
		}
	}

	for(int i = 0; i < n; i++) {

		int x = ps[i].first;
		int y = ps[i].second;

		int xl = x, xr = n - 1 - x;
		int yl = y, yr = n - 1 - y;
		int xlyl = bit.sum(y);
		int xlyr = i - xlyl;
		int xryl = yl - xlyl;
		int xryr = yr - xlyr;

		assert(xlyl + xlyr == xl);
		assert(xryl + xryr == xr);

		bit.add(y, 1);

		i64 a = 0;

		a += modpow2[n] - 1;
		a -= modpow2[xl] - 1;
		a -= modpow2[xr] - 1;
		a -= modpow2[yl] - 1;
		a -= modpow2[yr] - 1;
		a += modpow2[xlyl] - 1;
		a += modpow2[xlyr] - 1;
		a += modpow2[xryl] - 1;
		a += modpow2[xryr] - 1;

		ans += a;

		//printf("%d (%d,%d) -> %d + %d + %d + %d, %lld\n", i, x, y, xlyl, xlyr, xryl, xryr, a);
	}

	ans = (ans + 5 * n * mod) % mod;

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 6260
/**
 *   Author: Praveen Ojha
 *   Created: 27 March 2019
 *   Time: 00:34:34
**/
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long double ld;
typedef pair<int,int> pii;
int n,k,a[101];
bool dp[100005]; // dp[i] TRUE if First player wins with i stones left.
int32_t main(){__
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]>=0 && !dp[i-a[j]]){
				dp[i]=true;
			}
		}
	}
	cout<<(dp[k] ? "First\n":"Second\n");
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, X[1010], Y[1010];
vector<int> v;

int abso(int a)
{
    if(a > 0)return a;
    return -a;
}

signed main()
{
    cin >> N;
    int a = 0, b = 0, D = 0ll;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
        int x = X[i];
        int y = Y[i];
        int d = abso(x) + abso(y);
        if(d % 2){
            a++;
        }
        else{
            b++;
        }
        D = max(D, d);
    }
    if(a > 0 && b > 0){
        printf("-1\n");
        return 0;
    }
    int n = 1;
    v.pb(1ll);
    if(D % 2 == 0ll){
        v.pb(1ll);
    }
    while(n < D){
        n *= 2ll;
        v.pb(n);
    }
    int S = v.size();
    printf("%lld\n", S);
    for(int i = 0; i < S; i++){
        printf("%lld", v[i]);
        if(i < S - 1){
            printf(" ");
        }
    }
    printf("\n");
    reverse(v.begin(), v.end());
    for(int i = 0; i < N; i++){
        int x = X[i];
        int y = Y[i];
        string s;
        for(int j = 0; j < S; j++){
            int dx = abso(x);
            int dy = abso(y);
            char dir;
            //printf("%lld x:%lld y:%lld\n", i, x, y);
            if(dx >= dy){
                if(x > 0){
                    x -= v[j];
                    dir = 'R';
                }
                else {
                    x += v[j];
                    dir = 'L';
                }
            }
            else{
                if(y > 0){
                    y -= v[j];
                    dir = 'U';
                }
                else{
                    y += v[j];
                    dir = 'D';
                }
            }
            s += dir;
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}

/*


*/


Measured memory_bytes: 256
n, *abc = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]
A = 0; B = 1; C = 2;

minmp = 10 ** 9
for k in range(2 ** (2 * n)):
    mat = [[], [], [], []]  # mat[0]:= Aの材料, mat[1]:=Bの材料, mat[2]:=Cの材料
    # for i = 0, ..., N-1
    # kの 2*i & 2*i+1ビット目が 0b00: l[i]はAに使う
    #     ↑lsbから             0b01: l[i]はBに使う
    #                         0b10: l[i]はCに使う
    #                         0b11: l[i]は使わない
    for i in range(n):
        mat[(k >> 2 * i) & (0b11)].append(l[i])

    if len(mat[0]) == 0 or len(mat[1]) == 0 or len(mat[2]) == 0:
        continue
        
    mp = 0
    for j in range(3):
        mp += 10 * (len(mat[j]) - 1)
        mp += 1 * abs(abc[j] - sum(mat[j]))

    minmp = min(minmp, mp)

print(minmp)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

ll bpow(ll a , ll b){
  if (b == 0) return 1;
  ll ret;
  if (b%2 == 0){
    ll  t = bpow(a, b/2);
    ret = t*t;
  }else{
    ll t = bpow(a, (b-1)/2);
    ret = a*t*t;
  }
  return ret;
}

int main() {
  ll n = 100100;
  vector<bool> is_square(n+1,false);
  FOR(i, 1, n+1){
    if(i*i > n) break;
    is_square[i*i] = true;
  }

  ll a,b; cin >> a >> b;
  ll l = to_string(b).size();

  if(is_square[bpow(10,l)*a+b]) yes();
  else no();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace C_Grid_Repainting_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().ToIntArray();
            var H = inputs[0];
            var W = inputs[1];

            var datas = new List<string>();

            for(var i = 0; i<H; i++)
            {
                datas.Add(Console.ReadLine());
            }

            var before = string.Empty;
            var current = string.Empty;
            var next = string.Empty;
            var result = true;
            for(var r = 0; r < H; r++)
            {
                current = datas[r];
                if(r + 1 < H)
                    next = datas[r + 1];
                else
                    next = string.Empty;

                for(var c = 0; c < W; c++)
                {
                    if(current[c] == '#')
                    {
                        var ret = false;
                        if(!string.IsNullOrEmpty(before))
                        {
                            if(before[c] == '#')
                            {
                                ret = true;
                            }
                        }

                        if(!string.IsNullOrEmpty(next))
                        {
                            if(next[c] == '#')
                            {
                                ret = true;
                            }
                        }

                        if(c > 0)
                        {
                            if(current[c - 1] == '#')
                            {
                                ret = true;
                            }
                        }

                        if(c < W - 1)
                        {
                            if(current[c + 1] == '#')
                            {
                                ret = true;
                            }
                        }

                        if(!ret)
                        {
                            result = false;
                            break;
                        }
                    }
                }

                if(!result)
                {
                    break;
                }
                before = current;
                current = next;
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
    
    static class StringExtention
    {
        static public int ToInt(this string input)
        {
            return int.Parse(input);
        }

        static public int[] ToIntArray(this string input)
        {
            return input.Split(' ').Select(int.Parse).ToArray();
        }

        static public long ToLong(this string input)
        {
            return long.Parse(input);
        }

        static public long[] ToLongArray(this string input)
        {
            return input.Split(' ').Select(long.Parse).ToArray();
        }
    }
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int k,x;cin>>k>>x;
	
	if(500*k >=x){
		writeln("Yes");
	}else {
		writeln("No");
	}
	
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;


int main(void) {
    int n, x;
    cin >> n >> x;
    int *l = new int[n+1];
    int *j = new int[n+1];

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

    int k = 0;
    j[0] = 0;
    
    while(k < n) {
        j[k+1] = j[k] + l[k];
        // cout << "j[" << k+1 << "]=" << j[k+1] << endl;

        if(j[k+1] > x) {
            break;
        }

        ++k;
    }

    cout << k+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a[100050][3];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x][i%2]++;
	}
	int x=0,y=0,mx=0,my=0,idx=0,idy=0;
	for (int i=1;i<=1e5;i++){
		if (a[i][1]>=x) mx=x,x=a[i][1],idx=i;else 
		if (a[i][1]>mx) mx=a[i][1];
		if (a[i][0]>=y) my=y,y=a[i][0],idy=i;else 
		if (a[i][0]>my) my=a[i][0];
	}
	int ans=0;
	if (idx==idy) {
		if (mx+y>x+my) ans=n-mx-y;else ans=n-x-my;
	}else ans=n-x-y;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1280
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = N / 1.08;

            var B1 = (int)Math.Floor(A);
            var B2 = (int)Math.Ceiling(A);
            var C1 = (B1 * 108) / 100;
            var C2 = (B2 * 108) / 100;

            if (C1 == N)
            {
                Console.WriteLine(B1);
            }
            else if (C2 == N)
            {
                Console.WriteLine(B2);
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}

Measured memory_bytes: 13140
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"

using namespace std;

#define f(i,n) for(int i=0; i<n;i++) 
#define rf(i, n) for(int i=n-1;i>=0;i--)
#define forn(i, j, n) for(int i=j; i<n; i++)
#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) (x) * (x)
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

const int sze = 3e5 + 50, INF = 1e18 + 500, mod = 998244353;
const double eps = 5e-10, PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi vertices[sze];
vc visit(sze, false);
vi arr(sze, 0);
int n, m, k, t;
int d = 0;
int cnt = 0;
string s;
vi col(sze, 0);
vi sum(sze, INF);
int x, y;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	
	int a, b;
	cin >> a >> b >> k;

	int f = true;
	while (k)
	{
		if (f)
		{
			b += a / 2;
			a /= 2;
		}
		else
		{
			a += b / 2;
			b /= 2;
		}

		f = !f;
		k--;
	}

	cout << a << " " << b;
	return 0;
}



Measured memory_bytes: 14592
N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if i == 'c':
    print('No')
  elif i =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif i =='b' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')

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

int main(void){
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    for (int i = k; i < n; i++){
        if (a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

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

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

  int n;
  cin >> n;

  vector<int> b(n-1);
  for (int i = 0; i < n-1; ++i) cin >> b[i];

  int ans = b[0];
  for (int i = 0; i < n-2; ++i) ans += min(b[i], b[i+1]);

  cout << ans + b[n-2] << endl;

  return (0);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
class UnionFind {
public:
    vector <int> par; 
    vector <int> siz; 

    UnionFind(int sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
 
    int root(int x) { 
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
 
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
 
    bool issame(int x, int y) { 
        return root(x) == root(y);
    }
 
    int size(int x) { 
        return siz[root(x)];
    }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M; cin >> N >> M;
  UnionFind uf(N);
  REP(i,M){
    int a, b; cin >> a >> b;
    a--; b--;
    uf.merge(a, b);
  }

  set<int> st;
  for(int i=0; i<N; i++){
    st.insert(uf.root(i));
  }

  int ans = 0;
  for(auto e: st){
    ans = max(ans, uf.size(e));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14184
N,*as = `dd`.split.map &:to_i

op = []
(1..N).reverse_each{ |i|
  (1..i).reverse_each{ |j|
    if as[j-1] == j
      op << j
      as.delete_at(j-1)
      break
    end
  }
}

puts op.size == N ? op.reverse : -1

Measured memory_bytes: 2044
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABCD = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var left = ABCD[0] + ABCD[1];
            var right = ABCD[2] + ABCD[3];
            var answer = "Balanced";
            if (left > right) answer = "Left";
            if (right > left) answer = "Right";
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28292
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>

 using namespace std;

int main(){
vector<int>a,b;
int c,d,n;
cin >> n;
for(int i=0;i<n;i++){
	cin >>c >>d;
	a.push_back(c);
	b.push_back(d);

}

int k = int((n-1)/2);

stable_sort(a.begin(),a.end());
stable_sort(b.begin(),b.end());
if(n%2==1)cout << b[k]-a[k]+1 << endl;

else  cout << (b[k+1]+b[k]-a[k]-a[k+1])+1 << endl;

return 0;
}


Measured memory_bytes: 5368
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int[] ans = new int[N+1];
    
    for(int x = 1; x <= 100; x++){
      for(int y = 1; y <= 100; y++){
        for(int z = 1; z <= 100; z++){
          int num = x*x + y*y + z*z + x*y + y*z + z*x;
          if(num <= N) ans[num]++;
        }
      }
    }
    for(int i = 1; i<=N; i++){
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 39072
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

using Graph = vector<vector<int>>;
Graph Gin,Gout;
signed main()
{
    int n, m;
    cin >> n >> m;
    Gin.assign(n, vector<int>());
    Gout.assign(n, vector<int>());
    for (int i = 0; i < n + m - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        Gin[x].push_back(y);
        Gout[y].push_back(x);
    }
    vector<int> ans(n);
    int root;
    for (int i = 0; i < n; i++)
    {
        if(Gout[i].size()==0){
            root = i;
            ans[i] = 0;
            break;
        }
    }
    vector<int> used(n, false);
    queue<int> q;
    q.push(root);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        used[v] = true;
        for (auto &u : Gin[v])
        {
            bool ok = true;
            for (auto &t : Gout[u])
            {
                if(!used[t]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                q.push(u);
                ans[u] = v+1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef int ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e5+100;
const ll inf = 1e9;
const ll mod = 1e9+7;



int main(){
	fastio;
	ll a,b,n;
	cin >>n;
	f(i,1,10){
		f(j,1,10){
			if(i*j == n){
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 3588
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n;
	cin >> n;

	for (int i = 1; i <= 50000; ++i)
	{
		int t = (i * 1.08);
		if(t == n)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << ":(" << endl;


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[] ){
		try{
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a*b + " " + (a+b)*2 );
		}catch(NumberFormatException e){
			System.out.println("??´??°???????????????");
		}
	}

}

Measured memory_bytes: 26084
#include<cstdio>
#include<algorithm>
using namespace std;
int tate[1405][1405]={};
int yoko[1405][1405]={};
int dp[1405][1405]={};
int c[1405][1405];
int main(){
  int h,w;
  scanf("%d %d",&h,&w);
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++) scanf("%d",&c[i][j]);
  }
  int ans = 0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(c[i][j] == 0){
	tate[i][j] = tate[i-1][j]+1;
	yoko[i][j] = yoko[i][j-1]+1;
	dp[i][j] = min(tate[i][j],yoko[i][j]);
	dp[i][j] = min(dp[i][j],dp[i-1][j-1]+1);
      }
      ans = max(ans,dp[i][j]*dp[i][j]);
    }
  }
  printf("%d\n",ans);
  return(0);
}



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

int main(){
    int T[101][101], r, c;
    
    cin >> r >> c;
    for ( int i = 0; i < r; i++ )
        for ( int j = 0; j < c; j++ ) cin >> T[i][j];
        
    for ( int i = 0; i <= r; i++ ) T[i][c] = 0;
    for ( int j = 0; j <= c; j++ ) T[r][j] = 0;
    
    for ( int i = 0; i < r; i++ ){
        for ( int j = 0; j < c; j++ ){
            T[i][c] += T[i][j];
            T[r][j] += T[i][j];
            T[r][c] += T[i][j];
        }
    }
    
    for ( int i = 0; i <= r; i++ ){
        for ( int j = 0; j <= c; j++ ){
            if ( j ) cout << " ";
            cout << T[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
Input = input()
li = Input.split(" ")
NT = list(map(int,li))
N = NT[0]
T = NT[1]
i = 1
mi = 9999

while i <= N:
    Input = input()
    li = Input.split(" ")
    a = list(map(int,li))
    c = a[0]
    t = a[1]
    if t <= T and c < mi:
        mi = c
    i += 1

if mi == 9999:
    print("TLE")
else:
    print(mi)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		
		System.out.println("NG");
	}
	
}


Measured memory_bytes: 26996
N = gets.to_i
as = []
N.times do |i|
    as[i] = [i, gets.to_i]
end
as.sort_by!{|arr| arr[1]}
ans = 0
N.times do |i|
    ans += 1 if (i - as[i][0]) % 2 == 1
end

puts ans/2

Measured memory_bytes: 12408
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000005
#define M 100000000
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
lli arr[S],n;
lli dp[S],prime[S];

bool fac(lli num)
{
    for(lli i=2;i*i<=num;i++)
    {
        if(num%i==0)
        {
            while(num%i==0)
            {
                num=num/i;
            }

            if(dp[i]==1)
            {
                return 0;
            }
            dp[i]=1;
        }
    }

    if(num>1)
    {
            if(dp[num]==1)
            {
                return 0;
            }
            dp[num]=1;        
    }

    return 1;
}
void solve()
{
    cin>>n;

    for(lli i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    lli g=arr[1];
    bool f=0;
    for(lli i=1;i<=n;i++)
    {
        g=__gcd(g,arr[i]);
        // print(arr[i])

        bool res=fac(arr[i]);
        if(res==0)
        {
            f=1;
        }

    }
    // print(g)
    if(f==0)
    {
        cout<<"pairwise coprime";
        return ;
    }
    else if(g==1)
    {
        cout<<"setwise coprime";
        return ;
    }
    else
    {
       cout<<"not coprime";
    }








}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 19244
#include<stdio.h>
  
int main(void)
{
    while (1) {
        char str_num[1001];
  
        scanf("%s", str_num);
  
        if (str_num[0] == '0') break;
  
        int i = 0;
        int sum = 0;
  
        do {
            sum += (str_num[i] - '0');
            i++;
        } while (str_num[i] != '\0');
  
        printf("%d\n", sum);
    }
  
    return 0;
}


Measured memory_bytes: 2140
S = input()

ans = 0
def dfs(now, i):
    if i == len(S):
        global ans
        ans += eval(now)
        return
    dfs(now+"+"+S[i], i+1)
    dfs(now+S[i], i+1)
    
dfs(S[0],1)
print(ans)

Measured memory_bytes: 66940
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;

char s[55][55];

int main()
{
	int h, w;
	cin >> h >> w;
	for(int i = 0; i <= h + 1; i++)
	{
		for(int j = 0; j <= w + 1; j++)
		{
			if(i == 0 || i == h + 1 || j == 0 || j == w + 1)
				s[i][j] = '.';
			else scanf(" %c", &s[i][j]);
		}
	}
	int f = 0;
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			if(s[i][j] == '#')
			{
				if(s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.')
				{
					f = 1;
					break;
				}
			}
		}
	}
	if(f) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int a; cin >> a;
	cout << 3 * a * a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;

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

	int t = 1;
	// cin >> t;

	while (t--) {
		string s;
      	cin >> s;
      	int ans = 0;
      	for (auto x : s) ans += (x - '0');
      	cout << (ans % 9 == 0 ? "Yes" : "No") << endl;	
    }
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 2e5 + 7;
int n, now, m;
char s[N];
int a[N];
LL ans;
int main() {
#ifdef fwat
#endif
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int i = 1;
	while(i <= n) {
		if(s[i] == 'A') a[++m] = 0, i++;
		else if(s[i] == 'B' && s[i + 1] == 'C') a[++m] = 1, i += 2;
		else a[++m] = 2, i++;
	}
	for(int i = m; i; --i) {
		if(a[i] == 1) ++now;
		else if(a[i] == 0) ans += now;
		else now = 0;	
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long int
int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(ll i=1;i<n;i++){
        if(a[i]<a[i-1]){ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
            
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5152
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n;
	cin >> n;

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

	priority_queue<P, vector<P>, greater<P>> q;
	for (int i = 0; i < n; i++) {
		if (i == 0 || i == n - 1 || a[i - 1] == 0 || a[i + 1] == 0) {
			q.push(P(a[i], i));
		}
	}

	while (q.size()) {
		int t = q.top().second;
		q.pop();
		int p;
		if (t == 0) {
			p = 1;
		}else
		if (t == n - 1) {
			p = n - 2;
		}else{
			if (a[t - 1] == 0) {
				p = t + 1;
			}
			else {
				p = t - 1;
			}
		}
		int m = a[t] / 2;
		a[t] %= 2;

		int tm = min(a[p], a[t]);
		a[p] -= tm;
		a[t] -= tm;

		m += tm;
		if (m) {
			ans += m;
			q.push(P(a[p], p));
		}
	}

	rep(i, n) {
		ans += a[i] / 2;
		a[i] %= 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>

int main(void)
{
    int i, j, H, W;
    
    while (1) {
        scanf("%d %d", &H, &W);
        
        if ( H == 0 && W == 0)
            break;
        for ( i=0; i<H; ++i){
            for ( j=0; j<W; ++j)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    
    return 0;
}


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


int main(){


    int n, x, i, l, t;

    int a = 0;

    vector<int> d(101);


    cin >> n >> x;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> l;

         d.at(i + 1) = d.at(i) + l;

         }



    for( i = 0 ; i <= n ; i = i + 1 ){

         if( d.at(i) <= x ) a += 1;

         }


    cout << a << endl;

    
    return 0;


    }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    int div4_num = 0;
    int div2_num = 0;
    int other_num = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if ( a % 4 == 0 ) {
            ++div4_num;
        }
        else if ( a % 2 == 0 ) {
            ++div2_num;
        }
        else {
            ++other_num;
        }
    }
    if ( div4_num >= other_num ) {
        cout << "Yes" << endl;
    }
    else if ( div4_num == other_num - 1 && div2_num == 0 ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    let s: String = read!(String);
    let k: usize = read!(usize);

    let c: Vec<char> = s.chars().collect();
    // ランレングス圧縮
    let mut runlen = Vec::new();
    let mut prev_c = c[0];
    let mut tmp = 0;
    for i in 0..c.len() {
        if prev_c == c[i] {
            tmp += 1;
            continue;
        } else {
            prev_c = c[i];
            runlen.push(tmp);
            tmp = 1;
        }
    }
    runlen.push(tmp);

    let mut ans = 0;
    // 先頭と末尾が同じ文字かどうかで場合分け
    if c.first().unwrap() != c.last().unwrap() {
        // 先頭と末尾が違う場合
        for r in runlen {
            if r == 1 {
                continue;
            } else {
                ans += r / 2;
            }
        }
        ans *= k;
    } else {
        // 先頭と末尾が同じ場合
        if runlen.len() > 1 {
            let r1 = &runlen[0];
            let r_middle = runlen.get(1..(runlen.len() - 1));
            let r2 = &runlen[runlen.len() - 1];

            match r_middle {
                Some(v) => {
                    for &r in v {
                        if r >= 2 {
                            ans += r / 2;
                        }
                    }
                    ans *= k;
                }
                None => (),
            }

            ans += *r1 / 2;
            ans += *r2 / 2;

            ans += (k - 1) * ((*r1 + *r2) / 2);
        } else {
            ans += (runlen[0] * k) / 2;
        }
    }
    println!("{}", ans);
}

fn b() {
    unimplemented!();
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    a();
}


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

int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
	int W, H;
	while (cin >> W >> H) {
		if (W == 0 && H == 0) return 0;
		vector<string> S(H);
		for (int i = 0; i < H; i++) cin >> S[i];
		int SX, SY;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (S[i][j] == '@') SX = i, SY = j;
			}
		}
		queue<pair<int, int> > Q;
		Q.push({ SX, SY });
		while (!Q.empty()) {
			pair<int, int> P = Q.front();
			Q.pop();
			for (int i = 0; i < 4; i++) {
				int NX = P.first + dx[i], NY = P.second + dy[i];
				if (0 <= NX && NX < H && 0 <= NY && NY < W) {
					if (S[NX][NY] == '.') {
						S[NX][NY] = '@';
						Q.push({ NX, NY });
					}
				}
			}
		}
		int ANS = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (S[i][j] == '@') ANS++;
			}
		}
		cout << ANS << endl;
	}
}


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#define DN 100005
#define x first
#define y second
using namespace std;
int n,f,g,viz[DN],nr,poz,p,p1,p2;
typedef pair<pair<int,int>,int> pii;
pii a[DN],b[DN];
long long rez,rez2;
void solve(pii a[DN],int &p,int type,long long &rez)
{
    while(viz[a[p].y])
        p++;
    viz[a[p].y]=1;
    if(poz>=a[p].x.x&&poz<=a[p].x.y)
        return;
    f=a[p].x.x;
    if(type==0)
        f=a[p].x.y;
    rez+=abs(f-poz);
    poz=f;
}
void rezolva(long long &rez)
{
    for(int i=1;i<=n;i++)
        viz[i]=0;
    poz=0;
    nr=n;
    p1=p2=1;
    while(nr--)
    {
       p=1-p;
       if(p==0)
        solve(b,p1,0,rez);
        else
            solve(a,p2,1,rez);
    }
    rez+=abs(poz);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x.x>>a[i].x.y;
        a[i].y=i;
        b[i]=a[i];
        swap(b[i].x.x,b[i].x.y);
        a[i].x.x=-a[i].x.x;
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)
    {
        a[i].x.x=-a[i].x.x;
        swap(b[i].x.x,b[i].x.y);
    }
    p=1;
    rezolva(rez);
    p=0;
    rezolva(rez2);
    cout<<max(rez2,rez);
}


Measured memory_bytes: 2944
/*
 * 2340.cc: Carpenters' Language
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll sum = 0;
  
  while (qn--) {
    int pi;
    char ci;
    ll ni;
    cin >> pi >> ci >> ni;
    if (ci == '(') sum += ni;
    else sum -= ni;
    cout << (sum == 0 ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    ll n, k;
    cin >> n >> k;
    cout << min(n - (n / k)*k, abs(n - (n / k)*k - k));
    return 0;
}


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


def cal1(a, b):
    return print(b - a)


def cal2(a, b):
    return print(abs(a - b) + 2)


def cal3(a, b):
    return print(abs(abs(a) - abs(b)) + 1)


if x > 0 and y > 0:
    if x > y:
        cal2(x, y)
    else:
        cal1(x, y)

elif x < 0 and y < 0:
    if x > y:
        cal2(x, y)
    else:
        cal1(x, y)

elif x == 0:
    if y > 0:
        cal1(x, y)
    else:
        cal3(x, y)

elif y == 0:
    if x > 0:
        cal3(x, y)
    else:
        cal1(x, y)

elif x > 0 and y < 0:
    if abs(x) > abs(y):
        cal3(x, y)
    elif abs(x) < abs(y):
        cal3(x, y)
    else:
        print(1)

else:
    if abs(x) > abs(y):
        cal3(x, y)
    elif abs(x) < abs(y):
        cal3(x, y)
    else:
        print(1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define repr(i,n) for (int i=(n-1); i>=0 ; --i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]] == c[i]) now+=d[i];

    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}
int main(){
  cin >> n >> m >> q;
  a = b = c = d = vector<int> (q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;

}


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

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 DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#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))

using namespace std;
int day(int y,int m,int d)
{
  //200,195,195 -> 590
  int y1[3]={0,200,395};
  int answer=0;
  answer+=y/3*590;
  answer+=y1[y%3];
  if(y%3) answer+=(m-1)*19+m/2;
  else answer+=(m-1)*20;
  answer+=d;
  return answer;
}

int main(void)
{
  int n;
  cin >> n;
  REP(i,n){
    int y,m,d;
    cin >> y >> m >> d;
    cout << day(1000,1,1)-day(y,m,d) << endl;
  }
  return 0;
}

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

int main(){
  int64_t N,K;
  cin>>N>>K;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  sort(H.begin(),H.end());
  int64_t Hsum=0;
  N=N-K;
  for(int i=0;i<N;i++){
    Hsum+=H.at(i);
  }
  cout<<Hsum<<endl;
}

Measured memory_bytes: 1024