akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){

    long long n, k;
    cin >> n;
    cin >> k;

    vector<long long> v(n);
    for(long long i = 0; i < n; i++){
        cin >> v[i];
    }

    long long num = (n - 1) / (k - 1);
    if((n - 1) % (k - 1) == 0) cout << num  << endl;
    else cout << num + 1 << endl;


    /*
    long long minInd;
    vector<long long> v(n);
    for(long long i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] == 1) minInd = i;
    }
    
    long long left = minInd ;
    long long right = n - 1 - minInd;
    
    long long left_mod = minInd % (k-1);
    long long right_mod = minInd % (k-1);
    */

    


}

Measured memory_bytes: 1024
MOD=10**9+7
X,Y=map(int,input().split())

def powmod(a,p):
  if p==0:
    return 1
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD
def invmod(a):
  return powmod(a,MOD-2)
def comb_mod(n,r):
  r=min(r,n-r)
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    nPr%=MOD
    fact_r*=r-i
    fact_r%=MOD  
  return (nPr*invmod(fact_r))%MOD

if (X+Y)%3!=0:
  print(0)
else:
  u=(2*X-Y)//3
  v=(-X+2*Y)//3
  if u>=0 and v>=0:    
    #print(u,v)
    print(comb_mod(u+v,v))
  else:
    print(0)

Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))
def move():
    global a
    s = [0] * (n + 1)
    for i in range(n):
        s[max(0, i - a[i])] += 1
        s[min(n, i + a[i] + 1)] -= 1
    for i in range(1, n + 1):
        s[i] += s[i - 1]
    if all(map(lambda i: a[i] == s[i], range(n))):
        return True
    a = s
    return False
for _ in range(k):
    if move():
        break
print(*a[:n])

Measured memory_bytes: 160636
//文字変換
#include <stdio.h>
#define MY_STR_MAX 1250
int main(){
    char c;
    for (;;) {
       scanf("%c", &c);
       if (c>=60&&c<=90) {
           c += 32;
       }else if (c>=97&&c<=122) {
           c -= 32;
       }else if (c=='\n') {
           break;
       }
       putchar(c);
    }
    putchar('\n');
}



Measured memory_bytes: 2040
N = int(input())
A = [int(input()) for _ in range(N)]

from bisect import bisect_right
	
def LIS(L) :   
    lis = [L[0]]
    for a in L[1:] :
        if a >= lis[-1] :
            lis.append(a)
        else :
            s = bisect_right(lis, a)
            lis[s] = a
    return len(lis)

print(LIS(A[::-1]))

Measured memory_bytes: 57560
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
 
using namespace std;
/*
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}
*/
int main()
{
    std::map<int,long long int> c;  // nC2
    c[1] = 0;
    for(int i=2; i<=2*100000; i++){
        /*
        int N = i;
        int K = 2;
        vector<vector<long long int> > v(N+1,vector<long long int>(N+1,0));
        comb(v);
        cout << N << "C" << K << " = " << v[N][K] << endl;
        */
        c[i] = c[i-1] + (i-1);
    }
    
    int n;
    cin >> n;
    int a[n];
    std::map<int,int> mp;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
        if(mp.find(tmp) == mp.end()){
            mp[tmp] = 1;
        }else{
            mp[tmp]++;
        }
    }
    
    long long int sum = 0;
    std::map<int,int>::iterator itr = mp.begin();
    while(itr != mp.end()){
        sum += c[itr->second];
        ++itr;
    }
    
    for(int i=0; i<n; i++){
        long long int ans = sum;
        int num = a[i];
        int cnt = mp[num];
        if(cnt >= 2){
            //cout << "num:" << num << ", sum:" << sum;
            //cout << ", " << c[cnt] << ", " << c[cnt-1] << endl;
            ans = ans - c[cnt] + c[cnt-1];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 20864
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>

#include <random>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL


//素数判定
vector<int> pr={2,3,5,7};

bool isprime(int n) {
  int i;
  int prime(int);
  int sz=pr.size();
  int sq = sqrt(n);
  for (i=1; i<sz; i++) {
    int p=pr[i];
    if (p>sq) return true;
    if (n%p==0) return false;
  }
  for (;;i++) {
    int p=prime(i);
    if (p>sq) return true;
    if (n%p==0) return false;
  }
}

//素数生成
int prime(int n) {
  int last = pr.size();
  if (n<last) return pr[n];

  for (int p=pr.back()+2; last <= n; p+=2) {
    if (isprime(p)) {
      last++;
      pr.push_back(p);
    }
  }
  return pr.back();
}


//素因数分解
//引数の整数を素因数分解する。
//mapクラスのキーに基数、対応する値に指数が入っている
map<ll, int> lc;
map<ll, int> fact(ll n) {
  map<ll, int> ret;
  ll base;
  int ix;

  int i;
  for (i=0; n>1; i++) {
    base = prime(i);
    ix = 0;
    while (n%base == 0) {
      ix++;
      n /= base;
    }
    if (ix > 0) {
      ret[base] = ix;
      auto itr = lc.find(base);
      if (itr == lc.end()) {
        lc[base] = ix;
      } else {
        lc[base] = max(ix, lc[base]);
      }
    } else {
      if (base * base >= n) {
        ret[n] = 1;
        auto itr = lc.find(n);
        if (itr == lc.end()) {
          lc[n] = 1;
        } else {
          lc[n] = max(1, lc[n]);
        }
        break;
      }
    }
  }
  return ret;
}

ll n;

ll ipow(int x, int y) {
  ll ret=1;
  for (int i=0; i<y; i++) {
    ret *= x;
  }
  return ret;
}

uint32_t rd();

int main()
{
  ll ans=0;
  map<ll, int> f;

  cin >> n;

  f=fact(n);

  for (auto it=f.begin(); it!=f.end(); it++) {
    int r;
    r = sqrt(it->second);
    while (r*r+r <= it->second*2) r++;
    r--;
    ans += r;
  }

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

uint32_t rd() {
  random_device seed_gen;
  minstd_rand engine(seed_gen());
  return engine();
}

/*
  素数pと正の整数eで z=p^e となるzを選ぶ
  Nがzで割り切れる
  以前の操作で選んだどの整数とも異なる
  */



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

int main() {
	int N;
	cin >> N;
	int f = 0;
	for (int i = N;i > 0;i /= 10) { // 各桁の和を求めているよ
		f += i % 10;
	}
	if (N % f == 0) cout << "Yes"; // 割り切れたなら
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

xをn進数で表した時の各桁の和をyとすると、yは次のように求められます(
for (int i = x;i > 0;i /= n) y += i % n;
これは競プロでは頻出なので覚えておいて損はないです
要するに、1の位は%nで求められるし、次の位も出したいなら一旦nで割れば位が一個落ちるよねって話
後は求めた値がNで割れるか判定して終了
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const int N=2e5;
int n;
ll k;
string s;

P<int, bool> c(bool z){
  char p = z ? '*' : s[n-1];
  int ret = 0;
  FOR(i, 0, n){
    if(s[i]==p){
      p = '*';
      ret++;
    }else{
      p = s[i];
    }
  }
  return mp(ret, p=='*');
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> k;
  n = sz(s);
  auto a = c(true), b = c(false);
  ll ans;
  if(a.se){
    ans = k*a.fi;
  }else if(b.se){
    ans = (k+1)/2*a.fi + k/2*b.fi;
  }else{
    ans = (k-1)*b.fi + a.fi;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
rank = [[0,0] for i in range(4)]
while True:
    try:
        eye = map(float, raw_input().split())
        for i in range(2):
            if   eye[i] >= 1.1: rank[0][i] += 1
            elif eye[i] >= 0.6: rank[1][i] += 1
            elif eye[i] >= 0.2: rank[2][i] += 1
            else:                   rank[3][i] += 1
    except:
        break
for i in range(4):
    print " ".join(map(str, rank[i]))

Measured memory_bytes: 4252
#include<stdio.h>

int main(void){

int a,b,c,w;

scanf("%d %d %d",&a,&b,&c);

if(a > b){
 w=a;a=b;b=w;
}
if(a > c){
 w=a;a=c;c=w;
}
if(b > c){
 w=b;b=c;c=w;
}
if(a > c){
 w=a;a=c;c=w;
}

printf("%d %d %d\n",a,b,c);

return 0;
}

Measured memory_bytes: 596
N,M = map(int, input().split())
H = [0] + list(map(int, input().split()))
P = [0] + [1]*N
for i in range(M):
  A,B = map(int, input().split())
  if H[A]<=H[B]:
    P[A]=0
  if H[A]>=H[B]:
    P[B]=0
print(sum(P))


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

int main(){
    char c[1]={};
    cin >> c;
    if(c[0]=='a'||c[0]=='e'||
    c[0]=='i'||c[0]=='o'||c[0]=='u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n>>m>>cnt;
    rep(i,n){
        if((i+1)/10000+(i+1)/1000%10+(i+1)/100%10+(i+1)/10%10+(i+1)%10>=m&&(i+1)/10000+(i+1)/1000%10+(i+1)/100%10+(i+1)/10%10+(i+1)%10<=cnt){
            ans+=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10476
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
ll a[N];
int main() {
	while(~scanf("%d", &n)) {
		rep(i, 1, n + 1) scanf("%lld", a + i);
		int cnt = 0;
		ll ans = 0, mn = 2e9;
		rep(i, 1, n + 1) {
			ans += abs(a[i]);
			if(a[i] < 0) cnt++;
			mn = min(mn, 1ll * abs(a[i]));
		}
		if(cnt & 1) ans -= 2 * mn;
		printf("%lld\n", ans);
	}
    return 0;
}


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

using namespace std;

double dp[3000][3000];
double a[3000];
int n;

main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = ((j > 0) ? (dp[i - 1][j - 1] * a[i]) : 0) + dp[i - 1][j] * (1 - a[i]);
		}
	}
	for (int i = n / 2 + 1; i < n; i++) {
		dp[n][i + 1] += dp[n][i];
	}
	cout << fixed << setprecision(10);
	cout << dp[n][n];
}


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

int main() {
  int W;
  cin>>W;
  string S="No";
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if(i*j==W){
         S="Yes";
      }
    }
  }
  cout <<S<<endl;
  
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <cmath>
#define PI 3.14159265359
using namespace std;

struct point{
	double x;
	double y;
};

struct point addPoint(point p1,point p2){
	point p3;
	p3.x = p1.x + p2.x;
	p3.y = p1.y + p2.y;
	return p3;
}


struct point subtractPoint(point p1,point p2){
	point p3;
	p3.x = p1.x - p2.x;
	p3.y = p1.y - p2.y;
	return p3;
}

struct point multiplyPoint(point p,double k){
	point p3;
	p3.x = p.x * k;
	p3.y = p.y * k;
	return p3;
}

struct point rotate(point p,double degree){
	point newP;
	double degree_rad = PI*degree/180.0;
	newP.x = p.x * cos(degree_rad) - p.y * sin(degree_rad);
	newP.y = p.x * sin(degree_rad) + p.y * cos(degree_rad);
	return newP;
}

void printPoint(point p){
	printf("%3.8lf  %3.8lf\n",p.x,p.y);
}

void kochCurve(point pStart,point pEnd,int count){
	if(count == 0) return;
	point p1,p2,p3;
	point vector1,vector2;
	vector1 = multiplyPoint(subtractPoint(pEnd,pStart),1.0/3.0);
	p1 = addPoint(pStart,vector1);
	p3 = addPoint(p1,vector1);
	vector2 = rotate(vector1,60);
	p2 = addPoint(p1,vector2);
	kochCurve(pStart,p1,count - 1);
	printPoint(p1);
	kochCurve(p1,p2,count - 1);
	printPoint(p2);
	kochCurve(p2,p3,count - 1);
	printPoint(p3);
	kochCurve(p3,pEnd,count - 1);
}

int main()
{
	int n;
	cin >> n;
	point pStart,pEnd;
	pStart.x = 0.0;
	pStart.y = 0.0;
	pEnd.x = 100.0;
	pEnd.y = 0.0;
	printPoint(pStart);
	kochCurve(pStart,pEnd,n);
	printPoint(pEnd);
	return 0;
}





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

int main()
{	
	int ans=0, i, j, k;
	int n, p[20] = {0};
	cin >> n;
	for (i = 0; i < n;i++){
		cin >> p[i];
	}

	for (i = 0; i < n - 2;i++){
		if(((p[i]<p[i+1])&&(p[i+1]<p[i+2]))||((p[i]>p[i+1])&&(p[i+1]>p[i+2])))
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

class FFT {
	static void fft(vector<com>& vec, int inv) {
		int s = vec.size();
		if (s == 1) return;
		vector<com> veca, vecb;
		for (int i = 0; i < s / 2; i++) {
			veca.pb(vec[2 * i]);
			vecb.pb(vec[2 * i + 1]);
		}
		fft(veca, inv);
		fft(vecb, inv);
		com x = 1;
		com z = polar(1.0, 2 * inv * PI / s);
		int t = s / 2 - 1;
		for (int i = 0; i < s; i++) {
			vec[i] = veca[i&t] + x * vecb[i&t];
			x *= z;
		}
	}
public:
	template<class T>
	static vector<int> multiply(vector<T> f, vector<T> g) {
		int s = 1;
		while (s < f.size() + g.size()) {
			s *= 2;
		}
		f.resize(s); g.resize(s);
		fft(f, 1); fft(g, 1);
		for (int i = 0; i < s; i++) f[i] *= g[i];
		fft(f, -1);
		vector<int> res;
		for (int i = 0; i < s; i++) {
			double d = f[i].real() / s;
			res.pb((int)(d + 0.5));
		}
		return res;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<com> c(100010);
	rep(i, n) {
		cin >> a[i];
		c[a[i]] += 1;
	}
	int ans = 0;
	vector<int> cnt = FFT::multiply(c, c);
	for (int i = 200000; i >= 0; i--) {
		if (cnt[i] < m) {
			ans += i * cnt[i];
			m -= cnt[i];
		}
		else if (m > 0) {
			ans += i * m;
			m = 0;
		}
		if (m == 0) break;
	}
	cout << ans << endl;
}

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

int main() {
	string str;
	cin >> str;

	if (str.at(2) == str.at(3) && str.at(4) == str.at(5)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int N;
    int A[100000];
    int ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A+N);
    if(N == 2){
        cout << A[1] - A[0] << endl;
        cout << A[1] << ' ' << A[0] << endl;
        return 0;
    }
    if(A[1] > 0){
        ans = -A[0];
        for(int i = 1; i < N; i++) ans += A[i];
        int sum = A[0]-A[1];
        cout << ans << endl;
        cout << A[0] << ' ' << A[1] << endl;
        for(int i = 2; i < N-1; i++){
            cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
        cout << A[N-1] << ' ' << sum << endl;
    }else if(A[N-2] < 0){
        ans = A[N-1];
        for(int i = N-2; i >= 0; i--) ans -= A[i];
        cout << ans << endl;
        int sum = A[N-1];
        for(int i = N-2; i >= 0; i--){
            cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
    }else{
        int idx;
        for(int i = 2; i < N; i++){
            if(A[i] >= 0) {
                idx = i;
                break;
            }
        }
        int sum = A[0];
        for(int i = idx; i < N-1; i++){
            //cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
        //cout << A[N-1] << ' ' << sum << endl;
        sum = A[N-1]-sum;
        for(int i = 1; i < idx; i++){
            //cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
        cout << sum << endl;
        sum = A[0];
        for(int i = idx; i < N-1; i++){
            cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
        cout << A[N-1] << ' ' << sum << endl;
        sum = A[N-1]-sum;
        for(int i = 1; i < idx; i++){
            cout << sum << ' ' << A[i] << endl;
            sum -= A[i];
        }
    }
}

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

int N,A,B,C;
int min_cost=1<<21;
int l[8];
int natural_num(int i){
    if(i < 0){
        return 0;
    } else {
        return i;
    }
}

void calc(vector<int> v){
    // cout << "calc" << endl;
    int a=0,b=0,c=0,i=-1;
    int A_sol=0,B_sol=0,C_sol=0;
    int cost=0;
    // 各枝での合体後のA,B,C候補を計算
    for(auto itr=v.begin();itr!=v.end();itr++){
        i++;
        // cout << i << endl;
        if(*itr == 0){
            a++;
            A_sol += l[i];
        } else if(*itr == 1){
            b++;
            B_sol += l[i];
        } else if(*itr ==2){
            c++;
            C_sol += l[i];
        }
    }
    if(a!=0 and b!=0 and c!=0){
        // 合体にかかるコストを計算
        cost += natural_num(a-1) * 10;
        cost += natural_num(b-1) * 10;
        cost += natural_num(c-1) * 10;
        // 差を計算
        cost += abs(A-A_sol);
        cost += abs(B-B_sol);
        cost += abs(C-C_sol);
        // costの最小値更新
        // cout << cost;
        if(cost < min_cost) min_cost=cost;
    }
}

int main(void) {
    cin>>N>>A>>B>>C;
    for (int i=0;i<N;i++){
        cin>>l[i];
    }
    vector<int> v(N);
    for(int i=0;i<2<<(N*2);i++){
        for(int k=0;k<N;k++){
            v[k]=i>>2*k & 3;
        }
        calc(v);
    }
    cout << min_cost;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N, x = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]
    As.sort()

    cnt = 0
    while x > 0 and cnt < N:
        x -= As[cnt]
        if cnt == N-1:
            if x == 0:
                cnt += 1
        else:
            if x >= 0:
                cnt += 1
    
    print(cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9164
n=int(input())  #数値入力 「N」だけの入力のとき
s=[]
cnt=0
for i in range(n):
    s.append(''.join(sorted(input())))

ss=sorted(s)

renzoku=0
for k in range(len(ss)-1):
    #print(ss[k],ss[k+1])
    if ss[k]==ss[k+1]:
        renzoku+=1
    else:
        cnt+= (renzoku+1)*(renzoku)//2
        #print(cnt)
        renzoku=0

cnt+= (renzoku+1)*(renzoku)//2
print(cnt)

Measured memory_bytes: 11408
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int X = (A); X <= (Y);++X)
#define _rep2(X, Y) for (int X = 0; X < (Y); ++X)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int X = (Y-1); X >= 0; --X)
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

int main() {
    cin >> S;

    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

void solvetask(){
    string s, t; cin >> s >> t;
    int ans = 0;
    for (int i=0; i<s.size(); i++) ans += s[i] != t[i];
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3752
#include <stdio.h>

int main (void)
{
    int a[3],i;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    if(a[0]==a[1])
    {
        printf("%d\n",a[2]);
    }else{
        if(a[1]==a[2])
        {
            printf("%d\n",a[0]);
        }else{
            printf("%d\n",a[1]);
        }
    }
    return 0;
}

Measured memory_bytes: 128
///dit me set
///tao xai Fenwick Tree

#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5;

int n;
int a[maxN * 3];
int64_t f[maxN * 3], g[maxN * 3];
map<pair<int, int>, int> pos;

int cnt[maxN * 3];
int64_t fwt[maxN * 3];

void upd(int idx, int64_t val) {
    for(; idx < 3 * maxN; idx += idx & -idx) {
        fwt[idx] += val;
        cnt[idx] += 1;
    }
}

pair<int64_t, int> sum(int idx) {
    int64_t total = 0;
    int bar = 0;
    for(; idx > 0; idx -= idx & -idx) {
        total += fwt[idx];
        bar += cnt[idx];
    }
    return {total, bar};
}

pair<int64_t, int> sum(int l, int r) {
    auto rr = sum(r);
    auto ll = sum(l - 1);

    return {rr.first - ll.first, rr.second - ll.second};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;

    int counter = 0;

    vector<pair<int, int> > vv;

    for(int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
        vv.emplace_back(a[i], i);
    }

    sort(vv.begin(), vv.end());

    for(auto p : vv)
        pos[p] = ++counter;

    int64_t pre = 0;

    for(int i = 1; i <= 2 * n; i++) {
        upd(pos[{a[i], i}], a[i]);
        pre += a[i];
        int64_t curSum = pre;

        if(i >= n) {
            int k = i - n;

            if(k) {
                int lo = 1, hi = 3 * maxN - 1;
                while(lo <= hi) {
                    int mid = (lo + hi) / 2;
                    auto curPair = sum(1, mid);
                    if(curPair.second > k) {
                        hi = mid - 1;
                    } else if(curPair.second < k) {
                        lo = mid + 1;
                    } else {
                        curSum -= curPair.first;
                        break;
                    }
                }
            }

            f[i] = curSum;
        }
    }

    for(int i = 0; i < 3 * maxN; i++)
        fwt[i] = cnt[i] = 0;

    int64_t suf = 0;
    for(int i = 3 * n; i > n; i--) {
        upd(pos[{a[i], i}], a[i]);
        suf += a[i];
        int64_t curSum = suf;

        if(i <= 3 * n - n + 1) {
            int k = 3 * n - n + 1 - i;
            if(k) {
                int lo = 1, hi = 3 * maxN - 1;
                while(lo <= hi) {
                    int mid = (lo + hi) / 2;
                    auto curPair = sum(mid, 3 * maxN - 1);
                    if(curPair.second > k) {
                        lo = mid + 1;
                    } else if(curPair.second < k) {
                        hi = mid - 1;
                    } else {
                        curSum -= curPair.first;
                        break;
                    }
                }
            }

            g[i] = curSum;
        }
    }

    int64_t ans = -1e18;
    for(int i = n; i <= n + n; i++) {
        ans = max(ans, f[i] - g[i + 1]);
    }

    cout << ans << '\n';

    return 0;
}


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

int main(){
    string s;
    cin>>s;
    if(s[0] != s[1] && s[0] != s[2] && s[1] != s[2]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

void shuffle(int card[], int p, int c);

int main()
{
    int n, r;
    while(1){
        cin >> n >> r;
        if(n == 0 && r == 0) break;
        int card[50];
        for(int i = 0; i < n; i++){
            card[n - 1 - i] = i + 1;
        }
        int p, c;
        for(int i = 0; i < r; i++){
            cin >> p >> c;
            shuffle(card, p, c);
        }
        cout << card[0] << endl;
    }
    return 0;
}

void shuffle(int card[], int p, int c)
{
    int hozon[50];
    for(int i = 0; i < p - 1; i++){
        hozon[i] = card[i];
    }
    for(int i = 0; i < c; i++){
        card[i] = card[i + p - 1];
    }
    for(int i = 0; i < p - 1; i++){
        card[c + i] = hozon[i];
    }
    return;
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    vector<int> v(4,0);
    for(int i=0;i<n;i++) {
        string s;
        cin>>s;
        if(s=="AC") v[0]++;
        else if(s=="WA") v[1]++;
        else if(s=="TLE") v[2]++;
        else v[3]++;
    }
    cout<<"AC x "<<v[0]<<newl;
    cout<<"WA x "<<v[1]<<newl;
    cout<<"TLE x "<<v[2]<<newl;
    cout<<"RE x "<<v[3];
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
/*???????±±?????????3?????????*/
int main()
{
    vector<int> vc;
    int N;
    while( cin >> N )
    {
        vc.push_back( N );
    }
    sort( vc.begin(), vc.end(), greater<int>() );
    REP( i, 3 )
    {
        cout << vc[ i ] << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0; i<n; ++i)

int main() {
  int n, k;
  cin >> n >> k;
  int x[101];
  rep(i, n) cin >> x[i];
  int min = 0;

  rep(i, n) {
    if(x[i] < k-x[i]) {
      min += x[i]*2;
    }else {
      min += (k-x[i])*2;
    }
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
 
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int _=1;_<=k;_++){
        memset(b,0,sizeof b);
        for(int i=0;i<n;i++){
            int l=max(0,i-a[i]);
            int r=min(n,a[i]+i+1);
            b[l]++;
            if(r<n)b[r]--;
        }
        for(int i=1;i<n;i++)
            b[i]+=b[i-1];
        int ok=1;
        for(int i=0;i<n;i++){
            if(b[i]!=n)ok=0;
        }
        for(int i=0;i<n;i++)swap(a[i],b[i]);
        if(ok)break;
    }
    for(int i=0;i<n;i++)
        cout << a[i] << ' ';
}

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

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<pair<ll,int>> A(0);
    for(int i=1; i<=N; i++){
        ll a;
        cin >> a;
        A.push_back(make_pair(a,i));
    }
    sort(A.rbegin(), A.rend());

    vector<vector<ll>> dp(N+1,vector<ll>(N+1,0));

    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++){
            dp[i-j+1][j]=max(dp[i-j+1][j],dp[i-j][j]+A[i].first*abs(A[i].second-(i-j+1)));
            dp[i-j][j+1]=max(dp[i-j][j+1],dp[i-j][j]+A[i].first*abs(A[i].second-(N-j)));
        }
    }
    ll ans=0;
    for(int i=0; i<=N; i++){
        ans=max(ans,dp[i][N-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 34672
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        h: usize,
        n: usize,
        ab: [(usize, usize); n],
    }

    let mut dp = vec![0usize; h+1];
    
    dp[0] = 0;

    for i in 1..=h {
        let mut min = None;
        for &(a, b) in ab.iter() {
            if i < a {
                if let Some(v) = min {
                    if v > b {
                        min = Some(b);
                    }
                } else {
                    min = Some(b);
                }
            } else {
                let cost = dp[i-a] + b;
                if let Some(v) = min {
                    if v > cost {
                        min = Some(cost);
                    }
                } else {
                    min = Some(cost);
                }
            }
        }
        if let Some(min) = min {
            dp[i] = min;
        }
    }

    println!("{}", dp[h]);
}

Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const int DX[4] = {0, 0, +1, -1};
const int DY[4] = {+1, -1, 0, 0};
const int TYPE[4] = {1, 2, 4, 8};
int main() {
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    vector<string> C(H); for (auto &c : C) cin >> c;
    vector<vector<int>> done(H, vector<int>(W));
    vector<vector<int>> cost(H, vector<int>(W, 1e9));
    queue<tuple<int, int, int>> Q;
    Q.emplace(0, x1, y1);
    cost[x1][y1] = 0;
    while (!Q.empty()) {
        auto [c, x, y] = Q.front(); Q.pop();
        if (cost[x][y] != c) continue;
        if (x == x2 && y == y2) {
            cout << c << '\n';
            return 0;
        }
        for (int i = 0; i < 4; i++) {
            if ((done[x][y] & TYPE[i]) != 0) continue;
            int nx = x, ny = y, rest = K;
            while (rest) {
                nx += DX[i], ny += DY[i], rest--;
                if (!(0 <= nx && nx < H && 0 <= ny && ny < W)) break;
                if (C[nx][ny] != '.') break;
                if (cost[nx][ny] == c && (done[nx][ny] & TYPE[i]) == 0) {
                    done[nx][ny] |= TYPE[i];
                    rest = K;
                } else if (cost[nx][ny] <= c) {
                    break;
                } else if (cost[nx][ny] > c + 1) {
                    cost[nx][ny] = c + 1;
                    Q.emplace(c + 1, nx, ny);
                }
            }
            done[x][y] |= TYPE[i];
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 16032
#include <iostream>
#include <queue>


using namespace std;

int main(int argc, const char * argv[]) {
    
    int n;
    cin>>n;
    
    queue<int> que[n];
    
    int q;
    cin>>q;
    
    
    for(int i=0;i!=q;++i){
        int query;
        
        cin>>query;
        
        int t;
        cin>>t;
        
        switch (query) {
            case 0:
                int x;
                cin>>x;
                
                que[t].push(x);
                break;
                
            case 1:
                if(que[t].empty()) break;
                cout<<que[t].front()<<endl;
                break;
            case 2:
                if(que[t].empty()) break;
                que[t].pop();
                break;
        }
        
    }
    
    return 0;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    Int res = 0;
    for (Int i =1; i <= n; i++) {
        res += i;
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 9999999999
using namespace std;
typedef long long ll;

int main()
{
 
    

        

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      
    string s;
    cin>>s;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

long long hash_table[1046528] = {};

int hashed_key(long long key_value, int collision_times) {
    int m = 1046527;

    int h1 = key_value % m;
    int h2 = 1 + key_value % (m-1);

    return (h1 + collision_times * h2) % m;
}

long long string2value(string key_string) {
    long long key = 0;
    long long digit = 1;

    for(int si = 0; si < key_string.size(); si++) {
        char target = key_string[si];

        if (target == 'A') key += 1 * digit;
        else if (target == 'T') key += 2 * digit;
        else if (target == 'C') key += 3 * digit;
        else if (target == 'G') key += 4 * digit;
        else key += 0;

        digit *= 5;
    }

    return key;
}

void insert(string key_string) {
    long long key_value = string2value(key_string);
    int collision_time = 0;

    while(true) {
        int candidate_hashed_key = hashed_key(key_value, collision_time);

        if (hash_table[candidate_hashed_key] == 0) {
            hash_table[candidate_hashed_key] = key_value;
            return;
        } else {
            collision_time += 1;
        }
    }
}

bool isKeyString(string key_string) {
    long long key_value = string2value(key_string);
    int collision_time = 0;

    while(true) {
        int candidate_hashed_key = hashed_key(key_value, collision_time);

        if (hash_table[candidate_hashed_key] == key_value) return true;
        else if (hash_table[candidate_hashed_key] != 0) collision_time += 1;
        else return false;
    }
}

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

    string cmd;
    string key_string;

    for(int i=0; i < n; i++){
        cin >> cmd >> key_string;

        if (cmd[0] == 'i') insert(key_string);
        else if (cmd[0] == 'f') isKeyString(key_string)? printf("yes\n") : printf("no\n"); 
    }
}


Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template<class RIt> void dbarr(RIt frs, RIt lst){ cerr << "arr: "; for(int i = 0; i < (int)(lst-frs); i++) cerr << frs[i] << " \n"[i==(int)(lst-frs)-1]; }
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main() {
	cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    vector<int> a(n);
    for(int& v : a) cin >> v;
    unordered_map<int,int> f;

    vector<int> sides;

    for(int v : a){
        f[v]++;
        if(f[v] >= 2 && f[v] % 2 == 0){
            sides.eb(v);
        }
    }
    if(sides.size() <= 1){
        cout << "0\n";
        return 0;
    }

    sort(all(sides),greater<>());
    cout << 1ll*sides[0]*sides[1] << "\n";
}



Measured memory_bytes: 7720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m; cin >> n >> m;
    vector<bool> issafe(n + 1, true);
    rep(i, m)
    {
        int a;
        cin >> a;
        issafe[a] = false;
    }

    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    Rep(i, 2, n + 1)
    {
        if (issafe[i - 1]) dp[i] += dp[i - 1];
        if (issafe[i - 2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 
const int mxn = 1e5+10;
int main(){
    ios::sync_with_stdio(false);
    int n = input(), m = input();
    vector<int> post(n+1, -1), adj[mxn];
    queue<int> q;
    q.push(1);
    for(int i = 0; i != m; ++i){
        int u = input(), v = input();
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while(not q.empty()){
        int cur = q.front();
        q.pop();
        for(int nx : adj[cur]){
            if(post[nx] == - 1){
                q.push(nx);
                post[nx] = cur;
            }
        }
    }
    int fail = count_if(post.begin()+1, post.end(), [](int i){return i == -1;});
    if(fail > 0) cout << "No\n";
    else{
        cout << "Yes\n";
        for(int i = 2; i <= n; ++i) cout << post[i] << "\n";
    }
}

Measured memory_bytes: 10168
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main() {
    long long h, w;
    int n;

    cin >> h >> w >> n;

    long long a, b;
    map<pair<long long, long long>, long long> mp;

    for (int i = 0; i < n; i++) {
        cin >> a >> b;

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a - j >= 1 && b - k >= 1 &&
                    a - j + 2 <= h && b - k + 2 <= w) {
                    mp[make_pair(a - j, b - k)]++;
                }
            }
        }
    }

    long long ans[10];

    for (int i = 0; i < 10; i++) {
        if (i == 0) {
            ans[i] = (h-2) * (w-2);
        } else {
            ans[i] = 0;
        }
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans[0]--;
        ans[itr->second]++;
    }

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 56448
#include <stdio.h>
int main(void)
{
    int i,j,H,W;
    while(scanf("%d %d",&H,&W)!=EOF)
    {
        if(H==0&&W==0)
        {
            break;
        }
        for ( i = 0; i < H; i++ )
        {
        for ( j = 0; j < W; j++ )
            {
                printf("#");
            }
             
            printf("\n");
        }
        printf("\n");
    }
    return(0);
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using LLpair = pair<LL, LL>;

#define DEBUG

int main() {
  string s, t;
  cin >> s;
  cin >> t;

  auto tsub = t.substr(0, t.size() - 1);
  //cout << tsub << endl;
  if (tsub == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);

		UnionFind uf = new UnionFind(n);
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]) - 1;
			int y = Integer.parseInt(sa[1]) - 1;
			uf.union(x, y);
		}
		br.close();

		System.out.println(uf.num);
	}

	static class UnionFind {
		int[] parent, size;
		int num = 0; // 連結成分の数

		UnionFind(int n) {
			parent = new int[n];
			size = new int[n];
			num = n;
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				size[i] = 1;
			}
		}

		void union(int x, int y) {
			int px = find(x);
			int py = find(y);
			if (px != py) {
				parent[px] = py;
				size[py] += size[px];
				num--;
			}
		}

		int find(int x) {
			if (parent[x] == x) {
				return x;
			}
			parent[x] = find(parent[x]);
			return parent[x];
		}

		/**
		 * xとyが同一連結成分か
		 */
		boolean same(int x, int y) {
			return find(x) == find(y);
		}

		/**
		 * xを含む連結成分のサイズ
		 */
		int size(int x) {
			return size[find(x)];
		}
	}
}


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

int mod = 1000000007;
int n;
int a[21][21];
int dp[1 << 21];

int dfs(int p, int rem) {
	if (p == n) return 1;
	if (dp[rem] != -1) return dp[rem];
	
	int i, ret = 0;
	rep(i, n) {
		if ((rem >> i) % 2 == 1 && a[p][i] == 1) {
			ret += dfs(p + 1, rem - (1 << i));
			ret %= mod;
		}
	}
	return dp[rem] = ret;
}

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) rep(j, n) cin >> a[i][j];
	rep(i, (1 << n)) dp[i] = -1;
	cout << dfs(0, (1 << n) - 1) << endl;
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
 
int main()
{
  int n;
  int reverse = 0;
  int remaind;
  int tmp;

  scanf("%d", &n);
 
  tmp = n;
  while(tmp!=0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }

  if( reverse == n)
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
    Info(int arg_start,int arg_end){
        start = arg_start;
        end = arg_end;
    }
    int start,end;
};

ll dp[5001][5001],work[16000];


int main(){

    int N,M,K,Q;

    scanf("%d %d %d %d",&N,&M,&K,&Q);

    int LIMIT = 0;
    while(LIMIT < N)LIMIT += 2*K;

    vector<Info> V;

    for(int day = 0; day <= M; day++){
        for(int num = 0; num <= N-1; num++)dp[day][num] = 0;
    }

    dp[0][0] = 1;

    for(int day = 0; day <= M-1; day++){

        for(int i = 0; i < 2*N; i++)work[i] = 0;

        for(int num = 0; num <= N-1; num++){

            if(dp[day][num] == 0)continue;

            work[num] += dp[day][num];
            work[num+K] -= dp[day][num];
            work[num+LIMIT] -= dp[day][num];
            work[num+LIMIT+K] += dp[day][num];
        }

        for(int i = 1; i < 2*N; i++){
            work[i] += work[i-1];
        }

        for(int i = 0; i < 2*N; i++){
            if(i+2*K < 2*N){
                work[i+2*K] += work[i];
            }else{
                break;
            }
        }

        dp[day+1][0] += work[0]%MOD;
        dp[day+1][0] %= MOD;

        for(int i = 1; i < 2*N; i++){
            dp[day+1][i%N] += work[i]%MOD;
            dp[day+1][i%N] %= MOD;
        }
    }

    int a,b,c;

    for(int loop = 0; loop < Q; loop++){
        scanf("%d %d %d",&a,&b,&c);

        c = (c-a+N)%N;

        printf("%lld\n",dp[b][c]%MOD);
    }

    return 0;
}



Measured memory_bytes: 198684