akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    if(N-M == 0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<=c){
    if(b>=c){
      printf("Yes");
    }else{
      printf("No");
    }
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n,ans=0;
vector<int>vec;
signed main(){
    cin>>n;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0)vec.push_back(n/i);
    }
    sort(vec.begin(),vec.end());
    while(vec[0]){
        vec[0]/=10;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String weeksday[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
        Scanner sc = new Scanner(System.in);
        String todays=sc.next();
        int i=0;
        int result=0;
        boolean x= false;
        if(todays.equals("SUN")){
            result=7;
        }else{
            while(x==false){
                if(todays.equals(weeksday[i])){
                    x=true;
                }
                i++;
            }
            result=7-i;
        }
        System.out.print(result);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
#define double long double
const double PI = acos(-1);
double d, l;
int n, b;
double p[10];
double h[10];

bool check(double Vx, double Vy, int pass) {
	for(int i = 0; i < n; i++) {
		if(i == pass) continue;
		double x = p[i] - l * (int)(p[i] / l);
		double y = -(1.0 / (2 * Vx * Vx)) * x * x + (Vy / Vx) * x;
		if(y < h[i]) return false;
	}
	return true;
}

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

	while(cin >> d >> n >> b) {
		for(int i = 0; i < n; i++) {
			cin >> p[i] >> h[i];
		}

		double ans = 1e9;
		for(int i = 0; i <= b; i++) {
			l = d / (i + 1);
			double V = sqrt(l / 2);
			if(check(V, V, -1)) {
				ans = min(ans, V * sqrt(2));
			}
			for(int j = 0; j < n; j++) {
				double x = p[j] - l * (int)(p[j] / l);
				double y = h[j];
				double Vx = sqrt((l - x) * x / (2 * y));
				double Vy = l / (2 * Vx);
				//cout << Vx << " " << Vy << endl;
				//cout << -(x * x / (2 * Vx * Vx)) + Vy * x / Vx << endl;;
				if(check(Vx, Vy, j)) {
					ans = min(ans, sqrt(Vx * Vx + Vy * Vy));
				}
			}
		}

		cout << setprecision(15) << ans << endl;
	}
}

Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            var s = Console.ReadLine().Select(x => (int)x).ToList();
            s.Sort();
            // 文字列の入力
            var t = Console.ReadLine().Select(x => (int)x).ToList(); ;
            t.Sort();
            t.Reverse();

            var max = Math.Min(s.Count, t.Count);

            string result = "No";

            for (int i = 0; i < max; i++) {
                if(s[i] < t[i]) {
                    result = "Yes";
                    break;
                } else if (s[i] > t[i]) {
                    result = "No";
                    break;
                }

                if (i == max - 1) {
                    if(t.Count > s.Count) {
                        result = "Yes";
                    }
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13268
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    S = input().strip()
    T = input().strip()
    for i in range(len(T)):
        t = T[i:] + T[0:i]
        if t == S:
            print("Yes")
            return
    print("No")

main()


Measured memory_bytes: 2940
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_imports)]

extern crate proconio;
use proconio::marker::Usize1;
use proconio::{fastout, input};
use std::vec::*;

macro_rules! echo {
  {$x:expr} => {println!("{}", $x)}
}

macro_rules! chmax {
  {$x:expr, $y:expr} => {
    $x = std::cmp::max($x, $y)
  }
}

macro_rules! chmin {
  {$x:expr, $y:expr} => {
    $x = std::cmp::min($x, $y)
  }
}

#[allow(unused_variables)]
#[fastout]
fn main() {
  let d: usize;
  let t: usize;
  let s: usize;
  input! {
    d: usize,
    t: usize,
    s: usize,
  }
  echo!(if d <= t * s { "Yes" } else { "No" });
}


Measured memory_bytes: 2132
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool prime[2000000];
int gap[1300000];

int main(){
	rep(i,2000000)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,10000)for(int j=i*2;j<2000000;j+=i)prime[j]=false;
	rep(i,1300000)gap[i]=-1;
	int pre=2;
	loop(i,3,1300000){
		if(prime[i]){
			gap[i]=i-pre;
			pre=i;
		}
	}
	for(int i=1300000-1;i>=2;i--){
		if(gap[i]==-1)gap[i]=pre;
		else{
			pre=gap[i];
			gap[i]=0;
		}
	}
	gap[2]=gap[1]=gap[0]=0;
	int k;
	while(cin>>k,k)cout<<gap[k]<<endl;
	return 0;
}

Measured memory_bytes: 10112
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static int tc=1;
    static String[] s;

    public static long[] ila(String[] s){
        long[] array=new long[s.length];
        for(int i=0;i<array.length;i++)
            array[i]=Long.parseLong(s[i]);
        return array;
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        tc=1;
        t:
        for(int z=1;z<=tc;z++){
        	int n = Integer.parseInt(br.readLine());
        	HashMap<Integer,Integer> hm=new HashMap<>();
        	String[] s=br.readLine().split(" ");
        	for(int i=0;i<n;i++){
        		int x = Integer.parseInt(s[i]);
        		if(hm.containsKey(x))
        			hm.put(x,hm.get(x)+1);
        		else
        			hm.put(x,1);
        	}
        	long ans = 0;
        	for(Map.Entry<Integer,Integer> x : hm.entrySet()){
        		int val = x.getValue();
        		if(val > 1 )
        		ans += ((long)val * (val - 1))>>1;
        	}
        	long actual =0;
        	long calculate=0;
        	for(int i=0;i<n;i++){
        		int x = Integer.parseInt(s[i]);
        		int val = hm.get(x);
        		if(val==1){
        		System.out.println(ans);
        		continue;
        		}
        		actual = ((long)val * (val - 1))>>1;
        		if(val==2){
        		System.out.println(ans-actual);
        		continue;
        		}
        		calculate = ((long)(val-1) * (val - 2))>>1;
        		System.out.println(ans-actual+calculate);
        	}
        }
    }
}


Measured memory_bytes: 115328
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long n, std::vector<long long> v){
    map<ll, ll> mp1, mp2;
    for(ll i=0; i< n; i+=2){
        if(!mp1.count(v[i]))
            mp1[v[i]] = 1;
        else
        {
            mp1[v[i]] += 1;
        }
    }
    for(ll i=1; i< n; i+=2){
        if(!mp2.count(v[i]))
            mp2[v[i]] = 1;
        else
        {
            mp2[v[i]] += 1;
        }
    }
    vector<pll> vp1, vp2;
    for(auto it=mp1.begin(); it != mp1.end(); it ++){
        vp1.push_back(pll(it->second, it->first));
    }
    for(auto it=mp2.begin(); it != mp2.end(); it ++){
        vp2.push_back(pll(it->second, it->first));
    }
    sort(vp1.begin(), vp1.end());
    sort(vp2.begin(), vp2.end());
    reverse(vp1.begin(), vp1.end());
    reverse(vp2.begin(), vp2.end());
    if(vp1[0].second != vp2[0].second){
        cout << n - vp1[0].first - vp2[0].first << endl;
        return;
    }
    else{
        if(vp1.size()==1 && vp2.size()==1){
            cout << n - max(vp1[0].first, vp2[0].first)<<endl;
            return;
        }
        else{
            ll ans = INF;
            if(vp1.size()>1){
                ans = min(ans, n - vp1[1].first - vp2[0].first);
            }
            if(vp2.size()>1){
                ans = min(ans, n - vp1[0].first - vp2[1].first);
            }
            cout << ans << endl;
            return;
        }
    }
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> v(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&v[i]);
    }
    solve(n, std::move(v));
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  for (long i = 0; i <= x; i++) {
    if ((2 * i + 4 * (x - i)) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3608
#include<stdio.h>


int main(void){
    int a,b,t;
    int rest, biscuit=0, plustime=1;

    scanf("%d %d %d", &a, &b, &t);
    rest = t;
    while(rest >= a*plustime){
        biscuit += b;
        plustime ++;
    }
    printf("%d\n", biscuit);
    return 0;
}

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

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

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

int main() 
{
  ll N; cin>>N;
  ll G=1;
  rep(i,N)
  {
    ll T; cin>>T;
    G=lcm(T,G);
  }
  cout<<G<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >>d;
    ll ma = a *c;
    ma = max(ma,a*d);
    ma = max(ma,b*c);
    ma = max(ma,b*d);
    cout << ma << endl;
}

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

string s ;

void get(){ cin >> s ;}
void out(int n){ cout << n << '\n' << flush ;}

int main(){
	int n ; cin >> n ;
	out(0) ; get() ;
	if(s=="Vacant") return 0 ;
	string first = s ;
	int l,r,m ;
	l = 0 ;
	r = n-1 ;
	while(l+1<r){
		m = (l+r)/2 ;
		out(m) ; get() ;
		if(s=="Vacant") return 0 ;
		if(m&1){
			if(first==s) r = m ;
			else l = m ;
		}else{
			if(first!=s) r = m ;
			else l = m ;
		}
	}
	out(r) ; get() ;
	if(s=="Vacant") return 0 ;
}


Measured memory_bytes: 852
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    L = int(input())
    print((L/3)**3)


if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
#include <fstream>
#include <iostream>
#include <string>
#include <iterator>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
   int a,b,c;
   cin>>a>>b>>c;
   cout<<c<<" "<<a<<" "<<b<<endl;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const 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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }

ll f[200005];
ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; ++i) {
		ll to = n * i;
		to -= i * (i - 1) / 2;
		ll from = i * (i - 1) / 2;
		from %= MOD;
		ans += to-from + 1;
		ans %= MOD;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
int main(){
    int h,w;cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w,'.'));
    vector<vector<int>> ans1(h,vector<int>(w,0)),ans2(h,vector<int>(w,0));
    vector<vector<int>> ans(h,vector<int>(w,0));

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>a[i][j];
        }
    }

    for(i=0;i<h;i++){//行　右に行くにつれて加算
        for(j=0;j<w;j++){
            if(a[i][j]=='.'){
                if(j==0){ans1[i][j]++;}
                else{ans1[i][j]=ans1[i][j-1]+1;}
            }
        }
    }

    for(i=0;i<h;i++){//列　下に行くにつれて加算
        for(j=0;j<w;j++){
            if(a[i][j]=='.'){
                if(i==0){ans2[i][j]++;}
                else{ans2[i][j]=ans2[i-1][j]+1;}
            }
        }
    }

    for(i=h-2;i>=0;i--){//行のmaxを振り分ける(連続している区間の最大を分配)
        for(j=w-2;j>=0;j--){
            if(ans1[i][j]!=0 && ans1[i][j+1]!=0){ans1[i][j]=ans1[i][j+1];}
            if(ans2[i][j]!=0 && ans2[i+1][j]!=0){ans2[i][j]=ans2[i+1][j];}
        }
    }

    for(i=0;i<h;i++){//それぞれのマスに置いたときのlampが照らすマスの数
        for(j=0;j<w;j++){
            ans[i][j]=ans1[i][j]+ans2[i][j]-1;
        }
    }

    int maxi=0;

    for(i=0;i<h;i++){//max
        for(j=0;j<w;j++){
            maxi=max(maxi,ans[i][j]);
        }
    }

    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 51328
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a % b == 0){
    return b;
  }
  return gcd(b,a%b);
}

int main(){
  int K;
  int ans = 0;
  cin >> K;
  for(int i = 1;i <= K;i++){
    for(int j = 1;j <= K;j++){
      for(int k = 1;k <= K;k++){
        ans += gcd(i,gcd(j,k));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    Cout(a*b);
    return 0;
}


Measured memory_bytes: 3224
/*
AizuOnline A0080
Third Root
*/
#include <stdio.h>
#include <float.h>
#include <math.h>

main()
{
  long   q;
  double x;

     
  while(EOF != scanf("%ld",&q) && q != -1)
    {


	x=q/2;

      while(fabs(x*x*x-q) >= 1e-5*q)
        {   
	  x+=(q/x/x-x)/3;
        }
     
         printf("%f\n",x);
    }

return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
   char n;
   cin>>n;
   if(n>='a'&&n<='z')
    cout<<'a'<<nn;
   else
    cout<<"A"<<nn;



    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
using namespace std;
const int MaxN=1e5+5;

int main(){
	int n;
	long long L[100000];
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		if(i==0){
			L[i]=2;
		}
		if(i==1){
			L[i]=1;
		}
		if(i!=1&&i!=0){
			L[i]=L[i-1]+L[i-2];
		}
	}
	printf("%lld\n",L[n]);
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<tuple>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef pair<int, int> pii;

int p, q, a, n;
map<tuple<int, int, int, int, int>, int> memo;

int gcd(int a, int b) {
    if (a==0) return b;
    if (a>b) return gcd(b, a);

    return gcd(b%a, a);
}

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

pii subt(int n1, int d1, int n2, int d2) {
    int l = lcm(d1, d2);
    n1 *= l / d1;
    n2 *= l / d2;
    int s = n1-n2;

    if (s < 0) {
        return pii(s, l);
    } else {
        int g = gcd(s, l);
        return pii(s/g, l/g);
    }
}

int dfs(int nume, int deno, int prev, int mul, int n) {
    if (n<=0) return 0;
    
    auto itr = memo.find(make_tuple(nume, deno, prev, mul, n));
    if (itr != memo.end()) return memo[make_tuple(nume, deno, prev, mul, n)];

    int output = 0;
    for (int i=prev; i<=a/mul; i++) {
        pii ans = subt(nume, deno, 1, i);
        if (ans.first < 0) continue;
        if (ans.first == 0) {
            output += 1;
            continue;
        }

        pii exp = subt(nume, deno, n, i);
        if (exp.first > 0) break;
        if (ans.second / ans.first * i * mul > a) continue;
        
        output += dfs(ans.first, ans.second, i, mul*i, n-1);
    }
    return memo[make_tuple(nume, deno, prev, mul, n)] = output;
}

int main(){
    while(1){
        memo = map<tuple<int, int, int, int, int>, int>();
        
        cin >> p >> q >> a >> n;
        if(p==0) break;

        cout << dfs(p, q, 1, 1, n) << endl;
    }
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 2e5 + 7;
typedef long long LL;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

inline void NIE() {
	puts("-1");
	exit(0);
}

int n;
int f[maxN];

LL gao(int l, int r) {
	if (r < l) l = r;
	if (l == 0) return 0;
	if (f[r] == r-l) return gao(l, r-1);
	if (r - f[r] <= 0 || r - f[r] >= l) NIE();
	return f[r] + gao(r-f[r], r);
}

int main() {

	n = ri();
	rep (i, 1, n) f[i] = ri();
	printf("%lld\n", gao(n, n));

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,k=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<n; )
    {
       if(a[i]==a[i+1])
            i=i+2;
       else
       {
           k++;
           i++;
       }

    }
    printf("%d\n",k);
    return 0;

}
                      


Measured memory_bytes: 640
import java.util.Scanner;

/**
 * Created on 2016/08/13.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        for(int i=0; i<line.length(); i++){
            if(i+2 <= line.length()-1){
                if(line.charAt(i) == line.charAt(i+2)){
                    System.out.println((i+1) + " " + (i+3));
                    return;
                }
            }

            if(i+1 <= line.length()-1){
                if(line.charAt(i) == line.charAt(i+1)){
                    System.out.println((i+1) + " " + (i+2));
                    return;
                }
            }
        }

        System.out.println("-1 -1");
    }
}



Measured memory_bytes: 14120
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a<=9&&b<=9) printf("%d\n",a*b); else printf("-1\n");
    return(0);
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N;
    cin >> N;
    if(N%2 == 0)cout << N << endl;
    else cout << N*2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=0;
	ll q=n/(a+b);
	ans+=q*a;
	ll m=n-q*(a+b);
	if(n%(a+b))
	{
		ans+=min(m,a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long,long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int H,W; cin >> H >> W;
    vecveci A(H,veci(W));
    REP(i,H) REP(j,W) cin >> A[i][j];
    vector<tuple<int,int,int,int>> ans;
    for(int i = 0; i < H; i++) {
        if(i%2 == 0) {
            for(int j = 0; j < W; j++) {
                if(A[i][j]%2 == 0) continue;
                if(j != W-1) {
                    ans.push_back(make_tuple(i,j,i,j+1));
                    A[i][j]--;
                    A[i][j+1]++;
                } else {
                    if(i+1 < H) {
                        ans.push_back(make_tuple(i,j,i+1,j));
                        A[i][j]--;
                        A[i+1][j]++;
                    }
                }
            }
        } else {
            for(int j = W-1; j >= 0; --j) {
                if(A[i][j]%2 == 0) continue;
                if(j != 0) {
                    ans.push_back(make_tuple(i,j,i,j-1));
                    A[i][j]--;
                    A[i][j-1]++;
                } else {
                    if(i+1 < H) {
                        ans.push_back(make_tuple(i,j,i+1,j));
                        A[i][j]--;
                        A[i+1][j]++;
                    }
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans) {
        cout << get<0>(p)+1 << " " << get<1>(p)+1 << " " << get<2>(p)+1 << " "  << get<3>(p)+1 << endl;
    }
}


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

#define int long long
#define endl "\n"
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) rep(i,n)
#define repn(i,n) for(int i=n;i>=0;i--);

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

  int sum = 0;
  int ans = 0, hoge = 0;
  int n;

  cin>>n;

  for(int i = 1; ; i *= 3){ //cout<<i<<" "<<sum<<endl;

    sum += i + i*3;


    if(sum > n){
      //cout<<"hoge  "<<hoge<<endl;
      int con = 0;
      sum -= i*3 + i;
      //cout<<sum<<endl;
      int num =  n - sum;
      // cout<<n<<" "<<sum <<endl;
      //cout<<num<<endl;
                 int fuga = 1;

      while(num){

        if(fuga == i){
          // cout<<"fuga "<<fuga<<"num "<<num<<" con "<<con<<endl;
          con += num;

          break;
        }

        fuga *= 3;

        // cout<<"num "<<num<<" "<<num%3<<endl;
        con += num%3;
        num /= 3;
      }
                                       // cout<<"con "<<con<<endl;
      ans = con + hoge;
      break;
    }

    hoge += 2;
  }

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int dp[100010][3];

int main() {
	int N; cin >> N;
	vector<vector<int>> A(N, vector<int>(3));
	rep(i, N) rep(j, 3) cin >> A[i][j];

	// i日目にj番目の遊びをした時、max(i-1日目にk(≠j)の遊びをした満足度)
	// dp[i][0] = max(dp[i-1][1]+A[i][0], dp[i-1][2]+A[i][0]);

	rep(i, N) rep(j, 3) {
		int a = A[i][j];
		dp[i+1][j] = max(dp[i][(j+1)%3]+a, dp[i][(j+2)%3]+a);
		// 上記は配るDPの例
		// もし、貰うDPだと以下のようになる
		// if (i>0) dp[i][j] = max(dp[i-1][(j+1)%3]+a, dp[i-1][(j+2)%3]+a);
		// ※ if文がないとi==0のとき配列外参照になるのでif文が必要だが、こうすると、
		//    dp[1][j] が a[1][j]を使った一つ目の幸福度になってしまい、NG
		//    if文を除去すると（配列外参照にはなるが）a[0][j]に正しく値が埋め込まれるので、OK
	}

	// N-1でなく、N番目をみる
	cout << *max_element(dp[N], dp[N]+3) << endl;
}

Measured memory_bytes: 6912
from math import ceil

N = int(input())
p = [float(i) for i in input().split()]

# dp[i][j]: i枚を投げて、表がj枚だったときの確率
dp = [[0] * (N+1) for _ in range(N+1)]

# 初期条件
dp[0][0] = 1.0

# 配るDP
for i in range(N):
    for j in range(i+1):
        # 次のコイン(i+1)が表
        dp[i+1][j+1] += dp[i][j] * p[i]
        # 次のコイン(i+1)が裏
        dp[i+1][j] += dp[i][j] * (1-p[i])

answer = 0.0
for i in range(ceil(N/2),N+1):
    answer += dp[N][i]

print(answer)

Measured memory_bytes: 253960
import Control.Monad

main = do
  n <- read <$> getLine
  xs <- replicateM n $ map read . words <$> getLine
  putStrLn $ if solve ([0,0,0]:xs) then "Yes" else "No"

solve :: [[Int]] -> Bool
solve [a, b] = ispossible a b
solve (a:b:xs) = ispossible a b && solve (b:xs)

ispossible :: [Int] -> [Int] -> Bool
ispossible [t1, x1, y1] [t2, x2, y2] =
  dt >= dx + dy && mod (dt - dx - dy) 2 == 0
    where dt = abs $ t2 - t1
          dx = abs $ x2 - x1
          dy = abs $ y2 - y1


Measured memory_bytes: 81276
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main(int argc, char *argv[])
{
    std::vector<int> a, b;
    int n;

    std::cin >> n;

    a.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::copy(a.begin(), a.end(), std::back_inserter(b));
    std::sort(b.begin(), b.end());

    for (int i = 0; i < n; i++) {
        if (a[i] == b[n - 1]) {
            std::cout << b[n - 2] << std::endl;
        } else {
            std::cout << b[n - 1] << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>

  /* 配列の要素を交換する */
void Swap(long x[ ], long i, long j)
{
    long temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

void QSort(long x[ ], long left, long right)
{
    long i, j;
    long pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

int main()
{
	long N,i , X_copy[200000], X[200000],small_mid,big_mid;
	scanf("%ld",&N);
	for(i = 0;i<N;i++)
	{
		scanf("%ld",&X[i]);
		X_copy[i] = X[i];
	}
	
	QSort(X_copy,0,N-1);
	small_mid = X_copy[N/2-1];
	big_mid = X_copy[N/2];
	
	for(i=0;i<N;i++) printf("%ld\n", (X[i] <= small_mid)? big_mid:small_mid);
	
	return 0;
}


Measured memory_bytes: 5248
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

typedef long long ll;

int main(){
    vector<int>a(4);
    int b=0,c=0,d=0,e=0;
    for(int i=0;i<4;i++){
        cin>>a[i];
        if(a[i]==1){
            b++;
        }else if(a[i]==4){
            c++;
        }else if(a[i]==7){
            d++;
        }else if(a[i]==9){
            e++;
        }
    }
    if(b*c*d*e==1&&b+c+d+e==4){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
LR = [list(map(int,input().split())) for k in range(K)]

dp = (3*N)*[0]
dp[0] = 1
dp[1] = -1

for n in range(N):
  for L,R in LR:
    dp[L+n]+=dp[n]
    dp[n+R+1]-=dp[n]
  dp[n+1] = (dp[n]+dp[n+1])%998244353

print(dp[N-1])

Measured memory_bytes: 26036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  if (n / 100 == n % 10) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define abs(a) ((a)<0 ? -(a) : (a))

int main(){
  int dish[5];
  int k;
  for(int i=0; i<5; i++)
    scanf("%d", &dish[i]);
  scanf("%d", &k);
  for(int i=0; i<4; i++){
    for(int j=i+1; j<5; j++){
      if(abs(dish[i]-dish[j]) > k){
	printf(":(\n");
	return 0;
      }
    }
  }
  printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 128
// edpc_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> A(N), B(N), C(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    vector<vector<int>> dp;
    dp.assign(N+1, vector<int>(3, 0));

    REP(i, N){
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + A[i];
        dp[i+1][1] = max(dp[i][2], dp[i][0]) + B[i];
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + C[i];
    }

    print(max(max(dp[N][0], dp[N][1]), dp[N][2]));


    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    ll n, m, a, b;
    cin >> n >> m;
    map<P, ll> p;
    rep1(i, m){
        cin >> a >> b;
        a--, b--;
        p[make_pair(min(a, b), max(a, b))] = 1;
    }
    UnionFind tree(n);
    for (auto xy: p){
        tree.unite(xy.first.first, xy.first.second);
    }
    vector<ll> count(n);
    rep1(i, n){
        ll cnt = tree.root(i);
        count[cnt]++;
    }
    ll ans = 0;
    rep1(i, n) ans = max(ans, count[i]);
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 25088
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
using P = pair<lint, lint>;
#define MOD 1000000007

lint X, Y;


/*逆元導出*/
lint inv_mod(lint x, lint y){
  	lint a = x, b = y, u = 1, v = 0;
  	lint d;
  	while(b){
    	d = a / b;
      	a -= b * d; swap(a, b);
      	u -= v * d; swap(u, v);
    }
  
  	u %= y;
  	if(u < 0) u += y;
  	return u;
}



lint Comb(lint n, lint r){
  	if(n < 1) return 0;
  	lint res = 1, div = 1;
  	for(lint i = 0; i < r; i++){ 
      	res *= (n-i); res %= MOD;
      	div *= (i+1); div %= MOD;
    }
  	res = (res * inv_mod(div, MOD)) % MOD;
  	return res;
}



P identif_pos(lint x, lint y){
    lint a = (2*x-y)/3, b = (2*y-x)/3;  //a, bは各々の方法の使用回数
    if(a < 0 || b < 0 
       || 3*a != 2*x-y 
       || 3*b != 2*y-x) return {-1, -1};
    else return {a, b};
}


int main(){
    cin >> X >> Y;
  	P p = identif_pos(X, Y);
  	//cout << "a: " << p.first << " b: " << p.second << endl;
    cout << Comb(p.first+p.second, p.first) << endl;
    return 0;
}



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

int main() {
    int n;  cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++)cin >> blue[i];
    int m;  cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++)cin >> red[i];
 
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) 
            if (t == s) buf++;
        for (string t: red)
            if (t == s) buf--;
        return buf;
    };
 
    for (string t: blue)  ans = max(ans, calc(t));
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
int main()
{
  int n;
  cin >> n;
  int arr[n];
  for(int i=0;i<n;i++)
      cin >> arr[i];
  int flag = 0;
  for(int i=n-2;i>=0;i--)
  {
    if(arr[i]-1 > arr[i+1])
    {
      flag =1;
      break;
    }
    else if(arr[i]-1 == arr[i+1])
    {
      arr[i] = arr[i]-1;
    }

  }
  if(flag ==1)
    cout << "No" << endl;
  else
  cout << "Yes" << endl;
  return 0;
  } 

Measured memory_bytes: 640
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<Integer, Integer>map = new HashMap<Integer, Integer>();

		for (int i=0; i<N; i++){
			int a = sc.nextInt();
			for (int j=-1; j<=1; j++){
				int num = a + j;
				if (map.containsKey(num)){
					map.put(num, map.get(num) + 1);
				} else {
					map.put(num,1);
				}
			}
		}
		int ret=0;
		for (Map.Entry<Integer, Integer> entry : map.entrySet()){
			int value = entry.getValue();
			ret = Math.max(ret,value);
		}
		System.out.println(ret);
	}
}





Measured memory_bytes: 65700
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 100;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
int h, w;
int a[N];
int mp[110][110];
int id = 1;

int nt() {
    int ret = id;
    if (a[id] == 1)
        ++id;
    else
        --a[id];
    return ret;

}

int main() {
    int i, j;
    cin >> h >> w >> n;
    for (i = 1; i < n; ++i) {
        cin >> a[i];
    }
    int dir = 1;
    for (i = 0; i < h; ++i) {
        if (dir) {
            for (j = 0; j < w; ++j) {
                mp[i][j] = nt();
            }
        }
        else {
            for (j = w - 1; j >= 0; --j) {
                mp[i][j] = nt();
            }
        }
        dir ^= 1;
    }
    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
            cout << mp[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    {
        ll ans = 0;
        in(n);
        in(p);
        string s;
        cin >> s;
        vector<ll> cnt(p + 90);
        ll l = s.length();

        if (p == 2)
        {
            fw(i, 0, n)
            {
                if ((s[i] - '0') % 2 == 0)
                {
                    ans += i + 1;
                }
            }
        }
        else if (p == 5)
        {
            fw(i, 0, n)
            {
                if ((s[i] - '0') % 5 == 0)
                    ans += i + 1;
            }
        }
        else
        {
            ll suf = 0;
            cnt[suf]++;
            ll pot = 1;
            fb(i, l - 1, 0)
            {
                ll dig = s[i] - '0';
                suf = (suf + dig * pot) % p;
                pot = 10 * pot % p;
                ans += cnt[suf];
                cnt[suf]++;
            }
                }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3740
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program 
    {
        public static void Main (string[] args)
        {
            var rx = new Regex(@"\A(dream(er)?|eraser?)+\z", RegexOptions.ExplicitCapture);
            var S = Console.ReadLine();
            Console.WriteLine(rx.IsMatch(S) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 17752
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

vector<pair<ll, ll>> getFactor(ll n) {
    vector<pair<ll, ll>> result;
    for (ll i = 2; i * i <= n; i++) {
        ll num = 0;
        while (n % i == 0) {
            n /= i;
            num++;
        }
        if (num != 0) {
            result.push_back({ i, num });
        }
    }

    if (n != 1) {
        result.push_back({ n, 1 });
    }

    return result;
}

constexpr ll MOD = (ll)1e9 + 7;

ll POW(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

vector<ll> fact, inv_fact;

ll combination(ll n, ll m) {
    return fact[n] * inv_fact[n - m] % MOD * inv_fact[m] % MOD;
}

int main() {
    ll N, M;
    cin >> N >> M;

    constexpr ll MAX = (ll)1e6;
    fact.resize(MAX + 1, 1);
    inv_fact.resize(MAX + 1, 1);
    for (ll i = 2; i <= MAX; i++) {
        fact[i] = i * fact[i - 1] % MOD;
        inv_fact[i] = POW(fact[i], MOD - 2);
        assert(fact[i] * inv_fact[i] % MOD == 1);
    }

    auto factor = getFactor(M);
    ll ans = 1;
    for (auto p : factor) {
        ans *= combination(N - 1 + p.second, p.second);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define si set<ll>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
#define F first
#define S second
int main()
{
	fast
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans=0;
	for(int i=a;i<=b;i++)
	{
		if(i%c==0)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

  char last = N.back();

  if (last == '3') {
    cout << "bon" << endl;
  } else if (last == '0' || last == '1' || last == '6' || last == '8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
open Core

let s = Scanf.scanf "%s" ident

let rec solve s =
  if String.length s = 0 then true
  else
    match String.chop_suffix s "dream" with
    | Some sub ->
        solve sub
    | None -> (
      match String.chop_suffix s "dreamer" with
      | Some sub ->
          solve sub
      | None -> (
        match String.chop_suffix s "erase" with
        | Some sub ->
            solve sub
        | None -> (
          match String.chop_suffix s "eraser" with
          | Some sub ->
              solve sub
          | None ->
              false ) ) )

let str = if solve s then "YES\n" else "NO\n"

let () = print_endline str


Measured memory_bytes: 33536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

typedef long long ll;

const int maxn=1e5+10;

struct node{
	int a;
	int b;
}sum[maxn];

int cmp(node x,node y)
{
	return x.a<y.a;
}

int main(void)
{
	ll n,k;
	cin >> n >>k;
	for(int i=0;i<n;i++)
	{
		cin >> sum[i].a >> sum[i].b;
	}
	sort(sum,sum+n,cmp);
	ll num=0;
	for(int i=0;i<n;i++)
	{
		num+=sum[i].b;
		if(num>=k)
		{
			cout << sum[i].a << endl;
			break;
		}
	}
} 

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){

    int g[] = { 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
    int x, y;
    cin >> x >> y;

    cout << (g[x - 1] == g[y - 1] ? "Yes\n" : "No\n");
    return 0;
    
}

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

int main (){
	int n,i;
	long long a[100005],b[100005],x[100005],sum=0,s[100005]={0};
	cin >> n;
	for(i=1;i<=n;i++) {
		cin >> a[i];
		sum+=a[i];
	}
	for(i=1;i<=n;i++){
		if(2*i-1==n) b[i]=a[n];
		else b[i]=a[(2*i-1)%n];
	}
	b[0]=b[n];
	for(i=1;i<=(n-1)/2;i++){
			s[n]+=b[i];
			s[0]+=b[i];
			
	}
	for(i=1;i<n;i++){
		s[2*i%n]=s[2*(i-1)%n]+b[(i+(n-1)/2)%n]-b[i];
	}	
	sum=sum/2;
	for(i=1;i<=n;i++) {
		s[i]=sum-s[i];
		cout << 2*s[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
using namespace std;

int main(){
	int point, sum;
	
	sum = 0;
	for(int i = 0; i < 5; i++){
		scanf("%d", &point);
		
		sum += (point < 40)? 40 : point;
	}
	
	printf("%d\n", sum / 5);
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  //mapは特定の値にある値が紐ついているようなデータを扱うのに適している。
  //mpに対しては辞書順のとこに値をそのまま入れているので大丈夫
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx=0;
  for(auto p : mp) mx=max(mx,p.second);
  for(auto p : mp){
    if(p.second==mx){
      cout << p.first << endl;
    }
  }
}


Measured memory_bytes: 25216