akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    cin>>n;
    int m;
    cin>>m;
    vector<int>p(m+1);
    vector<string> s(m+1);
    vector<bool> ac(n+1,false);
    vector<int> count(n+1,0);
    ll sum=0;
    ll acc=0;
    rep(i,m){
        cin>>p[i]>>s.at(i);
        if(s[i]=="WA"&&ac[p[i]]==false)count.at(p[i])++;
        else if(s[i]=="AC"&&ac[p[i]]==false){sum+=count[p[i]];ac[p[i]]=true;acc++;}
        else if(ac[p[i]]==true)continue;

    }
    cout<<acc<<" "<<sum<<endl;
    return 0;
}




Measured memory_bytes: 6528
import sys
input = sys.stdin.readline

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        stack = []
        while self.parent_or_size[a] >= 0:
            stack.append(a)
            a = self.parent_or_size[a]
        for i in stack:
            self.parent_or_size[i] = a
        return a

    def size(self, a):
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


Measured memory_bytes: 75608
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] x = new int[n];
			int[] y = new int[n];

			for (int i = 0; i < n; i++) {
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}

			double tmp = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					long l = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
					tmp += Math.sqrt(l);
				}
			}

			System.out.println(tmp - (tmp * (rootCount(n) - (n - 1)) / rootCount(n)));
		}
	}

	private static int rootCount(int n) {
		int result = 0;
		if (n <= 1) {
			return 0;
		}
		int tmp = 1;
		for (int i = 1; i < n; i++) {
			result += tmp;
			tmp++;
		}
		return result;
	}

}


Measured memory_bytes: 23764
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
  n,m=map(int,input().split())
  uf=UnionFind(n)
  now=n*(n-1)//2
  g=[]
  ans=[now]
  now=n*(n-1)//2
  for i in range(m):
    a,b=map(int,input().split())
    g.append((a-1,b-1))
  #print(g)
  g=g[::-1]
  for a,b in g:
    now-=uf.size(a)*uf.size(b)*(1-uf.same(a,b))
    ans.append(now)
    uf.union(a,b)
  ans=ans[:-1][::-1]
  print(*ans,sep="\n")
  
  
  
  
  
  
  
  
  
  
  
  
  
  
if __name__ == "__main__":
	main()

Measured memory_bytes: 25348
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int A, B, M;
	cin >> A >> B >> M;

	vector<int> a(A), b(B), x(M), y(M), c(M);
	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
		c[i];
	}

	int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
	for (int i = 0; i < M; i++) {
		int tmp = a[x[i]] + b[y[i]] - c[i];
		ans = min(ans, tmp);
	}

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


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int a, b, c; cin >> a >> b >> c;
    int n = 0;
    while (1) {
        n += a;
        if (n % b == c) {
            cout << "YES\n";
            return 0;
        }
        else if (n % b == 0) {
            cout << "NO\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int A, B;
  int i;
  int sum = 0;

  cin >> A;
  cin >> B;

  for(i=0; i<2; i++){
    if(A<B){
    sum += B;
    B--;
    }
    else{
      sum += A;
      A--;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;

int main(){
	int n,d,i,j,k,ans = 0;
	cin >> n;
	cin >> d;
	double x[n][d];
	double y[n][n];
	for(i = 0; i < n; i++){
		for(j = 0; j < d; j++){
			cin >> x[i][j];
		}
	}

	for(i = 0; i < n; i++){
		for(j = i+1; j < n; j++){
			y[i][j] = 0;
			for(k = 0; k < d; k++){
				y[i][j] = y[i][j] + std::pow(x[i][k] - x[j][k], 2.0);
			}
			y[i][j] = std::sqrt(y[i][j]);
			if(ceil(y[i][j]) == floor(y[i][j])){
				ans++;
			}
		}
	}

	cout << ans;
	return 0;
}


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

int D[2][6];
void spin(int n,char c)
{
  if(c=='E'){
    swap(D[n][0],D[n][3]);swap(D[n][3],D[n][5]);swap(D[n][5],D[n][2]);
  }
  else if(c=='W'){
    swap(D[n][0],D[n][2]);swap(D[n][2],D[n][5]);swap(D[n][5],D[n][3]);
  }
  else if(c=='S'){
    swap(D[n][0],D[n][1]);swap(D[n][0],D[n][4]);swap(D[n][4],D[n][5]);
  } 
  else if(c=='N'){
    swap(D[n][0],D[n][1]);swap(D[n][1],D[n][5]);swap(D[n][5],D[n][4]);
  }
}
int main()
{
  char SWS[10]={"SSSSWSSSS"};
  for(int i=0;i<6;i++)cin>>D[0][i];
  for(int i=0;i<6;i++)cin>>D[1][i];
  for(int i=0;i<10;i++){
    if(D[0][1]==D[1][1])break;
    spin(1,SWS[i]);
  }
  if(D[0][1]!=D[1][1] || D[0][4]!=D[1][4])cout<<"No"<<endl;
  else{
    for(int i=0;i<4;i++){
      if(D[0][0]==D[1][0] &&D[0][2]==D[1][2] &&D[0][3]==D[1][3] &&D[0][5]==D[1][5]){
	cout<<"Yes"<<endl;
	break;
      }
      spin(1,'W');
      if(i==3)cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>



int main(void) {

    int H, W;

    while(1) {

        scanf("%d %d", &H, &W);

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                
                if(i==0 ||i==H-1 || j==0 || j==W-1){
                    printf("#");
                }else{
                    printf(".");
                }
                
                
            }
            printf("\n");
        }


        if (H == 0 & W == 0) {
            break;
        }
        printf("\n");
    }


    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int w[10],k[10];
  for(int i = 0 ; i < 10 ; i++)cin >> w[i];
  for(int i = 0 ; i < 10 ; i++)cin >> k[i];
  sort(w,w+10);
  sort(k,k+10);

  cout << w[9] +w[8] +w[7] << " " << k[9] +k[8] +k[7] << endl; 

}

Measured memory_bytes: 1176
def vc(p,q):
    return[p[0]-q[0],p[1]-q[1]]

def cross(u,v):
    return(u[0]*v[1]-u[1]*v[0])

n = int(input())
v = []
for _ in range(n):
    x0,y0 = map(int,input().split())
    v.append([x0,y0])
flag = True
for i in range(n-2):
    e_i = vc(v[i+1],v[i])
    e_nxt = vc(v[i+2],v[i+1])
    if cross(e_i,e_nxt)<0:
        flag = False
e_i = vc(v[-1],v[-2])
e_nxt = vc(v[0],v[-1])
if cross(e_i,e_nxt)<0:
    flag = False
e_i = vc(v[0],v[-1])
e_nxt = vc(v[1],v[0])
if cross(e_i,e_nxt)<0:
    flag = False
if flag:
    print(1)
else:
    print(0)
        
    



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

long long f[20010],mxa,ans=0x3f3f3f3f3f3f3f3f;
void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B){
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    for(int i=0;i<N;i++)
    {
        for(int j=A[i];j<=H+mxa;j++)
            f[j]=min(f[j],f[j-A[i]]+B[i]);
    }
    for(long long i=H;i<=H+mxa;i++)
        ans=min(ans,f[i]);
    cout<<ans<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        mxa=max(mxa,A[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>

#define MAX_NUM 24

#define SQUARE(x) ((x) * (x))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

int n;
int x[MAX_NUM];
int y[MAX_NUM];
int r[MAX_NUM];
int c[MAX_NUM];

int overlap[MAX_NUM];

// bit
// i番の円盤がない（取り除いた）とき、LSBから数えてi桁目を1とする
char maxRemovableNum[1 << MAX_NUM];
bool isVisited[1 << MAX_NUM];

void init()
{
	int i;
	for (i = 0; i < 1 << MAX_NUM; ++i)
	{
		maxRemovableNum[i] = 0;
		isVisited[i] = false;
	}
}

bool overlapBetween(int a, int b) { return SQUARE(r[a] + r[b]) > SQUARE(x[a] - x[b]) + SQUARE(y[a] - y[b]); }

bool exist(int a, long stateNumber) { return (stateNumber & 1L << a) == 0L; }

bool isTop(int a, long stateNumber)
{
	int i;
	for (i = 0; i < a; ++i)
	{
		if (!exist(i, stateNumber)) { continue; }
		if (overlap[a] & 1 << i) { return false; }
	}

	return true;
}

char solve(long stateNumber)
{
	if (isVisited[stateNumber]) { return maxRemovableNum[stateNumber]; }

	int i, j;
	for (i = 0; i < n; ++i)
	{
		if (!exist(i, stateNumber) || !isTop(i, stateNumber)) { continue; }

		for (j = i + 1; j < n; ++j)
		{
			if (!exist(j, stateNumber) || !isTop(j, stateNumber) || c[i] != c[j]) { continue; }

			maxRemovableNum[stateNumber] = MAX(maxRemovableNum[stateNumber],
			                                   (char)(solve(stateNumber | 1 << i | 1 << j) + 2));
		}
	}

	isVisited[stateNumber] = true;
	return maxRemovableNum[stateNumber];
}

int main()
{
	while (true)
	{
		//region DataInput
		scanf("%d", &n);
		if (n == 0) { break; }

		init();

		int i, j;
		for (i = 0; i < n; ++i)
		{
			scanf("%d %d %d %d", &x[i], &y[i], &r[i], &c[i]);

			overlap[i] = 0;
			for (j = 0; j < i; ++j)
			{
				if (overlapBetween(i, j)) { overlap[i] |= 1 << j; }
			}
		}
		//endregion

		printf("%d\n", solve(0L));
	}

	return 0;
}


Measured memory_bytes: 34564
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    cout<<(double)(6.28318530717958623200*t);
    return 0;
}

Measured memory_bytes: 3740
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

long long lcm(unsigned long long a, unsigned long long b) {
	return ((a * b) / gcd(a, b));
}

int main() {

	long long a, b, c, d; cin >> a >> b >> c >> d;
	// cout << b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - (b / lcm(c , d)) + ((a - 1) / lcm(c , d)));
	long long tot = b - a + 1;
	long long c_mult = (b / c) - ((a - 1) / c);
	long long d_mult = (b / d) - ((a - 1) / d);
	long long cd_mult = (b / lcm(c , d)) - ((a - 1) / lcm(c , d));

	long long c_or_d_mult = c_mult + d_mult - cd_mult;

	long long c_nor_d_mult = tot - c_or_d_mult;

	cout << c_nor_d_mult;

	return 0;
}

Measured memory_bytes: 3200
X, Y = map(int, input().split())

bird_only = 2 * X
if bird_only <= Y:
    if (Y%2) == 0:
        r = (Y-bird_only) / 2
        if r <= X:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	sort(all(v));
	dump(v);
	unordered_set<int> st;
	int cnt = 0;
	rep(i, 0, N) {
		if (st.count(v[i]))cnt++;
		st.insert(v[i]);
	}
	dump(cnt);
	cout << N - cnt - (cnt % 2) << endl;
	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  if(a == b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		
		//????????£????????§??´??°?????????????????????
	    Scanner sc = new Scanner(System.in);
	    String s1 = sc.next();
	    int a = Integer.parseInt(s1);
	    String s2 = sc.next();
	    int b = Integer.parseInt(s2);
	    String s3 = sc.next();
	    int c = Integer.parseInt(s3);
	    int sum = 0;
	    
	    //??´??°a???b???c????????¶??????????????????????????????????????????a<=b??§??????????¢????
	    if(1 <= a && a <= 10000){
	    	if(1 <= b && b <= 10000){
	    		if(1 <= c && c <= 10000){
	    			if(a <= b){
	    					
	    			    //c?´???°???a??????b?????§?????????????????????????¨????
	    				for(int i = a; i <= b; i++){
	    					if(c % i == 0){
	    					    sum++;
	    					}
	    				}
	    				
	    				//?´???°?????°?????¨???
	    				System.out.println( sum );
	    			}
	    		}
	    	}
	    }
	}
}

Measured memory_bytes: 17320
#!/usr/bin/env python3

import re


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    T = input()

    S = S.replace("?",".")

    pos = []
    for i in range(0,len(S)-len(T)+1):
        s =  S[i:i+len(T)]
        m = re.match(s,T)
        if m: 
            pos.append(i)

    if len(pos) == 0:
        print("UNRESTORABLE")
        return

    S = S.replace(".","a")
    si = max(pos)

    print(S[0:si] + T + S[si+len(T):])




    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<vector>

int main(){
	int n, k;
	std::vector<int> aList;
	std::vector<bool> dpList;

	std::cin>>n>>k;
	aList.resize(n);
	dpList.resize(k+1,false);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<k+1; i++){
		bool canWin= false;
		for(int j=0; j<n; j++){
			if(i- aList[j] < 0)
				continue;

			if(!dpList[i-aList[j]])
				canWin=true;
		}

		if(canWin)
			dpList[i]=true;
	}

	if(dpList[k])
		std::cout<<"First"<<std::endl;
	else
		std::cout<<"Second"<<std::endl;		

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int inputA, inputB, inputC;

    scanf("%d %d %d", &inputA, &inputB, &inputC);

    // Checks if all numbers have the same value
    if (inputA == inputB && inputB == inputC)
    {
        printf("No \n");
    }
    else if (inputA != inputB && inputB != inputC && inputA != inputC)
    {
        printf("No \n");
    }
    else
    {
        printf("Yes \n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int m, g, a, b, n;
	while(cin >> m && m)
	{	
		vector<vint> dp(m, vint(1001, 0));

		rep(i, m)
		{
			cin >> a >> b;
			
			if(i == 0) 
			{
				for(int j = 0; j <= b && a * j <= 1000; j++)
				{
					dp[i][a * j]++;
				}
			}
			else
			{
				for(int j = 0; j <= b; j++)
				{
					for(int k = 0; k + a * j <= 1000; k++)
					{
						dp[i][k + a * j] += dp[i - 1][k];
					}
				}
			}
		}
				
		cin >> g;
		rep(i, g)
		{
			cin >> n;
			cout << dp[m-1][n] << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void) {
	int N, M, K[30] = {}, A, count[31] = {}, ans = 0;
	scanf("%d%d", &N,&M);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &K[i]);
		for (int j = 0; j < K[i]; j++)
		{
			scanf("%d",&A);
			count[A]++;
			if (j + 1 == K[i])
			{
				for (int l = 0; l < M; l++)
				{
					if (count[l+1] == N)ans++;
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 998244353;

int n, x, y;
vector <int> G[2020];
int dpd[2020];
int dt[2020];
int32_t main()
{
    usecppio
    cin >> n >> x >> y;
    for (int i = 1; i<n; i++)
    {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    for (int i = 1; i<=n; i++)
    {
        memset(dt, 0x7f, sizeof(dt));
        queue <int> q;
        q.push(i);
        dt[i] = 0;
        while(!q.empty())
        {
            int p = q.front();
            q.pop();
            for (auto it:G[p])
            {
                if (dt[it]==INF)
                {
                    dt[it] = dt[p]+1;
                    q.push(it);
                }
            }
        }
        for (int j = 1; j<=n; j++)
        {
            dpd[dt[j]]++;
        }
    }
    for (int i = 1; i<n; i++)
    {
        cout << dpd[i]/2 << '\n';
    }
}

Measured memory_bytes: 384
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    inf = float('inf')
    n = int(input())
    a = []

    for i in range(n):
        line = [int(i) for i in input().split()]
        line = [i if i != -1 else inf for i in line]
        a.append(line)

    
    checked = [False] * n
    d = [inf] * n
    d[0] = 0
    checked[0] = True
    ans = 0
    nxt = 0

    for i in range(n - 1):
        for j in range(n):
            if a[nxt][j] < d[j]:
                d[j] = a[nxt][j]

        min_w = inf
        min_n = 0

        for j in range(n):
            if not checked[j] and d[j] < min_w:
                min_n = j
                min_w = d[j]

        checked[min_n] = True
        nxt = min_n
        ans += min_w

    # debug(d, locals())
    print(ans)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 7872
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int a[10],n;
int32_t main() {
	n=5;
	int r=0,sum=0,i;
	
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%10==0)
			sum+=a[i];
		else{ sum+=a[i]/10*10+10;
		r=max(r,10-a[i]%10);
		}
	}
	cout<<sum-r;
	
}
						

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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N, M;    // input

  int i, j;     // subscript

  int s_cnt, t_cnt;
  int kinds;
  int max; // output


  /* Input, Array_Proclamation */
  cin >> N;
  vector<string> s(N);

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

  cin >> M;
  vector<string> t(M);

  for(i=0; i<M; i++)
  {
    cin >> t.at(i);
  }

  string types;
  vector<int> money(N);


  /* Initialize */
  kinds = 0;
  max   = 0;

  /* Calculation */

  while(s.size() != 0)
  {

    s_cnt = 0;
    t_cnt = 0;

    types = s.at(0);

    for(j=0; j<N; j++)
    {

      if(s.size() == 0)
      {
        break;
      }
      else if(types == s.at(j))
      {
      
        swap(s.at(j), s.at(N-1));
        s.pop_back();
        j--;
        N--;

        s_cnt++;

      }

    }

    for(j=0; j<M; j++)
    {

      if(t.size() == 0)
      {
        break;
      }
      else if(types == t.at(j))
      {

        swap(t.at(j), t.at(M-1));
        t.pop_back();
        j--;
        M--;

        t_cnt++;
        
      }

    }

    money.at(kinds) = s_cnt - t_cnt;
    kinds++;

  }
  

  /* Output */
  for(i=0; i<kinds; i++)
  {
    if( max < money.at(i) )
    {
      max = money.at(i);
    }
  }

  cout << max << endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c and c <= b) cout << "Yes" << endl;
	else if (b <= c and c <= a) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n) { cin >> a[i]; }
	ll yen = 1000;
	ll kabu = 0;
	REP(i, n) {
		if(i == n - 1) {
			yen += kabu * a[i];
			kabu = 0;
		} else if(a[i + 1] > a[i]) {
			kabu += yen / a[i];
			yen %= a[i];
		} else if(a[i + 1] < a[i]) {
			yen += kabu * a[i];
			kabu = 0;
		}
	}
	cout << yen << endl;
	return 0;
}


Measured memory_bytes: 3624
from collections import deque
N = int(input())
edges = [[] for _ in range(N + 1)]
for edge_idx in range(1, N):
    a, b = map(int, input().split())
    edges[a].append([edge_idx, b])
    edges[b].append([edge_idx, a])

used_edges = set()
colors = [1 for _ in range(1, N + 1)]
used_colors = [set() for _ in range(N + 1)]
stack = deque([[edges[1], 0]])
max_col = 1

while stack:
    edge_info, parent_node_idx = stack.pop()
    cur_color = 1
    for edge_idx, node_idx in edge_info:
        if edge_idx in used_edges: continue
        while cur_color in used_colors[node_idx] or cur_color in used_colors[parent_node_idx]:
            cur_color += 1
        used_colors[node_idx].add(cur_color)
        colors[edge_idx] = cur_color
        stack.append([edges[node_idx], node_idx])
        used_edges.add(edge_idx)
        max_col = max(max_col, cur_color)
        cur_color += 1

print(max_col)
for c in colors[1:]:
    print(c)


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

int main(){
  int a[3][3];
  int d[3][3];
  rep(i,3)rep(j,3) cin >> a[i][j];
  int n;
  cin >> n;
  
  rep(i,n) {
    int b;
    cin >> b;
    rep(i,3)rep(j,3) if(a[i][j] == b) d[i][j] = 1;
  }
  
  bool w = false;
  rep(i,3){
    int ans = 0;
    rep(j,3) ans += d[i][j];
    if(ans == 3) w =true;
  }
  
  rep(i,3){
    int ans = 0;
    rep(j,3) ans += d[j][i];
    if(ans == 3) w = true;
  }
  { int ans =0;
    rep(j,3)ans += d[j][j];
    if(ans == 3) w = true;
  }
  {
    int ans = 0;
    rep(j,3)ans += d[j][2-j];
    if(ans == 3) w = true;
  }
  puts(w ? "Yes":"No");
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),K=sc.nextInt();
        long[] sum = new long[n+1], a = new long[n+1], posi = new long[n+1];
        for(int i=1;i<=n;i++){
            a[i] = sc.nextLong();
            sum[i] = sum[i-1]+a[i];
            posi[i] = posi[i-1]+Math.max(0,a[i]);
        }
        long ans = 0;
        for(int start =1; start+K-1<=n;start++){
            int end = start+K-1;
            long cur = Math.max(0,sum[end]-sum[start-1]);
            cur += posi[start-1]+posi[n]-posi[end];
            ans = Math.max(ans,cur);
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

const int M = 1e9 + 7;

void solve() {
    int n;
    read(n);
    vt<int> a(n);
    read(a);
    
    vt<int> pre(n + 1);
    FOR(n) {
        pre[i + 1] = (pre[i] + a[i]) % M;
    }
    
    int ans = 0;
    FOR(n) {
        int x = (a[i] * pre[i]) % M;
        ans = (ans + x) % M;
    }
    print(ans);
    
    
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int count = 0;
  int ans = 0;
  rep(i,sz(s)) {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      count++;
    }else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        cnt+=(r-l+1);
    }
    cout<<cnt<<endl;
}


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

int main()
{
    float a,s,d,f,g,h,j,k;
    float q,w,e,r;
        int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a>>s>>d>>f>>g>>h>>j>>k;
        q=d-a;
    w=f-s;
    e=j-g;
    r=k-h;
        float key=q*r-w*e;
        if(!key)cout<<"YES"<<endl;
        else  cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, dem = 0;
    cin >> n;
    char a[n], b[n];
    for(int i = 1 ; i <= n/2;i++)
    {
        cin >> a[i];
    }
    for(int i = 1 ; i <= n/2 ;i++)
    {
        cin >> b[i];
    }
    if(n % 2 != 0)
    {
        cout << "No";
        return 0;
    }
    for(int i = 1; i <= n/2;i++)
    {
        if(a[i] == b[i])
            dem++;
//        cout << a[i] <<" "<<b[j];
//        cout << endl;
    }
//    cout << dem;
    if(dem == n/2)
    {
        cout << "Yes";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
# Binary Search Tree 2

import sys
sys.setrecursionlimit(10**6)


class Node():
    __slots__ = ['key', 'parent', 'left', 'right']

    def __init__(self, key=None, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

    def __repr__(self):
        k = str(self.key)
        p = str(self.parent.key) if self.parent else 'None'
        l = str(self.left.key) if self.left else 'None'
        r = str(self.right.key) if self.right else 'None'
        s = "<Node %s: parent=%s, left=%s, right=%s>" % (k, p, l, r)
        return s


class BinaryTree():
    def __init__(self, n=0):
        self.T = [Node() for _ in range(n)]
        self.root = None

    def preorder(self):
        self.preorder_key = []
        self.preorder_rec(self.root)
        print('', *(self.preorder_key))

    def preorder_rec(self, node):
        if node == None:
            return
        self.preorder_key.append(node.key)
        self.preorder_rec(node.left)
        self.preorder_rec(node.right)

    def inorder(self):
        self.inorder_key = []
        self.inorder_rec(self.root)
        print('', *(self.inorder_key))

    def inorder_rec(self, node):
        if node == None:
            return
        self.inorder_rec(node.left)
        self.inorder_key.append(node.key)
        self.inorder_rec(node.right)

    def insert(self, key):
        node = Node(key)

        y = None
        x = self.root

        while x != None:
            y = x
            if key < x.key:
                x = x.left
            else:
                x = x.right

        node.parent = y
        if y == None:
            self.root = node
        elif key < y.key:
            y.left = node
        else:
            y.right = node

    def find(self, x, key):
        while x != None and key != x.key:
            if key < x.key:
                x = x.left
            else:
                x = x.right
        return x

    def has(self, key):
        if self.find(self.root, key):
            return True
        else:
            return False


N = int(input())
S = [input() for _ in range(N)]
tree = BinaryTree()

for s in S:
    if 'print' in s:
        tree.inorder()
        tree.preorder()
    else:
        command, key = s.split()
        key = int(key)

        if 'find' in command:
            print('yes' if tree.has(key) else 'no')

        elif 'insert' in command:
            tree.insert(key)



Measured memory_bytes: 95188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;cin>>N;
  ll ans=1;
  for(int i=1;i<=N;i++){
    ans=(ans*i)%INF;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
// Copyright 2017 wu_qing
#include <cstdio>
#include <algorithm>
const int N = 1e5 + 10;
int n, b[N], h[N], l[N], tar = 1, end;
bool cmp(int a, int b) {
    return a > b;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", b + i);
    std::sort(b + 1, b + n + 1, cmp);
    b[0] = b[1];
    for (int i = 1; i <= n; i++) {
        l[i] = b[i] + 1;
        h[i] = b[i - 1] + 1;
    }
    h[n + 1] = b[n] + 1;
    while (tar < l[tar])
        tar++;
    tar--;
    if (!((l[tar] - tar) & 1)) {
        printf("First\n");
        return 0;
    }
    end = tar;
    while (tar < h[end])
        end++;
    end--;
    if ((end - tar) & 1)
        printf("Second\n");
    else
        printf("First\n");
    return 0;
}


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

int main()  {
    int n;
    int r=0, b=0;
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        char c;
        std::cin >> c;
        if (c == 'R') ++r;
        else ++b;
    }
    std::cout << (r > b ? "Yes" : "No") << std::endl;
    return 0;
}

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

using namespace std;

double dp[2][16][1<<16];

int main(){
  int m,n;
  cin>>m>>n;
  double g[16][16];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin>>g[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<1<<m;j++){
      if(j>>i&1)continue;
      dp[n&1][i][j]=1;
    }
  }
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<1<<m;j++){
      for(int k=0;k<m;k++){
	dp[i&1][k][j]=0;
	if(!(j>>k&1)){
	  dp[i&1][k][j]=dp[i+1&1][k][j]*g[k][i];
	  for(int l=0;l<m;l++){
	    if(j>>l&1){
	      dp[i&1][k][j]=max(dp[i&1][k][j],dp[i+1&1][k][j]*g[k][i]+dp[i&1][l][j^1<<l]*(1-g[k][i]));
	    }
	  }
	}
      }
    }
  }
  double ans=0;
  for(int i=0;i<m;i++){
    ans=max(ans,dp[0][i][(1<<m)-1^1<<i]);
  }
  cout.precision(9);
  cout<<fixed<<ans<<endl;
}

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

//create arrays outside of main()

int a[100];

int main(){

    int a;
    int b;
    int c;
    cin >> a >> b >> c;

    int shortest;

    if((a+b)<(b+c)){
        shortest = a+b;
    } else {
        shortest = b+c;
    }

    if((a+c)<shortest){
        shortest = a+c;
    } 

    cout << shortest;
    

    return 0;
}

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

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

using namespace std;

// dp memory
const int MAX_N = 44;
int fib[MAX_N+1];

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

    // fib dynamic programming
    fib[0] = 1;fib[1] = 1;
    REP(i, 2, n+1){
        fib[i] = fib[i-1] + fib[i-2];
    }

    cout << fib[n] << endl;
}


Measured memory_bytes: 3084
#def area###############################

def pr(s,a,b):
	print s[int(a):int(b)+1]

def rv(s,a,b):
	tmp=s[::-1]
	news=s[:int(a)]+tmp[len(tmp)-int(b)-1:len(tmp)-int(a)]+s[int(b)+1:]
	return news

def rp(s,a,b,p):
	news=s[:int(a)]+p+s[int(b)+1:]
	return news

########################################


I=raw_input()
n=int(input())
for i in range(n):
	k=raw_input().split(" ")
	if k[0]=="replace":
		I=rp(I,k[1],k[2],k[3])
	elif k[0]=="reverse":
		I=rv(I,k[1],k[2])
	elif k[0]=="print":
		pr(I,k[1],k[2])

Measured memory_bytes: 6472
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    ll res = 0;
    REP(i,d){
        int t; cin >> t; t--;
        res += v[i][t];
        REP(j,26){
            if(j == t) loss[j] = 0;
            else loss[j] += c[j];
            res -= loss[j];
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3672
from functools import reduce
from fractions import gcd
n,k,*a=map(int,open(0).read().split())
if max(a)<k:
    print("IMPOSSIBLE")
elif max(a)==k:
    print("POSSIBLE")
else:
    if k%reduce(gcd,a)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 16068
#include<stdio.h>

const int mod = 1e9 + 7;

int main(){
  int N;
  scanf("%d", &N);
  int C[N + 1];
  for(int i = 1; i <= N; i++) scanf("%d", C + i);
  C[0] = 0;
  
  int dp[N + 1];
  dp[0] = 1;
  int s[(int)(2 * 10e5 + 1)];
  for(int i = 0; i <= 2 * 10e5; i++) s[i] = 0;
  for(int i = 1; i <= N; i++){
    dp[i] = dp[i - 1];
    if(C[i - 1] != C[i]){
      dp[i] += s[C[i]];
      dp[i] %= mod;
      s[C[i]] = dp[i];
    }
  }
  
  printf("%d", dp[N]);
  
  return 0;
}

Measured memory_bytes: 9600