akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
using namespace std;

char a[55][55];
char b[55][55];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    char c;
    scanf("%c",&c);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            scanf("%c",&a[i][j]);
        }
        scanf("%c",&c);
    }
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=m;j++)
        {
            scanf("%c",&b[i][j]);
        }
        scanf("%c",&c);
    }
    for(int x=1;x<=n-m+1;x++)
    {
        for(int y=1;y<=n-m+1;y++)
        {
            bool ok=true;
            for(int i=1;i<=m;i++)
            {
                for(int j=1;j<=m;j++)
                {
                    if(b[i][j]!=a[x+i-1][y+j-1])
                    {
                        ok=false;
                    }
                }
            }
            if(ok)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();

        if (a >= 1000) {
            System.out.println("ABD");
        } else {
            System.out.println("ABC");

        }
    }
}


Measured memory_bytes: 22356
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
template<class T>bool CHMAX(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)

int main() {
	int n;
	int d[100000];
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &d[i]);
	}
	std::sort(d, d + n);
	int ans = d[n / 2] - d[n / 2 - 1];
	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include<iostream>
    #include<map>
    #include<deque>
    #include<algorithm>
    #include<string>
    using namespace std;
    #define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
    #define Rep(i,n) REP(i,0,n)
    #define rep(i,n) REP(i,1,n+1)
    typedef long long ll;
     
    int N,K,X,Y;
    int main(){
        cin>>N>>K>>X>>Y;
        ll ans=0;
        if(N>K){
            ans=K*X+(N-K)*Y;
        }
        else ans=N*X;
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/
int ok(string s) {
  int k = 1, l = 0, r = (int) s.size() - 1;
  while (l < r) {
    if (s[l] != s[r]) return 0;
    ++l, --r;
  }
  return 1;
}
int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  string s; cin >> s;
  int n = SZ(s);
  cout << ((ok(s) && ok(s.substr(0, (n - 1) / 2)) && ok(s.substr(n / 2 + 1, n / 2))) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    int D;
    cin >> D;
    vector<int> c(26), cc(26);
    rep(i, 26) {
        cin >> c[i];
        cc[i] = c[i];
    }
    vector<vector<int>> s(D);
    rep(i, D) {
        s[i].resize(26);
        rep(j, 26) cin >> s[i][j];
    }

    vector<int> lst(26);

    // vector<bool> held(26);

    rep(d, D) {
        // if (d % 26 == 0) {
        //     rep(i, 26) held[i] = false;
        // }
        int x = -1;
        int best = -1000000;
        rep(i, 26) {
            // if (held[i]) continue;
            int tmp = s[d][i] + cc[i];
            if (best < tmp) {
                x = i;
                best = tmp;
            }
        }
        // held[x] = true;
        cout << (x+1) << endl;

        int v = s[d][x];
        lst[x] = d+1;
        rep(i, 26) {
            v -= ((d+1)-lst[i]) * c[i];
            cc[i] = ((d+1)-lst[i]) * c[i];
        }
        // cerr << "d = " << d << ", v = " << v << endl;    
    }

    return 0;
}




Measured memory_bytes: 3604
n, k = map(int, input().split())
A = []
ans = [0 for i in range(n)]
an = 0
for i in range(k):
    d = int(input())
    AA = list(map(int, input().split()))
    A[len(A):len(A)] = AA
for num in A:
    ans[num-1] += 1
for n in ans:
  if n == 0:
    an += 1
print(an)

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

int main(){
  int n;
  cin >>n;
  int odd = (n+1)/2;
  int even = n-odd;
  cout << odd*even << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
def bfs(sy,sx):
    dis=[[0]*W for i in range(H)]
    q=deque()
    q.append([sy,sx])
    while(len(q)!=0):
        y=q[0][0]
        x=q[0][1]
        q.popleft()
        for dy,dx in ([0, 1], [1, 0], [0, -1], [-1, 0]):
            ny=y+dy
            nx=x+dx
            if ny<0 or ny>=H or nx<0 or nx>=W:
                continue
            if field[ny][nx]=="#":
                continue
            if dis[ny][nx]!=0:
                continue
            dis[ny][nx]=dis[y][x]+1
            q.append([ny,nx])
    if dis[H-1][W-1]==0:
        print(-1)
        exit()
    return dis[H-1][W-1]


H,W=map(int,input().split())
field=[input() for i in  range(H)]
O=0
for i in range(H):
    O+=field[i].count(".")
ans=O-1-bfs(0,0)
print(ans)

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    
    int a,b;
    cin >>a>>b;

    int h = (b-a)*(b-a+1)/2;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << h - b << endl;

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


Measured memory_bytes: 256
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
p = inl()
p.sort()
print(sum(p[:k]))


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

#define rep(i, n) for(long long i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll n, m;
    ll ans = 0, num = 0;
    cin >> n >> m;
    vector<pair<ll, ll>> a(n);
    rep(i, n){
        cin >> a[i].first >> a[i].second;
    }
    sort(ALL(a));
    rep(i, n){
        if(num + a[i].second >= m){
            ans += (m - num) * a[i].first;
            break;
        }
        ans += a[i].first * a[i].second;
        num += a[i].second;
    }
    print(ans);
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000001
#define AMAX 10000

int partition(short*,int,int);

int main(){

  unsigned short *A;

  int i,n;
  int x,p,q,r;

  scanf("%d",&n);

  p=0;
  r=n-1;

  A=malloc(sizeof(short)*n+1);

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


  q=partition(A,p,r);



  for(i=0;i<q;i++){
    printf("%d",A[i]);
    if(i!=n) printf(" ");
  }
  printf("[%d] ",A[q]);

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


  return 0;
  
}


int partition(short* A,int p,int r){
    int i,j,x,mv;
  i=p-1;
  x=A[r];

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
 
      mv=A[i];
      A[i]=A[j];
      A[j]=mv;
    }

  }

  mv=A[i+1];
  A[i+1]=A[r];
  A[r]=mv;

  return i+1;
}

Measured memory_bytes: 800
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String S = sc.next();
			int length = S.length();
			int K = sc.nextInt();
			if (length == 1) {
				System.out.print(K / 2);
				return;
			}
			char head = S.charAt(0);
			boolean[] bls = new boolean[length];
			char tail = S.charAt(length - 1);
			long firstCount = 0;
			char last = S.charAt(0);
			for (int i = 1; i < length; i++) {
				if (S.charAt(i) == last && bls[i - 1] == false) {
					bls[i] = true;
					firstCount++;
				}
				last = S.charAt(i);
			}
			if (K == 1) {
				System.out.println(firstCount);
				return;
			}
			long count = 0;
			boolean[] bls2 = new boolean[length];
			if (head == tail && bls[length - 1] == false) {
				bls2[0] = true;
				count++;
			}
			last = S.charAt(0);
			for (int i = 1; i < length; i++) {
				if (S.charAt(i) == last && bls2[i - 1] == false) {
					bls2[i] = true;
					count++;
				}
				last = S.charAt(i);
			}
			if (K == 2) {
				System.out.println(firstCount + count);
				return;
			}
			long count3 = 0;
			bls = new boolean[length];
			if (head == tail && bls2[length - 1] == false) {
				bls[0] = true;
				count3++;
			}
			last = S.charAt(0);
			for (int i = 1; i < length; i++) {
				if (S.charAt(i) == last && bls[i - 1] == false) {
					bls[i] = true;
					count3++;
				}
				last = S.charAt(i);
			}
			if (bls[length - 1] == bls2[length - 1] && head == tail) {
				System.out.println(firstCount + count + count3 * (K - 2));
				return;
			}

			long num3 = (K - 1) / 2;
			long num2 = K - 1 - num3;

			long ans = firstCount + count * (num2) + count3 * num3;
			System.out.print(ans);
		}
	}
}

Measured memory_bytes: 22612
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    bool flag;
    int num[15];
    int a,b,t;
    cin >> t;
    while(t--)
    {
        a = 0,b = 0;
        flag = true;
        for(int i = 0; i < 10; i++)
        {
            cin >> num[i];
        }
        for(int i = 0; i < 10; i++)
        {
            if(a >= b)
            {
                if(num[i] > a)
                {
                    a = num[i];
                }
                else if(num[i] > b)
                {
                    b = num[i];
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            else
            {
                if(num[i] > b)
                {
                    b = num[i];
                }
                else if(num[i] > a)
                {
                    a = num[i];
                }
                else
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
        {
            printf("YES\n");
        }
        else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A):
    B = 0
    bm = Counter()
    bm[0] += 1
    for i in range(1, N+1):
        B = A[i-1] + B
        bm[B % M] += 1

    ans = 0
    for v in bm.values():
        if v > 1:
            ans += (v*(v-1))//2

    return ans


def main():
    N, M = read_int_n()
    A = read_int_n()

    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88184
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;
	
	int n = s.size();
	int licznik = 0;
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
			licznik++;
			ans = max(ans, licznik);
		}
		else licznik = 0;
	}
	
	cout << ans << '\n';
	
	
	
	
	
	
	
	
	
    
	return 0;
}


Measured memory_bytes: 256
C = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(1, 3):
    for j in range(1, 3):
        if C[i][j] - C[i-1][j] != C[i][0] - C[i-1][0]:
            flag = False
        if C[i][j] - C[i][j-1] != C[0][j] - C[0][j-1]:
            flag = False
print('Yes' if flag else 'No')
        

Measured memory_bytes: 3064
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1<<i)<=x;i++);
    return i;
}

vector<int> osci(vector<int> v) {
	vector<int> v1;
	int n=v.size();
	int i=0,j=n-1;
	for(int k=0;k<n;k++) {
		if(k%2==0)
			v1.pb(v[i++]);
		else
			v1.pb(v[j--]);
	}
	reverse(all(v1));
	return v1;
} 

int b[125451]={0};
 
int32_t main() {
    fio
	cout << fixed << setprecision(15);
    
    int n,m;cin >> n >> m;
    
    if(n==1 and m==1) {
        cout << 1;
        return 0;
    }
    if(n==1 or m==1) {
        cout << max(n,m)-2;
        return 0;
    }
    cout << (n-2)*(m-2);
    
    
    return 0;
    
}

Measured memory_bytes: 7808
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	const s = input[0];
	// 処理
  	console.log(s.startsWith('YAKI') ? 'Yes' : 'No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29636
n = int(input())
point = [0, 0]
for i in range(n):
    a, b = input().split()
    if a > b:
        point[0] += 3
    elif a < b:
        point[1] += 3
    else:
        point[0] += 1
        point[1] += 1
print(*point)



Measured memory_bytes: 5600
A=io.read("n")
B=io.read("n")
C=io.read("n")
if A>B then
  A,B=B,A
end
if B>C then
  B,C=C,B
  if A>B then
    A,B=B,A
  end
end
local count=0
if (B-A)%2==0 then
  count=(B-A)//2+C-B
  else count=(B+1-A)//2+C-B+1
end
print(count)

Measured memory_bytes: 760
import java.util.*;

class Main {
    // ABC152D
    static final long MOD = 1_000_000_007;
    // 10^9+7
    static final int MAX = 2_147_483_646;
    // intの最大値
    static final int INF = 1_000_000_000;

    // 10^9
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        long all = 0;
        for(int i = 0;i < n;i++){
            all += sc.nextInt();
        }
        if(all < h){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
   
}


Measured memory_bytes: 48316
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int count = 0;

    rep(i,n){
        if(i+1 == a[a[i]-1]) count++;
    }
    
    cout << count/2 << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll ans = 0;
	string str;cin >> str;
	ll k;cin >> k;
	ll n = str.size();

	bool flag = true;
	REP(i, n-1){
		if(str[i] != str[i+1])flag = false;
	}
	if(flag){
		cout << n * k / 2 << endl;
		return 0;
	}

	ll ans1 = 0;
	for(int i = 1;i < n;i++){
		if(str[i-1] == str[i]){
			ans1++;
			i++;
		}
	}

	ll ans2 = 0;
	for(int i = 1;i < 2*n;i++){
		if(str[(i-1)%n] == str[i%n]){
			ans2++;
			i++;
		}
	}

	cout << ans1 + (ans2 - ans1) * (k - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

using mint = modint998244353;

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////
ll v;
bool b(ll x) { return x < v; }
ll e() { return -1; }

int main() {
	ll N, Q;
	cin >> N >> Q;
	vll a(N);
	rep(i, N)cin >> a[i];
	segtree<ll, max, e> sg(a);

	rep(q, Q) {
		ll t;
		cin >> t;

		if (t == 1) {
			ll x, vv;
			cin >> x >> vv;
			x--;
			sg.set(x, vv);
		}

		else if (t == 2) {
			ll l, r;
			cin >> l >> r;
			l--; r--;
			cout << sg.prod(l, r + 1) << endl;
		}

		else {
			ll x;
			cin >> x >> v;
			x--;
			ll ans = sg.max_right<b>(x);
			cout << ans + 1 << endl;
		}
	}
}


Measured memory_bytes: 9072
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String input1 = sc.nextLine();
        String[] inputs = input1.split(" ");
        
        int a = Integer.parseInt(inputs[0]);
        int b = Integer.parseInt(inputs[1]);
        
        int i = 1;
        int count = 0;
        while(true) {
            if (i >= b) {
                break;
            }
            count++;
            i += (a - 1);
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

Pred = []
dp = []

for i in range(K,N):
    if(T[i] == T[i-K]):
        T[i] = 'x'
    else:
        continue

x = T.count('r')
y = T.count('s')
z = T.count('p')

print(P * x + R * y + S * z)
        

Measured memory_bytes: 4084
import sys
n=int(input())
a,b=list(map(int,input().split())),0
if n==2:
    print(a[0]*2)
    sys.exit()
else:
    for i in range(n-2):
        b+=min(a[i],a[i+1])
    b+=a[0]+a[-1]
print(b)

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);
uniform_int_distribution<> DD(0, 1000000000);

ll random(ll r){
    return (ll(DD(eng))*1000000000 + ll(DD(eng)))%r;
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll mod2 = 1000003;

ll upp(ll i, ll j){
    if(j == 0)return 1;
    ll h = upp(i,j/2);
    if(j%2 == 0){
        return (h*h)%mod2;
    }
    return (i*((h*h)%mod2))%mod2;
}

ll INV[mod2] = {0};
ll FAC[mod2] = {0};
ll FACI[mod2] = {0};

ll prod(ll l, ll r){
    if(l > r)return 0;
    if(l == 0)return 0;
    return (FAC[r] * FACI[l-1])%mod2;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    ll t = 1;
    for(ll c1 = 0; c1 < mod2; c1++){
        INV[c1] = upp(c1, mod2-2);
        FAC[c1] = t;
        FACI[c1] = upp(t, mod2-2);
        t *= c1+1;
        t %= mod2;
    }

    cin >> q;

    rep(c1,0,q){
        ll x;
        cin >> x >> d >> n;
        if(d == 0){
            ll ans = upp(x,n);
            cout << ans << "\n";
            continue;
        }
        if(n >= mod2){
            cout << 0 << "\n";
            continue;
        }
        ll di = upp(d, mod2-2);
        ll x2 = (x*di)%mod2;
        ll ans = prod(x2,(x2 + n - 1)%mod2);
      //  cerr << ans << " - " << x2 << "," << (x2 + n - 1) << "\n";
        ans *= upp(d, n);
        ans %= mod2;
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 24320
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	int area1,area2;
	area1=A*B;
	area2=C*D;
	printf("%d\n",area1>=area2?area1:area2);
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
    char s[11];
    int r=9;
    scanf("%s", s);
    if (s[0]=='h' && strlen(s)%2==0){
        for (int i=1; i<strlen(s); ++i){
            if (i%2!=0){
                if (s[i]=='i'){
                    r+=0;
                }else{
                    r=20;
                    break;
                }
            }else{
                if (s[i]=='h'){
                    r+=0;
                }else{
                    r=20;
                    break;
                }
            }
        }
    }else{
        r=20;
    }
    if (r==20){
        printf("No\n");
    }else if(r==9){
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int max = (a > c)? a: c;
    int min = (b > d)? d: b;
    int ret = min - max;
    if (ret < 0)
        ret = 0;
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

#define MAX 200005
#define INFTY 1e13

int main() {
	int N;
	vector<int> A(MAX);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	vector<long long> ans(MAX);
	for (int i = 0; i < N; i++) ans[i] = INFTY;
	
	long long sum = 0;
	for (int i = 1; i < N; i++) sum += A[i];
	ans[0] = (long long)A[0] - sum;
	for (int i = 1; i < N; i++) {
		//if ((ans[i - 1] + 2LL * (long long)A[i]) > INFTY) ans[i] = INFTY;
		 ans[i] = ans[i - 1] + 2LL * (long long)A[i];
	}
	//for (int i = 0; i < N-1; i++) cout << ans[i] << " ";

	long long minl = INFTY;
	for (int i = 0; i < N-1; i++) {
		if (minl > llabs(ans[i])) minl = llabs(ans[i]);
	}

	cout << minl << endl;

	return 0;
}

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

using namespace std;

int main()
{
 int x,y;
cin>>x>>y;
int b=(y-2*x)/2;
if((y-2*x) % 2 == 0 && ((b>=0&& b<=x) && (x-b>=0 && x-b<=x)))
    {cout<<"Yes";}
else
    {cout<<"No";}
    return 0;
}


Measured memory_bytes: 3592
import sys
import itertools
import math

curdeg = 0
xstep = 0
ystep = 0
for line in sys.stdin.readlines():
    step, deg = map(int, line.split(","))
    xstep += step * math.cos(math.pi * curdeg / 180)
    ystep += step * math.sin(math.pi * curdeg / 180)
    curdeg += deg 

print(int(ystep))
print(int(xstep))

Measured memory_bytes: 7860
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
ll c, a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<"\n"; return 0;
    }
    cout << min(a*b,min(a*c,b*c)) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
  
int main(){
    vector<int> h(10);
    int in;
    for(int i=0;i<10;i++){
        cin>>in;
        h[i]=in;
    }
    sort(h.begin(),h.end());
    cout<<h[9]<<endl;cout<<h[8]<<endl;cout<<h[7]<<endl;
    return 0;
}

Measured memory_bytes: 3132
import sys
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    output = 0
    x = y = z = 0
    for _ in range(N):
        s = sys.stdin.readline().rstrip()
        output += s.count('AB')
        if s[0] == 'B' and s[-1] == 'A': y += 1
        elif s[-1] == 'A': x += 1
        elif s[0] == 'B': z += 1
        
    if y == 0:
        output += min(x, z)
        print(output)
        return

    if x > 0:
        output += y + min(1, z) + max(min(x-1, z-1), 0)
        print(output)
        return

    output += y - 1 + min(1, z)
    print(output)

    return

if __name__ == '__main__':
    main()


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

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

   int x, y = 400, z = 0;
   cin >> x;
   while (y + 200 <= x) {
      y += 200;
      z++;
   }
   cout << 8 - z << '\n';

   return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>


class Point {
public:
    float x;
    float y;
    void print() {
        printf("%.6f %.6f\n", x, y);
    }
};

//print depth-d koch except for p1,p2
void koch(int d, Point p1, Point p2) {
    if (d == 0) {
        return;
    }
    Point s,u,t;
    //(1/3)(p2-p1)=s-p1
    s.x=(p2.x+2*p1.x)/3;
    s.y=(p2.y+2*p1.y)/3;
    //(2/3)(p2-p1)=t-p1
    t.x=(2*p2.x+p1.x)/3;
    t.y=(2*p2.y+p1.y)/3;
    //u-s=R(t-s),where R is rotation matrix
    u.x=s.x+0.5*(t.x-s.x)-0.866025*(t.y-s.y);
    u.y=s.y+0.866025*(t.x-s.x)+0.5*(t.y-s.y);

    koch(d-1,p1,s);
    s.print();
    koch(d-1,s,u);
    u.print();
    koch(d-1,u,t);
    t.print();
koch(d-1,t,p2);
}

int main() {
    int n;
    scanf("%d",&n);
    Point p1,p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    p1.print();
    koch(n,p1,p2);
    p2.print();
    return 0;
}



Measured memory_bytes: 2756
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, w, k = map(int, input().split())
a = [list(map(int, list(input()))) for _ in range(h)]

ret = 100000
for i in range(2 ** (h-1)):
    hi = [0] * h
    for j in range(h-1):
        hi[j+1] += hi[j] + (i >> j & 1)
    cnt = max(hi)
    pj = 0
    x = []
    while pj < w:
        s = [0] * 10
        fg = False
        for j in range(pj, w):
            for t in range(h):
                s[hi[t]] += a[t][j]
            if max(s)>k:
                if j == pj:
                    cnt = 100000
                    fg = True
                    break
                else:
                    x.append(j)
                    cnt += 1
                    pj = j
                break
            if j == w-1:
                pj = w
                break
        if fg:
            break
    ret = min(ret, cnt)
print(ret)

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


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    count = 0

    for i in range(len(a)):
        if i == a[a[i] - 1] - 1:
            count += 1

    print(count // 2)


Measured memory_bytes: 14004
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d; cin>>a>>b>>c>>d;
	if (a*b<=c*d) cout<<(c*d)<<endl;
	else cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
s = []
for _ in range(H):
    s.append(list(input()))
cnt = 1
for y in range(H):
    for x in range(W):
        if s[y][x] == '#':
            s[y][x] = cnt
            cnt += 1

for y in range(H):
    for x in range(1, W):
        if s[y][x] == '.':
            s[y][x] = s[y][x - 1]
    for x in range(W - 2, -1, -1):
        if s[y][x] == '.':
            s[y][x] = s[y][x + 1]
for x in range(W):
    for y in range(1, H):
        if s[y][x] == '.':
            s[y][x] = s[y - 1][x]
    for y in range(H - 2, -1, -1):
        if s[y][x] == '.':
            s[y][x] = s[y + 1][x]
# print(s)
for y in range(H):
    for x in range(W):
        if x != W - 1:
            print(s[y][x], end=' ')
        else:
            print(s[y][x], end='\n')


Measured memory_bytes: 60120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int n=s.size();
	int a[n];
	rep(i,n) a[i]=1;

	for(int i=0;i<n-2;i++){
		if(s[i]=='R'){
			if(s[i+1]=='R'){
				a[i+2]+=a[i];
				a[i]=0;
			}
		}
	}
	//rep(i,n) cout<<a[i]<<" ";
	//cout<<"\n";
	for(int i=n-1;i>1;i--){
		if(s[i-1]=='L'&&s[i]=='L'){
			a[i-2]+=a[i];
			a[i]=0;
		}
	}
	rep(i,n) cout<<a[i]<<" ";
	cout<<"\n";

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,m;
struct mat
{
    int x[4][4];
    inline mat operator*(mat a)
    {
        mat p={};
        int i,j,k;
        for(i=0;i<4;i++)
          for(j=0;j<4;j++)
            for(k=0;k<4;k++)
              p.x[i][j]=(p.x[i][j]+(L)x[i][k]*a.x[k][j])%q;
        return p;
    }
}u,v,w;
inline mat power(mat a,int b)
{
    if(b==1)
      return a;
    mat c=power(a,b>>1);
    c=c*c;
    if(b&1)
      c=c*a;
    return c;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	for(i=0;i<4;i++)
	  for(j=0;j<4;j++)
	    if((i&j)==i)
	      u.x[i][j]=v.x[i][j]=1;
	for(i=0;i<4;i++)
	  u.x[3][i]++;
	for(i=0;i<4;i++)
	  w.x[i][i]=1;
	scanf("%d%d",&n,&m);
	for(i=1,k=0;i<=m;i++)
	  {
       scanf("%d",&j);
       j++;
       if(j-1>k)
         w=w*power(u,j-k-1);
       w=w*v;
       k=j;
      }
    if(k<n)
      w=w*power(u,n-k);
    printf("%d\n",w.x[0][3]);
	return 0;
}


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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define INF 1123456789
#define MOD 1000000007LL
#define ff first
#define ss second
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pi> vpi;



void solve(int testcase)
{
    string s;
    cin >> s;
    int a = 0, b = 0;
    rep(i, 0, 3){
        if(s[i] == '+') a++;
        else b--;
    }
    cout << a+b;


}

signed main()
{
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(10);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i<(int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const int INF = 1e9+10;

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

	int a, b, c; cin >> a >> b >> c;
	if((a == b && c != a) || 
	   (a == c && b != a) ||
	   (b == c && a != c))
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char s[4];
  cin>>s;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(s[i]=='o')cnt++;
  }
  cout<<700+cnt*100<<endl;
}

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

string data[10]={
	"",
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};
int main(){
	int t;
	cin>>t;
	while(t>0){
		t--;
		string str;
		cin>>str;
		string ans;
		int counts=0;
		for(int i=0;i<str.size();i++){
			if(str[i]=='0'){
				if(counts)ans+=data[str[i-1]-'0'][(counts-1)%data[str[i-1]-'0'].size()];
				counts=0;
			}
			else counts++;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

int main()
{
  int a[3];
  int k;
  int sum = 0;

  for ( int i = 0; i < 3; ++i ) cin >> a[i];
  sort(a,a+3);
  cin >> k;

  for ( int i = 0; i < k; ++i ) a[2] *= 2;
  for ( int i = 0; i < 3; ++i ) sum += a[i];

  cout << sum << "\n";
}


Measured memory_bytes: 256
//我是菜鸡
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 10+5;
const int MOD = 9973;
const double exps = 1e-6;
void deprint() {
	ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, a[105], sum = 0; cin >> n;
	ll ans = 0;
	_for(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	int t = floor(double(sum) / n + 0.5);
	_for(i, 0, n)ans += (a[i] - t) * (a[i] - t);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl v(m),dp(n+3);
	rep(i,m)cin>>v[i],dp[v[i]]=-1;
	dp[0]=1;
	rep(i,n){
		if(dp[i]!=-1&&dp[i+2]!=-1){
			dp[i+2]+=dp[i];dp[i+2]%=MOD;
		}
		if(dp[i]!=-1&&dp[i+1]!=-1){
			dp[i+1]+=dp[i];dp[i+1]%=MOD;
		}
	}
	cout<<(dp[n]!=-1?dp[n]:0)<<endl;

}


Measured memory_bytes: 1792
N = int(input())
D = []
for _ in range(N):
    D.append(tuple(map(int, input().split())))

for i in range(N - 2):
    if D[i][0] == D[i][1] and D[i + 1][0] == D[i + 1][1] and D[i + 2][0] == D[i + 2][1]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int minDistance(vector<vector<int>>& edge, int st, int en) {
	size_t numNode = edge.size();
	vector<bool> passed(numNode, false);
	queue<int> v;
	queue<int> d;

	v.push(st);
	d.push(0);
	passed[st] = true;

	while(!v.empty()) {

		int nowV = v.front(); v.pop();
		int nowD = d.front(); d.pop();

		if(nowV == en) {
			return nowD;
		}

		for(auto nextV : edge[nowV]) {
			if(passed[nextV]) {
				continue;
			}

			v.push(nextV);
			d.push(nowD + 1);
			passed[nextV] = true;
		}

	}

	return -1;
}

int main() {

	int n;
	cin >> n;

	vector<vector<int>> edge(n);
	for(int i = 0; i < n; i++) {
		int u, k, v;
		cin >> u >> k;
		for(int j = 0; j < k; j++) {
			cin >> v;
			edge[u - 1].push_back(v - 1);
		}
	}

	for(int i = 0; i < n; i++) {
		cout << i + 1 << " " << minDistance(edge, 0, i) << endl;
	}

	return 0;
}


Measured memory_bytes: 3156
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int n;
        scanf("%d", &n);
        printf("%d\n", (1000-n%1000)%1000);
        return 0;
}

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

int main()
{
    int n;
    string s, t, ans;
    cin >> n;
    cin >> s >> t;
    for(int i=0; i<n; i++)
    {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << "\n";
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    map<int, bool> visited;
    int ans = 0;
    for(auto x: mp)
    {
        if(visited[x.first])
        {
            continue;
        }
        for(int i = x.first; i <= 1000000; i += x.first)
        {
            if(mp.count(i) && !visited[i])
            {
                visited[i] = 1;
            }
        }
        if(x.second <= 1)
        {
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 22336
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k,ans;
	scanf("%d %d %d",&a,&b,&k);
	for(int i=min(a,b);i>0;i--){
		if(a%i==0&&b%i==0) ans++;
		if(ans==k){
			printf("%d",i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> v(10);
    rep(i, 0, n) {
        v[s[i] - '0'].push_back(i);
    }
    int ans = 0;
    rep(i, 0, 1000) {
        int t[3] = {i / 100, (i / 10) % 10, i % 10};
        int p = 0;
        bool found = true;
        int cnt = 0;
        rep(j, 0, 3) {
            if ((int)v[t[j]].size() == 0) {
                found = false;
                break;
            }
            auto it = lower_bound(all(v[t[j]]), p);
            if (it - v[t[j]].begin() == (int)v[t[j]].size()) {
                found = false;
                break;
            }
            p = *it + 1;
            cnt++;
        }
        if (found && cnt == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
int c,f;
int main(){
	cin>>s;
	c=0,f=s.length()-1;
	while(s[c]!='C'&&c<=f) c++;
	while(s[f]!='F'&&f>=0) f--;
	if(c<f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256