akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

bool is_triangle(int a, int b, int c) {
    if ((a < b + c) && (b < a + c) && (c < a + b)) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int n; cin >> n;
    vector<int> l;
    int tmp;
    REP(i, n) {
        cin >> tmp;
        l.push_back(tmp);
    }
    sort(ALL(l));

    ll res = 0;
    FOR(ai, 0, n-3) {
        FOR(bi, ai+1, n-2) {
            FOR(ci, bi+1, n-1) {
                if (is_triangle(l[ai], l[bi], l[ci])) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define Rint register int
#define int long long 
using namespace std;
typedef long long LL;
template<typename T>
inline void read(T &x){
	int ch = getchar();
	bool flag = false;
	x = 0;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){
		flag = true;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	if(flag) x = -x;
}
int n, a[3], b[3], x;
signed main(){
	read(n); read(a[0]); read(a[1]); read(a[2]); read(b[0]); read(b[1]); read(b[2]);
	for(Rint i = 0;i < 3;i ++) if(a[i] > b[i]) ++ x;
	if(x == 0){
		int ans = 0;
		for(Rint x = 0;x <= n / a[0];x ++)
			for(Rint y = 0;y <= (n - a[0] * x) / a[1];y ++){
				int z = (n - a[0] * x - a[1] * y) / a[2];
				int tmp = x * (b[0] - a[0]) + y * (b[1] - a[1]) + z * (b[2] - a[2]);
				ans = max(ans, tmp);
			}
		printf("%lld", ans + n);
	} else if(x == 1){
		for(Rint i = 1;i < 3;i ++)
			if(a[i] > b[i]){
				swap(a[0], a[i]);
				swap(b[0], b[i]);
				break;
			}
		int ans = 0;
		for(Rint x = 0;x <= n / a[1];x ++){
			int y = (n - a[1] * x) / a[2];
			ans = max(ans, x * (b[1] - a[1]) + y * (b[2] - a[2]));
		}
		ans += n;
		ans += (ans / b[0]) * (a[0] - b[0]);
		printf("%lld", ans);
	} else if(x == 2){
		for(Rint i = 1;i < 3;i ++)
			if(a[i] < b[i]){
				swap(a[0], a[i]);
				swap(b[0], b[i]);
				break;
			}
		int ans = n + n / a[0] * (b[0] - a[0]), tmp = 0;
		for(Rint x = 0;x <= ans / b[1];x ++){
			int y = (ans - b[1] * x) / b[2];
			tmp = max(tmp, x * (a[1] - b[1]) + y * (a[2] - b[2]));
		}
		printf("%lld", ans + tmp);
	} else {
		int ans = 0;
		for(Rint x = 0;x <= n / b[0];x ++)
			for(Rint y = 0;y <= (n - b[0] * x) / b[1];y ++){
				int z = (n - b[0] * x - b[1] * y) / b[2];
				int tmp = x * (a[0] - b[0]) + y * (a[1] - b[1]) + z * (a[2] - b[2]);
				ans = max(ans, tmp);
			}
		printf("%lld", ans + n);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  deque<ll> B;
  rep(i, n) {
    if(i%2==0) B.push_back(A[i]);
    else B.push_front(A[i]);
  }
  if(n%2==0) {
    rep(i, n) cout << B[i] << ' '; cout << "\n";
  } else {
    rrep(i, n) cout << B[i] << ' '; cout << "\n";
  }
  return 0;
}


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

int main(void)
{
	int S=0, a=0, b=0, c=0;
  	cin >> S;
    a = S/100;
	b = (S-a*100)/10;
	c = (S-a*100-b*10)/1;
  	cout << a+b+c << endl;
}

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

#define int ll
#define pb push_back
#define DBGB if (true)

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;
using E=array<int,3>;
using ve=vector<E>;

template<typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B>& p) { return out << "(" << p.first << ", " << p.second << ")"; }
template<typename Ch, typename Tr, typename C> basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& out, const C& xs) { out << "["; for (const auto& x: xs) out << x << ", "; out << "]"; }


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

  int M, D;
  cin >> M >> D;
  int cnt=0;
  for (int m=1; m<=M; ++m) {
    for (int d=1; d<=D; ++d) {
      if (d >= 10 && d%10 >= 2 && d/10 >= 2 && (d%10)*(d/10) == m)
        ++cnt;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

long long mem[405][405];
int n;
long long arr[405];

long long go(int l,int r)
{
	if(l>=r) return 0;
	if(mem[l][r]!=-1) return mem[l][r];
	long long sum=arr[r]-arr[l-1];
	mem[l][r]=(1LL<<60);
	for(int i=l;i<r;i++)
	{
		mem[l][r]=min(mem[l][r],sum+go(l,i)+go(i+1,r));
	}
	return mem[l][r];
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> arr[i];
		arr[i]+=arr[i-1];
	}
	memset(mem,-1,sizeof mem);
	cout << go(1,n) << endl;
}

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

class Student {
public:
    int height;
    bool isShortest;
    bool isTallest;
};

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<Student> > students(n, vector<Student>(n));
        for (int y = 0; y < n; y++) {
            for (int x = 0; x < n; x++) {
                cin >> students[y][x].height;
            }
        }
        for (int y = 0; y < n; y++) {
            int min_heiht = 1 << 30;
            for (int x = 0; x < n; x++) {
                min_heiht = min(min_heiht, students[y][x].height);
            }
            for (int x = 0; x < n; x++) {
                students[y][x].isShortest = (min_heiht == students[y][x].height);
            }
        }
        for (int x = 0; x < n; x++) {
            int max_height = 0;
            for (int y = 0; y < n; y++) {
                max_height = max(max_height, students[y][x].height);
            }
            for (int y = 0; y < n; y++) {
                students[y][x].isTallest = (max_height == students[y][x].height);
            }
        }
        int result = 0;
        for (int y = 0; y < n; y++) {
            for (int x = 0; x < n; x++) {
                if (students[y][x].isShortest == true && students[y][x].isTallest == true) {
                    result = students[y][x].height;
                    break;
                }
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 0
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] arr = in.next().toCharArray();
            int len = arr.length;

            if (arr[0] == arr[len - 1]) {
                len--;
            }

            if (len % 2 == 1) {
                out.println("First");
            } else {
                out.println("Second");
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 30548
#include <bits/stdc++.h>
using namespace std;
const int maxn = 400, mod = 998244353;
int n, ans;
int f[maxn + 10][maxn + 10][maxn + 10];
int fac[maxn + 10], ifac[maxn + 10], inv, sum;
int a[maxn + 10], b[maxn + 10], p[maxn + 10];

inline void addto(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
inline void decto(int &x, int y) {
	x -= y; if (x < 0) x += mod;
}
inline int mul(int x, int y) {
	return 1ll * x * y % mod;
}
inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

void init() {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		fac[i] = mul(fac[i - 1], i);
		ifac[i] = fpow(fac[i], mod - 2);
	}
}

int main() {
	init();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i], &b[i]); sum += a[i];
	}
	inv = fpow(sum, mod - 2);
	for (int i = 1; i <= n; ++i) p[i] = mul(a[i], inv);
	f[0][0][0] = mod - 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= maxn; ++j)
			for (int k = 0; k <= maxn; ++k)
				if (f[i][j][k]) {
					addto(f[i + 1][j][k], f[i][j][k]);
					for (int l = 0, pw = 1; l < b[i + 1]; ++l) {
						decto(f[i + 1][j + l][k + a[i + 1]], mul(f[i][j][k], mul(pw, ifac[l])));
						pw = mul(pw, a[i + 1]);
					}
				}
	}
	for (int i = 0; i <= maxn; ++i)
		for (int j = 1; j <= maxn; ++j)
			if (f[n][i][j]) {
				int inv = fpow(j, mod - 2);
				addto(ans, mul(f[n][i][j], mul(fac[i], mul(sum, fpow(inv, i + 1)))));
			}
	printf("%d", ans);
}


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


Measured memory_bytes: 2112
n = int(input())
d = [[] for _ in range(n)]
for i in range(n):
    d[i] = list(map(int, input().split()))
counter = 0
for i in d:
    if i[0] == i[1]:
        if counter == 2:
            print("Yes")
            exit()
        else:
            counter += 1
    else:
        counter = 0
print("No")

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i=0; i<N; i++) {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for (int i=0; i<K; i++) {
        ans += p[i];
    }
    cout << ans << endl;
}

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

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

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

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

struct DPStatus
{
  unsigned score;
  unsigned value;
  DPStatus(unsigned score = 0, unsigned value = 0)
    : score(score), value(value) {}
  DPStatus operator+(unsigned s) const {
    DPStatus status(score, value);
    status.score += s;
    status.value = (status.score % 10 > 0) ? status.score : 0;
    return status;
  }
  bool operator<(const DPStatus &status) const {
    return score < status.score;
  }
};

#ifdef __DEBUG__
std::ostream& operator<<(std::ostream &os, const DPStatus &s)
{
  os << s.value;
  return os;
}
#endif

unsigned search(const std::vector<unsigned> &s)
{
  unsigned N = s.size();
  
  std::set<DPStatus> dp[2];
  
  dp[0] = std::set<DPStatus>();
  dp[0].insert(DPStatus(0, 0));
  
  dp[1] = std::set<DPStatus>();
  
  for (unsigned n = 0; n < N; ++n) {
    dp[1].clear();
    
    for (const DPStatus &status : dp[0]) {
      dp[1].insert(status);
      dp[1].insert(status + s[n]);
    }
    
    dp[0] = std::set<DPStatus>(dp[1]);
  }
  
  unsigned max = 0;
  for (const DPStatus &status : dp[0]) {
    max = std::max(max, status.value);
  }
  return max;
}

int main()
{
  unsigned N = 0;
  std::cin >> N;
  
  std::vector<unsigned> s(N);
  for (unsigned n = 0; n < N; ++n) {
    std::cin >> s[n];
  }
  
  std::cout << search(s) << std::endl;
  
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int a,b,d,r;;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d = a/b;
    r = a%b;
    f = 1.0*a/b;
    
    // insert code here...
    printf("%d %d %lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 636
using System;

namespace ALDS1_4_A
{
    public abstract class Array<T>
    {
        protected T[] array;
        public int Count { get; protected set; }
        public Array(int capacity)
        {
            array = new T[capacity];
            Count = 0;
        }
    }

    public class List<T> : Array<T>
    {
        public static int AUTOSIZE = 1024;
        public static int INCSIZE = 1024;

        private int capacity;
        private readonly int incSize;
        public List(T[] array) : base(array.Length)
        {
            incSize = INCSIZE;
            array.CopyTo(this.array, 0);    
        }

        public bool Contains(T element)
        {
            foreach (var e in array) if (e.Equals(element)) return true;
            return false;
        }

        protected void CheckCapacity()
        {
            if (Count == capacity)
            {
                var newArray = new T[capacity + incSize];
                array.CopyTo(newArray, 0);
                array = newArray;
                capacity += incSize;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var S = new List<string>(Console.ReadLine().Split(' '));
            Console.ReadLine();
            var T = Console.ReadLine().Split(' ');

            int cnt = 0;
            foreach (var a in T)
            {
                if (S.Contains(a)) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 9588
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
        int ans=0;
        for(int x=1; x*x<i; x++){
            for(int y=x; x*x+y*y+y*x<i; y++){
                for(int z=y; x*x+y*y+z*z+x*y+y*z+z*x<=i; z++){
                    if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                        if(x!=y){
                            if(y!=z){
                                ans+=6;
                            }else{
                                ans+=3;
                            }
                        }else{
                            if(y!=z){
                                ans+=3;
                            }else{
                                ans+=1;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 3560
def main():
    t = list(map(int, input().split()))
    mass = [[0]*t[1] for i in range(t[0])]
    input()
    colors = list(map(int, input().split()))

    w = 0
    h = 0
    direction = 0
    count = 0
    for color in colors:
        count += 1
        for i in range(color):
            mass[h][w] = count
            w = w + 1 if direction == 0 else w - 1
            if w == len(mass[0]) or w <= -1:
                h += 1
                direction = 1 if direction == 0 else 0
                w = 0 if direction == 0 else len(mass[0]) - 1
                continue
    for m in mass:
        print(' '.join([str(v) for v in m]))



if __name__ == '__main__':
    main()

Measured memory_bytes: 40432
#include <stdio.h>

int main(void)
{
	int p,m,c,a;
	scanf("%d %d %d",&p,&m,&c);
	if((0<=p && p<=10000) && (0<=m && m<=10000) && (0<=c && c<=10000)){
		a=p+m+c;
		printf("%d\n",a);
	}
	else{
		printf("error\n");
	}
	return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, i, j, k, x, y;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];
	bool valid = true;
	int v[4][2] = { 1, 0, 0, 1, -1, 0, 0, -1 };
	for (i = 0; i < n; i++) {
		for (j = 0; j < m;j++) 
			if (s[i][j] == '#') {
				bool matched = false;
				for (k = 0; k < 4; k++) {
					x = i + v[k][0];
					y = j + v[k][1];
					if ((x >= 0) && (x < n) && (y >= 0) && (y < m) && (s[x][y] == '#')) matched = true;
				}
				if (!matched) valid = false;
			}
	}
	if (valid) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
class UnionSet:
        def __init__(self, nmax):
            self.size = [1]*nmax
            self.id = [i for i in range(nmax+1)]
        def root(self, i):
            while i != self.id[i]:
                self.id[i] = self.id[self.id[i]]
                i = self.id[i]
            return i
        def connected(self, p, q): return self.root(p) == self.root(q)
        def unite(self, p, q):
            i, j = self.root(p), self.root(q)
            if i == j: return
            if self.size[i] < self.size[j]:
                self.id[i] = j
                self.size[j] += self.size[i]
            else:
                self.id[j] = i
                self.size[i] += self.size[j]
    # UNION-FIND library
     
def id(r, c):
        global w
        return r*w+c

mv = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]

while True:
        w, h = map(int, input().split())
        if w == 0: break
        arr = [[] for r in range(h)]
        u = UnionSet(w*h)
        for r in range(h): arr[r] = list(map(int, input().split()))
        for r in range(h):
                for c in range(w):
                        if not arr[r][c]: continue
                        for i in range(8):
                                r2, c2 = r + mv[i][0], c + mv[i][1]
                                if r2 < 0 or r2 >= h or c2 < 0 or c2 >= w or not arr[r2][c2]: continue
                                u.unite(id(r, c), id(r2, c2))
        ans = 0
        for r in range(h):
                for c in range(w):
                        if arr[r][c] and u.root(id(r, c)) == id(r, c): ans += 1
        print(ans)


Measured memory_bytes: 5880
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
const int maxn = 21;
const ll mod = 1e9 + 7;
ll dp[1 << maxn][maxn + 1];
int v[maxn][maxn];

int count_ones(int mask, int n) {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (mask & (1 << i)) > 0;
  }
  return cnt;
}

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

  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> v[i][j];
  for (int i = 0; i < (1 << n); i++) dp[i][n] = 0;
  dp[(1 << n) - 1][n] = 1;

  for (int i = (1 << n) - 2; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (count_ones(i, n) != j) continue;

      ll& ans = dp[i][j];
      ans = 0;

      for (int k = 0; k < n; k++) {
        if (i & (1 << k)) continue;
        if (!v[j][k]) continue;
        ans += dp[i | (1 << k)][j + 1];
        ans %= mod;
      }
    }
  }
  cout << dp[0][0] << endl;

  return 0;
}


Measured memory_bytes: 360704
s = input()
t = input()

ans = float("inf")
for i in range(len(s)):
    count = 0
    if i + len(t) > len(s):
        break

    for j in range(len(t)):
        if t[j] != s[i+j]:
            count+=1
    
    ans = min(ans,count)

print(ans)

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

using namespace std;

vector<int> vc;

int binary_search(int key)
{
    int left = 0, right = (int)vc.size() - 1; // 配列 a の左端と右端
    while (right >= left)
    {
        int mid = left + (right - left) / 2; // 区間の真ん中
        if (vc[mid] == key)
            return mid;
        else if (vc[mid] > key)
            right = mid - 1;
        else if (vc[mid] < key)
            left = mid + 1;
    }
    return -1;
}

int main()
{

    int N, Q, s, t;
    int count = 0;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> s;
        vc.push_back(s);
    }

    sort(vc.begin(), vc.end());
    unique(vc.begin(), vc.end());

    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> t;
        if (binary_search(t) != -1){
            count++;
        }
    }

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 3340
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  p=LF()
  p=[0]+p

  dp=[[0]*(n+1) for _ in range(n+1)]
  dp[0][0]=1

  # dp[i][j]=i個目までに表がj回出る確率
  for i in range(1,n+1):
    for j in range(n+1):
      if j>0:
        dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i]
      else:
        dp[i][j]=dp[i-1][j]*(1-p[i])

  ans=0
  for j in range(n//2+1,n+1):
    ans+=dp[n][j]
  return ans

# main()
print(main())


Measured memory_bytes: 258548
N = int(input())
t = 0
x = 0
y = 0
for i in range(N):
    t1,x1,y1 = map(int,input().split())
    if abs(x1-x) + abs(y1-y) > t1-t or (abs(x1-x) + abs(y1-y) - (t1-t)) % 2 != 0:
        print('No')
        exit(0)
    t,x,y = t1,x1,y1
print('Yes')

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sa,ni,ichi;
	cin>>n;
	if(n/100==1){
		sa = 9;
	}else{
		sa = 1;
	}
	int tmp=0;
	if(n/100==1){
		tmp = 100;
	}else{
		tmp = 900;
	}
	if((n-tmp)/10==1){
		ni = 9;
		tmp = 10;
	}else{
		ni = 1;
		tmp = 90;
	}
	if((n-tmp)%100==1){
		ichi = 9;
	}else{
		ichi = 1;
	}
	int res = sa*100+ni*10+ichi;
	cout<<res<<endl;
}


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

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
    for(int u : to[v]) {
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; -- b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    REP(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    /*
    cout << "test" << endl;
    for (int u : to[0]) {
        cout << u << endl;
    }
    */
    dfs(0);
    REP(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 3e3 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
string s, t;
int memo[N][N];
int solve(int i = 0, int j = 0)
{
    if(i == sz(s) || j == sz(t))
        return 0;
    int &ret = memo[i][j];
    if(~ret)
        return ret;
    ret = 0;
    if(s[i] == t[j])
        ret = solve(i + 1, j + 1) + 1;
    else
        ret = max(solve(i + 1, j), solve(i, j + 1));
    return ret;
}
void build(int i = 0, int j = 0)
{
    if(i == sz(s) || j == sz(t))
        exit(0);
    int ret = memo[i][j];
    if(s[i] == t[j])
    {
        cout << s[i];
        build(i + 1, j + 1);
    }
    else
    {
        if(ret == solve(i + 1, j))
            build(i + 1, j);
        else
            build(i, j + 1);
    }
}
int main()
{
    MuhammedAly
    mem(memo, -1);
    cin >> s >> t;
    solve();
    build();
    return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+100;


int main(){
	fastio;
	ll tc,n,m,a,b,c,d;
	cin>>a>>b>>c>>d;
	n=0;
	while(a>0 && c>0){
		if(n&1) a-=d;
		else c-=b;
//		cout<<a<<" "<<c<<endl;
		n++;
	}
	if(a<=0) cout<<"No\n";
	else if(c<=0) cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;

typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;

ll n, m, k, t;

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n;
    cout << 360 / __gcd(n, 360LL);
    return 0;
}

Measured memory_bytes: 3604
n,m,l = list(map(int,input().split()))
matrix_a = [list(map(int,input().split())) for i in range(n)]
matrix_b = [list(map(int,input().split())) for i in range(m)]
matrix_b = [list(x) for x in zip(*matrix_b)]

for i in range(n):
    line = []
    for j in range(l):
        line.append(sum([x*y for (x,y) in zip(matrix_a[i],matrix_b[j])]))
    print(' '.join(list(map(str,line))))

Measured memory_bytes: 8664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
const ll INF=1e18,MOD=1e9+7;
bool comp(ll a,ll b){
    return abs(a)>abs(b);
}
int main(){
    ll m,ans;
    cin>>m;
    vector<ll>a(m);
    priority_queue<ll,vector<ll>>nega;
    priority_queue<ll,vector<ll>,greater<ll>>posi;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),comp);
    for(int i=0;i<m;i++){
        if(a[i]>0)posi.push(a[i]);
        else nega.push(a[i]);
    }
    vector<ll>ans_f(m-1),ans_s(m-1);
    ll now=0;
    for(int i=0;i<m-1;i++){
        bool flag=posi.size()<nega.size()?true:false;//結果を正にするか負かを保持
        if(flag){
            ll fir,sec;
            if(posi.size()==1&&nega.size()==1){
                fir=posi.top();posi.pop();
                sec=nega.top();nega.pop();
                ans=fir-sec;
                ans_f[now]=fir;
                ans_s[now]=sec;
                now++;
                //cout<<fir<<" "<<sec<<endl;
            }
            else if(posi.size()==0){//posiが0
                fir=nega.top();nega.pop();
                sec=nega.top();nega.pop();
                ll push_num=fir-sec;
                ans_f[now]=fir;
                ans_s[now]=sec;
                now++;
                //cout<<fir<<" "<<sec<<endl;
                posi.push(push_num);
            }
            else{
                fir=posi.top();posi.pop();
                sec=nega.top();nega.pop();
                ll push_num=fir-sec;
                ans_f[now]=fir;
                ans_s[now]=sec;
                now++;
                //cout<<fir<<" "<<sec<<endl;
                posi.push(push_num);
            }
            

        }
        else{
            int fir,sec;
            //cout<<posi.size()<<" "<<nega.size()<<endl;
            if(posi.size()==1&&nega.size()==1){
                fir=posi.top();posi.pop();
                sec=nega.top();nega.pop();
                ans=fir-sec;
                ans_f[now]=fir;
                ans_s[now]=sec;
                now++;
                //cout<<fir<<" "<<sec<<endl;
            }
            else if(nega.size()==0){//negaが0
                fir=posi.top();posi.pop();
                sec=posi.top();posi.pop();
                ll push_num=sec-fir;
                ans_f[now]=sec;
                ans_s[now]=fir;
                now++;
                //cout<<sec<<" "<<fir<<endl;
                nega.push(push_num);
            }
            else{
                fir=posi.top();posi.pop();
                sec=nega.top();nega.pop();
                ll push_num=sec-fir;
                ans_f[now]=sec;
                ans_s[now]=fir;
                now++;
                //cout<<sec<<" "<<fir<<endl;
                nega.push(push_num);
            } 
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<m-1;i++)cout<<ans_f[i]<<" "<<ans_s[i]<<endl;
}

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
    while(x!=parent[x]){
        parent[x] = parent[parent[x]];
        x = parent[x];
    }
    return x;
}

void sunion(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx != ry){
        if(Size[rx] > Size[ry]){
            parent[ry] = parent[rx];
            Size[rx] += Size[ry];
        }
        else{
            parent[rx] = parent[ry];
            Size[ry] += Size[rx];
        }
    }
}
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        ll n,k;
        cin >> n >> k;
        ll ans = 0LL;
        ll lsum=0,rsum=0;
        ll i=0,j=n;
        for(;i<k;i++,j--){
            lsum += i;
            rsum += j;
        }
        for(ll z=k;z<=n+1;z++){
            // cout << lsum << " " << rsum << "\n";
            ll a = rsum-lsum+1;
            ans = (ans + a)%INF;
            
            lsum += i;
            i++;
            
            rsum += j;
            j--;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001


int main(){

int  x,y,z;
scanf("%d %d %d",&x,&y,&z);

if(x%(y+z)>=z)printf("%d",x/(y+z));
else printf("%d",x/(y+z)-1);

return 0;
}


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

int main(void){
    int n,T; cin >> n >> T;
    int min=10000;
    for(int i=0; i<n; i++){
        int c,t; cin >> c >> t;
        if(t<=T && c<min) min=c;
    }

    if(min==10000) cout << "TLE" << endl;
    else cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll D;
    cin >> D;
    vector<ll> C(26);
    vector<ll> T(D);
    vector<ll> last(26);
    REP(i,26)cin >> C[i];
    vector<vector<ll>> S(D,vector<ll>(26));
    REP(i,D){
        REP(l,26)cin >> S[i][l];
    }
    ll score = 0;
    REP(i,D){
        ll scores = 0;
        REP(l,26){
            if(scores < (i-last[l]) * C[l]+S[i][l]){
                scores = (i-last[l]) * C[l]+S[i][l];
                T[i] = l;
            }
        }
        last[T[i]] = i+1;
        score += S[i][T[i]];
        REP(l,26){
            score -= C[l] * (i+1 -last[l]);
        }
    }
    REP(i,D)cout << T[i]+1 << "\n";
}

Measured memory_bytes: 3780
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
	}
	vector<int> fact(1 << N), inv(1 << N), factinv(1 << N);
	fact[0] = factinv[0] = 1;
	for (int i = 1; i < 1 << N; ++i) {
		fact[i] = 1LL * fact[i - 1] * i % mod;
		inv[i] = (i == 1 ? 1 : 1LL * inv[mod % i] * (mod - mod / i) % mod);
		factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	}
	function<int(int, int)> comb = [&](int n, int k) {
		return n < k ? 0 : 1LL * fact[n] * factinv[k] % mod * factinv[n - k] % mod;
	};
	sort(A.begin(), A.end(), greater<int>());
	vector<int> dp(1 << N);
	dp[0] = 1;
	for (int i = 0; i < M; ++i) {
		for (int j = (1 << N) - 1; j > 0; --j) {
			for (int k = 0; k < N; ++k) {
				if (!((j >> k) & 1)) continue;
				dp[j] = (dp[j] + 1LL * dp[j - (1 << k)] * comb((1 << N) - A[i] - j + (1 << k), (1 << k) - 1) % mod * fact[1 << k]) % mod;
			}
		}
	}
	vector<int> fl(1 << N);
	int ret = 0;
	for (int i = 0; i < 1 << N; ++i) {
		if (i >= 1) fl[i] = fl[i >> 1] ^ (i & 1);
		int val = 1LL * dp[i] * fact[(1 << N) - i - 1] % mod;
		if (fl[i] == 0) ret = (ret + val) % mod;
		else ret = (ret + mod - val) % mod;
	}
	cout << 1LL * ret * (1 << N) % mod << '\n';
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class B105 {
public:
	void solve(istream& in, ostream& out) {
	    int n; in >> n;
	    if(n < 105) out << 0 << endl;
	    else if(105 <= n && n < 135) out << 1 << endl;
	    else if(135 <= n && n < 165) out << 2 << endl;
	    else if(165 <= n && n < 189) out << 3 << endl;
	    else if(189 <= n && n < 195) out << 4 << endl;
	    else if(195 <= n) out << 5 << endl;
	}
};

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

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

typedef struct node {
	struct node *next, *prev;
	int key;
} LINKEDLIST;

void insert(int key);
void delete(int key);
void deleteFirst();
void deleteLast();
void printList();

int node_cnt = 0;
LINKEDLIST *head = NULL;
LINKEDLIST *tail = NULL;

int main(void)
{
	int n;								// ????????°
	scanf("%d", &n);

	char command[12];					// ?????????????´?
	int key, i;
	for (i=0; i<n; i++) {
		scanf("%s", command);
		if (command[0] == 'i') {		// command == "insert"
			scanf("%d", &key);
			insert(key);
		} else if (command[6] == 'F') {	// command == "deleteFirst"
			deleteFirst();
		} else if (command[6] == 'L') {	// command == "deleteLast"
			deleteLast();
		} else {						// command == "delete"
			scanf("%d", &key);
			delete(key);
		}
	}

	printList();

	return 0;
}

// add a new node at the head of the list
void insert(int key) {
	LINKEDLIST *node;
	node = malloc(sizeof(LINKEDLIST));
	(*node).key = key; 					// same as "node->key = key;"
	(*node).next = head;				// head contains the non-renewed value
	(*node).prev = NULL;
	if (head != NULL) {					// if list was not empty
		(*((*node).next)).prev = node;
	} else {
		tail = node;
	}
	head = node;
	node_cnt++;
}

void deleteFirst() {
	LINKEDLIST *point = head;
	if ((*head).next != NULL) {
		head = (*head).next;
		(*head).prev = NULL;
	} else {
		head = NULL;
		tail = NULL;
	}
	free(point);
	node_cnt--;
}

void delete(int key) {
	int i;
	if (head == NULL) return;						// return if there is no entry in list
	LINKEDLIST *point = head;
	for (i=0; i<node_cnt; i++) {
		if ((*point).key == key) {
			if ((*point).prev == NULL) {			// if the node containing the key is the first node
				deleteFirst();
			} else if ((*point).next == NULL) {		// if the node containing the key is the last node
				deleteLast();
			} else {
				(*((*point).prev)).next = (*point).next;
				(*((*point).next)).prev = (*point).prev;
				free(point);
				node_cnt--;
			}
			break;
		} else {
			point = (*point).next;
		}
	}
}

void deleteLast() {
	/*
	int i;
	LINKEDLIST *point = head;
	for (i=0; i<node_cnt-1; i++) {
		point = (*point).next;
	}
	if ((*point).prev != NULL)
		(*((*point).prev)).next = NULL;
	else
		head = NULL;
	free(point);
	node_cnt--;
	*/
	if ((*tail).prev != NULL) {
		(*((*tail).prev)).next = NULL;
		tail = (*tail).prev;
	} else {
		head = NULL;
		tail = NULL;
	}
	node_cnt--;
}

void printList() {
	int i;
	LINKEDLIST *point = head;
	for (i=0; i<node_cnt; i++) {
		printf("%d", (*point).key);
		if (i<node_cnt-1)
			putchar(' ');
		point = (*point).next;
	}
	putchar('\n');
}

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

int main() {
  int a,b;cin>>a>>b;
  int ans = (a+b)%24;
  // cout << (ans?"YES":"NO") << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, stones = map(int, readline().split())
a = list(map(int,readline().split()))
dp = [-1]*stones
def can_or_cant(rem, chance):
    if rem == 0:
        return True
    if dp[rem] != -1:
        return dp[rem]
    den = 2 if chance == 1 else 2
    for j in range(len(a)):
        if rem - a[j] >= 0 and can_or_cant(rem-a[j], den):
            dp[rem] = False
            return False
    dp[rem] = True
    return True


res = False
for i in range(n):
    if can_or_cant(stones - a[i], 1):
        res = True
        break
print("First" if res else "Second")



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

long long sum_xor(long long x){
    int m_x=x%4;
    long long sum=0;
    for(int i=0;i<=m_x;i++){
        sum=sum^(x-m_x+i);
    }
    return sum;
}

int main(){
    long long A,B; cin >> A >> B;
    long long ans=sum_xor(A-1)^sum_xor(B);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
 
    public static void main(String[] args){
        
        /*
        InputStreamReader is = new InputStreamReader(System.in);       
        BufferedReader br = new BufferedReader(is);     
        */
        Scanner scan = new Scanner(System.in);
 
 
        int a,b;
        a = Integer.parseInt(scan.next());   
        b = Integer.parseInt(scan.next());
        int ans;
        ans = a;
        
        if(a > b){
            ans--;
        }
 
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
W = list(map(int, input().split()))

print(min(abs(sum(W[:i]) - sum(W[i:])) for i in range(1, N)))



Measured memory_bytes: 38512
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	if(A >= 13){
		myout(B);
	}else if(A <= 12 && A >= 6){
		myout(B / 2);
	}else{
		myout(0);
	}
}


Measured memory_bytes: 30068
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int main() {
    double pi = acos(-1);
    double n;
    cin>>n;
    cout<<2*pi*n;
}


Measured memory_bytes: 3792
import math
prime = [2, 3, 5]
for i in range(7, 1001, 2):
  sqi = math.sqrt(i)
  for j in prime:
    if i % j == 0:
      break
    if sqi < j:
      prime.append(i)
      break

def legendre(n, p):
  if n == 0:
    return 0
  else:
    return n // p + legendre(n // p, p)

N = int(input())
power_of_prime = [legendre(N, p) for p in prime]

cnt = 1
for i in range(len(power_of_prime)):
  cnt = (cnt * (power_of_prime[i] + 1)) % 1000000007
print(cnt)


Measured memory_bytes: 9208
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<vector<char>> c(3, vector<char>(3));

	for (Int i = 0; i < 3; i++) {
		for (Int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	string ans = "";
		ans+=c[0][0];
		ans += c[1][1];
		ans += c[2][2];

		cout << ans << "\n";

}


Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split()) 

pathes = {i: set() for i in range(1, n + 1)}
for _ in range(m):
  ai, bi = map(int, input().split()) 
  pathes[ai].add(bi)
  pathes[bi].add(ai)

queue = deque()
queue.append(1)

ans = [None] * n 

for _ in range(n):
  if len(queue) == 0:
    break;
  i = queue.popleft()
  next_room = pathes[i]
  for j in next_room:
    if ans[j-1] == None:
      ans[j-1] = str(i)
      queue.append(j)

ans[0] = "Yes"

print("\n".join(ans))


Measured memory_bytes: 77648
weather = ("Sunny", "Cloudy", "Rainy")

def indexForcast(present_index = 0):
    if present_index == len(weather) - 1:
        present_index = -1
    return present_index + 1

today_weather = input()

present_index = weather.index(today_weather)

weather_forcast = weather[indexForcast(present_index)]
print(weather_forcast)

Measured memory_bytes: 2940