akhauriyash/Code-Regression huggingface dataset:
#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 main()
{
        string S;
        cin >> S;
        string T = "ACGT";
        int now = 0;
        int ans = 0;

        for (int i = 0; i < S.size(); i++)
        {
                bool ok = false;

                for (int j = 0; j < T.size(); j++)
                {
                        if (S[i] == T[j])
                        {
                                ok = true;
                        }
                }
                if (!ok)
                {
                        now = 0;
                }
                else
                {
                        now++;
                        ans = max(now, ans);
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,count=0,aaa[100],i,j,temp;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&aaa[i]);
  }

  for(i=0;i<=n;i++){
    for(j=n-1;0<j;j--){
      if(aaa[j-1]>aaa[j]){
	temp=aaa[j];
	aaa[j]=aaa[j-1];
	aaa[j-1]=temp;
	count++;
      }
    }
  }

  for(i=0;i<n-1;i++){
    printf("%d ",aaa[i]);
  }
  printf("%d\n",aaa[n-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2104
def sol(inp=input):
    a,b,c,d=map(int,inp().split())
    def gcd(x,y):
        while y>0:
            x,y=y,x%y
        return x
    def fix_min(b):
        c_=b//c
        d_=b//d
        cd_=b//(c*d//gcd(c,d))
        return b-c_-d_+cd_
    return fix_min(b)-fix_min(a-1)
print(sol())

Measured memory_bytes: 38256
S = input()
if S == "SUN":
  print("7")
elif S == "MON":
  print("6")
elif S == "TUE":
  print("5")
elif S == "WED":
  print("4")
elif S == "THU":
  print("3")
elif S == "FRI":
  print("2")
else:
  print("1")


Measured memory_bytes: 2940
#include<iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int X = x2 - x1;
	int Y = y2 - y1;

	int x3 = x2 - Y;
	int y3 = y2 + X;
	int x4 = x3 - X;
	int y4 = y3 - Y;


	cout << x3<<" "<<y3<<" "<<x4<<" "<<y4 << endl;

	return 0;


}



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

int main() {

	map<int, char> rankMap = {
		{100, 'A'},
		{80,  'B'},
		{65,  'C'},
		{50,  'D'},
		{30,  'F'},
	};

	for (;;) {
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		if (m == -1 || f == -1) {
			cout << "F" << endl;
			continue;
		}
		auto it = rankMap.lower_bound(m + f);
		char rank = ((it->first == m + f) ? ++it : it)->second;
		if (rank == 'D' && r >= 50) {
			rank = 'C';
		}
		cout << rank << endl;
	}

	return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
char buf[100005];

int main(){

	scanf("%d",&N);
	scanf("%s",buf);

	char pre = '@';
	int ans = 0;

	for(int i = 0; i < N; i++){
		if(buf[i] == pre)continue;

		ans++;
		pre = buf[i];
	}

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

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  u64 a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  u64 ans = 0;
  u64 aa = a*8, bb = b*4, cc = c*2, dd = d;
  if (dd < aa && dd < bb && dd < cc) {
    ans += n/2*d;
    n-=n/2*2;
  }
  if (aa < bb && aa < cc) {
    ans += n*4*a;
    cout << ans << endl;
    return 0;
  }
  if (bb < cc) {
    ans += n*2*b;
    cout << ans << endl;
    return 0;
  }
  ans += n*c;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int n=10;int m=10;int q=50;
vin a(q),b(q),c(q),d(q);
int M=0;

int dfs(vin &A){
    if(A.size()==n){
        int tmp=0;
        rep(i,q)if(A[b[i]-1]-A[a[i]-1]==c[i])tmp+=d[i];
        return tmp;
    }
    int last=(A.empty()?1:A.back());
    rep2(i,last,m+1){
        A.push_back(i);
        M=max(M,dfs(A));
        A.pop_back();
    }
    return M;
}

int main(){
    cin>>n>>m>>q;
    rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    vin A;
    cout<<dfs(A)<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int main(){
    string x;
    cin >> x;
    int n=x.size();
    int ans=10000;
    rp(i,n-2){
        string s=x.substr(i,3);
        int can=(s[0]-'0')*100+(s[1]-'0')*10+(s[2]-'0');
        can=abs(can-753);
        ans=min(ans,can);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let s: Vec<char> = get_chars();
    let keyence: Vec<char> = "keyence".chars().collect();
    let mut i = 0;
    let mut j = 0;
    if s.len() < keyence.len() {
        println!("NO");
    } else {
        for k in 0..keyence.len() {
            if keyence[k] != s[k] { break; }
            i = k+1;
        }
        for k in 0..keyence.len() {
            if keyence[(keyence.len() as i64 -1 - k as i64) as usize] != s[(s.len() as i64 - 1 - k as i64) as usize] { break; }
            j = k+1;
        }
        if i + j < keyence.len() {
            println!("NO");
        } else {
            println!("YES");
        }
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 4352
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  val points = Array.tabulate(n){_ ⇒
    readLine.trim.split(' ').map(_.toInt - 1).sorted.foldLeft(0){case (a, b) ⇒ a * n + b}
  }.groupBy(it ⇒ it)
  println(
    points.toArray.map{case (_, a) ⇒ a.length - 1}.sum
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*


 */


Measured memory_bytes: 46560
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
                if((i*500+j*100+k*50)==x)
                    ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
# 2019/05/22
# AtCoder Beginner Contest 093 - B

# Input
a, b, k = map(int, input().split())
cnt = b - a + 1

vals = list()
if cnt < k:
    wk = cnt
else:
    wk = k

# small
for i in range(a, a + wk):
    print(i)

if k * 2 > cnt:
    wk = cnt - wk

# large
for i in range(b - wk + 1, b+1):
    print(i)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define llu unsigned long long
#define loop(i,a,b) for (long long int i=a; i<b; i++)
#define loopr(i,a,b) for(long long int j=a-1;j>b;j--)
#define st string
#define sz size()
#define maxe *max_element
#define mine *min_element
#define gt greater<ll>()
#define F first
#define S second
#define R return
#define B break
#define C continue
#define pb push_back
#define tc ll t; cin>>t; while(t--)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ROG ios::sync_with_stdio(0); cin.tie(0);
#define sortA(v)   sort(v.begin(), v.end())
#define sortD(v)   sort(v.begin(), v.end(), greater<auto>())
#define next cout<< "\n"
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<long long int> vll;
typedef vector<char> vc;
typedef long double ld;





int main()
{
    ROG
    ll a[2],b[2];
  loop(i,0,2)
  {
    cin >> a[i];
  }
  loop(i,0,2)
  {
    cin >> b[i];
  }
  ll ans=-1e18;
  loop(i,0,2)
  {
    loop(j,0,2)
    {
    	ans=max(ans,a[i]*b[j]);
    }
  }
    cout << ans << "\n";
  
    
}











Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=5e5+5;
int min3(int a,int b,int c)
{
    return min(min(a,b),c);
}
int max3(int a,int b,int c)
{
    return max(max(a,b),c);
}
int gcd(int x, int y)
{
    if(y==0)return x;
    return gcd(y, x%y);
}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int dir[4][2]={1,0,0,1,-1,0,0,-1};
char s[405][405];
int vis[405][405];
int c1;
int c2;
ll ans;
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)scanf("%s",s[i]+1);

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(vis[i][j]==0 && s[i][j]=='#')
            {
                c1=c2=0;
                queue<pair<int,int> >Q;
                Q.push(make_pair(i,j));
                vis[i][j]=1;
                while(!Q.empty())
                {
                    pair<int,int>t,tt;
                    t=Q.front();
                    Q.pop();
                    if(s[t.first][t.second]=='#')c1++;
                    c2++;
                    for(int k=0;k<4;k++)
                    {
                        tt=make_pair(t.first+dir[k][0],t.second+dir[k][1]);
                        if(tt.first>0 && tt.second>0 && tt.first<=h && tt.second<=w)
                        {
                            if(vis[tt.first][tt.second]==0 && s[tt.first][tt.second]!=s[t.first][t.second])
                            {
                                Q.push(tt);
                                vis[tt.first][tt.second]=1;
                            }
                        }
                    }
                }
                ans+=1ll*c1*(c2-c1);
            }
        }
    }

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


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
    vll a(n);
    forn(i,n) cin>>a[i];
    int id = 0;
    ll lft = 1000;
    ll ans = 0;
    while(id<n)
    {
        int j = id; id++;
        while(id<n && a[id] >= a[id-1] ) id++;
        ll g = lft/a[j];
        ans += ( g*(a[id-1]-a[j]) );
        lft += g*(a[id-1]-a[j]);
    }
    cout<<lft;

	return 0;
}


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

int main(){
      int N;
      cin >> N;
      vector<int> A(N);
      vector<int> ans(N);

      for(int i = 0;i < N;i++){
            cin >> A[i];
            ans[A[i]-1] = i + 1;
      }
      for(int i = 0;i < N;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

string S;

int main() {
    cin >> S;

    int N = S.length();
    bool tuyoi = true;
    rep(i, (N - 1) / 2) {
        if (S[i] != S[N / 2 - 1 - i]) tuyoi = false;
    }
    REP(i, (N + 3) / 2, N) {
        if (S[i] != S[N - 1 - i]) tuyoi = false;
    }

    cout << Yes(tuyoi) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	string S,T;
	cin >> S;
	for (size_t i = 0; i < S.size(); i++)
	{
		if (S.at(i) == '0')T += '0';
		else if (S.at(i) == '1') T += '1';
		else if (T.size() != 0)T.erase(T.size() - 1);
	}
	cout << T;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int Ha, Hb, Hc, Hx, Hy, Hz, Hmax, Hmin;
int ans;
int a,b;

int main() {
	cin >> a >> b;
	ans = 6 - a - b;
	cout << ans << endl;
	return 0;
}

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

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

    int K, N;
    cin >> K >> N;
    vector<int> A(N + 1);
    for (auto &x : A) {
        cin >> x;
    }
    A.at(N) = A.at(0) + K;
    int res = 0;
    for (int i = 0; i < N; ++i) {
        res = max(res, A.at(i + 1) - A.at(i));
    }
    cout << K - res << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			Console.WriteLine(N*PI*2);
		}

	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x]=A[y];
			A[y]=tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static IEnumerable<int> Indices<T>(this T[] X) => Enumerable.Range(0, X.Length);
		public static IEnumerable<int> Indices<T>(this T[,] X, int dim)
			=> Enumerable.Range(0, X.GetLength(dim));
		public static string Join<T>(this T[,] X, string separatorD2 = ",", string separatorD1 = "\n")
			=> X.Indices(0).Select(
				i => X.Indices(1).Select(j => X[i, j]).Join(separatorD2)
			).Join(separatorD1);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}


Measured memory_bytes: 27988
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = sc.nextInt();
		int k = sc.nextInt();
		int all = n*(n-1)/2;
		if(all - k < n-1){
			bw.write("-1"); bw.flush(); bw.close();
		}
		else{
			int count = 0;
			all -= (n-1+k);
			StringBuilder sb = new StringBuilder();
			for(int i = 2; i <= n; i++){
				sb.append(String.format("%d %d\n", 1, i));
				count++;
			}
			if(all > 0){
				for(int i = 2; i <= n; i++){
					for(int j = i+1; j <= n; j++){
						sb.append(String.format("%d %d\n", i, j));
						count++;
						all--;
						if(all <= 0) break;
					}
					if(all <= 0) break;
				}
			}
			bw.write(String.format("%d\n", count));
			bw.write(sb.toString());
			bw.flush(); bw.close();
		}
	}
}


Measured memory_bytes: 28092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1) a = 14;
  if(b==1) b = 14;

  if(a==b) cout << "Draw" << endl;
  else if(a<b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
template<typename T>
constexpr auto all(T x) { return (x).begin(),(x).end(); }
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	double t, x; CI t >> x;

	CO t / x EN;

	return 0;
}

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





int main(void){
    // Your code here!
    int N;

    int count=0;

  
  
  //入力
  cin >> N;
vector<int> vc(N);
  for(int i=0;i<N;i++)  cin >> vc[i];
  
  
  //どれかが奇数になるまで全て割り続ける
  //true部分を関数にするのもよいが今回はif
  while(true) {
      bool isOdd = false;
      
      //奇数が一個でもあるかどうか
      for(int i=0;i<N;i++){
          if(vc[i]%2==1){
              isOdd = true;
          }
      }
      
      
     if(!isOdd){
     //全要素2で割り算をする
        for(int i=0;i<N;i++){
          vc[i] /= 2;
         
        }
         count++;
     }
     else break;
      
  }
  
  
   cout << count << endl;
   
   
   
   
}


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

using namespace std;

signed main()
{
    long long i = 0, j = 0, k = 0, ans = 0;
    long long n, a[200], color[9]={0};
    cin >> n;
    for (i=0; i < n;i++){
        cin >> a[i];
        if(a[i]<3200)
            color[a[i] / 400]++;
        else
            color[8]++;
    }

    for (i = 0; i < 8;i++){
        if(color[i]>0)
            ans++;
    }
    cout << max(1LL,ans) << " "<< ans+color[8] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll>x1;
    vector<ll>x2;

    rep(i,N){
        ll x;
        cin>>x;
        if(x>0){
            x1.pb(x);
        }else{
            x2.pb(-x);
        }
    }

    sort(all(x1));
    sort(all(x2));
    ll N1 = x1.size();
    ll N2 = x2.size();
    ll  ans = INF;
    if(N2==0){
        cout<<x1[K-1]<<endl;
        return 0;
    }
    rep(i,N-K+1){
        ll l,r;
        l = x2.size()-i-1;
        r = K-l-2;
        //cout<<r<<endl;
        if(r<0){
            chmin(ans,x2[l]);
        }else{
            chmin(ans,x2[l]+x1[r]+min(x2[l],x1[r]));
        }

    }


    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=0;i<n;i+=2)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  int h,n;
  cin >> h >> n;
  string s="No";
  r1(i, n) {
    int a;
    cin >> a;
    h-=a;
    if(h<1) {
      s="Yes";
      break;
    }
  }
  cout << s << endl;
}

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

int main() {
	string s;cin >> s;
	int w; cin >>w;
	string out ="";
	int pos =0;
	while(s.size()-1 >= pos){
		out += s.substr(pos,1);
		pos += w;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = 0;
    if (n >= b - 1)
    {
        ce(ll(a * (b - 1) / b) - a * ll((b - 1) / b));
    }
    else
    {
        ce(ll(a * (n) / b) - a * ll((n) / b));
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> P(M);
  vector<string> S(M);
  rep(i,M) cin>>P[i]>>S[i];

  rep(i,M) P[i]--;

  vector<int> num(N+1,0);
  int ac=0,wa=0;
  for(int i=0;i<M;i++){
    if(num[P[i]]==-1) continue;
    if(S[i]=="AC"){
      wa+=num[P[i]];
      ac++;
      num[P[i]]=-1;
    }else{
      num[P[i]]++;
    }
  }

  cout<<ac<<" "<<wa<<endl;

  return 0;
}


Measured memory_bytes: 6528
s=input()
l=list(s)
lo=[]
le=[]
oc={'R','U','D'}
ec={'L','U','D'}
for i in range(len(s)):
    if i%2==0:
        lo.append(s[i])
    else:
        le.append(s[i])
if oc|set(lo)==oc and ec|set(le)==ec:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define FOR(i,j,n) for(int i=(j);i<=((int)n);++i)
#define N 1000005
#define MOD 1000000007
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
typedef long long int ll;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;

vector <int>g[N];
void init()
{
	for(int i = 0; i < N; i++) {
		g[i].clear();
	}
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2<<endl;
   
}





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

int main()
{
    int H,W;
    char c;

    cin>>W>>H>>c;

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){

            if((i==1||i==H)&&(j==1||j==W)){
                cout<<"+";
            }else if(i==1||i==H){
                cout<<"-";
            }else if(j==1||j==W){
                cout<<"|";
            }else if((i==(H/2)+1)&&(j==(W/2)+1)){
                cout<<c;
            }else{
                cout<<'.';
            }
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define int long long
using namespace std;
int vis[300005],ans;
 main()
{
   int n,k;
   cin>>n>>k;
   while(k--){
    int d;
    cin>>d;
    for(int i =0; i<d; i++){
        int x;
        cin>>x;
        vis[x] = 1;
    }
   }
   for(int i =1; i<=n; i++)
    ans+=(!vis[i]);
   cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 0) {
                if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 22740
N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])

Measured memory_bytes: 9120
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll a,b,k;
cin>>a>>b>>k;
ll x=min(a,k);
a=a-x;
k=k-x;
ll y=min(b,k);
k=k-y;
b=b-y;
cout<<a<<" "<<b<<endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void init(int N[],int M);
int judge(int P[],int T[],int C,int M);
int main(){
  int N,M,C,ct=0;
  int i;

  scanf("%d%d%d",&N,&M,&C);
  int A[N][M];
  int B[M];
  init(B,M);
  for(i=0;i<N;i++)init(A[i],M);

  for(i=0;i<N;i++)if(judge(B,A[i],C,M)>0)ct++;
  printf("%d\n",ct);

  return 0;
}

void init(int N[],int M){
  for(int i=0;i<M;i++)scanf("%d",&N[i]);
}

int judge(int P[],int T[],int C,int M){
  int tm=0;
  for(int i=0;i<M;i++){
    tm+=P[i]*T[i];
  }
  return tm+C;
}


Measured memory_bytes: 128
from fractions import gcd
from functools import reduce

# 2つの数の最小公倍数
def lcm(x,y):
    return (x*y) // gcd(x,y)

# リストを引数にして最小公倍数を表示
def lcm_of_list(a):
    return reduce(lcm, a)

def waruni(a):
    return a//2


n,m = map(int, input().split())
b = list(map(waruni, map(int, input().split())))

L = lcm_of_list(b)

for i in range(n):
    if (L//b[i])%2==0:
        print(0)
        exit()

ans = (m//L+1)//2

print(ans)

Measured memory_bytes: 89708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  string S;
  cin >> a >> b;
  cin >> S;
  if(S[b-1]=='A') S[b-1]='a';
  else if(S[b-1]=='B') S[b-1]='b';
  else S[b-1]='c';
  cout << S << endl;
}  


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[101010], b[101010];
LL suma, sumb;
int main() {
	cin >> n;
	REP(i, n)cin >> a[i], suma+=a[i];
	REP(i, n)cin >> b[i], sumb+=b[i];
	if (suma > sumb) {
		cout << "No" << endl;
		return 0;
	}
	LL count = sumb - suma;
	REP(i, n) {
		if (b[i] > a[i]) {
			if (count < 0) {
				cout << "No" << endl;
				return 0;
			}
			count -= (b[i] - a[i] + 1) / 2;
			if (count < 0) {
				cout << "No" << endl;
				return 0;
			}
			a[i] += (b[i] - a[i] + 1) / 2 * 2;
		}
		if (count&&i==n-1) {
			a[i] += count * 2;
		}
	}
	count = sumb - suma;
	REP(i, n) {
		if (a[i] > b[i]) {
			if (count < 0) {
				cout << "No" << endl;
				return 0;
			}
			count -= a[i] - b[i];
			if (count < 0) {
				cout << "No" << endl;
				return 0;
			}
			b[i] = a[i];
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 384
n, k = [int(_) for _ in input().split()]
s = []
for i in range(k):
    s.append([int(_) for _ in input().split()])
dp = [0 for i in range(n)]
dp[0] = 1
dp_s = [0 for i in range(n+1)]
dp_s[1] = 1
for i in range(1, n):
    for j in range(len(s)):
        r, l = s[j]
        if i-r >= 0:
            if i-l >= 0:
                dp[i] += dp_s[i-r+1] - dp_s[i-l]
            else:
                dp[i] += dp_s[i-r+1] - dp_s[0]
    dp[i] = dp[i] % 998244353
    dp_s[i+1] += dp_s[i] + dp[i]
    dp_s[i+1] = dp_s[i+1] % 998244353
print(dp[-1])

Measured memory_bytes: 24672
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, ans = "Yes";
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (i%2 == 0 && s[i] == 'L') {
      ans = "No";
      break;
    }
    else if (i%2 == 1 && s[i] == 'R') {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

string a;
int n;

int main(){
  cin>>a>>n;
  for (uint i = 0; i < a.size(); i+=n) {
    cout<<a[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;

const int mod = 1e9+7;
const int oo = 1e8+7;

int main() {
    
    int n;
    scanf("%d",&n);
    
    ll dp1 = 0, dp2 = 0, dp3 = 0;
    
    for(int i = 0; i < n; ++i) {
        ll a, b, c;
        scanf("%lld%lld%lld",&a,&b,&c);
        
        ll one = dp1, two = dp2, three = dp3;
        
        dp1 = max(dp1, two+a);
        dp1 = max(dp1, three+a);
        
        dp2 = max(dp2, one+b);
        dp2 = max(dp2, three+b);
        
        dp3 = max(dp3, one+c);
        dp3 = max(dp3, two+c);
    }
    
    cout << max(dp1, max(dp2,dp3)) << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<ll,ll>pll;
#define fi first
#define se second
#define pb(x) push_back(x)
#define m_p(a,b) make_pair(a,b);
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define jkl ios::sync_with_stdio(false);cin.tie(false);
#define all(x) x.begin(),x.end()
/*********************************************/
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a*b<c) cout << a*b;
	else cout << c;
}

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

using namespace std;

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	int y1,y2;
	y1=abs(a-x);
	y2=abs(b-x);
	
	if (y1<y2){
		cout<<"A"<<endl;
	}
	else cout<<"B"<<endl;


	return 0;
}


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

int main(){
  int n; cin >> n;
  long long int ans =0;
  if(n > 1){
  long long int pow=2;
  long long int mid = 1;
  ans = 1;
  for(int i = 0; i < n; i++){
    pow*=9;
    pow%=1000000007;
  }
  for(int i = 0; i < n; i++){
   mid*=8;
   mid%=1000000007;
  }
  for(int i = 0; i < n; i++){
   ans*=10;
    ans %=1000000007; 
  }
  
  ans = ans - pow+mid;
  if(ans <= 0)ans+=1000000007;
  }
    cout << ans << endl;
}

Measured memory_bytes: 3564
# coding:utf-8
x, k, d = map(int, input().split())

if (abs(x) // d) > k:
    print(abs(x) - k * d)
else:
    if (k - (abs(x) // d)) % 2 == 0:
        print(abs(x) % d)
    else:
        print(d - abs(x) % d)


Measured memory_bytes: 9072
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();

    int count = 0;

    for (int x = 0; x <= k; x++) {
      for (int y = 0; y <= k; y++) {
        int z = s-x-y;
        if (0 <= z && z <= k) {
          count++;
        }
      }
    }

    System.out.println(count);

  }

}


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

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

    int s = 1, e = N;
    int x;
    while(s <= e) {
        int m = (s + e)>>1;

        if(1LL * m * (m + 1) / 2 >= N) {
            x = m;
            e = m - 1;
        }
        else s = m + 1;
    }

    for(int i = 1; i <= x; i++) {
        if(i == x*(x + 1)/2 - N) continue;
        printf("%d\n", i);
    }
}


Measured memory_bytes: 256
# Nは使わない
_ = input()

# 文字列
S = input()

# 答えの初期値は0
ans = 0
current = 0
for s in S:
    # Iなら+1
    if s == "I":
        current +=1
    elif s== "D":
        current -=1
    # 最大値を更新する
    ans = max(ans, current)
    
print(ans)
    

Measured memory_bytes: 2940
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

alias OP = Tuple!(int, "x", int, "y");

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);

    OP[] lr, rl;
    foreach (i; 0..N-1) lr ~= OP(i, i+1);
    foreach_reverse (i; 0..N-1) rl ~= OP(i+1, i);

    long max_a = long.min, min_a = long.max;
    int max_i, min_i;
    foreach (i, a; as) {
        if (a > max_a) {
            max_a = a;
            max_i = i.to!int;
        }
        if (a < min_a) {
            min_a = a;
            min_i = i.to!int;
        }
    }
    if (max_a == min_a) {
        writeln(0);
        return;
    }

    OP[] res;
    if (max_a <= 0) {
        res = rl;
    } else if (min_a >= 0) {
        res = lr;
    } else if (abs(max_a) > abs(min_a)) {
        foreach (i; 0..N) if (i != max_i) res ~= OP(max_i, i);
        res ~= lr;
    } else {
        foreach (i; 0..N) if (i != min_i) res ~= OP(min_i, i);
        res ~= rl;
    }
    writeln(res.length);
    foreach (r; res) writefln("%d %d", r.x+1, r.y+1);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int n;
    cin >> n;
    double x=n/1.08;
    rep2(i,50000){
        if(n<=(i*1.08)&&(i*1.08)<n+1){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+20;
int n,m,c[N];
struct node{
	int l,r,len;
}a[N];
bool cmp(node a,node b)
{
	return a.len<b.len;
}
void update(int j,int k)
{
	for(int i=j;i<=m;i+=(i&-i))
		c[i]+=k;
}
int sum(int j)
{
	int res=0;
	for(int i=j;i>=1;i-=(i&-i))
		res+=c[i];
	return res;
}
int main()
{
	while(cin>>n>>m)
	{
		memset(c,0,sizeof(c));//
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&a[i].l,&a[i].r);
			a[i].len=a[i].r-a[i].l+1;
		}
		sort(a+1,a+n+1,cmp);
		int k=1;
		for(int d=1;d<=m;d++)
		{
			//O(m+nlogm)
			for(;k<=n&&a[k].len<d;k++)//最多n次 
			{
				update(a[k].l,1);
				update(a[k].r+1,-1);//差分,[1..li..kd..ri,ri+1...m],树状数组统计前缀和 
			}
			int ans=n-k+1;//区间长度>=d个数 
			//O(mlogm)
			for(int e=d;e<=m;e+=d)
			{
				ans+=sum(e);
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>
#include <math.h>

int a[999999];

int prime(int x) {
	if (a[x] == 1) return 1;
	else if (a[x] == 2) return 0;
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			a[x] = 2;
			return 0;
		}
	}
	return a[x]=1;
}
int main(){
	int n;
	while (scanf("%d", &n) != EOF){
		int count = 0;
		for (int i = 2; i <= n; i++) {
			if (prime(i))count++;
		}
		count++;
		if (n == 0)count = 0;
		if (n == 1)count = 0;
		if (n == 2)count = 1;
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 4928
import java.util.*;
public class  Main {

	public static void main(String[] args) {
	// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//???????????°
		int diff;//???????????°
		int c = 2;//?????????????????¨?????????????????????????????????????????´??????????????????????????????????????????
		int a = 2;//??????????????\???????????´??????????????°???????????????
		int sum = 0;//????????????????????°
		char answer[] = sc.next().toCharArray();//???????????????
		char names[][] = new char[n][];//????????????????´?????????????
		
		for(int i = 0; i < n; i++){//?????????????????????????????\???????????????
			names[i] = sc.next().toCharArray();
		}
		for(int i = 0; i < n; i++){//???????????°???(N???)?????????
			c = 2;//????????????????????????????????¨????????????
			a = 2;//????????????????????????????????¨????????????
			search:for(int k = 0; k < names[i].length; k++){//1????????????????´¢
				if(names[i][k] == answer[0]){//??????1???????????????????????£??????
//					System.out.println(k +"??????????????????0???????????¨?????´?????????");
					for(int j = k+1; j < names[i].length; j ++){//????????????????´¢
						if(names[i][j] == answer[1]){//????????????????????????????????£??????
//							System.out.println(j +"??????????????????1???????????¨?????´?????????");
							diff = j - k;//??????????????¨??????????????????????????\???????????°
							for(int h = j+diff; h < names[i].length; h += diff){//??????????????¨??????????????????????????????????????????
								if(a == answer.length){//?????????????????????????´¢?????????
//									System.out.println("?????????"+i+"????????????????????§?????????");
									sum++;
									break search;
								}else if(names[i][h] == answer[c]){
//									System.out.println(h +"??????????????????" + c + "???????????¨?????´?????????");
									c++;
									a++;
								}else{
//									System.out.println(h +"??????????????????" + c + "???????????¨?????´????????????");
									c = 2;
									a = 2;
									break;
								}
							}
							if(a == answer.length){//?????????????????????????´¢?????????(?????¨????????????????¶????????????´?????¨)
//								System.out.println("?????????"+i+"????????????????????§?????????");
								sum++;
								break search;
							}
						}else{
//							System.out.println(j +"??????????????????1???????????¨?????´????????????");
						}
					}
				}else{
//					System.out.println(k +"??????????????????0???????????¨?????´????????????");
				}
			}
		}
		System.out.println(sum);
	}
}

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

int main(){
    int A, B, C, D, N;
    int t = 0;
    string s;
    cin >> N >> A >> B >> C >> D;
    cin >> s;
    
    if(D<C && D-B==1){
        for(int i = A; i < C-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == C-3) t++;
        }
        if(s.at(B-2)=='.' || s.at(D+1) == '.') t++;
        if(t == 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    else if(D < C) {
        for(int i = A; i < C-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == C-3) t++;
        }
        for(int i = B-2; i < D-1; i++){
            if(s.at(i)=='.' && s.at(i+1)=='.' && s.at(i+2)=='.') {
                t++;
                break;
            }
            else if(i == D-3) continue;
        }
        if(t == 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    else if(C-A<3 && D-B<3){
        cout << "Yes" << endl;
    }

    else if(D-B<3){
        for(int i = A; i < C-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == C-3) t++;
        }
        if(t == 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    else if(C-A<3){
        for(int i = B; i < D-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == D-3) t++;
        }
        if(t == 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }    

    else {
        for(int i = A; i < C-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == C-3) t++;
        }
        for(int i = B; i < D-2; i++){
            if(s.at(i)=='#' && s.at(i+1)=='#') break;
            else if(i == D-3) t++;
        }
        if(t == 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
}

Measured memory_bytes: 640
def z_algo(N, S):
    i = 0 # start 
    j = 1 # end
    ml = 0 # max length

    while i < N:
        if j-i > N-j:
            break
        
        sw = S[i:j]

        if sw in S[j:]:
            ml = max(ml, len(sw))
            j += 1
        else:
            i += 1

    return ml


N = int(input())
S = input()

print(z_algo(N, S))

Measured memory_bytes: 40924