akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb      push_back
#define all(v)  v.begin(),v.end()
#define see(x)  cout<<#x<<" : "<<(x)<<endl;
#define ya      cout<<"YES"<<endl;
#define no      cout<<"NO"<<endl;
#define ff      first
#define sc      second
typedef long long ll;
typedef pair<ll,ll> pii;

int main()
{

    ll x,k,d,i,j,ans=0;

    scanf("%lld %lld %lld",&x,&k,&d);
    x=abs(x);
    if (x/d > k)
    {
        cout<<x-k*d<<endl;
    }
    else
    {
        j = x/d;
        if ( (k-j) & 1 ) cout<< abs(x - j*d - d)<<endl;
        else cout<< abs(x - j*d)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

  int l,r,d; cin>>l>>r>>d;
  int c=0;
  REP(i,l,r+1){if(i%d==0)c++;}
  
  cout<<c<<endl;
  
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005, M = 100005;
const long long inf = 1000000000000000ll;
template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} graph[M << 1];
int n, m, head[N], id[N], fa[N], cnt = 0;
long long a[N], b[N], f[N], g[N];
pair<int, int> vec[N];

void addedge (int u, int v) {
	edge e = {v, head[u]};
	graph[head[u] = cnt++] = e;
}

int findroot (int x) {
	return fa[x] == x ? x : fa[x] = findroot(fa[x]);
}


int main () {
	read(n), read(m);
	for (int i = 1; i <= n; i++) fa[i] = i, head[i] = -1;
	for (int i = 1; i <= n; i++) {
		read(a[i]), read(b[i]);
		a[i] = max(a[i] - b[i], 0ll);
	}
	for (int i = 1; i <= m; i++) {
		int u, v;
		read(u), read(v);
		addedge(u, v);
		addedge(v, u);
	}

	for (int i = 1; i <= n; i++) vec[i] = make_pair(a[i], i);
	sort(vec + 1, vec + n + 1);
	for (int i = 1; i <= n; i++) id[vec[i].second] = i;
	for (int i = 1; i <= n; i++) {
		int u = vec[i].second;
		vector<int> child;
		f[u] = inf, g[u] = b[u];
		for (int j = head[u]; ~j; j = graph[j].nxt) {
			int v = graph[j].to, rv = findroot(v);
			if (id[v] < id[u] && rv != u) {
				fa[rv] = u, g[u] += g[rv];
				child.push_back(rv);
			}
		}

		f[u] = min(f[u], a[u] + g[u]);
		for (int j = 0; j < child.size(); j++) {
			int v = child[j];
			f[u] = min(f[u], max(a[u], f[v]) + g[u] - g[v]);
		}
	}

	write(f[vec[n].second]), putchar('\n');
	return 0;
}

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

int log2(int x){
  int ans = 0;
  while(x%2 == 0){
    ans++;
    x /= 2;
  }
  return ans;
}

int main(void){
  int N, A;
  cin >> N;
  int ans = 10000;
  for(int i=0;i<N;i++){
    cin >> A;
    ans = min(ans, log2(A));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
using namespace std;
#include <stdio.h>
#include <limits.h>
#include "bits/stdc++.h"
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
int a, b, c, d;
string str;
int main() {
	cin >> a >> b >> c >> d;
	str = "No";
	if (abs(a - c) <= d) {
		str = "Yes";
	}
	if (abs(a - b) <= d && abs(b - c) <= d) {
		str = "Yes";
	}
	cout << str;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    for (long long i = 1;i <= b;i++) {
        if (a * i % b == 0) {
            cout << a * i << endl;
            break;
        }
    }
}
     

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
//解説AC
using namespace std;

typedef long long ll;

const ll inf = 1LL << 60 ;

int dp[3100][3100] = {0};

int main(){
 string s,t; cin >> s >> t;
  int n = (int)s.size(); int m = (int) t.size();
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if( s[i] == t[j]){ dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);}
      
      dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]); }}
  
  //dp[n][m]が、最長共通部分列の長さに他ならない
  string res ="";
  
  int i = n; int j = m;
  
  while(i > 0 && j > 0){
    if( dp[i][j] == dp[i-1][j]){i--;}
    else if( dp[i][j] == dp[i][j-1]){j--;}
    else{
      res = s[i-1] + res; i--;j--;}}
  
  cout << res << endl; 
  return 0;}
    
       
      
      
      
      
      

Measured memory_bytes: 37120
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll r,g,b,n;cin>>r>>g>>b>>n;

    ll ans=0;
    for(ll i=0;i*r<=n;i++){
        for(ll j=0;j*b + i*r<=n;j++){
            ll rem = n - j*b - i*r;
            if(rem%g==0)ans++;
        }
    }

    cout<<ans;
}





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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node x, int k){
  while(x != NIL && k != x->key){
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  return x;

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;
  }

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

  z = malloc(sizeof(struct 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;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    else if(strcmp(com,"print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25132
from collections import defaultdict

def get_yakusuu(num):
    yakusuu_dic = defaultdict(int)
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
    for now_num in range(1, num + 1):
        for num_ele in seed_primes:
            if now_num < num_ele:
                break
            while now_num % num_ele == 0:
                yakusuu_dic[num_ele] += 1
                now_num = now_num // num_ele
    return list(yakusuu_dic.values())

def calc(yakusuu_dic, lim):
    count = 0
    for num in yakusuu_dic:
        if num >= lim:
            count += 1
        else:
            break
    return count

def main():
    num = int(input())
    yakusuu_dic = get_yakusuu(num)
    yakusuu_dic.sort(reverse=True)

    up_4 = calc(yakusuu_dic, 4)
    up_2 = calc(yakusuu_dic, 2)
    ans1 = max(up_4 * (up_4 - 1) * (up_2 - 2) // 2, 0)

    up_24 = calc(yakusuu_dic, 24)
    ans2 = max(up_24 * (up_2 - 1), 0)

    up_14 = calc(yakusuu_dic, 14)
    ans3 = max(up_14 * (up_4 - 1), 0)

    up_74 = calc(yakusuu_dic, 74)
    ans4 = up_74

    ans = ans1 + ans2 + ans3 + ans4

    print(ans)




if __name__ == '__main__':
    main()

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	int k;
	string s;
	cin >> k >> s;
	if(s.size() <= k)
		cout << s << endl;
	else {
		string ans;
		for(int i=0;i<k;i++)
			ans += s[i];
		ans += "...";
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c =='u' ) {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

struct UnionFind{
  vector<int64_t> S;
  vector<int64_t> weight;
  
  UnionFind(int N){
    S = vector<int64_t>(N,0);
    weight = vector<int64_t>(N,1);
    for(int i = 0 ; i < N ; i++){
      S.at(i) = i;
      weight.at(i) = 1;
    }
  }
  
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(S.at(x) == x){
     return x; 
    }
    return S.at(x) = root(S.at(x));
  }
  
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    //cout << rx << ":" << ry <<endl;
    if (rx == ry){
      return;
    }
    if (S.at(x) > S.at(y)){
      swap(x, y);
    }
    //cout << x << ":" << y <<endl;
    weight.at(S.at(x)) += weight.at(S.at(y));
    S.at(y) = S.at(x);
    return; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }
  
  int size(int x){
    return weight.at(x);
  }
  
  //bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    //int rx = root(x);
    //int ry = root(y);
    //return rx == ry;
  //}
  
};

int main(){//main_program
  int K;
  cin >> K;
  
  for(int i = 0; i < K ; i++){
    cout << "ACL" ;
  }
  cout <<endl;
  
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

int H, W;
vector<string> vec;

bool check(int row, int col) {
	char c = vec[row][col];
	if (c == '.') {
		return true;
	}

	// c == '#'
	//
	// left
	if (0 < col) {
		if (vec[row][col - 1] == '#') {
			return true;
		}
	}

	// up
	if (0 < row) {
		if (vec[row - 1][col] == '#') {
			return true;
		}
	}

	// right
	if (col + 1 < W) {
		if (vec[row][col + 1] == '#') {
			return true;
		}
	}

	// down
	if (row + 1 < H) {
		if (vec[row + 1][col] == '#') {
			return true;
		}
	}

	return false;
}

int main(void) {
	cin >> H >> W;

	string s;
	int i;
	for (i = 0; i < H; i++) {
		cin >> s;
		vec.push_back(s);
	}

	string result = "Yes";
	for (i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (check(i, j)) {
				;
			} else {
				result = "No";
				break;
			}
		}
		if (result != "Yes") {
			break;
		}
	}
	
	cout << result << endl;
	return 0;
}


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

const int N = 1 << 18, mod = 998244353, i2 = (mod + 1) / 2;

typedef long long LL;

inline int Pow(int x, int y) {
	int res = 1;
	for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
	return res;
}

inline void FWT(int a[], int len, int type) {
	for (int mid = 2; mid <= len; mid <<= 1)
		for (int i = 0; i < len; i += mid)
			for (int j = i; j < i + (mid >> 1); j++) {
				int t = a[j]; a[j] = (t + a[j + (mid >> 1)]) % mod, a[j + (mid >> 1)] = (t - a[j + (mid >> 1)] + mod) % mod;
				if (!type) a[j] = (LL)a[j] * i2 % mod, a[j + (mid >> 1)] = (LL)a[j + (mid >> 1)] * i2 % mod;
			}
}

int A[N], B[N];

int main() {
	int n, sum = 0; scanf("%d", &n), n = 1 << n;
	for (int i = 0; i < n; i++) scanf("%d", &A[i]), B[i] = mod - 1, sum = (sum + A[i]) % mod;
	sum = Pow(sum, mod - 2);
	for (int i = 0; i < n; i++) A[i] = (LL)A[i] * sum % mod;
	B[0] = n - 1, A[0] = (A[0] + mod - 1) % mod;
	FWT(A, n, 1), FWT(B, n, 1);
	for (int i = 0; i < n; i++) B[i] = (LL)B[i] * Pow(A[i], mod - 2) % mod;
	FWT(B, n, 0);
	for (int i = 0; i < n; i++) printf("%d\n", (B[i] - B[0] + mod) % mod);
}

Measured memory_bytes: 4864
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) printf("Yes\n");
	else printf("No\n");
	return 0;
}



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

using namespace std ;

vector < string > v ;

int a , b ;

string s ;

int main ()
{
    cin >> a >> b ;
    for ( int i = 0 ; i < a ; ++ i ){
        cin >> s ;
        v . push_back ( s ) ;
    }
    sort ( v . begin ( ) , v . end ( ) ) ;
    for ( int i = 0 ; i < v . size ( ) ; ++ i ){
        cout << v [ i ] ;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string jstr,xstr;
	int i;
	cin>>jstr;
	xstr=jstr;
	reverse(xstr.begin(),xstr.end());
	for(i=0;i<xstr.size();i++)
	{
		if(xstr[i]=='b')
			xstr[i]='d';
		else if(xstr[i]=='d')
			xstr[i]='b';
		else if(xstr[i]=='p')
			xstr[i]='q';
		else if(xstr[i]=='q')
			xstr[i]='p';
	}
	if(xstr==jstr)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0; 
}

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

using namespace std;

const int MAX_N = 700 + 5;

int N, M, n, K;
char m[MAX_N][MAX_N], vis[MAX_N];
bool f[2][MAX_N];

void dfs(int u, int color) {
    vis[u] = color;
    color == 1 ? n ++ : n --;
    for (int v = 1; v <= N; v ++) {
        if (u != v && !m[u][v]) {
            if (vis[v] == color) {
                printf("-1\n");
                exit(0);
            } else if (!vis[v]) {
                dfs(v, color ^ 3);
            }
        }
    }
}

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= M; i ++) {
        int x, y;
        scanf("%d%d", &x, &y);
        m[x][y] = 1;
        m[y][x] = 1;
    }
    f[0][0] = 1;
    for (int i = 1; i <= N; i ++) {
        if (!vis[i]) {
            n = 0;
            K ^= 1;
            dfs(i, 1);
            n = abs(n);
            for (int j = 0; j <= N; j ++) {
                f[K][j] = f[K ^ 1][abs(j - n)] || (j + n <= N ? f[K ^ 1][j + n] : 0);
            }
        }
    }
    for (n = 0; !f[K][n]; n ++);
    n = N + n >> 1;
    N = N - n;
    M = n * (n - 1) + N * (N - 1) >> 1;
    printf("%d\n", M);
    return 0;
}

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



// Inserted snippets: io, opt, root
#pragma gcc optimize("Ofast")
#pragma gcc target("avx2")
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int a, b; read(a, b);
	write(a * b);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  vector<int> V(3);
  cin >> V.at(0) >> V.at(1) >> V.at(2);
  sort(V.begin(), V.end());
  if(V.at(2) == V.at(0) + V.at(1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 256
using System;
class main
{
    static void Main(string[] args)
    {
        while (true)
        {
            string s = Console.ReadLine();

            if (s != null)
            {
                int i = 0; 
                string[] s1 = s.Split(' ');
                long[] a = new long[2];
                long[] l = new long[2];
                a[0] = long.Parse(s1[0]);
                a[1] = long.Parse(s1[1]);

                Array.Sort(a);

                long c = a[0] * a[1];

                l[0] = a[1] % a[0];
                if (l[0] != 0)
                {
                    l[1] = a[0] % l[0];
                    if (l[1] != 0)
                    {
                        while (true)
                        {
                            Array.Resize(ref l, i + 3);
                            l[i + 2] = l[i] % l[i + 1];
                            if (l[i + 2] == 0)
                            {
                                break;
                            }
                            ++i;
                        }
                        Console.WriteLine("{0} {1}", l[i + 1], (c / l[i + 1]));
                    }
                    if (l[1] == 0)
                    {
                        Console.WriteLine("{0} {1}", l[0], (c / l[0]));
                    }
                }
                if (l[0] == 0)
                {
                    Console.WriteLine("{0} {1}", a[0], (c / a[0]));
                }
                

            }
            if (s == null)
            {
                break;
            }
            //Console.ReadKey();
        }
    }
}

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

int main() {
    int N;
    cin >> N;

    vector<int> cnt(100001, 0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int res = 0;
    for (int i = 1; i <= 100000 ; i++)
        res = max(res, cnt[i - 1] + cnt[i] + cnt[i + 1]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll x,y,z;
	cin>>x>>y>>z;
	ll i,j;
	ll s=0;
	for(i=x;i<=y;i++)
		if(i%z==0)
			s++;
	cout<<s<<endl;
}


Measured memory_bytes: 3628
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string s;
int n;

int main()
{
  s = GetString();
  n = SIZE(s);
  s = '?' + s;
  if (s[n] == '1')
  {
    puts("-1");
    return 0;
  }
  FORN(i,1,n-1) if(s[i] != s[n-i])
  {
    puts("-1");
    return 0;
  }
  if (s[1] != '1')
  {
    puts("-1");
    return 0;
  }
  vii risan;
  int now = 1;
  int last = 1;
  FORN(i,1,n-1)
  {
    if (s[i] == '1')
    {
      ++last;
      risan.pb(mp(now,last));
      now = last;
    } else 
    {
      ++last;
      risan.pb(mp(now,last));
    }
  }
  REP(i,SIZE(risan)) printf("%d %d\n",risan[i].fi,risan[i].se);
  return 0;
}











Measured memory_bytes: 2548
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = 2019;
		int L = sc.nextInt();
		int R = sc.nextInt();
		int ans = M;
		if (R - L <= M) {
			for (int i = L; i <= R; i++) {
				for (int j = i + 1; j <= R; j++) {
					ans = Math.min(((i%M) * (j%M)) % M, ans);
				}
			}
		} else {
			L = L % M;
			R = (R % M) + M;
			for (int i = L; i <= R; i++) {
				for (int j = i + 1; j <= R; j++) {
					ans = Math.min(((i%M) * (j%M)) % M, ans);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
atoz = list(input())
A_num = 0
Z_num = 0
for i, j in enumerate(atoz):
    if j == "A" and A_num == 0:
        A_num = i + 1
    elif j == "Z" and A_num < i:
        Z_num = i + 1
    else:
        pass
    
print(Z_num - A_num+1)

Measured memory_bytes: 4840
#include <iostream>
#include <string.h> 
#include <algorithm>
using namespace std;

int main()
{
    int judge,count=0;
	char str[1001];
	string word;
	string text;
	string eot="END_OF_TEXT";
	
	cin>>word;
	transform(word.begin(), word.end(), word.begin(), ::tolower);
	while(1)
	{
		cin>>text;
		if(text==eot)break;
		//if ( 0== (judge=stricmp( word.c_str() , text.c_str()))) count+=1;
		transform(text.begin(), text.end(), text.begin(), ::tolower);
		if(word==text)count+=1;
	}
	cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1196
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    tmp = input()
    if tmp == 'AC':
        AC += 1
    elif tmp == 'WA':
        WA += 1
    elif tmp == 'TLE':
        TLE += 1
    elif tmp == 'RE':
        RE += 1

print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)


Measured memory_bytes: 69852
#include<stdio.h>

int main(){
  int a,b,i,a1;
  scanf("%d %d",&a,&b);
  
  while(1){
    a1 = a;
    a = b%a;
    b = a1;
    if(a==0){
      printf("%d\n",b);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

}

Measured memory_bytes: 37476
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> v1(n,0),v2(n,0);
    rep(i,n-1){
        if(s[i]=='E'){
            v1[i+1]=v1[i]+1;
        }
        else v1[i+1]=v1[i];
    }
    for(int i=n-1;i>0;i--){
        if(s[i]=='W'){
            v2[i-1]=v2[i]+1;
        }
        else v2[i-1]=v2[i];
    }
    /*
    rep(i,n) cout<<v1[i]<<" ";
    cout<<endl;
    rep(i,n) cout<<v2[i]<<" ";
    cout<<endl;*/
    vector<int> v(n,0);
    rep(i,n) v[i]=v1[i]+v2[i];
    sort(v.begin(),v.end());
    //cout<<v[n-1]<<endl;
    cout<<n-v[n-1]-1<<endl;
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define len(x) x.size()
#define endl "\n"
#define m_p make_pair
#define int long long
using namespace std;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pari;
ld PI = 3.14159265358979323846;


struct Point{
    int x,y;
};


void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    cout << fixed;
}


int n;
const int N = 1e6;
const int INF = 1e18+7;
const int MOD = 1e9+7;

int mas[N];


void input(){
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> mas[i];
}


void solve(){
    sort(mas,mas+n);
    int sum = 0;
    for(int i = 0;i < n-1;i++)
        sum += mas[i];
    if(sum <= mas[n-1]) cout << "No";
    else cout << "Yes";
}

signed main(){
    volodya22();
    input();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////
int main()
{
	int N[5];
	int mi1=2000,mi2=2000;
	rep(i,5)
	{
		s_1(N[i]);
		if(i<=2)mi1=min(N[i],mi1);
		else if(i>=3 && i<=4)mi2=min(N[i],mi2);
	}
	cout<<mi1+mi2-50<<endl;
	return 0;
}

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

int main(){
    long A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V <= W){
        cout << "NO" << endl;
        return 0;
    }
    if(abs(A - B) <= T * (V - W)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

    int main()
    {
        int n,m,inp,sum=0;
        cin>>n>>m;

        for(int i=0;i<m;i++)
        {
            cin>>inp;
            sum = sum +inp;
        }
        if(sum<=n)
        {
            cout<<n-sum<<endl;
        }
        else
            cout<<"-1"<<endl;


        return 0;
    }


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> num(100000, 0);
  for (long long i = 0; i < N; i++) {
    long long a, b;
    cin >> a >> b;
    a--; b;
    num[a] += b;
  }
  long long sum = 0;
  long long res = -1;
  for (long long i = 0; i < 100000; i++) {
    if (sum + num[i] < K) {
      sum += num[i];
    } else {
      res = i+1;
      break;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
def main():
    from bisect import bisect
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    cnt = 0

    for i in range(N-1,1,-1):
        for j in range(i-1,0,-1):
            temp = L[i] - L[j]
            l = bisect(L,temp,lo=0,hi=j)
            cnt += j - l
    print(cnt)
if __name__ == '__main__':
    main()

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

namespace ABC151
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            string a = "abcdefghijklmnopqrstuvwxyz";
            string b = Console.ReadLine();
            char c = b[0];
            int d = a.IndexOf(c);
            Console.WriteLine(a[d + 1]);
        }
    }
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w,h,x,y;
  cin >> w>>h>>x>>y;
  cout << (double)w*(double)h/2 << endl;
  if(2*x == w && 2*y == h) cout << "1\n";
  else cout << "0\n";
  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> acc(N + 1), acc_plus(N + 1);
    for(int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
        acc_plus[i + 1] = acc_plus[i] + (A[i] > 0 ? A[i] : 0);
    }

    ll ans = 0;
    for (int i = 0; i < N - K + 1; i++) {
        ll black = acc[i + K] - acc[i];
        ll more = acc_plus[N] - acc_plus[i + K] + acc_plus[i];
        ans = max({ans, black + more, more});
    }
    cout << ans << endl;

}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;

    map<long, int> cnt;
    for (int i = 0; i < N; ++i) {
        long a;
        cin >> a;
        ++cnt[a];
    }

    long fst = 0;
    long snd = 0;
    for (auto it = cnt.rbegin(); it != cnt.rend(); ++it) {
        if (it->second < 2)
            continue;

        if (fst == 0 && it->second >= 4) {
            fst = snd = it->first;
            break;
        }
        if (it->second >= 2) {
            if (fst == 0) {
                fst = it->first;
            } else {
                snd = it->first;
                break;
            }
        }
    }

    cout << fst * snd << '\n';

    return 0;
}


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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;

	vector<vector<char>> img(h + 2, vector<char>(w + 2, '#'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> img[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << img[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split(" ")))

zero = 0
two = 0
four = 0

for i in a:
	if i % 2 == 0:
		if i % 4 == 0:
			four += 1
		else:
			two += 1
	else:
		zero += 1

four -= zero
if four >= 0 or (two == 0 and four == (-1)):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 14252
#include <stdio.h>
int main(){
  int A,B,C,K,x;
  scanf("%d %d %d %d",&A,&B,&C,&K);
  if(K<=A){x=K;}
  else if(K>A+B){x=A-(K-A-B);}
  else{x=A;}
  printf("%d",x);
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>

using namespace std;

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

const int nmax = 100005;
int imos[nmax];

int main() {
    std::ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        imos[a]++;
        imos[b+1]--;
    }
    for (int i = 1; i < nmax; i++)
        imos[i] += imos[i-1];
    int res;
    rep(i,nmax) {
        if (imos[i] >= i - 1)res = i - 1;
    }
    cout << res << endl;
    return 0;
}

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

namespace ABC166A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s == "ABC") Console.WriteLine("ARC");
            else Console.WriteLine("ABC");
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 17340
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}

		int ans = 0;
		boolean even = true;
		while(even) {
			for(int i=0; i<n; i++) {
				if(a[i]%2 != 0) {
					even = false;
					break;
				}
				a[i] = a[i]/2;
			}
			if(even)ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21204
import sys

class Queue:
    class Cell:
        def __init__(self, x, y = None):
            self.data = x
            self.next = y

    def __init__(self):
        self.size = 0
        self.rear = None

    def enqueue(self, x):
        if self.size == 0:
            self.rear = Queue.Cell(x)
            self.rear.next = self.rear
        else:
            new_cell = Queue.Cell(x, self.rear.next)
            self.rear.next = new_cell
            self.rear = new_cell
        self.size += 1

    def dequeue(self):
        if self.size == 0: raise IndexError
        front = self.rear.next
        self.rear.next = front.next
        self.size -= 1
        if self.size == 0: self.rear = None
        return front.data

    def isEmpty(self):
        return self.size == 0

def generator(n1, n2, step=1):
    n = n1
    while n<n2:
        yield n
        n+= step

n, q = map(int, raw_input().split())
 
A = Queue()
for i in generator(0,n):
    name, time = raw_input().split()
    A.enqueue([name, int(time)])

stime = 0
while not A.isEmpty():
    job = A.dequeue()
    if q>=job[1]:
        stime += job[1]
        print job[0], stime
    else:
        stime += q
        job[1] -= q
        A.enqueue(job)

Measured memory_bytes: 29352
import sys
def f(x):
  x = float(x)
  f = 0
  if x<.2: f = 3
  elif x<.6: f = 2
  elif x<1.1: f = 1
  return f

C1=[0]*4
C2=[0]*4
for s in sys.stdin:
  L, R = map(f,s.split())
  C1[L]+=1
  C2[R]+=1
for a,b in zip(C1,C2):
  print a,b

Measured memory_bytes: 4232
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<int> d(n);
	d[0] = 0;
	d[1] = abs(h[0] - h[1]);
	
	rep2(i, 2, n) {
		d[i] = min(d[i - 2] + abs(h[i] - h[i - 2]), d[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << d[n-1] << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, m, c, count=0;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0; i<m; i++) {
        cin >> b[i];
    }
    for(int i=0; i<n; i++) {
        // vector<int> a(m);
        int a, acum=c;
        for(int j=0; j<m; j++) {
            cin >> a;
            acum += a * b[j];
        }
        if(acum > 0) {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int roll[10][10]={
    {3, 2, 6, 1, 5, 4}, 
    {4, 2, 1, 6, 5, 3}, 
    {2, 6, 3, 4, 1, 5}, 
    {5, 1, 3, 4, 6, 2}, 
};
int main()
{
    int dice[10], newdice[10], key[200];
    string cmd;
    key['W'] = 0, key['E'] = 1, key['N'] = 2,key['S'] = 3;
    for(int i = 0; i < 6; i++)
    {
        cin >> dice[i];
    }
    cin >> cmd;
    for(int i = 0; i < cmd.size(); i++)
    {
        for(int j = 0; j < 6; j++)
        {
            newdice[j] = dice[roll[key[cmd[i]]][j]-1];
        }
        for(int j = 0; j < 6; j++)
        {
            dice[j] = newdice[j];
        }
    }
    cout << dice[0] << endl;
    return 0;
}



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

int main()
{
    string s;
    cin>>s;
    if(s.size()%2)
    { int ans=0;
        int low=((s.size())/2)-1;
        int high=((s.size())/2)+1;
        while(low>=0 && high<=(s.size()-1))
        {
            if(s[low]!=s[high])
            {
                ans++;
                
            }
            low--;high++;
        }
        cout<<ans;
    }
    else
    {int ans=0;
        int low=((s.size())/2)-1;
        int high=((s.size())/2);
        while(low>=0 && high<=(s.size()-1))
        {
            if(s[low]!=s[high])
            {
                ans++;
            
            }
            low--;high++;
        }
        cout<<ans;
        
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 0;
    
    for(int i=1; i<N+1; i++){
        if(i*i > N){
            break;
        }else{
            ans = i*i;
        }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const ll maxn=1e7+5;
const int mod=998244353;
ll n,m,p;
int pos[30][30];
ll dis[500][500];
char str[30][30];
bool vis[500];
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};
struct node{
    int e,next;
}edge[maxn];
ll cnt=0;
int head[maxn];
int judge(int x,int y)
{
    if(x>=1&&y>=1&&x<=n&&y<=m&&str[x][y]=='.') return 1;
    return 0;
}
void addedge(int u,int v)
{
    edge[cnt]=node{v,head[u]};
    head[u]=cnt++;
}
void spfa(int s)
{
    for(int i=1;i<=n*m;i++) dis[s][i]=INF,vis[i]=false;
    queue<int>q;
    q.push(s);
    vis[s]=true;dis[s][s]=0;
    while(!q.empty())
    {
        int u=q.front();q.pop();vis[u]=0;
        for(int i=head[u];~i;i=edge[i].next)
        {
            int e=edge[i].e;
            if(dis[s][e]>dis[s][u]+1)
            {
                dis[s][e]=dis[s][u]+1;
                if(!vis[e])
                {
                    q.push(e);
                    vis[e]=1;
                }
            }
        }
    }
}
int main()
{
    int cot=0;
    memset(head,-1,sizeof(head));
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
    for(int i=1;i<=n;i++)
        for(int k=1;k<=m;k++)
            pos[i][k]=++cot;
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=m;k++)
        {
            if(str[i][k]=='.')
            {
                for(int j=0;j<4;j++)
                {
                    int mx=i+dx[j],my=k+dy[j];
                    if(judge(mx,my)) addedge(pos[i][k],pos[mx][my]);
                }
            }
        }
    }
    for(int i=1;i<=n*m;i++)
            spfa(i);
    ll maxl=0;
    for(int i=1;i<=n*m;i++)
        for(int k=1;k<=n*m;k++)
            if(dis[i][k]!=INF)
            maxl=max(maxl,dis[i][k]);
    printf("%lld\n",maxl);
    return 0;
}
/**
***/


Measured memory_bytes: 43264
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    
    vector<vector<int> > C(N+2, vector<int>(N+2, 0));  // C[l][r]
    for(int m=0; m<M; m++) {
        int l, r;
        cin >> l >> r;

        C[1][r]++;
        C[l+1][r]--;
    }
    

    for(int r=1; r<N+1; r++) {
        for(int l=1; l<=r+1; l++) {
            C[l][r] += C[l-1][r];
        }
    }
    
    for(int l=1; l<N+1; l++) {
        for(int r=l; r<N+1; r++) {
            C[l][r] += C[l][r-1];
        }
    }
    
    for(int q=0; q<Q; q++) {
        int l, r;
        cin >> l >> r;
        
        cout << C[l][r] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int V;
	static int E;
	static ArrayList<Integer>[] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		ord = new int[V];
		vis = new boolean[V];
		pending = new boolean[V];

		sort();

		for (int i = 0; i < V; ++i) {
			System.out.println(ord[i]);
		}
	}

	static int[] ord;
	static boolean[] vis;
	static boolean[] pending;
	static int now = 0;

	static void sort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		for (int to : g[cur]) {
			if (to != pre && !vis[to]) {
				if (pending[to])
					throw new AssertionError();
				dfs(to, cur);
			}
		}
		ord[V - now - 1] = cur;
		vis[cur] = true;
		++now;
	}
}

Measured memory_bytes: 69480
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <time.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define hoge cout << hoge << endl;
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,f,g,h,w;
ll x[1000005],y[1000005],z[1000005];
bool flag,dame;
char s[500005];

int main(){	
	cin >> n;
	num = INF;
	while(n >= 100){
		ans = n % 1000;
		if(abs(ans - 753) < num){
			num = abs(ans - 753);
		}
		n /= 10;
	}
	p(num);



	return 0;
}

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

int last[26];
char str[105];
int mx[26];
int main(){
	scanf("%s",str);
	int n = (int)strlen(str);
	for(int i=0;i<26;i++){
		last[i] = -1;
		mx[i] = -1;
	}
	for(int i=0;i<n;i++){
		int target = str[i] - 'a';
		mx[target] = max(i-last[target]-1, mx[target]);
		last[target] = i;
	}
	for(int i=0;i<26;i++){
		mx[i] = max(mx[i], n-1-last[i]);
	}
	int ans = 100000000;
	for(int i=0;i<26;i++){
		if(ans > mx[i]) ans = mx[i];
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
    $count = 1;
    $array = str_split($n);
if($array[0] == $array[1] && $array[1] == $array[2]){
	echo 'Yes';
}elseif($array[1] == $array[2] && $array[2] == $array[3]){
	echo 'Yes';
}else{
	echo 'No';

}
?>

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
vector<int> g[4];
int main()
{
    long long k, a, b;
    cin >> k >> a >> b;
    if(b - a <= 1)
    {
        cout<<k + 1;
    }
    else
    {
        long long ans =0;
        if(a > k)
        {
            cout << k + 1;
            return 0;
        }
        else
        {
            k -= (a - 1);
            cout << a + (k % 2) + k /2 * (b - a);
        }
    }

}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

pre_index = 99

sum_point = 0
for index in a_list:
    sum_point += b_list[index - 1]
    
    if (index - pre_index == 1):
        sum_point += c_list[pre_index - 1]
    
    pre_index = index

print(sum_point)

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    vector<int> cnt(2, 0);
    for (char c : s) {
        cnt[c - '0']++;
    }
    cout << 2 * min(cnt.front(), cnt.back()) << '\n';
    return 0;
}


Measured memory_bytes: 512
strs = list(input())

nums = list(map(int, strs))

op_patterns = []

ops = ['+', '-']

for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            op_patterns.append((op1, op2, op3))


for pat in op_patterns:
    express = '{}{}{}{}{}{}{}'.format(nums[0], pat[0], nums[1], pat[1], nums[2], pat[2], nums[3])
    result = eval(express)

    if result == 7:
        print(express + '=7')
        exit()

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

int main() {
  char S;
  cin >> S;
  if (S == 'a' || S == 'e' || S == 'i' || S == 'o' || S == 'u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main()
{
	unsigned ll m=1e18;
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   	int t;
   	//cin>>t;
   	t=1;
   	while(t--)
   	{
   		ll n;
   		cin>>n;
   		ll a[n];
   		for(ll i=0;i<n;i++)
   		cin>>a[i];
   		sort(a,a+n);
   		if(a[0]==0)
   		cout<<"0";
   		else{
   			unsigned ll ans=a[n-1];
   			bool flag=0;
   		for(ll i=n-2;i>=0;i--)
   		{
   			if(ans>m/a[i])
   			{
   				cout<<"-1"<<endl;
   				flag=1;
   				break;
			}
			ans=ans*a[i];
		}
		if(flag==0)
		cout<<ans;
		}
   	}
	return 0;
}

Measured memory_bytes: 4436