akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int A[20], n;

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

int main(){
    int q, m, i;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    while(q--){
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  scn(a)   scanf("%d",&(a))
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }

int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(abs(x-a)<abs(x-b)?"A":"B")<<endl;
    
        
    return 0;
}


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

using namespace std;

int fact[65536];
int len;

void init() {
    int i = 1;
    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2; i < 65536; ++i) {
        fact[i] = fact[i-1] + i;
        if (fact[i] > (int)1e9) {
            //printf("%d\n", i); // 44721
            len = i+1;
            return ;
        }
    }
}

int main() {
    init();
    int X;
    while(scanf("%d", &X) != EOF) {
        if (X == 1) {
            printf("1\n");
            continue;
        }
        auto it = lower_bound(fact, fact+len, X);
        int x = distance(fact, it);
        printf("%d\n", x);
    }
}


Measured memory_bytes: 384
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    string S;
    cin >> S;
    
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())


num = 0
sum = 0
tmp = 0

#print(n,a,b)

for i in range(1,n+1,1):
  #print(i)
  tmp = 0
  num = i
  while True:
    tmp += num % 10
    num = num // 10
    if num == 0:
      #print( tmp, i )
      if a <= tmp <= b:
        #print( sum )
        sum += i

        
      break

print( sum )

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

void dfs(int k, ll now, vector<ll> &ans) {
    ans.push_back(now);
    if(k == 10) return;
    for(int u = -1; u <= 1; u++) {
        int add = (now % 10) + u;
        if(add >= 0 && add <= 9) dfs(k + 1, now * 10 + add, ans);
    }
}

int main() {
    int K; cin >> K;
    vector<ll> ans;
    for (int i = 1; i <= 9; i++) dfs(1, i, ans);
    sort(ans.begin(), ans.end());
    cout << ans.at(K - 1) << endl;
}

Measured memory_bytes: 5356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int ans = 100000;
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			ans = (int)((double)ans * 1.05);
			ans = ans % 1000 != 0 ? ans - (ans % 1000) + 1000 : ans;
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){      
      lint h,w;
      cin>>h>>w;
      char s[h][w];
      bool isv[h][w];
      vector<P>p;
      rep(i,h){
          rep(j,w){
              cin>>s[i][j];
              if(s[i][j]=='#')p.push_back(make_pair(i,j));
              isv[i][j]=false;
          }
      }
        lint ans=0;
        queue<P> que;
        vector <lint> x={-1,1,0,0};
        vector <lint> y={0,0,1,-1};
        rep(i,p.size()){
            lint a,b;
            tie(a,b)=p[i];
            if(isv[a][b])continue;
            else que.emplace(a,b);
            lint countb=1;
            lint countw=0;
                while(!que.empty()){
                    lint yy,xx;
                    tie(yy,xx)=que.front();
                    isv[yy][xx]=true;
                    que.pop();
                 rep(i,4){
            if((xx+x[i])<0||(xx+x[i])>(w-1)||(yy+y[i])<0||(yy+y[i])>(h-1)){              
                    continue;
                }
                if(isv[yy+y[i]][xx+x[i]])continue;
            if(s[yy][xx]=='#'&&s[yy+y[i]][xx+x[i]]=='.'){
            que.emplace(yy+y[i],xx+x[i]);
             isv[yy+y[i]][xx+x[i]]=true;
            countw++;
        }
                    if(s[yy][xx]=='.'&&s[yy+y[i]][xx+x[i]]=='#'){
             que.emplace(yy+y[i],xx+x[i]);
             isv[yy+y[i]][xx+x[i]]=true;
             countb++;
        }
      }
                }
                ans+=countb*countw;
        }
        cout<<ans<<endl;
      }
  
     


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

int main(){
  int N,M,Asum=0;
  cin>>N>>M;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<M;i++){
    Asum+=A.at(i);
  }
  

  if(N-Asum<0){
    cout<< "-1"<< endl;
  }
  else{
    cout<<N-Asum<< endl;
  }

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> price(n,0);
  for(int i=0;i<n;i++){cin>>price[i];}
  sort(price.begin(),price.end());
  int mini;
  mini = min(n,m);
  long long sum = accumulate(price.begin(),price.begin()+mini,0);
  printf("%lld",sum);
}

Measured memory_bytes: 3692
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	
	string s;
	while (cin >> s, s != "."){
		vector<int> vi;
		vector<int> vi2;
		int a = 0;
		for (int i = 0; i < s.length(); i++){
			
			if (s[i] == '+')a++;
			if (s[i] == '-')a--;
			if (s[i] == '[')vi2.push_back(vi.size());
			if (s[i] == ']'){
				reverse(vi.begin() + vi2.back(), vi.begin() + vi.size());
				vi2.pop_back();
			}
			if (s[i] == '?'){
				vi.push_back('A');
				a = 0;
			}
			if (s[i] >= 'A'&&s[i] <= 'Z'){
				while (s[i] + a < 'A')a += 26;
				while (s[i] + a > 'Z')a -= 26;

				vi.push_back(s[i]+a);
				a = 0;
			}
		}
		string s2="";
		for (int i = 0; i < vi.size(); i++){
			s2 += vi[i];
		}
		cout << s2 << endl;
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

void solve(void){
    int w, h, n;
    cin >> w >> h >> n;
    int xl = 0, xr = w, yd = 0, yu = h;
    rep(n, i) {
        int x, y, a;
        scanf("%d%d%d\n", &x, &y, &a);
        switch (a) {
            case 2: xr = min(xr, x); break;
            case 1: xl = max(xl, x); break;
            case 4: yu = min(yu, y); break;
            case 3: yd = max(yd, y); break;
        }
    }
    int ans;
    if (xr <= xl or yu <= yd) ans = 0;
    else ans = (xr - xl) * (yu - yd);
    cout << ans << '\n';
}

int main(void){
  solve();
  return 0;
}


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

const ll INF = 1001001001001001001;
const int MAX = 5e5 + 10;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0, ans = INF, tmp = 0;
    rep(i,n){
        sum += a[i];
        if(i % 2 == 0 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
        if(i % 2 == 1 && sum >= 0){
            tmp += sum + 1;
            sum = -1;
        }
    }
    ans = min(ans, tmp);
    tmp = 0;
    sum = 0;
    rep(i,n){
        sum += a[i];
        if(i % 2 == 0 && sum >= 0){
            tmp += sum + 1;
            sum = -1;
        }
        if(i % 2 == 1 && sum <= 0){
            tmp += 1 - sum;
            sum = 1;
        }
    }
    ans = min(ans, tmp);
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[1000][1000];
struct st{int x1, y1, x2, y2;};
vector<st> vec;
signed main(){
  int h, w;
  cin >> h >> w;
  rep(i,h)rep(j,w)cin >> a[i][j];
  rep(i,h-1)rep(j,w){
    if(a[i][j]%2 == 1){
      vec.push_back(st{i+1, j+1, i+2, j+1});
      // printf("%lld %lld %lld %lld\n", i, j, i+1, j);
      a[i][j] -= 1;a[i+1][j] += 1;
    }
  }
  rep(i,w-1){
    if(a[h-1][i]%2 == 1){
      vec.push_back(st{h, i+1, h, i+2});
      // printf("%lld %lld %lld %lld", h-1, i, h-1, i+1);
      a[h-1][i]--;a[h-1][i+1]++;
    }
  }
  int m = vec.size();
  cout << m << endl;
  rep(i,m){
    printf("%lld %lld %lld %lld\n", vec[i].x1, vec[i].y1, vec[i].x2, vec[i].y2);
  }
	return 0;
}










Measured memory_bytes: 10480
#include<iostream>

using namespace std;

#define WHITE 0
#define BLACK 2
#define GRAY 1
#define MAX 100
#define INFITY 1<<21

int n,M[MAX][MAX];

int prim()
{
	int d[MAX],color[MAX],p[MAX];

	for (int i = 0; i < n; ++i)
	{
		d[i]=INFITY;
		p[i]=-1;
		color[i]=WHITE;
	}

	d[0]=0;
	color[0]=GRAY;
	while(1){
		int u=-1;
		int minv=INFITY;
		// 把距离最小的顶点加入MST
		for (int i = 0; i < n; ++i)
		{
			if (minv>d[i]&&color[i]==GRAY)
			{
				minv=d[i];
				u=i;
			}
		}
		if (u==-1)
		{
			break;
		}
		color[u]=BLACK;

		// 更新距离
		for (int i = 0; i < n; ++i)
		{
			if (color[i]!=BLACK&&d[i]>M[u][i])
			{
				d[i]=M[u][i];
				color[i]=GRAY;
				p[i]=u;
			}
		}
	}
	int sum=0;
	for (int i = 0; i < n; ++i)
	{
		if (p[i]!=-1)
		{
			sum+=M[i][p[i]];
		}
	}

	return sum;
}

int main(int argc, char const *argv[])
{
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			int v;
			cin>>v;
			M[i][j]=(v==-1)?INFITY:v;
		}
	}
	cout<<prim()<<endl;
	return 0;
}


Measured memory_bytes: 3124
A, B, K= map(int, input().split())

for i in range(int(K)):
	if i % 2 == 0:
		if A % 2 != 0 :	A += -1
		B += A/2
		A -= A/2
	else:
		if B % 2 != 0 :	B+= -1
		A += B/2
		B -= B/2
print(int(A) , int(B))

Measured memory_bytes: 3060
n = int(input())
s = [ i for i in input().split()]
cnt = 0
for i in range(n-1):
    minj = i
    for j in range(i+1,n):
        if int(s[j]) < int(s[minj]):
            minj = j
    if i != minj:
        cnt += 1
        s[i],s[minj] = s[minj],s[i]
print(' '.join(s))
print(cnt)



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


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
  int t=1;
    //cin>>t;
    while(t--){
        int n,m,k;
        cin>>n>>m>>k;
        //vector <int> v1(n),v2(m);
        vector <long long> pre1(n+1),pre2(m+1);
        pre1[0]=0;
        pre2[0]=0;
        for(int i=0;i<n;i++)
            {
                int x;cin>>x;
                pre1[i+1]=pre1[i]+x;
            }
        for(int j=0;j<m;j++)
            {
                int x;cin>>x;
                pre2[j+1]=pre2[j]+x;
            }
        int j=m;
        int ans=0;
        for(int i=0;i<n+1;i++)
        {
            if(pre1[i]>k)
                break;
            else
            {
                while(j>=0 && (pre1[i]+pre2[j])>k)
                    {
                        //ans=max(ans,i+j);
                        --j;
                    }
                if(j>=0)
                   ans=max(ans,i+j);
            }
        }
        cout<<ans<<'\n';
    }



return 0;
}

Measured memory_bytes: 6348
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int H = cin.nextint;
        int W = cin.nextint;

        WriteLine((N - H + 1) * (N - W + 1));
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13268
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::collections::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
        t: Chars,
    }

    let mut s_1: VecDeque<char> = VecDeque::new();
    for i in 0..s.len() {
        s_1.push_back(s[i]);
    }
    for i in 0..s.len() {
        debug!(s_1);
        if s_1==t {
            println!("Yes");
            return;
        } else {
            s_1.push_front(s_1[s_1.len()-1]);
            s_1.pop_back();
        }
    }

    println!("No");

}


Measured memory_bytes: 2184
#include<iostream>
using namespace std;
int p[100010],r[100010];
void makeset(int x){
    for(int i=0;i<x;++i){
        p[i]=i;
        r[i]=0;
    }
}
int findset(int a){
    if(a!=p[a])
        p[a]=findset(p[a]);
    return p[a];
}
bool same(int a,int b){
    return (findset(a)==findset(b));
}

void link(int a,int b){
    if(r[a]>r[b]){
        p[b]=a;
    }
    else{
        p[a]=b;
        if(r[a]==r[b]){
            r[b]++;
        }
    }
}
void unite(int a,int b){
    link(findset(a),findset(b));
}
int main(){
    int n,q;
    cin>>n>>q;
    makeset(n);
    int x[100001],y[100001],comp[100001];
    for(int i=0;i<q;++i){
        cin>>comp[i]>>x[i]>>y[i];
        if(comp[i]==0){
            unite(x[i],y[i]);
        }
        else if(comp[i]==1){
            int t=same(x[i],y[i]);
            cout<<t<<endl;
        }
    }
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e6+40,MAXM=5e5+10,hrdg=1000000007;
const ll llINF=0x7fffffff;
const int INF=0x7fffffff;
ll a[MAXN];
int num[MAXN];

int main()
{
    int n,m;
    cin>>n>>m;
    int temp;
    for(int i=1;i<=m;i++)
        {
            cin>>temp;
            num[temp]++;
        }
    a[0]=a[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!num[i-2])
            a[i]+=a[i-2];
        if(!num[i-1])
            a[i]+=a[i-1];
        a[i]%=1000000007;
    }
    a[n]%=1000000007;
    cout<<a[n];
    return 0;
}


Measured memory_bytes: 4736
/*
ALDS1_2_C
*/

#include <iostream>

using namespace std;

static const int MAX = 100;

typedef struct Card {
    char suit, value;
} Card;

void print(int N, Card A[]) {
    for(int i = 0; i < N; i++) {
        if(i) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

void bubbleSort(int N, Card A[]) {
    for(int i = 0; i < N; i++) {
        for(int j = N-1; j > i; j--) {
            if(A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
            }
        }
    }
}

void selectionSort(int N, Card A[]) {
    for(int i = 0; i < N; i++) {
        int minj = i;
        for(int j = i; j < N; j++) {
            if(A[minj].value > A[j].value) {
                minj = j;
            }
        }
        swap(A[minj], A[i]);
    }
}

bool isStable(Card bA[], Card sA[], int N) {
    for(int i = 0; i < N; i++) {
        if(bA[i].suit != sA[i].suit) 
            return false;
    }
    return true;
}

int main() {
    int n;
    Card bA[MAX], sA[MAX];

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> bA[i].suit >> bA[i].value;
        sA[i] = bA[i];
    }

    bubbleSort(n, bA);
    selectionSort(n, sA);

    print(n,bA);
    cout << "Stable" << endl;

    print(n,sA);
    if(isStable(bA, sA, n)) {
        cout << "Stable" << endl; 
    }
    else {
       cout << "Not stable" << endl;  
    }


}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> X){
	ll res = INF;
	rep(i, 101) {
		ll now = 0;
		rep(j, N) {
			now += (X[j]-i)*(X[j]-i);
		}
		res = min(res, now);
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> X(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&X[i]);
	}
	solve(N, X);
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(long n, long m) {
    long answer = Math.min(n, m / 2);
    n -= answer;
    m -= 2 * answer;
    answer += m / 4;
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long n = reader.nextLong();
    long m = reader.nextLong();
    out.println(solve(n, m));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception 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());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22996
// Takahashi's Information
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<vector<int>> mat(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> mat.at(i).at(j);
        }
    }

    vector<int> a(3);
    vector<int> b(3);
    a.at(0) = 0;
    b.at(0) = mat.at(0).at(0);
    b.at(1) = mat.at(0).at(1);
    b.at(2) = mat.at(0).at(2);
    a.at(1) = mat.at(1).at(1) - b.at(1);
    a.at(2) = mat.at(2).at(2) - b.at(2);
    int count = 0;

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (mat.at(i).at(j) == a.at(i) + b.at(j)) count++;
        }
    }

    if (count == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M;
ll V[110][110];
ll A[1010], B[1010], C[1010];
ll used[110][110];


int main(int argc, char **argv)
{
	REP(i, 110)REP(j, 110) V[i][j] = INF*(i!=j);
	cin >> N >> M;
	REP(i, M)
	{
		ll a, b, c; cin >> a >> b >> c;
		--a, --b;
		V[a][b] = V[b][a] = c;
		A[i] = a;
		B[i] = b;
		C[i] = c;
	}

	REP(v, N)REP(s, N)REP(t, N)
		V[s][t] = min(V[s][t], V[s][v] + V[v][t]);

	ll res{M};
	REP(i, M)
	{
		ll ok{false};
		REP(j, N)
		{
			if (V[j][A[i]] == V[j][B[i]] + C[i]) ok = true;
		}

		if (ok)
			--res;
	}

	std::cout << res << std::endl;
}


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

typedef long long ll;

const int maxn = 1e5 + 1e2;
int val[maxn];
std::map<int, int> mapp;

int main(){
	std::ios::sync_with_stdio(false);

	int n, m;
	std::cin >> n >> m;

	for(int i = 0; i < n; i++){
		std::cin >> val[i];
		val[i] %= m;
	}

	int sum = 0;
	for(int i = 0; i < n; i++){
		sum += val[i];
		sum %= m;
		mapp[sum]++;
	}

	sum = 0;
	ll res = 0;
	for(int i = 0; i < n; i++){
		res += mapp[sum % m];
		sum += val[i];
		sum %= m;
		mapp[sum]--;
	}

	std::cout << res << '\n';
}


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

void getChildrenNum(vector<int> &ans, int sizeR, int sizeL, int centerRL) {
  // 偶数パターン
  if((sizeR+sizeL)%2==0) {
    ans[centerRL] = ans[centerRL+1] = (sizeR+sizeL)/2;
  } else
  // 奇数パターン
  if((sizeR+sizeL)%2!=0) {
    // Rの長さが奇数個なら、R側が1つ多い　偶数なら逆
    if(sizeR%2==0) {
      ans[centerRL] = ((sizeR+sizeL)-1)/2;
      ans[centerRL+1] = ans[centerRL]+1;
    } else
    if(sizeR%2!=0) {
      ans[centerRL] = ((sizeR+sizeL)+1)/2;
      ans[centerRL+1] = ans[centerRL]-1;
    }
  }
  return;
}

int main() {
  string s;
  int startRL=0, centerRL, sizeR, sizeL;
  cin >> s;
  vector<int> ans(s.size(), 0);
  // 左端にはR、右端にはLが必ずある
  // ということは、どこかに必ずRLが並ぶ場所がある
  for(int i=0; i<s.size()-1; i++){
    // RLブロックの中心点
    if(s[i]=='R' && s[i+1]=='L') centerRL=i;
    // RLブロックの終わり
    if(s[i]=='L' && s[i+1]=='R') {
      sizeR = (centerRL+1) - startRL;
      sizeL = i-centerRL;
      getChildrenNum(ans, sizeR, sizeL, centerRL);
      startRL=i+1;
    } else if(i==(int)s.size()-2){
      sizeR = (centerRL+1) - startRL;
      sizeL = (i+1)-centerRL;
      getChildrenNum(ans, sizeR, sizeL, centerRL);
    }
  }
  for(auto vec: ans) {
    cout << vec << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
string s;
int mn=1e9,now;
int ins[101];
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='(') now++;
        else now--;
        mn=min(now,mn);
    }
    for(int i=0;i<max(0,-mn);i++)
        putchar('(');
    cout<<s;
    now=max(0,-mn);
    for(int i=0;i<s.size();i++)
        if(s[i]=='(') now++;
        else now--;
    if(now>0)
        for(int i=0;i<now;i++)
            putchar(')');
    return 0;
}

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

int main() {

  int a,b,c,x;
  int p,q,r;
  int s = 0;

  cin >> a >> b >> c >> x;

  // 100
    for(p=0;p<=a;p++)
    {
      for(q=0;q<=b;q++)
      {
        for(r=0;r<=c;r++)
        {
          if(( 500 * p + 100 * q + 50 * r) == x )
            s++;
        }
      }
     }

    cout << s;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;

double dot(P a, P b) {
    return real(conj(a) * b);
}

P projection(P x, P d) {
    return dot(x, d) * d / abs(d) / abs(d);
}

P reflection(P x, P d) {
    P t = projection(x, d);
    return 2. * t - x;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    P p0(x0, y0), p1(x1, y1);
    int q;
    cin >> q;
    while (q--) {
        double x2, y2;
        cin >> x2 >> y2;
        P p2(x2, y2);
        P a = reflection(p2 - p0, p1 - p0) + p0;
        printf("%.10f %.10f\n", a.real(), a.imag());
    }

}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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


    int ans = 0;
    int bscore = 0;
    int ascore = 0;
    bool ne = false; //ばらばらのがいる
    rep(i, n){
        bool aok = false;
        bool bok = false;
        if (s[i][0] == 'B') bok = true;
        if (s[i][s[i].size()-1] == 'A') aok = true;
        for (int si = 0; si < s[i].size()-1; si++)
        {
            if (s[i][si] == 'A' && s[i][si+1] == 'B'){
                ans++;
            }
        }
        if ((aok&&!bok) || (!aok&&bok)){
            ne = true;
        }
        if (aok) ascore++;
        if (bok) bscore++;
    }
    int plus = min(ascore, bscore);

    if (plus != 0 && !ne){
        plus--;
    }
    ans += plus;
    cout << ans << endl;
}



Measured memory_bytes: 768
import java.util.Scanner;

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

		while(scan.hasNext())
		{
			double a = scan.nextDouble();

			if(a<=48.00)
				System.out.println("light fly");
			else if(a<=51.00)
				System.out.println("fly");
			else if(a<=54.00)
				System.out.println("bantam");
			else if(a<=57.00)
				System.out.println("feather");
			else if(a<=60.00)
				System.out.println("light");
			else if(a<=64.00)
				System.out.println("light welter");
			else if(a<=69.00)
				System.out.println("welter");
			else if(a<=75.00)
				System.out.println("light middle");
			else if(a<=81.00)
				System.out.println("middle");
			else if(a<=91.00)
				System.out.println("light heavy");
			else 
				System.out.println("heavy");
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;
int use[256];
int main(void){
	string s;
	cin >> s;
	if(s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	REP(i, s.size()) {
		use[s[i]] = 1;
	}
	REP(i, 26) {
		if(!use[i + 'a']){
			cout << s << (char)(i + 'a') << endl;
			return 0;
		}
	}

	RREP(i, s.size()) {
		use[s[i]] = 0;
		if(s[i-1] < s[i]) {
			char prev = s[i-1];
			RREP(j, 26) if(!use[j + ('a')] && prev < (char)(j + 'a')) s[i-1] = (char)(j + 'a');
			REP(j, i) cout << s[j];
			cout << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double
#define pi acos(-1)
#define eps 1e-10
using namespace std;
struct Po{lb x,y;};
struct curc{Po a;lb r;}c1,c2;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
lb operator ^(Po x,Po y){return x.x*y.x+x.y*y.y;}
Po operator *(Po x,lb y){return (Po){x.x*y,x.y*y};}
Po operator /(Po x,lb y){return (Po){x.x/y,x.y/y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
lb dis(Po x){return sqrt(x.x*x.x+x.y*x.y);}
Po ro(Po x,lb y){return (Po){x.x*cos(y)-x.y*sin(y),x.x*sin(y)+x.y*cos(y)};}
int main(){
	get(c1.a);scanf("%Lf",&c1.r);
	get(c2.a);scanf("%Lf",&c2.r);
	lb di=dis(c2.a-c1.a);
	lb a=(di*di+c1.r*c1.r-c2.r*c2.r)/(2*di);
	lb b=sqrt(c1.r*c1.r-a*a);
	Po gen=(c2.a-c1.a)/di;
	Po e=c1.a+gen*a;
	gen=ro(gen,pi/2);
	Po an1=e+gen*b,an2=e-gen*b;
	if (an1.x>an2.x+eps||(fabs(an1.x-an2.x)<eps&&an1.y>an2.y+eps))swap(an1,an2);
	printf("%.10Lf %.10Lf %.10Lf %.10Lf\n",an1.x,an1.y,an2.x,an2.y);
	return 0;
}


Measured memory_bytes: 3516
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int r=n%10;
    if(r==2||r==4||r==5||r==7||r==9)
      System.out.println("hon");
    else if(r==0||r==1||r==6||r==8)
      System.out.println("pon");
    else if(r==3)
      System.out.println("bon");
  }
}


Measured memory_bytes: 26948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#include <string>
#include <ctime>
#include <stack>
#include <set>
#include <stdio.h>
#include <locale>
#define y1 y3278
#define y2 y4368
#define y y4368232
#define x x43682322
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define tm tm3278
#define left left3278
#define right right3278
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
template <class T> using Pair_indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long INF = 2000000000000000000;
const long long Maxll = 9223372036854775807;
const long long MOD = 1000000000000037;
const long long q0 = 31;
const int differ = 'a' - 'A';
template <class T>
istream& operator >> (istream &in, vector <T> &a)
{
    for (T &i: a) in >> i;
    return in;
}
template <class T>
ostream& operator << (ostream &out, vector <T> &a)
{
    for (T &i: a) out << i << ' ';
    out << '\n';
    return out;
}
template <class T>
ostream& operator << (ostream &out, set <T> &a)
{
    //out << a.size() << '\n';
    for (T i: a) out << i << ' ';
    return out;
}
/// Actual code starts here
string str;

void PYPY()
{
    cin >> str;
    if (find(all(str),'7') != str.end())
        cout << "Yes";
    else
        cout << "No";

}

int main()
{
     ios::sync_with_stdio(0);
     cin.tie(0);
     cout.tie(0);
    ll t = 1;
    // cin >> t;
     while (t--)
         PYPY();
}


Measured memory_bytes: 3612
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
fscanf(STDIN, "%d", $r);
// fscanf(STDIN, "%d", $b);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// $arr = array("SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN");
// for ($i = 0; $i <= count($arr); $i++) {
//   if ($arr[$i] == $s) {
//     break;
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "win";
// if ($a + $b + $c >= 22) {
//   $r = "bust
// ";
// }
// $arr = array(1, 2, 3);
// unset($arr[$a - 1]);
// unset($arr[$b - 1]);
// $arr = array_values($arr);

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $arr[0] . "\n";
// echo $i + 1 . "\n";
echo $r ** 2 . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
// echo $t . $s . "\n";


Measured memory_bytes: 16096
#include<stdio.h>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	while(h!=0&&w!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		
		printf("\n");
		scanf("%d%d",&h,&w);
	}
	return 0;
}


Measured memory_bytes: 2104
//---includes---//
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
//---defines---//
#define MAX_N 200
#define MAX_M 10000
#define INF 1 << 30
#define MAX_E 5
//---ints---//
int N, M, E, S, T, R;
int A[MAX_M], B[MAX_M];
vector<int> X[1 << MAX_E][MAX_N];
int E1[MAX_E][2], F[MAX_E], power[MAX_E];
int DP[1 << MAX_E][MAX_N], DP2[1 << MAX_E], maxn[MAX_N];
queue<pair<int, int>>Q;
//---bfs---//
int bfs() {
	DP[0][S] = 0;
	Q.push(make_pair(0, S));
	for (int i = 0; i < MAX_E; i++)
	{
		int AA = 0;
		if (i >= 1) {
			AA = 1;
		}
		for (int j = 0; j < (1 << MAX_E); j++) {
			DP2[j] = INF;
			for (int k = 0; k < N; k++) {
				DP2[j] = min(DP2[j], DP[j][k] + AA);
			}
		}
		for (int j = 0; j < (1 << MAX_E); j++) {
			for (int k = 0; k < MAX_N; k++) {
				DP[j][k] = INF;
			}
		}
		for (int j = 0; j < (1 << MAX_E); j++) {
			DP[j][S] = DP2[j];
			if (DP[j][S] < INF) {
				Q.push(make_pair(j, S));
			}
		}
		while (!Q.empty()) {
			pair<int, int>pa = Q.front();
			Q.pop();
			int a1 = pa.first;
			int a2 = pa.second;
			for (int j = 0; j < X[a1][a2].size(); j++) {
				int a3 = X[a1][a2][j];
				int a4 = 0;
				for (int j = 0; j < E; j++) {
					if ((a1 / power[j]) % 2 == 0) {
						if (F[j] == a3) {
							a4 += power[j];
						}
					}
				}
				a4 += a1;
				if (DP[a4][a3] > DP[a1][a2] + 1) {
					DP[a4][a3] = DP[a1][a2] + 1;
					Q.push(make_pair(a4, a3));
				}
			}
		}
		for (int j = 0; j < (1 << MAX_E); j++) {
			for (int k = 0; k < MAX_N; k++) {
				maxn[k] = min(maxn[k], DP[j][k]);
			}
		}
	}
	return maxn[T];
}
//---memset---//
void _memset() {
	N = 0; M = 0; E = 0; S = 0; T = 0; R = 0;
	for (int i = 0; i < MAX_M; i++) {
		A[i] = 0;
		B[i] = 0;
	}
	for (int i = 0; i < MAX_E; i++) {
		power[i] = 0;
		E1[i][0] = 0;
		E1[i][1] = 0;
		F[i] = 0;
	}
	for (int i = 0; i < (1 << MAX_E); i++) {
		while (!Q.empty()) {
			Q.pop();
		}
		for (int j = 0; j < MAX_N; j++) {
			DP[i][j] = INF;
			maxn[j] = INF;
		}
	}
}
//---main---//
int main() {
	_memset();
	power[0] = 1;
	for (int i = 1; i < MAX_E; i++) {
		power[i] = power[i - 1] * 2;
	}
	cin >> N >> M >> E >> S >> T >> R;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}
	for (int i = 0; i < E; i++) {
		cin >> E1[i][0] >> E1[i][1] >> F[i];
	}
	for (int i = 0; i < (1 << E); i++) {
		for (int j = 0; j < M; j++) {
			X[i][A[j]].push_back(B[j]);
			X[i][B[j]].push_back(A[j]);
		}
		for (int j = 0; j < E; j++) {
			if ((i / power[j]) % 2 == 1) {
				X[i][E1[j][0]].push_back(E1[j][1]);
				X[i][E1[j][1]].push_back(E1[j][0]);
			}
		}
	}
	int RES = bfs();
	if (RES >= INF) {
		RES = -1;
	}
	cout << RES << endl;
	return 0;
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

const int max_prime_range=1000000;
bool done_get_prime_list=false;
vector<ll> prime;
void get_prime_list(ll n=max_prime_range){
	if(done_get_prime_list)return;
	done_get_prime_list=true;
	ll visited[max_prime_range+1]={};
	reg(i,2,n){
		if(visited[i]==0){
			prime.push_back(i);
			reg(j,2,n){
				if(j*i>n)break;
				visited[i*j]=1;
			}
		}
	}
}
void factoring(ll n, vector<ll>& v){
	v.assign(prime.size()+1,0);
	rep(i,prime.size()){
		while(n%prime[i]==0){
			n/=prime[i];
			v[i]++;
		}
	}
	if(n>1)v[prime.size()]=n;  // 最後だけ個数じゃなくて素数そのもの
	return;
}

V<ll> aa,bb;
ll a,b,ans=1;

void init(){
	cin>>a>>b;
	get_prime_list(1000000);
	cerr<<prime.size()<<endl;
	factoring(a,aa);
	factoring(b,bb);
}

int main(void){
	init();
	rep(i,prime.size()){
		if(min(aa[i],bb[i])>0)ans++;
	}
	if(aa[prime.size()]!=0 && aa[prime.size()]==bb[prime.size()])ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9972
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m, X, Y;
int x[100];
int y[100];

signed main() {
	int i, j;
	
	cin >> n >> m >> X >> Y;
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];
	
	for (int z = X + 1; z <= Y; z++) {
		rep(i, n) if (x[i] >= z) break;
		if (i < n) continue;
		rep(i, m) if (y[i] < z) break;
		if (i < m) continue;
		cout << "No War" << endl;
		return 0;
	}
	cout << "War" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  int n;
  cin >> n;
  map<string, long long>mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort (begin (s), end (s) );
    mp[s]++;
  }
  long long ans =  0;
  for (auto i : mp) {
    ans += ( 1ll * (i.second) * (i.second - 1) ) / 2;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11264
#define ALL(obj) (obj).begin(), (obj).end()
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;
 
ll N, A, B;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B;
    ll loopcount = N/(A+B);
    ll m = N % (A+B);
    ll ans = 0;
    if (A+B > N) {
        if (A>N) {
            ans = N;
        } else {
            ans = A;
        }
        cout << ans << endl;
    } else {
        ans = loopcount*A + min(m, A);
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = N % 10;
  
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256