akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 1000000
#define NUM2_MAX (1<<20)
#define ROOT_NODE 1
#define INF (1e+9)

void update(int *seg, int num, int val, int idx) {
    int node = num + idx;
    seg[node] = val;
    while((node = node / 2)) {
        seg[node] = min(seg[node*2], seg[node*2+1]);
    }
    return;
}

int main(void) {
    int num, len;
    static int arr[NUM_MAX];
    static int ans[NUM_MAX];
    int aidx = 0;
    // Range Minimum Query
    static int seg[NUM2_MAX*2];
    get_int2(&num, &len);
    fget_array(arr, num);
    int len2 = 1;
    while(len > len2) len2 *= 2;
    int i;
    // initialization
    for(i = 0; i < len2*2; i++) {
        seg[i] = INF;
    }

    for(i = 0; i < num; i++) {
        int idx = i % len;
        update(seg, len2, arr[i], idx);
        if(i >= len-1) ans[aidx++] = seg[ROOT_NODE];
    }

    // presentation
    for(i = 0; i < aidx; i++) {
        printf("%d%c", ans[i], (i == aidx-1) ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 10176
import math
def judge(x):
    cnt=0
    for l in a:
        c=l//x
        if l%x!=0:
            c+=1
        cnt+=c-1 
    return cnt<=k

n,k=map(int,input().split())
a=list(map(int,input().split()))
left=0
right=max(a)
mid=(left+right)//2
while right-left>1:# 最後は整数なので実数で扱わなくていい
    if judge(mid):
        right=mid
        mid=(left+right)//2
    else:
        left=mid
        mid=(left+right)//2
print(right)


Measured memory_bytes: 93856
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll l;
    ll r;
    ll d;
    ll ans = 0;
    std::cin >> l >> r >> d;
    for (int i = l; i <= r; ++i) {
        if (i % d == 0) {
            ++ans;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll a;
    string s, t;
    cin >> a >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '.')
            continue;
        t += s[i];
    }
    while (t.size() != 3)
        t += '0';
    ll b = stoi(t);
    cout << a*b / 100 << endl;
    
    return 0;
}


Measured memory_bytes: 3564
A,B,K = map(int, input().split())

AB = range(A,B+1)
tail = len(AB)
AB_L = set(AB[0:min(K,tail)])
AB_R = set(AB[max(0,tail-K):tail])
AB_SL = sorted(AB_L | AB_R)

for ab in AB_SL:
    print(ab)

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

int main()
{
	int a[200001];
	int n, cnt=0, index=1;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		cin>>a[i];
		if (a[i]==index)
			cnt++, index++;
	}
	if (cnt==0)
		cout<<-1;
	else
		cout<<n-cnt;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int p[111];
int main()
{
	int x,n;
	cin>>x>>n;
	for(int i=0;i<n;i++)
		cin>>p[i];
	for(int i=0;;i++)
	{
		bool ex1=0,ex2=0;
		int now1=x-i,now2=x+i; 
		for(int j=0;j<n;j++)
		{
			if(p[j]==now1)
				ex1=1;
			if(p[j]==now2)
				ex2=1;
		}
		if(ex1==0)
		{
			cout<<now1;
			return 0;
		}
		if(ex2==0)
		{
			cout<<now2;
			return 0;
		}
	}
 } 

Measured memory_bytes: 3624
try:
    while True:
        w=float(input())
        if(w<=48.00):
            print('light fly')
        elif(w>48.00 and w<=51.00):
            print('fly')
        elif(w>51.00 and w<=54.00):
            print('bantam')
        elif(w>54.00 and w<=57.00):
            print('feather')
        elif(w>57.00 and w<=60.00):
            print('light')
        elif(w>60.00 and w<=64.00):
            print('light welter')
        elif(w>64.00 and w<=69.00):
            print('welter')
        elif(w>69.00 and w<=75.00):
            print('light middle')
        elif(w>75.00 and w<=81.00):
            print('middle')
        elif(w>81.00 and w<=91.00):
            print('light heavy')
        else:
            print('heavy')
except EOFError:
    pass



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

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(char *s, char *t, int a, int b, char *u)
{
    if(strcmp(s, u) == 0)
        a--;
    else {
        b--;
    }
    printf("%d %d\n", a, b);
}

int
main(int argc, char *argv[])
{
    char S[11], T[11];
    int A, B;
    char U[11];
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    scanf("%s%s", S, T);
    scanf("%d%d", &A, &B);
    scanf("%s", U);
    solver(S, T, A, B, U);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int i, tmp, number, count = 0, answer = 0;
    number = Integer.parseInt(sc.next());
    int[] height = new int[number];
    for(i = 0; i < number; i++) height[i] = Integer.parseInt(sc.next());
    tmp = height[0];
    for(i = 1; i < number; i++) {
      if(answer < count) answer = count;
      if(tmp >= height[i]) {
        count++;
      } else {
        count = 0;
      }
      tmp = height[i];
    }
    if(answer < count) answer = count;
    System.out.println(answer);
  }
}


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

using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// DFSライブラリ

	struct DFSedge
	{
		ll vertex;	// 頂点
		DFSedge(ll v) { vertex = v; }
	};

	template <class TE = DFSedge> struct DFS
	{
		using Graph = vector<vector<TE>>;
		Graph graph;

		DFS(ll size)
		{
			graph.resize(size);
		}

		vector<DFSedge>& operator [](int n) { return graph[n]; }

		void CreateEdge(ll v1, ll v2)
		{
			graph[v1].push_back(DFSedge(v2));
			graph[v2].push_back(DFSedge(v1));
		}
	};

}

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

using namespace NyaGadget;

/**
@brief 深さ優先探索
@param v 頂点
@param r 根
@param g 処理するグラフ
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void Solve(ll r, ll v, DFS<>& dfs, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	for (const auto& e : dfs[v])
	{	// 後戻りしないようにする
		if (e.vertex == r)
			continue;

		Solve(v, e.vertex, dfs, memo, ans);
	}
}

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

	ll u, v;
	DFS<> dfs(n);
	rep(ei, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		dfs.CreateEdge(u, v);
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	vector<ll> memo(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	vector<ll> ans(n);
	ans[0] = memo[0];
	Solve(-1, 0, dfs, memo, ans);

	for (auto& e : ans)
		cout << e << " ";

	return 0;
}


Measured memory_bytes: 35200
#include<bits/stdc++.h>
using namespace std;
#define Abs(a) ((a)<0?(a)*(-1):(a))

int MIN(int a,int b){
  if(a<b){
    return a;
  }
  return b;
}

int main(void){
  int n=0;
  int k=0;
  int ans=0;
  cin>>n;
  cin>>k;
  for(int i=0;i<n;i++){
    int a=0;
    cin>>a;
    ans+=MIN(a,Abs(k-a))*2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	string S;
	cin >> S;
	vector<int> dp(4); dp[0] = 1;
	for (char c : S) {
		vector<int> ndp(4);
		for (int i = 0; i <= 3; ++i) {
			ndp[i] = dp[i] * (c == '?' ? 3LL : 1LL) % mod;
			if (i >= 1 && (c == '?' || c == char('A' + i - 1))) {
				ndp[i] += dp[i - 1];
				if (ndp[i] >= mod) ndp[i] -= mod;
			}
		}
		dp = ndp;
	}
	cout << dp[3] << endl;
	return 0;
}

Measured memory_bytes: 512
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r,d,xbase;
	cin>>r>>d>>xbase;
	for(ll i=1;i<=10;i++)
	{
		ll tmp=r*xbase-d;
		cout<<tmp<<endl;
		xbase=tmp;
	}
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef struct {
  int x;
  int y;
  int dist;
} X;

int ds[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(int argc, char const *argv[]) {
  int H, W;
  cin >> H >> W;
  char S[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }


  X *ans = new X{0,0,0};
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#')
        continue;

      queue<X*> q;
      int used[H][W];
      for (int k = 0; k < H; k++) {
          for (int l = 0; l < W; l++) {
              used[k][l]=0;
          }
      }
      auto _x = new X{j, i, 0};
      X *max = _x;
      q.push(_x);

      while (!q.empty()) {
        auto x = q.front();
        q.pop();
        if (used[x->y][x->x] == 1)
          continue;

        used[x->y][x->x] = 1;
        for (int aa = 0; aa < 4; aa++) {
          int nx = x->x + ds[aa][0];
          int ny = x->y + ds[aa][1];
          if (!(0 <= nx && nx < W)) {
              continue;
          }
          if (!(0 <= ny && ny < H)) {
              continue;
          }
          if (S[ny][nx] == '#') {
              continue;
          }
          auto x2 = new X{nx, ny, x->dist + 1};
          if (used[x2->y][x2->x] == 1) {
              continue;
          }
          q.push(x2);
          if (max->dist <= x2->dist) {
              max = x2;
          }
        }
      }

      if (ans->dist < max->dist) {
        ans = max;
      }
    }
  }

  cout << ans->dist << endl;
  return 0;
}


Measured memory_bytes: 19328
s = int(input())
a = s//100
b = s%100

if 1 <= a <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    // Create a vector of size n+1 (for extra space) with all values as 0
    vector<int> v(n+1, 0);

    for(int i=0; i<n; i++) {
        // next element is greater, so add 1 to it
        if(s[i] == '<') v[i+1] = v[i]+1;
    }
    for(int i=n-1; i>=0; i--) {
        if(s[i] == '>') v[i] = max(v[i], v[i+1]+1);
    }
    ll ans = 0;
    for(int i=0; i<v.size(); i++) {
        ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5320
#include<stdio.h>

int main(void)
{
 	int a, b;
 	scanf( "%d %d", &a, &b);
 	
 	if( a < b ) {
 		printf( "a < b\n");
 	} else if( a == b) {
 		printf( "a == b\n");
 	} else {
 		printf( "a > b\n"); 	
 	}

	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, k;
  cin >> n >> k;

  vector<ll> a(n);
  REP(i, n) { a[i] = 0; }

  REP(i, k) {
    ll d;
    cin >> d;
    REP(j, d) {
      ll t;
      cin >> t;
      a[t - 1]++;
    }
  }

  ll ans = 0;
  REP(i, n) {
    if (a[i] == 0) {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int H, W;
	char a[100][100];
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", a[i]);
	}
	for (int i = -1; i <= H; i++) {
		for (int j = -1; j <= W; j++) {
			if (i < 0 || i >= H || j < 0 || j >= W) {
				printf("#");
			}
			else {
				printf("%c", a[i][j]);
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {

    lli N;
    cin >> N;


    cout << (N -1) * N / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    // ?は全部Dと見る
    ll cnt = 0;
    rep(i, s.size()){
        if(s[i] == '?') cout << 'D';
        else cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << " ";
    os << *it;
  }
  return os << "";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  int sum = a[0];
  REP(i, 1, n) sum ^= a[i];
  vector<int> ans(n);
  rep(i, n) {
    ans[i] = sum ^ a[i];
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

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

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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> a(N); REP(i, N) cin >> a[i];
    
    vector<ll> sum(N+1, 0);
    REP(i, N) sum[i+1] = sum[i] + a[i];
    
    vector<ll> pls(N+1, 0);
    REP(i, N) pls[i+1] = pls[i] + (a[i] > 0 ? a[i] : 0);
    
    ll ans = 0;
    FOR(i, 1, N-K+2) {
        ll b = sum[i+K-1]-sum[i-1];
        if (b < 0) b = 0;
        b += pls[i-1];
        b += pls[N] - pls[i+K-1];
        ans = max(ans, b);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define Mod 1000000007
using namespace std;
int n,a[100010];
long long ans=1;
int b[3];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) {
		bool g=false;long long cnt=0;
//		cout<<b[0]<<' '<<b[1]<<' '<<b[2]<<' '<<a[i]<<'\n'; 
		if(b[0]==a[i]) {
			cnt++;if(!g) g=true,b[0]++;
		}
		if(b[1]==a[i]) {
			cnt++;if(!g) g=true,b[1]++;
		} 
		if(b[2]==a[i]) {
			cnt++;if(!g) g=true,b[2]++;
		}
		ans=ans*cnt%Mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  cin >>n;
  int cnt=0;
  for(i=0;i<n;++i) {
    long a;cin>>a;
    while (a%2==0) {
      ++cnt;
      a=a/2;
    }
  }
  cout << cnt <<endl;
  return 0;
}


Measured memory_bytes: 256
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

//typedef pair<int, int> p;
typedef long long ll;

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

  vector<pair<ll,int>> fs;
  for (ll i = 2; i*i <= n; ++i) {
    int x = 0;
    while (n%i == 0) {
      n /= i;
      ++x;
    }
    fs.emplace_back(i,x);
  }
  if (n != 1) fs.emplace_back(n,1);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19688
#include<stdio.h>

//最小値を求める関数終わり
int main (void)
{
    long long n;
    scanf("%lld",&n);
    long long a[n];
    for(long long i = 0; i < n; i++)  {
        scanf("%lld",&a[i]);
    }   //入力終わり//
    long long ans = a[0];
    long long temp = a[0];
    if(a[1] > a[0]) temp = a[1];
    for (long long i = 1; i < n; i ++)    {
        if(ans >= a[i])   {
            temp = ans;
            ans = a[i];
        }  //もしそれよりも小さいものがあれば，その小さい数にする．// 
    }   //ansはaの配列の中で最も小さなアタになっているはず//
    ans = temp;
        int fail = 0;
    do{
        for(long long i = 0; i < n; i ++) {
            if(a[i] % ans != 0) fail ++;
            if(fail == 2)   break;
        }
        if(fail < 2)    break;
        else {
            ans --;
            fail = 0;
        }
    }while(1);  
    printf("%lld",ans);
}

Measured memory_bytes: 896
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        Scanner in = new Scanner(System.in);
        String wet = in.next();
        Map<String, String> wetmap = new HashMap<>();
        wetmap.put("Sunny", "Cloudy");
        wetmap.put("Cloudy", "Rainy");
        wetmap.put("Rainy", "Sunny");
        System.out.println(wetmap.get(wet));

    }
}


Measured memory_bytes: 22228
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var RGBN = ReadLine().Split().Select(int.Parse).ToArray();
        var R = RGBN[0];
        var G = RGBN[1];
        var B = RGBN[2];
        var N = RGBN[3];

        var a = 0;
        for (int i = 0; i <= N/R; i++)
        {
            for (int j = 0; j <= (N-R*i)/G; j++)
            {
                var m = N - i * R - j * G;
                if (m % B == 0) a++;
            }
        }

        WriteLine(a);
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

def solve():
    dxys = [(-1,0), (1,0), (0,-1), (0,1)]

    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    Sss = ['#'*(W+4)] + ['#'*(W+4)] + ['##'+input().rstrip()+'##' for _ in range(H)] + ['#'*(W+4)] + ['#'*(W+4)]

    Ch, Cw, Dh, Dw = Ch+1, Cw+1, Dh+1, Dw+1

    usedss = [[0]*(W+4) for _ in range(H+4)]
    for x in range(H+4):
        for y in range(W+4):
            if Sss[x][y] == '#':
                usedss[x][y] = 1

    ans = 0
    vs = set([(Ch, Cw)])
    vNews = set([(Ch, Cw)])
    usedss[Ch][Cw] = 1
    while True:
        while vs:
            v2s = set()
            for x, y in vs:
                for dx, dy in dxys:
                    x2, y2 = x+dx, y+dy
                    if usedss[x2][y2]: continue
                    v2s.add((x2, y2))
                    vNews.add((x2, y2))
                    usedss[x2][y2] = 1
            vs = v2s

        if usedss[Dh][Dw]:
            print(ans)
            break

        if not vNews:
            print(-1)
            break

        vs = set()
        for x, y in vNews:
            for dx in range(-2, 3):
                for dy in range(-2, 3):
                    x2, y2 = x+dx, y+dy
                    if usedss[x2][y2]: continue
                    vs.add((x2, y2))
                    usedss[x2][y2] = 1

        ans += 1
        vNews = set(vs)


solve()


Measured memory_bytes: 99136
N = int(input())
name = ''
div = 26
while(N > 0):
    N, mod = divmod(N, div)
    if mod == 0:
        mod = 26
        N -= 1
    atoz = chr(mod+96)
    #print(mod, atoz, N)
    atoz += name
    name = atoz
print(name)

Measured memory_bytes: 9096
#include<iostream>
using namespace std;
int main(){
  string s;
  int a,b,c;
  a=b=c=0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    switch(s[i]){
      case 'a': a++; break;
      case 'b': b++; break;
      case 'c': c++; break;
    }
  }
  if(abs(a-b)<=1&&abs(b-c)<=1&&abs(c-a)<=1){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}


Measured memory_bytes: 512
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		for(int i=0; i<str.length(); i++) {
			String s=str.substring(i,(i+1));
			if(s.matches("[A-Z]")) {
				String ss=s.toLowerCase();
				System.out.print(ss);
			}else if(s.matches("[a-z]")) {
				String ss=s.toUpperCase();
				System.out.print(ss);
			}else {
				System.out.print(s);
			}
			if(i==str.length()-1) {
				System.out.println();
			}
		}
	}
}



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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3604
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...)
#endif

ll comb_mod(int n, int c) {
    ll ans = 1;

    for (int i = n; i>n-c; --i) {
        ans = (ans * i % MOD) % MOD;
    }

    FOR(i, 1, c+1) ans = (ans * mod_inv(i, MOD)) % MOD;

    return ans;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll N, M;
    cin >> N >> M;

    unordered_map<int, int> p;
    int m = int(floor(sqrt(M)));
    int S[m+1];
    REP(i, m+1) S[i] = i;
    for(int i=2; i<m+1; ++i) {
        if (S[i] != i) continue;

        for(int j = i+i; j < m+1; j+=i) {
            S[j] = i;
        }

        int cnt = 0;
        while(M % i == 0) {
            M /= i;
            ++cnt;
        }
        p[i] = cnt;
    }
    if (M != 1) p[M] = 1;

    ll ans = 1;
    for (auto it = p.begin(); it != p.end(); ++it) {
        ans = (ans * comb_mod(it->se + N - 1, it->se)) % MOD;
    }

    cout << fixed << setprecision(20);
    cout << ans << endl;

}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Node
{
	int l,r;
}a[505];
int n;
ll MOD,f[505][505],ans;
bool cmp(Node a,Node b)
{
	if(a.l==0&&b.l==0)return a.r<b.r;
	if(a.l==0)return a.r<=b.l-1;
	if(b.l==0)return a.l-1<b.r;
	return a.l<b.l||(a.l==b.l&&a.r<b.r);
}
int main()
{
	scanf("%d%lld",&n,&MOD);
	int nowr=2*n-1,nowl=n;
	for(int i=0;i<2*n;i++)
	{
		while(i*i+nowr*nowr>4*n*n)nowr--;
		while(nowl>=0&&i*i+nowl*nowl>=n*n)nowl--;
		a[i].r=nowr;
		a[i].l=nowl+1;
	}
	sort(a,a+2*n,cmp);
	for(int x=0;x<=n;x++)
	{
		memset(f,0,sizeof(f));
		f[0][0]=1;
		int num=0;
		for(int i=0;i<2*n;i++)
		{
			for(int j=0;j<=x;j++)
			{
				if(f[i][j]==0)continue;
				f[i][j]%=MOD;
				if(a[i].l==0)f[i+1][j]+=f[i][j]*(a[i].r+1-j-num);
				else
				{
					f[i+1][j]+=f[i][j]*(a[i].r+1-i-(n-num)-(x-j));
					f[i+1][j+1]+=f[i][j]*(a[i].l-j-num);
				}
			}
			if(a[i].l==0)num++;
		}
		if(x&1)ans-=f[2*n][x];
		else ans+=f[2*n][x];
	}
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [(usize, usize); n]
    }

    let rs = a.iter().map(|x| x.0).sorted().collect_vec();
    let ls = a.iter().map(|x| x.1).sorted().collect_vec();

    let ans = if n % 2 == 1 {
        ls[n/2] - rs[n/2] + 1
    } else {
        ls[n/2-1] + ls[n/2] - rs[n/2-1] - rs[n/2] + 1
    };

    println!("{}", ans);
}


Measured memory_bytes: 12796
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }
    let mut part_s: String = s
        .chars()
        .take(3)
        .collect::<Vec<char>>()
        .iter()
        .collect::<String>();
    println!("{}", part_s);
}


Measured memory_bytes: 2108
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1<<30)

class Edge {
public:
	int t, w;
	Edge(){}
	Edge(int t,int w):t(t),w(w){}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s) {
	for (int i = 0; i < n; i++)d[i] = INFTY;
	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	int u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		for (int i = 0; i < G[u].size(); i++) {
			Edge e = G[u][i];
			if (d[e.t] == INFTY) {
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

void solve() {
	bfs(0);
	int maxv = 0;
	int tgt = 0;
	for (int i = 0; i < n; i++) {
		if (maxv < d[i]) {
			maxv = d[i];
			tgt = i;
		}
	}

	bfs(tgt);
	maxv = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] == INFTY)continue;
		maxv = max(maxv, d[i]);
	}

	cout << maxv << endl;
}

main() {
	int s, t, w;
	cin >> n;

	for (int i = 0; i < n - 1; i++) {
		cin >> s >> t >> w;

		G[s].push_back(Edge(t, w));
		G[t].push_back(Edge(s, w));
	}
	solve();
}


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

int main() {
  
  int N; cin >> N; int tmp = 0; int count = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  for (int i = 0; i < N - 1; i++) {
    
    if (vec[i + 1] <= vec[i]) tmp++;
    
    else tmp = 0;
    
    count = max(count, tmp);
    
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
using namespace std;
using lli = long long ;

int n,a[300000];
lli fs[300001],bs[300001];

void f() {
	priority_queue<lli,vector<lli>,greater<lli>> que;
	lli sum=0;
	for(int i=0;i<3*n;i++) {
		sum += a[i]; que.push(a[i]);
		while(sz(que)>n) {
			sum -= que.top();que.pop();
		}
		fs[i] = sum;
	}
}
void g() {
	priority_queue<lli> que;
	lli sum=0;
	for(int i=3*n-1;i>=0;i--) {
		sum += a[i]; que.push(a[i]);
		while(sz(que)>n) {
			sum -= que.top();que.pop();
		}
		bs[i] = sum;
	}
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<3*n;i++) scanf("%d",a+i);
	
	f(); g();

	lli mx=-1e18;
	for(int i=n-1;i<2*n;i++) {
		mx = max(mx,fs[i]-bs[i+1]);
	}
	printf("%lld\n",mx);

	return 0;
}


Measured memory_bytes: 7920
#include<cstdio>
#include<cstring>
char a[200] , b[200] ;
int lena , lenb;
int main(){
	memset(a , 0 ,sizeof a);
	memset(b , 0 ,sizeof b);
	scanf("%s%s",&a,&b);
	lena = strlen(a);
	lenb = strlen(b);
	if(lena == lenb){
		for(int i = 0;i < lena;i++){
			if(a[i] == b[i]){
				if(i == lena - 1 && a[i] == b[i]){
					printf("EQUAL");
				}
				else continue;
				}
			else if(a[i] > b[i]){
				printf("GREATER\n");break;
				}
			else printf("LESS\n");break;
			}
		}
	else if(lena > lenb)printf("GREATER\n");
	else printf("LESS\n");
	return 0;
	}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int n, ans = 0, dp[200010][2] = {};
int main() {
  string s;
  cin >> s;
  n = s.length();
  ans = n;
  dp[0][0] = 1;
  dp[0][1] = -500000;
  dp[1][1] = 1;
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i][1] = -500000;
    dp[1][1] = 1;
    if (s[i] != s[i - 1]) {
      dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
    }
    if (i >= 2) {
      dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1);
      dp[i][1] = max(dp[i][1], dp[i - 2][0] + 1);
    }
    if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) {
      dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
    }
  }
  printf("%d\n", max(dp[n - 1][0], dp[n - 1][1]));
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std
;int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  c*=2;
  if(c>a+b)c=a+b;
  if(x>y)cout << y*c+(x-y)*min(c,a);
  else cout << x*c+(y-x)*min(c,b);
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
struct node{
    int cnt[26];
    node* next[26];
    node(){
        for(int i = 0; i < 26; i++){
            cnt[i] = 0;
            next[i] = NULL;
        }
    }
}*root;
        
        void insert(string str){
            int count[26] = {0};
            for(int i = 0; i < str.length(); i++)
                count[str[i]-'a']++;

            node* cur = root;
            for(int i = 0; i < str.length(); i++){
                for(int j = 0; j < 26; j++){
                    cur->cnt[j] += bool(count[j]);
                }

                int c = str[i]-'a';
                count[c]--;
                // cur->cnt[c]--;
                if(cur->next[c] == nullptr)
                    cur->next[c] = new node();
                cur = cur->next[c];
            }
        }
        int go(string str){
            node* cur = root;
            for(int i=  0; i < str.length()-1; i++){
                cur = cur->next[str[i]-'a'];
            }
            return cur->cnt[str.back() - 'a']-1;
        }

        void solve(){
            root = new node();
            ll n;
            cin>>n;
            vector<string> vec(n);
            for(int i = 0; i < n; i++){
                cin>>vec[i];
                reverse(vec[i].begin(), vec[i].end());
                insert(vec[i]);
            }
            int ans = 0;
            for(int i = 0;i < n; i++)
                ans += go(vec[i]);

            cout<<ans;
            // insert("abcxyx");
        }
        int main(){ 
                hs;
                ll t;
                t=1;
                // cin>>t;
                for (int i=1; i<=t; i++){
                        //cout<<"Case #"<<i<<": ";
                        solve();
                 }
return 0; 
}         



Measured memory_bytes: 316644
#ABC132 B
N, L = (int(_) for _ in input().split())
Dmin = 1000
Dsum = 0
for i in range(N):
    D = L + i
    Dsum += D
    Dmin = min(abs(D), Dmin)
if D < 0:
    print(Dsum + Dmin)
else:
    print(Dsum - Dmin)

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

using namespace std;

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

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

bool f[3];

int main(){
    migmig
    int a , b;
    cin >> a >> b;
    a -- , b -- ;
    f[a] = 1;
    f[b] = 1;
    if(!f[0]){
        cout << 1;
    }
    if(!f[1]){
        cout << 2;
    }
    if(!f[2]){
        cout << 3;
    }


    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b);
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,r;cin >> n >> r;
    cout << r+100*max(0,10-n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,j,f1,f2,f3;
	char s[85],k1[]="this",k2[]="that",k3[]="the";
	while(fgets(s,85,stdin)!=NULL){
		while(1){
			for(i=0;i<strlen(s);i++){
				if(s[i]>='a' && s[i]<'z'){
					s[i]++;
				}else if(s[i]=='z')s[i]='a';
			}
			for(i=0;i<strlen(s);i++){
				f1=f2=f3=0;
				if(i>=3-1){
					for(j=2;j>=0;j--){
						if(s[i-j]==k3[2-j])f3++;
						else break;
					}
					if(f3==3)break;
				}
				if(i>=4-1){
					for(j=3;j>=0;j--){
						if(s[i-j]==k2[3-j])f2++;
						else break;
					}
					if(f2==4)break;
					for(j=3;j>=0;j--){
						if(s[i-j]==k1[3-j])f1++;
						else break;
					}
					if(f1==4)break;
				}
			}
			if(f1==4 || f2==4 || f3==3){
				printf("%s",s);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
n,m = [int(i) for i in input().split()]

nl = [[int(i) for i in input().split()] for _ in range(n)]
ml = [[int(i) for i in input().split()] for _ in range(m)]

for i in nl:
    ans = 0
    dist = 10 **18
    for idx,j in enumerate(ml):
        if dist > abs(i[0] - j[0]) + abs(i[1] - j[1]):
            dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
            ans = idx + 1
    print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	int N;
    int[] h;
    int K;
	public static void main(String[] args) {
        (new Main()).run();
    }
    
    void run(){
        input();
        int[] dp = new int[N+1];
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = Math.abs(h[1] - h[2]);
        
        for(int i=3; i<=N; i++){
            int min = Integer.MAX_VALUE;
            for(int k=(i-K <1 ? 1 : i-K); k<i; k++){
                //System.err.println(i+":"+k);
                int tmp = dp[k] + Math.abs(h[k] - h[i]);
                if(tmp < min){
                    min = tmp;
                }
            }
            dp[i] = min;
        }
        System.out.println(dp[N]);
    }
	void input(){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        h = new int[N+1];
        for(int i=1; i<=N; i++){
            h[i] = sc.nextInt();
        }
	}
}

Measured memory_bytes: 58808
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = abs(i - (n - 1 - i));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(a != b){
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for(int i=0; i<n/2; ++i){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=100+5;
int n,m;
int a[N][N],dp[N][N];
void print()
{
	int i,j;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
			cout<<a[i][j]<<" ";	
		cout<<endl;
	}

}
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i,j;
	scanf("%d %d ",&n,&m);
	char c;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			c=getchar();
			if(c=='.') a[i][j]=1;
			else a[i][j]=2;
		}		
		c=getchar();
	}
	
//	print();
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
			dp[i][j]=INF;
	}
	dp[0][1]=dp[1][0]=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
		{
			if(a[i][j]==1)
			{
				dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
			}
			else
			{
				dp[i][j]=min(dp[i][j-1]+(a[i][j]!=a[i][j-1]),dp[i-1][j]+(a[i][j]!=a[i-1][j]));			
			}
		}
//	for(i=1;i<=n;i++)
//	{
//		for(j=1;j<=n;j++)
//			cout<<dp[i][j]<<" ";	
//		cout<<endl;
//	}	
	cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 384
a, b, k = map(int,input().split())

for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += a//2
        a //= 2
    
    else:
        if b%2 == 1:
            b -= 1
        a += b//2
        b //= 2

print(a,b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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 all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

int main() {
    int n, m; cin >> n >> m;
    auto res = factor(m);
    combination cm(1000000);
    mint ans = 1;
    rep(i,res.size()) {
        ans *= cm(n+res[i].second-1,res[i].second);
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll a[n];

    ll cnt = 0;
    rep(i,0,n){
        cin >> a[i];
        while(a[i] % 2 == 0){
            cnt++;
            a[i] /= 2;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3672
package main

import "fmt"

func main() {
    var a, b, c, x int
    fmt.Scan(&a, &b, &c, &x)

    cnt := 0

    for i := 0; i <= a; i++ {
        for j := 0; j <= b; j++ {
            for k := 0; k <= c; k++ {
                if i*500+j*100+k*50 == x {
                    cnt++
                }
            }
        }
    }

    fmt.Println(cnt)
}

Measured memory_bytes: 512