akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n, k, q;
    cin >> n >> k >> q;
    int win[100010] = {};

    rep(i, q) {
        int a;
        cin >> a;
        a--;
        win[a]++;
    }

    rep(i, n) {
        Yes(q - win[i] < k);
    }

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    vector<int> v(n);
	rep(i,n) v[i] = i;
    double ans = 0, div = 0;
	do{
		rep(i,n-1){
            ans += sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        }
        ++div;
	} while(next_permutation(v.begin(), v.end()));
    ans /= div;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 3788
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

c = [[False]*3 for i in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                c[j][k] = True

flag = False

for i in range(3):
    if all(c[i]) == True:
        flag = True
    elif all([x[i] for x in c]) == True:
        flag = True

if c[0][0] == c[1][1] == c[2][2] == True:
    flag = True
if c[0][2] == c[1][1] == c[2][0] == True:
    flag = True

if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int x;

int main(){
    vector<int> c;

    for(int i = 0; i < 3; i++){
        cin >> x;
        c.push_back(x);
    }

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

    if(c[0] + c[1] == c[2]){
        cout << "Yes";
    } else{
        cout << "No";
    }


}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,d,i;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b){
        d=a;
        a=b;
        b=d;
    }
    if(a<c){
        d=a;
        a=c;
        c=d;
    }
    if(b<c){
        d=b;
        b=c;
        c=d;
    }
    for(i=0; i<7; i++){
        scanf("%d",&d);
        if(a<d){
            c=b;
            b=a;
            a=d;
        }else if(b<d){
            c=b;
            b=d;
        }else if(c<d){
            c=d;
        }
    }
    printf("%d\n%d\n%d\n",a,b,c);
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) int((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int tc=1;
	fo(q, tc)
	{
		ll d, t, s;
		cin>>d>>t>>s;
		if(s*t >= d) on("Yes");
		else on("No");
	}
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

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

int n;
vector<int> v[31];
pair<int, string> ch[20];

int main()
{
	while (scanf("%d", &n), n){
		for (int i = 0; i <= 30; i++) v[i].clear();
		for (int i = 0; i < n; i++) ch[i].first = 0;
		for (int i = 0; i < n; i++){
			cin >> ch[i].second;
			int m;
			scanf("%d", &m);
			while (m--){
				int d;
				scanf("%d", &d);
				v[d].push_back(i);
			}
		}
		for (int i = 0; i <= 30; i++){
			for (int j = 0; j < v[i].size(); j++){
				ch[v[i][j]].first += n - v[i].size() + 1;
			}
		}
		sort(ch, ch + n);
		cout << ch[0].first << " " << ch[0].second << endl;
	}
}

Measured memory_bytes: 1276
#include<stdio.h>
#include<string>
using namespace std;
int n;
void dfs(string s,char high)
{
	if(s.size()==n)
		printf("%s\n",s.c_str());
	else
		for(char c='a';c<=high;++c)
			dfs(s+c,high>c?high:high+1);
}
int main()
{
	scanf("%d",&n);
	dfs("",'a');
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    vector<P> v(6);
    for(int i=0; i<6; ++i) {
        cin >> v[i].first >> v[i].second;
        if(v[i].first > v[i].second) {
            swap(v[i].first, v[i].second);
        }
    }
    sort(v.begin(), v.end());
    if(v[0] != v[1] || v[2] != v[3] || v[4] != v[5] || v[0].first != v[2].first || v[0].second != v[4].first || v[2].second != v[4].second) {
        cout << "no" << endl;
    } else {
        cout << "yes" << endl;
    }
}


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

using namespace std;
using ll = long long;


int main()
{
    vector<vector<int>> gr(3, vector<int>(3));
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) cin >> gr[i][j];
    }

    for(int i = 0; i < 3; i++){
        if(gr[i][1] - gr[i][2] == gr[0][1] - gr[0][2] && gr[i][0] - gr[i][1] == gr[0][0] - gr[0][1]) {
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		ArrayList<Integer> numList1 = new ArrayList<Integer>();
		ArrayList<Integer> numList2 = new ArrayList<Integer>();

		while (true) {
			String[] lines = sc.nextLine().split(" ");
			int num1 = Integer.parseInt(lines[0]);
			int num2 = Integer.parseInt(lines[1]);
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				numList1.add(num1);
				numList2.add(num2);
			}
		}
		for(int i = 0;i < numList1.size();i++) {
			if(numList1.get(i) > numList2.get(i)) {
				int x = numList1.get(i);
				numList1.set(i, numList2.get(i));
				numList2.set(i, x);
			}
			System.out.println(numList1.get(i) + " " + numList2.get(i));
		}
		sc.close();
	}
}

Measured memory_bytes: 36068
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
int main() {
	long long n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	vector<int> ans;
	ans.push_back(2);
	ans.push_back(4);
	ans.push_back(3);
	ans.push_back(9);
	for (int i = 8; i + 2 <= 30000 && ans.size() + 1 < n;i += 6) {
		ans.push_back(i);
		ans.push_back(i + 2);
	}
	for (int i = 15; i + 6 <= 30000 && ans.size() + 1 < n; i += 12) {
		ans.push_back(i);
		ans.push_back(i + 6);
	}
	for (int i = 6; i <= 30000 && ans.size() < n; i += 6) {
		ans.push_back(i);
	}
	assert(ans.size() == n);
	sort(ans.begin(), ans.end());
	cout << ans[0];
	for (int i = 1; i < ans.size(); ++i) {
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var minab = Min(a, b).ToString()[0];
        var maxab = Max(a, b);
        Console.WriteLine(new string(minab, maxab));
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].ToLong();
            var b = r[1].ToLong();
            long now = Gcd(a, b);
            long i = 2;
            long ans = 1;
            while (i * i <= now)
            {
                if (now % i == 0)
                {
                    ans += 1;
                    while (now % i == 0)
                    {
                        now /= i;
                    }
                    continue;
                }
                else
                {
                    i++;
                }
            }
            if (now != 1) ans++;
            WriteRead(ans);
        }

        public static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
  int N, K;
  double tmp = 0.0;
  double l;
  double m;
  int i, j;
  double cnt;
  cin >> N >> K;

  for (i=1;i<=N;i++){
    cnt = 0.0;
    j = i;
    while (j<K){
      j *= 2;
      cnt += 1.0;
    }
    if (cnt != 0){
      l = pow(2.0, cnt);
      m = 1.0/(N*l);
      tmp += m;
    }else {
      m = 1.0/N;
      tmp += m;
    }
  }

  cout << setprecision(12) << tmp << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
    return 0;
}

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

# define debug(x) cerr << #x << " = " << x << endl

using namespace std;

const int N = 500 + 77;
long long x , y , z , d , ans;
int main() {
   cin >> x >> y >> z;
   d = z - y;
   if(d % 2 == 0)
      return ! printf("%lld\n" , d / 2);
   long long tn = 0;
   long long yy = y , zz = z;
   zz -= yy;
   tn += yy;
   yy = 1;
   tn += (zz - yy) / 2;
   ans = tn;
   tn = 0;
   yy = y;
   zz = z;
   yy += (x - zz + 1);
   tn += (x - zz + 1);
   zz = x;
   tn += (zz - yy) / 2;
   ans = min(ans , tn);
   printf("%lld\n" , ans);

   return 0;
}


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

int main(void){
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0;i < n;i++){
    int p;
    cin >> p;
    a.push_back(p);
  }
  sort(a.begin(),a.end(),greater<int>());
  int count = 0;
  int ans = 0;
  for(int i = 0;i < n;i++){
    if(count % 2 == 0){
      ans += a[i];
      count++;
    }
    else{
      ans -= a[i];
      count++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int W,a,b;
cin >> W >> a >> b;
if (abs(b-a) <= W) cout << 0 << endl;
else {
    if (b > a) cout << b-(a+W) << endl;
    else cout << a-(b+W) << endl;
}


return 0;
}

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

int main(){
    string S, T;
    cin >> S >> T;
    int res = 0;
    rep(i, 3){
        if(S[i] == T[i]) res++;
    }
    cout << res << endl;
}

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

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

    vector<int> Ps(N);
    for (int i = 0; i < N; i++) cin >> Ps[i];

    vector<int> ans(N + 1, 0);
    for (int i = 0; i < N; i++) {
        ans[Ps[i]] = ans[Ps[i] - 1] + 1;
    }
    int a = 0;
    for (int i = 0; i < N + 1; i++) {
        a = max(a, ans[i]);
    }
    cout << N - a << endl;

    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    char c;
    int a[4];
    bool q[3]={0};
    rep(i,4)cin>>c,a[i]=c-'0';
    rep(i,8){
        int s=a[0];
        rep(i,3){
            s+=(q[i]*2-1)*a[i+1];
        }
        if(s==7) {
            cout<<a[0];
            rep(i,3){
                cout<<(q[i]?"+":"-")<<a[i+1];
            }
            cout<<"=7\n";
            exit(0);
        }
        red(i,3){
            if(q[i]==0){
                q[i]=1;
                break;
            }
            q[i]=0;
        }
    }

    return 0;
}


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

namespace STDquantum {

int n, ans;
inline void main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    for (int j = 1; i * j < n; ++j) { ++ans; }
  }
  printf("%d", ans);
}

}  // namespace STDquantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("D:\\OI\\STDquantum\\test.in", "r", stdin);
  freopen("D:\\OI\\STDquantum\\test.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif
#endif
  STDquantum::main();
  return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

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

    int n;  cin >> n;
    ll  S = 0;

    bool equal = 1;
    vector<int> vec;

    for(int i = 0 ; i < n ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;

        if (x != y) equal = 0;
        if (x == y) S += x;
        else    {
            if (x < y)  S += y;
            else        vec.pb(y);
        }
    }
    if (vec.size()) {
        vec.erase(min_element(all(vec)));
        S += accumulate(all(vec),0ll);
    }
    if (equal)  S = 0;
    
    cout << S << endl;
}

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

vector<double> v;

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		double a;
		scanf("%lf",&a);
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	double wanna=v[n-1]/2;
	double ans=v[0];
	//prijntf("%ll");
	for(int i=0;i<n-1;i++)
	{
		if(abs(ans-wanna)>abs(v[i]-wanna))ans=v[i];
	}
	printf("%.0lf %.0lf\n",v[n-1],ans);
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  ll n, a, b, ans = 0;
  //string s;
  cin >> n >> a >> b;
  //vector<int> v(n), c(n);
  //if(1) {}
  //
  //for(int i = 0; i < n; i++){}
  cout << a * (n / (a + b)) + min(n % (a + b), a) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int>x(n);
  int mn=1e6;
  int mx=0;
  for(int i=0;i<n;i++){
    cin>>x.at(i);
    mx=max(mx,x.at(i));
    mn=min(mn,x.at(i));
  }
  
  int ans=1e9;
  for(int i=mn;i<=mx;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      
      sum+=(x.at(j)-i)*(x.at(j)-i);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#%%
n, k = map(int, input().split())
reach = [[] for _ in range(n)]
mod = 10**9 + 7
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    reach[a].append(b)
    reach[b].append(a)

def kai(i, j, mod):
    tmp = 1
    for x in range(i, i-j, -1):
        tmp *= x
        tmp %= mod
    return tmp

def dfs(st, n, k, reach, mod):
    check = [0] * n
    stack = [st]
    ans = k
    check[st] = 1
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        alredy = 1
        yet = 0
        for i in tmp_list:
            if check[i] != 1:
                stack.append(i)
                check[i] = 1
                yet += 1
            else:
                alredy += 1
        t = kai(k-alredy, yet, mod)
        ans *= t
        ans %= mod
    return ans

ans = dfs(0, n, k, reach, mod)
print(ans)

Measured memory_bytes: 70816
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>


using namespace std;


int main(){
    long long int n, k;
    cin >> n >> k;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    vector<int> a;
    for(int i = 0; i < n - k + 1; i++){
        if(p[i] >= 0){
            a.push_back(p[i + k - 1]);
        }
        else if(p[i + k - 1] <= 0){
            a.push_back(abs(p[i]));
        }
        else{
            if(abs(p[i]) >= abs(p[i + k - 1])){
                a.push_back(abs(p[i]) + 2 * abs(p[i + k - 1]));
            }else{
                a.push_back(abs(p[i]) * 2 + abs(p[i + k - 1]));
            }
        }
    }
    cout << *min_element(a.begin(), a.end());
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
}

Measured memory_bytes: 9804
while True:

    h, w = map(int, input().split())
    sharp = "#"
    dot = "."

    if h == w == 0:
        break

    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print(sharp, end="")
            else:
                print(dot, end="")
        print()

    print()



Measured memory_bytes: 7004
#include <stdio.h>

int main(int argc, char *argv[]){
        int total_second,h,m,s;
        scanf("%d", &total_second);
        h = total_second / 60 / 60;
        m = (total_second / 60) % 60;
        s = total_second % 60;
        printf("%d:%d:%d\n", h, m, s);
        return 0;
}

Measured memory_bytes: 592
#include <cstdio>

struct Node { int parent, left, right; };

const int MAX = 25;
const int NIL = -1;

Node T[MAX];
int n;

void print_preorder(int u) {
  if (u == NIL) return;
  std::printf(" %d", u);
  print_preorder(T[u].left);
  print_preorder(T[u].right);
}

void print_inorder(int u) {
  if (u == NIL) return;
  print_inorder(T[u].left);
  std::printf(" %d", u);
  print_inorder(T[u].right);
}

void print_postorder(int u) {
  if (u == NIL) return;
  print_postorder(T[u].left);
  print_postorder(T[u].right);
  std::printf(" %d", u);
}

int main() {
  std::scanf("%d", &n);
  for (int i = 0; i < n; ++i) T[i].parent = NIL;

  for (int i = 0; i < n; ++i) {
    int u, l, r;
    std::scanf("%d %d %d", &u, &l, &r);
    T[u].left = l;
    T[u].right = r;
    if (l != NIL) T[l].parent = u;
    if (r != NIL) T[r].parent = u;
  }

  int root;
  for (root = 0; root < n && T[root].parent != NIL; ++root);
  std::printf("Preorder\n");
  print_preorder(root);
  std::printf("\nInorder\n");
  print_inorder(root);
  std::printf("\nPostorder\n");
  print_postorder(root);
  std::printf("\n");
  return 0;
}




Measured memory_bytes: 2708
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e=0,p=0,k=0;
	scanf("%d %d %d %d\n",&a,&b,&c,&d);
	k=a+b+c+d;
	printf("%d\n",k/60);
	printf("%d\n",k%60);
	return 0;
}

Measured memory_bytes: 1788
N = int(input())

def num(i):
 num = []
 n = i
 while n != 0:
  num.append(n % 10)
  n = n // 10
 return 3 in num

for i in range(1, N+1):
 if i % 3 == 0:
  print(" " + str(i), end="")
 elif num(i):
  print(" " + str(i), end="")
print("")

Measured memory_bytes: 7956
break_offs = set()
N, M = map(int, input().split())
for i in range(M):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    break_offs.add((a, b))

last_bridge = 0
count = 0
for a, b in sorted(list(break_offs), key=lambda x:x[1]):
    if last_bridge <= a:
        last_bridge = b
        count += 1

print(count)

Measured memory_bytes: 22952
#include<iostream>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        sum+=a;
    }
    int ans;
    ans=n-sum;
    if(ans>=0)
        cout<<ans;
    else
        cout<<-1;
    
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    // 整数A、B、Cがスペース区切りで与えられるので、それを受け取る
    int A = sc.nextInt(); // スペースまでを整数として読込
    int B = sc.nextInt();
    int C = sc.nextInt();

    // A、B、Cに5が2つ、7が1つ含まれてる場合のみ
    // A * B * C = 5 * 5 * 7になる
    int product = 5 * 5 * 7;

    // A * B * Cがproductと一致するか判定
    if(A * B * C == product) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 35560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 15 + 5;
#define ll long long
struct Node
{
    ll x , y;
    ll p;
}node[maxn];
ll minn[maxn];
int n ;
ll ans = 1e18;
void dfs (int step , int rest , ll sum)
{
    if (step == n + 1){
    //    cout << sum << endl;
        ans = min (ans , sum);
        return ;
    }
    // 不放
    dfs (step + 1 , rest , sum);
    if (rest == 0) return ;
    // 横着放 - 更新minn数组
    ll all = 0 , o[16];
    for (int i = 1 ; i <= n ; i++){
        o[i] = minn[i];
        minn[i] = min (minn[i] , abs(node[step].y - node[i].y) * node[i].p);
        all += minn[i];
    }
    dfs (step + 1 , rest - 1 , all);
    // 竖着放
    all = 0;
    for (int i = 1 ; i <= n ; i++){
        minn[i] = o[i];
        minn[i] = min (minn[i] , abs(node[step].x - node[i].x) * node[i].p);
        all += minn[i];
    }
    dfs(step + 1 , rest - 1 , all);
    for (int i = 1 ; i <= n ; i++) minn[i] = o[i];
    return ;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    memset( minn , 0x3f , sizeof minn);
    ll sum = 0;
    for (int i = 1 ; i <= n ; i++){
        cin >> node[i].x >> node[i].y >> node[i].p;
        minn[i] = min(abs(node[i].x) , abs(node[i].y)) * node[i].p;
        sum += minn[i];
    }
    for (int i = 0 ; i <= n ; i++){
        ans = 1e18;
        dfs(1 , i , sum);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3668
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

MIN = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    MIN = min(MIN, a[x-1] + b[y-1] - c)
print(MIN)

Measured memory_bytes: 18616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str;
		if((str=br.readLine())!=null){
			String[] sp = str.split(" ");

			double tubo = 3.305785;
			double a = Double.parseDouble(sp[0]);
			double b = Double.parseDouble(sp[1]);

			System.out.println(a * b / tubo);


		}
	}
}

Measured memory_bytes: 24304
import fractions

A, B, C, D = map(int, input().split())

lcm = int((C * D) // fractions.gcd(C, D))

print(B - A + 1 - (B// C - (A-1)// C) - (B// D - (A-1)// D) + (B // lcm - (A-1) // lcm))

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

using namespace std;
typedef long long ll;

ll N;
ll a,b,c;

int main() {
    string s;
    cin >> s;
    int ct=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o') ct++;
    }
    cout << (15-s.size()+ct>=8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<char,int> P;
typedef pair<int,int> P1;

int main(){
  
  int n, l;
  char d;
  
  cin>>n;

  vector<P> x;
  
  priority_queue<P1,vector<P1>,greater<P1> > q;
  
  for(int i=0;i<n;i++){
    
    cin>>d>>l;
    
    if(!i){
      x.push_back(P(d,l));
      continue;
    }
    
    if(d==x[x.size()-1].first){
      
      if(x[x.size()-1].first=='y')
	x[x.size()-1].second=min(x[x.size()-1].second,l);
      
      if(x[x.size()-1].first=='n')
	x[x.size()-1].second=max(x[x.size()-1].second,l);
      
    }else x.push_back(P(d,l));
    
  }
  
  for(int i=0;i<x.size();i++)
    if(x[i].first=='y') q.push(P1(x[i].second,i));

  vector<int> used(x.size(),0);
  
  int ans=0;
  
  while(!q.empty()){
    
    P1 t=q.top(); q.pop();
    
    int cost=t.first, node=t.second;
    
    if(used[node])continue;
    used[node]=1;
    
    ans++;
    
    for(int i=node-1;i>=0;i--){
      if(x[i].first=='n'&&cost<=x[i].second)break;
      used[i]=1;
    }
    
    for(int i=node+1;i<x.size();i++){
      if(x[i].first=='n'&&cost<=x[i].second)break;
      used[i]=1;
    }
    
  }

  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

int main(){
	int N=0;
	long long count=0;
	cin >> N;
	
	int* A = new int[N];
	long long S;
	map<long long, long long> C;
	
	for(int i=0;i < N;i++){
		cin >> A[i];
		S += A[i];
		C[S]++;
	}

	for(auto i : C) count += (i.second) * (i.second - 1) / 2; 
	count += C[0];
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 13568
/**
 *  author: said_v15
 *  created with web_programmer
**/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A , B , T ;
    cin >> A >> B >> T ;
int times = T / A ;
int ans =times * B ;
cout<<ans<<endl ;
return 0;

}

Measured memory_bytes: 256
N=int(input())
x=list(map(int,input().split()))
M=int(input())
a=list(map(int,input().split()))
F=True    
for i in a:
    for j in range(N):
        #print(x[i-1])
        if x[i-1]+1 == x[j] or x[i-1] ==2019:
            F=False
            break
    if F==True:
        x[i-1]+=1
    F=True
for i in range(N):
    print(x[i])



Measured memory_bytes: 5608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int m = A + B;
        if(m < (A - B)){
            m = A - B;
        }
        if(m < (A * B)){
            m = A * B;
        }
        System.out.println(m);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);

int X;
  cin>>X;
  int ans=1;
  int a;
vector<int> vec(1000);
  int k=0;
    for(int i=1;i<32;i++){
      for(int j=2;j<32;j++){
        ans=pow(i,j);
        
        //cout<<ans<<endl;
        if(ans<=X&&ans>0){vec[k]=ans;k++;}
      
    }
  }

  vsort(vec);
  vreverse(vec);
  
  cout<<vec[0]<<endl;
}




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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);   
    ll ans=inf;
    int n,m; cin>>n>>m;
    if (n>=3){
        if (n%3) ans=min(ans,1ll*m); else ans=0;
    }
    if (m>=3){
        if (m%3) ans=min(ans,1ll*n); else ans=0;
    }
    for (int i=1;i<=n-1;i++){
        ll a=1ll*i*m;
        ll b=1ll*(m/2)*(n-i);
        ll c=1ll*(m-m/2)*(n-i);
        ans=min(ans,max({a,b,c})-min({a,b,c}));
    }
    for (int i=1;i<=m-1;i++){
        ll a=1ll*i*n;
        ll b=1ll*(n/2)*(m-i);
        ll c=1ll*(n-n/2)*(m-i);
        ans=min(ans,max({a,b,c})-min({a,b,c}));
    }
    cout<<ans<<"\n";
   
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	map<pii, int>mp;
	vector<int>X(n), Y(n);
	for(int i = 0; i < n; i++)
		cin >> X[i] >> Y[i];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i != j)
			{
				int a = X[i] - X[j];
				int b = Y[i] - Y[j];
				mp[pii(a, b)]++;
			}
		}
	}
	int mx = 0;
	for(auto aa : mp)
		mx = max(mx, aa.y);
	cout << n - mx << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;


const int N = 1e5;

char s[N + 1];

int main()
{
    //freopen("input.txt", "r", stdin);


    int n, k;
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    int bl = 1;
    for (int i = 1; i < n; ++i)
        bl += (s[i] != s[i - 1]);

    int ans = n - max(1, bl - 2 * k);
    printf("%d", ans);
}


Measured memory_bytes: 384
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tempmin = 10**5
ans = 0

for i,h in enumerate(h,1):
    temp = abs(a-(t-h*0.006))
    if tempmin > temp:
        ans = i
        tempmin = temp

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> height(n+3,0);
    rep(i,n)cin >> height[i];
    vector<ll> dp(n+3,INF);
    dp[0] = 0;
    rep(i,n){
        for(ll j = 1;j <=k;j++){
            if(i+j >= n)break;
            dp[i+j] = min(dp[i+j],dp[i] + abs(height[i] - height[i+j]));
        }
    }
    std::cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>




const int N = 60;
int n, m, q, a[N], b[N], c[N], d[N], res, crr;
vector<int>v;


int scr()
{
	int ret = 0;
	for(int i = 1; i <= q; i++)
	{
		if(v[b[i]] - v[a[i]] == c[i])ret += d[i];
	}
	return ret;
}






void solve()
{
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}
	res = 0;
	for(int i = 0; i < (1 << (n + m - 1)); i++)
	{
		v.clear();
		crr = 1;
		for(int j = 1; j < (1 << (n + m - 1)); j <<= 1)
		{
			if(i&j)
			{
				v.pb(crr);
			}
			else
			{
				crr++;
			}
		}
		if(v.size() == n)
		{
			res = max(res, scr());
		}
	}
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n , a[N] , b[N] , w;
long long dp[200][N] , INF = -2e12 - 1 ,ans = 0;
int main(){
    scanf("%d%d", &n , &w);
    for(int i = 1 ; i <= n ; i++){
        scanf("%d%d", &a[i] , &b[i]);
    }
    for(int i = 0 ; i < n ; i++)
        for(int j = 1 ; j <= w ; j++)
            dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i = 1; i <= n ; i++){
        for(int j = 0 ; j <= w ; j++){
            if(i > 0)
            dp[i][j] = dp[i - 1][j];
            if(a[i] <= j && i)
            dp[i][j] = max(dp[i][j] , dp[i - 1][j - a[i]] + b[i]);
            ans = max(dp[i][j] , ans);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>
#include <string.h>
int main()
{   int i,chk[27]={0},flag=0;
    char s[27];
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
        if(chk[s[i]-'a']==0){
            chk[s[i]-'a']=1;
        }else{
            flag=1;
            break;
        }
    }
    if(flag==0){
        printf("yes");
    }else printf("no");
    
    

    return 0;
}


Measured memory_bytes: 128
<?php
[$N] = ints();
$str = '';
for($i = 0; $i < $N; $i++){
  [$a, $b] = ints();
  $str.= $a==$b ? "*" : ".";
}
echo strpos($str, "***") === false ? "No" : "Yes";

function str(){return trim(fgets(STDIN));}
function ints($n = false){
  if($n===false){
    return array_map('intval',explode(' ',trim(fgets(STDIN))));
  }else{$ret = [];for($i = 0; $i < $n; $i++)foreach(array_map('intval',explode(' ',trim(fgets(STDIN)))) as $j => $v)$ret[$j][] = $v;return $ret;}
}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array\n";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      if($both == 0){
        $G[$a][] = $b;
      }elseif($both == 1){
        $G[$a][] = $b;
        $G[$b][] = $a;
      }else{
        $G[$b][] = $a;
      }
    }else{
      list($a, $b, $d) = $values;
      if($both == 0){
        $G[$a][] = [$b, $d];
      }elseif($both == 1){
        $G[$a][] = [$b, $d];
        $G[$b][] = [$a, $d];
      }else{
        $G[$b][] = [$a, $d];
      }
    }
  }
  return $G;
}

Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n, ct = 0, cx = 0, cy = 0; cin >> n;
    rep(i, n){
        ll t, x, y; cin >> t >> x >> y;
        if((abs(x-cx)+abs(y-cy)) <= (t-ct) && ((abs(x-cx)+abs(y-cy)) - (t-ct)) % 2 == 0){
            ct = t, cx = x, cy = y;
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

#define ll long long

using namespace std;

const int max_n = 100'000;
vector<int> G[max_n];

vector< pair<ll, ll> > A(max_n);

const ll mod = 1'000'000'000 + 7;

void DFS(int v, int p) {
    ll b = 1, w = 1;
    for(auto & c : G[v])
        if(c != p) {
            DFS(c, v);
            b = (b * A[c].first) % mod;
            w = (w * (A[c].first + A[c].second)) % mod;
        }
    A[v] = {w, b};
}

int main() {
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    DFS(0, -1);
    cout << (A[0].first + A[0].second) % mod << "\n";

    return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
void solve(int test) {
    int x;
    cin >> x;
    int ans;
    if (x < 600)
        ans = 8;
    else if (x < 800)
        ans = 7;
    else if (x < 1000)
        ans = 6;
    else if (x < 1200)
        ans = 5;
    else if (x < 1400)
        ans = 4;
    else if (x < 1600)
        ans = 3;
    else if (x < 1800)
        ans = 2;
    else if (x < 2000)
        ans = 1;
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
        cout << "\n";
    }
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; cin >> n;
    vs S(n); REP(i, n) cin >> S[i];

    vi count(26, INF);
    REP(i, n)
    {
        vi tmp(26, 0);
        REP(j, (int)S[i].length()) tmp[S[i][j]-'a']++;
        REP(j, 26) chmin(count[j], tmp[j]);
    }

    REP(i, 26)
    {
        while(count[i] > 0)
        {
            cout << (char)('a'+i);
            count[i]--;
        }
    }
    cout << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>

int gx, gy, h, w;
int cost[20][20];
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

void solve(int x,int y, int field[20][20]){
	static int count = 0;
	int i, j, flag;
	if(cost[y][x] > count || cost[y][x] == -1){
		cost[y][x] = count;
		if(field[y][x] == 3)
			return;
	}
	if(count < 10){
		for(i = 0;i < 4;i++){
			flag = 0;
			for(j = 1;x + dx[i] * j >= 0 && x + dx[i] * j < w && y + dy[i] * j >= 0 && y + dy[i] * j < h;j++){
				if(field[y + dy[i] * j][x + dx[i] * j]){
					flag = 1;
					break;
				}
			}
			if(flag && field[y + dy[i] * j][x + dx[i] * j] == 3){
				count++;
				solve(x + dx[i] * j,y + dy[i] * j,field);
				count--;
			}
			else if(j != 1 && flag){
				field[y + dy[i] * j][x + dx[i] * j] = 0;
				count++;
				solve(x + dx[i] * (j - 1),y + dy[i] * (j - 1),field);
				field[y + dy[i] * j][x + dx[i] * j] = 1;
				count--;
			}
		}	
	}
}


int main(void){
	int i, j, field[20][20], sx, sy;
	while(1){
		scanf("%d%d",&w,&h);
		if(w == 0 && h == 0)
			break;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++)
				scanf("%d",&field[i][j]);
		}
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(field[i][j] == 2){
					sy = i, sx = j;
					field[i][j] = 0;
				}
				else if(field[i][j] == 3)
					gy = i, gx = j;
			}
		}
		memset(cost,-1,sizeof(cost));
		solve(sx,sy,field);
		printf("%d\n",cost[gy][gx]);
	}
	return 0;
}

Measured memory_bytes: 1028