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

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

vector<pair<int,int>> u;
vector<pair<int,int>> d;

int main() {
  int n;
  cin>>n;
  string s;
  REP(i,n){
    cin>>s;
    int minv=INF;
    int now=0;
    REP(j,s.size()){
      if(s[j]=='(') now++;
      else now--;
      if(now<minv) minv=now;
    }
    if(now>0) u.push_back(pair<int,int>(minv,now));
    else d.push_back(pair<int,int>(minv-now,-now));
  }
  sort(u.begin(),u.end(),[](const pair<int,int>& x, const pair<int,int>& y){return x.first > y.first;}
  );
  sort(d.begin(),d.end(),[](const pair<int,int>& x, const pair<int,int>& y){return x.first > y.first;}
  );
  int now=0;
  REP(i,u.size()){
    if(now+u[i].first<0){
      cout<<"No"<<endl;
      return 0;
    }
    now+=u[i].second;
//    if(now<0){
//      cout<<"No"<<endl;
//      return 0;
//    }
  }
  int top=now;

  now=0;
  REP(i,d.size()){
    if(now+d[i].first<0){
      cout<<"No"<<endl;
      return 0;
    }
    now+=d[i].second;
  }

  if(now==top)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 11316
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, m, dp[10000],s[1100][20], v[1100];
int main() {
	cin >> n >> m;
	REP(i, 10000)dp[i] = INF;
	REP(i, m) {
		ll b;
		cin >> v[i] >> b;
		REP(j, b) {
			ll a;
			cin >> a;
			a--;
			s[i][a] = 1;
		}
	}
	dp[0] = 0;
	REP(i, 1ll << n) {
		REP(j, m) {
			ll now = i;
			REP(k, 20) {
				if (s[j][k] == 1 and !(now & (1ll << k))) now += (1 << k);
			}
			//cout << dp[i] + v[j] << "  a" << endl;
			dp[now] = min(dp[now], dp[i] + v[j]);
			//cout << i << " " << now << endl;
		}
	}
		if (dp[(1ll << n) - 1] == INF)cout << -1 << endl;
		else cout << dp[(1ll << n) - 1] << endl;
}

Measured memory_bytes: 512
#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=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;

bool finish(int n, int i, const map<char, int> mp) {
    vi v;
    for (auto p : mp) {
        v.emplace_back(p.second);
    }
    sort(rall(v));
    int rest = n - i - 1;
    if (v[0] > v[1] + rest) {
        for (auto p : mp) {
            if (p.second == v[0]) {
                cout << p.first << " " << i + 1 << endl;
                return true;
            }
        }
    }
    else {
        return false;
    }
}

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

    int n;
    while (cin >> n, n) {
        map<char, int> mp;
        mp['#'] = 0;
        vector<char> vc(n);
        rep(i, n) {
            cin >> vc[i];
        }

        bool ret = [&](){
            rep(i, n) {
                mp[vc[i]]++;
                if (finish(n, i, mp)) {
                    return true;
                }
            }
            return false;
        }();
        if (!ret) cout << "TIE" << endl;
    }
}

Measured memory_bytes: 3124
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();

    int count = 0;

    for (int i = 0; i < s.length(); i++) {
      if (!s.substring(i,i+1).equals(t.substring(i,i+1))) {
        count++;
      }
    }

    System.out.println(count);

  }

}


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

int main() {
	int x=1, y=1;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		else {
			if (x >= y) {
				cout << y << " " << x << "\n";
			}
			else {
				cout << x << " " << y << "\n";
			}
		}
		}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int64_t> lu(N+2);
  lu.at(0)=2;
  lu.at(1)=1;
  for(int i=2;i<N+1;i++){
    lu.at(i)=lu.at(i-1)+lu.at(i-2);
  }
  cout<<lu.at(N)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a,h,m,s;
    // a = 3660
    // h = ?
    // m = ?
    // s = ?
    scanf("%d",&a);
    
    // a = 3660
    // h = 3660/3600
    // m = ?
    // s = ?
    h=a/3600;
    // a = 3660
    // h = 1
    // m = (3660-h*3600)/60
    // s = ?
    m=(a-h*3600)/60;
    s=a-h*3600-m*60;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt()+1;
		int m = scanner.nextInt();
		int x = scanner.nextInt();
		
		boolean[] gate = new boolean[n];
		Arrays.fill(gate, false);
		
		for (int i = 0; i < m; i++) {
			int g = scanner.nextInt();
			gate[g] = true;
		}
		
		int rgoal = 0;
		int lgoal = 0;
		
		
		for (int i = x; i < gate.length; i++) {
			if (gate[i]) {
				rgoal++;
			}
		}
		
		for (int i = x; i > 0; i--) {
			if (gate[i]) {
				lgoal++;
			}
		}
		
		int anser = lgoal;
		
		if (rgoal<lgoal) {
			anser = rgoal;
		}
		
		System.out.println(anser);
		scanner.close();
	}
	
	

}


Measured memory_bytes: 23508
import std.stdio, std.algorithm, std.conv, std.array, std.string;

wchar[600][600] BD1, BD2;

void main()
{
    auto N = readln.chomp.to!int;

    foreach (i; 0..N) {
        foreach (j, c; readln.chomp) {
            BD1[i][j] = BD1[i][N+j] = BD1[N+i][j] = BD1[N+i][N+j] = c;
            BD2[j][i] = BD2[j][N+i] = BD2[N+j][i] = BD2[N+j][N+i] = c;
        }
    }

    int cnt;
    foreach (a; 0..N) {
        foreach (i; 0..N) {
            if (BD1[a+i][0..N] != BD2[i][a..N+a]) goto bad;
        }
        ++cnt;
        bad:
    }
    writeln(cnt * N);
}

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }

const int mod = TEN(9) + 7;

bool used[200010];

signed main()
{
	int N; cin >> N;
	vi a(N + 1);
	rep1(i, N) cin >> a[i];

	vi ans;

	for (int i = N; i >= 1; --i) {
		int counter = 0; 
		for (int j = i; j <= N; j += i) {
			if (used[j]) {
				counter++;
			}
		}

		if (a[i] != (counter % 2)) {
			ans.PB(i);
			used[i] = true;
		}
	}

	cout << ans.size() << endl;

	for(int &i : ans) printf("%lld\n", i);
}




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

int main() {

	int n, r;
	cin >> n >> r;

	if (n >= 10) cout << r<<endl;
	else cout << r+100*(10-n)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
ll n; bool ans=true;
std::vector<ll> a;
int main(){
  cin >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 2 == 0){
      if(a[i] % 3 != 0 && a[i] % 5 != 0)ans = false;
    }
  }
  cout << (ans?"APPROVED":"DENIED") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<double,ll> P;

int n;
ll l;
ll t[500001],v[500001];

int main(void){
	scanf("%d%lld",&n,&l);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&t[i],&v[i]);
	}
	double res=0.0;
	deque<P> que;
	for(int i=0;i<n;i++){
		if(i>0){
			ll rest=v[i];
			while(rest>0){
				P q=que.front();
				if(q.second>rest){
					q.second-=rest;
					que.pop_front();
					que.push_front(q);
					res-=(double)q.first*rest;
					break;
				}else{
					rest-=q.second;
					res-=(double)q.first*q.second;
					que.pop_front();
				}
			}
		}
		res+=(double)t[i]*v[i];
		P p=P((double)t[i],v[i]);
		while(que.size()){
			P q=que.back();
			if(q.first+EPS>p.first){
				P r=P((q.first*(double)q.second+p.first*(double)p.second)/(double)(p.second+q.second),p.second+q.second);
				p=r;
				que.pop_back();
			}else break;
		}
		que.push_back(p);
		printf("%.10f\n",res/(double)l);
	}
	return 0;
}


Measured memory_bytes: 26512
#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 all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int main() {
  int n,y;
  cin >> n >> y;
   
  for(int i=0; i<=n; i++){
     for(int j=0; i+j<=n; j++){
        int k = n - i - j;
        if(10000*i+5000*j+1000*k == y){
         cout << i << " " << j << " " << k << endl;
         return 0;
        }
     }
  }

  cout << -1 << " " <<  -1 << " " <<  -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[])
{
    char chs[5];
    scanf("%s", chs);
    sort(chs, chs + 4);
    if (chs[0] == chs[1] && chs[1] != chs[2] && chs[2] == chs[3])
    {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

int main(){
    rep(i,3){
        string s;
        cin >> s;
        char c=s[0]-32;
        cout << c;
    }
    cout << endl;
    return 0;
}

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

signed main() {
	int m, f, r;
	char grade;
	while (cin >> m >> f >> r and (m > -1 or f > -1 or r > -1)) {
		if (m == -1 or f == -1) grade = 'F';
		else if (m + f >= 80) grade = 'A';
		else if (m + f >= 65) grade = 'B';
		else if (m + f >= 50 or r >= 50) grade = 'C';
		else if (m + f >= 30) grade = 'D';
		else grade = 'F';

		cout << grade << endl;
	}
}



Measured memory_bytes: 3080
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

L = input()
rem = L / (2 ** 18)
L %= (2 ** 18)
N = 20
M = 0

ls = []
for i in range(2, 20):
    ls.append((i, i + 1, 2 ** (20 - i - 1)))
    ls.append((i, i + 1, 0))
    M += 2

L = bin(L)[2:][::-1]
S = 0
for i in range(len(L)):
    c = L[i]
    if c == '1':
        pos = 20 - i
        ls.append((1, pos, S))
        S += 2 ** i
        M += 1

for i in range(rem):
    ls.append((1, 2, S))
    M += 1
    S += (2 ** 18)

print N, M

for p in ls:
    print " ".join(map(str, p))

Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){//桁数
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){//最小公倍数
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){//最大公約数
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  fo(i,a)
    cin>>b[i];
  Sort(b);
  int c=b[0],d=0,e=0;
  for(int i=0;i<b.size();i++){
    if(c==b[i])
      d++;
    else{
      if(d>=b[i-1])
        e+=d-b[i-1];
      else
        e+=d;
      c=b[i];
      d=1;
    }
  }
  if(d>=b[b.size()-1])
    e+=d-b[b.size()-1];
  else
    e+=d;
  cout<<e<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner str = new Scanner(System.in);
        int H = str.nextInt();
        int A = str.nextInt();

        if(H % A == 0){
            System.out.println(H / A);
        }
        else{
            System.out.println(H / A + 1);
        }

        str.close();
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int a,b;
		cin >> a >> b;
		cout << (float)a / b;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
using namespace std;
int sl,fh;
char s[4];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	scanf("%s",s);
	if(s[1]==s[0]) {puts("Bad"); return 0;}
	if(s[2]==s[1]) {puts("Bad"); return 0;}
	if(s[3]==s[2]) {puts("Bad"); return 0;}
	puts("Good");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9+7;



void solve()
{
	int n;
	cin>>n;
	d1(1-n);
}


int main()
{
	fifo
	ll t=1;
	//cin>>t;
	//cout<<t<<endl;
	for(ll test_case=1;test_case<=t;++test_case)
	{
		//cout<<"#"<<test_case<<endl;
		solve();
	}
}


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

int main(void)
{
    int n, max = 0, sum = 0, l[11];
    scanf("%d", &n);

    max = 0, sum = 0;
    for (int i = 0; i < n; i++){    
        scanf("%d", &l[i]);
        sum += l[i];
        if(max < l[i]){
            max = l[i];
        }
    }
    printf("%s\n", sum - max > max ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
N,K = map(int,input().split())
M = 10**9 + 7
T = pow(10,100,M)
ans = 0
for k in range(K, N+2):
    ans += (2*N-k+1)*k//2 - k*(k-1)//2 + 1
    ans %= M
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> s(m), c(m);
	rep(i, m) {
		cin >> s[i] >> c[i];
		s[i]--;
	}
	for (int i = 0; i < 1000; ++i) {
		string S = to_string(i);
		if (S.size() != n) continue;
		bool elf = true;
		rep(i, m) {
			if (S[s[i]] != char(c[i] + '0')) elf = false;
		}
		if (elf) {
			dunk(i);
			return 0;
		}
	}
	dunk(-1);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ
# 最小化
# dp = Hash.new{ Float::INFINITY }
# dp[i] = [dp[i], dp[i-1] + hoge].min
# dp[0] = 0
# 最大化
# dp = Hash.new{ 0 }
# dp[i] = [dp[i], dp[i-1] + hoge].max
# dp[0] = 0

dp = {}
dp[0] = 0
n,m = gets.split(' ').map(&:to_i)
ary = Array.new(m) { gets.to_i }
ary.each{ |ele| dp[ele] = 0 }
if ary.include?(1) && ary.include?(2)
  dp[n] = 0
  puts 0
  exit
elsif ary.include?(1) && !ary.include?(2)
  dp[1] = 0
  dp[2] = 1
elsif !ary.include?(1) && ary.include?(2)
  dp[1] = 1
  dp[2] = 0
else
  dp[1] = 1
  dp[2] = 2
end

3.upto(n) do |i|
  next if dp[i]
  dp[i] = dp[i-1] + dp[i-2]
end

# p dp
puts dp[n] % 1_000_000_007


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

int main() {
  int n;
  cin >> n;
  vector<char>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
    if(data.at(i) == 'Y'){
      cout << "Four" << endl;
      break;
    }
    if(i == n-1){
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,M;cin>>N>>M;
    vec p(100010);
    vector<string> S(100010);
    vector<bool> b(100010,false);
    for(int i=0;i<M;i++){
        cin>>p[i]>>S[i];
        if(S[i]=="AC"){
            b[p[i]]=true;
        }
    }
    vector<bool> AC(100010,false);
    int x=0,y=0;
    for(int i=0;i<M;i++){
        if(S[i]=="AC" && !AC[p[i]]){
            x++;
            AC[p[i]]=true;
        }
        if(S[i]=="WA" && !AC[p[i]] && b[p[i]]){
            y++;
        }
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  string s;
  
  cin>>s;
  
  int ans=0,temp=0;
  
  rep(i,3){
    if(s[i]=='R')temp++;
    else{
      ans=max(ans,temp);
      temp=0;
    }
    
  }
      ans=max(ans,temp);
  
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
using namespace std;
// }}} End Header

int main()
{
	int n;
	cin >> n;
	if(n<1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t ans = N / (A+B) * A;
    if(N%(A+B) <=A) {
        ans += N%(A+B);
    } else {
        ans += A;
    }

    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>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
void solve(){
    string s="abcdefghijklmnopqrstuvwxyz";
    set<char> st;
    for(auto c:s){
        st.insert(c);
    }
    char a;
    cin>>a;
    if(st.count(a)) cout<<"a";
    else cout<<"A";
    return;
}
int main(){
    //IO FO
    //TEST
    solve();

    return(0);
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
	scanf("%d%d%d", &a,&b,&n);
	if(n * 2 >= b - a + 1){
		for(int i=a;i<=b;i++){
			printf("%d\n", i);
		}
	}else{
		for(int i=a;i< a+n;i++){
			printf("%d\n", i);
		}
		for(int i=b-n+1; i<=b ; i++){
			printf("%d\n", i);
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
using namespace std;
typedef long long ll;

class Edge
{
	public:
	int cost;
	int from;
	int to;

	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];
vector<int> keiro;//u-v間の経路
bool used[100000];
bool uvpath(int s,int t,int now,int prev)
{
	if(now==t)
	{
		keiro.push_back(now);
		return true;
	}
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(e.to==prev)
			continue;
		if(uvpath(s,t,e.to,now))
		{
			keiro.push_back(now);
			return true;
		}
	}
	return false;
}
int longpath(int now,int prev,int length)
{
	int ret=length;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(e.to==prev)
			continue;
		ret=max(ret,longpath(e.to,now,length+1));
	}
	return ret;
}

int main()
{
	int n,u,v;
	cin>>n>>u>>v;
	u--;v--;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	uvpath(u,v,u,-1);
	// for(int i=0;i<keiro.size();i++)
	// 	cerr<<keiro[i]<<" ";
	// cerr<<endl;
	reverse(keiro.begin(),keiro.end());
	int midp=((int)keiro.size()/2)-1;//高橋が引き返す地点のインデックス
	int l=longpath(keiro[midp],keiro[midp+1],0); //引き返してからどれくらい進めるか
	//cerr<<keiro.size()<<" "<<midp<<" "<<keiro[midp]<<" "<<keiro[midp+1]<<" "<<l<<endl;
	int ans=l+midp;//高橋くんが逃げる距離
	if(keiro.size()&1)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

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

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    int c = 0;
    REP2(i, 1, n+1) {
        if (to_string(i).size() % 2 == 1) {
            c++;
        }
    }
    cout << c << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll x,y;
    cin>>x>>y;
    vector<ll> adj[n+1];
    ll dis[n+1];
    for(ll i=0;i<n-1;++i)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dis[y]=0;
    queue<ll> q;
    q.push(y);
    ll vis[n+1]={0};
    vis[y]=1;
    while(!q.empty())
    {
        ll v=q.front();
        q.pop();
        for(auto u:adj[v])
        {
            if(vis[u]){continue;}
            vis[u]=1;
            q.push(u);
            dis[u]=1+dis[v];
        }
    }

    ll ans=0;
    for(ll i=0;i<=n;++i){vis[i]=0;}
    ll time[n+1]={0};
    q.push(x);
    vis[x]=1;
    time[x]=0;
    while(!q.empty())
    {
        ll v=q.front();
        q.pop();
        for(auto u:adj[v])
        {
            if(vis[u]){continue;}
            time[u]=1+time[v];
            vis[u]=1;
            if(time[u]>dis[u]){continue;}
            if(time[u]==dis[u]){ans=max(ans,time[u]);continue;}
            q.push(u);
            if(dis[u]-time[u]==1){
                ans=max(ans,time[u]);
            }
            else{
                if(adj[u].size()>1){
                    ans=max(ans,dis[u]);
                }
                else{
                    ans=max(ans,dis[u]-1);
                }
            }
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100010;
vector<int> G[N];

int main(){
    int n,m;
    scanf(" %d %d", &n, &m);
    rep(i,m){
        int x,y,z;
        scanf(" %d %d %d", &x, &y, &z);
        --x;
        --y;
        G[x].pb(y);
        G[y].pb(x);
    }

    int c = 0;
    vector<bool> vis(n);
    rep(i,n)if(!vis[i]){
        ++c;
        vis[i]=true;
        queue<int> que({i});
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int e:G[v]){
                if(!vis[e]){
                    vis[e] = true;
                    que.push(e);
                }
            }
        }
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#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 repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int a[50];

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

    int n = 50;
    int r = k%n;
    rep (i,n) a[i] = n-1 + k/n - r;
    rep (i,r) a[i] += n+1;

    cout << n << endl;
    rep (i,n) cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 384
N,M = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}
if sc == [] and N == 1:
  print(0)
  exit()
if sc == [[1,0]] and N == 1:
  print(0)
  exit()
for k in sc:
  if k[0] in dic:
    if dic[k[0]] != k[1]:
      print(-1)
      exit()
  else:
    dic[k[0]] = k[1]
ans = 0
if 1 in dic and dic[1] == 0:
  print(-1)
  exit()
for k in dic:
  ans += 10**(N-k) * dic[k]
if ans < 10**(N-1):
  ans += 10**(N-1)
print(ans)

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

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

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (A, B, C, D) = get!(i64, i64, i64, i64);

    let ans = if A + B > C + D {
        "Left"
    } else if A + B == C + D {
        "Balanced"
    } else {
        "Right"
    };

    // 出力
    println!("{}", ans);
}


Measured memory_bytes: 4352
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let nk: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nk[0] as usize;
    let k = nk[1];
    let a: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut memo = vec![vec![0u64; 60]; 2];

    for i in 0..60 {
        let mut p = 0u64;
        let mut q = 0u64;
        let tar = 1u64 << i;
        for j in 0..n {
            if tar & a[j] > 0 {
                p += tar;
            } else {
                q += tar;
            }
        }
        memo[0][i] = p;
        memo[1][i] = q;
    }

    let mut ans = 0;

    for i in 0..60 {
        let mut tmp = 0;
        let mut tk = 0;
        for j in (0..60).rev() {
            let b = 1u64 << j;
            if i==j || memo[0][j] >= memo[1][j] || tk+b > k {
                tmp += memo[0][j];
            } else {
                tmp += memo[1][j];
                tk += b;
            }
        }
        ans = cmp::max(ans, tmp);
    }


    println!("{}",  ans);
}


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

int main() {
  //input
  int N, K;
  cin >> N >> K;
  int h[N];
  for(int i=0; i<N; i++){cin >> h[i];}
  
  //main
  int INF = 1e9;
  int memo[N];
  for(int i=0; i<N; i++){memo[i] = INF;}
  memo[0] = 0;
  
  for(int i=0; i<N-1; i++) {
    for(int j=0; j<K && i-j>=0; j++) {
      memo[i+1] = min( memo[i+1], memo[i-j]+abs(h[i+1]-h[i-j]) );
    }
  }
  
  //output  
  cout << memo[N-1] << endl;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
import heapq

a=list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(a)

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-tmp_min//2))
print(-sum(a))

Measured memory_bytes: 20316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long> l(n);
  for(int i = 0; i < n; i++)
    cin >> l.at(i);
  int cnt = 0;
  for(int i = 0; i < n - 2; i++){
    for(int j = i + 1; j < n -1; j++){
      for(int k = j + 1; k < n; k++){
        if(l.at(i) == l.at(j) or l.at(j) == l.at(k) or l.at(i) == l.at(k)) continue;
        if(l.at(i) < l.at(j) + l.at(k) and l.at(j) < l.at(k) + l.at(i) and l.at(k) < l.at(i) + l.at(j))
          cnt++;
      }
    }
  }
  
  cout << cnt;
  
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;


bool isprime(int n);

int Q;
int L[100000], R[100000];
int prime[100000], is2017[1000000], n2017[100001];

int main(){
	cin >> Q;
	for(int i=0; i<Q; i++){
		cin >> L[i] >> R[i];
	}
	
	int k = 0; //k:素数の個数
	for(int i=1; i<100000; i++){
		if(isprime(i)){ prime[k] = i; k++;} //prime[i]:i番目の素数
	}
	
	for(int i = 0; i<k; i++){
		for(int j=0; j<k; j++){ 
			if((prime[i]+1)/2 == prime[j]){ is2017[prime[i]] = 1; } //is2017[i]:iが2017に似た数なら1,他は0
		}
	}
	
	n2017[0] = 0;
	for(int i = 1; i<= 100000; i++){
		n2017[i] = n2017[i-1] + is2017[i];
	}
	
	for(int i = 0; i<Q; i++){
		cout << n2017[R[i]] - n2017[L[i]-1] << endl;
	}

}

//素数判定
bool isprime(int n){
	if(n < 2){return false;}
	if(n == 2){return true;}
	if(n % 2 == 0){return false;}
	
	double sqn = sqrt(n);
	for(int i = 3; i<=sqn; i+=2){
		if(n % i == 0){return false;}
	}
	
	return true;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc115/abc115_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, K;
  cin >> N >> K;
  
  vector<ll> h(N);
  rep(i, N) { cin >> h[i]; }
  sort(h.begin(), h.end(), greater<ll>());

  ll ans = 1e10 + 100;
  rep(i, N - K + 1) {
    ans = min(ans, h[i] - h[i + K - 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
//MISHON69
//DATE:6/22/2020
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if((i+1)%2==0&&s[i]=='R'){
       cout<<"No"<<endl;
       return 0;
    }
    else if((i+1)%2!=0&&s[i]=='L'){
       cout<<"No"<<endl;
       return 0;
    }
  }
  cout<<"Yes"<<endl;  
}  


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

int main(){
  int *A;
  int n, v;
  int i, j, k;
  
  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int));

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  for(i=0; i<n; i++){
    if(i==n-1)
      printf("%d",A[i]);
    else
      printf("%d ",A[i]);
  }
  printf("\n");

  for(i=1; i<n; i++){
    v = A[i];
    j = i-1;

    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = v;

    for(k=0; k<n; k++){
      if(k==n-1)
	printf("%d",A[k]);
      else
	printf("%d ",A[k]);
    }
    printf("\n");
  }
  

  free(A);
  return 0;
}



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

using namespace std;

int a,b,c,n,s;

int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50))
                s++;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 256
s = list(input())
ans = 0

for i in range(2**(len(s)-1)):
    ss = s.copy()
    for j in range(len(s)-1,-1,-1):
        if (i>>j)&1:
            ss.insert(j+1, "+")
    k = "".join(ss)
    k = map(int, k.split("+"))
    ans += sum(k)
print(ans)

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

int main(void)
{
	using namespace std;
	
	int n;
	cin >> n;

	bool flg_card[4][13];
	for(int i = 0; i<4; i++){
		for(int j = 0; j<13; j++){
			flg_card[i][j] = true;
		}
	}

	for(int i=0; i<n; i++){
		char mark;
		int number, marknum;
		cin >> mark;
		cin >> number;

		switch(mark){
			case 'S':
				marknum = 0;
				break;

			case 'H':
				marknum = 1;
				break;

			case 'C':
				marknum = 2;
				break;

			case 'D':
				marknum = 3;
				break;
		}

		flg_card[marknum][number-1] = false;
	}


	for(int i = 0; i<4; i++){
		for(int j = 0; j<13; j++){
			if(flg_card[i][j]) {
				char mark;
				switch(i){
					case 0:
						mark = 'S';
						break;
	
					case 1:
						mark = 'H';
						break;
	
					case 2:
						mark = 'C';
						break;
	
					case 3:
						mark = 'D';
						break;
				}
				cout << mark << " " << j+1 << endl;
			}
		}
	}

	return 0;

}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N;
    ll goukei=0;
    cin >> N;

    vector<int> v(N);

    for(int i = 0;i < N;i++)
        cin >> v.at(i);

    for(int i = 0;i < N -1;i++)
        for(int j = i + 1;j < N;j++)
            goukei += v.at(i) * v.at(j);

    cout << goukei << endl;

    
}

Measured memory_bytes: 3576
#include<stdio.h>
long long f(long long a,long long b){//printf("%d %d\n",a,b);
  if((a%2)==(b%2))return a*2;
  else return a*2-1;
}
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,i,s=0,a=0,d[200010];
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  for(i=0;i<n;i++)d[i]*=2;
  for(i=0;i<n;i++)s+=d[i];//printf("%d \n",s);
  s=s/2;//printf("%d\n",s);
  for(i=0;s>d[i]&&i<n;i++)s-=d[i];
  //printf("%d %d %d\n",d[i],s,a);
  //printf("%d %d\n",f(s,a),f(d[i]-s,a));
  printf("%lld\n",MIN(s,d[i]-s));
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

bool isprime(int n)
{
    if(n <= 1) return false;
    for(int i = 2; i * i <= n; ++ i)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    int a, b;
    cin >> a >> b;
    int g = __gcd(a, b);
    vector<int> vec;
    int cnt = 1;
    
    for(int i = 1; i * i <= g; ++ i)
    {
        if(g % i == 0)
        {
            vec.push_back(i);
            if(i * i != g)
                vec.push_back(g / i);
        }
    }
    for(int i = 0; i < (int)vec.size(); ++ i)
    {
        if(isprime(vec[i])) ++ cnt;
    }
    
    cout << cnt << endl;
    
    
    return 0;
}






Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

void solve()
{
    int n;
    scanf("%d", &n);
    const int N = 1000000;
    vector<int> cnt(N+1);
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
    }

    vector<ll> c(N+1);
    for (i = 1; i <= N; i++) {
        ll  tmp = minv(i);
        c[i] = (c[i] + tmp) %MOD;
        int curr = i + i;
        while (curr <= N) {
            c[curr] = (c[curr] - c[i] + MOD) % MOD;
            curr += i;
        }
    }

    ll ans = 0;
    for (i = 1; i <= N; i++) {
        int curr = i;
        ll sum1 = 0, sum2 = 0;
        while (curr <= N) {
            sum1 = (sum1 + cnt[curr] * (ll)curr) % MOD;
            sum2 = (sum2 + cnt[curr] * (ll)curr % MOD * curr %MOD) % MOD;
            curr += i;
        }
        ll sum = (sum1 * sum1 - sum2 + MOD) % MOD;
        sum = sum * minv(2) % MOD;
        ans = (ans + sum * c[i]) % MOD;
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 100000000000000008
#define MOD 998244352
#define N 305	
#define M 1000003
#define C 100000
#define lab(i,j) (((i-1)*n)+j)
#define LOG 19
#define KOK 650
#define EPS 0.0001
using namespace std;

int main() {
 
//	freopen("input.txt","r",stdin);
 
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int n;
	int a[N][N];

	cin>>n;

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=n;j++) {

			cin>>a[i][j];

		}

	}

	int dp[N][N];

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=n;j++) {

			dp[i][j]=a[i][j];

		}

	}

	ll tot=0;

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=n;j++) {

			bool no=1;

			for(int k=1;k<=n;k++) {

				umin(dp[i][j],dp[i][k]+dp[k][j]);

				if(dp[i][j]==dp[i][k]+dp[k][j]) {

					no&=(k==i || k==j);

				}

			}

			if(dp[i][j]!=a[i][j]) {

				cout<<-1;

				return 0;

			}

			tot+=no*a[i][j];

		}

	}
	cout<<tot/2;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>                                                                                                                
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if((a+b) % 2 == 0) cout << (a+b)/2 << '\n';
    else cout << "IMPOSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<list>
using namespace std;
list<int>L;
int main()
{
	int N;
	int d;
	char command[20];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
	   scanf("%s",command);
	   if(command[0]=='i'){
		   scanf("%d",&d);
		   L.push_front(d);
	   }

	   else if(command[6]=='F'){
		   L.pop_front();
	   }
	   else if(command[6]=='L'){
		   L.pop_back();
	   }
	    else if(command[0]=='d'){
		   scanf("%d",&d);
		   for(list<int>::iterator it=L.begin();it!=L.end();it++)
		   {
			   if(d==*it){
				   L.erase(it);
				   break;
			   }
		   }
	   }
	}
	int i=0;
	for(list<int>::iterator it=L.begin();it!=L.end();it++){
		if(i++)printf(" ");
		printf("%d",*it);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 34004