akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    reverse(all(S));
    if (S.size() == 0) {
        cout << "YES" << endl;
        return 0;
    } else if (S.size() <= 2) {
        cout << "NO" << endl;
        return 0;
    }
    ll p = 2;
    string T;
    while (p < S.size()) {
        if (S[p] == 'e') {
            p += 5;
            T = "dream" + T;
        } else if (S[p] == 'm') {
            p += 7;
            T = "dreamer" + T;
        } else if (S[p] == 'a') {
            p += 5;
            T = "erase" + T;
        } else if (S[p] == 's') {
            p += 6;
            T = "eraser" + T;
        } else {
            break;
        }
    }
    reverse(all(S));
    if (T == S) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 704
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <iostream>

using namespace std;
typedef long long ll;

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

void calc(int r){
    int w[2],h[2],x[2],y[2],l[2][500][500],c,a,b,s[2][100001]={0},ans=1000000000;
    bool kaku[2][500][500]={0};
    pair<int,pair<int,int> > pp;
    
    for(int k=0;k<2;k++){
        priority_queue<pair<int,pair<int,int> > > pq;
        
        scanf("%d%d%d%d",&w[k],&h[k],&x[k],&y[k]);
        
        for(int i=0;i<h[k];i++)
            for(int j=0;j<w[k];j++)
                scanf("%d",&l[k][i][j]);
        
        pq.push(make_pair(-1,make_pair(y[k]-1,x[k]-1)));
        s[k][0]=0;
        kaku[k][y[k]-1][x[k]-1]=true;
        c=0;
        
        for(int i=1;i<=min(w[k]*h[k],r);i++){
            pp = pq.top();
            pq.pop();
            
            c=max(c,-pp.first);
            s[k][i]=c;
            
            for(int j=0;j<4;j++){
                a = pp.second.first+mo[j];
                b = pp.second.second+mo[j+1];
                if(0<=a && a<h[k] && 0<=b && b<w[k])
                    if(!kaku[k][a][b]){
                        pq.push(make_pair(-l[k][a][b],make_pair(a,b)));
                        kaku[k][a][b]=true;
                    }
            }
        }
    }
    
    for(int i=0;i<=r;i++){
        if(i<=w[0]*h[0] && r-i<=w[1]*h[1])
            ans=min(ans,s[0][i]+s[1][r-i]);
    }
    printf("%d\n",ans);
    
    return;
}

int main(){
    int r;
    
    while(1){
        scanf("%d",&r);
        
        if(r==0) break;
        
        calc(r);
    }
}

Measured memory_bytes: 4552
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  if (N == 1 and M == 0) {
    cout << 0;
    return 0;
  }
  vector<int> S(N + 1, -1);
  int tmp;
  int tmps;
  int flag = 0;  //-1を出力しなきゃ！
  //暫定の桁ごとの数字
  for (int i = 1; i <= M; i++) {
    cin >> tmp;
    cin >> tmps;
    if (tmp == 1 and tmps == 0 and N == 1 and M == 1) {
      
        cout << 0;
        return 0;
      
    }
    if (S[tmp] != -1 and S[tmp] != tmps) {
      flag = 1;
    }
    S[tmp] = tmps;
  }
  int zf = 0;  // 0フラグ
  int pzf = 0;
  for (int i = 1; i <= N; i++) {
    pzf = 0;
    if (S[i] == 0) {
      if (zf == 0) {
        flag = 1;
      }

    } else {
      pzf = zf;
      zf = 1;
    }
    if (S[i] == -1) {
      if (pzf == 0) {
        S[i] = 1;
        zf = 1;
      } else {
        S[i] = 0;
      }
    }
  }
  if (flag == 0) {
    for (int i = 1; i <= N; i++) {
      cout << S[i];
    }
  } else {
    cout << -1;
  }
  return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;
  priority_queue<llong> A;

  llong a;
  for(int i=0;i<N;i++) {
    cin >> a;
    A.push(a);
  }

  for(int i=0;i<M;i++) {
    a = A.top(); A.pop();
    a /= 2;
    A.push(a);
  }

  llong ans=0;
  for(int i=0;i<N;i++) {
    ans += A.top();
    A.pop();
  }

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

//keyword:priority queue


Measured memory_bytes: 1400
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a[10000],ans=0.0,fans;
long long int i,n;

cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
    ans+=1/a[i];

}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//

        int N, Q;
        cin >> N >> Q;
        string S;
        cin >> S;
        vector<int> l(Q), r(Q);
        for (int i = 0; i < Q; i++)
        {
                cin >> l[i] >> r[i];
        }
        // A C A C A A C
        //0 0 1 1 2 2 2 3
        // 1 2 3 4 5 6 7
        vector<int> sum(N + 1, 0);
        for (int i = 1; i < N + 1; i++)
        {
                sum[i + 1] = sum[i];
                if (S[i - 1] == 'A' && S[i] == 'C')
                {
                        sum[i + 1]++;
                }
        }

        for (int i = 0; i < Q; i++)
        {
                cout << sum[r[i]] - sum[l[i]] << endl;
        }

        return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        int n;
        int m;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
        }

        int answer = n * (n - 1) / 2 + m * (m - 1) / 2;
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
S = gets.chomp
w = []
S.size.times do |x|
  w << S[x]
end
# p w
w.sort!
dup = false
(0..(S.size-2)).each do |x|
  if w[x] == w[x+1] then
    dup = true
    break
  end
end
if dup then
  puts 'no'
else
  puts 'yes'
end


Measured memory_bytes: 1788
n,k=map(int,input().split())

M=[n]*(n+1)
m=[0]*(n+1)
for i in range(1,n+1):
    M[i]=M[i-1]+n-i
    m[i]=m[i-1]+i

mod=10**9+7
ans=0
for i in range(k-1,n+1):
    tmp=M[i]-m[i]+1
    ans=(ans+tmp)%mod
ans=ans%mod
print(ans)

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

int main(void){
    int N;
    cin>>N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin>>A[i];
    vector<int> num(1e5+10,0);
    for (int i=0;i<N;i++) num[A[i]]++;
    int nn=0;
    for (int i=0;i<1e5+5;i++) if (num[i]) nn++;
    if (nn%2==0) nn--;
    cout<<nn<<endl; 
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	REP(i, n){
		int k;
		cin >> k;
		REP(j, k){
			int a;
			cin >> a;
			mp[a]++;
		}
	}

	int ans = 0;

	for (auto x : mp){
		if (x.second == n) ans++;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1e9+7;
const int N = 3e3+10;

vector<int> cur(N),nex(N);

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        
   int n;
    cin >> n;
    
   string s;
    cin >> s;
    
   
   for(int i=1;i<=n;i++) cur[i] = 1;
    
   for(int i=0;i<n-1;i++)
   {
       if(s[i] == '<')
           for(int j=1;j<=i+2;j++) nex[j] = (nex[j-1] + cur[j-1])%MOD; 
       else
           for(int j=1;j<=i+2;j++) nex[j] = ( (nex[j-1] + cur[i+2] - cur[j-1])%MOD +MOD)%MOD;
       
       nex[i+3] = nex[i+2];
       
       swap(cur,nex);
   }
    
   cout << cur[n]; 
}

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

int main(){
  int N;
  cin >> N;
  vector <int> v(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> v.at(i);
    sum+=v.at(i)-1;
  }
  cout << sum <<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  vector<pair<int64_t, int>> change(M);
  for(int i = 0; i < M; i++) {
    int64_t c;
    int b;
    cin >> b >> c;
    change.at(i) = make_pair(-c, b);
  }
  sort(change.begin(), change.end());
  int keep = 0;
  bool judge = false;
  for(int i = 0; i < M; i++) {
    int64_t c = (-1) * change.at(i).first;
    int b = change.at(i).second;
    for(int j = keep; j < min(keep + b, N); j++) {
      if(data.at(j) < c) {
        data.at(j) = c;
      }
      else {
        judge = true;
        break;
      }
    }
    if(judge) {
      break;
    }
    keep += b;
    if(keep >= N) {
      break;
    }
  }
  int64_t ans = 0;
  for(int i = 0; i < N; i++) {
    ans += data.at(i);
  }
  cout << ans << endl;   
}


Measured memory_bytes: 5568
#include<stdio.h>

void initialize(char array[], int n);
int adventure(char tile, int *x, int *y);
void output(int x, int y, int flag);

main()
{
	int i = 0, j = 0;
	int x = 0, y = 0;
	int h = 0, w = 0;
	while(1)
	{
		i = 0, j = 0, x = 0, y = 0, h = 0, w = 0;
		scanf("%d %d", &h, &w); //h,wの値を取得
		//printf("h = %d w = %d\n", h, w); //デバッグ用
		char room[h][w]; //タイルの状態を代入する配列
		for(i = 0; i < h; i++) //初期化を行う
		{
			initialize(room[i], w); //初期化関数の呼び出し
		}
		if((h == 0) && (w == 0)) //h=0,w=0ならばループを抜ける
		{
			break;;
		}
		for(i = 0; i < h; i++)
		{
			scanf("\n");
			gets(room[i]); //getsで横1列ずつタイルの状態を代入する
		}
		int limit = 3 * (h * w), limit_counter = 0, flag = 0;
		for(limit_counter = 0; limit_counter <= limit; limit_counter++)
		{
			flag = adventure(room[y][x], &x, &y);
			//printf("limit_counter = %d ", limit_counter);
			//printf("room[%d][%d] = %c\n", y, x, room[y][x]);
			if(flag == 1)
			{
				break;
			}
		}
		output(x, y, flag);
	}
	return 0;
}
void initialize(char array[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = 0x00;
	}
}
int adventure(char tile, int *x, int *y)
{
	if(tile == 0x3e)
	{
		*x += 1;
	}
	else if(tile == 0x3c)
	{
		*x -= 1;
	}
	else if(tile == 0x5e)
	{
		*y -= 1;
	}
	else if(tile == 0x76)
	{
		*y += 1;
	}
	else if(tile == 0x2e)
	{
		return 1;
	}
	return 0;
}
void output(int x, int y, int flag)
{
	if(flag == 1)
	{
		printf("%d %d\n", x, y);
	}
	else
	{
		printf("LOOP\n");
	}
}

Measured memory_bytes: 620
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var x = Read();
        var a = Read();
        Console.WriteLine(x < a ? 0 : 10);
    }

    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int Read()
    {
        int res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#define mod 1000000007
using namespace std;
int n,m;
long long x[100000],y[100000],ax=0,ay=0,ans,sx[100001],sy[100001];
int main(){
    
    scanf("%d %d",&n,&m);
    sx[0]=sy[0]=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&x[i]);
        sx[i+1]=sx[i]+x[i];
        sx[i+1]%=mod;
        ax+=x[i]*i-sx[i];
        ax%=mod;
    }
    for(int i=0;i<m;i++){
        scanf("%lld",&y[i]);
        sy[i+1]=sy[i]+y[i];
        sy[i+1]%=mod;
        ay+=y[i]*i-sy[i];
        ay%=mod;
    }
    printf("%lld\n",ax*ay%mod);
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0)cout << a - b << endl;
	else cout << b - a  << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

double ex(double input)
{
  double tmp = 0;
  double ans = 0;
  for (double i = 0; i <= input; i++)
  {
    tmp += (double)i;
  }
  return tmp / input;
}

int main()
{
  cout.precision(15);
  ll N, K;
  cin >> N >> K;
  vector<double> p(N + 1);
  vector<double> Ex(N + 1);
  vector<double> ans(N + 1);
  // for (ll i = 0; i < N; i++)
  // {
  //   cin >> p.at(i);
  //   Ex.at(i) = ex(p.at(i));
  // }
  // ans.at(0) = Ex.at(0);
  // for (ll i = 1; i <= N; i++)
  // {
  //   ans.at(i) += ans.at(i - 1) + Ex.at(i);
  // }

  ll a;
  double total = 0;
  ans.at(0) = 0;
  for (ll i = 1; i <= N; i++)
  {
    cin >> a;
    total = 0.0;
    for (int j = 1; j <= a; j++)
    {
      total += (double)j;
    }
    total /= (double)a;
    ans.at(i) = total + ans.at(i - 1);
  }

  double max_ = 0;
  for (ll i = 0; i <= N - K; i++)
  {
    if (max_ < ans.at(i + K) - ans.at(i))
    {
      max_ = ans.at(i + K) - ans.at(i);
    }
  }
  cout << max_ << endl;

  return 0;
}


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


signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
    
    return 0;
}


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

int main()
{
    int k, x;
    cin >> k >> x;

    int L = max(-100000, x - k + 1);
    int R = min(100000, x + k - 1);

    for(int i=L; i<=R; i++)
        cout << i << " ";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define All(X)      (X).begin(),(X).end()

ll int INF = 10000000023;

int main(){
	int n;
	int a[100000];
	ll int dp[100010];
	cin >> n;
	REP(i,n) cin >> a[i];
	REP(i, n+1) dp[i] = INF;


    REP(i,n){
    	int j = 0;
    	ll int* p = lower_bound(dp, dp + n, a[i]);
   		*p = a[i];
    }

  ll int* p = lower_bound(dp, dp + n, INF);
  cout << p - dp << endl;
  return 0;
}

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

int main() {
	char x,y,z,a;
	cin>>x;
	cin>>y;
	cin>>z;
	cin>>a;
	if(x!=y&&y!=z&&z!=a){
	cout<<"Good";
	}
	else{
		cout<<"Bad";
	}
	return 0;
}

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

main () {
  int n;
  scanf("%d", &n);

  //それぞれの入力に対して素因数分解したときに2を幾つ含むかを求める。
  //その和が答えとなる。
  int ans = 0;
  rep(i,n) {
    int a;
    scanf("%d", &a);
    while((a&1) == 0) {
      a >>= 1;
      ans++;
    }
  }
  printf("%d\n", ans);

  return 0;
}


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

const ll int INF = 1e18 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;
    cin>>n;
    ll int a[n][n];
    for(ll int i=0;i<n;i++){
    	for(ll int j=0;j<n;j++){
    		cin>>a[i][j];
    	}
    }
    vector<ll int> dp(1<<n,0);
    dp[0] = 1;
    ll int MOD = 1e9 + 7;
    for(ll int i=0;i<(1<<n);i++){
    	ll int x = __builtin_popcount(i);
    	for(ll int j=0;j<n;j++){
    		if(!(i&1<<j) && a[x][j]){
    			dp[i|1<<j] = (dp[i|1<<j]+dp[i])%MOD;
    		}
    	}
    }
    cout<<dp[((1<<n)-1)];
	return 0;
}

Measured memory_bytes: 16640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 5;
int num[MaxN],vis[MaxN];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; i++){
		num[i] = 1;
		vis[i] = 0;
	}
	vis[1] = 1;
	for(int i = 1; i <= m; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		num[a]--;
		num[b]++;
		if(vis[a]) vis[b] = 1;
		if(vis[a] && !num[a]) vis[a] = 0;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(vis[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()


int main()
{	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll maxi= INT_MIN;
	maxi=(maxi*INT_MAX);
	maxi-=1000;
	maxi=max(maxi,a*c);
	maxi=max(maxi,a*d);
	maxi=max(maxi,b*c);
	maxi=max(maxi,b*d);
	cout<<maxi<<endl;
}	

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			if(!(a[i]%3==0||a[i]%5==0))
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

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

int main()
{
        ll n, k;
        cin >> n >>k;
        ll a = n%k;
        ll ans = min(a, k-a);
        cout << ans << endl;

        return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int x[101];
int y[101];
int h[101];

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

    int N;
    cin >> N;

    REP(i,1,N+1) {cin >> x[i]; cin >> y[i]; cin >> h[i];}

    int xb, yb, hb;
    REP(i,1,N+1) {
        if(h[i] > 0) {
            xb = x[i]; yb = y[i]; hb = h[i];
            break;
        }
    }

    rep(i,101) {
        rep(j,101) {
            int H = hb +abs(i -xb) +abs(j -yb);
            bool ok=true;
            REP(k,1,N+1) if(max(H -abs(i -x[k]) -abs(j -y[k]), 0) != h[k])
                ok=false;

            if(ok){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/dp/tasks/dp_c

n = int(input())

acts = []
for i in range(n):
    a, b, c = map(int, input().split())
    acts.append((a, b, c))

dp = [acts[0][0], acts[0][1], acts[0][2]]

for i in range(1, n):
    act = acts[i]
    m = [0] * 3
    # i implies curr day
    # j implies prev day
    for i in range(3): 
        temp = []
        for j in range(3):
            if i != j:
                temp.append(act[i] + dp[j])
        m[i] = max(temp)
    dp = m
print(max(dp))



Measured memory_bytes: 62040
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]

dp = [[[-10**10]*(320) for j in range(100)] for i in range(N)]
#dp[i個までで][j個もって][余り部分kの重さ]の時の価値最大値

dp[0][0][0] = 0
dp[0][1][0] = wv[0][1]
for i in range(1,N):
    for j in range(100):
        for k in range(320):
            dp[i][j][k]=dp[i-1][j][k]#持たない
            if j-1>=0 and k+wv[0][0]-wv[i][0]>=0:#持つ
                dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k+wv[0][0]-wv[i][0]]+wv[i][1])
    
ans = 0
for j in range(100):
    for k in range(320):
        if j*wv[0][0]+k <= W:
            ans = max(ans,dp[N-1][j][k])


print(ans)

Measured memory_bytes: 99756
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    vector<vector<int>> d(70, vector<int>(n)); //2^x回移動した時の移動先
    rep(i, n){
        int a; cin >> a; a--;
        d[0][i] = a;
    }
    rept(i, 1, 70){
        rep(j, n){
            int cur = j;
            cur = d[i-1][cur];
            d[i][j] = d[i-1][cur];
        }
    }
    int res = 0;
    rep(i, 70){
        if(k <=0) break;
        if(k%2==1){
            res = d[i][res];
        }
        k /= 2;
    }
    cout << res + 1 << ln;
}

Measured memory_bytes: 58972
# -*- coding: utf-8 -*-
from pprint import pprint
N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

X = 10**5+2

c_s = [[0 for _ in range(X)] for _ in range(C)]
c_t = [[0 for _ in range(X)] for _ in range(C)]

# チャンネルごとにマッピング
for s,t,c in stc:
    c_s[c-1][s] += 1
    c_t[c-1][t] -= 1

# for c in range(C):
#     pprint(c_s[c][:14])
#     pprint(c_t[c][:14])
# print()

# チャンネルごとにいもす累計
c_rec = [[0 for _ in range(X)] for _ in range(C)]
for c in range(C):
    c_rec[c][0] = c_s[c][0] + c_t[c][0]
    for i in range(1,X):
        c_rec[c][i] = c_rec[c][i-1] + c_s[c][i] + c_t[c][i]

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# チャンネルごとのスタートを0.5分ずらす
for c in range(C):
    for i in range(X-1):
        diff = c_rec[c][i+1] - c_rec[c][i]
        if diff > 0: # 負はずらさない
            c_rec[c][i] += diff

# for c in range(C):
#     pprint(c_rec[c][:14])
# print()

# 合計する
sumlist = [0 for _ in range(X)]
for c in range(C):
    for i in range(X):
        sumlist[i] += c_rec[c][i]

# pprint(sumlist[:14])

print(max(sumlist))



Measured memory_bytes: 178908
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k,t,u,v,l;
    cin>>n>>k>>t>>u>>v>>l;
    int a[l+1]={};
    rep(i,n){
        int d;
        cin>>d;
        a[d]++;
    }
    int s=0,q=0,w=0,c=0,tt=0;
    REP(i,1,l){
        (c?w:q)++;
        if(c)c--;
        if(!c&&tt)c=v,tt--;
        if(!c&&!tt&&s)s--,c=v,tt=t-1;
        if(a[i]){
            s++;
            if(!c)s--,c=v,tt=t-1;
            else if(s>k)s--,c=v,tt=t-1;
        }
    }
    cout<<(1.0*q/u+1.0*w/v)<<endl;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
 
string s, t;
 
int main()
{
	cin >> s >> t;
	bool ok = s == t;
	for (int i = 1; i < s.length() && !ok; i++)
		ok = s.substr(i) + s.substr(0, i) == t;
	printf("%s\n", ok? "Yes": "No");
	return 0;
}

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

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

 vector<int> vec(N);
 
 for(int i = 0; i < N; i++) {
   cin >> vec.at(i);
   vec.at(i) -= i + 1;
 }

  sort(vec.begin(),vec.end());
//  for(int i = 0; i < N; i++) {
//    cout << vec.at(i) << " ";
//  }
//  cout << endl;
long long mid;
 if(N % 2 == 0) {
    mid = (vec.at(N / 2) + vec.at(N / 2 - 1)) / 2;
 }else {
    mid = vec.at(N / 2);
 }

long long sum = 0;
 for(int i = 0; i < N; i++) {
   vec.at(i) -= mid;
   sum += abs(vec.at(i));
 }
 
 cout << sum << endl;


 
}



Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = sc.nextInt();

        for(int i=3;i<=n;i++){
            int x = i;
            if(x%3==0){
                System.out.print(" "+i);
                continue;
            }
            do{
                if(x%10 == 3){
                    System.out.print(" "+i);
                    break;
                }
                x /= 10;
            }while(x>0);
        }
        System.out.println();
    }
}


Measured memory_bytes: 28396
// ref: https://img.atcoder.jp/arc088/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    int N = s.size();
    
    int num=N;
    for(int i=0; i<(int)s.size()-1; ++i){
        if(s[i]!=s[i+1]){ num = min(num, max(i+1, N-i-1)); }
    }
    cout << num << endl;
    
    return 0;
}

Measured memory_bytes: 512
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"2002
2017
" => r"2032",

r"4500
0
" => r"-4500"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        r: i32,
        g: i32,
    }

    (r + ((g - r) * 2)).to_string()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
 
const int MAXN = 16;
const int H = 4;
const int W = 4;
const char C[3] = {'R','G','B'};
const int INF = 1<<28;
 
int n;
char goal[H][W];
int h[MAXN], w[MAXN];
bool vis[1<<(W*H)];
 
inline int getId(const int &x, const int &y) {
  return x + y * W;
}
 
int stamp(int state, int x, int y, int w, int h, char c) {
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      int nx = x + j;
      int ny = y + i;
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      int id = getId(nx,ny);
      state = (state & ~(1<<id));
      if(goal[ny][nx] == c) state |= (1<<id);
    }
  }
  return state;
}
 
int bfs() {
  queue<int> que;
  int vis[1<<(W*H)];
  que.push(0);
  fill(vis,vis+(1<<(W*H)), INF);
  vis[0] = 0;
  while(!que.empty()) {
    int s = que.front();
    que.pop();
    for(int k = 0; k < n; ++k) {
      for(int m = 0; m < 3; ++m) {
    for(int x = 1-w[k]; x < W; ++x) {
      for(int y = 1-h[k]; y < H; ++y) {
        int ns = stamp(s,x,y,w[k],h[k],C[m]);
        if(vis[ns] != INF) continue;
        vis[ns] = vis[s] + 1;
        que.push(ns);
        if(ns == (1<<(W*H))-1) return vis[ns];
      }
    }
      }
    }
  }
  return INF;
}
 
int main() {
  while(cin >> n) {
    for(int i = 0; i < n; ++i) {
      cin >> h[i] >> w[i];
    }
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
    cin >> goal[i][j];
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1608
from collections import deque, Counter

N,K,*abf = map(int, open(0).read().split())
ab = [abf[i:i+2] for i in range(0, len(abf), 2)]
connected = [[] for _ in range(N+1)]
m = 1000000007
for a, b in ab:
    connected[a].append(b)
    connected[b].append(a)
    
dist = [-1] * (N+1)
d = deque([1])
parents = [-1] * (N+1)
dist[1] = 0
while d:
    temp = d.popleft()
    for edge in connected[temp]:
        if dist[edge] == -1:
            d.append(edge)
            dist[edge] = dist[temp] + 1
            parents[edge] = temp
ans = K
c = Counter(parents)
for x in c.items():
    if x[0] < 1:
        continue
    elif x[0] == 1:
        for i in range(1,x[1]+1):
            ans = (ans*(K-i)) % m
    else:
        for i in range(2,x[1]+2):
            ans = (ans*(K-i)) % m
print(ans)

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

const int MAX = 1000001;
char p[MAX] = {0};

void f(){
	for(int i=2 ; i < MAX ; i++ ) p[i] = 1;
	for(int i=2 ; i*i < MAX ; i++ ){
		if( p[i] ){
			for(int j=i+i ; j < MAX ; j += i ){
				p[j] = 0;
			}
		}
	}
}

int main(){
	int n;
	f();
	while( cin >> n ){
		int ans=0;
		for(int a=1 ; a <= n ; a++ ){
			int b = n + 1 - a;
			if( p[a] && p[b] ) ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(long.Parse).ToArray();
        if (hw[0] == 1 || hw[1] == 1)
        {
            Console.WriteLine(1);
            return;
        }
        Console.WriteLine((hw[0] * hw[1] + 1) / 2);
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
main(){
  int i, j, m, N;
  int r[100];
  scanf("%d",&N);
  for(i=0;i< N;i++)
    scanf("%d",&r[i]);
  for(i=1;i<=N;i++){
    for(j=0;j<N-1;j++)
      printf("%d ",r[j]);
    printf("%d\n",r[j]);
    m=r[i];
    j=i-1;
    while(j>=0&&r[j]>m){
      r[j+1]=r[j];
      j--;
    }
    r[j+1]=m;
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int s[200001];
int n;
inline bool check(int x)
{
	int l=n-1,r=n+1;
	for(register int i=1;i<=(n<<1)-1;++i)
	  s[i]=(a[i]>=x);
	while(l>=1)
	  {
	   	if(s[l]==s[l+1]) return s[l];
	   	if(s[r]==s[r-1]) return s[r];
	   	--l;++r;
	  }
	return s[1];
}
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=(n<<1)-1;++i) scanf("%d",&a[i]);
	int l=1,r=1e8,ans=0;
	while(l<r)
	  {
	  	int mid=(l+r)>>1;
	  	if(check(mid)) l=mid+1,ans=mid;
	  	else r=mid;
	  }
	cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=105;
int n,k;
int main()
{
    int ans=0;
    cin>>n>>k;
    while(n)
    {
        ans++;
        n/=k;
    }
    if(ans==0) ans++;
    cout<<ans<<endl;
}


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

int main(void){
    int N;
    int array[100000];
    int sum = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &array[i]);
        sum += array[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (sum - array[i]) * array[i];
    }
    printf("%d\n",ans/2);
}


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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

int main() {
    int N = ni();

    set<int> s;
    REP(i, N) {
        int a = ni();
        if (s.count(a) == 0) s.insert(a);
        else s.erase(a);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	int cnt=0;
	while(1){
		if(a<=b)cnt++;
		else break;
		a*=2;
	}
	puta(cnt);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line = br.readLine();

            // ????????????????????´?????????
            // String line; // ??\???????????????????????\???
            // while ((line = br.readLine()) != null) {
            // processLine(line);
            // }
            

        	/*for( int i = 0 ; i < Integer.valueOf(line) ; i++ )
        	{
        	    double interest = initialValue * 0.05;
        	    initialValue = initialValue + interest;
        	    initialValue = initialValue / 1000;
        	    initialValue = Math.ceil(initialValue);
        	    initialValue = initialValue * 1000;
        	}*/
        	System.out.println((int)Math.pow(Integer.valueOf(line),3));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // private static void processLine(String line) {
    // System.out.println(line);
    // }
}

Measured memory_bytes: 24280
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

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

  void run() {
    for (; ; ) {
      int n, r;
      n = ni();
      r = ni();
      if (n == 0) {
        break;
      }
      ArrayList<Integer> list = new ArrayList<>();
      for (int i = 0; i < n; ++i) {
        list.add(n - i);
      }
      for (int i = 0; i < r; ++i) {
        int p, c;
        p = ni();
        c = ni();
        ArrayList<Integer> sub = new ArrayList<>();
        Iterator<Integer> ite = list.listIterator(p - 1);
        for (int j = 0; j < c; ++j) {
          int val = ite.next();
          sub.add(val);
          ite.remove();
        }
        list.addAll(0, sub);
      }

      System.out.println(list.get(0));
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h,w;

vector<string> vs;
map<string,ll> m;

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

void make(int y,int x){
    rep(i,8){
        string t = "";
        int ny = y,nx = x;
        while(1){
            t += vs[ny][nx];
            ny += dy[i];
            ny = (ny + h) % h;
            nx += dx[i];
            nx = (nx + w) % w;
            if(ny == y && nx == x)break;
        }
        m[t]++;
    }
}


int main(){
    while(cin >> h >> w&& h + w){
        vs.clear();
        vs.resize(h);
        m.clear();
        rep(i,h)cin >> vs[i];
        rep(i,h)rep(j,w)make(i,j);
        ll l = 0;
        string ans = "";
        for(auto it = m.begin();it != m.end();it++){
            if(it->second > 1){
                if(l < it->first.size()){
                    l = it->first.size();
                    ans = it->first;
                }
            }
        }
        map<string,ll>::iterator end = m.end();
        end--;
        for(auto it = m.begin();it != end;it++){
            auto nxt = it;
            nxt++;
            string s = it->first;
            string t = nxt->first;
            rep(i,min(t.size(),s.size())){
                if(s[i] != t[i]){
                    if(i != 0){
                        string buf = s.substr(0,i);
                        if(l < buf.size()){
                            // cout << s << "  " << t << endl;
                            // cout << "!!" << buf << endl;
                            l = buf.size();
                            ans = buf;
                        }
                    }
                    break;
                }
            }
        }
        if(l <= 1)cout << 0 << endl;
        else cout << ans << endl;
    }

}


Measured memory_bytes: 3504
import numpy as np
def read():
    return list(map(int, input().split()))
x, _ = read()
p = read()
rem = np.array(p) - x
count = 0
while True:
    if (-1) * count not in rem:
        print(x - count)
        break
    if count not in rem:
        print(x + count)
        break

    count += 1

Measured memory_bytes: 27352
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> value_list(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> value_list[i];
	}

	int result = 0;

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			result += value_list[i] * value_list[j];
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
#define A_MAX 1000000
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
	int x = 0;
	for(; (c<48)||(c>57);c = getchar_unlocked());
	for(; (c>47)&&(c<58);c = getchar_unlocked())
		x = 10 * x + c - 48;
    return x;
} 
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
 
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an > 1) {
            if (an == N) {
                printf("not coprime\n");
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += an;
        a[q[n]] += an;
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15428
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>

using namespace std;

int main(){
    string t;
    cin>>t;
    size_t l = t.length();

    for(int i = l-1;i>=0;i--){
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout<<t<<endl;
}  


Measured memory_bytes: 3696
import java.util.Scanner;
class Main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		// TODO Auto-generated method stub
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		if(a < b && b < c){
			System.out.println("Yes");
			}
			else {
			System.out.println("No");
			}
		
		}

}

Measured memory_bytes: 26112