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

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 26596
#include <iostream>

using namespace std;

int main() {
    char ch;
    int c[2] = {0, 0};
    while (cin >> ch) {
        c[ch-'0']++;
    }

    cout << 2 * (c[0] < c[1] ? c[0] : c[1]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif

	int N,K;
	cin >> N >> K;
	ll ans = 1;
	for(int i=0;i<N;i++){
		ll a = ans * 2;
		ll b = ans + K;
		ans = min(a,b);
	}

	printf("%ld\n",ans);

	return 0;
}


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

bool linear_search(int A[], int n, int m) {
    int i = 0;
    A[n] = m;
    while(A[i] != m) {
        i++;
    }
    return i != n;
}

int main() {
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int q;
    int count = 0;
    cin >> q;
    int t;
    for (int j = 0; j < q; ++j) {
        cin >> t;
        for (int i = 0; i < n; ++i) {
           if(S[i] == t) {
               count++;
               break;
           }
        }
//        if(linear_search(S, n, t)){
//            count++;
//        }
    }
    cout << count << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    V p(n);rep(i,n)cin>>p[i];
    int cnt=0;
    for(int i=1;i<n-1;i++){
        int a=p[i-1];
        int b=p[i];
        int c=p[i+1];
        if((a<b&&b<c)||(c<b&&b<a))cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m1,m2,d1,d2;
    cin>>m1>>d1>>m2>>d2;
    if(abs(d1-d2)>1){
        cout<<1<<'\n';
    }
    else{
        cout<<0<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
#include<stdio.h> 
int main()
{  int n,c[4]={0},i;
   char s[100001][3],t;
   scanf("%d%c",&n,&t);
   for(i=0;i<n;i++)
   { gets(s[i]);
     if(s[i][0]=='A') c[0]++;
     if(s[i][0]=='W') c[1]++;
     if(s[i][0]=='T') c[2]++;
     if(s[i][0]=='R') c[3]++;
   }
   printf("AC x %d\n",c[0]);
   printf("WA x %d\n",c[1]);
   printf("TLE x %d\n",c[2]);
   printf("RE x %d\n",c[3]);
} 

Measured memory_bytes: 2028
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

a.sort(reverse = True)

po = 0

for i in range(2 * n):
    if i % 2:
        po += a[i]
print(po)



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

int main(){
  int N,K;
  int noreru = 0;
  cin >> N >> K;
  vector<int> nakama(N);
  for(int i = 0; i < N; i++){
    cin >> nakama.at(i);
    if(nakama.at(i) >= K){
      noreru++;
    }
  }
  cout << noreru << endl;
}

Measured memory_bytes: 640
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print (list[K-1])

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    TreeMin down;
    TreeMin right;


    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int q = Integer.parseInt(tokenizer.nextToken());

        down = new TreeMin(n - 2);
        right = new TreeMin(n - 2);


        long res = 0;
        for (int q1 = 0; q1 < q; q1++) {
            tokenizer = new StringTokenizer(f.readLine());
            if (tokenizer.nextToken().charAt(0) == '1') {
                int x = Integer.parseInt(tokenizer.nextToken()) - 2;
                int upTo = down.getMin(x, 0, n - 3, 1);
                res += upTo;
                if (upTo != 0) right.makeMin(x, 0, upTo - 1, 0, n - 3, 1);
            }else {
                int x = Integer.parseInt(tokenizer.nextToken()) - 2;
                int upTo = right.getMin(x, 0, n - 3, 1);
                res += upTo;
                if (upTo != 0) down.makeMin(x, 0, upTo - 1, 0, n - 3, 1);
            }
        }

        out.println((long) (n - 2) * (n - 2) -  res);
        out.close();
    }

    private static class TreeMin {
        int[] tree;
        int n;


        public TreeMin(int n) {
            this.n = n;
            this.tree = new int[4 * n];
            Arrays.fill(tree, n);
        }

        private void makeMin(int min, int from, int to, int a, int b, int node) {
            if (from <= a && b <= to) {
                tree[node] = Math.min(tree[node], min);
                return;
            }


            int mid = (a + b)  / 2;
            if (from <= mid) makeMin(min, from, to, a, mid, node * 2);
            if (to > mid) makeMin(min, from, to, mid + 1, b, node * 2 + 1);
        }

        private int getMin(int index, int a, int b, int node) {
            int min = tree[node];
            if (a == b) return min;

            int mid = (a + b) / 2;
            if (index <= mid) min = Math.min(min, getMin(index, a, mid, node * 2));
            if (index > mid) min = Math.min(min, getMin(index, mid + 1, b, node * 2 + 1));

            return min;
        }
    }
}

Measured memory_bytes: 60976
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

void solve()
{
    string t, s;
    cin >> s >> t;
    ll n=s.size()-t.size()+1;
    ll k=0, mn=t.size()+1;
    for (int i=0; i<n; ++i)
    {
        for (int j=i; j<t.size()+i; j++)
            if (s[j]!=t[j-i])
                k++;

        mn=min(k, mn);
        k=0;
    }
    cout << mn;
}


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

    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
        cout << '\n';
    }

}

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

const int MAX = 2000010;
const int mod = 1000003;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long fac[MAX], finv[MAX], inv[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

long long modpow(long long x, int y){
	if(x % mod == 0) return 0;
	if(y == 0) return 1;
	if(y % 2 == 0){
		return (modpow(x, y/2) * modpow(x, y/2)) % mod;
	}else{
		return (x * modpow(x, y-1) % mod);
	}
}

int main(){
	int Q; cin >> Q;
	pre_comb();
	for(int i=0; i<Q; i++){
		long long x, d, n; cin >> x >> d >> n;
		if(d == 0){
			cout << modpow(x, n) << endl;
			continue;
		}
		if(n >= mod){
			cout << 0 << endl;
			continue;
		}
		long long b = modpow(d, mod-2);
		int v = (x * b) % mod;
		if(v==0){ cout << 0 << endl; continue; }
		cout << ((long long)fac[n] * comb(v+n-1, n) % mod) * modpow(d, n) % mod << endl;
	}
	return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    rep(i,0,1000){
        string tmp;
        if(i/10==0) tmp = "00" +  to_string(i);
        else if(i/100==0) tmp = "0" + to_string(i);
        else tmp = to_string(i);
        int locate=0;
        rep(i,0,n){
            if(tmp[locate] != s[i]) continue;
            locate++;
            if(locate==3){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    if (N % 2 == 0){
        cout << N << endl;
    }else{
        cout << 2 * N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
l=[0]
for i in range(n):
  l.append(2**(i+1)-1)
m=[0]
for i in range(n+1):
  m.append(2**(i+2)-3)
c=0
for i in range(n,-1,-1):
  t=2**(i+1)-1
  if x<t:
    x-=1
  elif x==t:
    c+=l[i]+1
    x=0
  else:
    c+=l[i]+1
    if x==m[i+1]:
      x-=1
    x=x-t
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


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

   int a,b,m;
   cin >> a >> b >> m;
   vector<int> A(a);
   vector<int> B(b);
   rep(i,0,a) cin >> A[i];
   rep(i,0,b) cin >> B[i];
   int minA = *min_element(A.begin(),A.end());
   int minB = *min_element(B.begin(),B.end());
   int ans = minA+minB;
   rep(i,0,m){
     int x,y,c;
     cin >> x >> y >> c; x--; y--;
     ans=min(ans,A[x]+B[y]-c);
   }
   cout << ans << endl;

}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
using namespace std;

const int Max=200;
int top,S[1000];

	bool isEmpty(int top){
		if(top==0)return true;
		return false;
	}
	bool isFull(int top){
		if(top>=Max-1)return true;
		return false;
	}
	void push(int x){
		if(isFull(top))cout<<"エラー";
		top++;
		S[top]=x;
	}
	int pop(){
		if(isEmpty(top))cout<<"エラー";
		top--;
		return S[top+1];
};

int main(){
	int a,b;
	int top=0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}

	printf("%d\n",pop());
		
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

bool check(int head, int N, vector<vector<pair<int,int>>> &list, bool marked[], long long pt[], vector<int> &step){
    if(list[head].empty()){
        if(step.empty()){
            for(int i=0;i<N;i++){
                if(!marked[i] && !list[i].empty()){
                    marked[i]=true;
                    return check(i,N,list,marked,pt,step);
                }
            }
            return true;
        }else{
            int prev=step.back();
            step.pop_back();
            return check(prev,N,list,marked,pt,step);
        }
    }

    pair<int,int> to=list[head].back();
    if(marked[to.first] && pt[head]+to.second!=pt[to.first]) return false;
    if(marked[to.first]){
        list[head].pop_back();
        return check(head,N,list,marked,pt,step);
    }else{
        list[head].pop_back();
        marked[to.first]=true;
        pt[to.first]=pt[head]+to.second;
        step.push_back(head);
        return check(to.first,N,list,marked,pt,step);
    }
}

int main(){
    int N,M;
    vector<vector<pair<int,int>>> list(100000);

    cin >> N >> M;
    for(int i=0;i<M;i++){
        int l,r,d;
        cin >> l >> r >> d;
        list[l].push_back(make_pair(r,d));
        list[r].push_back(make_pair(l,-d));
    }

    bool marked[100000];
    long long pt[100000];
    for(int i=0;i<N;i++){
        marked[i]=false;
        pt[i]=0;
    }

    marked[0]=true;
    vector<int> step;
    bool result=check(0,N,list,marked,pt,step);

    if(result) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 56960
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)


struct Node {
	int value;
	Node *parent;
	Node *left;
	Node *right;
	Node() : parent(NULL), left(NULL), right(NULL) {}
};

void Preorder(Node *node) {
	printf(" %d", node->value);
	if(node->left != NULL) Preorder(node->left);
	if(node->right != NULL) Preorder(node->right);
}
void Inorder(Node *node) {
	if (node->left != NULL) Inorder(node->left);
	printf(" %d", node->value);
	if (node->right != NULL) Inorder(node->right);
}
void Postorder(Node *node) {
	if (node->left != NULL) Postorder(node->left);
	if (node->right != NULL) Postorder(node->right);
	printf(" %d", node->value);
}
Node *Insert(Node *root, Node *z) {
	Node *y = NULL;
	Node *x = root;
	while (x != NULL) {
		y = x;
		if (z->value < x->value) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		root = z;
	}
	else if(z->value < y->value) {
		y->left = z;
	}
	else {
		y->right = z;
	}
	return root;
}
int main(void) {
	int n;
	scanf("%d", &n);
	char line[1024];
	Node *root = NULL;
	for (int i = 0; i < n; ++i) {
		scanf("%s", &line[0]);
		if (strcmp(line, "print") == 0) {
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
		else {
			int k;
			scanf("%d", &k);
			Node *z = new Node();
			z->value = k;
			root = Insert(root, z);
		}
	}
	return 0;
}


Measured memory_bytes: 26028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll k;
    cin >> k;
    ll now = 0;
    vector<bool> used(k+1);
    ll ans = 0;
    
    bool ok = true;
    while (1) {
        now  = now*10 + 7;
        now %= k;
        if (used[now]) {
            ok = false;
            break;
        }
        used[now] = true;
        ans++;
        if (now==0) break;
    }
    if (!ok) ans = -1;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
typedef long long ll;
int s[300000], ans[300000];
int flg[300000];
int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		ans[i] = s[i];
	}
	sort(ans, ans + n);
	fill(flg, flg + n, 0);
	int cnt = 0;
	for(int i = 0; i < n; i++) if(ans[i] != s[i]) flg[i] = 1, cnt++;
	int q;
	cin >> q;
	int mn = INF;
	if(cnt == 0) mn = 0;
	for(int i = 1; i <= q; i++){
		int x, y;
		cin >> x >> y;
		swap(s[x - 1], s[y - 1]);
		if(s[x - 1] == ans[x - 1]){
			if(flg[x - 1]) flg[x - 1] = 0, cnt--;
		} else {
			if(!flg[x - 1]) flg[x - 1] = 1, cnt++;
		}
		if(s[y - 1] == ans[y - 1]){
			if(flg[y - 1]) flg[y - 1] = 0, cnt--;
		} else {
			if(!flg[y - 1]) flg[y - 1] = 1, cnt++;
		}
		if(cnt == 0) mn = min(mn, i);
	}
	if(mn == INF) mn = -1;
	cout << mn << endl;
	return 0;
}


Measured memory_bytes: 6688
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

int bestforDay[100005];

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

    int n;
    cin >> n;

    map<string, int> strs;

    ll pairs = 0;
    for (int i = 0; i < n; i++)
    {
        string in;
        cin >> in;
        sort(in.begin(), in.end());
        auto ret = strs.insert({in, 0});
        if (!ret.second)
        {
            (ret.first->second)++;
            pairs += ret.first->second;
        }
    }
    cout << pairs;
}


Measured memory_bytes: 11264
# ABC114, B - 754

S = list(input())

diff_ls = []
for i in range(len(S)-2):
    num = int(''.join(S[i:i+3]))
    diff = abs(num - 753)

    if diff == 0:
        print(0)
        break
    diff_ls.append(diff)
else:
    print(min(diff_ls))


Measured memory_bytes: 3060
import sys
from fractions import gcd

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]



r, d, x = na()

for i in range(10):
    x = r * x - d
    print(x)


Measured memory_bytes: 5716
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
 
using namespace std;
 
int main() {
  int x, ans;
  cin >> x;
  ans += (x / 500) * 1000;
  ans += (x % 500) - ((x % 500) % 5);
  cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad.State

main = do
    list@[a1,m1,a2,m2,a3,m3] <- map read.words<$>getLine
    if all (== 0) list then return ()
                       else do
                           print $ searchMinCycle [a1,m1] [a2,m2] [a3,m3]
                           main

nextP :: Int -> Int -> Int -> Int
nextP a m x = a*x `mod` m

searchMinCycleP :: [Int] -> Int
searchMinCycleP [a,m] = evalState (loop next 1) 0
    where next = nextP a m

searchMinCycle :: [Int] -> [Int] -> [Int] -> Int
searchMinCycle parX parY parZ= foldl1 lcm [xLoop, yLoop, zLoop]
    where xLoop = searchMinCycleP parX
          yLoop = searchMinCycleP parY
          zLoop = searchMinCycleP parZ

loop :: (Int -> Int) -> Int -> State Int Int
loop f p = do
    let p' = f p
    if p' == 1 then (+1)<$>get
               else modify (+1) >> loop f p'



Measured memory_bytes: 11412
from math import floor

arr = []

def factorization(n):
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    
n = int(input())
if n == 1:
  print(0)
  exit()
  
factorization(n)
ans = 0

for prime,power in arr:
  ans += floor((-1+(1+8*power)**0.5)/2)
  
print(ans)

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

int main() {
  string s;
  cin >> s;
  int ans = 700;
  if (s[0] == 'o') ans += 100;
  if (s[1] == 'o') ans += 100;
  if (s[2] == 'o') ans += 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int x,y,ans=INT_MAX;
int main(){
  cin >> x >> y;
  for (size_t i = 0; i < 4; i++) {
    int a=0 , nx=x , ny=y ;
    if(i == 1 || i == 3){
      a++;
      nx *= -1;
    }
    if(i == 2 || i == 3){
      a++;
      ny *= -1;
    }
    if(!(nx <= ny))continue;
    a += ny-nx; nx += ny-nx;
    if(nx == ny && ans > a && a >= 0)ans = a;
  }
  cout << ans << endl;
}


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


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

  int h,w,k;
  cin >> h >> w >> k;

  vector<string> s(h);
  rep(i,h) cin >> s[i];
  ll ans = 0;
  rep(hi,1<<h)rep(wi,1<<w){
    int tcnt = h*w;
    rep(i,h)rep(j,w){
      if(((1<<i) & hi)>0 || (((1<<j) & wi) )>0 || s[i][j] == '.'){
        tcnt--;
      }
    }
    if(tcnt==k) ans++;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUFSIZ 8

int main (int ac, char **av) {
  char readline[BUFSIZ] = {0};
  int mountains[3] = {0};
  while (fgets(readline, BUFSIZ, stdin) != NULL) {
    int x = atoi(readline);
    if (mountains[0] == 0) {
      mountains[0] = x;
    } else {
      int idx = 0;
      for (idx = 0; idx < 3; idx++) {
	if (mountains[idx] < x) {
	  memmove(mountains+idx+1, mountains+idx, sizeof(int) * (2-idx));
	  mountains[idx] = x;
	  break;
	}
      }
    }
  }
  int i=0;
  for (i = 0; i < 3; i++) {
    fprintf(stdout, "%d\n", mountains[i]);
  }
      

  return 0;
}

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

const int inf=1e9+5;
int main () {
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int &i:v)cin>>i;
    
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n){
            dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
            }
        }
    }
   
      cout<<dp[n-1];
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<pair<int, int> > sayings[n];

  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      sayings[i].emplace_back(x, y);
    }
  }

  int result=0;
  rep(bits, pow(2,n)){
    bool flag=true;
    rep(i,n){
      if( !(bits>>i & 1) ) continue;

      rep(j, sayings[i].size()){
        int target = sayings[i][j].first-1;
        if(sayings[i][j].second != (int)(bits>>target & 1))flag=false;
//cout<<sayings[i][j].second <<' '<< (bits>>target & 1)<<'|'<<(sayings[i][j].second != (int)(bits>>target & 1))<<'|'<<bits<<' '<<target<<' '<<j<<endl;
      }
    }

//cout<<flag<<' '<<bits<<' '<<result<<' '<<__builtin_popcount(bits)<<endl<<endl;

    if(flag)result=max(result,  (int)__builtin_popcount(bits));
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 256
from math import gcd
mod = 10**9+7
n = int(input())
dicn = {}
dicp = {}
dicz = {'a': 0, 'b': 0, 'z': 0}
for i in range(n):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    dicz['z'] += 1
  else:
    g = gcd(a,b)
    a //= g
    b //= g
    if a < 0:
      a *= -1
      b *= -1
    elif a == 0 and b < 0:
      b *= -1
    if a * b > 0:
      if a in dicp:
        if b in dicp[a]:
          dicp[a][b] += 1
        else:
          dicp[a][b] = 1
      else:
        dicp[a] = {b: 1}
    elif a * b < 0:
      if b in dicn:
        if a in dicn[b]:
          dicn[b][a] += 1
        else:
          dicn[b][a] = 1
      else:
        dicn[b] = {a: 1}
    else:
      if a == 0:
        dicz['a'] += 1
      else:
        dicz['b'] += 1

ans = 1

for a in dicp:
  for b in dicp[a]:
    if -a in dicn:
      if b in dicn[-a]:
        ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)
        dicn[-a][b] = 0
      else:
        ans *= pow(2, dicp[a][b], mod)
    else:
      ans *= pow(2, dicp[a][b], mod)
    ans %= mod

for b in dicn:
  for a in dicn[b]:
    ans *= pow(2, dicn[b][a], mod)
    ans %= mod
    
if dicz['a'] > 0 and dicz['b'] > 0:
  ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1
elif dicz['a'] > 0:
  ans *= pow(2,dicz['a'],mod)
elif dicz['b'] > 0:
  ans *= pow(2,dicz['b'],mod)
  
ans += dicz['z']
print((ans-1)%mod)


Measured memory_bytes: 82552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n + 2);
  rep(i,n)cin >> v[i + 1];
  ll sum = 0;
  v[0] = 0;
  v[n + 1] = 0;
  int x = 0;
  rep(i,n + 2){
    sum += abs(v[i] - v[i + 1]);
  }
  sum += abs(x);
  ll ans = 0;
  REP(i,1,n+1){
    ans = sum + abs(v[i - 1] - v[i + 1]) - (abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a= sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 20820
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	vs := make([]float64, n)
	for i := range vs {
		fmt.Scan(&vs[i])
	}
	sort.Float64s(vs)
	r := vs[0]
	for i:=1; i<n; i++ {
		r = (vs[i] + r) / 2
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
N = int(input())
A = [[int(a),"A"] for a in input().split()]
B = [[int(b),"B"] for b in input().split()]
C = [[int(c),"C"] for c in input().split()]

parts = A+B+C
parts.sort(key = lambda x:x[1])
parts.sort(reverse = True,key = lambda x:x[0])

A_pat = [0]  
B_pat = [0]
C_count = 0

for s,t in parts:
    if t=="C":      
        C_count += 1
    elif t=="B":
        B_pat.append(C_count+B_pat[-1])
    elif t=="A":
        A_pat.append(B_pat[-1]+A_pat[-1])
print(A_pat[-1])


Measured memory_bytes: 55748
use proconio::*;

fn calc(a: &[u32], b: &[u32], v: u32) -> usize {
    let mut ans = 0;
    let mut p = b.len();
    for a in a.iter() {
        while p > 0 && *a + b[p - 1] >= v {
            p -= 1;
        }
        ans ^= b.len()- p;
    }
    ans & 1
}

fn run() {
    input! {
        n: usize,
        mut a: [u32; n],
        mut b: [u32; n],
    }
    a.sort();
    b.sort();
    let mut buf = vec![];
    let mut ans = 0;
    for i in (0..29).rev() {
        let mut c = 0;
        for j in 1..=3 {
            c ^= calc(&a, &b, j << i);
        }
        ans |= c << i;
        let mask = (1 << i) - 1;
        for a in [&mut a, &mut b].iter_mut() {
            buf.clear();
            let mut i = a.iter().take_while(|a| **a <= mask).count();
            buf.extend_from_slice(&a[..i]);
            for a in a[i..].iter_mut() {
                *a &= mask;
            }
            let mut j = 0;
            let mut k = 0;
            while i < n && j < buf.len() {
                if a[i] <= buf[j] {
                    a[k] = a[i];
                    i += 1;
                } else {
                    a[k] = buf[j];
                    j += 1;
                }
                k += 1;
            }
            while j < buf.len() {
                a[k] = buf[j];
                j += 1;
                k += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 8260
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

bool mycmp(ii a, ii b) {
	return a.second > b.second;
}

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

	int n, m;
	scanf("%d%d", &n, &m);
	vi a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(all(a));

	vector<ii> op(m);
	for (int i = 0; i < m; i++) scanf("%d%d", &op[i].first, &op[i].second);
	sort(all(op), mycmp);

	vi b(n);
	int last = 0;
	for (auto p : op) {
		while (last < n && p.first > 0) {
			b[last++] = p.second;
			--p.first;
		}
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) ans += max(a[i], b[i]);
	printf("%lld\n", ans);
}


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

inline long long gcd(long long m,long long n){
  return ((m%n==0)? n:gcd(n,m%n));
}

int main()
{
  int N;
  cin>>N;
  vector<long long> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  long long m=vec[0];
  for(int i=1;i<N;i++){
    long long d=gcd(m,vec[i]);
    if(d==1){
      m*=vec[i];
    }
    else{
      m*=vec[i]/d;
    }
  }
  cout<<m;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

long table[200000][3];

int main()
{
    std::string S,T;
    std::cin >> S >> T;
    long A,B;
    std::cin >> A >> B;
    std::string U;
    std::cin >> U;
    if(S==U){
        std::cout << A-1 << " " << B << std::endl;
    }else{
        std::cout << A << " " << B-1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, q;
  scanf("%d%d", &n, &q);
  char s[200001];
  scanf("%s", s);
  char t[200001], d[200001];
  for(int i=0; i<q; i++){
    scanf(" %c %c", &t[i], &d[i]);
  }

  /* 改良 */
  int count=0;
  int count2=0;
  int r=n-1;

  /* 呪文の実行 */
  for(int i=q-1;i>=0;i--){
    if(d[i] == 'R'){
      if (s[count-1] == t[i]) {
        count--;
      }
      if(s[r] == t[i]){
        r--;
      }
    }else if(d[i] == 'L'){
      if(s[r+1] == t[i]) {
        r++;
      }
      if(s[count] == t[i]) {
        count++;
      }
    }
  }

  if(r < 1){
    count2 = 0;
  }else{
    count2 = r-count+1;
  }

  printf("%d\n",count2);
  return 0;
}


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

void f(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i == v.size() - 1)
    cout << v.at(i) << endl;
    else
    cout << v.at(i) << " ";
  }
}

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  if (prev_permutation(v.begin(), v.end()))
  f(v);
  next_permutation(v.begin(), v.end());
  f(v);
  if (next_permutation(v.begin(), v.end()))
  f(v);
}



Measured memory_bytes: 3164
#include<cstdio>
#include<algorithm>
long long a[200005];
long long sum[200005], sumr[200005];
//for the middle

long long min(long long a,long long b){ return a>b?b:a; }

long long getValue(long long x,long long y,long long u,long long v){
    long long b[5];
    b[0] = x, b[1] = y, b[2] = u, b[3] = v;
    std::sort(b,b+4);
    return b[3]-b[0];
}

void upDate(int x,int y,int z,int n,long long &ans){
    if(x>=1 && y>x && z>y && z<n){
        long long cur = getValue(sum[x],sum[y]-sum[x],sum[z]-sum[y],sum[n]-sum[z]);
        ans = min(ans,cur);
    }
}

int main(){
    int n;
    scanf("%d",&n);
    sum[0] = 0;
    for(int i = 1; i <= n; i++){ 
        scanf("%lld",&a[i]);
        sum[i] = sum[i-1]+a[i];
    }
    int p0 = 0, p1 = 0;
    long long ans = 1e18+7;
    for(int i = 1; i <= n; i++){
        long long partL = sum[i], partR = sum[n]-sum[i];
        while(p0+1<i && 2*sum[p0+1]<=partL) p0++;
        while(p1<i+1 || (p1+1<n && 2*(sum[p1+1]-sum[i])<=partR)) p1++;
        //printf("p0 = %d, i = %d, p1 = %d\n",p0,i,p1);
        upDate(p0,i,p1,n,ans);
        upDate(p0,i,p1+1,n,ans);
        upDate(p0+1,i,p1,n,ans);
        upDate(p0+1,i,p1+1,n,ans);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4864
#include<stdio.h>

int main() {
    int H, N;
    scanf("%d %d", &H, &N);
    int A, sum=0;

    for (int i=0; i<N; i++) {
        scanf("%d", &A);
        sum += A;
    }

    if (sum >= H) printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int k;
    cin>> k;
    if(k%2==1){
      cout <<  (k/2)*(k/2+1)<<endl;
    }
    else {
        cout << (k/2)*(k/2)<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
str = gets.chomp
com = gets.to_i
com.times do
  state = gets.split(' ')
  s1 = state[1].delete('?\"').to_i
  s2 = state[2].delete('?\"').to_i
  case state[0]
    when "print"
      puts str[s1..s2]
    when "reverse"
      str[s1..s2] = str[s1..s2].reverse
    when "replace"
      str[s1..s2] = state[3]
  end
end

Measured memory_bytes: 8576
def main():
    _ = int(input())
    a = list(map(int,input().split()))

    sm = sum(a)
    sn = a[0]
    ar = sm - a[0]
    ans = abs(sn - ar)

    for i in range(1,len(a)-1):
        sn += a[i]
        ar -= a[i]
        ans = min(ans,abs(sn-ar))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24832
defmodule Main do
  def main do
    [n,k]=IO.gets("") |> String.trim |> String.split(" ") |> Enum.map(&String.to_integer(&1))
    IO.stream(:stdio, :line) 
    |> Enum.take(2*k)
    |> Enum.map(&String.trim(&1))
    |> Enum.drop_every(2)
    |> Enum.map(&String.split(&1, " "))
    |> Enum.reduce(Enum.map((1..n), fn x-> Integer.to_string(x) end), fn (x,acc)-> acc--x end)
    |> length()
    |> IO.puts()
    
  end
end


Measured memory_bytes: 32028
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll i,j,n,m;
    double r;
    cin>>r;
    cout<<setprecision(15)<<2*r*M_PI;


    return 0;
}



Measured memory_bytes: 3788
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;

struct cell {
	int x, y;
	int deep;
	cell(int x, int y, int deep) : x(x), y(y), deep(deep) {}
};

int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
void solv() {

	int h, w;
	cin >> h >> w;
	string ta[1010];
	for (size_t i = 0; i < h; i++)
	{
		cin >> ta[i];
	}
	queue<cell> q;
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (ta[i][j] == '#') {
				q.push(cell(i, j, 0));
			}
		}
	}

	int res = 0;
	while (!q.empty())
	{
		cell p = q.front();
		q.pop();
		res = max(p.deep, res);
		for (size_t i = 0; i < 4; i++)
		{
			int tx = p.x + dx[i];
			int ty = p.y + dy[i];
			if (tx < 0 || ty < 0 || tx >= h || ty >= w) continue;
			if (ta[tx][ty] == '#') continue;
			ta[tx][ty] = '#';
			q.push(cell(tx, ty, p.deep + 1));
		}
	}

	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 13456
/* Filename: ABC077A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			String row1 = input.next();
			String row2 = input.next();
			
			boolean isSameAfterRotation = true;
			for(int i = 0, j = row2.length() - 1; i < row1.length(); ++i, --j){
				if(row1.charAt(i) != row2.charAt(j)){
					isSameAfterRotation = false;
					break;
				}
			}
			
			if(isSameAfterRotation){
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,eg,x,y,k,hd[MAXN],nx[2*MAXN],ver[2*MAXN],col[2*MAXN];
void add_edge (int x,int y) {
	ver[++eg]=y;
	nx[eg]=hd[x];
	hd[x]=eg;
	return;
}
void dfs (int x,int fa,int cc) {
	int cnt=(x!=1),ncol=1;
	for (int i=hd[x];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		if (ncol==cc) {ncol++;}
		col[i]=col[i^1]=ncol,cnt++;
		dfs(ver[i],x,ncol);
		ncol++;
	}
	k=max(k,cnt);
	return;
}
int main () {
	scanf("%d",&n);
	eg=1;
	for (int i=1;i<=n-1;i++) {
		scanf("%d%d",&x,&y);
		add_edge(x,y),add_edge(y,x);
	}
	dfs(1,0,0);
	printf("%d\n",k);
	for (int i=2;i<=eg;i+=2) {printf("%d\n",col[i]);}
	return 0;
}

Measured memory_bytes: 6528
<?php

fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%d', $k);
fscanf(STDIN, '%d', $x);
fscanf(STDIN, '%d', $y);

$cost = 0;
for ( $i=1; $i<=$n; $i++) {
    if ($i<=$k) {
        $cost += (int)$x;
    } else {
        $cost += (int)$y;
    }
}

echo $cost . "\n";

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    string s;
    cin >> s;
    int ans = 0,cur=0;
    rep(i,s.size()){
        if(s[i]=='R'){
            cur++;
        }
        else{
            cur = 0;
        }
        ans = max(cur,ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();


      outer:
         for (int j = 1; j < 10; j++) {
            for (int i = 1; i < 10; i++) {
               if (n == i*j) {
                  System.out.println("Yes");
                  break outer;
               }
               if(i*j == 81){
                  System.out.println("No");
               } 
            }
         }

   }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
v = sum(b)
for i in range(1,n):
    if a[i] == a[i-1] + 1:
        v = v + c[a[i-1]-1]
print(v)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll N,K,A[200000];
    cin >> N >> K;
    REP(i,N){
        cin >> A[i];
        if(i>=K){
            if(A[i-K]<A[i]){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }
    return 0;  
}


Measured memory_bytes: 5156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  ll n,k,q;
  cin >> n >> k >> q;
  vector<ll> a;
  for(ll i = 0;i < q;i++)
  {
    ll A;
    cin >> A;
    a.push_back(A);
  }

  ll ans[n];
  for(ll i = 0;i < n;i++)
  {
    ans[i] = q;
  }

  for(ll i = 0;i < q;i++)
  {
    ans[a[i]-1] -= 1;
  }
  
  for(ll i = 0;i < n;i++)
  {
    if(ans[i] < k)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 2292
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;string s;
	cin>>n>>s;
	vi co(26);
	rep(i,n)co[s[i]-'a']++;
	int MOD=1000000007;
	int t=1;
	rep(i,26)(t*=co[i]+1)%=MOD;
	cout<<(t+MOD-1)%MOD<<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int A, n;

int main()
{
	int flag = 0;
	scanf("%d %d", &n, &A);
	if(n%500 == 0)
	{
		flag = 1;
	}
	for(int i = 1; i <= A; i++)
	{
		if((n - i)%500 == 0)
		{
			flag = 1;
			break;
		}
	}
	if(flag == 0) printf("No\n");
	if(flag == 1) printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MOD=1000000007;

int n;
int a[30][30];
ll dp[30][1<<21]; // man, woman

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
	for(int i=0;i<(1<<n);i++) dp[0][i]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<(1<<n);j++)
	{
		if(__builtin_popcount(j)!=i) continue;
		for(int k=0;k<n;k++)
		{
			if(!(j&(1<<k))) continue;
			if(!a[i][k+1]) continue;
			dp[i][j]=(dp[i][j]+dp[i-1][j^(1<<k)])%MOD;
		}
	}
	printf("%lld\n",dp[n][(1<<n)-1]);
	return 0;
}



Measured memory_bytes: 327936
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
const int MAX=1001001001;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
  cin>>S;
	ll n=S.size();
	vector<ll>s(n);
	rep(i,n){
		s[i]=S[i]-'0';
	}
	//あまりの数
	vector<ll>ten(n+1);
	ten[0]=1;
	rep(i,n){
		ten[i+1]=ten[i]*10;
		ten[i+1]%=2019;
	}
	vector<ll> p(n+1,0);
	map<ll,ll>mp;
	p[n-1]=s[n-1]%2019;
	mp[p[n-1]]++;

	//cout<<p[n-1]<<endl;
	rep(i,n-1){
		p[n-2-i]=s[n-2-i];

		//	cout<<j<<endl;
			p[n-2-i]*=ten[i+1];
			p[n-2-i]%=2019;


	//	p[n-2-i]+s[n-1-i]);
	p[n-2-i]+=p[n-1-i];
		p[n-2-i]=p[n-2-i]%2019;
	//	cout<<p[n-2-i]<<endl;

		mp[p[n-2-i]]++;
	}
	mp[0]++;
	ll ans=0;
//cout<<mp[44]<<'m'<<endl;
	rep(i,2019){
		ll temp=mp[i];
		ans+=temp*(temp-1)/2;
	//	cout<<temp<<endl;
	}

	cout<<ans;


}


Measured memory_bytes: 8292