akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int a = scan.nextInt();
      	int b = scan.nextInt();
      	int c = scan.nextInt();
      	int m = 100 * a + 10 * b + c;
      	if(m % 4 == 0){
        	System.out.print("YES");
        }
      	else{
        	System.out.print("NO");
        }
    }
	
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);




int main(){

	ll k;
	cin>>k;

	queue<string> qq;
	qq.push("1");
	qq.push("2");
	qq.push("3");
	qq.push("4");
	qq.push("5");
	qq.push("6");
	qq.push("7");
	qq.push("8");
	qq.push("9");
	if(k<=9) {cout<<k<<endl; return 0;}
	ll cnt=0;
	while(!qq.empty()){

		string tmp=qq.front();
		//dbg(tmp);
		qq.pop();
		cnt++;
		if(cnt==k){
			cout<<tmp<<endl;
			return 0;
		}

		int tmp2=tmp[sz(tmp)-1]-'0';
		fo(i,10){
			if(abs(tmp2-i)<2) {qq.push(tmp+(char('0'+i)));}
		}



	}


	
}

Measured memory_bytes: 13696
#include<stdio.h>

int main(void) {
    int S[13] = {}, H[13] = {}, C[13] = {}, D[13] = {};
    int s[13] = {}, h[13] = {}, c[13] = {}, d[13] = {};
    int cs = 0, ch = 0, cc = 0, cd = 0;
    char a, e;
    int b, n, i;

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%c", &e);
            
        scanf("%c %d", &a, &b);
        
        if(a == 'S') {
            S[b - 1] = b;
        }
        else if(a == 'H') {
            H[b - 1] = b;
        }
        else if(a == 'C') {
            C[b - 1] = b;
        }
        else if(a == 'D') {
            D[b - 1] = b;
        }
    }

    for(i = 0; i < 13; i++) {
        if(S[i] != i + 1) {
            s[cs] = i + 1;
            cs++;
        }
        if(H[i] != i + 1) {
            h[ch] = i + 1;
            ch++;
        }
        if(C[i] != i + 1) {
            c[cc] = i + 1;
            cc++;
        }
        if(D[i] != i + 1) {
            d[cd] = i + 1;
            cd++;
        }
    }

    for(i = 0; i < cs; i++) {
        printf("S %d\n", s[i]);
    }
    for(i = 0; i < ch; i++) {
        printf("H %d\n", h[i]);
    }
    for(i = 0; i < cc; i++) {
        printf("C %d\n", c[i]);
    }
    for(i = 0; i < cd; i++) {
        printf("D %d\n", d[i]);
    }

    return 0;

}



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

using namespace std;

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  
  if(a + b < c && 4ll * a * b < (c - a - b) * (c - a - b)){
    puts("Yes");
  }else puts("No");
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int D = sc.nextInt();
		int N = sc.nextInt();

		if(N==100)
			N +=1;
		
		if(D==0)
			System.out.println(N);
		else if(D==1)
			System.out.println(100*N);
		else 
			System.out.println(10000*N);
	}

}

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

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int N,K;
int h[100010];

int main() {
  int i;

  cin >> N >> K;
  REP(i,N) scanf("%d", &h[i]);

  sort(h, h + N);
  reverse(h, h + N);
  int mn = (1<<30);
  for (i = 0; i < N - K + 1; i++) {
    mn = min(mn, h[i] - h[i+K-1]);
  }

  cout << mn << endl;

  return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AParking {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, a, b;
	    in >> n >> a >> b;
	    out << min(n*a, b) << endl;
	}
};


int main() {
	AParking solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll f = 0;
    REP(i, n){
        cin >> a[i];
        f |= a[i];
    }
    if(!f){
        cout << "Yes" << endl;
        return 0;
    }
    if(n % 3 != 0){
        cout << "No" << endl;
        return 0;
    }
    map<ll, ll> mp;
    REP(i, n){
        mp[a[i]]++;
    }
    if(mp.size() == 3){
        vector<pair<ll, ll>> t;
        for(auto &x : mp){
            t.push_back(x);
        }
        if((t[0].first ^ t[1].first ^ t[2].first) == 0 &&
           (t[0].second == n / 3 && t[1].second == n / 3 && t[2].second == n / 3)){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    else if(mp.size() == 2){
        for(auto &x : mp){
            if(x.first == 0) continue;
            if(x.second == n / 3 * 2){
                cout << "Yes" << endl;
                return 0;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    else{
        cout << "No" << endl;
        return 0;
    }
}


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

int main(){
    int n,m = 0,cnt = 0;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(h[i]>=m){
            cnt += 1;
            m = h[i];
        }
    }
    cout << cnt << endl;
}

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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextLong();
            var a = cin.nextLong();
            var b = cin.nextLong();
            
            var w = n / (a + b);
            var m = n % (a + b);

            if(m <= a)
            {
                Console.WriteLine(a*w + m);
            }
            else
            {
                Console.WriteLine(a * w + a);
            }

            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  
  ll x = min(n, b-1);
  ll ans = a*x/b;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3572
h,w = map(int,input().split())
c = [0]*h
for i in range(h):
    c[i] = list(map(int,input().split()))

L = []
for i in range(h):
    for j in range(w):
        if c[i][j]%2 == 1:
            
            if j != w-1:
                c[i][j] -= 1
                c[i][j+1] += 1
                L.append([str(i+1),str(j+1),str(i+1),str(j+2)])
                
            else:
                if i != h-1:
                    c[i][j] -=1
                    c[i+1][j] += 1
                    L.append([str(i+1),str(j+1),str(i+2),str(j+1)])
                    
print(len(L))
for x in L:
    print(" ".join(x))

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> ruiseki(n + 1);
    ruiseki[0] = 0;
    for (int i = 1; i <= n; i++) {
        ruiseki[i] = ruiseki[i - 1] + a[i - 1];
    }

    ll ans = -1;
    for (int i = 1; i < n; i++){
        if (i == 1) ans = abs(ruiseki[i] - (ruiseki[n] - ruiseki[i]));
        else ans = min(ans, abs(ruiseki[i] - (ruiseki[n] - ruiseki[i])));
    }
    
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 5536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define int long long

using namespace std;

typedef long double ld;
typedef pair<int, int> pa;
typedef long long ll;

const int mod = 998244353, N = 1e5;
const ld pi = 3.1415926535;

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

    cout.precision(6);
    cout << fixed;

    ld r;
    cin >> r;
    cout << (r * 2 * pi);
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   int n,m;
   cin>>n>>m;
   string a,b;
   rep(i,m){
      a+=to_string(n);
   }
   rep(i,n){
      b+=to_string(m);
   }
   (a<=b)? cout<<a:cout<<b;


    
   return 0;
}

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

int n, x, d, t; 

int main() {
    cin >> n;
    for (int i=1; i<=n; i++){
        t = i;
        while(t > 0){
            t = t/10;
            d++;
        }
        if(d%2!=0){
            x++;
        }
        d = 0;
    }
    cout << x;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int num[9] = {0, 400, 600, 800, 1000, 1200, 1400, 1600, 1800};
int main () {
  int x;
  scanf("%d", &x);
  FORD(i, 8, 1) {
    if (x >= num[i]) {
      printf("%d\n", 8 - i + 1); return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける

int main(){
  int N, K, count=0;
  cin >> N >> K;
  vi h(N);
  for (int n = 0; n < N; n++)
  { 
    cin >> h.at(n);
  }
  for (int i = 0; i < N; i++)
  {
    if (h.at(i)>=K)
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();
        if (n < b) {
            System.out.println(a * n / b);
            return;
        }
        long x = n - (n % b) - 1;
        if (n % b == b - 1) {
            x = n;
        }
        long x2 = Math.max(0, x - b);
        System.out.println(
                Math.max((a * x / b) - a * (x / b), (a * x2 / b) - a * (x2 / b)));
    }
}


Measured memory_bytes: 35712
#include<stdio.h>
#define MAX_N 100000
int par[MAX_N];
int rank[MAX_N];

//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return find(par[x]);
    return par[x] = find(par[x]);
  }
}

//x?????????????´?????±??????????????????£??¨????????????
int depth(int x){
  if(par[x]==x){
    return 0;
  }else {
    return depth(par[x])+1;
  }
}

//x,y????±?????????????????????¨??????
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else {
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}


//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}


int main(){
  int N,Q;
  char s[16];
  int i,d;
  long long int res;
  while(1){
    if(!gets(s))break;
    sscanf(s,"%d %d",&N,&Q);
    if(N==0)break;
    res=0;
    init(N);
    for(i=1;i<N;i++){
      gets(s);
      sscanf(s,"%d",&par[i]);
      par[i]--;
    }
    for(i=0;i<Q;i++){
      gets(s);
      sscanf(s+2,"%d",&d);
      //printf(s);
      //return;
      switch(s[0]){
      case 'Q':
        res+=find(d-1)+1;
        //printf("%d\n",find(d-1)+1);
        break;
      case 'M':
        par[d-1]=d-1;
        //printf("%d\n",d-1);
        break;
      }
      //return 0;
    }
    //for(i=0;i<N;i++)printf("%d ",par[i]);
    printf("%lld\n",res);
  }
  return 0;
}

Measured memory_bytes: 1388
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
void build(ll l,ll r,ll in,string &s,vector<ll> &tree)
{
    if(l>r)
    {
        return;
    }
    else if(l==r)
    {
        if(s[l]=='0')
        {
            tree[in]=l;
        }
        return ;
    }
    ll mid = (l+r)>>1;
    build(l,mid,2*in+1,s,tree);
    build(mid+1,r,2*in+2,s,tree);
    tree[in] = max(tree[2*in+1],tree[2*in+2]);
    return;
}
ll query(ll l,ll r,ll ql,ll qr,ll in,vector<ll> &tree)
{
    if(r<l)
    {
        return -1;
    }
    if(r<ql || l>qr)
    {
        return -1;
    }
    else if(l>=ql && r<=qr)
    {
        return tree[in];
    }
    ll mid = (l+r)>>1;
    ll ans1 = query(l,mid,ql,qr,2*in+1,tree);
    ll ans2 = query(mid+1,r,ql,qr,2*in+2,tree);
    return max(ans1,ans2);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    vector<ll> tree(4*n+10,-1);
    build(0,n+1,0,s,tree);
    ll cp = 0;
    vector<ll> ans;
    while(cp!=n)
    {
        ll l = cp+1;
        ll r = min(cp+m,n);
        ll in = query(0,n+1,l,r,0,tree);
        if(in==-1)
        {
            cout<<-1;
            return 0;
        }
        ans.pb(in-cp);
        cp = in;
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans)
    {
        cout<<x<<' ';
    }
    return 0;
}



Measured memory_bytes: 4680
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;
int main(){

  string s,str,col[3];
  queue<string> que;
  map<string,int> mp;
  int flag;
  while(cin >> s,s != "0"){
    mp.clear();
    flag = 1;
    que.push(s);
    mp[s] = 0;
    for(int i=0;i<3;i++) col[i] = "";
    for(int i=0;i<s.size();i++){
      col[0] += "r";
      col[1] += "b";
      col[2] += "g";
    }
    while(!que.empty()){
      if(que.front()==col[0]){
	cout << mp[col[0]] << endl;
	flag--;
	break;
      }
      if(que.front()==col[1]){
	cout << mp[col[1]] << endl;
	flag--;
	break;
      }
      if(que.front()==col[2]){
	cout << mp[col[2]] << endl;
	flag--;
	break;
      }
      
      for(int i=0;i<s.size()-1;i++){
	str = que.front();
	if(str[i] != str[i+1]){
	  if(str[i] != 'r' && str[i+1] != 'r'){
	    str[i] = 'r';
	    str[i+1] = 'r';
	  } else if(str[i] != 'b' && str[i+1] != 'b'){
	    str[i] = 'b';
	    str[i+1] = 'b';
	  }else if(str[i] != 'g' && str[i+1] != 'g'){
	    str[i] = 'g';
	    str[i+1] = 'g';
	  }
	  if(mp.count(str) == 0){
	    que.push(str);
	    mp[str] = mp[que.front()]+1;
	  }
	}
      }
      que.pop();
    }
    while(!que.empty()) que.pop();
    if(flag) cout << "NA" << endl;
  }
  return (0);
}

Measured memory_bytes: 4668
n,d=map(int,input().split())
lst=[]
for i in range(n):
	lst.append(list(map(int, input().split())))

def calc_distant(p,q):
	sco = 0
	for i in range(d):
		sco += (p[i]-q[i])**2
	return sco

num=[]
for i in range(n-1):
	for j in range(i+1,n):
		num.append(calc_distant(lst[i],lst[j]))

def joukon(m):
	if float.is_integer(m**(0.5)):
		return 1
	else:
		return 0

lust = []
for i in num:
	lust.append(joukon(i))
print(sum(lust))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		int sum=0;
		if(a==b){
			sum++;
		} 
		if(a==c){
			sum++;
		} 
		if(b==c){
			sum++;
		}
		if(sum==1){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define lb(arr,n,x) lower_bound(arr,arr+n,x)-arr
#define ub(arr,n,x) upper_bound(arr,arr+n,x)-arr
#define endl "\n"
#define PI 3.14159265358979323846  /* pi */
#define sqr(x) (x)*(x)
#define sign(x) (x>0)-(x<0)
#define is_poweroftwo(n) (n&& !(n&(n-1)))
#define all(v)  ((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI) // Converts radians to degrees.
#define int long long
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define AagLgaDe ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef long double ld;
 
//Calculation of (x^y)%mm
ll mod_exp(ll x,ll y,ll mm)
{
    if(y==0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x)%mm,y/2,mm));
    else
        return((x*mod_exp((x*x)%mm,(y-1)/2,mm))%mm);
}
bool isPowerOfTwo(int n) 
{ 
   if(n==0) 
   return false;
   return (ceil(log2(n)) == floor(log2(n))); 
}
 
//int x1[]={+1,-1,+0,+0};
//int y1[]={+0,+0,+1,-1};
//int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
//int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
//int x3[]={-2,-2,-1,-1,+1,+1,+2,+2};
//int y3[]={-1,+1,-2,+2,-2,+2,-1,+1};
 
int solve()
{
	int n;
	cin>>n;
	vector<vector<int>> dp(n+1, vector<int>(3, 0));
	int x, y, z;
	cin>>x>>y>>z;
	dp[0][0]=0, dp[0][1]=0, dp[0][2]=0;
	dp[1][0]=x, dp[1][1]=y, dp[1][2]=z;
	for(int i=2;i<=n;i++)
	{
		int a, b, c;
		cin>>a>>b>>c;
		x+=max(b, c);
		y+=max(a,c);
		z+=max(a,b);
		dp[i][0]=max(dp[i-1][0], dp[i-2][0]+a);
		dp[i][0]=max(dp[i][0], max(dp[i-1][1], dp[i-1][2])+a);
		dp[i][1]=max(dp[i-1][1], dp[i-2][1]+b);
		dp[i][1]=max(dp[i][1], max(dp[i-1][0], dp[i-1][2])+b);
		dp[i][2]=max(dp[i-1][2], dp[i-2][2]+c);
		dp[i][2]=max(dp[i][2], max(dp[i-1][0], dp[i-1][1])+c);
	}
	return max(dp[n][0], max(dp[n][1], dp[n][2]));
}	
 
signed main() {
  	AagLgaDe
    // int t;cin>>t;while(t--)
	   cout<<solve();
 
 
return 0;
}

Measured memory_bytes: 8736
import math

n = int(input())
a = list(map(int,input().split()))
L = [0]*(n+1)
R = [0]*(n+1)
for i in range(n):
    L[i+1] = math.gcd(L[i], a[i])
    R[-2-i] = math.gcd(R[-1-i], a[-1-i])
    
ans = 0
for i in range(n):
    G = math.gcd(L[i], R[i+1])
    ans = max(ans, G)
print(ans)


Measured memory_bytes: 20748
def f_single_dot():
    # 参考: https://atcoder.jp/contests/abc168/submissions/13368489
    import sys
    from collections import deque
    input = sys.stdin.readline
    N, M = [int(i) for i in input().split()]

    x_set, y_set = set([0]), set([0])  # 重複を除いた xy 座標の一覧 (座標圧縮に必要)

    vertical_lines = []
    for _ in range(N):
        a, b, c = [int(i) for i in input().split()]
        vertical_lines.append((a, b, c))
        x_set |= {a, b}
        y_set |= {c}

    horizontal_lines = []
    for _ in range(M):
        d, e, f = [int(i) for i in input().split()]
        horizontal_lines.append((d, e, f))
        x_set |= {d}
        y_set |= {e, f}

    x_set = sorted(x_set)
    y_set = sorted(y_set)

    # 座標圧縮 (壁も配列に格納するので、2 倍している)
    x_encoded = {n: i * 2 for i, n in enumerate(x_set)}
    y_encoded = {n: i * 2 for i, n in enumerate(y_set)}
    # 座標圧縮されたグリッドで縦横に 1 マス分進むことは実際にはどれくらい進んだことなのか
    x_length = [x_set[i // 2 + 1] - x_set[i // 2] if i %
                2 else 0 for i in range(len(x_set) * 2 - 1)]
    y_length = [y_set[i // 2 + 1] - y_set[i // 2] if i %
                2 else 0 for i in range(len(y_set) * 2 - 1)]

    # 壁を埋めていく (累積和を用いていない)
    x_size, y_size = 2 * len(x_set) - 1, 2 * len(y_set) - 1
    grid = [[0] * y_size for _ in range(x_size)]
    for a, b, c in vertical_lines:
        a, b, c = x_encoded[a], x_encoded[b], y_encoded[c]
        for x in range(a, b + 1):
            grid[x][c] = 1
    for d, e, f in horizontal_lines:
        d, e, f = x_encoded[d], y_encoded[e], y_encoded[f]
        for y in range(e, f + 1):
            grid[d][y] = 1

    queue = deque()
    is_visited = [[0] * (y_size + 1) for _ in range(x_size + 1)]

    # 一度原点から斜めに動く (壁もグリッドに入れたため、ずれが生じたことによる)
    for dx, dy in ((-1, -1), (-1, 1), (1, 1), (1, -1)):
        nx, ny = x_encoded[0] + dx, y_encoded[0] + dy
        if 0 <= nx < x_size and 0 <= ny < y_size:
            queue.append((nx, ny))
            is_visited[nx][ny] = 1

    diff = ((-1, 0), (1, 0), (0, -1), (0, 1))
    ans = 0
    while queue:
        x, y = queue.pop()
        if (x % 2) & (y % 2):
            ans += x_length[x] * y_length[y]
        # grid を 2 マスずつ動いているのは、壁をグリッドに入れたことによる
        for dx, dy in diff:
            nx, ny = x + dx, y + dy
            nnx, nny = nx + dx, ny + dy
            if grid[nx][ny] == 0:
                if not ((0 <= nnx < x_size) and (0 <= nny < y_size)):
                    return 'INF'
                if not is_visited[nnx][nny]:
                    queue.appendleft((nnx, nny))
                    is_visited[nnx][nny] = 1
    return ans

print(f_single_dot())

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

typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    double lx = 0, hx = 1000, ans = 2e6;
    rep(i, 500) {
        double mx[2] = {(lx * 2 + hx) / 3, (lx + hx * 2) / 3}, dx[2] = {2e6, 2e6};
        rep(j, 2) {
            double ly = 0, hy = 1000;
            rep(k, 500) {
                double my[2] = {(ly * 2 + hy) / 3, (ly + hy * 2) / 3}, dy[2] = {0, 0};
                rep(l, 2) {
                    rep(m, N) {
                        dy[l] = max(dy[l], (mx[j] - x[m]) * (mx[j] - x[m]) + (my[l] - y[m]) * (my[l] - y[m]));
                    }
                    dx[j] = min(dx[j], dy[l]);
                }
                if (dy[0] < dy[1]) hy = my[1];
                else ly = my[0];
            }
            ans = min(ans, dx[j]);
        }
        if (dx[0] < dx[1]) hx = mx[1];
        else lx = mx[0];
    }
    cout << setprecision(20) << sqrt(ans) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
 
#define MAX_N 101
#define MAX_M 101
#define INF (1<<29)
 
int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];
 
double width(int* X, int* Y, int n, double x){
  double lb = INF, ub = -INF;
  for(int i = 0 ; i < n ; i++){
    double x1 = X[i], y1 = Y[i], x2 = X[(i+1)%n], y2 = Y[(i+1)%n];
    if((x1 - x) * (x2 - x) <= 0 && x1 != x2){
      double y = y1 + (y2-y1) * (x-x1) / (x2-x1);
      lb = min(lb, y);
      ub = max(ub, y);
    }
  }
  return max(0.0, ub - lb);
}
 
void solve(){
  int min1 = *min_element(X1, X1+M), max1 = *max_element(X1, X1+M);
  int min2 = *min_element(X2, X2+N), max2 = *max_element(X2, X2+N);
  vector<int> xs;
  for(int i = 0 ; i < M ; i++) xs.push_back(X1[i]);
  for(int i = 0 ; i < N ; i++) xs.push_back(X2[i]);
  sort(xs.begin(), xs.end());
   
  double res = 0;
   
  for(int i = 0 ; i+1 < xs.size() ; i++){
    double a = xs[i], b = xs[i+1], c = (a+b)/2;
    if(min1 <= c && c <= max1 && min2 <= c && c <= max2){
      double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
      double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
      double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
      res += (b-a)/6*(fa+4*fc+fb);
    }
  }
  printf("%.10f\n", res);
}
 
int main(void){
 
  while(cin >> M >> N,N|M){
    for(int i=0;i<M;i++){
      cin >> X1[i] >> Y1[i];
    }
    for(int i=0;i<N;i++){
      cin >> X2[i] >> Z2[i];
    }
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 1248
// finish date: 2018/01/19
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    int sum, mi=INF;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    FOR(i,-100,101){
        sum = 0;
        rep(j,N){
            sum += (i-a[j])*(i-a[j]);
        }
        mi = min(mi,sum);
    }
    cout<<mi<<endl;

    return 0;
}


Measured memory_bytes: 256
use warnings;
    use Data::Dumper;
    
    sub GetInputData{
    
        my @array_data;
    
        my $line = <STDIN>;
    
        chomp($line);
    
        while($line ne ""){
    
           push(@array_data,$line);
    
           $line = <STDIN>;
    
           chomp($line);
    
    }
    
        return @array_data;
    
    }
    
    sub GetSpaceInputData{
    
        my @array_temp=GetInputData();
    
        my @array_buf;
    
        foreach(@array_temp){
    
            #戻りは配列スペース区切りを分解
            # myを先頭につける必要あり
            my @array_work=split(" ",$_);

            # print "@array_work";
    
            # リファレンスを配列に代入
            push(@array_buf,\@array_work);
        }
    
        return @array_buf;
    
    }
    
    my @arr_result = GetSpaceInputData();

    my $x = $arr_result[0][0];


    print $x==7 || $x==5  || $x==3 ? "YES" : "NO";

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

int A,B,C,D;

int GCD(int a,int b)
{
    if(b == 0)return a;
    return GCD(b,a % b);
}

int main()
{
    scanf("%d%d%d%d",&A,&B,&C,&D);
    A = (int)abs(A - C);B = (int)abs(B - D);
    printf("%d\n",A + B - GCD(A,B));
    return 0;
}


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

    int val=0,num;
    cin>>num;
    if(int(floor(log10(num) + 1))%2==0)
    {
        for(int i=1;i<int(floor(log10(num) + 1));i+=2)
        {
            val+=int(pow(10,i))-int(pow(10,i-1));
        }
        cout<<val<<endl;
    }
    else
    {
      val+=num-int(pow(10,floor(log10(num) + 1)-1)-1);
      for(int i=1;i<=int(floor(log10(num)+1)-2);i+=2)
      {
          val+=int(pow(10,i))-int(pow(10,i-1));
      }
      cout<<val<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)
	var arr []byte
	fmt.Scan(&arr)
	var w byte = 87
	var r byte = 82
	wi := 0
	ri := d - 1
	ctr := 0
	for {
		for arr[wi] != w {
			wi++
			if wi == d {
				fmt.Println(ctr)
				return
			}
		}
		for arr[ri] != r {
			if ri == wi {
				fmt.Println(ctr)
				return
			}
			ri--
		}
		arr[wi] = r
		arr[ri] = w
		ctr++
	}
}


Measured memory_bytes: 3396
#include<bits/stdc++.h>
const int MOD = 1000000007;

int n, m, pr=-1, t, i, a[100000], fib[1000100];

int main(){
	fib[0] = 0;
	fib[1] = 1;
	for(i=2;i<100010;i++) fib[i] = (fib[i-1]+fib[i-2])%MOD;

	int_fast64_t ans = 1;
	scanf("%d %d", &n, &m);
	for(i=0; i<m; i++){
		scanf("%d", &t);
		ans = ans * fib[t-pr-1] % MOD;
		pr = t;
	}
	printf("%ld\n", ans * fib[n-pr] % MOD);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

long long arr[N];
int c[N];
int n;
char s[55];
int bit[10][55][55];

void add(int i, int j, int d) {
    i++, j++;
    for(int x = i; x < 55; x += (x & -x)) {
        for(int y = j; y < 55; y += (y & -y)) bit[d][x][y]++;
    }
}

int get(int i, int j, int d) {
    i++, j++;
    int ret = 0;
    for(int x = i; x > 0; x -= (x & -x)) {
        for(int y = j; y > 0; y -= (y & -y)) ret += bit[d][x][y];
    }
    return ret;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        scanf("%d", &n);
        for(int i = 0; i < n; i++) {
            scanf("%s", &s);
            arr[i] = 0;
            int m = strlen(s);
            bool bo = 0;
            bool ok = 0;
            for(int j = 0; j < m; j++) {
                if(s[j] == '.') {
                    bo = 1;
                    continue;
                }
                if(bo && s[j] != '0') ok = 1;
            }
            bo = 0;
            for(int j = 0; j < m; j++) {
                if(s[j] == '.') {
                    if(!ok) break;
                    bo = 1;
                    continue;
                }
                c[i] += bo;
                arr[i] = arr[i] * 10 + s[j] - '0';
            }
        }
        long long ans = 0;
        for(int i = 0; i < n; i++) {
            int two = 0, five = 0;
            while(arr[i] % 2 == 0) {
                arr[i] >>= 1;
                two++;
            }
            while(arr[i] % 5 == 0) {
                arr[i] /= 5;
                five++;
            }
            for(int d = 0; d < 10; d++) {
                int dig = d + c[i];
                int x1 = dig - two, y1 = dig - five;
                x1 = max(x1, 0), y1 = max(y1, 0);
                int add = get(40, 40, d) - get(x1 - 1, 40, d) - get(40, y1 - 1, d) + get(x1 - 1, y1 - 1, d);
                assert(add >= 0);
                ans += add;
                // if(add) {
                //     cout << i << ' ' << d << ' ' << add << '\n';
                //     cout << x1 << ' ' << y1 << '\n';
                // }
            }
            add(two, five, c[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 6120
#include<bits/stdc++.h>
using namespace std;
char s[10];
int a,b,c,d;
int main()
{
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    for(int i=43;i<=45;i+=2)
    {
        for(int j=43;j<=45;j+=2)
        {
            for(int k=43;k<=45;k+=2)
            {
                int ans=a;
                if(i==43)ans+=b;
                else ans-=b;
                if(j==43)ans+=c;
                else ans-=c;
                if(k==43)ans+=d;
                else ans-=d;
                if(ans==7)
                {
                    cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll dfs(ll N, ll X) {
    ll total = (1ll << (N + 2)) - 3;
    // debug(X);
    if(X == 0)
        return 0;
    if(X == total)
        return (1ll << (N + 1)) - 1;
    if(N == 0)
        return 1;
    if(total > 2 * X) {
        return dfs(N - 1, X - 1);
    }
    return (1ll << N) + dfs(N - 1, X - ((1ll << (N + 1)) - 1));
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    cout << dfs(N, X) << endl;
    return 0;
}


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

s = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int,input().split())
        s[i].append((x-1, y))

ans = 0
for state in range(1<<n):
    tmp = 0
    hh = []
    for mask in range(n):
        if (1<<mask)&state:
            hh.append(mask)
    flag = True
    for h in hh:
        for x,y in s[h]:
            if y == 1:
                if x not in hh:
                    flag = False
                    break
            else:
                if x in hh:
                    flag = False
                    break
        tmp += 1
    if flag:        
        ans = max(tmp, ans)
    
print(ans)

Measured memory_bytes: 74772
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

# a = [x//2 for x in a]
# if a[0] % 2 == 0:  # 偶数の時
# 	for x in a:
# 		if x % 2 == 1:
# 			print(0)
# 			sys.exit(0)
# 	for x in a:
# 		if a[0] != x and abs(a[0]-x)%gcd(2*a[0], 2*x) != 0:
# 			print(0)
# 			sys.exit()

# 	tmp = 1
# 	for x in a:
# 		tmp = x*tmp//gcd(x, tmp)
# 	print((M-tmp)//(tmp*2)+1)

# else:
# 	for x in a:
# 		if x % 2 == 0:
# 			print(0)
# 			sys.exit(0)
# 	tmp = 1
# 	for x in a:  # 奇数の時
# 		tmp = x*tmp//gcd(x, tmp)
# 	print((M-tmp)//(tmp*2)+1)

for i in range(1, N):
	if abs(a[0]//2-a[i]//2) % gcd(a[0], a[i]) != 0:
		print(0)
		sys.exit()
tmp = 1
for x in a:
	tmp = x//2*tmp//gcd(x//2, tmp)
print((M-tmp)//(tmp*2)+1)


Measured memory_bytes: 85100
///Coder ---->>>> Kael (Joan Marcos Rivera)
///Team ACM : CyberSpace ____ IPVCE FEDERICO ENGELS
///KingOfString
///Copyright

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

typedef long long ll;
typedef pair < int , int > par;

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define maxn 100010
#define mod 1000000007
#define less(n) order_of_key(n)
#define en_pos(n) find_by_order(n) /// --- >> iterador --- >> empieza en 0

int dp[maxn],a[110];
main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,k;

    cin >> n >> k;

    int mini = k + 1;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        dp[a[i]] = 1;
        mini = min(mini , a[i]);
    }

    for(int i=mini+1;i<=k;i++){
        if(dp[i])continue;
        int orr=0;
        for(int j=1;j<=n;j++){
            if(a[j] <= i && !dp[i-a[j]])dp[i]=1;
        }
    }


    if(dp[k])cout << "First" << '\n';
    else cout << "Second" << '\n';
}
/*
5 5
5 1
5 4
4 3
5 2
3 2
10
3 4
2 2
5 4
5 3
3 5
5 1
5 3
3 4
2 3
3 4*/


Measured memory_bytes: 640
#include <stdio.h>

int n, A[2000];

int solve (int i, int m)
{
  if (m == 0) {
    return 1;
  }
  if (i >= n) {
    return 0;
  }
  int res = solve (i + 1, m) || solve (i + 1, m - A[i]);
  return res;
}

int main()
{
  int q, i, M;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &M);
    if(solve (0, M)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<vector<int> > edge(N);
  int a, b;
  for(int i=0;i<N-1;++i) {
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  queue<pair<int, int> > que;
  que.push(mp(0, 0));
  pair<int, int> state;
  map<int, int> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  amap[0] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    for(int i=0;i<edge[state.fi].size();++i) {
      if(amap[edge[state.fi][i]]>-1) continue;
      que.push(mp(edge[state.fi][i], state.se+1));
      amap[edge[state.fi][i]] = state.se+1;
    }
  }
  int ans = 0;
  int node = 0;
  for(int i=0;i<N;++i) {
    if(ans<amap[i]) {
      ans = amap[i];
      node = i;
    }
  }
  que.push(mp(node, 0));
  for(int i=0;i<N;++i) amap[i] = -1;
  amap[node] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    for(int i=0;i<edge[state.fi].size();++i) {
      if(amap[edge[state.fi][i]]>-1) continue;
      que.push(mp(edge[state.fi][i], state.se+1));
      amap[edge[state.fi][i]] = state.se+1;
    }
  }
  for(int i=0;i<N;++i) {
    ans = max(ans, amap[i]);
  }
  ans++;
  if(ans%3==2) cout<<"Second"<<endl;
  else cout<<"First"<<endl;
}



Measured memory_bytes: 26080
// abc165_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

void dfs(vector<int> A) {
  // cout<<"A start"<<endl;
  // for (auto x : A) {
  //   cout<<x<<endl;
  // }
  // cout<<"A end"<<endl;
  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;
  return 0;
}


Measured memory_bytes: 3628