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

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

	int count = 0;
	for (int i = 1; i < N; i++) {
		if (N % i == 0) {
			count += N / i - 1;
		}
		else {
			count += N / i;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5010,p=998244353,M=5000;
int C[N][N];
int main()
{
    int n,k;scanf("%d%d",&k,&n);
    C[0][0]=1;
    for(int i=1;i<=M;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<M;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
    }
    for(int i=2;i<=2*k;i++)
    {
        int x=i<=k+1?i/2:i/2-i+k+1,ans=0;
        for(int j=0;j<=x;j++)ans=(ans+1ll*(j&1?p-1:1)*C[x][j]%p*C[n-2*j+k-1][k-1])%p;
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 98176
import datetime
year=2000
month=10
day=10
h1,m1,h2,m2,K = map(int,input().split())

dt1 = datetime.datetime(year=year,month=month,day=day,hour=h1,minute=m1)
dt2 = datetime.datetime(year=year,month=month,day=day,hour=h2,minute=m2)
dt2_bef = dt2 - datetime.timedelta(minutes=K)

td = dt1 - dt2_bef

if td.days<0:
    td = dt2_bef - dt1
print(int(td.total_seconds()//60))



Measured memory_bytes: 9500
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

char a[333][333];
int n, m, k, ans[333][333], sz, row[333][333];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m >> k;
   int sz = 0;
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++) {
         cin >> a[i][j]; 
         if (a[i][j] == '#') sz ++, ans[i][j] = sz;
         row[i][j] = row[i][j - 1] + (a[i][j] == '#');
      }
   for (int i = 1; i <= n; i ++) {
      int last = 1;
      for (int j = 1; j <= m; j ++) {
         if (a[i][j] == '#') {
            for (int k = last; k <= j; k ++)
               ans[i][k] = ans[i][j];
            last = j + 1;
         }
      }
      if (last <= m && a[i][last - 1] == '#') {
         for (int j = last; j <= m; j ++)
            ans[i][j] = ans[i][last - 1];
      }
   }
   for (int i = 1; i <= n; i ++) {
      if (!row[i][m]) {
         for (int j = i - 1; j >= 1; j --) {
            if (row[j][m]) {
               for (int k = 1; k <= m; k ++)
                  ans[i][k] = ans[j][k];
               break;
            }
         }
         if (!ans[i][1]) {
            for (int j = i + 1; j <= n; j ++) {
               if (row[j][m]) {
                  for (int k = 1; k <= m; k ++)
                     ans[i][k] = ans[j][k];
                  break;
               }
            }
         }
      }
   }
   for (int i = 1; i <= n; i ++, cout << endl)
      for (int j = 1; j <= m; j ++)
         cout << ans[i][j] << ' ';
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 2432
s = input()
if s == s[::-1] and s[:(len(s) - 1) // 2] == s[:(len(s) - 1) // 2][::-1] and s[(len(s) + 3) // 2 - 1:] == s[(len(s) + 3) // 2 - 1:][::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int main(){
	int n;
	int res;
	int x, y, h, w, l;
	while(cin >> n && n){
		res = 0;
		rep(i, n) {
			cin >> x >> y >> h >> w;
			l = x + y + h;
			if(l <= 60 && w <= 2){
				res += 600;
			}else if(l <= 80 && w <= 5){
				res += 800;
			}else if(l <= 100 && w <= 10){
				res += 1000;
			}else if(l <= 120 && w <= 15){
				res += 1200;
			}else if(l <= 140 && w <= 20){
				res += 1400;
			}else if(l <= 160 && w <= 25){
				res += 1600;
			
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
int x1,x2,x3,x4,x5;
cin >> x1 >> x2 >> x3 >> x4 >> x5;
if(x1 == 0) cout << 1 << endl;
else if(x2 == 0) cout << 2 << endl;
else if(x3 == 0) cout << 3 << endl;
else if(x4 == 0) cout << 4 << endl;
else if(x5 == 0)cout << 5 << endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;
const int N=1e5;
ll ans[N];

int main()
{
    FAST
    f(i,1,101)
    {
        f(j,1,101)
        {
            f(k,1,101)
            {
                ll curr=(i+j)*(i+j)+(i+k)*(i+k)+(k+j)*(k+j);
                if(curr/2<N) ans[curr/2]++;
            }
        }
    }
    ll n;cin>>n;
    f(i,1,n+1) cout<<ans[i]<<endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MOD 1e9+7

int main(){
  char c;
  cin >> c;
  char result;
  switch(c){
    case 'A':result = 'T';
      break;
    case 'T':result = 'A';
      break;
    case 'C':result = 'G';
      break;
    case 'G':result = 'C';
      break;
  }
  cout << result << 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;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    if (n>=m) {
        for (int i=0; i<=n-m; i++) {
            for (int j=0; j<=n-m; j++) {
                int count=0;
                rep(k,m) {
                    rep(l,m) {
                        if (a[i+k][j+l]==b[k][l]) {
                            count++;
                            //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        }
                    }
                }
                if (count==m*m) {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}


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

int main() {
  long n;
  cin >> n;
  
  vector<long> a(n), b(n);
  for (int i=0; i<n; ++i) {
    cin >> a.at(i);
  }
  b=a;
  sort(a.begin(), a.end());
  
  for (long i=0; i<n; ++i) {
    if (b.at(i)==a.at(a.size()-1)) {
      cout << a.at(a.size()-2) << endl;
    } else {
      cout << a.at(a.size()-1) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

void solve(){
  string s;
  cin >> s;
  int i6, i7;
  i6 = s[5];
  i7 = s[6];
  string ans = "TBD";
  if(i6=='0' && (i7=='1' || i7=='2' || i7=='3' || i7=='4')) ans = "Heisei";
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b; cin >> a >> b;
	printf("%d %d %.12f \n",a/b,a%b,1.0*a/b);
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
const int INF = 1145141919;
#define F first
#define S second
int main(void){
    int n,m; cin>>n>>m;
    vector <vector<int>> graph(n ,vector <int>( ));
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        graph[a].push_back(b);
    }
    int sv, gv; cin>>sv>>gv;
    sv--; gv--;
    vector <vector<int>> dist(n+10 ,vector <int>(3, INF ));
    dist[sv][0] = 0;
    queue <pair <int,int> > q;
    q.push({sv, 0});
    while(!q.empty()){
        int v = q.front().F;
        int l = q.front().S;
        q.pop();
        for(int i=0;i<graph[v].size();i++){
            int nl = (l+1)%3;
            int nv = graph[v][i];
            if(dist[nv][nl]!= INF) continue;
            dist[nv][nl%3] = dist[v][l] + 1;
            q.push({nv, nl});
        }
    }
    int ans = dist[gv][0];
    if(ans == INF) ans = -1;
    else ans/=3;
    cout<<ans<<endl;
}


Measured memory_bytes: 11136
N, K = gets.split.map(&:to_i)
Vs = gets.split.map(&:to_i)
ans = 0
(K+1).times{|a|
    (K-a+1).times{|b|
        # Warning 同じ宝石を二度取ってしまっている。。。
        hand = (a + b < N) ? Vs[0...a] + Vs[([N-b,0].max)...N] : Vs
        delete_num = K - (a + b)
        tmp_ans = 0
        target = hand.sort
        # p "A=#{a} B=#{b} K=#{delete_num}"
        # p "Vs = #{Vs}"
        # p "Vs_a = #{Vs[0...a]}"
        # p "Vs_b = #{Vs[(N-b)...N]}"
        # p target
        target.each{|x|
            if (x < 0 && delete_num > 0)
                delete_num -= 1
            else 
                tmp_ans += x
            end
        }
        # p "tmp_ans = #{tmp_ans}"
        ans = [ans, tmp_ans].max
    }
}

puts ans

Measured memory_bytes: 3836
#include <stdio.h>

typedef long long ll;

int main(void) {
  ll n, m;
  scanf("%lld%lld", &n, &m);
  if(n * m == 1) printf("1");
  else if(n == 1) printf("%lld", m - 2);
  else if(m == 1) printf("%lld", n - 2);
  else printf("%lld", (n - 2) * (m - 2));
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int R;
  cin>>R;
  if(R>=2800){
    cout<<"AGC"<<endl;
  }else if(R>=1200){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int partition(double *num, int start, int end, double p);
void quicksort(double *num, int start, int end);

int main(void){
    int N = 0;
    int i = 0;
    double v[128];
    double value = 0.0;

    scanf("%d", &N);

    for(i = 0; i <N; i++){
        scanf("%lf", &v[i]);
    }

    quicksort(v, 0, N-1);

    value = v[0];

    for(i = 1; i < N; i++){
        value = (v[i]+value)/2;         
    }

    printf("%f", value);

    return 0;

}

int partition(double *num, int start,int end, double p){
    int i = start, j = end;
    double temp = 0.0;
    while(i <= j){
        while(i <= end && num[i] <= p){
            i++;
        }
        while(j >= start && num[j] > p){
            j--;
        }

        if(i > j){
            break;
        }

        temp = num[i];
        num[i] = num[j];
        num[j] = temp;

    }
    return i;
}


void quicksort(double *num, int start, int end){
    if(start == end){
        return ;
    }
    double p = num[start];
    int flg = 0;
    int base = start;
    int k = 0;
    while(base <= end){
        if(num[base] < p){
            flg = 1;
            p = num[base];
            break;
        }else if(num[base] > p){
            flg = 1;
            break;
        }
        base++;
    }

    if(flg == 1){
        k = partition(num, start, end, p);
        quicksort(num, start, k-1);
        quicksort(num, k, end);
    }
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    a=0;
    b=0;
    c=0;
    int r[10]={};
    for(int u=1;u<=10;u++){
        cin>>r[u];
        if(a<r[u]){
            c=b;
            b=a;
            a=r[u];
        }else if(b<r[u]){
            c=b;
            b=r[u];
        }else if(c<r[u]){
            c=r[u];
        }
    }
    cout<<a<<endl;
    cout<<b<<endl;
    cout<<c<<endl;
}



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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N, M;
    LL K;
    cin >> N >> M >> K;
    vector<LL> A(N), B(M);
    for(auto& a : A) {
        cin >> a;
    }
    for(auto& b : B) {
        cin >> b;
    }
    LL s = 0;
    for(int n = 0; n < N; ++n) {
        s += A[n];
    }
    int n = N - 1;
    int ans = 0;
    for(int m = 0; m <= M; ++m) {
        if(K < 0) {
            break;
        }
        while(s > K) {
            s -= A[n];
            --n;
        }
        ans = max(ans, n + 1 + m);
        if(m < M) {
            K -= B[m];
        }
    }
    cout << ans << "\n";
    
    
    return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    int sum=0;
    sum+=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    sum-=min(c,k);
    k-=min(c,k);
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        //return process2(input);

        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = long.Parse(spl[1]);

        var aa = ToIntArray(input.ReadLine(), n);
        SetArray(aa, (v, i) => v - 1);

        int idx = 0;

        while (true) {
            var z = 1L;
            var bb = CloneArray(aa);

            while (true) {
                if (z * 2 > k) break;

                var cc = new int[n];
                for (int i = 0; i < n; i++) {
                    cc[i] = bb[bb[i]];
                }
                bb = cc;
                z *= 2;
            }

            idx = bb[idx];
            k -= z;
            //Console.WriteLine(k);

            if (k == 1) return aa[idx] + 1;
            if (k == 0) return idx + 1;
        }
    }

    static T[] CloneArray<T>(T[] source) {
        var ret = new T[source.Length];
        for (int i = 0; i < source.Length; i++)
            ret[i] = source[i];
        return ret;
    }
    static void SetArray<T>(T[] array, Func<T, int, T> f) {
        for (int i = 0; i < array.Length; i++)
            array[i] = f(array[i], i);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }


    static object process2(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = long.Parse(spl[1]);

        var aa = ToIntArray(input.ReadLine(), n);
        var li = new List<Z>();
        li.Add(new Z() { c = 1, aa=aa });

        long c = 1;
        while(c * 2 < k) {
            var z = new Z();
            z.aa = new int[n];

            for(int i=0; i<n; i++) {
                z.aa[i] = aa[li.Last().aa[i]];
            }
            c *= 2;
            z.c = c;
        }

        int idx = li.Count - 1;
        int pos = 0;
        while (k > 0) {
            while (li[idx].c > k) idx--;
            k -= li[idx].c;
            pos = li[idx].aa[pos];
        }

        return pos;
    }

    class Z
    {
        public long c;
        public int[] aa;
    }
}


Measured memory_bytes: 102656
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

class Z_algorithm {

public:
	vector<int>v;
	Z_algorithm(string s) {
		v.resize(s.size(),0);
		v[0] = s.size();
		int i = 1, j = 0;
		while (i < s.size()) {
			while (i + j < s.size() && s[i + j] == s[j]) {
				j++;
			}
			v[i] = j;
			if (j == 0) {
				i++;
				continue;
			}
			int k = 1;
			while (i + k < s.size() && k + v[k] < j) {
				v[i + k] = v[k];
				k++;
			}
			i += k;
			j -= k;
		}
	}
};

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

	string s;
	cin >> s;
	string t;
	cin >> t;
	string u, v;
	u = t + s;
	v = s + t;
	reverse(v.begin(), v.end());
	Z_algorithm zu(u);
	Z_algorithm zv(v);
	int ans = 0;
	for (int i = 0; i + t.size() <= s.size(); i++) {
		ans += zu.v[i + t.size()] + zv.v[s.size() - i]+1==t.size();
	}
	cout << ans << endl;
}



Measured memory_bytes: 8364
#include <stdio.h>
#define N 100

int G[101][101],v[101],size[101];

void dfs(int p,int t){
  
  int i;
  
  v[p] = t;
  for(i = 1;i <= size[p];i++) if(t+1 < v[G[p][i]]) dfs(G[p][i],t+1);
  
}

int main(){
  
  int i,j,n,u;
  
  scanf("%d", &n);
  
  for(i = 1;i <= n;i++){
    v[i] = N;
    scanf("%d",&u);
    scanf("%d",&size[u]);
    for(j = 1;j <= size[u];j++) scanf("%d",&G[u][j]);
  }
  
  dfs(1, 0);
  
  for(i = 1;i <= n;i++) printf("%d %d\n",i,(v[i] == N) ? -1 : v[i]);
  
  return 0;
  
}



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

for i in range(N):
    A[i] -= i

A.sort()

Ans = 0
mi = len(A)//2 # 中央値のindex
for i in range(N):
    Ans += abs(A[i]-A[mi])

print(Ans)


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i=0; i<M; i++) {
    cin >> B.at(i);
  }
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int count=0;
  for (int i=0; i<N; i++) {
    int test=0;
    for (int j=0; j<M; j++) {
      test += A.at(i).at(j)*B.at(j);
    }
    test += C;
    if (test >0) {
      count += 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,card[4][13] = {0};
	int i, j, d;
	char m;

	scanf("%d", &n);

	for(i=0;i<n;i++){
		scanf(" %c %d", &m, &d);
		switch(m){
            case 'S' : card[0][d-1] = 1;
                        break;
            case 'H' : card[1][d-1] = 1;
                        break;
            case 'C' : card[2][d-1] = 1;
                        break;
            case 'D' : card[3][d-1] = 1;
                        break;
		}
	}

	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(card[i][j] == 0){
				switch(i){
					case 0: printf("S %d", j+1);
							break;
					case 1: printf("H %d", j+1);
							break;
					case 2: printf("C %d", j+1);
							break;
					case 3: printf("D %d", j+1);
							break;
				}	
				printf("\n");
			}
		}

	}
	return 0;
}

Measured memory_bytes: 600
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
size_t strlen(const char* s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
struct ToUpper {
	char operator()(char c) { return toupper(c); }
};
struct ToLower {
	char operator()(char c) { return tolower(c); }
};
const int N = 200010;
const int P = 1000000007;
using ll = long long;

//絶対値
int ze(int a, int b) {
	if (a > b) {
		return a - b;
	}
	else {
		return b - a;
	}
}
//小さい方
long long int min(long long int a, long long int b) {
	if (a > b) {
		return b;
	}
	else {
		return a;
	}
}
//大きい方
long long int max(long long int a, long long int b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod) {
	return (a * b) % mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/

/*
	char s[N];
	strlen(s)
*/

/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

/*添字1がa個、2がb個
  vector<vector<ll>> map(a,vector<ll>(b));
*/

int main() {
  ll x,k,d;
  cin>>x>>k>>d;
  if(x<0){
    x=-x;
  }
  if(x/d>k){
    cout<<x-k*d<<endl;
  }else{
    if((k-(x/d))%2==0){
      cout<<x%d<<endl;
    }else{
      cout<<d-(x%d)<<endl;
    }
  }
}

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

int gcd(int x,int y){
  while(x%y){
    if(x<y){
      swap(x,y);
    }
    x=x%y;
  }
  return y;
}

int main(){
  int x,y,z;
  cin >> x >> y;

  z=gcd(x,y);

  cout << z << "\n";

  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,m,i,j,a,b;cin>>n>>m;char c;
    string s,r="snuke";
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>s;
            if(s==r){
                a=i;b=j;
            }
        }
    }c=char(65+b);
    cout<<c<<a+1;

    return 0;
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,x,y;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<=10 && b<=10 && c<=10 && d<=10){
            x=a+b;
            y=c+d;
            if(x==y){
                printf("Balanced");
            }
            else if(x>y){
                printf("Left");
            }
            else
                printf("Right");

    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,mx=0;
	cin >>n;
	vector<vector<int>>a(2,vector<int>(n,0));
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++)
			cin >> a.at(i).at(j);
	for(int i=0;i<n;i++){
		int l=0,sum=0;
		for(int j=0;j<n;j++){
			sum += a.at(l).at(j);
			if(i==j){
				l=1;
				sum += a.at(l).at(j);
			}
		}
		mx = max(mx,sum);
	}
	cout << mx << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int n,m;cin>>n>>m;
   Graph G(n);
   rep(i,m){
       int a,b;cin>>a>>b;
       a--;b--;
       G[a].push_back(b);
       G[b].push_back(a);
   }
   rep(i,n){
       cout<<G[i].size()<<endl;
   }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct SCC{
	vector<vector<int> > G;
	vector<vector<int> > rG;
	vector<int> vs;
	vector<bool> used;
	vector<int> cmp;
	int sz,newsz;
	SCC(int n):G(n),rG(n),used(n,false),cmp(n){sz = n;}
	
	//辺を張る
	void add_edge(int from,int to){
		G[from].PB(to);
		rG[to].PB(from);
	}
	
	void dfs(int v){
		used[v] = true;
		REP(i,G[v].size()){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.PB(v);
	}
	
	void rdfs(int v,int k){
		used[v] = false;
		cmp[v] = k;
		REP(i,rG[v].size()){
			if(used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}
	
	//ＳＣＣ実行
	int reMake(){
		vs.clear();
		REP(i,sz)if(!used[i])dfs(i);
		int k = 0;
		for(int i = sz-1;i >= 0;i--){
			if(used[vs[i]]){
				rdfs(vs[i],k++);
			}
		}
		return newsz = k;
	}
	
	int scc_node(int n){
		return cmp[n];
	}
};


int main(){
	int n,m;cin >> n >> m;
	
	SCC scc(n);
	
	REP(i,m){
		int a,b;cin >> a >> b;
		scc.add_edge(a,b);
	}
	
	scc.reMake();
	
	int q;cin >> q;
	
	REP(i,q){
		int a,b;cin >> a >> b;
		if(scc.scc_node(a) == scc.scc_node(b)){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
			
	return 0;
}


Measured memory_bytes: 4392
#include <iostream>
//#include

using namespace std;
const int MAX_N = 200000;
int R[MAX_N], n;

int main(){
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> R[i];
  int maxv = -2000000000;
  int minv = R[0];
  
  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  
  cout << maxv << endl;
  
  return 0;
  
  
}

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

using namespace std ;

const int MAX = 1e6 + 10 ;

int arr[MAX] , prime[MAX] ;
int n ;

void sieve()
{
	for(int i = 0 ; i < MAX ; ++i)
		prime[i] = 1 ; 
	prime[0] = prime[1] = 0 ;
	for(int i = 2 ; i < MAX ; ++i)
	{
		if(prime[i])
		{
			if(i >= n)
			{
				cout<<i<<"\n" ;
				return ;
			}
			for(int j = i+i ; j < MAX ; j += i)
				prime[j] = 0 ;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	sieve() ;
	return 0 ;
}		

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum=0;
    cin >> N;
  int t=N;
  while (t > 0)
    sum += t%(10),
    t /= 10;
  
  if (N%sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int n; cin >> n;
    vector<tuple<string, int, int>> all(n);
    for (int i=1; i<=n; i++) {
        string s;
        int p;
        cin >> s >> p;
        all[i-1] = make_tuple(s, 100-p, i);
    }
    sort(all.begin(), all.end());
    for (int i=0; i<n; i++) cout << get<2>(all[i]) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int n, x;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> x;
    priority_queue<int, vector<int>, greater<int>> q;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        q.push(a);
    }
    int cnt = 0;
    while (!q.empty()) {
        int u = q.top();
        if (q.top() > x) break;
        q.pop();
        ++cnt;
        x -= u;
    }
    if (x > 0 && q.empty()) --cnt;
    cout << cnt;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
v = gets.split.map(&:to_i)
l = [n, k].min

ans = 0

0.upto(l) do |a|
    0.upto(l - a) do |b|
        next if a + b == 0
        vv = v[0, a] + v[-b, b]
        vv.sort!
        c = k - a - b
        while c > 0 && !vv.empty? && vv[0] < 0
            vv.shift
            c -= 1
        end
        w = vv.inject(0, :+)
        ans = w if ans < w
        #p [a, b, vv]
    end
end

p ans

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

int N;
vector<long long> x, y;

int solve() {


    int res = N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for (int i2 = 0; i2 < N; ++i2) {
                for (int j2 = 0; j2 < N; ++j2) {
                    if (j2 == i2) continue;
                    if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    cout << solve() << endl;
}

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

int main() {
  string s; cin >> s;
  map<char, int> cnt_map;
  string result = "yes";
  
  for (int i = 0; i < s.size(); ++i) {
    if (cnt_map[s[i]] > 0) {
      result = "no";
      break;
    }
    ++cnt_map[s[i]];
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll d,t,s;
int main(){
	cin>>d>>t>>s;
	if(s*t>=d)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
	int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	int min = p + r;
	if (min > p + q)
		min = p + q;
	if (min > q + r)
		min = q + r;
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fcout cout << fixed << setprecision(18)

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

  double R; cin >> R;
  
  fcout << (2.0 * R * 3.14159265358979) << '\n';
  return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n;
ll sum=0;
int main() 
{
   cin>>n;
   ll a[n],i;
    for(i=0;i<n;i++)
   	 cin>>a[i];
   	ll dp[n+1];
   	memset(dp,0x3f,sizeof dp);
   	dp[1]=0;
    for(i=1;i<=n;i++)
    {
    	if(i>1)
    	    {
                dp[i]=min(dp[i],dp[i-1]+abs(a[i-1]-a[i-2]));
                //cout<<dp[i]<<" "<<i<<endl;
    	    }
    	if(i>2)
    		{
    			dp[i]=min(dp[i],dp[i-2]+abs(a[i-1]-a[i-3]));
    			// cout<<dp[i]<<" "<<i<<endl;
    		}
    		//cout<<dp[i]<<endl;

    }
    cout<<dp[n];
}


Measured memory_bytes: 1792
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define MAX 1000005
#define forci(p,q) for(int i=p;i<q;i++)
bool prime[MAX];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<MAX;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<MAX;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	double r;
	cin>>r;
	cout<<(double)3.1415926535897*2*r<<endl;
	
	
	
	
	
	
}












Measured memory_bytes: 3796
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

ll mod(ll a, ll b) {
    ll ans = a % b;
    if (ans < 0) {
        ans = b + ans;
    }
    return ans;
}

int main(void) {
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

}

/*
5 4 3 2 1
*/


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

int const N = 100000, md = 998244353;
int fr[N];

void fn(int x) { printf("%d\n", x); exit(0); }

int main(){
	int n, t;
	scanf("%d%d", &n, &t);
	if (t)fn(0);
	++fr[0];
	f(i, 1, n){
		scanf("%d", &t);
		if (t == 0)fn(0);
		++fr[t];
	}
	int an = 1;
	f(i, 1, n)f(j, 0, fr[i])an = (ll)an * fr[i - 1] % md;
	printf("%d\n", an);
}

Measured memory_bytes: 640
from collections import Counter
n = int(input())
A = Counter([int(i) for i in input().split()])
l4 = [0]
l2 = [0]

for k, v in A.items():
    if v >= 4:
        l4.append(k)
        l2.append(k)
    elif v >= 2:
        l2.append(k)
        
if max(l4) >= max(l2):
    print(max(l4) ** 2)
else:
    x = sorted(l2, reverse=True)
    print(x[0] * x[1])

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

ll atoi(char c){
    return c - '0';
}

int main(){
    string s; cin >> s;
    int k; cin >> k;
    if(k == 1){
        ll ans = 0;
        for(int i = 1; i < s.size(); i++){
            ans += 9;
        }
        ans += atoi(s[0]);
        cout << ans << endl;
        return 0;
    }else if(k == 2){
        ll ans = 0;
        for(int i = 2; i < s.size(); i++){
            ans += 9 * (i-1) * 9;
        }
         ans += (atoi(s[0])-1) * (s.size()-1) * 9;
         int f = 0;
         for(int i = 1; i < s.size(); i++){
             if(f == 1){
                 ans += 9;
             }else{
                if(atoi(s[i]) != 0){
                    f = 1;
                    ans += atoi(s[i]);
                }    
             }
         }
         cout << ans << endl;
        return 0;
    }else{
        ll ans = 0;
        ll siz = s.size();
        for(ll i = 3; i < siz; i++){
            ans += (i-1) * (i-2) / 2 * 729;
        }
        ans +=  (atoi(s[0])-1) * (siz-1) * (siz-2) / 2 * 81;
        int f = 0;
        for(ll i = 1; i < siz; i++){
            if(f == 1){
                ans += 9 * (siz-1-i) * 9;
            }else{
                if(atoi(s[i]) != 0){
                    f = 1;
                    int f2 = 0;
                    //ans += atoi(s[i]) * (siz-1-i) * 9;
                    for(ll l = i+1; l < siz; l++){
                        if(f2 == 1){
                            ans += atoi(s[i]) * 9;
                        }else{
                            if(atoi(s[l]) != 0){
                                //cout << "OK" << endl;
                                f2 = 1;
                                ans += atoi(s[l]);
                                ans += (atoi(s[i])-1) * 9;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
using System;

namespace abc144_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string res = "No";

            for (int index = 1; index <= 9; index++)
            {
                int a = n % index;
                if (a == 0)
                {
                    int b = n / index;

                    if (b <= 9)
                    {
                        res = "Yes";
                        break;

                    }

                }



            }


            Console.WriteLine(res);
        }
    }
}


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

int main(){
  int h, w;
  cin >> h >> w;
  int dp[h+1][w+1];
  for (int i=1; i<=h; ++i){
    for (int j=1; j<=w; ++j){
      char s; cin >> s;
      if (s=='#'){
        dp[i][j] = 1;
      }else{
        dp[i][j] = 0;
      }
    }
  }
  int L[h+1][w+1]={}, R[h+1][w+1]={}, D[h+1][w+1]={}, U[h+1][w+1]={};
  for (int i=1; i<=h; ++i){
    for (int j=1; j<=w; ++j){
      if (dp[i][j]){
        L[i][j]=0;
        U[i][j]=0;
      }else if (i==1 && j==1){
        L[i][j]=1;
        U[i][j]=1;
      }else if (i==1){
        L[i][j]=L[i][j-1]+1;
        U[i][j]=1;
      }else if (j==1){
        L[i][j]=1;
        U[i][j]=U[i-1][j]+1;
      }else{
        L[i][j]=L[i][j-1]+1;
        U[i][j]=U[i-1][j]+1;
      }
    }
  }
  for (int i=h; i>0; --i){
    for (int j=w; j>0; --j){
      if (dp[i][j]){
        R[i][j]=0;
        D[i][j]=0;
      }else if (i==h && j==w){
        R[i][j]=1;
        D[i][j]=1;
      }else if (i==h){
        R[i][j]=R[i][j+1]+1;
        D[i][j]=1;
      }else if (j==w){
        R[i][j]=1;
        D[i][j]=D[i+1][j]+1;
      }else{
        R[i][j]=R[i][j+1]+1;
        D[i][j]=D[i+1][j]+1;
      }
    }
  }
  int ans = 0;
  for (int i=1; i<=h; ++i){
    for (int j=1; j<=w; ++j){
      ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]);
    }
  }
  cout << ans-3 << endl;
  return 0;
}

Measured memory_bytes: 78464
import sys
sys.setrecursionlimit(10**7)
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for x,y in XY:
    x,y = x-1,y-1
    es[x].append(y)
    es[y].append(x)

def grundy(v,p=-1):
    x = 0
    for to in es[v]:
        if to==p: continue
        x ^= (grundy(to,v) + 1)
    return x
print('Alice' if grundy(0) else 'Bob')

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

typedef long long ll;
typedef unordered_map <int, int> umap;

const int MAXN = 1e5 + 5;
const int MOD = 998244353;

int N;
umap G1, G2, G3;
vector <int> adj[MAXN];
int pot[MAXN];
int mex[MAXN];

inline void add(int &x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
}

inline int mul(int x, int y) {
	return (ll)x * y % MOD;
}

int dfs(int x) {
	if (mex[x] != -1)
		return mex[x];
	umap occ;
	for (auto it : adj[x])
		occ[dfs(it)] = 1;
	occ[-1] = 1;
	while (occ[mex[x]])
		mex[x]++;
	return mex[x];
}

void input(umap &G) {
	memset(mex, -1, sizeof mex);
	for (int i = 1; i <= N; i++)
		adj[i].clear();
	int M;
	scanf("%d", &M);
	while (M--) {
		int a, b;
		scanf("%d%d", &a, &b);
		adj[min(a, b)].push_back(max(a, b));
	}
	for (int i = 1; i <= N; i++)
		add(G[dfs(i)], pot[i]);
}

void load() {
	scanf("%d", &N);
	pot[0] = 1;
	for (int i = 1; i <= N; i++)
		pot[i] = mul(pot[i - 1], (ll)1e18 % MOD);
	input(G1);
	input(G2);
	input(G3);
}

int solve() {
	umap conv;
	for (auto it1 : G1)
		for (auto it2 : G2)
			add(conv[it1.first ^ it2.first], mul(it1.second, it2.second));
	int sol = 0;
	for (auto it : G3)
		add(sol, mul(conv[it.first], it.second));
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 6016
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    from collections import Counter
    M = max(A) + 1
    B = [True] * (M+1)
    A = sorted(A)
    C = Counter(A)

    answer = 0
    for a in A:
        if B[a]:
            for j in range(a, M, a):
                B[j] = False
            if C[a] > 1:
                continue
            else:
                answer += 1

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 121612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	r := nextInt()
	g := nextInt()
	b := nextInt()
	k := nextInt()

	if r < g && g < b {
		fmt.Println("Yes")
		return
	}
	for i := 0; i < k; i++ {
		// rは放置
		// gがrより大きくなるまでgをふやす
		if r >= g {
			g *= 2
			if r < g && g < b {
				fmt.Println("Yes")
				return
			}
		} else if g >= b {
			b *= 2
			if r < g && g < b {
				fmt.Println("Yes")
				return
			}
		}

	}

	fmt.Println("No")

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    
    let mut dp = vec![vec![0; 2]; s.len() + 3];
    
    dp[0][0] = 1;
    dp[1][1] = 1;
    use std::cmp::max;
    
    for i in 1 .. s.len() {
    	// 1 -> 1
        if s[i-1] != s[i] && dp[i-1][0] > 0 {
            dp[i][0] = max(dp[i][0], dp[i-1][0]+1);
        }
        // 2 -> 1
        if dp[i-1][1] > 0 {
            dp[i][0] = max(dp[i][0], dp[i-1][1]+1);
        }
        // 1 -> 2
        if i+1 < s.len() &&  dp[i-1][0] > 0 {
            dp[i+1][1] = max(dp[i+1][1], dp[i-1][0]+1);
        }
        // 2 -> 2
        if i+1 < s.len() && dp[i-1][1] > 0 && s[i-2..i] != s[i..i+2] {
            dp[i+1][1] = max(dp[i+1][1], dp[i-1][1]+1);
        }
    }
    println!("{}", max(dp[s.len()-1][0], dp[s.len()-1][1]));
    // println!("{:?}", dp);
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "dddd"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll mod = 1e15 + 7;
using namespace std;
const int N = 35;
const int M = 5e6;
ll tong, m, n, k, t, T, ntest, ans, h[N], bit[N][N], a[M], b[M], c[M];
char ch[N][N];
struct dang
{
    ll id;
    vector<int> vc;
};
string s;
vector<ll> adj[N], adt[N];
vector<ll> pre;
list<pll> ds;

inline void sol()
{
    for(int i = 0; i < 4; i ++)cin >> a[i];
    cout << max(max(max(a[0] * a[2], a[1] * a[2]), a[0] * a[3]), a[1] * a[3]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    sol();
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  int n;
  cin >> n;
  string s;
  cin >> s;
  s = ' ' + s;
  int p = n;
  int cntr = 0;
  for (int i = 1; i <= n; i++)
    cntr += (s[i] == 'R');
  int ans = 0;
  for (int i = 1; i <= cntr; i++) {
    if (s[i] == 'W')
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3876