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

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(b<c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3124
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
//グローバル変数宣言
 ll p=0,q=0,r=0;


int main(){
   ll n,d,x;
   cin>>n>>d>>x;
   vl a(n);
   d-=1;
   rep(i,n){
      cin>>a[i];
      x+=d/a[i]+1;
   }
   print(x);
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define pb push_back
int m[100000];
int a[100000];
int fun(int n){
	if(n==0)return 0;
	if(n==1)return abs(a[1]-a[0]);
	if(m[n]!=-1)return m[n];
	else{
		m[n]=min(fun(n-1)+abs(a[n-1]-a[n]),fun(n-2)+abs(a[n-2]-a[n]));
		return m[n];
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	memset(m,-1,n*sizeof(m[0]));
	for(int i=0;i<n;i++)cin>>a[i];
	int x=fun(n-1);
	cout<<x;
	return 0;
}


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

// 全体の最大公約数に一致するというまさかの展開
// 細かい証明は調べればよろし
// gcd(a,b) = gcd(b,b-a) から　ユークリッドの互助法的に二匹の時は解ける。
// あとは帰納法なりなんなりで証明すればよさそう。
// とりあえず、数字のランダム引き算で最小になるときは「最大公約数」と覚えておくことがポイント

int GCD(int a,int b){ //ユークリッドの互助法で最大公約数
    if (a%b == 0){
        return b;
    }
    else {
        return GCD(b,a%b);
    }
}

int main(){
    int N; cin >> N;
    vector<int> mons(N+1);

    int i,j;


    rep(i,N){       
        cin >> mons[i];
    }



    int temp = mons[0];

    rep(j,N){
        temp = GCD(temp,mons[j]);
    }

    cout << temp << endl;
}
// 20190528AC

// なんかvector使って cin >> mons[i]; ってやろうとしたら　バグッた
// なにやらイテレータ破壊だかっていう現象っぽい。
// vectorはコンテナだから、コンテナに動的に追加するとイテレータがなんちゃらでやばいらしい

Measured memory_bytes: 640
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn gcd(a: usize, b: usize) -> usize {
   if b == 0 {
      a
   } else {
      gcd(b, a % b)
   }
}

fn main() {
   input! {
      n: usize,
      _x: usize,
      _xs: [usize; n]
   }
   let mut x = _xs.clone();
   x.push(_x);
   x.sort();
   let mut d = x[1] - x[0];
   for i in 1..n {
      d = gcd(d, x[i + 1] - x[i]);
   }
   println!("{}", d);
}


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

int main(){
  char *ans="keyence";
  std::string sans(ans);
  std::string input;
  std::cin >> input;
  bool suc=false;
  for(int i = 0; i < input.size(); i++){
    for(int j = 0; j < input.size()-i+1; j++){
      std::string buf(input);
      buf.erase(i,j);
      if (buf==sans) {
        suc=true;
        break;
      }
    }
  }
  if (suc) {
    std::cout << "YES" << std::endl;
  }else{
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;

int main(){

    string str;
    cin>>str;

    if(str[str.size()-1]=='s'){
        str = str + "es";
    } else{
        str = str + "s";
    }

    cout<<str;
    return 0;
}

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

constexpr long long kInf = 1e18;

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

  int n;
  cin >> n;
  ++n;

  vector<int> a(n);
  for (int& e: a)
    cin >> e;

  vector<long long> sums(a.begin(), a.end());
  for (int i = n - 2; i >= 0; --i)
    sums[i] += sums[i + 1];

  long long result = 0;
  long long vertices = 1;

  int i = 0;
  for (int e: a) {
    if (vertices < e) {
      result = -1;
      break;
    }

    vertices -= e;
    result += e;
    vertices = min(vertices, sums[i] - a[i]);
    result += vertices;
    ++i;
    vertices *= 2;

    if (vertices >= kInf) {
      result = -1;
      break;
    }
  }

  cout << result << '\n';
}

Measured memory_bytes: 4504
#include<iostream>
using namespace std;
int main(){
    
    int a, b, c;
    cin >> a >> b >> c;
    
    int count=0;
    
    for (int x=a; x<=b; x++){
        
        if(c%x ==0){
            count ++;
        }else{
            continue;
        }
        
        
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

#define ll long long 
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define inf (1<<31)

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	fr(i,tx-sx){
		cout<<'R';
	}
	fr(i,ty-sy){
		cout<<'U';
	}
	fr(i,tx-sx){
		cout<<'L';
	}
	fr(i,ty-sy){
		cout<<'D';
	}
	cout<<'D';
	fr(i,tx-sx+1){
		cout<<'R';
	}
	fr(i,ty-sy+1){
		cout<<'U';
	}
	cout<<'L';
	cout<<'U';
	fr(i,tx-sx+1){
		cout<<'L';
	}
	fr(i,ty-sy+1){
		cout<<'D';
	}
	cout<<'R';
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def decompose(n:Int) = {
    val a = new ArrayBuffer[(Int,Int)]
    for(i<-1 to Math.sqrt(n).toInt) {
      if(n%i==0)
        a += ((i,n/i))
    }
    a.toArray
  }
  def main(args:Array[String]) = {
    var s = "0 0"
    while({s=readLine.trim;s} != "0 0") {
      val n = s.split(" ").map(_.toInt)
      val x = decompose(n(0))
      val y = decompose(n(1))
      var min = Int.MaxValue
      for(i<-x) {
        for(j<-y) {
          val z = Array(i._1,i._2,j._1,j._2).sorted
          val sum = (z(1)-z(0))*(z(1)-z(0)) + (z(2)-z(1))*(z(2)-z(1)) + (z(3)-z(2))*(z(3)-z(2))
          if(sum<min) min = sum
        }
      }
      println(min)
    }
  }
}

Measured memory_bytes: 60144
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), m = in.nextInt();
		int[] arr = new int[n];
		Pair[] pairs = new Pair[m];
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			pairs[i] = new Pair(Math.min(a, b), Math.max(a, b));
		}
		Arrays.sort(pairs, Comparator.comparing(Pair::getB));
		int ans = 0, last = -1;
		for(Pair p : pairs) {
			if(last <= p.a){
				ans++;
				last = p.b;
			}
		}
		System.out.println(ans);
	}
}

class Pair {
	int a, b;
	public Pair(int a, int b) {
		this.a = a;
		this.b = b;
	}
	public int getA() { return this.a; }
	public int getB() { return this.b; }
}

Measured memory_bytes: 97352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			
			if (true == timesFraction(N))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}

	private static boolean timesFraction(int n) {
		// int to ArrayString
		String[] s =  String.valueOf(n).split("");
		
		int N = s.length;
		final int M = (int)(N / 2);
		
		for (int i = 0; i < M; i++) {
			if (false == s[i].equals(s[N - 1])) {
				return false;
			}
		}
		return true;
	}
}

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

int main() {
  long long N,H,W,ans = 0;
  cin >> N >> H >> W;
  vector<long long>A(N);
  vector<long long>B(N);
  for(int i=0; i<N; i++){
   cin >> A[i] >> B[i];
    if(A[i] >= H && B[i] >= W){
      ans++;
    }
  }
  cout << ans << endl;
}


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

uint_fast64_t digdp(int d, vector<int>& dig, int state, bool lz, bool less){
    if(d <= -1){
        return state == 168;
    }
    if(less){
        uint_fast64_t ret(0);
        if(lz){
            ret += digdp(d - 1, dig, state, lz, less);
        }
        ret += digdp(d - 1, dig, state | 8, 0, 1);
        ret += digdp(d - 1, dig, state | 32, 0, 1);
        ret += digdp(d - 1, dig, state | 128, 0, 1);
        return ret;
    }else{
        uint_fast64_t ret(0);
        if(lz){
            ret += digdp(d - 1, dig, state, lz, dig[d] != 0);
        }
        if(dig[d] >= 3)ret += digdp(d - 1, dig, state | 8, 0, dig[d] > 3);
        if(dig[d] >= 5)ret += digdp(d - 1, dig, state | 32, 0, dig[d] > 5);
        if(dig[d] >= 7)ret += digdp(d - 1, dig, state | 128, 0, dig[d] > 7);
        return ret;
    }
}

int main(){
    int_fast64_t N(0);
    cin >> N;
    vector<int> dig;
    int d(0);
    while(N){
        dig.push_back(N % 10);
        N /= 10;
        ++d;
    }
    cout << digdp(d - 1, dig, 0, 1, 0);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<stdio.h>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

struct Panel{
	string name;
	int x1,y1,x2,y2;
	vector<Panel> v;
};

int fp;

Panel parse(string s){
	Panel p;
	int ep=0;
	while(s[fp] != '>'){
		ep++;
		fp++;
	}
	p.name = s.substr(fp-ep,ep);
	ep=0;fp++;
	while(s[fp] != ','){
		ep++;
		fp++;
	}
	p.x1 = toInt(s.substr(fp-ep,ep));

	ep=0;fp++;
	while(s[fp] != ','){
		ep++;
		fp++;
	}
	p.y1 = toInt(s.substr(fp-ep,ep));
	ep=0;fp++;
	while(s[fp] != ','){
		ep++;
		fp++;
	}
	p.x2 = toInt(s.substr(fp-ep,ep));
	ep=0;fp++;
	while(s[fp] != '<'){
		ep++;
		fp++;
	}
	p.y2 = toInt(s.substr(fp-ep,fp-1));
	
	fp++;
	while(1){
		if(s[fp]=='/'){ fp+=p.name.size()+3; break;}
		else p.v.push_back(parse(s));
	}	
	return p;
}

Panel search(int x,int y,Panel r_p,Panel p){
	if(p.x1 <= x && p.x2 >= x && p.y1 <= y && p.y2 >= y){
		if(p.v.size()==0) return p;	
		rep(i,p.v.size()){	
			Panel tmp = search(x,y,p,p.v[i]);
			if(tmp.name != p.name ) return tmp;
		}
		return p;
	}
	
	return r_p;
}

int main(){

	while(1){
		int n;
		string str;
		cin >> n;
		if(n==0) break;
		cin >> str;
		fp=1;
		Panel p = parse(str);
		rep(i,n){
			int x,y;
			cin >> x >> y;
			Panel root;root.name="-1";
			Panel ans=search(x,y,root,p);
			if(ans.name=="-1") cout << "OUT OF MAIN PANEL 1" << endl;
			else cout << ans.name << " " << ans.v.size() << endl;
		}
	}
}

Measured memory_bytes: 1264
#include <iostream>

using namespace std;
using LL = long long;

const LL INF = 1L << 29;

int N, M, R;
int r[8];
bool U[8];
LL d[201][201];
LL ans = INF;

void dfs(int count, int prev, LL dist) {
    if (count == R) {
        ans = min(ans, dist);
        return;
    }
    for (int i = 0; i < R; i++) {
        if (!U[i]) {
            U[i] = true;
            dfs(count + 1, i, prev == -1 ? 0L : dist + d[r[prev]][r[i]]);
            U[i] = false;
        }
    }
}

int main() {

    cin >> N >> M >> R;

    for (int i = 0; i < R; i++) {
        cin >> r[i];
        U[i] = false;
    }

    fill(d[0], d[N + 1], INF);
    for (int i = 1; i <= N; i++) d[i][i] = 0;

    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        d[A][B] = d[B][A] = C;
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    dfs(0, -1, 0L);

    cout << ans << endl;
}


Measured memory_bytes: 512
root=[]
n,k = map(int,input().split())
for i in range(k):
    x,y = map(int,input().split())
    root.append([x,y])

toori=[0]*(2*10**5)+[0]*n+[0]*(2*10**5)
toori[2*10**5]=1
cum=[0]*k
for a,i in enumerate (root):
    s=0
    for j in range (i[0],i[1]+1):
        s+=toori[2*10**5+1-j]
    cum[a]=s
aaa=sum(cum)%998244353
toori[2*10**5+1]+=aaa


for now in range(2,n):#nowが今の場所
    hueru=0
    for a,i in enumerate (root):
        hueru+=(toori[2*10**5+now-i[0]] - toori[2*10**5+now-1-i[1]])
    aaa+=hueru
    aaa%=998244353
    toori[2*10**5+now]+=aaa
    toori[2*10**5+now]%=998244353
    


print(toori[2*10**5+n-1]%998244353)

Measured memory_bytes: 21516
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(){

	//FILE *fp;
	//if((fp=fopen("output.txt","w"))==NULL){
	//	return -1;
	//}

	int a,b,c,d,e,f;
	while(1){
		cin >> a >> b >> c >> d >> e >> f;
		if(cin.eof()){
			break;
		}
		double y = (double)(a*f-c*d)/(a*e-b*d);
		double x = (double)(c-b*y)/a;
		fprintf(stdout,"%.3f %.3f\n",x,y);
	}
//	fclose(fp);

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
 
int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;
 
  scanf("%s %s",s,p);
 
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;
 
  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
 
  if( t )
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}
  


Measured memory_bytes: 2112
/* Simultaneous Equation */

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double bunbo = a * e - b * d;
    double x = (c * e - b * f) / bunbo;
    double y = (a * f - c * d) / bunbo;

    if(x == 0) x = 0.000;
    if(y == 0) y = 0.000;
    printf("%.3lf %.3lf\n", x, y);
  }

  return 0;
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    long int d;
    cin >> d;

    int ans = 0;

    for(int i = 0; i < n; ++i){
        long int a,b;
        cin >> a >> b;
        if(a * a + b * b <= d * d){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	vector<int> s(4);
	int a; cin >> a;
	s[0] = a / 1000 % 10;
	s[1] = a / 100 % 10;
	s[2] = a / 10 % 10;
	s[3] = a % 10;
	for (int i = 0; i < pow(2, 3); ++i)
	{
		int tmp = s[0] + s[1] + s[2] + s[3];
		vector<char> ans(3, '+');
		rep(j, 0, 2)
		{
			if (i >> j & 1)
			{
				tmp -= s[3 - j] * 2;
				ans[2 - j] = '-';
			}
		}
		if (tmp == 7)
		{
			rep(j, 0, 2)
			{
				cout << s[j] << ans[j];
			}
			cout << s[3] << "=7" << endl;
			return 0;
		}
	}
}

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


int main() {
    int N, W;
    cin >> N >> W;
    vector<long long> weight(N+1), value(N+1);
    for (int i = 1; i < N+1; i++) {
        cin >> weight[i] >> value[i];
    }

    vector<vector<long long>> dp(W+1, vector<long long> (N+1, 0)); //第一成分が重さの合計，第二成分は何番目までの品物を考えたか

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j - weight[i] >= 0) {
                dp[j][i] = max(dp[j][i-1], dp[j - weight[i]][i-1] + value[i]);
            }
            else {
                dp[j][i] = dp[j][i-1];
            }
        }
    }

    long long result = 0;
    for (int i = 0; i <= W; i++) {
        result = max(result, dp[i][N]);
    }
    cout << result << endl;
}

Measured memory_bytes: 85364
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        int now = 0;
        int nx = 0;
        int ny = 0;
        for (int i = 0; i < N; i++)
        {
            int t = cin.nextint;
            int x = cin.nextint;
            int y = cin.nextint;

            int need = Math.Abs(nx - x) + Math.Abs(ny - y);
            int time = t - now;
            if (need <=  time && (time - need ) % 2 == 0)
            {
                now = t;
                nx = x;
                ny = y;
            }
            else
            {
                WriteLine("No");
                return;
            }
        }
        WriteLine("Yes");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 15292
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int main(){
    int n,q; cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        int m,s,e; cin >> m >> s >> e;
        if (m == 0){
            long long mn = MM;
            for(int k = s; k < e; k++){
                mn = min(mn,a[k]);
            }
            cout << mn << endl;
        } else {
            long long mx = -MM;
            for(int k = s; k < e; k++){
                mx = max(mx,a[k]);
            }
            cout << mx << endl;
        }
    }
}
  




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

int main() {
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) cout << "bon" << endl;
  else if(n == 0 || n == 1|| n == 6|| n == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3580
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
//#define int long long
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const double Rad_to_deg=45.0/atan(1.0);
inline ll floor(const ll&a,const ll&b){return a/b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=100010,mod=998244353;
inline int cal(int x){int res=0;while(x){x/=10;res++;}return res;}
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int mul(int a,int b){return (ll)a*b%mod;}
priority_queue<int>q;
int x;
ll sum1;
int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x;sum1+=x;
		q.push(x);
	}
	for(int i=1;i<=m;i++)
	{
		int dang=q.top();
		dang=dang/2;
		sum1-=(q.top()-dang);
		q.pop();
		q.push(dang);
	}
	cout<<sum1;
}

Measured memory_bytes: 3888
K = int(input())
mod = 7
index = 1
flag = 0

if K % 2 == 0:
  print(-1)
elif K % 5 == 0:
  print(-1)
else:  
  while(index<=K):
      mod=mod%K
      if mod==0:
          print(index)
          flag=1
          break
      mod=mod*10+7
      index+=1
  if flag==0:
      print(-1)

Measured memory_bytes: 9176
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
using namespace std;
int main (){
	int n,Na[200],Nb[200],Nc[200],Ma[200],Mb[200],Mc[200];
	cin >> n;

	for(int i=0; i<n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		int A = a,B = b,C = c;

		Ma[i] = a;
		Mb[i] = b;
		Mc[i] = c;


		for(int j=0; j<i; j++){
			if(a == Ma[j]){
				Na[j] = 0;
				A = 0;
			}
			if(b == Mb[j]){
				Nb[j] = 0;
				B = 0;
			}
			if(c == Mc[j]){
				Nc[j] = 0;
				C = 0;
			}
		}
		Na[i] = A;
		Nb[i] = B;
		Nc[i] = C;

	}

	for(int i=0; i<n; i++){
		cout << Na[i]+Nb[i]+Nc[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
s = input()
ans=''
for i in range(len(s)):
    if s[i] == 'B' and i==0:
        ans = ans
    elif s[i] == 'B':
        ans = ans[:-1]
    elif s[i] == '0':
        ans+="0"
    elif s[i] == '1':
        ans+="1"
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include<climits>
using namespace std;
int minCostBU(int n,int k,int a[]){
    int dp[100005]={0};
    int min;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<k;i++){
        min = INT_MAX;
        for(int j=1;j<=i;j++){
            if(dp[i-j]+abs(a[i]-a[i-j])<min){
                min = dp[i-j]+abs(a[i]-a[i-j]);
            }
        }
        
        dp[i]=min;
    }
    for(int i=k;i<n;i++){
        int min = INT_MAX;
        for(int j=1;j<=k;j++){
            if(dp[i-j]+abs(a[i]-a[i-j])<min){
                min =dp[i-j]+abs(a[i]-a[i-j]);
            }
        }
        
        dp[i]=min;
    }
    return dp[n-1];
}
int main() {
    int n,k;cin>>n>>k;
    int a[100005],dp[100005]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<minCostBU(n,k,a);

}

Measured memory_bytes: 1024
def submit():
    n, k = map(int, input().split())
    plist = list(map(int, input().split()))
    
    # 各iのサイコロの出目の期待値を計算
    exp = {1: 1}
    max_p = max(plist)
    for x in range(2, max_p + 1):
        exp[x] = exp[x - 1] + x
    for x in range(1, max_p + 1):
        exp[x] /= x
    
    # 期待値リストに変換し、合計が最大値になるところを探す
    explist = [exp[p] for p in plist]
    curr_sum = sum([e for e in explist[:k]])
    curr_max = curr_sum

    l, r = 1, k
    while r < n:
        curr_sum += explist[r] - explist[l - 1]
        if curr_sum > curr_max:
            curr_max = curr_sum
        l += 1
        r += 1

    print(curr_max)
    

if __name__ == "__main__":
    submit()

Measured memory_bytes: 25172
#include<stdio.h>

int bubbleSort(int A[], int N) {
	int sw = 0;
	int flag = 1;
	int i, j,tmp;
	for (i = 0; flag; i++) {
		flag = 0;
		for (j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main() {
	int i,A[100], N, sw;
	scanf("%d", &N);
	for (i = 0; i < N; i++)scanf("%d", &A[i]);

	sw = bubbleSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);

	return 0;
}

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

int main(){
    ll a, b;
    cin >> a >> b;
    printf("%lld %lld %.10f\n",
        a / b, a % b, static_cast<double>(a) / b);
    return 0;
}



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

n, m = map(int, input().split())
broken = set([int(input()) for _ in range(m)]) # ここが'list'だとPypyでも通らない

def ptn_num(x): # 'x'stepまでのパターン数
    dp = [0] * (x+1) # DP枠_including step'0'
    if 1 in broken: # 固定部分_in case, step'1' broken 
        dp[:2] = 1, 0
    else:
        dp[:2] = 1, 1 # 固定部分_Usually

    for i in range(2, x+1):
        if i not in broken: # 階段が壊れてない場合...
            dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7) # -1段目と-2段目の合計
    print(dp[-1])

ptn_num(n)

Measured memory_bytes: 13192
package main

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

func main() {
	n := getInt()

	t, x, y := 0, 0, 0
	ans := "Yes"
	for i := 0; i < n; i++ {
		nt, nx, ny := getInt(), getInt(), getInt()
		dt := nt - t
		dd := abs(nx-x) + abs(ny-y)

		if (dd > dt) || ((dt % 2) != (dd % 2)) {
			ans = "No"
			// break
		}

		t, x, y = nt, nx, ny
	}

	fmt.Println(ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    N = I()
    P =LI()
    out=0
    for i in range(2,N):
        if (P[i-2]>P[i-1] and P[i-1]>P[i]) or(P[i-2]<P[i-1] and P[i-1]<P[i]):
            out+=1

    print(out)

    
    
if __name__ == "__main__":
    main()

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

hash = {}

for i in a:
    if i in hash:
        hash[i] += 1
    else:
        hash[i] = 1

ans = 0
for k, v in hash.items():
    if k < v:
        ans += v - k
    elif k > v:
        ans += v
    


print(ans)

Measured memory_bytes: 18172
#include "bits/stdc++.h"
using namespace std;

int INF = 1000000;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	priority_queue<pair<int, int> > PQ;
	vector<int> X(N, -INF);
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) X[i] = INF, PQ.push({ INF, i });
	}
	while (!PQ.empty()) {
		pair<int, int> P = PQ.top();
		PQ.pop();
		int Time = P.first, Now = P.second;
		if (Time < X[Now]) continue;
		for (int i = 0; i < 2; i++) {
			int Next = Now + (i * 2 - 1);
			if (0 <= Next && Next < N) {
				int NextTime;
				if (A[Next] < 0) NextTime = min(-A[Next], Time - 1);
				else NextTime = Time - 1;
				if (X[Next] < NextTime) {
					X[Next] = NextTime;
					PQ.push({ NextTime, Next });
				}
			}
		}
	}
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		ANS += min(max(0, A[i]), max(0, X[i]));
	}
	cout << ANS << endl;
}


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

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

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

    int max = A.at(0), min = A.at(0);
    for (int i=0; i<N; i++){
        if (max < A.at(i)) max = A.at(i);
        if (min > A.at(i)) min = A.at(i);
    }
    cout << max - min << endl;
}

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

signed main() {
  int N;
  string S, ans = "";
  cin >> N >> S;

  for (int i = 0; i < S.size(); i++) {
    ans += char('A' + (int(S[i] - 'A') + N) % 26);
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	int x, y;
	cin >> x >> y;
	bool tmp = false;
	rep(i, x + 1) {
		if (i * 4 + (x - i) * 2 == y)tmp = true;
	}
	if (tmp) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

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

int main(){
    int n, m;
    vector<int> v, dis;
    cin >> n >> m;
    v.resize(m);
    for(int i = 0; i != m; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 1; i != m; ++i)
    {
        dis.push_back(v[i] - v[i - 1]);
    }
    sort(dis.begin(), dis.end());
    int ans = 0;
    for(int i = 0; i < (int)dis.size() - n + 1; ++i)
    {
        ans += dis[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1276
#include<cstdio>

using namespace std;

const int N = 100005;
int n, k, ans;

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%*d", &ans);
	ans = (n-1) / (k-1);
	if((n-1) % (k-1))
		ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



///////////////////////////




int main() {

	ll N;

	ll A[MAX];

	cin >> N;

	repn(i, N) cin >> A[i];

	string ans = "APPROVED";

	repn(i, N) {
		if (A[i] % 2 == 0) { if (A[i] % 3 != 0 && A[i] % 5 != 0) { ans = "DENIED"; } }
	}

	cout << ans;


	system("PAUSE");

}


Measured memory_bytes: 504
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		boolean flag = false;

		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (N == i * j) {
					flag = true;
					break;
				}
			}
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 22868
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    result = 0
    for i in range(N - 2):
        if S[i : i + 3] == "ABC":
            result += 1

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  if(D==0){
    if(N==100) cout << 101 << endl;
    else cout << N << endl;
  }

  if(D==1){
    if(N==100) cout << 10100 << endl;
    else cout << 100*N << endl;
  }

  if(D==2){
    if(N==100) cout << 1010000 << endl;
    else cout << 10000*N << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math


def main():
    a,b,h,m = list(map(int, input().split()))
    short = 0
    # 短針の角度
    short = (h * 30) + (m * 0.5)
    long = m * 6
    ka = max(short, long) - min(short, long)
    ka = 360 - ka if ka > 180 else ka
    if ka == 90:
        print(math.sqrt(a**2+b**2))
        exit()
    else:
        print(math.sqrt(a**2 + b**2 - 2*(a*b) * math.cos(math.radians(ka))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62644
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,T;
    cin >> N >> T;
    int c,t;
    int ans = INT_MAX;
    for ( int i = 0; i < N; i++ ) {
        cin >> c >> t;
        if ( t <= T ) {
            ans = min( ans, c );
        }
    }
    if ( ans == INT_MAX ) { cout << "TLE" << endl; }
    else { cout << ans << endl; }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ki = [[] for i in range(n)]
for i in range(n-1):
    ki[a[i]-1].append(i+1)
    ki[i+1].append(a[i]-1)
for i in range(n):
    if i == 0:
        print(len(ki[i]))
        continue
    print(len(ki[i])-1)



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

struct node {
    int id;
    int score;
    node(int i, int s) : id(i), score(s) { }
    bool operator <(const node &x) const {
        if(this->score != x.score) return this->score > x.score;
        return this->id < x.id;
    }
};

int main() {
    int n; cin >> n;
    vector<node> v;
    while(n--) {
        int id, score; cin >> id >> score;
        v.push_back(node(id, score));
    }
    node p = *min_element(v.begin(), v.end());
    cout << p.id << ' ' << p.score << endl;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
LL in[N];
LL sil[N];
LL odw[N];

int fast(int a, int b){
	int ret = 1;
	while(b){
		if(b & 1)
			ret = (1LL * ret * a)%MX;
		
		b >>= 1;
		a = (1LL * a * a)%MX;
	}
	
	return ret;
}

int newton(int a, int b){
	if(a < b || b < 0)
		return 0;
	return (((sil[a] * odw[b])%MX) * odw[a - b])%MX;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%lld", &in[i]);
	
	sil[0] = 1;
	for(int i = 1; i <= n; ++i)
		sil[i] = (sil[i - 1] * i)%MX;

	odw[n] = fast(sil[n], MX - 2);	
	for(int i = n; i >= 1; --i)
		odw[i - 1] = (odw[i] * i)%MX;

	LL res = 0LL, cur = 0LL;
	for(int i = 1; i <= n; ++i){
		cur = (cur + ((sil[n] * odw[i])%MX) * sil[i - 1])%MX;
		res = (res + cur * in[i])%MX;
	}
	
	cur = 0;
	for(int i = n - 1; i >= 1; --i){
		cur = (cur + ((sil[n] * odw[n - i + 1])%MX) * sil[n - i])%MX;
		res = (res + cur * in[i])%MX;
	}
	
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
int main(void){
   int A,B;
   char S[11],T[11],U[11];
   scanf("%s %s",S,T);
   scanf("%d %d",&A,&B);
   scanf("%s",U);
   if(strcmp(T,U)==0){
      printf("%d %d",A,B-1);
   }else{
      printf("%d %d",A-1,B);
   }
   
   return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int ra = a % 2;
		int rb = b % 2;
		int rc = c % 2;
		int count = 0;
		if (!(ra == rb && rb == rc)) {
			if (ra == rb) {
				a += 1;
				b += 1;
			} else if (ra == rc) {
				a += 1;
				c += 1;
			} else {
				b += 1;
				c += 1;
			}
			count += 1;
		}
		int max = Math.max(a, Math.max(b, c));
		count += (max - a) / 2;
		count += (max - b) / 2;
		count += (max - c) / 2;
		out.println(count);
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


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

int main () {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
      
    else if (i == N - 1) {
      cout << "Three" << endl;      
    }
  }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if(b == 100) {
		if(a == 0) cout<<"101";
		if(a == 1) cout<<"10100";
		if(a == 2)cout<<"1010000";
		return 0;
	}
	if(a == 0) printf("%d\n", b);
	if(a == 1) cout<<b<<"00"<<endl;
	if(a == 2) cout << b << "0000"<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define ForE(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;
string s,t;

main()
{
        cin>>s;
        reverse(All(s));

        vector<string> vs={"dream","dreamer","eraser","erase"};
        ForE(&it,vs)reverse(All(it));
        //ForE(it,vs)cout<<it<<endl;

        int tmp=0,l=s.size();
        while(tmp!=l)
        {
                int hoge=tmp;
                rep(i,4)
                {
                        if(s.find(vs[i],tmp)==tmp)
                        {
                                tmp+=vs[i].size();
                                break;
                        }
                }
                if(hoge==tmp)
                {
                        cout<<"NO"<<endl;
                        return 0;
                }
        }
        cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> n;

  FOR(i, 1, n + 1) {
	if (i % 2 == 0) continue;
	cnt = 0;
	FOR(j, 1, i + 1) {
	  if (i%j == 0) cnt++;
	}
	if (cnt == 8) ans++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<algorithm>
typedef long long int64;
inline int64 getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int64 x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
const int N=3e5+1,mod=998244353;
int fac[N],ifac[N];
void exgcd(const int &a,const int &b,int &x,int &y) {
    if(!b) {
        x=1,y=0;
        return;
    }
    exgcd(b,a%b,y,x);
    y-=a/b*x;
}
inline int inv(const int &x) {
    int ret,tmp;
    exgcd(x,mod,ret,tmp);
    return (ret%mod+mod)%mod;
}
inline int power(int a,int k) {
    int ret=1;
    for(;k;k>>=1) {
        if(k&1) ret=(int64)ret*a%mod;
        a=(int64)a*a%mod;
    }
    return ret;
}
inline int C(const int &n,const int &m) {
    return (int64)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    int n=getint(),a=getint(),b=getint();
    int64 k=getint();
    for(register int i=fac[0]=1;i<=n;i++) {
        fac[i]=(int64)fac[i-1]*i%mod;
    }
    ifac[n]=inv(fac[n]);
    for(register int i=n;i>=1;i--) {
        ifac[i-1]=(int64)ifac[i]*i%mod;
    }
    int ans=0;
    for(register int i=0;i<=n&&(int64)a*i<=k;i++) {
        if((k-(int64)a*i)%b!=0) continue;
        const int64 j=(k-(int64)a*i)/b;
        if(j>n) continue;
        (ans+=(int64)C(n,i)*C(n,j)%mod)%=mod;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		String str=sc.next();
		
		if(str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 23892
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main
{
    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    private static List<Long> factorize(long x) {
        List<Long> result = new ArrayList<>();
        result.add(1L);
        for (long i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                result.add(i);
                while (x % i == 0) {
                    x /= i;
                }
            }
        }
        if (x > 1) {
            result.add(x);
        }
        return result;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long gcd = gcd(a, b);
        System.out.println(factorize(gcd).size());
    }
}



Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long lsum[][] = new long[n][n]; // local sum:部分和
		for ( int c = 0; c < n; c++ ) {
			lsum[c][c] = in.nextInt();
			for ( int r = 0; r < c; r++ ) {
				lsum[r][c] = lsum[r][c - 1] + lsum[c][c];
			}
		}

		long cost[][] = new long[n][n]; // 累積コスト
		for ( int r = n - 2; 0 <= r; r-- ) {
			for ( int c = r + 1; c < n; c++ ) {
				Long min = Long.MAX_VALUE;
				for ( int i = r; i <= c - 1; i++ ) {
					if ( min > cost[r][i] + cost[i + 1][c] ) {
						min = cost[r][i] + cost[i + 1][c];
					}
				}
				cost[r][c] = min + lsum[r][c];
			}
		}

		System.out.println(cost[0][n - 1]);
		in.close();
	}
}

Measured memory_bytes: 92884