akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll dectobin(ll n,ll p[])
{
    ll i=0 ;
    while(n!=0)
    {
        p[i]=n%2 ;
        n/=2 ;
        i++ ;
    }
    return(i-1) ;
}
ll binarySearchCount(ll arr[], ll n, ll key) 
{ 
    ll left = 0; 
    ll right = n - 1; 
  
    ll count = 0; 
  
    while (left <= right) { 
        int mid = (right + left) / 2; 
  
        // Check if middle element is 
        // less than or equal to key 
        if (arr[mid] < key) { 
  
            // At least (mid + 1) elements are there 
            // whose values are less than 
            // or equal to key 
            count = mid + 1; 
            left = mid + 1; 
        } 
  
        // If key is smaller, ignore right half 
        else
            right = mid - 1; 
    } 
  
    return count; 
} 
void printDivisors(ll n,ll k) 
{  ll temp=1  ;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                {
                	if(i<=k && i>temp)
                	temp=i ;
				}
  
            else // Otherwise print both 
                
                {
                if(i<=k && i>temp)
                	temp=i ;
                if(n/i<=k && n/i>temp)
                temp=n/i ;
				}
        } 
    }
	cout<<n/temp<<"\n" ;
	return ; 
} 
ll solve(ll n)
{
	ll temp=-1 ;
	forn(i,n)
	{
		forn(j,3)
		{
			if(j!=temp)
			{
				
			}
		}
	}
}
int main(int argc, char** argv)
{   sws ;
 //tcase
{
ll n,m ;
cin>>n>>m ;
if(n==m)
{
	forn(i,n)
	cout<<n;
}
else
{
	forn(i,max(m,n))
	cout<<min(n,m);
}
}
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int X = Integer.parseInt(scan.next());

		int[] x = new int[N];
		for (int i = 0; i < N; i++) {
			x[i] = Integer.parseInt(scan.next());
		}
		int[] distance = new int[N];
		for (int i = 0; i < N; i++) {
			distance[i] = Math.abs(x[i] - X);
		}
		int result = distance[0];
		for (int i = 1; i < N; i++) {
			result = gcd(distance[i], result);
		}
		System.out.println(result);
	}

	public static int gcd(int x, int y) {
		if (x < y) {
			return gcd(y, x);
		}
		int r = x % y;
		if (r == 0) {
			return y;
		}
		return gcd(y, r);

	}
}


Measured memory_bytes: 48788
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> p(n);
	REP(i, n) cin >> p[i];
	vector<vector<ll>> dp(n, vector<ll>(n + 1, INF * INF));
	dp[0][0] = a;
	dp[0][p[0]] = 0;
	FOR(i, 1, n) {
		vector<ll> mn1(n + 1, INF * INF);
		vector<ll> mn2(n + 1, INF * INF);
		REP(j, n + 1) {
			if(j == 0) mn1[j] = dp[i - 1][0];
			else mn1[j] = min(dp[i - 1][j], mn1[j - 1]);
		}
		for(ll j = n; j >= 0; j--) {
			if(j == n) mn2[j] = dp[i - 1][n];
			else mn2[j] = min(dp[i - 1][j], mn2[j + 1]);
		}
		REP(j, n + 1) {
			if(j == 0) {
				dp[i][j] = a + dp[i - 1][j];
			} else if(j == p[i]) {
				dp[i][j] = mn1[j];
			} else if(j < p[i]) {
				dp[i][j] = dp[i - 1][j] + a;
			} else {
				dp[i][j] = dp[i - 1][j] + b;
			}
		}
	}
	ll ans = INF * INF;
	REP(i, n + 1) {
		ans = min(ans, dp[n - 1][i]);
	}
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 197504
/*  
    ┬┴┬┴┤(･_├┬┴┬┴ hiding from those WAs
*/

#include <bits/stdc++.h>
using namespace std;

int cnt[100005];
void ngk(){
	int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    
	long long ans = 0;
	int pow10 = 1;
	int sum = 0;
    if (p != 2 && p != 5){
		cnt[0] = 1;
		for(auto v: s){
			sum = (sum + (v - '0') * pow10) % p;
			ans += cnt[sum]++;
			pow10 = pow10 * 10 % p;
		}
    }
    else{
    	int z = 0;
    	for(auto v: s){
    		if ((v - '0') %p == 0) z ++;
    		ans += z;
    	}
    }
    cout << ans;
}

int main(int argc, char *argv[]){
    iostream::sync_with_stdio(0);
    int test = 1;
    while(test--){
        ngk();
    }
    return 0;
}

Measured memory_bytes: 720
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x,y,z;
  cin >> x >> y >> z;

  cout << (x - z )/ (y + z) << endl;



  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); IO();
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

void IO()
{
	#ifndef ONLINE_JUDGE
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
}

//================================

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

	if (b >= a)
		cout << "unsafe\n";
	else
		cout << "safe\n";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <queue>

// sに含まれないもので，小さい方から2つ
std::array<int, 2> mex(std::set<int> s) {
    std::array<int, 2> ret;
    int idx = 0;
    for (int x = 0;; ++x) {
        if (s.count(x)) continue;
        ret[idx] = x;
        if (++idx == 2) break;
    }
    return ret;
}

bool solve(const std::vector<int>& par, int choice) {
    int n = par.size();

    // 出次数
    std::vector<int> outdeg(n, 0);
    for (auto p : par) ++outdeg[p];

    std::queue<int> que;
    std::vector<int> assign(n, -1);
    for (int v = 0; v < n; ++v) {
        if (outdeg[v] == 0) {
            assign[v] = 0;
            que.push(v);
        }
    }

    // 子のassignの集合
    std::vector<std::set<int>> ch(n);
    while (true) {
        while (!que.empty()) {
            int v = que.front();
            que.pop();

            int u = par[v];
            ch[u].insert(assign[v]);

            // 親の出次数が0になったら割り当て
            if (--outdeg[u] == 0 && assign[u] < 0) {
                assign[u] = mex(ch[u])[0];
                que.push(u);
            }
        }

        bool finish = true;
        for (int v = 0; v < n; ++v) {
            if (assign[v] < 0) {
                // サイクルから1つ選んで，適当に割り当て
                // この割り当て(choice)を全探索
                finish = false;
                assign[v] = mex(ch[v])[choice];
                que.push(v);
                break;
            }
        }
        if (finish) break;
    }

    // Judge
    for (auto& c : ch) c.clear();
    for (int v = 0; v < n; ++v) {
        int u = par[v];
        ch[u].insert(assign[v]);
    }
    for (int v = 0; v < n; ++v) {
        if (assign[v] != mex(ch[v])[0]) {
            return false;
        }
    }

    return true;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> par(n);
    for (auto& p : par) {
        std::cin >> p;
        --p;
    }

    for (int choice = 0; choice < 2; ++choice) {
        if (solve(par, choice)) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}


Measured memory_bytes: 20224
#include<iostream>

using namespace std;

int division_counts[2*100000 + 10][2] = {{}};

int main(void)
{
  string str;
  
  cin >> str;
  
  division_counts[0][0] = 1;
  division_counts[0][1] = 1;
  if(str[0] == str[1]){
    division_counts[2][1] = 2;
  }else{
    division_counts[1][0] = 2;
  }

  for(int i = 2; i < str.size(); i++){
    if(str[i] == str[i - 1]){
      division_counts[i][0] = division_counts[i - 1][1] + 1;
      division_counts[i][1] = max(division_counts[i - 2][1], division_counts[i - 2][0]) + 1;
    }else{
      division_counts[i][0] = max(division_counts[i - 1][0], division_counts[i - 1][1]) + 1;
      division_counts[i][1] = max(division_counts[i - 2][0], division_counts[i - 2][1]) + 1;
    }
  }
  
  int end_index = str.size() - 1;
  cout << max(division_counts[end_index][0], division_counts[end_index][1]) << endl;
  
  return 0;
}

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

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

    vector<int> t(D);
    rep(i,D){cin >> t[i];}

    vector<int> zenkai(26,0);

    int score=0;
    rep(i,D){
        zenkai[t[i]-1]=i+1;
        score+=s[i][t[i]-1];
        rep(j,26){
            score-=c[j]*(i+1-zenkai[j]);
        }
        cout << score << endl;
    }

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,k;
	cin>>n>>k;
	vi a(n+3);
	rep(i,n){
		int z;cin>>z;z--;
		a[i]=z;
	}

	int now=0;
	int cnt=0;
	vi visit[200200];
	visit[0].pb(0);

	bool f=1;
	rep(i,k){
		now=a[now];
		cnt++;
		visit[now].pb(cnt);

		if(f&&visit[now].size()==2){
			f=0;
			int t=visit[now][1]-visit[now][0];
			i+=(k-cnt-t)/t*t;
		}
	}
	cout<<now+1<<endl;
	
	// int t=visit[now][1]-visit[now][0];
	// k-=visit[now][0];
	// k%=t;
	// k+=visit[now][0];
	// int ans=0;
	// rep(i,k){
	// 	ans=a[ans];
	// }
	// ans++;
	// cout<<ans<<endl;
	// printf("t=%d\n",t);

	// rep(i,n) printf("a[%d]=%d\n",i,a[i]);
	// rep(i,n){
	// 	printf("visit[%d]: ",i);
	// 	rep(j,visit[i].size()) cout<<visit[i][j]<<' ';
	// 	cout<<endl;
	// }

	return 0;
}



Measured memory_bytes: 14564
xs, ys, xt, yt = map(int, input().split())
n = int(input())
p = [(xs, ys, 0), (xt, yt, 0)]
for i in range(n):
    p.append(tuple(map(int, input().split())))
edge = [[0] * (n + 2) for _ in range(n + 2)]
for i in range(n + 2):
    for j in range(i, n + 2):
        edge[i][j] = max(0, ((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)**0.5 - p[i][2] - p[j][2])
        edge[j][i] = max(0, ((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)**0.5 - p[i][2] - p[j][2])


def dijkstra(s, n, edges):
    INF = float('inf')
    d = [INF] * n
    d[s] = 0
    import heapq
    pq = [(0, s)]
    while len(pq):
        c, v = heapq.heappop(pq)
        if d[v] < c:
            continue
        # for v2nvcost, nv in edges[v]:
        for nv, v2nvcost in enumerate(edges[v]):
            if c + v2nvcost < d[nv]:
                d[nv] = c + v2nvcost
                heapq.heappush(pq, (d[nv], nv))
    return d


dist = dijkstra(0, n + 2, edge)
print(dist[1])


Measured memory_bytes: 127148
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

from collections import Counter

n = readint()
a = sorted(readints())

c = Counter(a)
ans = 0
b = [1]*(max(c)+1)
l = max(c)

for x in c:
    if c[x]==1 and b[x]==1:
        ans += 1
    for i in range(1,l//x+1):
        b[x*i] = 0

print(ans)





Measured memory_bytes: 130992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	NMC := readIntArray()
	N := NMC[0]
	M := NMC[1]
	C := NMC[2]
	B := readIntArray()
	var ans int
	for i := 0; i < N; i++ {
		a := readIntArray()
		val := 0
		for j := 0; j < M; j++ {
			val += a[j] * B[j]
		}
		val += C
		if val > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

// s = "aabbbc" -> [[a,2],[b,3],[c,1]]
vector<pair<char,int>> rle (string s) {
  vector<pair<char,int>> res;
  int n = (int)s.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && s[j] == s[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(s[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  string s;
  cin >> s;
  int n = s.size();
  
  bool same = true;
  rep(i,n-1) {
    if (s[i] != s[i+1]) {
      same = false;
      break;
    }
  }
  if (same) {
    cout << 0 << endl;
    return 0;
  }

  auto vp = rle(s);
  int ans = vp.size() - 1;
  cout << ans << endl;

  return 0;
}

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

int main() {
  long long n, k;
  cin >> n >> k ;
  vector<int> a(n);
  for(int j=0;j<n;j++){
    cin >> a[j];
  }
  
  vector<int> s;
  vector<int> ord(n+1, -1);
  int v = 1, c=1, l=0;
  while(ord[v] == -1){
    ord[v] = s.size();
    s.push_back(v);
    v = a[v-1];
  }
  c = s.size() - ord[v];
  l = ord[v];
  
  if(k < l) cout << s[k] << endl;
  else{
   k -= l;
   k %= c;
  cout << s[l + k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5808
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<string>

const int MAX_N=1<<17;

using namespace std;

int n,dat[2*MAX_N];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
}

void add(int k,int a){
  k+=n-1;
  dat[k]+=a;

  while(k>0){
    k=(k-1)/2;
    dat[k]=dat[2*k+1]+dat[2*k+2];
  }
}

int query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return 0;
  if(a<=l && r<=b)return dat[k];

  int vl=query(a,b,k*2+1,l,(l+r)/2);
  int vr=query(a,b,k*2+2,(l+r)/2,r);
  return vl+vr;
}

int main(void){

  int m,q,a,b,com;

  cin >> m >> q;

  init(m);
  while(q--){
    cin >> com >> a >> b;
    if(com)cout << query(a-1,b,0,0,n) << endl;
    else add(a-1,b);

  }
  return 0;
}

Measured memory_bytes: 1964
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll power(ll x, ll  y)  
{  
    ll res = 1;     // Initialize result  
    x = x % mod;
    y=y%mod;
    while (y > 0)  
    {  
        if (y & 1)  
            res = ((res%mod)*(x%mod)) % mod;  
        y = y>>1; // y = y/2  
        x = ((x%mod)*(x%mod)) % mod;  
    }  
    return res%mod;  
}  
  
int main(){
    ll n,m;
    cin>>n;ll a[n+2];ll hash[200005]={0};
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    if(n%2==0)
    {
    	if(a[0]!=1) {cout<<"0\n";return 0;}
    	if(a[1]!=1) {cout<<"0\n";return 0;}
    	for(int i=2,j=3;i<n;i+=2,j+=2){
    	if(a[i]==j && a[i+1]==j){}else {cout<<"0\n";return 0;}}
    	
    }
    else
    {
    	if(a[0]!=0) {cout<<"0\n";return 0;}
    	for(int i=1,j=2;i<n;i+=2,j+=2){
    	if(a[i]==j && a[i+1]==j){}else {cout<<"0\n";return 0;}}
    }

   ll po=power(2,n/2)%mod;cout << po << endl;
    }
    
    
   

    


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
   int n;
   cin >> n; 
   string s;
   cin >> s;
   int ans = 1;
   char c = s[0];
   rep(i, n) {
       if(c == s[i]) continue;
       ++ans;
       c = s[i];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string S,T;
	cin>>S>>T;
	int answer=T.length();
	for(int i=0;i<=S.length()-T.length();i++){
		int now=0;
		for(int j=0;j<T.length();j++){
			if(S[i+j]!=T[j]){
				now++;
			}
		}
		answer=min(now,answer);
	}
	cout<<answer;
	return 0;
}


Measured memory_bytes: 3156
import sys

n = int(sys.stdin.readline())
dist = [0] + [-1] * (n-1)
vv=[list(map(int, sys.stdin.readline().split()))[2:] for _ in range(n)]


def walk(k, d):
    for i in vv[k]:
        if dist[i-1]<0 or (dist[i-1]>0 and dist[i-1]>d):
            dist[i-1]=d
        else: continue
        walk(i-1, d+1)

walk(0, 1)

for i, d in enumerate(dist):
    print(i+1, d)


Measured memory_bytes: 5644
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]

    memo = deque()
    memo.append(0)
    d = defaultdict(int)
    ans = 0
    nv = 0
    d[0] += 1
    for i,ai in enumerate(a):
        nv += ai-1
        nv %= k
        memo.append(nv)
        if i >= k-1:
            pi = memo.popleft()
            d[pi] -= 1
        ans += d[nv]
        d[nv] += 1

    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 118772
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

h, w = I2()
c = [S() for _ in range(h)]
#print("------------------")
for i in range(2*h):
    print(c[i//2])

Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline().strip()

n, u, v = map(int, input().split())
u, v = u-1, v-1

tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

from queue import Queue

# 青木君によるWFS
aoki = [-1 for _ in range(n)]
aoki[v] = 0
todo = Queue()
todo.put(v)
while not todo.empty():
    i = todo.get()
    for j in tree[i]:
        if aoki[j] == -1:
            todo.put(j)
            aoki[j] = aoki[i] + 1

# 高橋君によるWFS
taka = [-1 for _ in range(n)]
taka[u] = 0
todo = Queue()
todo.put(u)
while not todo.empty():
    i = todo.get()
    for j in tree[i]:
        if taka[j] == -1:
            if taka[i] + 1 < aoki[j]:
                todo.put(j)
            taka[j] = taka[i] + 1

# search
ans = 0
for i in range(n):
    if taka[i] != -1:
        if aoki[i] - 1 > ans:
            ans = aoki[i] - 1

print(ans)

Measured memory_bytes: 29532
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N = S()
    K = I()
    dig = len(N)
    if dig < K:
        print(0)
        exit()
    ans = 0
    for i in range(dig):
        if K == 0:
            ans += 1
            break
        if int(N[i]) == 0:
            continue
        if dig - i - 1 >= K:
            ans += combinations_count(dig - i - 1, K) * pow(9, K)
        if dig - i - 1 >= K - 1:
            ans += (int(N[i]) - 1) * combinations_count(dig - i - 1, K - 1) * pow(9, K - 1)
        if i == dig - 1:
            ans += 1
        K -= 1
    print(ans)
if __name__ == "__main__":
    main()



Measured memory_bytes: 68456
#include<iostream>
using namespace std;
int main() {
    int A, B;
    string S, T, U;
    cin >> S >> T >> A >> B >> U;
    if (U == S) {
        A--;
        cout << A << " " << B << endl;
    }
    else {
        B--;
        cout << A << " " << B-- << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int d[100005];
set<int>bl[100005];
set<int>fd[100005];
int fi(int x) {
    return d[x] < 0 ? x : d[x] = fi(d[x]);
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    memset(d, -1, sizeof(d));
    for (int i = 0 ; i < a ; i++) {
        int x, y;
        cin >> x >> y;
        fd[x].insert(y);
        fd[y].insert(x);
        int xx = fi(x);
        int yy = fi(y);
        if (xx != yy) {
            d[xx] += d[yy];
            d[yy] = xx;
        }
    }
    for (int i = 0 ; i < b ; i++) {
        int x ,y;
        cin >> x >> y;
        bl[x].insert(y);
        bl[y].insert(x);
    }
    for (int i = 1 ; i <= n ;i++) {
        int ans = -d[fi(i)] - fd[i].size() - 1;
        for (auto j:bl[i]) {
            if(fi(i) == fi(j)) {
                ans--;
            }
        }
        cout << ans <<' ';
    }
    cout << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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

    if (A % 2 == B % 2) {
        cout << abs(A - B) / 2 << endl;
        return 0;
    }


    ll ans = 0;
    if (A > B) swap(A, B);
    ll dist_a = A - 1;
    ll dist_b = N - B;
    if (dist_a < dist_b) {
        A -= dist_a;
        B -= dist_a + 1;
        ans += dist_a + 1;
    } else {
        A += dist_b + 1;
        B += dist_b;
        ans += dist_b + 1;
    }

    ans += abs(A - B) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}

vector<pair<long long, int>> factor(long long x) {
    vector<pair<long long, int>> res;
    for (long long i = 2; i*i <= x; ++i) {
        if (x % i) continue;
        res.emplace_back(i, 0);
        while (x % i == 0) {
            x /= i;
            res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factor(g);
    ll ans = 0;
    ans += sz(f);
    ans++;
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  int l,r; l = r = 2;
  
  ROF(i,n,0){
    l = (l + a[i] - 1) / a[i] * a[i];
    r = r / a[i] * a[i] + a[i] - 1;
  }
  dump(l,r);

  if(r < l) cout << -1 << endl;
  else cout << l << " " << r << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,g;
  int p[10], c[10];
  bool used[10] = {};
  cin >> d >> g;
  for(int i = 0; i < d; i++){
    cin >> p[i] >> c[i];
  }
  int lim = pow(2,d);
  int ans = 1000000;
  for(int i = 0; i < lim; i++){
    // どの得点の問題を解くのか設定
    int crr = i;
    for(int j = 0; j < d; j++){
      used[j] = (crr%2 == 1);
      crr /= 2;
    }

    // スコア計算
    int score = 0, cnt = 0;
    for(int j = 0; j < d; j++){
      if(used[j]){
        score += p[j]*100*(j+1) + c[j];
        cnt += p[j];
      }
    }

    // 足りなければ解いてない問題のうち最大得点のものを解く
    if(score < g){
      int tar = -1;
      for(int j = d-1; j >=0; j--){
        if(!used[j]){
          tar = j;
          break;
        }
      }
      if(tar < 0){
        continue;
      }
      int qnum = (int)ceil((g-score)/((double)(tar+1)*100));
      if(qnum > p[tar]){
        continue;
      }
      cnt += qnum;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

int is_right_triangle(int a, int b, int c) {
  return a * a == b * b + c * c;
}

int main(void) {
  int i, n, a, b, c;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);

    if (is_right_triangle(a, b, c) ||
        is_right_triangle(b, a, c) ||
        is_right_triangle(c, a, b)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int n,x,a[100];
	cin>>n>>x;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(a[i]<=x){
			ans++;
			x=x-a[i];
		}
		else {
			cout<<ans<<endl;
			return 0;
		}
	}
	if(x!=0){
		ans--;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main() {
	ll n;
	string s;
	cin>>n>>s;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'A'+n;
		if(now>=26){
			now-=26;
		}
		cout << char(now+'A');
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    double a, b, x;
    cout << fixed << setprecision(10);
    cin >> a >> b >> x;
    double s = x/a;
    double h = s/a;
    double u, v;
    if (h > b/2) {
        v = max(b - h, 0.0);
        u = a/2;
    }
    else {
        v = b;
        u = 2*s/b;
    }

    cout << atan(v/u)*180/M_PI << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	char c;
	stack<int> s;
	int i=0;
	int sum=0;
	int k=0;
   std::vector<int> v;
    stack<pair<int,int> > s2;
	while(cin>>c){
		i++;
		if(c=='\\'){
           s.push(i);
		}
		else if(c=='/' && s.size()>0){
			int j=s.top();s.pop();
			int a=i-j;
            sum+=a;
            while(s2.size()>0 && s2.top().first>j){
            	 a+=s2.top().second;s2.pop();
            }
            s2.push(make_pair(j,a));
                 
		}
	}
	cout<<sum<<endl;
	while(s2.size()>0){
		v.push_back(s2.top().second); s2.pop();
	}
	cout<<v.size();
	for(int i=v.size()-1;i>=0;--i){
		cout<<' '<<v[i];
	}
	cout<<endl;	
		return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 10, mod = 1e9 + 7;
char lx[N];
int a[N];
ll f[N][3];

void Add(ll &x, ll y) {
	x = (x + y) % mod;
}

void Max(ll &x, ll y) {
	x = max(x, y);
}

ll add(ll x, ll y) {
	return (x + y) % mod;
}

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		if(i != n) cin >> lx[i];
	}
	for(int i = 0; i <= n; ++i) 
		for(int j = 0; j < 3; ++j)
			f[i][j] = -1e18;
	f[1][0] = a[1];
	for(int i = 2; i <= n; ++i) {
		for(int j = 0; j < 3; ++j) {
			ll pos = a[i];
			int t = 0, now;
			if(lx[i - 1] == '-') t = 1;
			now = t ^ (j & 1);
			if(now) pos = -a[i];
			if(t && j < 2) Max(f[i][j + 1], f[i - 1][j] + pos);
			// printf("%d %d %lld\n", i, j, pos);
			for(int k = 0; k <= j; ++k) {
				Max(f[i][k], f[i - 1][j] + pos);
			}
		}
	}
	// for(int i = 1; i <= n; ++i)
	// 	for(int j = 0; j < 3; ++j) {
	// 		printf("f[%d][%d] = %lld\n", i, j, f[i][j]);
	// 	}
	printf("%lld\n", f[n][0]);
	return 0;
}

Measured memory_bytes: 3072
using System;
using System.Linq;
using System.Collections.Generic;

namespace MSPC2020
{
    class A
    {
        static void Main(string[] args)
        {
            //var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var LRd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var X = int.Parse(Console.ReadLine());
            //var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var K = int.Parse(Console.ReadLine());
            var A = ABC[0]; var B = ABC[1]; var C = ABC[2];

            for (int i = 0; i < K; i++)
            {
                if (B <= A)
                {
                    B *= 2;
                }
                else if (C <= B)
                {
                    C *= 2;
                }
                //Console.WriteLine("{0} {1} {2}", A, B, C);
                //if (A < B && B < C) Console.WriteLine("Yes");
            }
            if (A < B && B < C) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28228
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a)+min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)


print(ans)

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define All(v) (v).begin(), (v).end()
#define Pb push_back

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

    ll a,b;
    cin >> a >> b;
    if(a==b) cout << "Draw" << "\n";
    else if(a==1) cout << "Alice" << "\n";
    else if(b==1) cout << "Bob" << "\n";
    else{
        if(a>b) cout << "Alice" << "\n";
        else cout << "Bob" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//????????¢??°????????????MAX???
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//?????\??¢??°
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//??????????????¢??°
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int mitr(int v,int e,int *a,int *b,int *c){
  int i,r,n,s=0,mi,d[100010]={0};
  int p[100010]={0};
  for(i=0;i<e;i++)hin(c[i]);
  for(i=0;i<e;i++){
    mi=hout()-1;//printf("%d %d %d %d ",mi,a[mi],b[mi],c[mi]);
    for(r=++a[mi];p[r];r=p[r]);
    for(;n=p[a[mi]];a[mi]=n)p[a[mi]]=r;
    for(r=++b[mi];p[r];r=p[r]);
    for(;n=p[b[mi]];b[mi]=n)p[b[mi]]=r;//printf("%d %d\n",a[mi],b[mi]);
    if(a[mi]-b[mi]){
      s+=c[mi];
      d[a[mi]]<d[b[mi]]?(p[a[mi]]=b[mi]):(p[b[mi]]=a[mi]);
      if(d[a[mi]]==d[b[mi]])d[a[mi]]++;
    }
  }
  return s;
}
int main(){
  int v,e,i,a[100010],b[100010],c[100010];
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  printf("%d\n",mitr(v,e,a,b,c));    
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,P; cin >> N >> P;
    VI A(N); REP(i,N) cin >> A[i];
    ll dp[N+1][2]; REP(i,N+1)REP(j,2) dp[i][j] = 0;

    dp[0][0] = 1;
    REP(i,N){
        if(A[i]%2){
            dp[i+1][0] += dp[i][1];
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] += dp[i][1];
        }
        else{
            dp[i+1][0] += dp[i][0];
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];
            dp[i+1][1] += dp[i][1];
        }
    }
    cout << dp[N][P] << en;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
    string s;
    cin >> s;
    if(s== "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}

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

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  
  int answer = 0;
  for (int i=0 ; i<S.size() ; i++){
    if (S.at(i) != T.at(i))
      answer++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 3860
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < n; ++i)
			{
				int a = stdIn.nextInt();
				list.add(a);
			}
			Collections.sort(list);
			int sum = 0;
			for(int i = 1; i < list.size() - 1; ++i)
			{
				sum += list.get(i);
			}
			System.out.println(sum / (list.size() - 2));
		}
	}
}

Measured memory_bytes: 12000
import numpy as np

class Restaurant:
    def __init__(self, index, city, point):
        self.index = index
        self.city = city
        self.point = int(point)

N = int(input())
restaurant_dict = {}
S, P = [], []
for i in range(N):
    s, p = [x for x in input().split()]
    if not s in restaurant_dict:
        restaurant_dict[s] = [Restaurant(i + 1, s, p)]
    else:
        restaurant_dict[s].append(Restaurant(i + 1, s, p))
    if not s in S:
        S.append(s)
    # P.append(int(p))
    # restaurant_dict.append(Restaurant(i, s, p))
for s in sorted(S):
    scores = np.array([rest.point for rest in restaurant_dict[s]])
    index = scores.argsort()
    index = index.tolist()
    for ind in reversed(index):
        # print(restaurant_dict[s][ind].city)
        print(restaurant_dict[s][ind].index)
        # print(restaurant_dict[s][ind].point)

Measured memory_bytes: 14432
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 
ll dp[100010] = {};
int main(){
  ll n, input;
  vector<ll> h;
  cin >> n;
  rep(i, 0, n){
    cin >> input;
    h.push_back(input);
  }
  
  dp[1] = labs(h[1] - h[0]);
  rep(i, 0, n-2){
    dp[i+2] = min(dp[i+1] + labs(h[i+2] - h[i+1]), dp[i] + labs(h[i+2] - h[i]));
  }
  print(dp[n-1]);
  return 0;
}

Measured memory_bytes: 1908
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    if(a>b){
        printf("a > b\n");
    }
    if(a==b){
        printf("a == b\n");
    }
    return 0;
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> m;
	cout<<n*m;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

//AOJ 0515

signed main(){
	int a, b, n, x, y;
	int dp[20][20];
	bool pass[20][20];
	while (1) {
		cin >> a >> b >> n;
		if (a + b == 0) break;
		rep(i, 0, 20) {
			rep(j, 0, 20) {
				dp[i][j] = 0;
				pass[i][j] = true;
			}
		}
		rep(i, 0, n) {
			cin >> x >> y;
			x--;
			y--;
			pass[x][y] = false;
		}
		dp[0][0] = 1;
		rep(i, 0, a) {
			rep(j, 0, b) {
				if (pass[i+1][j]) {
					dp[i+1][j] += dp[i][j];
				}
				if (pass[i][j+1]) {
					dp[i][j+1] += dp[i][j];
				}
			}
		}
		cout << dp[a - 1][b - 1] << endl;
	}
}

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

using namespace std;
using namespace __gnu_pbds;

typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false);

    int n, k;
    cin>>n>>k;
    long long Ans = (n/k) + ((n%k) ? 1 : 0);
    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A, B, C, X;
	scanf("%d%d%d%d", &A, &B, &C, &X);
	int i, j, k, count=0;
	for (i = 0;i <= A; i++) {
		for (j = 0; j <= B; j++) {
			for (k = 0; k <= C; k++) {
				if ((500*i + 100*j + 50*k) == X) {
					count++;
				}
				if ((500*i + 100*j + 50*k) > X) {
					break;
				}
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

int main() {
	string s; cin >> s;
	string t = s;
	ll ans = 0;

	for (int i = 0; i < s.size();)
	{
		if (t.size() == 1 && t[0] == s[i]) {
			if (i == s.size() - 1) {
				break;
			}

			ans++;
			t = s.substr(i, 2);
			i += 2;
		}
		else {
			t = s.substr(i, 1);
			ans++;
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N, M;
  cin >> N >> M;
  int *ans;
  ans = new int[N];
  rep(i, N){
    ans[i] = 0;
  }
  int ret = 0;
  rep(i, M){
    int s, c;
    cin >> s >> c;
    if(ans[s-1]!=0&&ans[s-1]!=c||N!=1&&s==1&&c==0) {
      ret = -1;
      break;
    } else {
      ans[s-1] = c;
    }
  }
  if(N!=1&&ret!=-1&&ans[0]==0){
    ans[0] = 1;
  }
  if(ret == -1){
    cout << ret << endl;
  } else {
    rep(i,N){
      ret = ret*10+ans[i];
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second


using namespace std;


void solve(){
    int h, w, n;
    cin >> h >> w >> n;
    swap(w, h);
    map<pair<int, int>, int> k;
    map<int, int> q;
    for(int i = 0; i < n; i++){
        int t, t1;
        cin >> t >> t1;
        k[{t, t1}] = 1;
        if(q[t] == 0){
            q[t] = t1;
        }
        else{
            q[t] = min(t1, q[t]);
        }
    }
    int t = 1;
    if(k[{2, 1}] == 1){
        cout << 1;
        return;
    }
    for(int i = 2; i < w; i++){
        if(k[{i, t + 1}] != 1){
            t++;
        }
       //cout << i << ' ' << t << ' ' <<  q[i + 1] << endl;
        if(q[i + 1] != 0 && t >= q[i + 1]){
            cout << i;
            return;
        }
    }
    cout <<  w;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int test = 1;
    //freopen("output.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //cin >> test;
    while(test--){
        solve();
    }
}


Measured memory_bytes: 34432