akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<char, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main() {
  string s; cin >>s;
  vector<P> v;
  int cnt = 1;
  FOR(i, 1, s.length()){
    if(s[i] == s[i - 1]) ++cnt;
    else {
      v.push_back( P(s[i - 1], cnt) );
      cnt = 1;
    }
  }
  v.push_back( P(s[s.length() - 1], cnt) );
  //REP(i, v.size()) cout <<v[i].first <<", " <<v[i].second <<endl;

  int k = 0;
  REP(i, v.size() - 2){
    //cout <<v[i].first <<", " <<v[i + 1].first <<", " <<v[i + 2].first <<endl;
    if(!(v[i].first == 'J' && v[i + 1].first == 'O' && v[i + 2].first == 'I')) continue;
    int min_num = min(v[i].second, min(v[i + 1].second, v[i + 2].second));
    if(!(v[i].second >= v[i + 1].second && v[i + 1].second <= v[i + 2].second)) continue;
    k = max(k, v[i + 1].second);
  }
  cout <<k <<endl;
  return 0;
}

Measured memory_bytes: 11700
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut count = 0i64;
    for i in 0..s.len() {
        if s[i] != t[i] {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4016
/* Click on the checkbox for Add Custom Input and then write the input there before running the program */
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	    Scanner input = new Scanner(System.in);
	    long a = input.nextLong();
	    long b = input.nextLong();
	    long c = input.nextLong();
	    boolean sol = false;
	    if((c-(a+b)<1)){
	    
	    }else{
	    sol = 4*a*b<(c-(a+b))*(c-(a+b));
	    }
	    
	    if(sol)
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  int min=1, sum=0;
  for(int i=1; i<=n; i++){
    if(abs(l+i-1)<abs(l+min-1)) min=i;
    sum+=l+i-1;
  }
  cout << sum-(l+min-1);
  return 0;
}

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

using namespace std;

typedef pair <int, int> pii;

int main(){
        int N, H;
        cin>>N>>H;
        vector <int> a(N), b(N);
        for(int i=0;i<N;i++){
                cin>>a[i]>>b[i];
        }
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());
        int h=0;
        int res=0;
        int bnow=0;
        while(h<H){
                if(b[bnow]>a[0]){
                        h+=b[bnow++];
                }
                else{
                        res+=(H-h)/a[0];
                        if((H-h)%a[0]!=0){
                                res++;
                        }
                        break;
                }
                res++;
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 1024
#n,m=map(int,input().split())
#p_3,p_4=map(int,input().split())
#n=int(input())
#a=int(input())
#b=int(input())
s=list(input())
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#b=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
judge=True
for i in range(len(s)):
    if i%2==0:
        if s[i]=="L":
            judge=False
    else:
        if s[i]=="R":
            judge=False
print("Yes") if judge else print("No")

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,k;
    cin>>n>>k;
    ll ans=1;
    rep(i,n){
        if(ans*2<=ans+k) ans*=2;
        else ans+=k;
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
/*
    Author : DemonStar
*/

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int rec(vi &dp, vector<vi> &v, int i)
{
    int &ans = dp[i];
    if (ans != -1)
        return ans;
    ans = 0;
    for (auto x : v[i])
    {
        ans = max(ans, 1 + rec(dp, v, x));
    }
    return ans;
}

int main()
{
    int n, k;
    cin >> n;
    vl v(n);
    cin >> v;
    vector<vl> dp(n + 1, vl(n + 1, 0));
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = i; j < n; j++)
        {
            if (i == j)
                dp[i][j] = v[i];
            else
                dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]);
        }
    }
    cout << dp[0][n - 1] << endl;

#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

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

typedef long long lint;

int M[1000100],n,S[1000100],m;
lint sumA=0,sumB=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) S[i]=3;
	for(int i=0;i<n;i++){
		char ch;
		cin>>ch;
		if(ch=='D') S[i]=2;
		if(ch=='M') S[i]=1;
		if(ch=='C') S[i]=0;
	}
	for(int i=0;i<n;i++){
		if(S[i]==1) M[i]++;
		if(i!=0) M[i]+=M[i-1];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int k;
		lint sumA=0,ans=0;
		cin>>k;
		queue <int> Q;
		for(int j=0;j<n;j++){
			if(Q.front()+k<j+1&&Q.size()>0){
				sumA-=M[Q.front()];
				Q.pop();
			}
			if(S[j]==0){
				while(Q.front()+k<j+1&&Q.size()>0){
					sumA-=M[Q.front()];
					Q.pop();
				}
				ans+=Q.size()*M[j]-sumA;
			}
			if(S[j]==2){
				Q.push(j);
				sumA+=M[j];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main() {
  while(1) {
    int count=0;
    string s;
    getline(cin,s);
    if(s=="END OF INPUT") break;
    for(int i=0; i<s.size(); i++) {
      if(s[i]==' ') {
	cout << count;
	count = 0;
      } else count++;
    }
    cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll x;
    cin >> x;
    ll ans = x / 11;
    x -= ans * 11;
    ans *= 2;
    if (x > 0) {
        x -= 6;
        ans++;
        if (x > 0) ans++;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>A(5);
  for(int i=0;i<5;i++)
    cin>>A.at(i);
  int ans=0;
  for(int i=0;i<5;i++)
    if(A.at(i)==0){ans=i+1;break;}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3452
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n, m, d := r.nextInt(), r.nextInt(), r.nextInt()
	x := float64((n-(1+d)+1)+((n-d)-1+1)*b2i(d > 0)) / float64(n) / float64(n) * float64(m-1)

	fmt.Fprintln(stdout, x)
}


Measured memory_bytes: 640
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A=[]
for i in range(M):
    A.append(list(map(int, input().split())))
result=[]
for i in range(N):
    result.append(1)

for j in A:
    # 自分より大きいものに説臆されていたらNG
    if H[j[0]-1] > H[j[1]-1]:
        result[j[1]-1]=0
    else:
        result[j[0]-1]=0
    if H[j[0]-1] == H[j[1]-1]:
        result[j[0]-1]=0
        result[j[1]-1]=0
#print(result)
print(result.count(1))

Measured memory_bytes: 32060
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,lst,cur,cnt[2];//0:L 1:R
string s;
long long res,MOD=1000000007LL;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s;
	lst=0;
	res=1LL;
	cnt[0]=1;
	if(s[0]=='W'||s[n*2-1]=='W'){cout<<0<<endl;return 0;}
	for(int i=1;i<n*2;i++){
		if(s[i]==s[i-1]) cur=1-lst;
		else cur=lst;
		if(cur==0&&i==n*2-1){cout<<0<<endl;return 0;}
		if(cur==1){
			if(cnt[0]<=cnt[1]){cout<<0<<endl;return 0;}
			res=(res*(long long)(cnt[0]-cnt[1]))%MOD;
		}
		cnt[cur]++;
		lst=cur;
	}
	if(cnt[0]-cnt[1]>0)
		res=0;
	for(int i=1;i<=n;i++) res=(res*(long long)(i))%MOD;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int ans = solve();
		System.out.println(ans);
	}
	
	private static int solve() {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		int count = 0;
		for (int i = 0; i < 6; i++) {
			if ((str.charAt(i)) == '1') {
				count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 23764
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans float64
	for i := 1; i <= n; i++ {
		p := 1.0
		for j := i; j < k; j *= 2 {
			p *= 0.5
		}
		ans += p / float64(n)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
x_y = [list(map(int, input().split())) for _ in range(n)]
avg = 0
d_sum = 0
for i in range(n-1):
  for l in range(i+1,n):
    d = math.sqrt((x_y[i][0]-x_y[l][0])**2 + (x_y[i][1]-x_y[l][1])**2)
    d_sum += d
k = (math.factorial(n) * (n-1))//combinations_count(n, 2)
avg = d_sum*k/math.factorial(n)
print(avg)

  

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
 
def main():
	N, M, Q = map(int, input().split(" "))
	N_list = [[0 for _ in range(N)] for _ in range(N)]
	
	for _ in range(M):
		l, r = map(int, input().split(" "))
		l -= 1
		r -= 1
		N_list[l][r] += 1
		
	#print(N_list)
	
	for i in range(N):
		for j in range(N):
			if i == 0 and j == 0:
				continue
			if i == 0:
				N_list[i][j] = N_list[i][j] + N_list[i][j-1]
				continue
			if j == 0:
				N_list[i][j] = N_list[i][j] + N_list[i-1][j]
				continue
			N_list[i][j] = N_list[i][j] + N_list[i-1][j] + N_list[i][j-1] - N_list[i-1][j-1]
			
	#print(N_list)
		
	for _ in range(Q):
		p, q = map(int, input().split(" "))
		p -= 1
		q -= 1
		
		a = 0
		b = 0
		c = 0
		if p != 0:
			a = N_list[q][p-1]
			b = N_list[p-1][q]
			c = N_list[p-1][p-1]
		ans = N_list[q][q] - a - b + c
		print(ans)
		
	
if __name__ == "__main__":
	main()

Measured memory_bytes: 61656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            string s = Console.ReadLine();
            string ans = s[0] + (s.Length - 2).ToString() + s[s.Length - 1];
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
s = input()
k = int(input())

if s[0] != "1":
    print(int(s[0]))
else:
    count = 0
    i = 0
    if len(set(s)) == 1:
        print(1)
    else:
        while s[i] == "1":
            count += 1
            i += 1
        if k <= count:
            print(1)
        else:
            print(int(s[i]))

Measured memory_bytes: 3064
#include<stdio.h>

#define MIN(x,y) (((x)>(y))?(y):(x))

int main(void) {
  int H,W,i,j,tmp_H=0,tmp_W=0,c;
  char map[51][51];
  int cicada[51][51];
  scanf("%d%d",&H,&W);
  for(i=0;i<H;i++){
    scanf("%s",map[i]);
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      map[i][j]-='0';
    }
  }
  //cicada[0][0] = 0;
  for(i=0;i<H;i++){
    tmp_H+=map[i][0];
    cicada[i][0]+=tmp_H;
  }
  for(i=0;i<W;i++){
    tmp_W+=map[0][i];
    cicada[0][i]+=tmp_W;
  }
  for(i=1;i<H;i++){
    for(j=1;j<W;j++){
      cicada[i][j]=MIN(cicada[i-1][j],cicada[i][j-1]) + map[i][j];
      //printf("%d\n",cicada[i][j]);
    }
  }
  printf("%d\n",cicada[H-1][W-1]);
  return 0;
}

Measured memory_bytes: 608
/* ex3_2 
　　　　　sachiyan*/

#include <stdio.h>
int main(void){
    int num; //Nを定義
    scanf("%d", &num); //入力値Nの読み取り
    if(num%10 == 3){ //Nを10で割った余りでNの一の位を与える。一の位が３のとき
        printf("bon\n"); //bonを出力
    }
    else if(num%10 == 0 || num%10 == 1 || num%10 == 6 || num%10 == 8){ //一の位が0,1,6,8のとき
        printf("pon\n"); //ponを出力
    }
    else{ //一の位が3,0,1,6,8以外のとき、つまり2,4,5,7,9のとき
        printf("hon\n"); //honを出力
    }
    return 0;
}


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

using namespace std;

int main(){
	int h,w;
	while(cin>>h>>w){
	if (h!=0 || w!=0){
	for (int i=1; i<=w; i++){
		cout<<'#';
	}
	cout<<endl;
	for (int j=2; j<h; j++){
		cout<<'#';
		for (int k=2; k<w; k++){
			cout<<'.';
		}
		cout<<'#';
		cout<<endl;
	}
	for (int i=1; i<=w; i++){
		cout<<'#';
	}
		cout<<endl<<endl;
	}
	else {
		break;
	}
}
}


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

int main() {
    string m[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    for (int i = 0; i < 7; i++) {
        if (m[i] == s) {
            cout << 7 - i << endl;
            return 0;
        }
    }
}

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

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

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

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

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

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

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

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

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

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

int main() {
	int n, k;
	cin >> n >> k;
	long double win_racio = 0.0l;
	REP(i, n) {
		long double racio = 1.0l / n;
		int point = i + 1;
		while(point < k) {
			racio /= 2.0l;
			point *= 2;
		}
		win_racio += racio;
	}
	cout << fixed << setprecision(15) << win_racio << endl;
	return 0;
}


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

int main(){
  int w,h;
  bool jad;
  cin >>h>>w;
  vector<string>a(h);
  for(int i=0;i<h;i++)
    cin >>a.at(i);
  vector<int>dx={0,1,0,-1};
  vector<int>dy={1,0,-1,0};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='#'){
        jad=true;
        int tmp=0;
        for(int k=0;k<4;k++){
          int ni=i+dy.at(k);
          int nj=j+dx.at(k);
        if(ni<0||ni>=h||nj<0||nj>=w)
          continue;
        if(a.at(ni).at(nj)=='.'){
          tmp++;
        }
          if(tmp==4){
            cout <<"No"<<endl;
            return 0;
          }
        }
      }
    }
  }
  if(jad==true)
    cout <<"Yes"<<endl;
  else
    cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a - b << endl;
    }else{
        cout << b - a << endl;
    }
    // a,bが交換しつつ、cだけ増えていく感じか
    // a = b+c;     b = a+c;     a-b=b-a;
    // a = a+c+c;   b = b+c+c;   a-b=a-b;
    // a = b+c+c+c; b = a+c+c+c; a-b=b-a;

}

Measured memory_bytes: 256
def resolve():
    n, l = map(int, input().split())
    alist =[l+i for i in range(n)]
    total = sum(alist)
    minimum = 10000
    j = 0
    for i in range(n):
        diff = abs(alist[i])
        if minimum > diff:
            minimum = diff
            j = i
    print(total-alist[j])
resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5,mod=1e9+7;
map<ll,ll> dp;
ll func(ll n){
    if(dp.count(n))return dp[n];
    ll v1 = func(n/2);
    ll v2 = func( (n-1)/2 );
    ll v3 = func( (n-2)/2 );
    v1 = (v1+v2)%mod + v3;
    return dp[n] = v1%mod;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    dp[0]=1;dp[1]=2;
    ll n;cin>>n;
    cout<<func(n);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((100*a + 10*b + c) % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
				
		}
		
		
		sc.close();
	}
}


Measured memory_bytes: 23252
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	a := readInt()
	b := readInt()
	q := readInt()

	s := make([]int64, a)
	for i := range s {
		s[i] = readInt64()
	}

	t := make([]int64, b)
	for i := range t {
		t[i] = readInt64()
	}

	for i := 0; i < q; i++ {
		x := readInt64()
		println(minInt64(query(x, s, t), query(x, t, s)))
	}
}

func search(x int64, s []int64) int {
	return sort.Search(len(s), func(j int) bool {
		return x <= s[j]
	})
}

func query(x int64, s, t []int64) int64 {
	var res int64 = math.MaxInt64
	a := search(x, s)
	if a == -1 {
		a = len(s) - 1
	}
	for i := -1; i < 2; i++ {
		j := a + i
		if j < 0 || len(s) <= j {
			continue
		}
		b := search(s[j], t)
		if b == -1 {
			b = len(t) - 1
		}
		for k := -1; k < 2; k++ {
			l := b + k
			if l < 0 || len(t) <= l {
				continue
			}
			res = minInt64(res, absInt64(x-s[j])+absInt64(s[j]-t[l]))
		}
	}
	return res
}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 6400
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()

if N[-1] in ["2", "4", "5", "7", "9"]:
	print("hon")
elif N[-1] in ["0", "1", "6", "8"]:
	print("pon")
else:
	print("bon")


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
 
int N,M,orig,dest;
 
vector<int>lis[111111];
 
const int INF=1001001001;
vector<int>dp[111111];
 
vector<tuple<int,int,int>>ev[222222];
vector<int>latte[222222];
signed main(){
    cin>>N>>M>>orig>>dest;
    orig--;dest--;
 
    lis[orig].pb(0);
 
    latte[0].pb(orig);
    rep(i,M){
        int a,b,t,c;
        scanf("%lld%lld%lld%lld",&a,&b,&t,&c);
        a--;b--;
        latte[t].pb(a);
        latte[t+c].pb(b);
 
        lis[a].pb(t);
        lis[b].pb(t+c);
        ev[t].pb(make_tuple(a,b,c));
    }
 
    rep(i,N){
        sort(all(lis[i]));
        lis[i].erase(unique(all(lis[i])),lis[i].end());
    }
 
    rep(i,N){
        dp[i]=vint(lis[i].size(),INF);
    }
    dp[orig][0]=0;
    for(int t=0;t<222222;t++){
        for(auto w:latte[t]){
            int k=lower_bound(all(lis[w]),t)-lis[w].begin();
            if(k+1!=lis[w].size()){
                chmin(dp[w][k+1],dp[w][k]+lis[w][k+1]-lis[w][k]);
            }
        }
 
        for(auto &w:ev[t]){
            int a,b,c;
            tie(a,b,c)=w;
 
            int k=lower_bound(all(lis[a]),t)-lis[a].begin();
            int l=lower_bound(all(lis[b]),t+c)-lis[b].begin();
            chmin(dp[b][l],dp[a][k]);
        }
    }
 
    int ans=INF;
    rep(i,lis[dest].size())chmin(ans,dp[dest][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 41840
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

from scipy.sparse.csgraph import floyd_warshall
D = floyd_warshall(C)

cnt = [0]*10
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            cnt[A[i][j]] += 1

ans = 0
for i in range(10):
    ans += cnt[i]*D[i][1]

print(int(ans))

Measured memory_bytes: 18380
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (long long i = k; i < (long long)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  ll n;
  cin >> n;
  n*=2;
  ll xx=sqrt(n)+1;
  ll fans=4*n;
  rrep(i,1,xx){
    if(n%i!=0) continue;
    ll k=n/i;
    Vl r,m;
    r.PB(0);
    m.PB(k);
    r.PB(-1);
    m.PB(i);
    Pll ans=crt(r,m);
    if(ans.F!=0) chmin(fans,ans.F);
    r[0]--;r[1]++;
    ans=crt(r,m);
    if(ans.F!=0) chmin(fans,ans.F);
  }
  cout << fans << endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
ll m=1000000007;
int main()
{
	fast;
	int n,x,t;cin>>n>>x>>t;
	int tx=x,tt=t;
	while(tx<n)
	{
		if(x<n)
		{
			tx=tx+x;
			tt=tt+t;
		}
	}
	cout<<tt;
}

Measured memory_bytes: 3648
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)

ll a,b;
ll tmp;

ll gcd(ll a,ll b){
	if((0==a)||(0==b)) return 0;
	
	while(a!=b){
		if(a>b) a -= b;
		else b -= a;
	}
	return a;
}

ll lcm(ll a,ll b){
	if((a==0)||(b==0)) return 0;
	
	return ((a/tmp) * b);
}

int main(){
	while(cin>>a>>b){
		tmp = gcd(a,b);
		cout<<tmp<<" "<<lcm(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    int su = 0;
    REP(i,n){
        FOR(j,i+1,n){
            su += A[i] * A[j];
        }
    }
    cout << su << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
       public static void main(String[] args) {
    	  Scanner input=new Scanner( System.in);
    	  
    	  String string=input.next();
    	  int len=string.length();
    	  int ans=0;
    	  for(int i=0;i<=(len+1)/2-1;i++)
    	  {
    		  if(string.charAt(i)=='p')
    		  {
    			  ans--;
    		  }
    	  }
    	  for(int i=(len+1)/2;i<len;i++)
    	  {
    		  if(string.charAt(i)=='g')
    		  {
    			  ans++;
    		  }
    	  }
    	  System.out.println(ans);
          
	}
}


Measured memory_bytes: 25556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int d = 365;
//const int d = 5;
int c[26];
int s[d][26];
int last[26] = {0};
bool llast[d][26] = {false};
vector<int> solution(d,-1);
int myscore = 0;

random_device seed_gen;
mt19937 mt(seed_gen());
uniform_int_distribution<int> con(0,26-1);
uniform_int_distribution<int> day(0,365-1);
uniform_real_distribution<double> pro(0.0,1.0);


int score(vector<int> t){
    vector<int> last(26,0);
    int ans = 0;
    rep(i,d){
        ans += s[i][t[i]];
        last[t[i]] = i+1;
        rep(j,26) ans -= c[j] * (i+1-last[j]);
        //cout << ans << endl;
    }
    return ans;
}

// p day contest changes q
void better(int p,int q,clock_t start,clock_t end){
    //cout << myscore << endl;
    int origin = solution[p];
    int newscore = myscore - s[p][origin] + s[p][q];
    int before_origin = 0,before_q = 0;
    int res = 0;
    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res += (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    llast[p][q] = true;
    llast[p][origin] = false;
    before_origin = 0;
    before_q = 0;

    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res -= (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    //cout << res << endl;

    double t = 1 - ((double)(end - start)/CLOCKS_PER_SEC)/1.87;
    //cout << t << endl;

    newscore += res;
    if(newscore - myscore > 0 || exp((- newscore + myscore)/t) < pro(mt)){
        myscore = newscore;
        solution[p] = q;
    }else{
        llast[p][q] = false;
        llast[p][origin] = true;
    }
}




//day 1-index i_day 's contest is k
int nowscore(int i,int k){
    int res = s[i][k];
    int before = last[k];
    last[k] = i+1;
    rep(j,26) res -= c[j] * (i+1-last[j]);
    last[k] = before;
    return res;
}

int main(){
    clock_t start = clock();

    int tmp;
    cin >> tmp;
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> s[i][j];

    for(int i=0;i<d;i++){
        int id = -1;
        int mx = -INF;
        for(int j=0;j<26;j++){
            int res = nowscore(i,j);
            if(mx < res){
                id = j;
                mx = res;
            }
        }
        solution[i] = id;
        last[id] = i+1; 
        llast[i][id] = true;
        myscore += mx;
    }

    clock_t end = clock();

    while(((double)(end - start)/CLOCKS_PER_SEC) < 1.87){
        better(day(mt),con(mt),start,end);
        end = clock();
    }



    rep(i,d) cout << solution[i]+1 << endl;
    /*
    cout << myscore << endl;
    cout << (score(solution) + 1e6) << endl;
    cout << (myscore + 1e6) << endl;
    */


    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n + 1, 0);
    rep(i, m) {
        int a;
        cin >> a;
        broken[a] = 1;
    }
    const int mod = 1000000007;

    vector<int> dp(n + 2);
    dp[n] = 1;

    for (int i = n - 1; i >= 0; i--) {
        if (broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
    }

    cout << dp[0] << endl;


}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(begin(a),end(a));
    ll now;
    vector<P> ans;
    if(a[0]<=0 && a.back()>=0){
      ll sum=0;
      rep(i,n) sum+=abs(a[i]);
      cout<<sum<<endl;
      priority_queue<ll> pu,mi;
      rep(i,n-1){
        if(a[i]<=0) mi.push(a[i]);
        else pu.push(a[i]);
      }
      while(!pu.empty()){
        ll x=pu.top();
        pu.pop();
        ll y=mi.top();
        mi.pop();
        mi.push(y-x);
        cout<<y<<' '<<x<<endl;
      }
      now=a.back();
      while(!mi.empty()){
        cout<<now<<' '<<mi.top()<<endl;
        now-=mi.top();
        mi.pop();
      }
    }else if(a[0]>0){
      now=a[0];
      rep(i,n-2){
        ans.push_back(P(now,a[i+1]));
        now-=a[i+1];
      }
      ans.push_back(P(a[n-1],now));
      now=a[n-1]-now;
      cout<<now<<endl;
      for(auto itr:ans){
        cout<<itr.first<<' '<<itr.second<<endl;
      }
    }else{
      reverse(begin(a),end(a));
      now=a[0];
      rep(i,n-1){
        ans.push_back(P(now,a[i+1]));
        now-=a[i+1];
      }
      cout<<now<<endl;
      for(auto itr:ans){
        cout<<itr.first<<' '<<itr.second<<endl;
      }
    }
}

Measured memory_bytes: 4208
def solve(a_list):
  alice_sum = 0
  bob_sum = 0
  a_list.sort()
  while True:
    if a_list == []:
      break
    alice_sum += a_list.pop()
    if a_list == []:
      break
    bob_sum += a_list.pop()
  
  return alice_sum - bob_sum

def main():
  N = int(input())
  a_list = list(map(int, input().strip().split()))
  print(solve(a_list))

if __name__ == '__main__':
  main()


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


int a,b,c,d;


int main()
{
    cin>>a>>b>>c>>d;

    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    return 0;

}




Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
 
#define N 1000001
#define M 10001
 
int main(){
    int i,j,tl,pl,flag;
    char t[N],p[M];
 
    scanf("%s",t);
    tl=strlen(t);
     
 
    scanf("%s",p);
    pl=strlen(p);
 
    for(i=0;i<tl;i++){
        /*if(t[i]==p[0]) flag=0;
        for(j=0;j<pl;j++){
            if(t[i+j]!=p[j]) flag=1;
        }*/
        if(strncmp(&t[i],p,pl)==0) printf("%d\n",i);
    }
 
    return 0;
}


Measured memory_bytes: 2784
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
ll find(vector<ll>& grp, int x) {
    if (grp[x] == x)
        return x;
    return grp[x] = find(grp, grp[x]);
}

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<pair<int, int>> edge;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        edge.push_back({a-1, b-1});
    }
    vector<ll> grp(n, 0);
    vector<ll> grp_size(n, 1);
    for(int i = 0; i < n; i++)
        grp[i] = i;
    ll cnt = ll(n)*ll(n-1) / 2;
    vector<ll> ans = {cnt};

    for(int i = m-1; i >= 0; i--) {
        int r1 = find(grp, edge[i].first);
        int r2 = find(grp, edge[i].second);
        if (r1 != r2) {
            ll sz1 = grp_size[r1] * (grp_size[r1]-1) / 2;
            ll sz2 = grp_size[r2] * (grp_size[r2]-1) / 2;
            cnt += sz1 + sz2;
            grp_size[r1] = grp_size[r2] = grp_size[r1]+grp_size[r2];
            cnt -= grp_size[r2] * (grp_size[r2]-1) / 2;
            grp[r1] = grp[r2] = min(grp[r2], grp[r2]);

        }
        ans.push_back(cnt);
    }
    ans.pop_back();
    reverse(ans.begin(), ans.end());
    for(auto val: ans) {
        cout << val << endl;
    }
    return 0;
}




Measured memory_bytes: 7360
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

ll po2(ll s, ll t, ll x) {
	ll tx = t - x;
	ll sx = s - x;
	// cout << sx << " " << tx << endl;
	if ((sx >= 0 && tx >= 0) || (sx <= 0 && tx <= 0)) {
		return max(abs(sx), abs(tx));
	} else {
		if (abs(sx) > abs(tx)) {
			return abs(tx) * 2 + abs(sx);
		} else {
			return abs(sx) * 2 + abs(tx);
		}
	}
}

int main() {
	IOS();
	ll a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(a), t(b);
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}
	// cout << endl;
	for (int i = 0; i < q; i++) {
		ll x, ans;
		cin >> x;
		int a1 = lower_bound(s.begin(), s.end(), x) - s.begin();
		int b1 = lower_bound(t.begin(), t.end(), x) - t.begin();
		// cout << a1 << " " << b1 << endl;
		if (a1 == a) {
			if (b1 == 0)
				ans = po2(s[a - 1], t[0], x);
			else if (b1 == b)
				ans = po2(s[a - 1], t[b - 1], x);
			else {
				ans = min(po2(s[a - 1], t[b1], x), po2(s[a - 1], t[b1 - 1], x));
			}
		} else if (a1 == 0) {
			if (b1 == 0)
				ans = po2(s[0], t[0], x);
			else if (b1 == b)
				ans = po2(s[0], t[b - 1], x);
			else {
				ans = min(po2(s[0], t[b1], x), po2(s[0], t[b1 - 1], x));
			}
		} else {
			if (b1 == 0)
				ans = min(po2(s[a1], t[0], x), po2(s[a1 - 1], t[0], x));
			else if (b1 == b)
				ans = min(po2(s[a1], t[b - 1], x), po2(s[a1 - 1], t[b - 1], x));
			else {
				ans = min(min(po2(s[a1], t[b1], x), po2(s[a1], t[b1 - 1], x)),
						  min(po2(s[a1 - 1], t[b1], x),
							  po2(s[a1 - 1], t[b1 - 1], x)));
			}
		}
		dump(ans);
	}
}

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

ll my_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return my_pow(x * x, n / 2);
    return x * my_pow(x, n - 1);
}

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    ll mod = my_pow(10, 9) + 7;
    ll d[26]{};
    d[s[0] - 'a'] = 1;
    for (int i = 1; i < N - 1; i++) {
        d[s[i] - 'a'] += d[t[i] - 'a'];
        d[s[i] - 'a'] %= mod;
    }
    cout << d[t[N - 1] - 'a'] << "\n";
    return 0;
}


Measured memory_bytes: 3332