akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
using namespace std;

#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

const int maxn=2e5+100;
int N;
char s[maxn];
int match[maxn];
vector <int> pos[30];
int tr[maxn];

void add(int x,int v,int len,int a[])
{
    for (int i=x; i<=len; i+=(i&(-i))) a[i]+=v;
}

int que(int x,int a[])
{
    int ret=0;
    for (int i=x; i; i-=(i&(-i))) ret+=a[i];
    return ret;
}

long long solve()
{
    static int p[maxn];
    static int num[maxn];
    long long ans=0;
    int tot=0;
    int m=0;
    For(i,1,N)
    {
        if (match[i]>i)
        {
            num[i]=num[match[i]]=++tot;
            ans+=i-tot;
        }
        else if (match[i]<i)
        {
            p[++m]=num[i];
        }
        else
        {
            p[++m]=(N>>1)+1;
        }
    }
    memset(tr,0,sizeof(tr[0])*(m+2));
    For(i,1,m)
    {
        ans+=que(p[i],tr);
        add(p[i],1,m,tr);
    }
    /*long long sum=0;
    For(i,1,m)
    {
        int goal=m-p[i]+1;
        sum+=abs(goal-i);
    }
    ans+=(sum>>1);*/
    return ans;
}

int main()
{
    for (; scanf("%s",s+1)!=EOF; )
    {
        N=strlen(s+1);
        For(i,0,25) pos[i].clear();
        For(i,1,N) pos[s[i]-'a'].push_back(i);
        int odd=0;
        For(i,0,25)
        {
            if (((int)pos[i].size())&1) ++odd;
            int j=0,k=pos[i].size()-1;
            for (; j<=k; ++j,--k) match[pos[i][j]]=pos[i][k],match[pos[i][k]]=pos[i][j];
        }
        if (odd>1)
        {
            printf("-1\n");
        }
        else
        {
            printf("%lld\n",solve());
        }
    }
    return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long int llint;
const int SIZE = 100000;
llint dp[51][2501][51] = {};

int main(void){
  int n, a;
  std::cin >> n >> a;
  int x[n+1];
  int val_max = 0;
  for(int i=1; i<=n; i++){
    std::cin >> x[i];
    val_max = std::max(val_max, x[i]);
  }

  for(int i=0; i<n; i++){
    dp[i][0][0] = 1;
  }
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n*val_max; j++){
      for(int k=1; k<=n; k++){
        if(j-x[i] >= 0) dp[i][j][k] += dp[i-1][j-x[i]][k-1];
        dp[i][j][k] += dp[i-1][j][k];
      }
    }
  }

  llint all = 0;
    for(int j=1; j<=n; j++){
      all += dp[n][j*a][j];
    }
  std::cout << all << std::endl;
  return 0;
}

Measured memory_bytes: 50048
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+200;
int a[N];
bool judge(int x)
{
	while(x)
	{
		if(a[x%10]==1)return 0;
		x/=10;
	}
	return 1;
}
int main()
{
	int n;
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
		for(int i=1;i<=k;++i)
		{
			int x;
			cin>>x;
			a[x]=1;
		}
		while(1)
		{
			if(judge(n))
			{
				cout<<n<<endl;
				break;
			}
			else n++;
		}
	}
	return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())

mod = 10**9 + 7

u = [0]*(n+1)
F = [0]*(n+1)
for i in range(m):
	x=int(input())
	u[x]=1

F[0]=1
for i in range(1,n+1):
	F[i]=F[i-1]+F[i-2]
	if u[i]==1: F[i]=0

print(F[n]%mod)

Measured memory_bytes: 460788
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
  int n;
  scanf("%d\n", &n);
  vector<long> a;
  for(int i=0; i<n; ++i) {
    long x;
    scanf("%ld", &x);
    a.push_back(x);
  }
  vector<long> sa(n);
  copy(begin(a), end(a), begin(sa));
  sort(begin(sa), end(sa));
  auto m1 = sa[n/2-1];
  auto m2 = sa[n/2];
  for(auto x : a) {
    long y;
    if(x <= m1) y = m2;
    else y = m1;
    printf("%ld\n", y);
  }
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int h,w;
    cin >> h >> w;
    int a[h][w];
    rep(h) repp(j, w){
        cin >> a[i][j];
    }

    int n = 0;
    int ans[500*500+10][4];
    rep(h){
        repp(j, w){
            if(i == h-1 && j == w-1) break;
            if(a[i][j] % 2 == 0) continue;
            a[i][j]--;
            ans[n][0] = i+1;
            ans[n][1] = j+1;
            if(j == w-1){
                a[i+1][j]++;
                ans[n][2] = i+2;
                ans[n][3] = j+1;
            }else{
                a[i][j+1]++;
                ans[n][2] = i+1;
                ans[n][3] = j+2;
            }
            n++;
        }
    }

    cout << n << endl;
    rep(n){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    }
    return 0;
}


Measured memory_bytes: 6912
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    map<ll, int> count;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        count[A]++;
    }
    int sum = 0;
    for(auto p : count){
        if(p.se % 2 == 1){
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 6528
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        map<int, int> mp;
        for(int i = 1; i <= 100; i++){
        	for(int j = 1; j <= 100; j++){
        		for(int k = 1; k <= 100; k++){
        			int x = i * i + j*j + k*k + i*j + i*k + j*k;
        			mp[x]++;
        		}
        	}
        }
        int n; cin >> n;
        for(int i = 1; i<= n; i++)
        	cout << mp[i] << '\n';
    	return 0;
}

Measured memory_bytes: 6032
X, Y = [int(_) for _ in input().split()]
mod = 10**9 + 7

#a(1, 2) + b(2, 1) = (X, Y)
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if (2 * Y - X) % 3 == (2 * X - Y) % 3 == 0 and a * b >= 0:
    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = i * f[i - 1] % mod
    fi = [1] * (a + b + 1)
    fi[-1] = pow(f[-1], mod - 2, mod)
    for i in range(a + b - 1, 1, -1):
        fi[i] = (i + 1) * fi[i + 1] % mod

    def comb(x, y):
        return (f[x] * fi[y] * fi[x - y]) % mod

    print(comb(a + b, b))
    exit()
print(0)


Measured memory_bytes: 55796
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());

            int xx = x;
            int result = 0;
            bool found = false;

            while (!found)
            {
                int check = 0;
                for(int i = 1; i < xx; i++)
                {
                    if ( xx % i == 0)
                    {
                        check++;
                    }
                }
                
                if(check == 1)
                {
                    found = true;
                    result = xx;
                }
                else
                {
                    xx++;
                }

            }

            Console.WriteLine(result);

        }
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++){
        cin >> s[i];
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++){
        cin >> t[i];
    }
    int score=0;
    int ans=0;
    for (int i = 0; i < N; i++){
        score=0;
        for (int k = 0; k < N; k++){
            if(s[i]==s[k])score++;
        }
        for (int j = 0; j < M; j++){
            if(s[i]==t[j])score--;
        }
        if(score>ans)ans=score;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def dfs(adj, s, d, f, now):
    now += 1
    d[s] = now
    for t in adj[s]:
        if t != s and f[t] < 0 and d[t] < 0:
            d, f, now = dfs(adj, t, d, f, now)
    now += 1
    f[s] = now
    return d, f, now


n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n):
    s = [int(x) for x in input().split()]
    u = s[0]
    for v in s[2:]:
        adj[u - 1].append(v - 1)
    adj[u - 1].sort()

d = [-1 for _ in range(n)]
f = [-1 for _ in range(n)]
now = 0
for s in range(n):
    if f[s] < 0:
        d, f, now = dfs(adj, s, d, f, now)

for i in range(n):
    print(str(i + 1) + " " + str(d[i]) + " " + str(f[i]))


Measured memory_bytes: 5636
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define debug(x) cerr << #x << ": " << x << endl;
using namespace std;

int main(){
  int x[3];
  cin >> x[0] >> x[1] >> x[2];

  int sum;
  int sum1 = abs(x[0]-x[1]);
  int sum2 = abs(x[1]-x[2]);
  int sum3 = abs(x[2]-x[0]);
  sum = sum1 + sum2 + sum3 - max({sum1,sum2,sum3});
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007
const int N = 3e5+5;

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
const double pi=acos(-1.0);

typedef pair<int, int> PII;

typedef vector<int> VI;

typedef vector<string> VS;

typedef vector<PII> VII;

typedef vector<VI> VVI;

typedef map<int,int> MPII;

typedef set<int> SETI;

typedef multiset<int> MSETI;

typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
using vl = vector<ll>;

bool isPowerOfTwo (int x)
{
  /* First x in the below expression is
    for the case when x is 0 */
  return x && (!(x&(x-1)));
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

long long phi[max1], result[max1],F[max1];
// Precomputation of phi[] numbers. Refer below link
// for details : https://goo.gl/LUqdtY
void computeTotient()
{
    // Refer https://goo.gl/LUqdtY
    phi[1] = 1;
    for (int i=2; i<max1; i++)
    {
        if (!phi[i])
        {
            phi[i] = i-1;
            for (int j = (i<<1); j<max1; j+=i)
            {
                if (!phi[j])
                    phi[j] = j;

                phi[j] = (phi[j]/i)*(i-1);
            }
        }
    }
    for(int i=1;i<=100000;i++)
{
	for(int j=i;j<=100000;j+=i)
	{  int p=j/i;
	F[j]+=(i*phi[p])%mod;
         F[j]%=mod;

          }
}
}
int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}

int main() {
    fast();
int n,x;
cin>>x>>n;
unordered_map<int,int> m;
int a;
FOR(i,n){
cin>>a;
m[a]++;
}
int i=0;
while(1){
    if(m.find(x-i)==m.end()){
    out(x-i);return 0;}

    if(m.find(x+i)==m.end()){
    out(x+i);return 0;}
    i++;
}
}


Measured memory_bytes: 3656
private class ModInt(x: Long) {

    companion object {
        const val MOD = 1e9.toLong() + 7
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

private fun fact(n: ModInt): ModInt {
    return (2..n.x).fold(ModInt(1L)) { acc, l -> acc * ModInt(l) }
}

private fun comb(n: ModInt, k: ModInt): ModInt {
    return fact(n) / fact(k) / fact(n - k)
}

fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(' ').map { it.toInt() }

    if ((x + y) % 3 != 0) {
        println(0)
        return
    }

    val m = (2 * x - y) / 3
    val n = x - 2 * m

    if (m < 0 || n < 0) {
        println(0)
        return
    }

    val mn = ModInt(n.toLong())
    val mm = ModInt(m.toLong())

    println(comb(mn + mm, mn))
}


Measured memory_bytes: 48616
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    S = input()
    height = 0
    deepest = 0
    for c in S:
        if c == '(':
            height += 1
        else:
            height -= 1
        deepest = min(deepest, height)
    ans = '(' * (-deepest) + S + ')' * (height - deepest)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 64920
n = int(input())
i = 1
divisor = n ** 0.5
min_value = 10 ** 10 + 1
while i < divisor + 1:
    if n % i == 0:
        min_value = min(min_value,max(len(str(i)),len(str(n // i))))
    i += 1
print(min_value)

Measured memory_bytes: 38896
package main

import (
   "fmt"
)

func solution(n, m int, s, t []string) int {
   memo := make(map[string]int)

   for _, v := range s {
        memo[v]++
   }

   for _, v := range t {
        memo[v]--
   }

   out := -1 << 31
   for _, v := range memo {
        out = max(out, v)
   }
   if out < 0 {
        return 0
   }
   return out
}

func max(x, y int) int {
   if x > y {
        return x
   }
   return y
}
func main() {
   var n int
   fmt.Scan(&n)
   s := make([]string, n)
   for i := range s {
        fmt.Scan(&s[i])
   }
   var m int
   fmt.Scan(&m)
   t := make([]string, m)
   for i := range t {
        fmt.Scan(&t[i])
   }
   fmt.Println(solution(n, m, s, t))
}

Measured memory_bytes: 1840
#include <iostream>
#include <math.h>
using namespace std;
const int N = 100000;

bool flag = true;
int n, t[N+1], x[N+1], y[N+1];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i+1] >> x[i+1] >> y[i+1];
	}

	for (int i = 0; i < n; i++) {
		int num = (t[i + 1] - t[i]) - (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]));
		if (num % 2 == 1 || num < 0) {
			flag = false;
		}
	}

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

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

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

	ll tmp = n;
	string cc = "";
	
	while( tmp ) {
		cc += (char)(((tmp - 1LL) % 26) + 'a');
		tmp = (tmp - 1LL) / 26;
	}
	
	reverse(cc.begin(), cc.end());
	
	cout << cc << endl;
	
	return 0;
}


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

int main(){
    long long n,ans;
    cin >> n;
    long long a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==1){
        ans=b[(n+1)/2-1]-a[(n+1)/2-1]+1;
        cout << ans << endl;
    }
    else{
        ans=b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 6784
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
inline ll toInt(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }


#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[3] = { -1, -1, 0 }, dy[3] = { -1, 0, -1};
const int mod = 1000000007;
const int INF = 1e9;

int n, m, a;
const int M = 1010;
tuple<int, int, int> l[M];

int main()
{
	while (cin >> n >> m >> a && n && m && a){
		
		rep(i, m){
			int h, p, q;
			cin >> h >> p >> q;
			l[i] = tuple<int, int, int>(h, p, q);
		}
		sort(l, l + m, greater<tuple<int, int, int>>());

		int t = 0;
		for(int i = 1001;i >= 0;i--){
			while (1){
				int j = get<0>(l[t]);
				if (j == i){
					int r0 = get<1>(l[t]),
						r1 = get<2>(l[t]);
					if (a == r0)a = r1;else
					if (a == r1)a = r0;
					t++;
				}
				else break;
			}
		}

		cout << a << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define PB push_back
#define ALL(_v) (_v).begin(), (_v).end()
#define SZ size()
#define SHOW(_v) cout << (_v) << endl
#define GET(_v) cin >> (_v)
#define MOD 1000000007
typedef long long LL;

using namespace std;

LL xyz(LL a, LL b)
{
    LL ans = 1;
    LL c = a;
    for(int i = 0; i < 60; i++) {
        if(b & (1LL << i)) {
            ans *= c;
        }
        c *= c;
    }
    
    return ans;
}


int main()
{
    int n, p;
    cin >> n >> p;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int gusu = 0;
    int kisu = 0;
    for(int i = 0; i < n; i++) {
        if(v[i] % 2 == 0) {
            gusu++;
        }
        else {
            kisu++;
        }
    }
    
    if(kisu == 0) {
        if(p == 0) {
            cout << xyz(2, n) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    else {
        cout << xyz(2, n - 1) << endl;
    }
    
    return 0;
}



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

using namespace std;

int main(){
  int N,A,B;
  
  cin >> N >> A >> B;
  
  int total=0, sum, tmp;
  
  for (int i = 1; i <= N; i++){
    tmp = i;
    sum = 0;
    while (tmp > 0){ 
      sum += tmp % 10;
      tmp /= 10;
    }
    if (A <= sum && sum <= B)
      total += i;
  }  
  
  cout << total << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;

string s1,s2;
int a,b;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>a>>b;
    if(a==b){
        for(int i=0;i<a;i++){
            cout<<a;
        }
    }
    else{
        for(int i=0;i<max(a,b);i++){
            cout<<min(a,b);
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=1005,MAXM=200005;

int N,M;
vector<int> adj[MAXN];
int E[MAXM][2];

int p[MAXN][MAXN],q[MAXN][MAXN];
bool vis[MAXN];

void mark(int s,int u,int id,int mk[])
{
	if(u==s||vis[u])return;
	vis[u]=true;
	mk[u]=id;
	for(int i=0;i<(int)adj[u].size();i++)
		mark(s,adj[u][i],id,mk);
}

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1,a,b;i<=M;i++)
	{
		scanf("%d%d",&a,&b);
		E[i][0]=a;E[i][1]=b;
		adj[a].push_back(b);
	}
	
	for(int i=1;i<=N;i++)
	{
		memset(vis,0,sizeof vis);
		int id=0;
		for(int j=0;j<(int)adj[i].size();j++)
			mark(i,adj[i][j],++id,p[i]);
		memset(vis,0,sizeof vis);
		reverse(adj[i].begin(),adj[i].end());
		id=adj[i].size();
		for(int j=0;j<(int)adj[i].size();j++)
			mark(i,adj[i][j],id--,q[i]);
	}
	
	for(int i=1;i<=M;i++)
		if((p[E[i][1]][E[i][0]]>0)==(p[E[i][0]][E[i][1]]!=q[E[i][0]][E[i][1]]))
			puts("same");
		else
			puts("diff");
	
	return 0;
}


Measured memory_bytes: 12288
new=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
print(*[new[i] for i in range(int(input()))])

Measured memory_bytes: 38256
<?php
fscanf(STDIN, "%s", $s);

if ($s === "zyxwvutsrqponmlkjihgfedcba") {
	echo "-1\n";
	return;
}

$min = "";
$mojis = [
	"a",
	"b",
	"c",
	"d",
	"e",
	"f",
	"g",
	"h",
	"i",
	"j",
	"k",
	"l",
	"m",
	"n",
	"o",
	"p",
	"q",
	"r",
	"s",
	"t",
	"u",
	"v",
	"w",
	"x",
	"y",
	"z",
];
foreach ($mojis as $moji) {
	$search = strpos($s, $moji);
	if ($search !== false) {
		continue;
	}
	$min = $moji;
	break;
}
if ($min !== "") {
	echo $s , $min, "\n";
	return;
}
$memo = [];
$memstr = $s;
for ($i = 0; $i < 26; $i++) {
	$str = substr($memstr, 0, strlen($memstr) - 1);
	$memo[] = $memstr[strlen($memstr) - 1];
	sort($memo);
	foreach ($memo as $m) {
		$res = $str . $m;
		if (strnatcmp($res, $s) > 0) {
			break 2;
		}
	}
	$memstr = $str;
}

echo $res, "\n";

Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
namespace{
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
static const int INF=1<<24;
vvint vv;

int flow(int n,int a,int b,int c){
	int ret=0;
	while(1){
		queue<int> q;
		q.push(a);
		vint used(n,-1);
		used[a]=a;
		while(!q.empty()){
			int t=q.front();
			q.pop();
			rep(i,n){
				if(used[i]<0&&vv[t][i]>0){
					used[i]=t;
					q.push(i);
				}
			}
			if(used[b]>=0) break;
		}
		if(used[b]<0) return ret;
		for(int i=b;i!=used[i];i=used[i]){
			--vv[used[i]][i];
			++vv[i][used[i]];
		}
		ret++;
		if(c) return ret;
	}
	return ret;
}
void mainmain(){
	int n,e,q;
	while(cin>>n>>e>>q){
		vint v(n,INF);
		initvv(vv,n,n,0);
		rep(i,e){
			int a,b;
			cin>>a>>b;
			a--;
			b--;
			vv[a][b]=1;
			vv[b][a]=1;
		}
		int ans=flow(n,0,n-1,0);
		rep(i,q){
			int r,a,b;
			cin>>r>>a>>b;
			a--;
			b--;
			if(r==2){
				rep(i,2){
					if(vv[b][a]==2){
						vv[b][a]=0;
						if(flow(n,a,b,1)) continue;
						ans--;
						flow(n,n-1,b,1);
						flow(n,a,0,1);
					}
					swap(a,b);
				}
				vv[a][b]=0;
				vv[b][a]=0;
			}
			else{
				vv[a][b]=1;
				vv[b][a]=1;
				ans+=flow(n,0,n-1,1);
			}
			cout<<ans<<endl;
		}
	}
}
}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    string S;
    cin >> S;
    int m = int(S.length());
    int ans = 0;
    reps(i,1,m){
        if(S[i] != S[i-1]) ans++;
    }
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define lower_bound lb
#define upper_bound ub

int main()
{
    int D; cin >> D;
    int C[27]; FOR(i,1,26) cin >> C[i];
    int S[D+1][27];
    FOR(i,1,D){
        FOR(j,1,26) cin >> S[i][j];
    }
    int T[D+1][1000]; int last[27]; ms(last, 0,sizeof(last));
    FOR(i,1,D){
        int max_index = 1; int maxi = S[i][1] + C[i] * (i - last[1]);
        FOR(j,2,26){
            ll s = S[i][j] + C[j] * (i - last[j]);
            if (maxi < s){
                maxi = s;
                max_index = j;
                
            }
        }
        last[max_index] = i;
        T[i][0] = max_index;
    }
    ll sat = 0; int d = 1; int q = T[1][0];
    int maxim = 1; ll max_sat = -10000000;
    FOR(_,1,10000){
        FOR(i,1,D) T[i][_] = T[i][_-1];
        T[d][_] = q;
        d = rand() % 365 + 1; q = rand() % 26 + 1;
        ms(last,0,sizeof(last));
        sat = 0;
        FOR(i,1,D){
            last[T[i][_]] = i;
            sat += S[i][T[i][_]];
            FOR(j,1,26) sat -= C[j] * (i - last[j]);
        }
        if (sat > max_sat){
            max_sat = sat;  maxim = _;
        }
    }
    FOR(i,1,D){
        cout << T[i][maxim] << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 5100
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int mod = 1e9+7;

int32_t main(){

    string a, b;    cin >> a >> b;

    if(a == b){
        cout << "EQUAL";
    }else{

        if(a.size() == b.size()){
            if(a > b)
                cout << "GREATER";
            else
                cout << "LESS";
        }else if(a.size() > b.size()){
            cout << "GREATER";
        }else {
            cout << "LESS";
        }

    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	cout << (n - 1) * n / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string kragr(int g){
  string st;
  st = g;
  return st;
}
int main(void){
  int n,s;
  cin >> n;
  int h[n + 1],m[n + 1];
  for(int i = 0; n > i; i++){
    cin >> h[i] >> m[i];
  }
  cin >> s;
  int h_2[s + 1], m_2[s + 1];
  for(int i = 0; s > i; i++){
    cin >> h_2[i] >> m_2[i];
  }
  int n_2 = 0;
  int s_2 = 0;
  while(n > n_2 && s > s_2){
    if((h_2[s_2] * 100 + m_2[s_2]) > (h[n_2] * 100 + m[n_2])){
      cout << h[n_2] << ":";
      if(m[n_2] < 10){
        cout << "0";
      }
      cout << m[n_2];
      n_2++;
    } else if((h_2[s_2] * 100 + m_2[s_2]) < (h[n_2] * 100 + m[n_2])){
      cout << h_2[s_2] << ":";
      if(m_2[s_2] < 10){
        cout << "0";
      }
      cout << m_2[s_2];
      s_2++;
    } else {
      cout << h[n_2] << ":";
      if(m[n_2] < 10){
        cout << "0";
      }
      cout << m[n_2];
      n_2++;
      s_2++;
    }
    if(n > n_2 && s > s_2){
      cout << " ";
    }
  }
  if(n > n_2){
    for(; n > n_2; n_2++){
      cout << " " << h[n_2] << ":";
      if(m[n_2] < 10){
        cout << "0";
      }
      cout << m[n_2];
    }
  }
  if(s > s_2){
    for(; s > s_2; s_2++){
      cout << " " << h_2[s_2] << ":";
      if(m_2[s_2] < 10){
        cout << "0";
      }
      cout << m_2[s_2];
    }
  }
  cout << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> vc1(N);
    for( auto& x : vc1 ){
        cin >> x;
    }
    
    int Q;
    cin >> Q;
    
    vector<int> vc2(Q);
    for( auto& x : vc2 ){
        cin >> x;
    }
    int count{};
    for( auto&& x : vc2 ){
        for( auto&& y : vc1 ){
            if( x == y ){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3180
N = int(input())
A = list(map(int, input().split()))

count1 = 0
now = A[0]
if now <= 0:
  count1 += (1-A[0])
  now = 1
for i in range(1, N):
  if i%2 == 0:
    if now+A[i] <= 0:
      count1 += 1-(now+A[i])
      now = 1
    else:
      now += A[i]
  else:
    if now+A[i] >= 0:
      count1 += 1+(now+A[i])
      now = -1
    else:
      now += A[i]
      
count2 = 0
now = A[0]
if now >= 0:
  count2 += (1+A[0])
  now = -1
for i in range(1, N):
  if i%2 == 1:
    if now+A[i] <= 0:
      count2 += 1-(now+A[i])
      now = 1
    else:
      now += A[i]
  else:
    if now+A[i] >= 0:
      count2 += 1+(now+A[i])
      now = -1
    else:
      now += A[i]
      
print(min(count1, count2))

Measured memory_bytes: 14332
# -*-coding: utf-8 -*-
def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    ans = 0
    for i in range(N):
        ans += a[2 * i + 1]
    print(ans)
if __name__ == '__main__':
    main()

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

int main()
{
  int N, X, L[100], ans = 1, d = 0;

  cin >> N >> X;
  for(int i = 0; i < N; i++)
    cin >> L[i];
  
  for(int i = 0; i < N; i++){
    d = d + L[i];
    if(d <= X)
      ans++;
    else
      break;
  }

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


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let (n, start) = read!(usize, i32);
    let x: Vec<i32> = read![[i32]];

    let x = x
        .into_iter()
        .map(|y| match y - start {
            t if t >= 0 => t as u64,
            t => (-1 * t) as u64,
        })
        .collect::<Vec<_>>();

    let mut ans = x[0];
    for xx in x {
        ans = gcd(ans, xx);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[4];
	for(int i=0;i<4;++i)
		scanf("%d",&a[i]);
	sort(a,a+4);
	if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b emplace_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e7;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={2,-1,2,1};
const ll ty[4]={-1,2,1,2};
const char rev_to[4]={'E','W','N','S'};
const int N=2*1e5+1;
ll dp[N];
bool used[N];
vector<ll>g[N];
void dfs(ll v,ll p){
    dp[v]=1;
    for(auto u : g[v]){
        if(u==p) continue;
        dfs(u,v);
        dp[v]+=dp[u];
    }
}
signed main(){
    ll n;
    cin>>n;
    ll v;
    for(ll i=1;i<n;i++){
        cin>>v;
        --v;
        g[v].p_b(i);
    }
//    for(ll i=0;i<n;i++){
//        if(!used[i]){
//            dfs(i,-1);
//        }
//    }
    for(ll i=0;i<n;i++){
        cout<<sz(g[i])<<endl;
    }
    return 0;
}
/*

    если WA , то чекер говно, поэтому почекай l8 строчку

*/


Measured memory_bytes: 14524
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	bool P = false;

	if (A == B && A != C) P = true;
	else if (B == C && B != A) P = true;
	else if (A == C && B != A) P = true;

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

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

int n;
long long fp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				fp += __gcd(i, (int)__gcd(j, k));
			}
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 500;

char T[maxN][maxN];
int vis[maxN], dist[maxN], ctr;
vector <int> G[maxN];

void conn(int a, int b)
{	G[a].pb(b); G[b].pb(a);	}

queue <int> Q;

void ins(int v)
{
	vis[v] = ctr;
	Q.push(v);
}

int bfs(int sr)
{
	++ctr;
	ins(sr);
	dist[sr] = 0;
	int ret = 0;
	
	while (!Q.empty())
	{
		int v = Q.front();
		Q.pop();
		for (int u : G[v]) if (vis[u] != ctr)
		{
			ins(u);
			dist[u] = dist[v] + 1;
			ret = max(ret, dist[u]);
		}
	}
	
	return ret;
}

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	FOR(i, 0, n)
		scanf ("%s", &T[i][0]), T[i][m] = '#';
	FOR(i, 0, m+1)
		T[n][i] = '#';
		
	FOR(i, 0, n) FOR(j, 0, m) if (T[i][j] == '.')
	{
		int v = i*m + j;
		if (T[i+1][j] == '.')
			conn(v, v+m);
		if (T[i][j+1] == '.')
			conn(v, v+1);
	}
	
	int res = 0;
	
	FOR(i, 0, n) FOR(j, 0, m)
		if (T[i][j] == '.')
			res = max(res, bfs(i*m + j));
	printf("%d\n", res);
}

int main()
{
	int t;
	t = 1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323



void solve()
{
      ll n, m;
      cin>>n>>m;
      ll k[m+1], p[m+1];
      ll s[15][15];
      memset(s, 0, sizeof s);
      rep(i,1,m+1)
      {
             cin>>k[i];
             rep(j,1,k[i]+1)
                     cin>>s[i][j];
      }
      rep(i,1,m+1) cin>>p[i];
      ll lim = (1 << n);
      ll ans=0;
      for(ll mask=0; mask < lim; mask++)
      {
             bool ok=1;
             ll cnt=0;
             for(ll i=1; i<=m; i++)
             {
                    cnt=0;
                    ll sws = k[i];
                    for(ll j=1; j<=sws; j++)
                    {
                           ll cur = s[i][j];
                           cur--;
                           if((mask >> cur) & 1) cnt++;
                    }
                    if(cnt%2 != p[i]) ok=0;
             }
             if(ok) ans++;
      }
      cout<<ans<<endl;

}

int main()
{
       speed_up;
       //pre();
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
h, w = [int(x) for x in input().split()]
A = []
# 列削除用フラグ初期化 1で削除
rm_pos = [1]*w

# 白マスのみの行はリスト追加しない
for i in range(h):
    a = input()
    if a != '.' * w:
        A += [list(a)]

# 白マスのみの列 検索、. が含まれていない場合は 削除フラグを0に
for j in range(w):
    for i in range(len(A)):
        if A[i][j] != '.':
            rm_pos[j] = 0 
            break

#　後ろ側から  列削除フラグが 1 の列を削除
for j in range(w)[::-1]:
    if rm_pos[j] == 1:
        for i in range(len(A)):
            del A[i][j]

# 回答出力
for i in range(len(A)):
    print(''.join(A[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    long long int n,k;

    cin>>n>>k;

    cout<<n-k+1<<endl;
}


Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<char>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    l(i,0,n)
    {
        cin>>a;
        v.pb(a);
    }
    l(i,1,n-1)
    {
        if((v[i]>v[i+1]&&v[i]<v[i-1])||(v[i]>v[i-1]&&v[i]<v[i+1]))

        {
          d++;
        }


    }
    cout<<d<<endl;
}


Measured memory_bytes: 3652