akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(int, input().split())

def gen_pattern(curr, result):
    if len(curr) == W - 1:
        result.append(curr)
        return
    if len(curr) == 0:
        gen_pattern([0], result)
        gen_pattern([1], result)
    else:
        gen_pattern(curr + [0], result)
        if curr[-1] == 0:
            gen_pattern(curr + [1], result)
bridge = []
gen_pattern([], bridge)

MOD = 1000000007

di = []
for y in range(H + 1):
    ret = []
    for x in range(W):
        ret.append(0)
    di.append(ret)
di[0][0] = 1

for y in range(1, H + 1):
    for x in range(W):
        left = 0
        center = 0
        right = 0
        if W == 1:
            center = 1
        else:
            for b in bridge:
                if x == 0:
                    if b[x] == 0:
                        center += 1
                    if b[x] > 0:
                        right += 1
                elif x == W - 1:
                    if b[x - 1] > 0:
                        left += 1
                    if b[x - 1] == 0:
                        center += 1
                else:
                    if b[x - 1] > 0:
                        left += 1
                    if b[x - 1] == 0 and b[x] == 0:
                        center += 1
                    if b[x] > 0:
                        right += 1
        t = (di[y - 1][x] * center) % MOD
        if x > 0:
            t += (di[y - 1][x - 1] * left) % MOD
        if x < W - 1:
            t += (di[y - 1][x + 1] * right) % MOD
        di[y][x] = t % MOD

print(di[H][K - 1])

Measured memory_bytes: 3188
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long sum = 0;
        HashMap<Long, Long> mp = new HashMap<>();
        for(int i=0; i<n; i++) {
            long x = fs.nextLong();
            sum += x;
            if(mp.containsKey(x))
                mp.put(x, mp.get(x)+1);
            else
                mp.put(x, 1L);
        }

        int q = fs.nextInt();
        while(q-- > 0) {
            long b = fs.nextLong();
            long c = fs.nextLong();
            sum -= b * mp.getOrDefault(b, 0L);
            sum += c * mp.getOrDefault(b, 0L);
            mp.put(c, mp.getOrDefault(c, 0L) + mp.getOrDefault(b, 0L));
            mp.replace(b, 0L);
            System.out.println(sum);
        }
    }

    static class FastScanner {
        BufferedReader br = null;
        StringTokenizer st;
    
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 63980
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=LIST()
    a.sort()
    print(a[0]*a[1]//2)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long lld;
typedef long double Lf;
#define Ma(x,y)((x)>(y)?(x):(y))
#define mi(x,y)((x)<(y)?(x):(y))

int main() {
	int n, k, t, all[6] = { 0 }, d[10] = { 0 };
	scanf("%d%d", &n, &k);
	rep(i, k) { scanf("%d", &t); d[t]++; }
	if (n == 1 && d[1] != 1) { printf("1"); return 0; }
	t++;
	Rep(i, 2 < n ? n : 2, 1e5) {
		rep(j, log10(i) + 1) {
			all[j] = (i % (int)pow(10, j + 1)) / (int)pow(10, j);
			rep(x, 10)if (d[all[j]])t = 0;
		}
		if (t) { printf("%d", i); return 0; }
		t++;
	}
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
import Data.Array.Unboxed
import Data.Ix (range)
import Data.Int (Int64)
import Data.List (foldl')

modulo = 1000000007 :: Int64
addMod x y = (x + y) `rem` modulo
mulMod x y = (x * y) `rem` modulo
sumMod = foldl' addMod 0
fromIntegerMod :: Integer -> Int64
fromIntegerMod x = fromInteger (x `mod` fromIntegral modulo)

---

matMul :: UArray (Int,Int) Int64 -> UArray (Int,Int) Int64 -> UArray (Int,Int) Int64
matMul a b = let ((i0,j0),(ix,jx)) = bounds a
                 ((j'0,k0),(j'x,kx)) = bounds b
             in if jx - j0 == j'x - j'0
                   then array ((i0,k0),(ix,kx))
                        [ ((i,k), sumMod [(a!(i,j)) `mulMod` (b!(j',k)) | (j,j') <- zip (range (j0,jx)) (range (j'0,j'x))])
                        | i <- range (i0,ix)
                        , k <- range (k0,kx)
                        ]
                else error "Matrix size mismatch"

matPow :: Int -> UArray (Int,Int) Int64 -> Int -> UArray (Int,Int) Int64
matPow k m 0 = array ((1,1),(k,k)) $
               [((i,j), if i == j then 1 else 0) | i <- [1..k], j <- [1..k]]
matPow _ m i = loop (i-1) m m
  where
    loop 0 !_ acc = acc
    loop 1 m acc = m `matMul` acc
    loop i m acc = case i `quotRem` 2 of
                     (j,0) -> loop j (m `matMul` m) acc
                     (j,_) -> loop j (m `matMul` m) (acc `matMul` m)

mat :: UArray (Int,Int) Int64
mat = array ((1,1),(7,7))
      [ ((i,j),aij)
      | (i,ai) <- zip [1..] values
      , (j,aij) <- zip [1..] ai
      ]
  where values = fmap (fmap fromIntegerMod)
          [[4, 0,-2,-3,-1, 0, 1]
          ,[1, 0, 0, 0, 0, 0, 0]
          ,[0, 1, 0, 0, 0, 0, 0]
          ,[0, 0, 1, 0, 0, 0, 0]
          ,[0, 1,-1, 0, 0, 0, 1]
          ,[0, 0, 0, 0, 1, 0, 0]
          ,[0, 0, 0, 0, 0, 1, 0]
          ]

main :: IO ()
main = do
  n <- readLn
  let m = matPow 7 mat n
  print $ m ! (1,1)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_V 100

int dist[MAX_V][MAX_V];//辺が存在しない場合はINF、ただしdist[i][i] = 0とする
int V;

void warshall_floyd(){
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            if(dist[i][k] == INF) continue;
            for(int j = 0; j < V; j++){
                if(dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}
//負の閉路があるかないかは、dist[i][i]が負になる頂点iがあるかどうかで判別できる

signed main(){
    int m;
    cin >> V >> m;
    REP(i,V){
        REP(j,V){
            if(i == j){
                dist[i][j] = 0;
            }else{
                dist[i][j] = INF;
            }
        }
    }
    int a[m],b[m],c[m];
    REP(i,m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }
    warshall_floyd();
    int ans = 0;
    REP(i,m){
        bool use = false;
        REP(j,V){
            REP(k,V){
                if(dist[j][k] == dist[j][a[i]] + c[i] + dist[b[i]][k]){
                    use = true;
                }
            }
        }
        if(!use){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input().split()
arare = ["P", "W", "G", "Y"]


def hina(S):
    if S in arare:
        arare.remove(S)
    return len(arare)


for i in range(n):
    hina(s[i])
print("Four") if (4 - len(arare) == 4) else print("Three")


Measured memory_bytes: 2940
k, n = map(int, input().split())
a = [int(i) for i in input().split()]
a += [a[0] + k]
sum = 0
max = 0

# 最も長い辺を求める
for i in range(n):
    d = abs(a[i] - a[i + 1])
    sum += d
    if max < d:
        max = d
# 最も長い辺を通らずに1周回るのが最小
print(sum - max)

Measured memory_bytes: 31660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    vector<string> p(3);
    rep(i,3) cin>>p[i];
    rep(i,3) cout<<p[i][i];
}

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

int main(void){
    int A,B,C,K;
    cin >> A >> B >> C >> K;

    bool flag = false;

    rep2(i,K){
        rep2(j,K){
            rep2(k,K){
                int AA = A * (1 << i); //あか
                int BB = B * (1 << j); //みどり
                int CC = C * (1 << k); //あお
                if(( BB > AA )&&( CC > BB )&&(i+j+k <= K)){
                    flag = true;
                   //break;
                } 
            }
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int num = N;

        int e;
        int sn = 0;
        int count;

        //桁数の算出
        e  = (int)Math.log10(N) + 1;
        
        //S(N)の算出
        for(int i = 0; i < e; i++){
            count = num % 10;
            sn += count;
            num = (num - count)/10;
        }

        //評価
        if(N % sn == 0 ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

int main(){
	lint a,b,c;cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		long ans = modpow(10, n, 1000000007) - modpow(9, n, 1000000007) - modpow(9, n, 1000000007)
				+ modpow(8, n, 1000000007);
		ans %= 1000000007;
		if (ans < 0)
			ans = (ans + 1000000007) % 1000000007;
		System.out.println(ans);
	}

	static long modpow(long a, long n, long mod) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1)
				res = res * a % mod;
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
}

Measured memory_bytes: 32556
#include <stdio.h>
#define N_MAX 15

int main(int argc, char *argv[]){
     int sq[N_MAX][N_MAX], n, x, y, i, f;
     
     while(scanf("%d",&n), n!=0){
	  for(y=0; y<n; y++)
	       for(x=0; x<n; x++)
		    sq[x][y]=0;

	  x=n/2, y=n/2+1;
	  for(i=1; i<=n*n; i++){
	       while(1){
		    f=0;
		    
		    if(x>=n) x=0, f=1;
		    if(x<0) x=n-1, f=1;
		    if(y>=n) y=0, f=1;
		    if(sq[x][y]) x--, y++, f=1;

		    if(!f) break;
	       }

	       sq[x][y] = i;
	       x++, y++;
	  }

	  for(y=0; y<n; y++){
	       for(x=0; x<n; x++)
		    printf("%4d",sq[x][y]);
	       puts("");
	  }
     }

     return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include "atcoder/all"

using namespace std;
using namespace atcoder;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }

    auto groups = d.groups();

    cout << (int)groups.size() - 1 << endl;
}

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair

using namespace std;

typedef long long ll;

const int nax=2e5+5;
int xx[nax];
int yy[nax];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    xx[i]=a+b;
    yy[i]=b-a;
  }
  sort(xx,xx+n);
  sort(yy,yy+n);
  cout<<max(abs(xx[0]-xx[n-1]),abs(yy[0]-yy[n-1]));

}


Measured memory_bytes: 5220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// ABC 148
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		scan.close();
		for(int i=0;i<3;i++) {
			if(a!=i+1&&b!=i+1) {
				System.out.println(i+1);
				break;
			}
		}
	}

}

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a > b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  } else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  }
  cout << endl;

  return 0;
}

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

int main(){
  int n, k; cin >> n >> k;
  int idx;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    if(a == 1) idx = i;
  }
  cout << (n-2)/(k-1) + 1 << endl;
}



Measured memory_bytes: 256
H, W = list(map(int, input().split()))
s = []

def search_around(i, j):
    ret = False
    if 0 <= i+1 < H and 0 <= j < W:
        if s[i+1][j] == '#':
            ret = True
    if 0 <= i < H and 0 <= j+1 < W:
        if s[i][j+1] == '#':
            ret = True
    if 0 <= i-1 < H and 0 <= j < W:
        if s[i-1][j] == '#':
            ret = True
    if 0 <= i < H and 0 <= j-1 < W:
        if s[i][j-1] == '#':
            ret = True
    return ret
    
ans = True
for i in range(H):
    s.append(input())
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if not search_around(i, j):
                ans = False
                break
if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import sys

n = int(input())
blocks = []
for line in sys.stdin.readlines():
    w, s, v = map(int, line.split())
    blocks.append((w + s, w, s, v))
blocks.sort()

dp = [-1] * 20001
dp[0] = 0
for _, w, s, v in blocks:
    for i in range(s, -1, -1):
        if dp[i] == -1:
            continue
        dp[i + w] = max(dp[i + w], dp[i] + v)
print(max(dp))


Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}


ll f[5000001];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
 ll n;
 ll ans=0;
 cin>>n;
 for(int i=1;i<=n;i+=2)
 {
     vector<int>d;
     for(int j=1;j*j<=i;j++)
     {

         if(i%j==0)
         {

             d.pb(j);
             if(j*j!=i) d.pb(n/j);
         }

     }
     if(d.size()==8) ans++;

 }
 cout<<ans;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
s = [input() for _ in range(n)]

dic = {}
for i in range(n):
    tmp = sorted(list(s[i]))
    tmp2 = "".join(tmp)
    if dic.get(tmp2) == None:
        dic[tmp2] = 1
    else:
        dic[tmp2] += 1

#print(dic)
ans = 0
for k, v in dic.items():
    #print(k, v)
    if v >= 2:
        num = (v-1)
        #print("num: ", num)
        #print("num//2*(num+1): ", num//2*(num+1))
        ans += num*(num+1)//2
        #print(ans)

print(ans)


Measured memory_bytes: 24980
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    vvl s(M);
    REP(i, M){
        ll k; cin >> k;
        REP(j, k){
            ll tmp; cin >> tmp; tmp--; s[i].pb(tmp);
        }
    }
    vl p(M); REP(i, M) cin >> p[i];
    
    ll ans = 0;
    REP(k, 1ll << N){
        vb on(N, false);
        REP(i, N){
            if(k >> i & 1) on[i] = true;
        }
        bool ok = true;
        REP(i, M){
            ll oncnt = 0;
            REP(j, s[i].size()){
                if(on[s[i][j]]) oncnt++;
            }
            if(oncnt%2 != p[i]){
                ok = false; break;
            }
        }
        if(ok){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll x,y;
    cin>>x>>y;
    ll now=x,cnt=1;
    while(now*2<=y){
        now*=2;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n)
    {
        mp[a[i]]++;
    }
    int ans = 0;
    int two = 0, one = 0;
    for (auto x : mp)
    {
        cerr << x.first << " " << x.second << endl;
        ans += (x.second - 1) / 2;
        if (2 - (x.second % 2) == 2)
        {
            two++;
        }
        else
        {
            one++;
        }
    }
    ans += two / 2;
    if (two % 2 == 1)
        ans++;
    cout << n - 2 * ans << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#define SENTINEL 2000000000

static unsigned long merge(int *a, int left, int mid, int right) {
  int n1, n2, i, j, k;
  int *l;
  int *r;
  unsigned long cnt;

  n1 = mid - left;
  l = (int *) malloc(sizeof(int) * (n1 + 1));
  if (l == NULL) return 0;
  for (i = 0; i < n1; ++i) l[i] = a[left + i];
  l[i] = SENTINEL;

  n2 = right - mid;
  r = (int *) malloc(sizeof(int) * (n2 + 1));
  if (r == NULL) return 0;
  for (i = 0; i < n2; ++i) r[i] = a[mid + i];
  r[i] = SENTINEL;

  for (i = j = 0, cnt = 0L, k = left; k < right; ++k) {
    if (l[i] <= r[j]) {
      a[k] = l[i++];
    } else {
      a[k] = r[j++]; cnt += n1 - i;
    }
  }

  free(l); free(r); return cnt;
}

static unsigned long merge_sort(int *a, int left, int right) {
  int mid;
  unsigned long cnt;

  cnt = 0L;
  if (left >= right - 1) return cnt;
  mid = (left + right) / 2;
  cnt += merge_sort(a, left, mid);
  cnt += merge_sort(a, mid, right);
  cnt += merge(a, left, mid, right);
  return cnt;
}

int main(int argc, char **argv) {
  int ret, n, i;
  int *a;

  ret = scanf("%d", &n);
  if (errno != 0) perror("scanf: n");
  if (ret < 1) exit(1);

  a = (int *) malloc(sizeof(int) * n);
  if (a == NULL) exit(0);

  for (i = 0; i < n; ++i) {
    ret = scanf("%d", &a[i]);
    if (errno != 0) perror("scanf: a[i]");
    if (ret < 1) break;
  }

  printf("%ld\n", merge_sort(a, 0, n));
  free(a); exit(0);
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  vl a(m),b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
  }
  vl memo(2*m,INF);
  ll j=0;
  rep(i,m){
    if(min(a[i],b[i])==1){
      memo[j]=max(a[i],b[i]);
      j++;
    }
  }
  rep(i,m){
    if(max(a[i],b[i])==n){
      memo[j]=min(a[i],b[i]);
      j++;
    }
  }
  sort(memo.begin(),memo.end());
  bool k=false;
  rep(i,2*m){
    if(memo[i]==memo[i+1]&&memo[i]!=INF){
      k=true;
      break;
    }
  }
  if(k){
    cout << "POSSIBLE" << endl;
  }
  else
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 6528
using System;

public class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] num = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int ans = 0;
        bool flag = true;
        while (flag)
        {
            for (int i = 0; i < num.Length; i++)
            {
                if (num[i] % 2 != 0)
                {
                    flag = false;
                    break;
                }
                else
                {
                    num[i] /= 2;
                }
                
            }
            if(flag)
                    ans++;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d, e, f, g, h, n, k, m;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  e = 0;
  f = 0;
  g = 0;
  h = 0;
  k = 0;
  in(n);
  rep(i, n){
    in(m);
    if(m < 400)
      a = 1;
    else if(m < 800)
      b = 1;
    else if(m < 1200)
      c = 1;
    else if(m < 1600)
      d = 1;
    else if(m < 2000)
      e = 1;
    else if(m < 2400)
      f = 1;
    else if(m < 2800)
      g = 1;
    else if(m < 3200)
      h = 1;
    else
      k++;
  }
  if(k >= 1){
    out(max(a + b + c + d + e + f + g + h, 1ll));
    hina;
    out(min(99999998ll, a + b + c + d + e + f + g + h + k));
    memi;
  }
  else{
    rep(i, 2){
    out(a + b + c + d + e + f + g + h);
    hina;
    }
    memi;
  }
}


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

const int MOD = 1e9+7;

int main()
{
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> dp(h, vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i == 0 && j == 0) {
                dp[i][j] = 1;
                continue;
            }
            if(a[i][j] == '.') {
                if(i > 0) {
                    dp[i][j] += dp[i-1][j];
                    if(dp[i][j] > MOD) {
                        dp[i][j] -= MOD;
                    }
                }
                if(j > 0) {
                    dp[i][j] += dp[i][j-1];
                    if(dp[i][j] > MOD) {
                        dp[i][j] -= MOD;
                    }
                }
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] c = S.toCharArray();
		if (c[0] != 'A') {
			System.out.println("WA");
			return;
		}
		int count = 0;
		int index = 0;
		for (int i = 2; i < c.length - 1; i++) {
			if (c[i] == 'C') {
				count++;
				index = i;
			}
		}
		if (count != 1) {
			System.out.println("WA");
			return;
		}

		for (int i = 0; i < c.length; i++) {
			if (i == 0 || i == index) {
				continue;
			}
			if (c[i] >= 'A' && c[i] <= 'Z') {
				System.out.println("WA");
				return;
			}
		}
		System.out.println("AC");
		sc.close();
	}
}

Measured memory_bytes: 23636
// https://atcoder.jp/contests/abc100/tasks/abc100_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, sum = 0;
    vector<int> v;
    cin >> n;
    v.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> v[i];
        // 2で割れる回数の合計を計算する
        int div = 1;
        while (v[i] % (1 << div) == 0) {
            div++;
        }
        sum += (div - 1);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int r, D, x;

	cin >> r >> D >> x;
	rep(i, 10) {
		x = r * x - D;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
ll longinf=1ll<<60;
 
 
double n,m,d;
 
int main(){
    cin>>n>>m>>d;
    double x;
  double y,z;
  if(d==0){y=0;z=n;}
  else if(n-2*d>0){y=n-2*d;z=2*d;}
  else {y=0;z=n;}
    x=(2*y+z)*(m-1)/(n*n);
    cout<<shosu<<x<<endl;
 
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
d = 0
for i in range(k):
  d += li_s[i]
  ans.append(d)
for j in range(k, n):
  d += li_s[j]
  d -= li_s[j-k]
  ans.append(d)
print(max(ans))


Measured memory_bytes: 85768
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	static class Node {
		Node prev;
		int value;
		public Node(int value, Node prev) {
			this.value = value;
			this.prev = prev;
		}
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		// System.out.println("start");

		int[] dp = new int[T];
		Node[] prev = new Node[T];
		for (int j = 0; j < N; j++) {
			final int a = A[j];
			final int b = B[j];
			for (int k = T - 1; k >= a; k--) {
				int add = dp[k-a] + b;
				if (dp[k] < add) {
					dp[k] = add;
					prev[k] = new Node(j, prev[k-a]);
				}
			}
		}
		// System.out.println("finish");
		// printArray(dp);
		HashSet<Integer> set = new HashSet<>();
		Node curr = prev[T-1];
		while (curr != null) {
			set.add(curr.value);
			curr = curr.prev;
		}
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (set.contains(i)) continue;
			max = Math.max(max, B[i]);
		}
		// System.out.println(dp[T-1] + ", " + max);
		int ans = dp[T-1] + max;
		System.out.println(ans);
	}
}


Measured memory_bytes: 182752
s=input()
n = len(s)
s = s[0:n-1]
if(len(s)%2==1):s=s[0:len(s)-1]
tmp = len(s)//2
while(1):
    f=True
    for i in range(tmp):
        if s[i]==s[tmp+(i)]:
            continue
        else:
            s = s[0:len(s)-2]
            f=False
            tmp-=1
            break
    if f:break

print(tmp*2)


Measured memory_bytes: 3064
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

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

    if(s=="Sunny") cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else cout<<"Sunny";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int dist(int x1, int y1, int x2, int y2)
{
    return abs(x2 - x1) + abs(y2 - y1);
}

int main()
{
    int N;
    cin >> N;
    int t[N + 1];
    int x[N + 1];
    int y[N + 1];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i < N+1; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < N; i++)
    {
        int T = t[i + 1] - t[i];
        int D = dist(x[i], y[i], x[i + 1], y[i + 1]);
        if (T < D)
        {
            cout << "No" << endl;
            return 0;
        }
        else if ((T - D) % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
use std::io::BufRead;
use std::process::exit;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_b();
}

fn solve_b() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let a = input!(r, isize);
    let b = input!(r, isize);
    let c = input!(r, isize);
    let d = input!(r, isize);
    let e = input!(r, isize);
    let k = input!(r, isize);
    let points: Vec<isize> = vec![a, b, c, d, e];
    for p in &points {
        for q in &points {
            if (p - q).abs() > k {
                println!(":(");
                exit(0);
            }
        }
    }
    println!("Yay!");
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl


int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint ans = 0;
	for (lint i = 1; i < N; i++) {
		if (A[i - 1] > A[i]) {
			ans += (A[i - 1] - A[i]);
			A[i] = A[i - 1];
		}
	}
	cout << ans << endl;
}

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

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

	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans*2 < ans+k) {
			ans *= 2;
		} else {
			ans += k;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a = input()
ar = [0 for i in range(len(a)+1)]
for i in range(len(a)):
    if a[i] == '<':
        ar[i+1] = max(ar[i] + 1,ar[i+1])
for i in range(len(a)-1,-1,-1):
    if a[i] == '>':
        ar[i] = max(ar[i+1] + 1,ar[i])
print(sum(ar))

Measured memory_bytes: 29924
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)
#define PI 3.14159265358979323846

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}


int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double ar = 0, br = 0;
    ar = 30.0 * h + 30.0 * (m / 60.0);
    br = 6.0 * m;

    double angle = 0;
    if (ar >= br) {
        angle = ar - br;
    } else {
        angle = br - ar;
    }
    if (angle >= 180) {
        angle = 360 - angle;
    }

    double ans = 0, temp = 0;
    angle = angle * PI / 180.0;
    temp = (a * a) + (b * b) - (2 * a * b * cos(angle));
    ans = sqrt(temp);

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 4164
a,b,c = map(int, input().split())
k = int(input())
ans = [[a,b,c]]
ans2 = []
for i in range(k):
  b = []
  for j in range(len(ans)):
    a = ans[j]
    a1,b1,c1 = a[0]*2,a[1]*2,a[2]*2
    b.append([a1,a[1],a[2]])
    b.append([a[0],b1,a[2]])
    b.append([a[0],a[1],c1])
  ans = b
t = 0
for i in ans:
  if i[0] < i[1] < i[2]:
    t = 1
    break
if t == 1:
  print("Yes")
else:
  print("No")

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

int main(){
  string s,p;
  char tmp;
  int p_len;
  cin >> s >> p;
  s += s;
  int loc = s.find(p);
  if(loc != string::npos){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll gcd(ll p, ll q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(){
    ll a, b, g;
    cin >> a >> b;
    g = gcd(a,b);
    auto ls = prime_factor(g);

    cout << ll(ls.size())+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX_N 100010
const ll R = 1e9 + 7;
 
int n, m;
ll dp[MAX_N] = {};

int main() {
    cin >> n >> m;
    int a[m + 1];
    for (int i = 0; i < m; i++) cin >> a[i];
    
    int j = 0;
    for (int i = 1; i <= n; i++) {
        if (i <= 2) dp[i] += dp[i - 1] + 1;
        if (i == a[j]) { 
            dp[i] = 0; 
            if (j < m) j++;
            continue;
        }
        else 
            if (i > 2) dp[i] = (dp[i - 1] + dp[i - 2]) % R;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1100, OO = 1e9 + 7, T = 410, M = 998244353, P = 6151, SQ = 450;
typedef pair <int, int> pii;
char c[N][N];
int dp[N][N];

int32_t main() {
	use_fast;	
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> c[i][j];
	for(int i = n; i >= 1; i--) {
		for(int j = m; j >= 1; j--) {
			if(i == n && j == m) {
				if(c[i][j] == '.')		
					dp[i][j] = 0;
				else
					dp[i][j] = 1;
				continue;
			}
			else if(i == n) {
				if(c[i][j] == '.')
					dp[i][j] = dp[i][j + 1];
				else {
					if(c[i][j + 1] == '.')
						dp[i][j] = 1 + dp[i][j + 1];
					else
						dp[i][j] = dp[i][j + 1];
				}
			}
			else if(j == m) {
				if(c[i][j] == '.')
					dp[i][j] = dp[i + 1][j];
				else {
					if(c[i + 1][j] == '.')
						dp[i][j] = 1 + dp[i + 1][j];
					else
						dp[i][j] = dp[i + 1][j];
				}				
			}
			else {
				if(c[i][j] == '.')	
					dp[i][j] = min(dp[i + 1][j], dp[i][j + 1]);
				else {
					if(c[i + 1][j] == '.')
						dp[i][j] = dp[i + 1][j] + 1;
					else	
						dp[i][j] = dp[i + 1][j];
					if(c[i][j + 1] == '.')
						dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1);
					else	
						dp[i][j] = min(dp[i][j], dp[i][j + 1]);
				}
			}
		}
	}
	cout << dp[1][1] << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  set<ll> se;
  rep(i,n)se.insert(a[i]);
    if(se.size()!=n){
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
return 0;}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	string s;
	cin >> s;
	int paper = 0, rock = 0, score = 0;
	for(char c : s) {
		if(paper + 1 <= rock) {
			paper++;
			score += c == 'g';
		} else {
			rock++;
			score -= c == 'p';
		}
	}
	cout << score << endl;
	return 0;
}

Measured memory_bytes: 512
using System.Linq;
using System;

public class Hello
{
    public const long INF = 99999999999;
    public static void Main()
    {
        var ret = new long[4];
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = long.Parse(line[0]);
        var y = long.Parse(line[1]);
        ret[0] = getAns(x, y);
        ret[1] = getAns(x, -y) + 1;
        ret[2] = getAns(-x, y) + 1;
        ret[3] = getAns(-x, -y) + 2;
        Console.WriteLine(ret.Min());
    }
    public static long getAns(long a, long b)
    {
        return a <= b ? b - a : INF;
    }
}


Measured memory_bytes: 13268
n = gets.to_i
a = gets.split.map(&:to_i)

ans = 1
for i in 0...n
    ans = 0 if a[i] == 0
end

for i in 0...n
    ans *= a[i]
    if ans > 10**18
        ans = -1
        break
    end
end

puts ans

Measured memory_bytes: 21492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
          string[] Input = Console.ReadLine().Split(' ');
          int A = int.Parse(Input[0]);
          int B = int.Parse(Input[1]);
          int C = int.Parse(Input[2]);
          int D = int.Parse(Input[3]);
          do
          {
            C -= B;
            if(C <= 0)
            {
              Console.WriteLine("Yes");
            }
            if(C > 0)
            {
            A -= D;
            if(A <= 0)
            {
              Console.WriteLine("No");
            }
            }
          }while(A > 0 && C > 0);
        }
    }

Measured memory_bytes: 17896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int X;
    cin>>X;
    if(X>=30){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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


int main() {
	set<string>st;
	string s;
	int n;
	bool first = 1;
	cin >> n;
	char c;
	char u;
	while(n--){
		cin >> s;
		if(first){
			first = 0;
			st.insert(s);
			c = s[(int)s.size()-1];
		} else {
			if(c != s[0] || st.count(s)){
				puts("No");
				return 0;
			}
			c = s[(int)s.size()-1];
			st.insert(s);
		}
	}
	puts("Yes");
	return 0;
}

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

using namespace std;

const int MAXN = 2e5 + 10;

int a[MAXN];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);// don't forget &
    for (int i = 1; i <= m; i++) {
        scanf("%d", &a[i]);// don't forget &
    }
    a[m + 1] = n + a[1];
    int ans = n;
    for (int i = 1; i <= m; i++) {
        ans = min(ans, n - (a[i + 1] - a[i]));
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 896