akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long double LD;
typedef long long ll;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define mod             1000000007
#define INF             2147483647
#define endl            "\n"
#define FasterIO        ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;
#define precision(a)    cout << fixed << setprecision(a)
#define bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define reset(a,b)      memset(a,b,sizeof(a));
#define For(x,n)        for(int i=x; i<n; i++)

const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

int strtoint(string str){
    stringstream ss(str);
    int x = 0;
    ss >> x ;
    return x ;
}
string intostr(int x){
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}
void rem(string &s, const string &c) {
	auto pos = s.find(c);
	if (pos == string::npos) {
		cout << -1 << endl;
		exit(0);
	}
	s.erase(0, pos + 1);
}
void println (int n){
    cout<<n<<"\n";
}
void printvec(vector <int> &a){
    for (int i=0;i<a.size();i++){
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void printgraph(vector <int> g[],int e){
    for (int i=0;i<e;i++){
        cout<<i<<" --> ";
        for (int j=0;j<g[i].size();j++){
            cout<<g[i][j]<<" ";
        }
        cout<<"\n";
    }
}

void printmap (map <int,int> &mymap){
    for (auto itr = mymap.begin(); itr != mymap.end(); ++itr) {
        cout << '\t' << itr->first
             << '\t' << itr->second << '\n';
    }
    cout << "\n";
}



void solve(){
    int n;
    cin>>n;
    if (n==1)cout<<0<<endl;
    else cout<<1<<endl;


}


int main(){
    //FasterIO;

    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vl v = {3, 5, 7};
  rep2(k, 3, 11) {
    ll m = pow(3, k);
    rep(i, m) {
      vl a(k);
      ll x = i;
      set<ll> st;
      rep(j, k) {
        a[j] = x % 3;
        x /= 3;
        st.insert(a[j]);
      }
      ll s = 0;
      rep(j, k) s += v[a[j]] * pow(10, j);
      if(s <= n && st.size() == 3) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    
    ll n;
    cin>>n;
    if(n%2==1){
        pr(0);
    }else{
        ll sum = 0;
        auto x = n/2;
        // rep(i,x){
        //     auto y = i+1;
        //     if(y%5==0){
        //         sum++;
        //     }
        // }
        ll base = 1;
        while(1){
            base*=5;
            sum+=x/base;
            // pr(sum);
            auto y = (ll)1000000000000000000;
            if(base >= y) {
                break;
            }
        }
        pr(sum);
    }

 

}


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

int main() {
  string s;
  long ans = 0, tmp = 0;

  cin >> s;

  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == 'W')
      ans += tmp;
    else
      tmp++;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

vector<int> get_next_seq(vector<int>& arr) { // // O(n) by using stack
    int n = arr.size();
    vector<int> st;
    vector<int> nxt(n, n);
    /* ref here
    "GT": auto cmp_func = [](const int& a, const int& b) {return a > b;};
    "GE": auto cmp_func = [](const int& a, const int& b) {return a >= b;};
    "LT": auto cmp_func = [](const int& a, const int& b) {return a < b;};
    "LE"  auto cmp_func = [](const int& a, const int& b) {return a <= b;}; */
    auto cmp_func = [](const int& a, const int& b) {return a < b;};
    for(int i = 0; i < n; i++) {
        while (!st.empty() && cmp_func(arr[i], arr[st.back()])) {
            nxt[st.back()] = i;
            st.pop_back();
        }
        st.push_back(i);
    }
    return nxt;
}
vector<int> get_prev_seq(vector<int>& arr) { // O(n) by using stack
    int n = arr.size();
    vector<int> st;
    vector<int> pre(n, -1);
    /* ref here
    "GT": auto cmp_func = [](const int& a, const int& b) {return a > b;};
    "GE": auto cmp_func = [](const int& a, const int& b) {return a >= b;};
    "LT": auto cmp_func = [](const int& a, const int& b) {return a < b;};
    "LE"  auto cmp_func = [](const int& a, const int& b) {return a <= b;}; */
    auto cmp_func = [](const int& a, const int& b) {return a < b;};
    for(int i = n-1; i >= 0; i--) {
        while (!st.empty() && cmp_func(arr[i], arr[st.back()])) {
            pre[st.back()] = i;
            st.pop_back();
        }
        st.push_back(i);
    }
    return pre;
}
int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    auto nxt = get_next_seq(arr);
    auto pre = get_prev_seq(arr);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += ll(nxt[i]-i) * ll(i - pre[i]) * ll(arr[i]);
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3832
import java.util.*;

public class Main {

    static Set<Integer> cnt = new HashSet<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int vertices = sc.nextInt();
        int edges = sc.nextInt();
        List<List<Integer>> edge = new ArrayList<>();

        for (int i = 0; i < edges; i++) {
            edge.add(Arrays.asList(sc.nextInt(), sc.nextInt()));
        }


        int ans = 0;
        for (int i = 0; i < edges; i++) {
            List<Integer> e = edge.remove(i);
            connected(mapGen(edge), edge.get(0).get(0));
            if (cnt.size() != vertices) ans++;
            cnt.clear();
            edge.add(i, e);
        }

        System.out.println(ans);

    }

    private static Map<Integer, List<Integer>> mapGen(List<List<Integer>> edges) {
        Map<Integer, List<Integer>> g = new HashMap<>();
        for (int i = 0; i < edges.size(); i++) {
            int v = edges.get(i).get(0);
            int w = edges.get(i).get(1);
            if (!g.containsKey(v)) g.put(v, new ArrayList<>());
            if (!g.containsKey(w)) g.put(w, new ArrayList<>());

            g.get(v).add(w);
            g.get(w).add(v);
        }

        return g;
    }

    private static void connected(Map<Integer, List<Integer>> g, int v) {
        if (cnt.contains(v)) return;
        cnt.add(v);
        for (int w : g.get(v)) {
            connected(g, w);
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
using namespace std;

int n,k,x,mx;

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    int d = 0;
    for (int i=1;i<=n;i++){
    	cin >> x;
    	d = __gcd(d, x);
    	mx = max(mx, x);
    }
    if (k % d == 0 && k <= mx) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
    return 0;
}

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

int main() {
    int N;
    double ans = 0.0;
    cin >> N;
    double x;
    string u;
    for (int i = 0; i < N; i++) {
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int i=0, x[101];
  char s[100];
 
  while( scanf( "%s" , s ) != EOF ) {
    if ( s[0] == ' ' ) continue;
    else if ( s[0] == '+' ) {
      x[i-2] = x[i-2] + x[i-1];
      i--;
    }
    else if ( s[0] == '-' ) {
      x[i-2] = x[i-2] - x[i-1];
      i--;
    }
    else if ( s[0] == '*' ) {
      x[i-2] = x[i-2] * x[i-1];
      i--;
    }
    else {
      x[i] = atoi(s);
      i++;
    }
  }
 
  printf( "%d\n" , x[0] );
  
  return 0;
}



Measured memory_bytes: 2052
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
   
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[input[i] - 0]);
  }
  
    
}
  
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);
  
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
      
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
  
  var primeNums = new Int32Array(max + 1);
  var sum = 0;
  for(var i = 1; i <= max; i++){
    sum = primeNums[i] += sum + 1 - primeNumbers[i];
  }
    
  return primeNums;
}

Measured memory_bytes: 13584
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

x,y=map(int,input().split())

def jj(n):
        if n in a:
            return 1
        if n in b:
            return 2
        if n in c:
            return 3

if jj(x)==jj(y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int a = min(A, X / 500); a >= 0; --a)
    {
        if(0 == (X - (500 * a)))
        {
            ans++;
            continue;
        }
        for(int b = min(B, (X - (500 * a)) / 100); b >= 0; --b)
        {
            if(0 == (X - (500 * a) - (100 * b)))
            {
                ans++;
                continue;
            }
            for(int c = min(C, (X - (500 * a) - (100 * b)) / 50); c >= 0; --c)
            {
                if(0 == (X - (500 * a) - (100 * b) - (50 * c)))
                {
                    ans++;
                    continue;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using lli = int64_t;
using vi = vector<lli>;

int main2()
{
    int U = 50;
    vector<int> v(U);
 
    for(int i = 0; i < U; i++) v[i] = i;
 
    for(int i = 1; i <= 1000000; i++)
    {
        v[0] += U;
 
        for(int j = 1; j < U; j++) v[j]--;
 
        sort(begin(v), end(v));
 
        if(i % U == 0) {
            cout << i << ": ";
            for(auto x : v) cout << x << ' '; cout << endl;
        }
    }
 
    cout << "OK" << endl;
    return 0;
}

int main()
{
    lli k; cin >> k;

    lli U = 50;

    lli q = k - (k % U);

    vi v(U);

    for(lli i = 0, j = q / U; i < U; i++, j++)
        v[i] = j;

    for(lli i = 0; i < k % U; i++)
    {
        v[0] += U;

        for(int j = 1; j < U; j++) v[j]--;

        sort(begin(v), end(v));
    }

    cout << U << endl;
    for(auto x : v) cout << x << ' '; cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   //IOS;
   int n;
   scanf("%d",&n);
   int p=n%10;
   if(p == 3) printf("bon");
   else if(p == 0||p == 1||p == 6||p == 8) printf("pon");
   else printf("hon");
}


Measured memory_bytes: 3752
A1,A2,A3 = map(int, input().split())
res = 100*3
A = [A1,A2,A3]
arr = [[0,1,2], [0,2,1], [1,0,2], [1,2,0],[2,0,1], [2,1,0] ]
for a in arr:
  m = abs(A[  a[0] ] - A[a[1]])
  n = abs(  A[ a[2] ] - A[a[1]])
  if res > m + n:
    res = m + n
print(res)

Measured memory_bytes: 9144
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	int n; cin >> n;
	int i = 0;
	while (1) {
		if (pow(i, 2) > n) {
			int a = pow(i - 1, 2);
			cout << a << endl;
			break;
		}
		else {
			i++;
		}
	}
}

Measured memory_bytes: 256
def c_s(str)
    i = -2
    kk = 0
    while 1
        i = str.index('AB', i+2)
        break if i == nil
        kk += 1
    end
    kk
end

aabb = 0
n=gets.split.map(&:to_i)
s=$<.map(&:chomp)
ab = s.map {|ss| c_s(ss)}.inject(:+)
a = s.select {|ss| ss.end_with?('A')}.size
b = s.select {|ss| ss.start_with?('B')}.size
a_b = s.select {|ss| ss.start_with?('B')}.select {|ss| ss.end_with?('A')}.size
aabb = 1 if a_b == a && a_b == b && a_b > 0
puts ab + ([a,b].min) - aabb


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

int main(){
  int n;
  cin >> n;
  vector<long long> l(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  long long ans = 0;
  for(int i = 0; i < n; i++){
    for(int  j = i; j < n; j++){
      for(int p = j; p < n; p++){
        if(l[i] != l[j] && l[j] != l[p] && l[i] != l[p]){
          if(l[i] + l[j] > l[p] && l[i] + l[p] > l[j] && l[j] + l[p] > l[j]){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,total=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n-2;i++)
		for(int j=i+1;j<=n-1;j++)
			for(int k=j+1;k<=n;k++)
				if(a[i]+a[j]>a[k]) total++;
				else break;
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m):
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n):
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    a=list(map(int,input().split()))
    sosu=[]
    memo = defaultdict(int)
    ccc=era(10**6)
    for i in range(n):
        if a[i]!=1:
            temp=soinsubunkai_e(a[i],ccc)
        else:
            temp={}
        for j in temp:
            memo[j]+=1

    memo.pop(1,None)
 #   print(sosu)
 #   print(memo)
 #   print(memo.values())
    if len(memo)>=1:
        mmm=max(memo.values())
    else:
        mmm=1
    if mmm<=1:
        print("pairwise coprime")
    elif mmm<n:
        print("setwise coprime")
    else:
        print("not coprime")








if __name__ == "__main__":

    main()


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

int main() {
  
  int n ;
  cin >> n;
  
  int c=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
    if(vec.at(i)%2==1){
      c++;
    }
  }
 
  if(c%2==1){
  cout << "NO" << endl;
  }
  
  else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main() {
        int n,app=1;
        cin >> n;    
        vector<int> a(n);
        vector<int> b(n);
        for (int i = 0; i < n; i++) {
                cin >> a[i];
                b[i] = 1;
                if (a[i] % 2 == 0) {
                        b[i] = 0;
                        if (a[i] % 3 == 0)  
                                b[i] = 1;
                        if (a[i] % 5 == 0)
                                b[i] = 1;
                }   
        }   
        for (int i = 0; i < n; i++)
                if (b[i] == 0)
                        app = 0;
        if (app)
                cout << "APPROVED" << endl;
        else
                cout << "DENIED" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    for(int j=0;j<N;j++){
        cout<<a.at(N-j-1);
        if(j!=N-1)cout<<" ";
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
long long gcd(long long a,long long b){ return a == 0 ? b : gcd(b % a, a); } 
int main()
{
	int n,t,m;
	long long a,b,c,d,d1;
	long long p;
	
	scanf("%d",&t);
	for(int i=1;i<=t;i++)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		p=0;
		
		if (b>a || a%b>c || d<b)
		{
			p=1;
		}
		
		if ((!p))
		{
			if(c+1>=b)
			{
				printf("Yes\n");
				continue;
			}
		}
		
		
		a=a%b;
		
		if ((d%b)==0)
		{
			if (p)
			{
				printf("No\n");
				continue;
			}
			else
			{
				printf("Yes\n");
				continue;
			}
		}
		
		d1=d%b;
		m=10010;
		while(m--)
		{
			a+=(c-a)/d1*d1;
			a=(a+d1)%b;
			if (a>c) p=1;
		}
		if (p)
		{
			printf("No\n");
		}
		else
		{
			printf("Yes\n");
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;
 
int main() {
	int N, K;
	cin >> N >> K;
 
	if (N % K == 0) {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}
 
	return 0;
}

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

int main(){
    int x,n;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    int ans;
    int num;
    map<int,bool> mp;
    for(int i=0;i<n;++i){
        cin>>num;
        mp[num]=true;
    }
    int sum=1010;
    for(int i=-100;i<=110;++i){
        if(mp[i]!=true){
            if(sum>abs(x-i)){
                sum=abs(x-i);
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    string s, ans;
    cin >> s;
    ans = "No";
    rep(i,3){
        if(s.at(i) == '7'){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my
{
//配列の最大値or最小値を数値で返す関数
int max_element(std::vector<int> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(vec.size() - 1);
}
int min_element(std::vector<int> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(0);
}
} // namespace my

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std名前空間を使用
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート

void bubble_sort (vector<string> &c, int n){
    for (int i = 0; i < n; i++){
        for (int j = n - 1; j > i; j--){
            if (c[j][1] < c[j-1][1]) {
                swap(c[j], c[j - 1]);
            }
        }
    }
}

void selection_sort (vector<string> &c, int n){
    for (int i = 0; i < n; i++){
        int minj = i;
        for (int j = i + 1; j < n; j++){
            if (c[j][1] < c[minj][1]){
                minj = j;
            }
        }
        swap(c[i], c[minj]);
    }
}

bool is_stable (vector<string> vec1, vector<string> vec2){
    if (vec1 == vec2){
        return true;
    }
    else{
        return false;
    }
}

int main(){
    int n;
    cin >> n;
    vector<string> vec1(n);
    vector<string> vec2(n);
    rep(i,n){
        cin >> vec1[i];
        vec2[i] = vec1[i];
    }    
    bubble_sort(vec1, n);
    selection_sort(vec2, n);

    rep(i, n - 1){
        cout << vec1[i] << ' ';
    }
    cout << vec1[n - 1] << endl;
    cout << "Stable" << endl;
    rep(i, n - 1){
        cout << vec2[i] << ' ';
    }
    cout << vec2[n - 1] << endl;
    if (is_stable(vec1,vec2) == false){
        cout << "Not stable"<<endl;
    }
    else cout << "Stable" << endl;
}


Measured memory_bytes: 3224
import sys
import math
import heapq
import fractions

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()

primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]

INL=LI()
LCM={}
for i in INL:
    for p in primes:
        cnt = 0
        while i%p == 0:
            i //= p
            cnt += 1
        if not p in LCM: LCM[p] = 0
        LCM[p] = max(LCM[p], cnt)
    if i != 1:
        if not i in LCM: LCM[i] = 0
        LCM[i] = max(LCM[i], 1)

res = 0
LCMMOD = 1
for p, cnt in LCM.items():
    LCMMOD *= (p**cnt)
    LCMMOD %= DVSR

for i in INL:
    res += LCMMOD*INV(i)%DVSR

print(res%DVSR)


Measured memory_bytes: 74840
def main():
    S = input()
    D = ['dream', 'dreamer', 'erase', 'eraser']
    D = [d[::-1] for d in D]
    tmp = ''
    for s in S[::-1]:
        tmp = ''.join([tmp, s])
        if tmp in D:
            tmp = ''
        if len(tmp) > 7:
            print('NO')
            exit()
    if tmp == '':
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 41836
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m=0,n,aa[1100][1100],a,b,cnt=0;
pair<int,int> p[220000];
string s,ss[110000];
char c;
signed main(){
    cin>>s;
    n=s.size();
    rep(i,n/2){
        if(s[i]!=s[n-1-i]){
            cout<<"No";
            return 0;
        }
    }
    rep(i,(n-1)/2/2){
        if(s[i]!=s[(n-1)/2-1-i]){
            cout<<"No";
            return 0;
        }
    }
    rep(i,(n-1)/2/2){
        if(s[i+(n+1)/2]!=s[(n-1)/2+n-i-(n+1)/2]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector <vec> mat;
ll n,m,a,b,c,T;

mat mul(mat &A,mat &B){
  mat res=mat(n,vec(n,0));

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++){
	res[i][j]+=A[i][k]*B[k][j];
	res[i][j]%=m;
      }
  return res;
}

mat mod_pow(mat &x,ll y){
  mat res;
  res.resize(n);
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)res[i].push_back(i==j);
  
  while(y){
    if(y%2) res=mul(res,x);
    x=mul(x,x);
    y/=2;
  }
  return res; 
}
int main(){ 
  while(1){
    cin>>n>>m>>a>>b>>c>>T;
    if(!n&&!m&&!a&&!b&&!c&&!T)break;

    mat s;
    s.resize(n);
    for(int i=0;i<n;i++) s[i].resize(n);
    for(int i=0;i<n;i++) cin>>s[i][0];
    
    mat x;
    x.resize(n);
    for(int i=0;i<n;i++) x[i].resize(n);

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(i==j) x[i][j]=b;
	else if(i+1==j&&i+1<n) x[i][j]=c;
	else if(i==j+1&&j+1<n) x[i][j]=a;
	else x[i][j]=0;
    
    x=mod_pow(x,T);
    mat ans=mul(x,s);
    for(int i=0;i<n-1;i++)cout << ans[i][0]<<" ";
    cout << ans[n-1][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- map readInt . BS.words <$> BS.getLine
  putStrLn $ if solve a b then "Odd" else "Even"

solve :: Int -> Int -> Bool
solve a b = odd $ a * b

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 380
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007
#define BOX 200000

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define uni(a) a.erase(unique(begin(a), end(a)), end(a))
#define sum(a) accumulate(begin(a), end(a), 0)


template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {
	ll S, W;
	cin >> S >> W;

	if (S > W) {
		cout << "safe" << endl;
	}
	else {
		cout << "unsafe" << endl;
	}

    return 0;

}

Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
const int L = 100000;
int time[L];
char name[L][11];
int main() {
	int i, n, q, front = 0, back, size, t = 0;
	scanf("%d%d", &n, &q);
	back = n - 1;
	size = n;
	for (i = 0; i < n; i++) {
		scanf("%s %d", &name[i], &time[i]);
	}
	while (size>0) {
		if (time[front] <= q) {
			t += time[front];
			printf("%s %d\n", name[front], t);
			size--;
		}
		else {
			t += q;
			time[front] -= q;
			back = (back + 1) % L;
			time[back] = time[front];
			strcpy(name[back], name[front]);
		}
		front = (front + 1) % L;
	}
	return 0;
}


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

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    vector<bool> per_nm(n + m - 1, true);
    for (int i = 0; i < m - 1; ++i) per_nm[i] = false;
    int ans = 0;
    do {
        int f_cnt = 1;
        vector<int> A;
        for (int i = 0; i < per_nm.size(); ++i) {
            if (per_nm[i]) A.push_back(f_cnt);
            else f_cnt++;
        }
        int sum = 0;
        for (int i = 0; i < q; ++i) {
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
    } while (next_permutation(per_nm.begin(), per_nm.end()));
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>//accumulateを使うためにインクルード

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    for(size_t i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for(size_t i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }

    int kyori = 0;
    int ans = 0;
    int ans_value = 999999999;
    for(size_t i = 0; i < n; i++)
    {
        for(size_t j = 0; j < m; j++)
        {
            kyori = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(kyori < ans_value){
                ans_value = kyori;
                ans = j+1;
            }
        }
        cout << ans << endl;
        ans_value = 999999999;
        ans = 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
string s;
int vis[200005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	vis[0] = 1;
	cin >> s;
	ll res = 0;
	ll n = 0;
	ll d = 1;
	for(int i = s.length() - 1;i >= 0;i--){
		n = (((s[i] - '0') * d) % 2019 + n % 2019) % 2019;
		res += vis[n];
		vis[n]++;
		d = d * 10 % 2019;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int cnt=0,i,j,k,n,r=0,g=0,b=0;
    string ptr;
    cin>>n>>ptr;

    for(i=0; i<ptr.length(); i++)
    {
        if(ptr[i]=='R')
            r++;
        if(ptr[i]=='G')
            g++;
        if(ptr[i]=='B')
            b++;
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(ptr[i]!=ptr[j])
            {
                if(2*j-i>=n)
                    continue;
                if(ptr[2*j-i]!=ptr[i]&&ptr[2*j-i]!=ptr[j])
                    cnt++;
            }
        }
    }
cout<<(r*g*b)-cnt<<endl;
}


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

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

int n, k, a[555], sum;
int up[555], lo[555];
bool f(int x) {
	vector<int>v;
	int sum2 = 0;
	rep(i, n) {
		sum2 += a[i] % x; v.push_back(a[i] % x);
	}
	sort(all(v), greater<>());
	int memo = sum2 / x;
	rep(i, memo) {
		sum2 -= v[i];
	}
	if (sum2 <= k)return 1;
	return 0;
}
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
	}
	int ans = 1;
	for (int i = 1; i * i <= sum; i++) {
		if (sum % i)continue;
		if (f(i))chmax(ans, i);
		if (f(sum / i))chmax(ans, sum / i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int height[2001][2001];
int width[2001][2001];

int main() {
    int h, w; cin >> h >> w;
    vector<string> field(h);
    rep(i,h){
        cin >> field[i];
    }
    rep(i,h){
        int count = 1;
        rep(j,w){
            if(field[i][j]=='#'){
                count = 1;
            }else{
                width[i][j] = count;
                count++;
            }
        }
    }
    rep(i,w){
        int count = 1;
        rep(j,h){
            if(field[j][i]=='#'){
                count = 1;
            }else{
                height[j][i] = count;
                count++;
            }
        }
    }
    for(int i = h-1; i >= 0; i--){
        for(int j = w-2; j >= 0; j--){
            if(width[i][j+1]!=0 && width[i][j]!=0){
                width[i][j] = width[i][j+1];
            }
        }
    }
    for(int i = w-1; i >= 0; i--){
        for(int j = h-2; j >= 0; j--){
            if(height[j+1][i]!=0 && height[j][i]!=0){
                height[j][i] = height[j+1][i];
            }
        }
    }
    int ans = 0;
    rep(i,h){
        rep(j,w){
            ans = max(ans,width[i][j]+height[i][j]);
        }
    }
    cout << ans-1 << endl;
    

    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];
    
    vector<int> AC(N, 0);
    REP(i, N) {
        if (S[i - 1] == 'A' && S[i] == 'C') AC[i] = AC[i - 1] + 1;
        else AC[i] = AC[i - 1];
    }
    rep(i, Q) {
        if (l[i] == 1) cout << AC[r[i] - 1] << endl;
        else cout << AC[r[i] - 1] - AC[l[i] - 1] << endl;
    }
    return 0;
}


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

using namespace std;

#define int long long

int n,m;
int dp1[111][111][3];
int dp2[111][111][111][3];

int dfs1(int A,int B,int d){
  if(n<A || n<B)return 0;
  if(B==n)return 1;
  if(dp1[A][B][d]!=-1)return dp1[A][B][d];
  
  int res=0;
  if(d==0){
    res += dfs1(A+1,B,0);
    if(A>B) res += dfs1(A,A,1);
  }
  if(d==1){
    res += dfs1(A,B+1,1);
    if(A<B) res += dfs1(B,B,0);
  }

  res %= 1000000;

  return dp1[A][B][d] = res;
  
}

int dfs2(int A,int B,int C,int d){
  if(n<A || n<B ||n<C)return 0;
  if(C==n)return 1;
  if(dp2[A][B][C][d]!=-1)return dp2[A][B][C][d];

  int res=0;
  if(d==0){
    if(A>B && A>C){
      int x = min(A-B,A-C)-1;
      res += dfs2(A,A,A,2) * x;
    }
    if(A>B){
      res += dfs2(A,A,C,1);
    }
    res += dfs2(A+1,B,C,0);
  }

  if(d==1){
    if(A<B) res += dfs2(B,B,C,0);
    res += dfs2(A,B+1,C,1);
    if(B>C) res += dfs2(A,B,B,2);
  }

  if(d==2){
    if(C>B && C>A){
      int x = min(C-B,C-A)-1;
      res += dfs2(C,C,C,0) * x;
    }
    if(C>B){
      res += dfs2(A,C,C,1);
    }
    res += dfs2(A,B,C+1,2);
  }

  res %= 1000000;

  return dp2[A][B][C][d] = res;
}

signed main(){
  cin>>n>>m;

  memset(dp1,-1,sizeof(dp1));
  memset(dp2,-1,sizeof(dp2));

  n++;

  if(m==1)cout<<dfs1(1,0,0)<<endl;
  else cout<<dfs2(1,0,0,0)<<endl;
}



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

int main() {
  int N,a,b;
  double X;
  cin>>N;
  X=N/1.08;
  a=(int)X*1.08;
  b=(int)(X+1)*1.08;
  if(a==N){cout<<(int)X<<endl;}
  else if(b==N){cout<<(int)(X+1)<<endl;}
  else{cout<<":("<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n,t[110],ans=1;
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int lcm(int x,int y){
    int n=gcd(x,y);
    return (x/n)*y;
}
signed main(){
    cin>>n;
    rep(i,n)cin>>t[i];
    if(n==1)ans=t[0];
    else{
        ans=lcm(t[0],t[1]);
        rep(i,n){
            ans=lcm(ans,t[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

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

//

int M, N;
int getans(const int nowx, const int nowy, vector<vector<int>>&field) {
	int ans = 1;
	for (int way = 0; way < 4; ++way) {
		const int nextx = nowx + dx[way];
		const int nexty = nowy + dy[way];
		if (nextx >= 0 && nextx < M&&nexty >= 0 && nexty < N) {
			if (field[nexty][nextx]) {
				field[nexty][nextx] = false;
				ans = max(ans, 1 + getans(nextx, nexty, field));
				field[nexty][nextx] = true;
			}
		}
		
	}
	return ans;
}

int main() {
	while (1) {cin >> M >> N;
		if (!M)break;

		vector<vector<int>>field(N, vector<int>(M));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				cin >> field[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				if (field[i][j]) {
					field[i][j] = false;
					ans = max(ans, getans(j, i, field));
					field[i][j] = true;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
def vertical_move(move):
    if move >= 0:
        return "U" * move
    return "D" * (-move)

def horizontal_move(move):
    if move >= 0:
        return "R" * move
    return "L" * (- move)

def opposite_horizontal_to_vertical(sx, sy, tx, ty):
    ans = ""
    first_opposite = ""
    vertical = ""
    horizontal = ""
    last_opposite = ""
    if sx <= tx:
        first_opposite = "L"
        horizontal = horizontal_move(tx - sx + 1)
    else:
        first_opposite = "R"
        horizontal = horizontal_move(tx - sx - 1)
        
    if sy <= ty:
        last_opposite = "D"
        vertical = vertical_move(ty + 1 - sy)
    else:
        last_opposite = "U"
        vertical = vertical_move(ty - 1 - sy)
        
    return first_opposite + vertical + horizontal + last_opposite

sx, sy, tx, ty = map(int, input().split())

ans = ""
ans += vertical_move(ty - sy)
ans += horizontal_move(tx - sx)
ans += vertical_move(sy - ty)
ans += horizontal_move(sx - tx)

ans += opposite_horizontal_to_vertical(sx, sy, tx, ty)
ans += opposite_horizontal_to_vertical(tx, ty, sx, sy)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int map[8][8];

int val(int y,int x){
	int dx[]={1,1,1,0,0,-1,-1,-1};
	int dy[]={1,0,-1,1,-1,1,0,-1};
	int ans=0;
	for(int i=0;i<8;i++){
		int cnt=0,a=y,b=x;
		while(true){
			a+=dy[i],b+=dx[i];
			if(a>=0&&a<8&&b>=0&&b<8){
				if(map[a][b]==1)cnt++;
				if(map[a][b]==0){
					ans+=cnt;
					break;
				}
				if(map[a][b]==2)break;
			}
			else break;
		}
	}
	return ans;
}

void ch(int y,int x){
	int dx[]={1,1,1,0,0,-1,-1,-1};
	int dy[]={1,0,-1,1,-1,1,0,-1};
	for(int i=0;i<8;i++){
		int a=y,b=x;
		bool ok=false;
		while(true){
			a+=dy[i],b+=dx[i];
			if(a>=0&&a<8&&b>=0&&b<8){
				if(map[a][b]==0){
					ok=true;
					break;
				}
				if(map[a][b]==2)break;
			}
			else break;
		}
		if(ok){
			while(true){
				if(a==y&&b==x)break;
				a-=dy[i],b-=dx[i];
				map[a][b]=0;
			}
		}
	}
}

int main(){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			char z;cin>>z;
			if(z=='o')map[i][j]=0;
			if(z=='x')map[i][j]=1;
			if(z=='.')map[i][j]=2;
		}
	}
	int t=0;
	for(int u=0;u<130;u++){
		if(t==0){
			int x=-1,y=-1,z=0;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(map[i][j]==2){
						int k=val(i,j);
						if(k>z)x=j,y=i,z=k;
					}
				}
			}
			if(z)ch(y,x);
		}
		if(t==1){
			int x=-1,y=-1,z=0;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(map[i][j]==2){
						int k=val(i,j);
						if(k>=z)x=j,y=i,z=k;
					}
				}
			}
			if(z)ch(y,x);
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(map[i][j]==0)map[i][j]=3;
				if(map[i][j]==1)map[i][j]=0;
				if(map[i][j]==3)map[i][j]=1;
			}
		}
		t=1-t;
	}
	
	if(t){
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(map[i][j]==0)map[i][j]=3;
				if(map[i][j]==1)map[i][j]=0;
				if(map[i][j]==3)map[i][j]=1;
			}
		}
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			if(map[i][j]==0)cout<<"o";
			if(map[i][j]==1)cout<<"x";
			if(map[i][j]==2)cout<<".";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
a=[int(input()) for i in range(20)]
b=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]]
c=[a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19]]
b.sort()
c.sort()
print(sum(b[7:10]),sum(c[7:10]))




Measured memory_bytes: 5600